lwIP Wiki
mNo edit summary
No edit summary
Line 1: Line 1:
 
@todo: verify, extend
 
@todo: verify, extend
   
Take a look at <code>doc/rawapi.txt</code> for official information.
+
Take a look at <code>doc/rawapi.txt</code> for official information..
  +
 
#if NO_SYS
   
 
/* Network interface variables */
 
/* Network interface variables */
Line 10: Line 12:
 
IP4_ADDR(&ipaddr, 192,168,0,2);
 
IP4_ADDR(&ipaddr, 192,168,0,2);
 
IP4_ADDR(&netmask, 255,255,255,0);
 
IP4_ADDR(&netmask, 255,255,255,0);
  +
/* The lwIP single-threaded core: initialize the network stack */ [http://www.nongnu.org/lwip/init_8c.html lwip_init](); #else /* lwIP in a multi-threaded system: initialize the network stack */ [http://www.nongnu.org/lwip/tcpip_8c.html#aa3df02b3de2b41fe4bf7b2194e5e8e0 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
 
#if NO_SYS
 
/* The lwIP single-threaded core: initialize the network stack */
 
[http://www.nongnu.org/lwip/init_8c.html lwip_init]();
 
#else
 
/* lwIP in a multi-threaded system: initialize the network stack */
 
[http://www.nongnu.org/lwip/tcpip_8c.html#aa3df02b3de2b41fe4bf7b2194e5e8e0 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 */
 
/* Bring up the network interface */

Revision as of 13:44, 22 February 2011

@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.