mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-02 12:52:10 +00:00
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
Provides callback on netif up/down state change.
This commit is contained in:
parent
d7ff85850c
commit
e5147d5562
@ -23,6 +23,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-03-21 Kieran Mansley
|
||||||
|
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
|
||||||
|
Provides callback on netif up/down state change.
|
||||||
|
|
||||||
2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds
|
2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds
|
||||||
* sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c,
|
* sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c,
|
||||||
ip.c, netif.h, tcpip.c, opt.h:
|
ip.c, netif.h, tcpip.c, opt.h:
|
||||||
|
@ -79,6 +79,10 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
|
|||||||
/* netif not under DHCP control by default */
|
/* netif not under DHCP control by default */
|
||||||
netif->dhcp = NULL;
|
netif->dhcp = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
#if LWIP_NETIF_CALLBACK
|
||||||
|
netif->status_callback = NULL;
|
||||||
|
#endif /* LWIP_NETIF_CALLBACK */
|
||||||
|
|
||||||
/* remember netif specific state information data */
|
/* remember netif specific state information data */
|
||||||
netif->state = state;
|
netif->state = state;
|
||||||
netif->num = netifnum++;
|
netif->num = netifnum++;
|
||||||
@ -287,10 +291,17 @@ netif_set_default(struct netif *netif)
|
|||||||
*/
|
*/
|
||||||
void netif_set_up(struct netif *netif)
|
void netif_set_up(struct netif *netif)
|
||||||
{
|
{
|
||||||
|
if ( !(netif->flags & NETIF_FLAG_UP )) {
|
||||||
netif->flags |= NETIF_FLAG_UP;
|
netif->flags |= NETIF_FLAG_UP;
|
||||||
|
|
||||||
#if LWIP_SNMP
|
#if LWIP_SNMP
|
||||||
snmp_get_sysuptime(&netif->ts);
|
snmp_get_sysuptime(&netif->ts);
|
||||||
#endif
|
#endif
|
||||||
|
#if LWIP_NETIF_CALLBACK
|
||||||
|
if ( netif->status_callback )
|
||||||
|
(netif->status_callback)( netif );
|
||||||
|
#endif /* LWIP_NETIF_CALLBACK */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,10 +322,18 @@ u8_t netif_is_up(struct netif *netif)
|
|||||||
*/
|
*/
|
||||||
void netif_set_down(struct netif *netif)
|
void netif_set_down(struct netif *netif)
|
||||||
{
|
{
|
||||||
|
if ( netif->flags & NETIF_FLAG_UP )
|
||||||
|
{
|
||||||
netif->flags &= ~NETIF_FLAG_UP;
|
netif->flags &= ~NETIF_FLAG_UP;
|
||||||
#if LWIP_SNMP
|
#if LWIP_SNMP
|
||||||
snmp_get_sysuptime(&netif->ts);
|
snmp_get_sysuptime(&netif->ts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_NETIF_CALLBACK
|
||||||
|
if ( netif->status_callback )
|
||||||
|
(netif->status_callback)( netif );
|
||||||
|
#endif /* LWIP_NETIF_CALLBACK */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -323,3 +342,15 @@ netif_init(void)
|
|||||||
netif_list = netif_default = NULL;
|
netif_list = netif_default = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if LWIP_NETIF_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 ))
|
||||||
|
{
|
||||||
|
if ( netif )
|
||||||
|
netif->status_callback = status_callback;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_NETIF_CALLBACK */
|
||||||
|
|
||||||
|
@ -90,6 +90,11 @@ struct netif {
|
|||||||
* to send a packet on the interface. This function outputs
|
* to send a packet on the interface. This function outputs
|
||||||
* the pbuf as-is on the link medium. */
|
* the pbuf as-is on the link medium. */
|
||||||
err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
|
err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
|
||||||
|
#if LWIP_NETIF_CALLBACK
|
||||||
|
/** This function is called when the netif state is set to up or down
|
||||||
|
*/
|
||||||
|
void (* status_callback)(struct netif *netif);
|
||||||
|
#endif /* end, LWIP_NETIF_CALLBACK */
|
||||||
/** This field can be set by the device driver and could point
|
/** This field can be set by the device driver and could point
|
||||||
* to state information for the device. */
|
* to state information for the device. */
|
||||||
void *state;
|
void *state;
|
||||||
@ -165,5 +170,11 @@ void netif_set_gw(struct netif *netif, struct ip_addr *gw);
|
|||||||
void netif_set_up(struct netif *netif);
|
void netif_set_up(struct netif *netif);
|
||||||
void netif_set_down(struct netif *netif);
|
void netif_set_down(struct netif *netif);
|
||||||
u8_t netif_is_up(struct netif *netif);
|
u8_t netif_is_up(struct netif *netif);
|
||||||
|
#if LWIP_NETIF_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 ));
|
||||||
|
#endif /* LWIP_NETIF_CALLBACK */
|
||||||
|
|
||||||
#endif /* __LWIP_NETIF_H__ */
|
#endif /* __LWIP_NETIF_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user