Example #1
0
/*****************************************************************************
 函 数 名  : uip_app_init
 功能描述  : the uip appliacation function
 输入参数  : void  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2017年4月17日
    作    者   : QSWWD
    修改内容   : 新生成函数

*****************************************************************************/
void uip_app_init(void)
{
	uip_ipaddr_t ipaddr;
	uip_ipaddr(ipaddr, 8,8,8,8);
	
	/*	hello_world_init();*/
	

	
	/*
	  resolv_init();
	  uip_ipaddr(ipaddr, 195,54,122,204);
	  resolv_conf(ipaddr);
	  resolv_query("www.sics.se");*/

	example1_init();
	example2_init();
	telnetd_init();
	smtp_init();
	uip_ipaddr(ipaddr, 127,0,0,1);
	smtp_configure("localhost", ipaddr);
	SMTP_SEND("*****@*****.**", NULL, "*****@*****.**",
		  "Testing SMTP from uIP",
		  "Test message sent by uIP\r\n");	
	hello_world_init();
	httpd_init();
	
#if UIP_UDP
	my_udp8899_init();
	dhcpc_init(&uip_ethaddr,6);
	resolv_init();
    resolv_conf(ipaddr);
    resolv_query("www.baidu.com");	
#endif
}
Example #2
0
void init_tcpip_lwip_stack(void)
{
	extern void lwip_system_init(void);
	extern rt_err_t eth_system_device_init(void);

	/* register ethernetif device */
	eth_system_device_init();
	RT_APPS_INIT_DEBUG(("eth_system_device_init() succ!\n"));

	rt_hw_stm32_eth_init();
	RT_APPS_INIT_DEBUG(("func:%s, line:%u, eie:0x%x!\n", __FUNCTION__, __LINE__, enc28j60_read(EIE)));
	/* to assure Ethernet Phy work well */ //lihao
	//Ethernet_Security();
	RT_APPS_INIT_DEBUG(("func:%s, line:%u!\n", __FUNCTION__, __LINE__));

	/* re-init device driver */
	rt_device_init_all();
	RT_APPS_INIT_DEBUG(("func:%s, line:%u, eie:0x%x!\n", __FUNCTION__, __LINE__, enc28j60_read(EIE)));

	/* init lwip system */
	lwip_system_init();
	RT_APPS_INIT_LOG(("TCP/IP initialized, eie:0x%x!\n", enc28j60_read(EIE)));

	/* init net apps */
#if RT_USING_HTTPSERVER_RAW
	httpd_init();
#endif

#if RT_USING_TELNETD
	telnetd_init();
#endif
}
Example #3
0
/*******************************************************************************
** Name: WebTask_Enter
** Input:void
** Return: void
** Owner:zhuzhe
** Date: 2014.6.16
** Time: 17:03:04
*******************************************************************************/
_WEB_TASK_WEBTASK_READ_
COMMON API void WebTask_Enter(void)
{
    WEB_TASK_CTRL_BLOCK*  pWebTaskControlBlock;
    WEB_EVENT_CLASS TempWebEventItem;
    uint32 timeout;
    struct netif Netif;

    if ( gpstWebCtrlBlock != NULL)
    {
        //ethernetif_input(netif, buf, len);
        pWebTaskControlBlock = gpstWebCtrlBlock;

        WebHardInit();

        WebEthIntit();

        httpd_init();
		CGIInit();

       // WebDNS();
do_keepalive:
        while (1)
        {
            vTaskDelay(1000);
        }

    }
}
Example #4
0
/* This function initializes applications */
static void
apps_init()
{
#if LWIP_DNS_APP && LWIP_DNS
  /* wait until the netif is up (for dhcp, autoip or ppp) */
  sys_timeout(5000, dns_dorequest, NULL);
#endif /* LWIP_DNS_APP && LWIP_DNS */

#if LWIP_CHARGEN_APP && LWIP_SOCKET
  chargen_init();
#endif /* LWIP_CHARGEN_APP && LWIP_SOCKET */

#if LWIP_PING_APP && LWIP_RAW && LWIP_ICMP
  ping_init();
#endif /* LWIP_PING_APP && LWIP_RAW && LWIP_ICMP */

#if LWIP_NETBIOS_APP && LWIP_UDP
  netbios_init();
#endif /* LWIP_NETBIOS_APP && LWIP_UDP */

#if LWIP_HTTPD_APP && LWIP_TCP
#ifdef LWIP_HTTPD_APP_NETCONN
  http_server_netconn_init();
#else /* LWIP_HTTPD_APP_NETCONN */
  httpd_init();
#endif /* LWIP_HTTPD_APP_NETCONN */
#endif /* LWIP_HTTPD_APP && LWIP_TCP */

#if LWIP_NETIO_APP && LWIP_TCP
  netio_init();
#endif /* LWIP_NETIO_APP && LWIP_TCP */

#if LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP
  rtp_init();
#endif /* LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP */

#if LWIP_SNTP_APP && LWIP_SOCKET
  sntp_init();
#endif /* LWIP_SNTP_APP && LWIP_SOCKET */

#if LWIP_SHELL_APP && LWIP_NETCONN
  shell_init();
#endif /* LWIP_SHELL_APP && LWIP_NETCONN */
#if LWIP_TCPECHO_APP
#if LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN)
  tcpecho_init();
#else /* LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) */
  echo_init();
#endif
#endif /* LWIP_TCPECHO_APP && LWIP_NETCONN */
#if LWIP_UDPECHO_APP && LWIP_NETCONN
  udpecho_init();
#endif /* LWIP_UDPECHO_APP && LWIP_NETCONN */
#if LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET
  socket_examples_init();
#endif /* LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET */
#ifdef LWIP_APP_INIT
  LWIP_APP_INIT();
#endif
}
Example #5
0
/*! \brief create ethernet task, for ethernet management.
 *
 *  \param uxPriority   Input. priority for the task, it should be low
 *
 */
