added functions dhcp/autoip_supplied_address() to check for the source of address assignemnt (replacement for NETIF_FLAG_DHCP)

This commit is contained in:
sg 2015-04-24 21:23:15 +02:00
parent 737a6921c3
commit e20a071977
5 changed files with 45 additions and 0 deletions

View File

@ -6,6 +6,10 @@ HISTORY
++ New features: ++ New features:
2015-04-24: Simon Goldschmidt
* dhcp.h/c, autoip.h/.c: added functions dhcp/autoip_supplied_address() to
check for the source of address assignemnt (replacement for NETIF_FLAG_DHCP)
2015-04-10: Simon Goldschmidt 2015-04-10: Simon Goldschmidt
* many files: task #13480: added LWIP_IPV4 define - IPv4 can be disabled, * many files: task #13480: added LWIP_IPV4 define - IPv4 can be disabled,
leaving an IPv6-only stack leaving an IPv6-only stack

View File

@ -1820,4 +1820,22 @@ dhcp_option_trailer(struct dhcp *dhcp)
} }
} }
/** check if DHCP supplied netif->ip_addr
*
* @param netif the netif to check
* @return 1 if DHCP supplied netif->ip_addr (states BOUND or RENEWING),
* 0 otherwise
*/
u8_t
dhcp_supplied_address(struct netif *netif)
{
if ((netif != NULL) && (netif->dhcp != NULL)) {
if ((netif->dhcp->state == DHCP_BOUND) ||
(netif->dhcp->state == DHCP_RENEWING)) {
return 1;
}
}
return 0;
}
#endif /* LWIP_IPV4 && LWIP_DHCP */ #endif /* LWIP_IPV4 && LWIP_DHCP */

View File

@ -520,4 +520,21 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
} }
} }
/** check if AutoIP supplied netif->ip_addr
*
* @param netif the netif to check
* @return 1 if AutoIP supplied netif->ip_addr (state BOUND),
* 0 otherwise
*/
u8_t
autoip_supplied_address(struct netif *netif)
{
if ((netif != NULL) && (netif->autoip != NULL)) {
if (netif->autoip->state == AUTOIP_STATE_BOUND) {
return 1;
}
}
return 0;
}
#endif /* LWIP_IPV4 && LWIP_AUTOIP */ #endif /* LWIP_IPV4 && LWIP_AUTOIP */

View File

@ -112,6 +112,9 @@ void autoip_tmr(void);
/** Handle a possible change in the network configuration */ /** Handle a possible change in the network configuration */
void autoip_network_changed(struct netif *netif); void autoip_network_changed(struct netif *netif);
/** check if AutoIP supplied netif->ip_addr */
u8_t autoip_supplied_address(struct netif *netif);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -129,6 +129,9 @@ void dhcp_network_changed(struct netif *netif);
void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr); void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr);
#endif #endif
/** check if DHCP supplied netif->ip_addr */
u8_t dhcp_supplied_address(struct netif *netif);
/** to be called every minute */ /** to be called every minute */
void dhcp_coarse_tmr(void); void dhcp_coarse_tmr(void);
/** to be called every half second */ /** to be called every half second */