... more
                 
            
         
    
    
« Back to documentation index 
    
netif.c File Reference 
lwIP network interface abstraction  
More... 
Go to the source code of this file. 
static err_t  netif_loopif_init  (struct netif  *netif )  Initialize a lwip network interface structure for a loopback interface.   struct netif  *  netif_add  (struct netif  *netif , ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)  Add a network interface to the list of lwIP netifs.   void  netif_set_addr  (struct netif  *netif , ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)  Change IP address configuration for a network interface (including netmask and default gateway).   void  netif_remove  (struct netif  *netif )  Remove a network interface from the list of lwIP netifs.   struct netif  *  netif_find  (char *name)  Find a network interface by searching for its name.   void  netif_set_ipaddr  (struct netif  *netif , ip_addr_t *ipaddr)  Change the IP address of a network interface.   void  netif_set_gw  (struct netif  *netif , ip_addr_t *gw)  Change the default gateway for a network interface.   void  netif_set_netmask  (struct netif  *netif , ip_addr_t *netmask)  Change the netmask of a network interface.   void  netif_set_default  (struct netif  *netif )  Set a network interface as the default network interface (used to output all packets for which no specific route is found)   void  netif_set_up  (struct netif  *netif )  Bring an interface up, available for processing traffic.   void  netif_set_down  (struct netif  *netif )  Bring an interface down, disabling any traffic processing.   void  netif_set_status_callback  (struct netif  *netif , netif_status_callback_fn status_callback)  Set callback to be called when interface is brought up/down.   void  netif_set_link_up  (struct netif  *netif )  Called by a driver when its link goes up.   void  netif_set_link_down  (struct netif  *netif )  Called by a driver when its link goes down.   void  netif_set_link_callback  (struct netif  *netif , netif_status_callback_fn link_callback)  Set callback to be called when link is brought up/down.   err_t  netif_loop_output  (struct netif  *netif , struct pbuf *p, ip_addr_t *ipaddr)  Send an IP packet to be received on the same netif (loopif-like).   void  netif_poll  (struct netif  *netif )  Call netif_poll()  in the main loop of your application.   void  netif_poll_all  (void)  Calls netif_poll()  for every netif on the netif_list.   struct netif  *  netif_list   The list of network interfaces.   struct netif  *  netif_default   The default network interface.   
Detailed Description 
lwIP network interface abstraction 
Definition in file netif.c .
Function Documentation 
      
        
          struct netif * netif_add  
          ( 
          struct netif  *  
           netif ,  
         
        
          ip_addr_t *  
           ipaddr ,  
         
        
          ip_addr_t *  
           netmask ,  
         
        
          ip_addr_t *  
           gw ,  
         
        
          void *  
           state ,  
         
        
          netif_init_fn  
           init ,  
         
        
          netif_input_fn  
           input   
         
        
          ) 
           [read] 
      
 
Add a network interface to the list of lwIP netifs. 
Parameters: 
  
    netif a pre-allocated netif structure  ipaddr IP address for the new netif  netmask network mask for the new netif  gw default gateway IP address for the new netif  state opaque data passed to the new netif  init callback function that initializes the interface  input callback function that is called to pass ingress packets up in the protocol layer stack. 
   
Returns: netif, or NULL if failed.  Definition at line 137  of file netif.c .
 
 
      
        
          struct netif * netif_find  
          ( 
          char *  
           name  ) 
           [read] 
      
 
Find a network interface by searching for its name. 
Parameters: 
  
    name the name of the netif (like netif->name) plus concatenated number in ascii representation (e.g. 'en0')  
   
Definition at line 286  of file netif.c .
 
 
      
        
          err_t netif_loop_output  
          ( 
          struct netif  *  
           netif ,  
         
        
          struct pbuf *  
           p ,  
         
        
          ip_addr_t *  
           ipaddr   
         
        
          ) 
           
      
 
Send an IP packet to be received on the same netif (loopif-like). 
The pbuf is simply copied and handed back to netif->input. In multithreaded mode, this is done directly since netif->input must put the packet on a queue. In callback mode, the packet is put on an internal queue and is fed to netif->input by netif_poll() .
Parameters: 
  
    netif the lwip network interface structure  p the (IP) packet to 'send'  ipaddr the ip address to send the packet to (not used)  
   
