mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-23 08:37:02 +08:00
Rework IGMP and MLD6 code to store group info per-netif.
Reasoning: - Makes code in single-netif case perform better and smaller - IGMP / MLD6 code is a little bit easier to read and understand - Easier to get multicast groups per netif when implementing drivers Downside: In multi-netif mode, there are two more pointers on each netif, even if IGMP/MLD6 is not used on it. But these systems should not be so memory-constrained that this will matter.
This commit is contained in:
@@ -74,8 +74,6 @@ extern "C" {
|
||||
struct igmp_group {
|
||||
/** next link */
|
||||
struct igmp_group *next;
|
||||
/** interface on which the group is active */
|
||||
struct netif *netif;
|
||||
/** multicast address */
|
||||
ip4_addr_t group_address;
|
||||
/** signifies we were the last person to report */
|
||||
@@ -88,9 +86,6 @@ struct igmp_group {
|
||||
u8_t use;
|
||||
};
|
||||
|
||||
/* Head of IGMP group list */
|
||||
extern struct igmp_group* igmp_group_list;
|
||||
|
||||
/* Prototypes */
|
||||
void igmp_init(void);
|
||||
err_t igmp_start(struct netif *netif);
|
||||
@@ -104,6 +99,9 @@ err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr);
|
||||
err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr);
|
||||
void igmp_tmr(void);
|
||||
|
||||
/* Get list of IGMP groups for netif */
|
||||
#define netif_igmp_data(netif) ((struct igmp_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,8 +58,6 @@ extern "C" {
|
||||
struct mld_group {
|
||||
/** next link */
|
||||
struct mld_group *next;
|
||||
/** interface on which the group is active */
|
||||
struct netif *netif;
|
||||
/** multicast address */
|
||||
ip6_addr_t group_address;
|
||||
/** signifies we were the last person to report */
|
||||
@@ -72,9 +70,6 @@ struct mld_group {
|
||||
u8_t use;
|
||||
};
|
||||
|
||||
/* Head of MLD group list */
|
||||
extern struct mld_group* mld_group_list;
|
||||
|
||||
#define MLD6_TMR_INTERVAL 100 /* Milliseconds */
|
||||
|
||||
err_t mld6_stop(struct netif *netif);
|
||||
@@ -87,6 +82,9 @@ err_t mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr);
|
||||
err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr);
|
||||
err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr);
|
||||
|
||||
/* Get list of MLD6 groups for netif */
|
||||
#define netif_mld6_data(netif) ((struct mld_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_MLD6))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -111,6 +111,12 @@ enum lwip_internal_netif_client_data_index
|
||||
#endif
|
||||
#if LWIP_AUTOIP
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
|
||||
#endif
|
||||
#if LWIP_IGMP
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
|
||||
#endif
|
||||
#if LWIP_IPV6_MLD
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
|
||||
#endif
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_MAX
|
||||
};
|
||||
@@ -201,6 +207,18 @@ typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif,
|
||||
const ip6_addr_t *group, enum netif_mac_filter_action action);
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
#if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (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 /* LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0) */
|
||||
|
||||
/** Generic data structure used for all lwIP network interfaces.
|
||||
* The following fields should be filled in by the initialization
|
||||
* function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
|
||||
@@ -257,7 +275,7 @@ struct netif {
|
||||
/** This field can be set by the device driver and could point
|
||||
* to state information for the device. */
|
||||
void *state;
|
||||
#if LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0)
|
||||
#ifdef netif_get_client_data
|
||||
void* client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA];
|
||||
#endif
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
@@ -424,18 +442,6 @@ void netif_poll_all(void);
|
||||
|
||||
err_t netif_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#if LWIP_DHCP || LWIP_AUTOIP || (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 /* LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0) */
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** @ingroup netif_ip6 */
|
||||
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
||||
|
||||
Reference in New Issue
Block a user