#ifndef _aplmt_networking_lwip_startapi_h_ #define _aplmt_networking_lwip_startapi_h_ /*---------------------------------------------------------------------------- ** SUMMARY: APLMT lwIP Network Stack Initialization (LWIPINIT) ** ** DESCRIPTION: ** This file defines the interface for starting the lwIP network stack. ** ** lwIP: ** ---- ** What is lwIP? It is light weight TCP/IP stack. The following is a excerpt ** from the uIP project home page (http://savannah.nongnu.org/projects/lwip/): ** ** "The focus of the lwIP TCP/IP implementation is to reduce resource usage ** while still having a full scale TCP. This making lwIP suitable for use ** in embedded systems with tenths of kilobytes of free RAM and room for ** around 40 kilobytes of code ROM." ** ** If you haven't read the lwIP documentation, do so now. ** ** START-UP SEQUENCE: ** ------------------ ** Once the kernel and APL/APLMT is up and running: ** 1) Create & initialize all resources needed by the LWIPARCH ** interface. Note: Do not call sys_init(), this will be done ** internally. ** ** 2) Call AplmtLWIP_start(). During the initialization of the stack, ** the callback function, AplmtLWIP_cbAddNetworkInterfaces(), is ** called. ** ** 3) Use the callback funciton, AplmtLWIP_cbAddNetworkInterfaces(), to ** add one or more network adapaters. The following code snippet ** illustrates how to add a network device: ** ------------------------------------------------------------ ** struct netif myNetif0; // Must stay in scope for life of network interface ** struct AplmtLwipUnixEtherDev myEth0; // Must stay in scope for life of network interface ** struct netif myNetif1; // Must stay in scope for life of network interface ** struct AplmtLwipUnixEtherDev myEth1; // Must stay in scope for life of network interface ** ** void AplmtLWIP_cbAddNetworkInterfaces(void) ** { ** struct ip_addr ipaddr, netmask, gw; ** ** myEth0Hdl._devInit = AplmtLWIP_devUnixEtherInit; ** myEth0Hdl._devOutput = AplmtLWIP_devUnixEtherOutput; ** myEth0Hdl._devInput = AplmtLWIP_devUnixEtherInput; ** myEth0Hdl._ethaddrInit = 0; // Use the low-lever driver's default MAC address ** ** // Use a fixed IP address for adapter 0 ** IP4_ADDR(&gw, 192,168,0,1); ** IP4_ADDR(&ipaddr, 192,168,0,2); ** IP4_ADDR(&netmask, 255,255,255,0); ** ** netif_add( &myNetif, ** &ipaddr, &netmask, &gw, ** &myEth0Hdl, ** AplmtLWIP_etherifInit, ** ip_input ); // Note: Call ip_input() directly -->bypass ITC message wrapper func tcpip_input() ** netif_set_default(&myNetif); ** ** myEth1Hdl._devInit = AplmtLWIP_devSmsc91c96Eth0Initialize; ** myEth1Hdl._devOutput = AplmtLWIP_devSmsc91c96Eth0TransmitPacket; ** myEth1Hdl._devInput = AplmtLWIP_devSmsc91c96Eth0ReadPacket; ** myEth1Hdl._ethaddrInit = 0; // Use the low-lever driver's default MAC address ** ** // Use a DHCP for adapter 1 ** IP4_ADDR(&gw, 0,0,0,0); ** IP4_ADDR(&ipaddr, 0,0,0,0); ** IP4_ADDR(&netmask, 0,0,0,0); ** ** netif_add( &myNetif1, ** &ipaddr, &netmask, &gw, ** &myEth1, ** AplmtLWIP_etherifInit, ** ip_input ); // Note: Call ip_input() directly -->bypass ITC message wrapper func tcpip_input() ** dhcp_start(&myNetif1); ** } ** ** ** 4) Initialize network application(s). ** ** ** ** CONFIGURATION ** ------------- ** COMPILE: none. ** ** APPLICATION: none. ** ** PLATFORM: none. ** ** ** NOTES: ** 1. Unless explicitly stated otherwise, NONE of the following methods may be ** called from interrupt service routines. ** 2. Unless explicitly stated otherwise, NONE of the following methods may be ** called before the platform's kernel is running. ** 3. Unless explicitly stated otherwise, all of the following methods assume ** that interrupts are enabled at the time of the call. ----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /*-------------- PUBLIC/PUBLISHED API --------------------------------------*/ /** This method is used by initialize and start lwIP TCP/IP network stack. */ void AplmtLWIP_start(void); /** This method is used to add network interfaces to the network stack. The method is callback called during the stack start up process. IMPORTANT: This method is called/executed in the context of the network stack's thread. */ void AplmtLWIP_cbAddNetworkInterfaces(void); #ifdef __cplusplus } #endif /*--------------------------------------------------------------------------*/ #endif /* end _aplmt_networking_lwip_startapi_h_ */