Returns: ERR_OK if the packet has been sent ERR_MEM if the pbuf used to copy the packet couldn't be allocated  Definition at line 594  of file netif.c .
 
 
      
        
          static err_t netif_loopif_init  
          ( 
          struct netif  *  
           netif  ) 
           [static] 
      
 
Initialize a lwip network interface structure for a loopback interface. 
Parameters: 
  
    netif the lwip network interface structure for this loopif  
   
Returns: ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated  Definition at line 89  of file netif.c .
 
 
      
        
          void netif_poll  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
 
      
        
          void netif_poll_all  
          ( 
          void  
           ) 
           
      
 
 
      
        
          void netif_remove  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Remove a network interface from the list of lwIP netifs. 
Parameters: 
  
    netif the network interface to remove  
   
Definition at line 236  of file netif.c .
 
 
      
        
          void netif_set_addr  
          ( 
          struct netif  *  
           netif ,  
         
        
          ip_addr_t *  
           ipaddr ,  
         
        
          ip_addr_t *  
           netmask ,  
         
        
          ip_addr_t *  
           gw   
         
        
          ) 
           
      
 
Change IP address configuration for a network interface (including netmask and default gateway). 
Parameters: 
  
    netif the network interface to change  ipaddr the new IP address  netmask the new netmask  gw the new default gateway  
   
Definition at line 222  of file netif.c .
 
 
      
        
          void netif_set_default  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Set a network interface as the default network interface (used to output all packets for which no specific route is found) 
Parameters: 
  
    netif the default network interface  
   
Definition at line 432  of file netif.c .
 
 
      
        
          void netif_set_down  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Bring an interface down, disabling any traffic processing. 
Note: : Enabling DHCP on a down interface will make it come up once configured. See also: dhcp_start()  Definition at line 492  of file netif.c .
 
 
      
        
          void netif_set_gw  
          ( 
          struct netif  *  
           netif ,  
         
        
          ip_addr_t *  
           gw   
         
        
          ) 
           
      
 
Change the default gateway for a network interface. 
Parameters: 
  
    netif the network interface to change  gw the new default gateway 
   
Note: call netif_set_addr()  if you also want to change ip address and netmask  Definition at line 390  of file netif.c .
 
 
      
        
          void netif_set_ipaddr  
          ( 
          struct netif  *  
           netif ,  
         
        
          ip_addr_t *  
           ipaddr   
         
        
          ) 
           
      
 
Change the IP address of a network interface. 
Parameters: 
  
    netif the network interface to change  ipaddr the new IP address 
   
Note: call netif_set_addr()  if you also want to change netmask and default gateway  Definition at line 319  of file netif.c .
 
 
      
        
          void netif_set_link_callback  
          ( 
          struct netif  *  
           netif ,  
         
        
          netif_status_callback_fn  
           link_callback   
         
        
          ) 
           
      
 
Set callback to be called when link is brought up/down. 
Definition at line 570  of file netif.c .
 
 
      
        
          void netif_set_link_down  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Called by a driver when its link goes down. 
Definition at line 558  of file netif.c .
 
 
      
        
          void netif_set_link_up  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Called by a driver when its link goes up. 
Definition at line 519  of file netif.c .
 
 
      
        
          void netif_set_netmask  
          ( 
          struct netif  *  
           netif ,  
         
        
          ip_addr_t *  
           netmask   
         
        
          ) 
           
      
 
Change the netmask of a network interface. 
Parameters: 
  
    netif the network interface to change  netmask the new netmask 
   
Note: call netif_set_addr()  if you also want to change ip address and default gateway  Definition at line 411  of file netif.c .
 
 
      
        
          void netif_set_status_callback  
          ( 
          struct netif  *  
           netif ,  
         
        
          netif_status_callback_fn  
           status_callback   
         
        
          ) 
           
      
 
Set callback to be called when interface is brought up/down. 
Definition at line 508  of file netif.c .
 
 
      
        
          void netif_set_up  
          ( 
          struct netif  *  
           netif  ) 
           
      
 
Bring an interface up, available for processing traffic. 
Note: : Enabling DHCP on a down interface will make it come up once configured. See also: dhcp_start()  Definition at line 455  of file netif.c .
 
 
Variable Documentation 
The default network interface. 
Definition at line 76  of file netif.c .
 
 
The list of network interfaces. 
Definition at line 75  of file netif.c .