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.

This commit is contained in:
fbernon 2007-08-25 10:43:19 +00:00
parent 7c90cc6aac
commit acbf25f2eb
3 changed files with 47 additions and 32 deletions

View File

@ -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.

View File

@ -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 */

View File

@ -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