void init_ethernet(pcl_freq_param_t *param)
{
	static const gpio_map_t MACB_GPIO_MAP =
	{
		{EXTPHY_MACB_MDC_PIN,     EXTPHY_MACB_MDC_FUNCTION   },
		{EXTPHY_MACB_MDIO_PIN,    EXTPHY_MACB_MDIO_FUNCTION  },
		{EXTPHY_MACB_RXD_0_PIN,   EXTPHY_MACB_RXD_0_FUNCTION },
		{EXTPHY_MACB_TXD_0_PIN,   EXTPHY_MACB_TXD_0_FUNCTION },
		{EXTPHY_MACB_RXD_1_PIN,   EXTPHY_MACB_RXD_1_FUNCTION },
		{EXTPHY_MACB_TXD_1_PIN,   EXTPHY_MACB_TXD_1_FUNCTION },
		{EXTPHY_MACB_TX_EN_PIN,   EXTPHY_MACB_TX_EN_FUNCTION },
		{EXTPHY_MACB_RX_ER_PIN,   EXTPHY_MACB_RX_ER_FUNCTION },
		{EXTPHY_MACB_RX_DV_PIN,   EXTPHY_MACB_RX_DV_FUNCTION },
		{EXTPHY_MACB_TX_CLK_PIN,  EXTPHY_MACB_TX_CLK_FUNCTION}
	};

	// Assign GPIO to MACB
	gpio_enable_module(MACB_GPIO_MAP,
		sizeof(MACB_GPIO_MAP) / sizeof(MACB_GPIO_MAP[0]));

	/* Initialize timer for lwIP calls; generates interrupts every 1ms */
	init_timer(param->pba_f);

	/* Initialize lwIP. */
	lwip_init();

	/* Set hw and IP parameters, initialize MACB too */
	prvEthernetConfigureInterface(NULL);

#if defined(HTTP_RAW_USED)
	/* Bring up the web server */
	httpd_init();
#endif
}
Example #6
0
/*-----------------------------------------------------------------------------------*/
static void
tcpip_init_done(void *arg)
{
  ip4_addr_t ipaddr, netmask, gw;
  sys_sem_t *sem;
  sem = (sys_sem_t *)arg;

  IP4_ADDR(&gw, 192,168,1,1);
  IP4_ADDR(&ipaddr, 192,168,1,2);
  IP4_ADDR(&netmask, 255,255,255,0);

  netif_set_default(netif_add(&netif_unix, &ipaddr, &netmask, &gw, NULL, unixif_init_client,
			      tcpip_input));
  netif_set_up(&netif_unix);
#if LWIP_IPV6
  netif_create_ip6_linklocal_address(&netif_unix, 1);
#endif
  /*  netif_set_default(netif_add(&ipaddr, &netmask, &gw, NULL, sioslipif_init1,
			      tcpip_input)); */

#if LWIP_NETCONN
  tcpecho_init();
  shell_init();
#if LWIP_IPV4 && LWIP_TCP
  httpd_init();
#endif
  udpecho_init();
#endif

  printf("Applications started.\n");

  sys_timeout(5000, tcp_timeout, NULL);

  sys_sem_signal(sem);
}
Example #7
0
void vBasicWEBServer( void *pvParameters )
{
struct ip_addr xIpAddr, xNetMast, xGateway;
extern err_t ethernetif_init( struct netif *netif );

    /* Parameters are not used - suppress compiler error. */
    ( void ) pvParameters;

    /* Create and configure the EMAC interface. */
    IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
    IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
    IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
    netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );

    /* make it the default interface */
    netif_set_default( &EMAC_if );

    /* bring it up */
    netif_set_up(&EMAC_if);

    /* Initialize HTTP */
    httpd_init();

	/* Nothing else to do.  No point hanging around. */
	vTaskDelete( NULL );
}
Example #8
0
/* Called from the TCP/IP thread. */
void lwIPAppsInit( void *pvArgument )
{
ip_addr_t xIPAddr, xNetMask, xGateway;
extern err_t ethernetif_init( struct netif *xNetIf );
static struct netif xNetIf;

	( void ) pvArgument;

	/* Set up the network interface. */
	ip_addr_set_zero( &xGateway );
	ip_addr_set_zero( &xIPAddr );
	ip_addr_set_zero( &xNetMask );

	LWIP_PORT_INIT_GW(&xGateway);
	LWIP_PORT_INIT_IPADDR(&xIPAddr);
	LWIP_PORT_INIT_NETMASK(&xNetMask);

	netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway, NULL, ethernetif_init, tcpip_input ) );
	netif_set_up( &xNetIf );

	/* Initialise the raw http server. */
	httpd_init();

	/* Install the server side include handler. */
	http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );
}
Example #9
0
int main(void) {
  cpu_init();
  uart_init();
  systick_init();
  AdsPinConfig();
  spi_init();

  init_ethernet();

  httpd_init();



  last_arp_time = last_tcp_time = 0;

  while(1) {
    //MAP_SysCtlSleep();

    task_lwip();
    task_enc();
    task_ads();

  }

  return 0;
}
Example #10
0
void uip_sys_init(void)
{    
    struct rt_device *eth_dev;
    uip_ipaddr_t ipaddr;

    uip_init();   

    httpd_init();  
    /*#if   HELLO_WORLD
      hello_world_init();
#elif TELNETD
telnetd_init();
#elif WEBSERVER
httpd_init();
printf("httpd_init\n\n");
#elif WEBCLIENT
webclient_init();
resolv_init();
uip_ipaddr(ipaddr, 202,96,128,166);  //set DNS server 
resolv_conf(ipaddr);
resolv_query("www.rt-thread.org");
#else
uip_listen(HTONS(1234));
uip_ipaddr(ipaddr, 192,168,2,244);
uip_connect(&ipaddr, HTONS(5678)); 
#endif
     */
    eth_dev = rt_device_find("e0");
    RT_ASSERT(eth_dev != RT_NULL);

    return;
}
Example #11
0
void
webserver_init(void)
{
  httpd_init();

  httpd_group_add(&main_group);
  httpd_group_add(&sensors_group);
  httpd_group_add(&status_group);
  httpd_group_add(&config_group);
  httpd_group_add(&statistics_group);
  httpd_group_add(&admin_group);

  httpd_group_add_page(&main_group, &webserver_main);
#if CETIC_NODE_INFO
  httpd_group_add_page(&sensors_group, &webserver_sensors_info);
  httpd_cgi_add(&webserver_sensor);
  httpd_group_add_page(&sensors_group, &webserver_sensors_tree);
  httpd_group_add_page(&sensors_group, &webserver_sensors_prr);
  httpd_group_add_page(&sensors_group, &webserver_sensors_ps);
  httpd_group_add_page(&sensors_group, &webserver_sensors_hc);
  httpd_cgi_command_add(&webserver_sensors_reset_stats_all_cmd);
  httpd_cgi_command_add(&webserver_sensor_reset_stats_cmd);
  httpd_cgi_command_add(&webserver_sensor_delete_node_cmd);
#endif
#if CETIC_NODE_CONFIG
  httpd_group_add_page(&sensors_group, &webserver_sensors_config);
#endif
  httpd_group_add_page(&status_group, &webserver_network);
#if UIP_CONF_IPV6_RPL
  httpd_group_add_page(&status_group, &webserver_rpl);
#endif
  httpd_group_add_page(&config_group, &webserver_config);
  httpd_group_add_page(&statistics_group, &webserver_statistics);
  if ((nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) {
#if UIP_CONF_IPV6_RPL
    httpd_cgi_command_add(&webserver_rpl_gr_cmd);
    httpd_cgi_command_add(&webserver_rpl_reset_cmd);
    httpd_cgi_command_add(&webserver_rpl_child_cmd);
#endif
    httpd_cgi_command_add(&webserver_network_route_add_cmd);
    httpd_cgi_command_add(&webserver_network_route_rm_cmd);
    httpd_cgi_command_add(&webserver_network_nbr_rm_cmd);
    httpd_cgi_command_add(&webserver_config_set_cmd);
    httpd_cgi_command_add(&webserver_config_reset_cmd);
    httpd_group_add_page(&admin_group, &webserver_admin);
    httpd_cgi_command_add(&webserver_admin_restart_cmd);
#if CONTIKI_TARGET_NATIVE
#if !CETIC_6LBR_ONE_ITF
    httpd_cgi_command_add(&webserver_admin_reset_slip_radio_cmd);
#endif
    httpd_cgi_command_add(&webserver_admin_reboot_cmd);
    httpd_cgi_command_add(&webserver_admin_halt_cmd);
    httpd_cgi_add(&webserver_log_send_log);
    httpd_cgi_add(&webserver_log_send_err);
    httpd_cgi_command_add(&webserver_log_clear_log_cmd);
    httpd_group_add_page(&admin_group, &webserver_plugins);
#endif
  }
}
Example #12
0
int
main (int argc, char **argv)
{
	int port;
	fd_set rset;
	int maxfd;
	struct listen_sock *lp;
	struct timeval tv;
	struct connection *cp;

	connections.next = &connections;
	connections.prev = &connections;

	for (port = 8000; port < 8100; port++) {
		if (httpd_init(port) >= 0) {
			printf ("listing on port %d\n", port);
			break;
		}
	}

	while (1) {
		FD_ZERO (&rset);

		maxfd = 0;
		for (lp = listen_socks; lp; lp = lp->next) {
			FD_SET (lp->sock, &rset);
			if (lp->sock > maxfd)
				maxfd = lp->sock;
		}

		for (cp = connections.next; cp != &connections; cp = cp->next) {
			if (cp->dead)
				continue;

			FD_SET (cp->sock, &rset);
			if (cp->sock > maxfd)
				maxfd = cp->sock;
		}

		tv.tv_sec = 0;
		tv.tv_sec = 100 * 1000;

		select (maxfd + 1, &rset, NULL, NULL, &tv);

		for (lp = listen_socks; lp; lp = lp->next) {
			if (FD_ISSET (lp->sock, &rset)) {
				accept_connection (lp);
			}
		}

		for (cp = connections.next; cp != &connections; cp = cp->next) {
			if (FD_ISSET (cp->sock, &rset)) {
				process_input (cp);
			}
		}
	}

	exit (0);
}
Example #13
0
void 
main(void)
{
  struct netif netif;

  lwip_init();

  netif_add(&netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY, NULL, netif_init, netif_input);
  netif.name[0] = 'e';
  netif.name[1] = '0';
  netif_create_ip6_linklocal_address(&netif, 1);
  netif.ip6_autoconfig_enabled = 1;
  netif_set_status_callback(&netif, netif_status_callback);
  netif_set_default(&netif);
  netif_set_up(&netif);
  
  /* Start DHCP and HTTPD */
  dhcp_start(&netif );
  httpd_init();

  while(1) {
    /* Check link state, e.g. via MDIO communication with PHY */
    if(link_state_changed()) {
      if(link_is_up()) {
        netif_set_link_up(&netif);
      } else {
        netif_set_link_down(&netif);
      }
    }

    /* Check for received frames, feed them to lwIP */
    lock_interrupts();
    struct pbuf* p = queue_try_get(&queue);
    unlock_interrupts();

    if(p != NULL) {
      LINK_STATS_INC(link.recv);
 
      /* Update SNMP stats (only if you use SNMP) */
      MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
      int unicast = ((p->payload[0] & 0x01) == 0);
      if (unicast) {
        MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
      } else {
        MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
      }

      if(netif.input(p, &netif) != ERR_OK) {
        pbuf_free(p);
      }
    }
     
    /* Cyclic lwIP timers check */
    sys_check_timeouts();
     
    /* your application goes here */
  }
}
Example #14
0
/**
 * \brief Inicializa os servicos disponiveis pela camada mult.
 */
void services_init(void){
	CHAT_PORT = 5555; //inicializa o chat com uma porta default. que será alterada de acordo com a def do chat.
	global_chat_flag = 0; //chat começa desabilitado, só é habilitado pela cli.
	telnetd_init(); //telnet faz comunicação através da porta 23
	httpd_init(); //http faz comunicação através da porta 80.
	chat_init();	//porta inicial, ela será alterada de acordo com o chat.
	//ftp_init();		//inicializa serviço de ftp
	sftd_init();
}
Example #15
0
/* Called from the TCP/IP thread. */
void lwIPAppsInit( void *pvArgument )
{
ip_addr_t xIPAddr, xNetMask, xGateway;
extern err_t xemacpsif_init( struct netif *netif );
extern void xemacif_input_thread( void *netif );
static struct netif xNetIf;

	( void ) pvArgument;

	/* Set up the network interface. */
	ip_addr_set_zero( &xGateway );
	ip_addr_set_zero( &xIPAddr );
	ip_addr_set_zero( &xNetMask );

	LWIP_PORT_INIT_GW(&xGateway);
	LWIP_PORT_INIT_IPADDR( &xIPAddr );
	LWIP_PORT_INIT_NETMASK(&xNetMask);

	/* Set mac address */
	xNetIf.hwaddr_len = 6;
	xNetIf.hwaddr[ 0 ] = configMAC_ADDR0;
	xNetIf.hwaddr[ 1 ] = configMAC_ADDR1;
	xNetIf.hwaddr[ 2 ] = configMAC_ADDR2;
	xNetIf.hwaddr[ 3 ] = configMAC_ADDR3;
	xNetIf.hwaddr[ 4 ] = configMAC_ADDR4;
	xNetIf.hwaddr[ 5 ] = configMAC_ADDR5;

	netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway, ( void * ) XPAR_XEMACPS_0_BASEADDR, xemacpsif_init, tcpip_input ) );
	netif_set_status_callback( &xNetIf, vStatusCallback );
	#if LWIP_DHCP
	{
		dhcp_start( &xNetIf );
	}
	#else
	{
		netif_set_up( &xNetIf );
	}
	#endif

	/* Install the server side include handler. */
	http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );

	/* Create the mutex used to ensure mutual exclusive access to the Tx 
	buffer. */
	xTxBufferMutex = xSemaphoreCreateMutex();
	configASSERT( xTxBufferMutex );

	/* Create the httpd server from the standard lwIP code.  This demonstrates
	use of the lwIP raw API. */
	httpd_init();

	sys_thread_new( "lwIP_In", xemacif_input_thread, &xNetIf, configMINIMAL_STACK_SIZE, configMAC_INPUT_TASK_PRIORITY );

	/* Create the FreeRTOS defined basic command server.  This demonstrates use
	of the lwIP sockets API. */
	xTaskCreate( vBasicSocketsCommandInterpreterTask, "CmdInt", configMINIMAL_STACK_SIZE * 5, NULL, configCLI_TASK_PRIORITY, NULL );
}
Example #16
0
static void
init_netifs(void)
{
#if PPP_SUPPORT
  pppInit();
#if PPP_PTY_TEST
  ppp_sio = sio_open(2);
#else
  ppp_sio = sio_open(0);
#endif
  if(!ppp_sio)
  {
      perror("Error opening device: ");
      exit(1);
  }

#ifdef LWIP_PPP_CHAP_TEST
  pppSetAuth(PPPAUTHTYPE_CHAP, "lwip", "mysecret");
#endif

  pppOpen(ppp_sio, pppLinkStatusCallback, NULL);
#endif /* PPP_SUPPORT */
  
#if LWIP_DHCP
  {
    IP4_ADDR(&gw, 0,0,0,0);
    IP4_ADDR(&ipaddr, 0,0,0,0);
    IP4_ADDR(&netmask, 0,0,0,0);

    netif_add(&netif, &ipaddr, &netmask, &gw, NULL, tapif_init,
              tcpip_input);
    netif_set_default(&netif);
    dhcp_start(&netif);
  }
#else
  
  netif_set_default(netif_add(&netif,&ipaddr, &netmask, &gw, NULL, tapif_init,
                  tcpip_input));
  netif_set_up(&netif);

#endif

#if 0
  /* Only used for testing purposes: */
  netif_add(&ipaddr, &netmask, &gw, NULL, pcapif_init, tcpip_input);
#endif
  
#if LWIP_TCP  
  //tcpecho_init();
  //shell_init();
  httpd_init();
#endif
#if LWIP_UDP  
  //udpecho_init();
#endif  
  /*  sys_timeout(5000, tcp_debug_timeout, NULL);*/
}
Example #17
0
int webserver_start(void)
{
	struct httpd * httpd;

	httpd = httpd_alloc();

	httpd_init(httpd, 80, 4, httpd_dir, NULL);

	return thinkos_thread_create_inf((void *)http_server_task,
			(void *)httpd, &httpd_inf);
}
Example #18
0
/*******************************************************************************
** Name: WebHttpd
** Input:void
** Return: void
** Owner:zhuzhe
** Date: 2014.6.25
** Time: 15:35:53
*******************************************************************************/
_WEB_TASK_WEBTASK_READ_
COMMON FUN void WebHttpd(void)
{
#if LWIP_HTTPD
    {
        httpd_init();
        CGIInit();
        rk_printf("httpd init success\n");
    }
#endif
}
/*..........................................................................*/
QState LwIPMgr_initial(LwIPMgr *me, QEvent const *e) {
    uint8_t  macaddr[NETIF_MAX_HWADDR_LEN];

    (void)e;        /* suppress the compiler warning about unused parameter */

    /* Configure the hardware MAC address for the Ethernet Controller */

    /*
     * Set up the MAC address and make sure it's not all FF values
     * TODO: This will evetually be read somewhere
     */

    /* the MAC address must have been programmed! */
    Q_ASSERT((STATIC_IPADDR0 != 0xFF) &&
    		 (STATIC_IPADDR1 != 0xFF) &&
    		 (STATIC_IPADDR2 != 0xFF) &&
    		 (STATIC_IPADDR3 != 0xFF));

    macaddr[0] = DEF_MAC_ADDR0;
    macaddr[1] = DEF_MAC_ADDR1;
    macaddr[2] = DEF_MAC_ADDR2;
    macaddr[3] = DEF_MAC_ADDR3;
    macaddr[4] = DEF_MAC_ADDR4;
    macaddr[5] = DEF_MAC_ADDR5;

                                          /* initialize the Ethernet Driver */
    me->netif = eth_driver_init((QActive *)me, macaddr);

    me->ip_addr = 0xFFFFFFFF;             /* initialize to impossible value */

                                     /* initialize the lwIP applications... */
    httpd_init();         /* initialize the simple HTTP-Deamon (web server) */
    http_set_ssi_handler(&ssi_handler, ssi_tags, Q_DIM(ssi_tags));
    http_set_cgi_handlers(cgi_handlers, Q_DIM(cgi_handlers));

    me->upcb = udp_new();
    udp_bind(me->upcb, IP_ADDR_ANY, 777);           /* use port 777 for UDP */
    udp_recv(me->upcb, &udp_rx_handler, me);

    QS_OBJ_DICTIONARY(&l_lwIPMgr);
    QS_OBJ_DICTIONARY(&l_lwIPMgr.te_LWIP_SLOW_TICK);
    QS_FUN_DICTIONARY(&QHsm_top);
    QS_FUN_DICTIONARY(&LwIPMgr_initial);
    QS_FUN_DICTIONARY(&LwIPMgr_running);

    QS_SIG_DICTIONARY(SEND_UDP_SIG,       (QActive *)me);
    QS_SIG_DICTIONARY(LWIP_SLOW_TICK_SIG, (QActive *)me);
    QS_SIG_DICTIONARY(LWIP_RX_READY_SIG,  (QActive *)me);
    QS_SIG_DICTIONARY(LWIP_TX_READY_SIG,  (QActive *)me);
    QS_SIG_DICTIONARY(LWIP_RX_OVERRUN_SIG,(QActive *)me);

    return Q_TRAN(&LwIPMgr_running);
}
Example #20
0
PROCESS_THREAD(webserver_nogui_process, ev, data)
{
  PROCESS_BEGIN();

  httpd_init();

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
    httpd_appcall(data);
  }

  PROCESS_END();
}
Example #21
0
void Network::Spin()
{
	if (active)
	{
//		++inLwip;
		ethernet_task();			// keep the Ethernet running
//		--inLwip;

		// See if we can send anything
		RequestState* r = writingTransactions;
		if (r != NULL)
		{
			bool finished = r->Send();

			// Disable interrupts while we mess around with the lists in case we get a callback from a network ISR
			irqflags_t flags = cpu_irq_save();
			writingTransactions = r->next;

			if (finished)
			{
				RequestState *rn = r->nextWrite;
				r->nextWrite = NULL;
				HttpState *hs = r->hs;
				AppendTransaction(&freeTransactions, r);
				if (rn != NULL)
				{
					if (hs != NULL)
					{
						hs->sendingRs = (rn->hs == hs) ? rn : NULL;
					}
					AppendTransaction(&writingTransactions, rn);
				}
				else if (hs != NULL)
				{
					hs->sendingRs = NULL;
				}
			}
			else
			{
				AppendTransaction(&writingTransactions, r);
			}
			cpu_irq_restore(flags);
		}
	}
	else if (establish_ethernet_link())
	{
		start_ethernet(reprap.GetPlatform()->IPAddress(), reprap.GetPlatform()->NetMask(), reprap.GetPlatform()->GateWay());
		httpd_init();
		active = true;
	}
}
Example #22
0
void httpd_task(void *pvParameters)
{
  xTaskCreate(battery_task, "Battery task", 256, NULL, uxTaskPriorityGet(NULL), NULL);

  tCGI pCGIs[] = {
    {"/pid", [](int, int, char*[], char*[]) { return "/pid.html"; }}
  };
  http_set_cgi_handlers(pCGIs, sizeof (pCGIs) / sizeof (pCGIs[0]));

  httpd_websocket_register_callbacks(NULL, (tWsHandler) httpd_websocket_cb);
  httpd_init();

  for (;;);
}
Example #23
0
int main(void) {
    struct http_state http;

    httpd_init(&http, 0);
    while (1) {
        char line[1024];
        int r = read(0, line, 1024);
        if (r < 0)
            break;
        httpd_receive(&http, line, r);
        if (http.state_server == HTTPD_SERVER_CLOSE)
            break;
    }
    return 0;
}
Example #24
0
/** initialize httpd server with default configuration
 * \param root_dir < root directory structure
 * \param index_page < pointer to index page with absolut path
 * \return pointer to created server structure
 */
