Add API macros for netif client data handling and update documentation accordingly

This commit is contained in:
Dirk Ziegelmeier 2016-08-26 11:21:49 +02:00
parent 537bd836c9
commit 0d510dd66d
6 changed files with 24 additions and 9 deletions

View File

@ -2096,6 +2096,7 @@ PREDEFINED = __DOXYGEN__=1 \
LWIP_NETIF_STATUS_CALLBACK=1 \
LWIP_NETIF_REMOVE_CALLBACK=1 \
LWIP_NETIF_LINK_CALLBACK=1 \
LWIP_NUM_NETIF_CLIENT_DATA=1 \
ENABLE_LOOPBACK=1 \
LWIP_AUTOIP=1 \
ARP_QUEUEING=1 \

View File

@ -95,7 +95,7 @@
static err_t autoip_arp_announce(struct netif *netif);
static void autoip_start_probing(struct netif *netif);
#define netif_autoip_data(netif) ((struct autoip*)netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP])
#define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
/**
* @ingroup autoip
@ -116,7 +116,7 @@ autoip_set_struct(struct netif *netif, struct autoip *autoip)
/* clear data structure */
memset(autoip, 0, sizeof(struct autoip));
/* autoip->state = AUTOIP_STATE_OFF; */
netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP] = autoip;
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, autoip);
}
/** Restart AutoIP client and check the next address (conflict detected)
@ -281,7 +281,7 @@ autoip_start(struct netif *netif)
}
memset(autoip, 0, sizeof(struct autoip));
/* store this AutoIP client in the netif */
netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP] = autoip;
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, autoip);
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip"));
} else {
autoip->state = AUTOIP_STATE_OFF;

View File

@ -193,7 +193,7 @@ static void dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif);
/* always add the DHCP options trailer to end and pad */
static void dhcp_option_trailer(struct dhcp *dhcp);
#define netif_dhcp_data(netif) ((struct dhcp*)netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])
#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP))
/** Ensure DHCP PCB is allocated and bound */
static err_t
@ -668,7 +668,7 @@ dhcp_set_struct(struct netif *netif, struct dhcp *dhcp)
/* clear data structure */
memset(dhcp, 0, sizeof(struct dhcp));
/* dhcp_set_state(&dhcp, DHCP_STATE_OFF); */
netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP] = dhcp;
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, dhcp);
}
/**
@ -686,7 +686,7 @@ void dhcp_cleanup(struct netif *netif)
if (netif_dhcp_data(netif) != NULL) {
mem_free(netif_dhcp_data(netif));
netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP] = NULL;
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL);
}
}
@ -730,7 +730,7 @@ dhcp_start(struct netif *netif)
}
/* store this dhcp client in the netif */
netif->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP] = dhcp;
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, dhcp);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp"));
/* already has DHCP client attached */
} else {

View File

@ -10,6 +10,11 @@
*
* @defgroup netif_ip6 IPv6 address handling
* @ingroup netif
*
* @defgroup netif_cd Client data handling
* Store data (void*) on a netif for application usage.
* @see @ref LWIP_NUM_NETIF_CLIENT_DATA
* @ingroup netif
*/
/*
@ -967,7 +972,7 @@ netif_poll_all(void)
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
/**
* @ingroup netif
* @ingroup netif_cd
* Allocate an index to store data in client_data member of struct netif.
* Returned value is an index in mentioned array.
* @see LWIP_NUM_NETIF_CLIENT_DATA

View File

@ -426,6 +426,14 @@ err_t netif_input(struct pbuf *p, struct netif *inp);
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
u8_t netif_alloc_client_data_id(void);
/** @ingroup netif_cd
* Set client data. Obtain ID from netif_alloc_client_data_id().
*/
#define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
/** @ingroup netif_cd
* Get client data. Obtain ID from netif_alloc_client_data_id().
*/
#define netif_get_client_data(netif, id) (netif)->client_data[(id)]
#endif
#if LWIP_IPV6

View File

@ -2495,7 +2495,8 @@
/**
* LWIP_HOOK_VLAN_SET:
* Hook can be used to set prio_vid field of vlan_hdr.
* Hook can be used to set prio_vid field of vlan_hdr. If you need to store data
* on per-netif basis to implement this callback, see @ref netif_cd.
* Called from ethernet_output() if VLAN support (@ref ETHARP_SUPPORT_VLAN) is enabled.\n
* Signature: s32_t my_hook_vlan_set(struct netif* netif, struct pbuf* pbuf, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type);\n
* Arguments: