diff --git a/include/zephyr/net/mld.h b/include/zephyr/net/mld.h new file mode 100644 index 00000000000000..97cecae66b71cc --- /dev/null +++ b/include/zephyr/net/mld.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016 Intel Corporation + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Multicast Listener Discovery API + */ + +#ifndef ZEPHYR_INCLUDE_NET_MLD_H_ +#define ZEPHYR_INCLUDE_NET_MLD_H_ + +/** + * @brief MLD (Multicast Listener Discovery) + * @defgroup mld Multicast Listener Discovery API + * @since 1.8 + * @version 0.8.0 + * @ingroup networking + * @{ + */ + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Join a given multicast group. + * + * @param iface Network interface where join message is sent + * @param addr Multicast group to join + * + * @return Return 0 if joining was done, <0 otherwise. + */ +#if defined(CONFIG_NET_IPV6_MLD) +int net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr); +#else +static inline int +net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr) +{ + ARG_UNUSED(addr); + ARG_UNUSED(iface); + + return -ENOTSUP; +} +#endif /* CONFIG_NET_IPV6_MLD */ + +/** + * @brief Leave a given multicast group. + * + * @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_IPV6_MLD) +int net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr); +#else +static inline int +net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr) +{ + ARG_UNUSED(iface); + ARG_UNUSED(addr); + + return -ENOTSUP; +} +#endif /* CONFIG_NET_IPV6_MLD */ + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* ZEPHYR_INCLUDE_NET_MLD_H_ */ diff --git a/samples/net/sockets/coap_server/src/main.c b/samples/net/sockets/coap_server/src/main.c index 4f476511b2cfc3..60dd32a000bab5 100644 --- a/samples/net/sockets/coap_server/src/main.c +++ b/samples/net/sockets/coap_server/src/main.c @@ -8,6 +8,7 @@ LOG_MODULE_REGISTER(net_coap_service_sample, LOG_LEVEL_DBG); #include +#include #ifdef CONFIG_NET_IPV6 #include "net_private.h" diff --git a/subsys/net/ip/ipv6.h b/subsys/net/ip/ipv6.h index 2dbd1189a6ae3c..68115f818c26ec 100644 --- a/subsys/net/ip/ipv6.h +++ b/subsys/net/ip/ipv6.h @@ -198,48 +198,6 @@ static inline int net_ipv6_finalize(struct net_pkt *pkt, } #endif -/** - * @brief Join a given multicast group. - * - * @param iface Network interface where join message is sent - * @param addr Multicast group to join - * - * @return Return 0 if joining was done, <0 otherwise. - */ -#if defined(CONFIG_NET_IPV6_MLD) -int net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr); -#else -static inline int -net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr) -{ - ARG_UNUSED(iface); - ARG_UNUSED(addr); - - return -ENOTSUP; -} -#endif /* CONFIG_NET_IPV6_MLD */ - -/** - * @brief Leave a given multicast group. - * - * @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_IPV6_MLD) -int net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr); -#else -static inline int -net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr) -{ - ARG_UNUSED(iface); - ARG_UNUSED(addr); - - return -ENOTSUP; -} -#endif /* CONFIG_NET_IPV6_MLD */ - /** * @brief Send MLDv2 report message with a single entry. * diff --git a/subsys/net/ip/ipv6_mld.c b/subsys/net/ip/ipv6_mld.c index 75644c2ca5801a..66166fd1d3be56 100644 --- a/subsys/net/ip/ipv6_mld.c +++ b/subsys/net/ip/ipv6_mld.c @@ -12,6 +12,7 @@ LOG_MODULE_DECLARE(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL); #include +#include #include #include #include diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 0d0248158f7587..5c85f02ff4d2c6 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL); #include #include #include +#include #include #include #include diff --git a/subsys/net/lib/dns/llmnr_responder.c b/subsys/net/lib/dns/llmnr_responder.c index bc56cbb149007f..b72d93f27eefc4 100644 --- a/subsys/net/lib/dns/llmnr_responder.c +++ b/subsys/net/lib/dns/llmnr_responder.c @@ -21,6 +21,7 @@ LOG_MODULE_REGISTER(net_llmnr_responder, CONFIG_LLMNR_RESPONDER_LOG_LEVEL); #include #include +#include #include #include #include diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c index ab8977d1c72b59..031f97df2fe1ad 100644 --- a/subsys/net/lib/dns/mdns_responder.c +++ b/subsys/net/lib/dns/mdns_responder.c @@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(net_mdns_responder, CONFIG_MDNS_RESPONDER_LOG_LEVEL); #include #include +#include #include #include #include diff --git a/subsys/net/lib/shell/ipv6.c b/subsys/net/lib/shell/ipv6.c index d13b6803e65d2e..eb65185c03ca1f 100644 --- a/subsys/net/lib/shell/ipv6.c +++ b/subsys/net/lib/shell/ipv6.c @@ -8,6 +8,8 @@ #include LOG_MODULE_DECLARE(net_shell); +#include + #include "net_shell_private.h" #include "../ip/ipv6.h" diff --git a/subsys/net/lib/sockets/sockets.c b/subsys/net/lib/sockets/sockets.c index 12fbce5c6c527d..9ca1972189f2e7 100644 --- a/subsys/net/lib/sockets/sockets.c +++ b/subsys/net/lib/sockets/sockets.c @@ -11,6 +11,7 @@ LOG_MODULE_REGISTER(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL); #include +#include #include #include #include diff --git a/subsys/net/lib/zperf/zperf_udp_receiver.c b/subsys/net/lib/zperf/zperf_udp_receiver.c index 0f7e1e4f077cb7..2f0d292f7ad0f4 100644 --- a/subsys/net/lib/zperf/zperf_udp_receiver.c +++ b/subsys/net/lib/zperf/zperf_udp_receiver.c @@ -12,6 +12,7 @@ LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL); #include +#include #include #include #include diff --git a/tests/net/ipv6/src/main.c b/tests/net/ipv6/src/main.c index 02df9ac650c6c6..1dd40afcde8c49 100644 --- a/tests/net/ipv6/src/main.c +++ b/tests/net/ipv6/src/main.c @@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL); #include +#include #include #include #include diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index e1bcce056cfaf3..1c95fe5409dcfb 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL); #include +#include #include #include #include