HTTPD_STRUCT* httpd_server_init(HTTPD_ROOT_DIR_STRUCT *root_dir, const char *index_page) {
    HTTPD_STRUCT *server = NULL;
    HTTPD_PARAMS_STRUCT *params;
    
    HTTPD_ASSERT(root_dir && index_page);
    
    params = httpd_default_params(NULL);
    if (params) {
        params->root_dir = root_dir;
        params->index_page = (char*)index_page;
        server = httpd_init(params);
    }
    
    return server;
}
Example #25
0
int main(void)
{
	
	SystemInit();
	
	SSD1963_Init();

	SSD1963_Clear(Red);
	Delay(100);
	SSD1963_Clear(Blue);
	Delay(100);
	SSD1963_Clear(Red);
	SSD1963_Fill(0, 0, 50, 50, Blue);
	
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
	GUI_Init();
	GUI_SetColor(GUI_RED);
	GUI_Clear();
	
	BSP_KeyInit( BSP_KEY1, BSP_KEY1_GPIO_PORT );

	BSP_USART_Init( );
	
	BSP_SPI_Init( );
	BSP_SPI_CS_Init( );
	
	//Debug_ShowRegister( GPIOA_BASE, (DebugPeripheralTypedef *)&DeBugGPIO );
	//Debug_ShowRegister( BSP_USARTx_BASE, (DebugPeripheralTypedef *)&DeBugUART );
	//Debug_ShowRegister( RCC_BASE, (DebugPeripheralTypedef *)&DeBugRCC );
	//Debug_ShowSpecificRegister( RCC_BASE, (DebugPeripheralTypedef *)&DeBugRCC, "APB2ENR" );
	
  /* 初始化LWIP协议栈*/
	LwIP_Init(); 

	/*初始化web server 显示网页程序*/
	httpd_init();
  
  /* 初始化telnet   远程控制 程序 */   
  CMD_init();                                       

  /* Infinite loop */
  while ( 1 )
	{	
		/*轮询*/  
		LwIP_Periodic_Handle(LocalTime);		          	  
  }

}
/** \brief Create ethernet task, for ethernet management.
 *
 */
