Improve netif client data API for lwIP internal clients - these can use a compile-time constant to access their data now

This commit is contained in:
Dirk Ziegelmeier
2016-08-18 12:37:21 +02:00
parent ebf7959880
commit 7f60cb3889
10 changed files with 85 additions and 100 deletions

View File

@@ -84,7 +84,6 @@ void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
void autoip_tmr(void);
void autoip_network_changed(struct netif *netif);
u8_t autoip_supplied_address(const struct netif *netif);
void autoip_init(void);
/* for lwIP internal use by ip4.c */
u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);

View File

@@ -118,10 +118,6 @@ u8_t dhcp_supplied_address(const struct netif *netif);
void dhcp_coarse_tmr(void);
/* to be called every half second */
void dhcp_fine_tmr(void);
void dhcp_init(void);
/* for use in unit tests only */
extern u8_t dhcp_netif_client_id;
#if LWIP_DHCP_GET_NTP_SRV
/** This function must exist, in other to add offered NTP servers to

View File

@@ -104,6 +104,17 @@ extern "C" {
* @}
*/
enum lwip_internal_netif_client_data_index
{
#if LWIP_DHCP
LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
#endif
#if LWIP_AUTOIP
LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
#endif
LWIP_NETIF_CLIENT_DATA_INDEX_MAX
};
#if LWIP_CHECKSUM_CTRL_PER_NETIF
#define NETIF_CHECKSUM_GEN_IP 0x0001
#define NETIF_CHECKSUM_GEN_UDP 0x0002
@@ -237,8 +248,8 @@ struct netif {
/** This field can be set by the device driver and could point
* to state information for the device. */
void *state;
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
void* client_data[LWIP_NUM_NETIF_CLIENT_DATA];
#if LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0)
void* client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA];
#endif
#if LWIP_IPV6_AUTOCONFIG
/** is this netif enabled for IPv6 autoconfiguration */

View File

@@ -1468,10 +1468,10 @@
/**
* LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store
* per data in client_data member array of struct netif.
* data in client_data member array of struct netif.
*/
#if !defined LWIP_NUM_NETIF_CLIENT_DATA || defined __DOXYGEN__
#define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_DHCP + LWIP_AUTOIP)
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#endif
/**
* @}