Example #1
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 #2
0
//初始化ssi和cgi
void init_ssi_cgi(void){
	
 http_set_cgi_handlers(ppcURLs , NUM_CONFIG_CGI_URIS);	
 http_set_ssi_handler (SSIHandler, ppcTags, NUM_CONFIG_SSI_TAGS );


}
Example #3
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 );
}
/*..........................................................................*/
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 #5
0
/**
 *
 * Initialize IO and SSI Handlers
 *
 */
void io_init(void)
{

#ifdef INCLUDE_HTTPD_SSI
	//
	// Pass our tag information to the HTTP server.
	//
#if DEBUG_SSI
	printf("io_init NUM_CONFIG TAGS = %d\n", NUM_CONFIG_TAGS);
#endif
	http_set_ssi_handler(SSIHandler);
#endif

#ifdef INCLUDE_HTTPD_CGI
	//
	// Pass our CGI handlers to the HTTP server.
	//
	http_set_cgi_handlers(g_psConfigCGIURIs, NUM_CONFIG_CGI_URIS);
#endif
}
/*..........................................................................*/
QState LwIPMgr_initial(LwIPMgr *me, QEvt 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 */
    macaddr[0] = MAC_ADDR0;
    macaddr[1] = MAC_ADDR1;
    macaddr[2] = MAC_ADDR2;
    macaddr[3] = MAC_ADDR3;
    macaddr[4] = MAC_ADDR4;
    macaddr[5] = MAC_ADDR5;

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

    me->ip_addr = 0x00000000U;            /* 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, 777U);          /* 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_connecting);
}
Example #7
0
/*************************************************************************************************
 * ssi_init
 *
 * Initializes the Server Side Includes (SSI) for the creation of dynamic webpages
 */
void ssi_init(void)
{
	http_set_ssi_handler(&ssi_handle_tags, tags, number_of_tags);
}
Example #8
0
/**
 * Initialize SSI handlers
 */
void httpd_ssi_init(void)
{  
  /* configure SSI handlers (ADC page SSI) */
  http_set_ssi_handler(ADC_Handler, (char const **)TAGS, 1);
}