combine MAC filter actions for IGMP and MLD6 (IGMP has compatibility defines for old code, MLD6 filter functions must be adapted)

This commit is contained in:
goldsimon 2016-08-19 13:54:14 +02:00
parent b3bae1b44c
commit 6b1e1af3d1
5 changed files with 23 additions and 26 deletions

View File

@ -143,7 +143,7 @@ igmp_start(struct netif *netif)
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD "));
ip4_addr_debug_print_val(IGMP_DEBUG, allsystems); ip4_addr_debug_print_val(IGMP_DEBUG, allsystems);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER); netif->igmp_mac_filter(netif, &allsystems, NETIF_ADD_MAC_FILTER);
} }
return ERR_OK; return ERR_OK;
@ -182,7 +182,7 @@ igmp_stop(struct netif *netif)
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, &group->group_address); ip4_addr_debug_print(IGMP_DEBUG, &group->group_address);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, &(group->group_address), IGMP_DEL_MAC_FILTER); netif->igmp_mac_filter(netif, &(group->group_address), NETIF_DEL_MAC_FILTER);
} }
/* free group */ /* free group */
memp_free(MEMP_IGMP_GROUP, group); memp_free(MEMP_IGMP_GROUP, group);
@ -513,7 +513,7 @@ igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup_netif: igmp_mac_filter(ADD ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup_netif: igmp_mac_filter(ADD "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr); ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER); netif->igmp_mac_filter(netif, groupaddr, NETIF_ADD_MAC_FILTER);
} }
IGMP_STATS_INC(igmp.tx_join); IGMP_STATS_INC(igmp.tx_join);
@ -613,7 +613,7 @@ igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: igmp_mac_filter(DEL ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr); ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER); netif->igmp_mac_filter(netif, groupaddr, NETIF_DEL_MAC_FILTER);
} }
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: remove group: ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: remove group: "));

View File

@ -114,7 +114,7 @@ mld6_stop(struct netif *netif)
} }
/* disable the group at the MAC level */ /* disable the group at the MAC level */
if (netif->mld_mac_filter != NULL) { if (netif->mld_mac_filter != NULL) {
netif->mld_mac_filter(netif, &(group->group_address), MLD6_DEL_MAC_FILTER); netif->mld_mac_filter(netif, &(group->group_address), NETIF_DEL_MAC_FILTER);
} }
/* free group */ /* free group */
memp_free(MEMP_MLD6_GROUP, group); memp_free(MEMP_MLD6_GROUP, group);
@ -373,7 +373,7 @@ mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr)
/* Activate this address on the MAC layer. */ /* Activate this address on the MAC layer. */
if (netif->mld_mac_filter != NULL) { if (netif->mld_mac_filter != NULL) {
netif->mld_mac_filter(netif, groupaddr, MLD6_ADD_MAC_FILTER); netif->mld_mac_filter(netif, groupaddr, NETIF_ADD_MAC_FILTER);
} }
/* Report our membership. */ /* Report our membership. */
@ -448,7 +448,7 @@ mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr)
/* Disable the group at the MAC level */ /* Disable the group at the MAC level */
if (netif->mld_mac_filter != NULL) { if (netif->mld_mac_filter != NULL) {
netif->mld_mac_filter(netif, groupaddr, MLD6_DEL_MAC_FILTER); netif->mld_mac_filter(netif, groupaddr, NETIF_DEL_MAC_FILTER);
} }
/* Free the group */ /* Free the group */

View File

@ -56,6 +56,10 @@ extern "C" {
#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL)
#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
/* Compatibility defines (don't use for new code) */
#define IGMP_DEL_MAC_FILTER NETIF_DEL_MAC_FILTER
#define IGMP_ADD_MAC_FILTER NETIF_ADD_MAC_FILTER
/** /**
* igmp group structure - there is * igmp group structure - there is
* a list of groups for each interface * a list of groups for each interface

View File

@ -132,6 +132,15 @@ enum lwip_internal_netif_client_data_index
struct netif; struct netif;
/** MAC Filter Actions, these are passed to a netif's igmp_mac_filter or
* mld_mac_filter callback function. */
enum netif_mac_filter_action {
/** Delete a filter entry */
NETIF_DEL_MAC_FILTER = 0,
/** Add a filter entry */
NETIF_ADD_MAC_FILTER = 1
};
/** Function prototype for netif init functions. Set up flags and output/linkoutput /** Function prototype for netif init functions. Set up flags and output/linkoutput
* callback functions in this function. * callback functions in this function.
* *
@ -181,31 +190,15 @@ typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p,
typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p);
/** Function prototype for netif status- or link-callback functions. */ /** Function prototype for netif status- or link-callback functions. */
typedef void (*netif_status_callback_fn)(struct netif *netif); typedef void (*netif_status_callback_fn)(struct netif *netif);
#if LWIP_IPV4 && LWIP_IGMP #if LWIP_IPV4 && LWIP_IGMP
/** MAC Filter Actions, these are passed to a netif's igmp_mac_filter callback function. */
enum netif_igmp_filter_action {
/** Delete a filter entry */
IGMP_DEL_MAC_FILTER = 0,
/** Add a filter entry */
IGMP_ADD_MAC_FILTER = 1
};
/** Function prototype for netif igmp_mac_filter functions */ /** Function prototype for netif igmp_mac_filter functions */
typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
const ip4_addr_t *group, enum netif_igmp_filter_action action); const ip4_addr_t *group, enum netif_mac_filter_action action);
#endif /* LWIP_IPV4 && LWIP_IGMP */ #endif /* LWIP_IPV4 && LWIP_IGMP */
#if LWIP_IPV6 && LWIP_IPV6_MLD #if LWIP_IPV6 && LWIP_IPV6_MLD
/** MAC Filter Actions, these are passed to a netif's mld_mac_filter callback function. */
enum netif_mld6_filter_action {
/** Delete a filter entry */
MLD6_DEL_MAC_FILTER = 0,
/** Add a filter entry */
MLD6_ADD_MAC_FILTER = 1
};
/** Function prototype for netif mld_mac_filter functions */ /** Function prototype for netif mld_mac_filter functions */
typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif,
const ip6_addr_t *group, enum netif_mld6_filter_action action); const ip6_addr_t *group, enum netif_mac_filter_action action);
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
/** Generic data structure used for all lwIP network interfaces. /** Generic data structure used for all lwIP network interfaces.

View File

@ -110,7 +110,7 @@ low_level_init(struct netif *netif)
if (netif->mld_mac_filter != NULL) { if (netif->mld_mac_filter != NULL) {
ip6_addr_t ip6_allnodes_ll; ip6_addr_t ip6_allnodes_ll;
ip6_addr_set_allnodes_linklocal(&ip6_allnodes_ll); ip6_addr_set_allnodes_linklocal(&ip6_allnodes_ll);
netif->mld_mac_filter(netif, &ip6_allnodes_ll, MLD6_ADD_MAC_FILTER); netif->mld_mac_filter(netif, &ip6_allnodes_ll, NETIF_ADD_MAC_FILTER);
} }
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */