lwIP Wiki
 
(2 intermediate revisions by 2 users not shown)
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 */
 
#if NO_SYS
 
/* The lwIP single-threaded core: initialize the network stack */
 
 
[http://www.nongnu.org/lwip/init_8c.html lwip_init]();
 
[http://www.nongnu.org/lwip/init_8c.html lwip_init]();
#else
+
#else
/* lwIP in a multi-threaded system: initialize the network stack */
+
/* 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);
+
[http://www.nongnu.org/lwip/tcpip_8c.html#aa3df02b3de2b41fe4bf7b2194e5e8e0 tcpip_init](tcpip_init_done, tcpip_init_done_param);
/* implicitly calls lwip_init();
+
/* implicitly calls lwip_init();
start new thread
+
start new thread calls tcpip_init_done(tcpip_init_done_param);
calls tcpip_init_done(tcpip_init_done_param); when tcpip init done
+
when tcpip init done tcpip_init_done and tcpip_init_done_param are user-defined (may be NULL). */
tcpip_init_done and tcpip_init_done_param are user-defined (may be NULL). */
+
/* todo: wait for tcpip_init_done() ? */
/* todo: wait for tcpip_init_done() */
 
 
#endif
 
#endif
 
 
/* Bring up the network interface */
 
/* Bring up the network interface */
 
/* Hint: netif_init(); was already called by lwip_init(); above */
 
/* Hint: netif_init(); was already called by lwip_init(); above */
Line 34: Line 32:
   
 
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]].
 
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 <code>contrib/ports/unix/proj/</code> directory.[[category:LwIP Application Developers Manual]]
+
Complete working examples can be found in the <code>contrib/ports/unix/proj/</code> directory.
  +
[[category:LwIP Application Developers Manual]]

Latest revision as of 03:42, 20 June 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.