void init_ethernet(const unsigned char ipAddress[], const unsigned char netMask[], const unsigned char gateWay[])
{
	/* Initialize lwIP */
	lwip_init();

	/* Set hw and IP parameters, initialize MAC too */
	ethernet_configure_interface(ipAddress, netMask, gateWay);

	/* Init timer service */
	sys_init_timing();

#if defined(HTTP_RAW_USED)
	/* Bring up the web server */
	httpd_init();
#endif
}
Example #27
0
/** \brief Create ethernet task, for ethernet management.
 *
 */
void init_ethernet(void)
{
	/* Initialize lwIP */
	lwip_init();

	/* Set hw and IP parameters, initialize MAC too */
	ethernet_configure_interface();

	/* Init timer service */
	sys_init_timing();

#if defined(HTTP_RAW_USED)
	/* Bring up the web server */
	httpd_init();
#endif
}
Example #28
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /* Enable the CPU Cache */
    CPU_CACHE_Enable();

    /* STM32F7xx HAL library initialization:
         - Configure the Flash ART accelerator on ITCM interface
         - Configure the Systick to generate an interrupt each 1 msec
         - Set NVIC Group Priority to 4
         - Global MSP (MCU Support Package) initialization
       */
    HAL_Init();

    /* Configure the system clock to 200 MHz */
    SystemClock_Config();

    /* Configure the BSP */
    BSP_Config();

    /* Initialize the LwIP stack */
    lwip_init();

    /* Configure the Network interface */
    Netif_Config();

    /* Http webserver Init */
    httpd_init();

    /* Notify user about the network interface config */
    User_notification(&gnetif);

    /* Infinite loop */
    while (1)
    {
        /* Read a received packet from the Ethernet buffers and send it
           to the lwIP for handling */
        ethernetif_input(&gnetif);

        /* Handle timeouts */
        sys_check_timeouts();

#ifdef USE_DHCP
        /* handle periodic timers for DHCP */
        DHCP_Periodic_Handle(&gnetif);
#endif
    }
}
Example #29
0
static void setup_servers()
{
    if (webserver_enabled) {
        // Initialize the HTTP server, listen to port 80.
        httpd_init();
        printf("Webserver initialized\n");
    }

    if (telnet_enabled) {
        // Initialize the telnet server
        Telnetd::init();
        printf("Telnetd initialized\n");
    }

    // sftpd service, which is lazily created on reciept of first packet
    uip_listen(HTONS(115));
}
Example #30
0
static int core_plugins(struct agent_core_t *core)
{
	vping_init(core);
	logger_init(core);
	vadmin_init(core);
	httpd_init(core);
	echo_init(core);
	vstatus_init(core);
	vcl_init(core);
	html_init(core);
	vparams_init(core);
	vban_init(core);
	vstat_init(core);
	vlog_init(core);
	vcurl_init(core);
	vac_register_init(core);
	return 1;
}