mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
factor out netif_set_addr so address of netif can be changed
This commit is contained in:
parent
12228ea34d
commit
8613f2a48e
@ -70,10 +70,9 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
|||||||
netif->state = state;
|
netif->state = state;
|
||||||
netif->num = netifnum++;
|
netif->num = netifnum++;
|
||||||
netif->input = input;
|
netif->input = input;
|
||||||
ip_addr_set(&(netif->ip_addr), ipaddr);
|
|
||||||
ip_addr_set(&(netif->netmask), netmask);
|
|
||||||
ip_addr_set(&(netif->gw), gw);
|
|
||||||
|
|
||||||
|
netif_set_addr(netif, ipaddr, netmask, gw);
|
||||||
|
|
||||||
if (init(netif) != ERR_OK) {
|
if (init(netif) != ERR_OK) {
|
||||||
mem_free(netif);
|
mem_free(netif);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -93,6 +92,16 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
|||||||
#endif /* NETIF_DEBUG */
|
#endif /* NETIF_DEBUG */
|
||||||
return netif;
|
return netif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||||
|
struct ip_addr *gw)
|
||||||
|
{
|
||||||
|
netif_set_ipaddr(netif, ipaddr);
|
||||||
|
netif_set_netmask(netif, netmask);
|
||||||
|
netif_set_gw(netif, gw);
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void netif_remove(struct netif * netif)
|
void netif_remove(struct netif * netif)
|
||||||
{
|
{
|
||||||
|
@ -116,6 +116,9 @@ struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
|||||||
err_t (* init)(struct netif *netif),
|
err_t (* init)(struct netif *netif),
|
||||||
err_t (* input)(struct pbuf *p, struct netif *netif));
|
err_t (* input)(struct pbuf *p, struct netif *netif));
|
||||||
|
|
||||||
|
void
|
||||||
|
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||||
|
struct ip_addr *gw);
|
||||||
void netif_remove(struct netif * netif);
|
void netif_remove(struct netif * netif);
|
||||||
|
|
||||||
/* Returns a network interface given its name. The name is of the form
|
/* Returns a network interface given its name. The name is of the form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user