lwIP Wiki
Register
Advertisement

@todo: verify, extend

Take a look at doc/rawapi.txt for official information..

 #if NO_SYS
 /* Network interface variables */
 struct ip_addr ipaddr, netmask, gw;
 struct netif netif;
 /* Set network address variables */
 IP4_ADDR(&gw, 192,168,0,1);
 IP4_ADDR(&ipaddr, 192,168,0,2);
 IP4_ADDR(&netmask, 255,255,255,0);
 /* The lwIP single-threaded core: initialize the network stack */ 
 lwip_init();
 #else 
 /* lwIP in a multi-threaded system: initialize the network stack */ 
 tcpip_init(tcpip_init_done, tcpip_init_done_param); 
 /* implicitly calls lwip_init(); 
    start new thread calls tcpip_init_done(tcpip_init_done_param); 
    when tcpip init done tcpip_init_done and tcpip_init_done_param are user-defined (may be NULL). */
 /* todo: wait for tcpip_init_done() ? */ 
 #endif
 /* Bring up the network interface */
 /* Hint: netif_init(); was already called by lwip_init(); above */
 netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethhw_init, ethernet_input);
   /* ethhw_init() is user-defined */
   /* use ip_input instead of ethernet_input for non-ethernet hardware */
   /* (this function is assigned to netif.input and should be called by the hardware driver) */
 netif_set_default(&netif);
 netif_set_up(&netif);

For more info on tcpip_init see Initialization using tcpip.c. Details about bring up the network interface can be found at Network interfaces management. For what happens after initialization, you can continue to read at lwIP with or without an operating system. Complete working examples can be found in the contrib/ports/unix/proj/ directory.

Advertisement