From 6b1e1af3d19c28f26519460531f28b23d4f6e1f0 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Fri, 19 Aug 2016 13:54:14 +0200 Subject: [PATCH] combine MAC filter actions for IGMP and MLD6 (IGMP has compatibility defines for old code, MLD6 filter functions must be adapted) --- src/core/ipv4/igmp.c | 8 ++++---- src/core/ipv6/mld6.c | 6 +++--- src/include/lwip/igmp.h | 4 ++++ src/include/lwip/netif.h | 29 +++++++++++------------------ src/netif/ethernetif.c | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index 94397274..164a3bf1 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -143,7 +143,7 @@ igmp_start(struct netif *netif) LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); ip4_addr_debug_print_val(IGMP_DEBUG, allsystems); 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; @@ -182,7 +182,7 @@ igmp_stop(struct netif *netif) LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL ")); ip4_addr_debug_print(IGMP_DEBUG, &group->group_address); 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 */ 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 ")); ip4_addr_debug_print(IGMP_DEBUG, groupaddr); 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); @@ -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 ")); ip4_addr_debug_print(IGMP_DEBUG, groupaddr); 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: ")); diff --git a/src/core/ipv6/mld6.c b/src/core/ipv6/mld6.c index f5e07ec4..9ae44c06 100644 --- a/src/core/ipv6/mld6.c +++ b/src/core/ipv6/mld6.c @@ -114,7 +114,7 @@ mld6_stop(struct netif *netif) } /* disable the group at the MAC level */ 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 */ 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. */ 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. */ @@ -448,7 +448,7 @@ mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr) /* Disable the group at the MAC level */ 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 */ diff --git a/src/include/lwip/igmp.h b/src/include/lwip/igmp.h index cc312238..be78c332 100644 --- a/src/include/lwip/igmp.h +++ b/src/include/lwip/igmp.h @@ -56,6 +56,10 @@ extern "C" { #define IGMP_V1_DELAYING_MEMBER_TMR (1000/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 * a list of groups for each interface diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index f316116a..1f11551b 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -132,6 +132,15 @@ enum lwip_internal_netif_client_data_index 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 * 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); /** Function prototype for netif status- or link-callback functions. */ typedef void (*netif_status_callback_fn)(struct netif *netif); - #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 */ 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 */ - #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 */ 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 */ /** Generic data structure used for all lwIP network interfaces. diff --git a/src/netif/ethernetif.c b/src/netif/ethernetif.c index c873c8c8..dc8ae6c4 100644 --- a/src/netif/ethernetif.c +++ b/src/netif/ethernetif.c @@ -110,7 +110,7 @@ low_level_init(struct netif *netif) if (netif->mld_mac_filter != NULL) { ip6_addr_t 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 */