/[lwip]/lwip/src/core/netif.c
ViewVC logotype

Diff of /lwip/src/core/netif.c

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

revision 1.2 by likewise, Wed Jan 8 10:09:42 2003 UTC revision 1.3 by davidhaas, Thu Feb 6 22:18:56 2003 UTC
# Line 43  struct netif *netif_default = NULL; Line 43  struct netif *netif_default = NULL;
43  struct netif *  struct netif *
44  netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,  netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
45            struct ip_addr *gw,            struct ip_addr *gw,
46              void *state,
47            void (* init)(struct netif *netif),            void (* init)(struct netif *netif),
48            err_t (* input)(struct pbuf *p, struct netif *netif))            err_t (* input)(struct pbuf *p, struct netif *netif))
49  {  {
# Line 55  netif_add(struct ip_addr *ipaddr, struct Line 56  netif_add(struct ip_addr *ipaddr, struct
56      return NULL;      return NULL;
57    }    }
58        
59      netif->state = state;
60    netif->num = netifnum++;    netif->num = netifnum++;
61    netif->input = input;    netif->input = input;
62    ip_addr_set(&(netif->ip_addr), ipaddr);    ip_addr_set(&(netif->ip_addr), ipaddr);
# Line 78  netif_add(struct ip_addr *ipaddr, struct Line 80  netif_add(struct ip_addr *ipaddr, struct
80    return netif;    return netif;
81  }  }
82  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
83    void netif_remove(struct netif * netif)
84    {
85            if ( netif == NULL ) return;  
86    
87            /*  is it the first netif? */
88            if(netif_list == netif) {
89                    netif_list = netif->next;
90            }    
91            else
92            {      
93                    /*  look for netif further down the list */
94                    struct netif * tmpNetif;
95                    for(tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
96                            if(tmpNetif->next == netif) {
97                                    tmpNetif->next = netif->next;
98                                    break;
99                            }    
100                    }
101                    if(tmpNetif == NULL)
102                            return; /*  we didn't find any netif today */
103            }
104    
105            if(netif_default == netif)
106                    netif_default = NULL;
107    
108            DEBUGF(NETIF_DEBUG, ("netif_remove: removed netif"));
109            mem_free( netif );
110    }
111    
112    /*-----------------------------------------------------------------------------------*/
113  struct netif *  struct netif *
114  netif_find(char *name)  netif_find(char *name)
115  {  {
# Line 131  netif_set_default(struct netif *netif) Line 163  netif_set_default(struct netif *netif)
163  {  {
164    netif_default = netif;    netif_default = netif;
165    DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",    DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
166                         netif->name[0], netif->name[1]));                         netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
167  }  }
168  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
169  void  void

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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