Added netif up/down basics.

This commit is contained in:
likewise 2004-06-30 18:38:07 +00:00
parent 27c6d299cf
commit d11fcafad8
2 changed files with 41 additions and 2 deletions

View File

@ -68,7 +68,6 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
err_t (* input)(struct pbuf *p, struct netif *netif)) err_t (* input)(struct pbuf *p, struct netif *netif))
{ {
static int netifnum = 0; static int netifnum = 0;
#if LWIP_DHCP #if LWIP_DHCP
/* netif not under DHCP control by default */ /* netif not under DHCP control by default */
@ -246,6 +245,41 @@ netif_set_default(struct netif *netif)
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
} }
/**
* Bring an interface up, available for processing
* traffic.
*
* @note: Enabling DHCP on a down interface will make it come
* up once configured.
*
* @see dhcp_start()
*/
void netif_set_up(struct netif *netif)
{
netif->flags |= NETIF_FLAG_UP;
}
/**
* Ask if an interface is up
*/
u8_t netif_is_up(struct netif *netif)
{
return (netif->flags & NETIF_FLAG_UP)?1:0;
}
/**
* Bring an interface down, disabling any traffic processing.
*
* @note: Enabling DHCP on a down interface will make it come
* up once configured.
*
* @see dhcp_start()
*/
void netif_set_down(struct netif *netif)
{
netif->flags &= ~NETIF_FLAG_UP;
}
void void
netif_init(void) netif_init(void)
{ {

View File

@ -53,7 +53,7 @@
/** whether the network interface is 'up'. this is /** whether the network interface is 'up'. this is
* a software flag used to control whether this network * a software flag used to control whether this network
* interface is enabled and processes traffic. * interface is enabled and processes traffic.
* TODO: who should act on this flag, lwIP stack or driver?? */ */
#define NETIF_FLAG_UP 0x1U #define NETIF_FLAG_UP 0x1U
/** if set, the netif has broadcast capability */ /** if set, the netif has broadcast capability */
#define NETIF_FLAG_BROADCAST 0x2U #define NETIF_FLAG_BROADCAST 0x2U
@ -105,6 +105,8 @@ struct netif {
u16_t mtu; u16_t mtu;
/** flags (see NETIF_FLAG_ above) */ /** flags (see NETIF_FLAG_ above) */
u8_t flags; u8_t flags;
/** link type */
u8_t link_type;
/** descriptive abbreviation */ /** descriptive abbreviation */
char name[2]; char name[2];
/** number of this interface */ /** number of this interface */
@ -141,5 +143,8 @@ void netif_set_default(struct netif *netif);
void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr); void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
void netif_set_netmask(struct netif *netif, struct ip_addr *netmast); void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
void netif_set_gw(struct netif *netif, struct ip_addr *gw); void netif_set_gw(struct netif *netif, struct ip_addr *gw);
void netif_set_up(struct netif *netif);
void netif_set_down(struct netif *netif);
u8_t netif_is_up(struct netif *netif);
#endif /* __LWIP_NETIF_H__ */ #endif /* __LWIP_NETIF_H__ */