From e77aa7b65eb0d08f63d0ea3dea68f3bbe97d75f4 Mon Sep 17 00:00:00 2001 From: Hendrik van Essen Date: Wed, 5 Oct 2022 16:28:13 +0200 Subject: [PATCH] net/ipv4/addr.h: add ipv4_addr_is_multicast --- sys/include/net/ipv4/addr.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/include/net/ipv4/addr.h b/sys/include/net/ipv4/addr.h index 30cc5fcb3c..73a0662d4e 100644 --- a/sys/include/net/ipv4/addr.h +++ b/sys/include/net/ipv4/addr.h @@ -57,6 +57,23 @@ static inline bool ipv4_addr_equal(const ipv4_addr_t *a, const ipv4_addr_t *b) return (a->u32.u32 == b->u32.u32); } +/** + * @brief Check if @p addr is a multicast address. + * + * @see + * RFC 1112, section 4 + * + * + * @param[in] addr An IPv4 address. + * + * @return true, if @p addr is multicast address, + * @return false, otherwise. + */ +static inline bool ipv4_addr_is_multicast(const ipv4_addr_t *addr) +{ + return (addr->u8[0] >= 0xE0 && addr->u8[0] <= 0xEF); +} + /** * @brief Converts an IPv4 address to its string representation *