Link status does not depend on LWIP_NETIF_LINK_CALLBACK (fixes bug #28899)

This commit is contained in:
goldsimon 2010-02-15 19:53:46 +00:00
parent e04e0cb98e
commit 7c2054091d
4 changed files with 11 additions and 13 deletions

View File

@ -131,6 +131,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2010-02-15: Simon Goldschmidt/Stephane Lesage
* netif.c/.h: Link status does not depend on LWIP_NETIF_LINK_CALLBACK
(fixes bug #28899)
2010-02-14: Simon Goldschmidt 2010-02-14: Simon Goldschmidt
* netif.c: Fixed bug #28877 (Duplicate ARP gratuitous packet with * netif.c: Fixed bug #28877 (Duplicate ARP gratuitous packet with
LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and

View File

@ -61,15 +61,15 @@
#endif /* LWIP_DHCP */ #endif /* LWIP_DHCP */
#if LWIP_NETIF_STATUS_CALLBACK #if LWIP_NETIF_STATUS_CALLBACK
#define NETIF_STATUS_CALLBACK(n) { if (n->status_callback) (n->status_callback)(n); } #define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
#else #else
#define NETIF_STATUS_CALLBACK(n) { /* NOP */ } #define NETIF_STATUS_CALLBACK(n)
#endif /* LWIP_NETIF_STATUS_CALLBACK */ #endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK #if LWIP_NETIF_LINK_CALLBACK
#define NETIF_LINK_CALLBACK(n) { if (n->link_callback) (n->link_callback)(n); } #define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0)
#else #else
#define NETIF_LINK_CALLBACK(n) { /* NOP */ } #define NETIF_LINK_CALLBACK(n)
#endif /* LWIP_NETIF_LINK_CALLBACK */ #endif /* LWIP_NETIF_LINK_CALLBACK */
struct netif *netif_list; struct netif *netif_list;
@ -502,7 +502,6 @@ void netif_set_status_callback(struct netif *netif, netif_status_callback_fn sta
} }
#endif /* LWIP_NETIF_STATUS_CALLBACK */ #endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
/** /**
* Called by a driver when its link goes up * Called by a driver when its link goes up
*/ */
@ -553,6 +552,7 @@ void netif_set_link_down(struct netif *netif )
} }
} }
#if LWIP_NETIF_LINK_CALLBACK
/** /**
* Set callback to be called when link is brought up/down * Set callback to be called when link is brought up/down
*/ */

View File

@ -2497,7 +2497,6 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
ocstrncpy((u8_t*)value, netif->hwaddr, len); ocstrncpy((u8_t*)value, netif->hwaddr, len);
break; break;
case 7: /* ifAdminStatus */ case 7: /* ifAdminStatus */
#if LWIP_NETIF_LINK_CALLBACK
{ {
s32_t *sint_ptr = (s32_t*)value; s32_t *sint_ptr = (s32_t*)value;
if (netif_is_up(netif)) if (netif_is_up(netif))
@ -2517,7 +2516,6 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
} }
} }
break; break;
#endif
case 8: /* ifOperStatus */ case 8: /* ifOperStatus */
{ {
s32_t *sint_ptr = (s32_t*)value; s32_t *sint_ptr = (s32_t*)value;

View File

@ -80,8 +80,7 @@ extern "C" {
* (set by the network interface driver). * (set by the network interface driver).
* Either set by the netif driver in its init function (if the link * Either set by the netif driver in its init function (if the link
* is up at that time) or at a later point once the link comes up * is up at that time) or at a later point once the link comes up
* (if link detection is supported by the hardware). * (if link detection is supported by the hardware). */
* Only really used with LWIP_NETIF_LINK_CALLBACK. */
#define NETIF_FLAG_LINK_UP 0x10U #define NETIF_FLAG_LINK_UP 0x10U
/** If set, the netif is an ethernet device using ARP. /** If set, the netif is an ethernet device using ARP.
* Set by the netif driver in its init function. * Set by the netif driver in its init function.
@ -279,18 +278,15 @@ void netif_set_down(struct netif *netif);
#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
#if LWIP_NETIF_STATUS_CALLBACK #if LWIP_NETIF_STATUS_CALLBACK
/*
* Set callback to be called when interface is brought up/down
*/
void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback);
#endif /* LWIP_NETIF_STATUS_CALLBACK */ #endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
void netif_set_link_up(struct netif *netif); void netif_set_link_up(struct netif *netif);
void netif_set_link_down(struct netif *netif); void netif_set_link_down(struct netif *netif);
/** Ask if a link is up */ /** Ask if a link is up */
#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
#if LWIP_NETIF_LINK_CALLBACK
void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback);
#endif /* LWIP_NETIF_LINK_CALLBACK */ #endif /* LWIP_NETIF_LINK_CALLBACK */