Skip to content

Commit

Permalink
net: ip: igmp: add igmpv3 support
Browse files Browse the repository at this point in the history
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
  • Loading branch information
IVandeVeire committed Nov 16, 2023
1 parent 2070121 commit f852baf
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 11 deletions.
54 changes: 52 additions & 2 deletions include/zephyr/net/igmp.h
Expand Up @@ -28,7 +28,7 @@ extern "C" {
#endif

/**
* @brief Join a given multicast group.
* @brief Join a given multicast group using IGMPv2.
*
* @param iface Network interface where join message is sent
* @param addr Multicast group to join
Expand All @@ -49,7 +49,36 @@ static inline int net_ipv4_igmp_join(struct net_if *iface,
#endif

/**
* @brief Leave a given multicast group.
* @brief Join a given multicast group using IGMPv3.
*
* @param iface Network interface where join message is sent
* @param addr Multicast group to join
* @param include True to include source list, false to exclude
* @param sources_list List of sources to include or exclude
* @param source_len Length of source list
*
* @return Return 0 if joining was done, <0 otherwise.
*/
#if defined(CONFIG_NET_IPV4_IGMPV3)
int net_ipv4_igmpv3_join(struct net_if *iface, const struct in_addr *addr, bool include,
struct in_addr source_list[], size_t sources_len);
#else
static inline int net_ipv4_igmpv3_join(struct net_if *iface, const struct in_addr *addr,
bool include, struct in_addr sources_list[],
size_t source_len)
{
ARG_UNUSED(iface);
ARG_UNUSED(addr);
ARG_UNUSED(include);
ARG_UNUSED(sources_list);
ARG_UNUSED(source_len);

return -ENOTSUP;
}
#endif

/**
* @brief Leave a given multicast group using IGMPV2.
*
* @param iface Network interface where leave message is sent
* @param addr Multicast group to leave
Expand All @@ -69,6 +98,27 @@ static inline int net_ipv4_igmp_leave(struct net_if *iface,
}
#endif

/**
* @brief Leave a given multicast group using IGMPV3.
*
* @param iface Network interface where leave message is sent
* @param addr Multicast group to leave
*
* @return Return 0 if leaving is done, <0 otherwise.
*/
#if defined(CONFIG_NET_IPV4_IGMPV3)
int net_ipv4_igmpv3_leave(struct net_if *iface, const struct in_addr *addr);
#else
static inline int net_ipv4_igmpv3_leave(struct net_if *iface,
const struct in_addr *addr)
{
ARG_UNUSED(iface);
ARG_UNUSED(addr);

return -ENOTSUP;
}
#endif

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 11 additions & 0 deletions include/zephyr/net/net_if.h
Expand Up @@ -101,6 +101,17 @@ struct net_if_mcast_addr {
uint8_t is_joined : 1;

uint8_t _unused : 6;

#if defined(CONFIG_NET_IPV4_IGMPV3)
/** Filter mode (used in IGMPV3)*/
uint8_t record_type;

/** Number of sources to be used by the filter*/
uint16_t sources_len;

/** Sources to filter on*/
struct net_addr sources[CONFIG_NET_IF_MCAST_IPV4_SOURCE_COUNT];
#endif
};

/**
Expand Down
4 changes: 4 additions & 0 deletions subsys/net/ip/Kconfig.ipv4
Expand Up @@ -37,6 +37,10 @@ config NET_IF_MCAST_IPV4_ADDR_COUNT
default 2 if NET_IPV4_IGMP
default 1

config NET_IF_MCAST_IPV4_SOURCE_COUNT
int "Max number of IPv4 sources per mcast address to be included or excluded"
default 1

config NET_ICMPV4_ACCEPT_BROADCAST
bool "Accept broadcast ICMPv4 echo-request"
help
Expand Down

0 comments on commit f852baf

Please sign in to comment.