From acbf25f2ebc6894229236c7c4482be17e5b5a02e Mon Sep 17 00:00:00 2001 From: fbernon Date: Sat, 25 Aug 2007 10:43:19 +0000 Subject: [PATCH] netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up". Add a netif_is_link_up() function if LWIP_NETIF_LINK_CALLBACK option is set. --- CHANGELOG | 4 +++ src/core/netif.c | 64 ++++++++++++++++++++++------------------ src/include/lwip/netif.h | 11 ++++--- 3 files changed, 47 insertions(+), 32 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 587ad57d..9f45525a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,10 @@ HISTORY ++ New features: + 2007-0825 Frédéric Bernon (Artem Migaev's Patch) + * netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up". + Add a netif_is_link_up() function if LWIP_NETIF_LINK_CALLBACK option is set. + 2007-08-22 Frédéric Bernon * netif.h, netif.c, opt.h: Rename LWIP_NETIF_CALLBACK in LWIP_NETIF_STATUS_CALLBACK to be coherent with new LWIP_NETIF_LINK_CALLBACK option before next release. diff --git a/src/core/netif.c b/src/core/netif.c index 9dd30fa0..968bcad8 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -395,14 +395,6 @@ void netif_set_up(struct netif *netif) } } -/** - * 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. * @@ -425,11 +417,19 @@ void netif_set_down(struct netif *netif) } } +/** + * Ask if an interface is up + */ +u8_t netif_is_up(struct netif *netif) +{ + return (netif->flags & NETIF_FLAG_UP)?1:0; +} + #if LWIP_NETIF_STATUS_CALLBACK /** * Set callback to be called when interface is brought up/down */ -void netif_set_status_callback( struct netif *netif, void (* status_callback)(struct netif *netif )) +void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif )) { if ( netif ) netif->status_callback = status_callback; @@ -437,28 +437,10 @@ void netif_set_status_callback( struct netif *netif, void (* status_callback)(st #endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK -/** - * Set callback to be called when link is brought up/down - */ -void netif_set_link_callback( struct netif *netif, void (* link_callback)(struct netif *netif )) -{ - if ( netif ) - netif->link_callback = link_callback; -} - -/** - * Called by a driver when its link goes down - */ -void netif_set_link_down( struct netif *netif ) -{ - netif->flags &= ~NETIF_FLAG_LINK_UP; - NETIF_LINK_CALLBACK(netif); -} - /** * Called by a driver when its link goes up */ -void netif_set_link_up( struct netif *netif ) +void netif_set_link_up(struct netif *netif ) { netif->flags |= NETIF_FLAG_LINK_UP; @@ -475,4 +457,30 @@ void netif_set_link_up( struct netif *netif ) NETIF_LINK_CALLBACK(netif); } + +/** + * Called by a driver when its link goes down + */ +void netif_set_link_down(struct netif *netif ) +{ + netif->flags &= ~NETIF_FLAG_LINK_UP; + NETIF_LINK_CALLBACK(netif); +} + +/** + * Ask if a link is up + */ +u8_t netif_is_link_up(struct netif *netif) +{ + return (netif->flags & NETIF_FLAG_LINK_UP) ? 1 : 0; +} + +/** + * Set callback to be called when link is brought up/down + */ +void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif )) +{ + if ( netif ) + netif->link_callback = link_callback; +} #endif /* LWIP_NETIF_LINK_CALLBACK */ diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index fe48f823..693692a2 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -215,23 +215,26 @@ 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 *netmask); 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); + #if LWIP_NETIF_STATUS_CALLBACK /* * Set callback to be called when interface is brought up/down */ -void netif_set_status_callback( struct netif *netif, void (* status_callback)(struct netif *netif)); +void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif)); #endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK +void netif_set_link_up(struct netif *netif); +void netif_set_link_down(struct netif *netif); +u8_t netif_is_link_up(struct netif *netif); /* * Set callback to be called when link is brought up/down */ -void netif_set_link_callback( struct netif *netif, void (* link_callback)(struct netif *netif)); -void netif_set_link_down( struct netif *netif); -void netif_set_link_up( struct netif *netif); +void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif)); #endif /* LWIP_NETIF_LINK_CALLBACK */ #ifdef __cplusplus