112 |
|
|
113 |
void |
void |
114 |
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask, |
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask, |
115 |
struct ip_addr *gw) |
struct ip_addr *gw) |
116 |
{ |
{ |
117 |
netif_set_ipaddr(netif, ipaddr); |
netif_set_ipaddr(netif, ipaddr); |
118 |
netif_set_netmask(netif, netmask); |
netif_set_netmask(netif, netmask); |
131 |
/* look for netif further down the list */ |
/* look for netif further down the list */ |
132 |
struct netif * tmpNetif; |
struct netif * tmpNetif; |
133 |
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { |
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { |
134 |
if (tmpNetif->next == netif) { |
if (tmpNetif->next == netif) { |
135 |
tmpNetif->next = netif->next; |
tmpNetif->next = netif->next; |
136 |
break; |
break; |
137 |
} |
} |
138 |
} |
} |
139 |
if (tmpNetif == NULL) |
if (tmpNetif == NULL) |
140 |
return; /* we didn't find any netif today */ |
return; /* we didn't find any netif today */ |
141 |
} |
} |
142 |
/* this netif is default? */ |
/* this netif is default? */ |
143 |
if (netif_default == netif) |
if (netif_default == netif) |
211 |
#endif |
#endif |
212 |
ip_addr_set(&(netif->ip_addr), ipaddr); |
ip_addr_set(&(netif->ip_addr), ipaddr); |
213 |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %u.%u.%u.%u\n", |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %u.%u.%u.%u\n", |
214 |
netif->name[0], netif->name[1], |
netif->name[0], netif->name[1], |
215 |
(u8_t)(ntohl(netif->ip_addr.addr) >> 24 & 0xff), |
(u8_t)(ntohl(netif->ip_addr.addr) >> 24 & 0xff), |
216 |
(u8_t)(ntohl(netif->ip_addr.addr) >> 16 & 0xff), |
(u8_t)(ntohl(netif->ip_addr.addr) >> 16 & 0xff), |
217 |
(u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff), |
(u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff), |
223 |
{ |
{ |
224 |
ip_addr_set(&(netif->gw), gw); |
ip_addr_set(&(netif->gw), gw); |
225 |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %u.%u.%u.%u\n", |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %u.%u.%u.%u\n", |
226 |
netif->name[0], netif->name[1], |
netif->name[0], netif->name[1], |
227 |
(u8_t)(ntohl(netif->gw.addr) >> 24 & 0xff), |
(u8_t)(ntohl(netif->gw.addr) >> 24 & 0xff), |
228 |
(u8_t)(ntohl(netif->gw.addr) >> 16 & 0xff), |
(u8_t)(ntohl(netif->gw.addr) >> 16 & 0xff), |
229 |
(u8_t)(ntohl(netif->gw.addr) >> 8 & 0xff), |
(u8_t)(ntohl(netif->gw.addr) >> 8 & 0xff), |
230 |
(u8_t)(ntohl(netif->gw.addr) & 0xff))); |
(u8_t)(ntohl(netif->gw.addr) & 0xff))); |
231 |
} |
} |
232 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
233 |
void |
void |
235 |
{ |
{ |
236 |
ip_addr_set(&(netif->netmask), netmask); |
ip_addr_set(&(netif->netmask), netmask); |
237 |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %u.%u.%u.%u\n", |
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %u.%u.%u.%u\n", |
238 |
netif->name[0], netif->name[1], |
netif->name[0], netif->name[1], |
239 |
(u8_t)(ntohl(netif->netmask.addr) >> 24 & 0xff), |
(u8_t)(ntohl(netif->netmask.addr) >> 24 & 0xff), |
240 |
(u8_t)(ntohl(netif->netmask.addr) >> 16 & 0xff), |
(u8_t)(ntohl(netif->netmask.addr) >> 16 & 0xff), |
241 |
(u8_t)(ntohl(netif->netmask.addr) >> 8 & 0xff), |
(u8_t)(ntohl(netif->netmask.addr) >> 8 & 0xff), |
242 |
(u8_t)(ntohl(netif->netmask.addr) & 0xff))); |
(u8_t)(ntohl(netif->netmask.addr) & 0xff))); |
243 |
} |
} |
244 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
245 |
void |
void |
247 |
{ |
{ |
248 |
netif_default = netif; |
netif_default = netif; |
249 |
DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", |
DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", |
250 |
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); |
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); |
251 |
} |
} |
252 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
253 |
void |
void |