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 |
{ |
{ |
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); |
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 |
{ |
{ |
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 |