diff --git a/src/core/netif.c b/src/core/netif.c index 06c6e9c6..2a79ae67 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -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)) { static int netifnum = 0; - #if LWIP_DHCP /* 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] : '\'')); } +/** + * 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 netif_init(void) { diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index bca52ea4..d0bda2df 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -53,7 +53,7 @@ /** whether the network interface is 'up'. this is * a software flag used to control whether this network * interface is enabled and processes traffic. - * TODO: who should act on this flag, lwIP stack or driver?? */ + */ #define NETIF_FLAG_UP 0x1U /** if set, the netif has broadcast capability */ #define NETIF_FLAG_BROADCAST 0x2U @@ -105,6 +105,8 @@ struct netif { u16_t mtu; /** flags (see NETIF_FLAG_ above) */ u8_t flags; + /** link type */ + u8_t link_type; /** descriptive abbreviation */ char name[2]; /** 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_netmask(struct netif *netif, struct ip_addr *netmast); 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__ */