From dce0f7468d4b1f3bb39dfdd0e768138bebb08b0d Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Wed, 12 Oct 2022 21:37:28 -0700 Subject: [PATCH] pimd, pim6d: Define pim_addr_is_multicast API pim_addr_is_multicast API will check if the address is multicast address or not. Signed-off-by: Sarita Patra --- pimd/pim_util.c | 12 ++++++++++++ pimd/pim_util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/pimd/pim_util.c b/pimd/pim_util.c index 4b67dbf1b1..150e1a01ea 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -166,3 +166,15 @@ int pim_get_all_mcast_group(struct prefix *prefix) #endif return 1; } + +bool pim_addr_is_multicast(pim_addr addr) +{ +#if PIM_IPV == 4 + if (IN_MULTICAST(addr.s_addr)) + return true; +#else + if (IN6_IS_ADDR_MULTICAST(&addr)) + return true; +#endif + return false; +} diff --git a/pimd/pim_util.h b/pimd/pim_util.h index a4362bef90..6af79ddf6c 100644 --- a/pimd/pim_util.h +++ b/pimd/pim_util.h @@ -37,4 +37,5 @@ int pim_is_group_224_0_0_0_24(struct in_addr group_addr); int pim_is_group_224_4(struct in_addr group_addr); bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp); int pim_get_all_mcast_group(struct prefix *prefix); +bool pim_addr_is_multicast(pim_addr addr); #endif /* PIM_UTIL_H */ -- 2.39.5