/[lwip]/lwip/doc/rawapi.txt
ViewVC logotype

Diff of /lwip/doc/rawapi.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by likewise, Sun Oct 17 21:28:25 2004 UTC revision 1.5 by christiaans, Wed Nov 2 08:08:06 2005 UTC
# Line 1  Line 1 
1  Raw TCP/IP interface for lwIP  Raw TCP/IP interface for lwIP
2    
3  Authors: Adam Dunkels, Leon Woestenberg  Authors: Adam Dunkels, Leon Woestenberg, Christiaan Simons
4    
5  lwIP provides two Application Program's Interfaces (APIs) for programs  lwIP provides two Application Program's Interfaces (APIs) for programs
6  to use for communication with the TCP/IP code:  to use for communication with the TCP/IP code:
# Line 289  level of complexity of UDP, the interfac Line 289  level of complexity of UDP, the interfac
289                                void *recv_arg)                                void *recv_arg)
290    
291    Specifies a callback function that should be called when a UDP    Specifies a callback function that should be called when a UDP
   datagram is received.  
292      datagram is received.
293      
294    
295    --- System initalization
296    
297    A truly complete and generic sequence for initializing the lwip stack
298    cannot be given because it depends on the build configuration (lwipopts.h)
299    and additional initializations for your runtime environment (e.g. timers).
300    
301    We can give you some idea on how to proceed when using the raw API.
302    We assume a configuration using a single Ethernet netif and the
303    UDP and TCP transport layers, IPv4 and the DHCP client.
304    
305    Call these functions in the order of appearance:
306    
307    - stats_init()
308    
309      Clears the structure where runtime statistics are gathered.
310    
311    - sys_init()
312      
313      Not of much use since we set the NO_SYS 1 option in lwipopts.h,
314      to be called for easy configuration changes.
315    
316    - mem_init()
317    
318      Initializes the dynamic memory heap defined by MEM_SIZE.
319    
320    - memp_init()
321    
322      Initializes the memory pools defined by MEMP_NUM_x.
323    
324    - pbuf_init()
325    
326      Initializes the pbuf memory pool defined by PBUF_POOL_SIZE.
327      
328    - etharp_init()
329    
330      Initializes the ARP table and queue.
331      Note: you must call etharp_tmr at a 10 second regular interval
332      after this initialization.
333    
334    - ip_init()
335    
336      Doesn't do much, it should be called to handle future changes.
337    
338    - udp_init()
339    
340      Clears the UDP PCB list.
341    
342    - tcp_init()
343    
344      Clears the TCP PCB list and clears some internal TCP timers.
345      Note: you must call tcp_fasttmr() and tcp_slowtmr() at the
346      predefined regular intervals after this initialization.
347      
348    - netif_add(struct netif *netif, struct ip_addr *ipaddr,
349                struct ip_addr *netmask, struct ip_addr *gw,
350                void *state, err_t (* init)(struct netif *netif),
351                err_t (* input)(struct pbuf *p, struct netif *netif))
352    
353      Adds your network interface to the netif_list. Allocate a struct
354      netif and pass a pointer to this structure as the first argument.
355      Give pointers to cleared ip_addr structures when using DHCP,
356      or fill them with sane numbers otherwise. The state pointer may be NULL.
357    
358      The init function pointer must point to a initialization function for
359      your ethernet netif interface. The following code illustrates it's use.
360      
361      err_t netif_if_init(struct netif *netif)
362      {
363        u8_t i;
364        
365        for(i = 0; i < 6; i++) netif->hwaddr[i] = some_eth_addr[i];
366        init_my_eth_device();
367        return ERR_OK;
368      }
369      
370      The input function pointer must point to the lwip ip_input().
371      
372    - netif_set_default(struct netif *netif)
373    
374      Registers the default network interface.
375    
376    - netif_set_up(struct netif *netif)
377    
378      When the netif is fully configured this function must be called.
379    
380    - dhcp_start(struct netif *netif)
381    
382      Creates a new DHCP client for this interface on the first call.
383      Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
384      the predefined regular intervals after starting the client.
385      
386      You can peek in the netif->dhcp struct for the actual DHCP status.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26