Skip to content

Commit 3481d86

Browse files
committed
[nrf fromtree] net: ipv6: Make Multicast Listener Discovery API public
IPv6 MLD API was so far defined in an internal header. This does not seem correct though, as application code should be able to join/leave multicast groups, hence the API should be exposed in a public header, just as it is done for its IPv4 countepart - IGMP. Signed-off-by: Robert Lubos <[email protected]> (cherry picked from commit c6498bb)
1 parent 44e2e92 commit 3481d86

File tree

12 files changed

+95
-42
lines changed

12 files changed

+95
-42
lines changed

include/zephyr/net/mld.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2016 Intel Corporation
3+
* Copyright (c) 2024 Nordic Semiconductor ASA
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/** @file
9+
* @brief Multicast Listener Discovery API
10+
*/
11+
12+
#ifndef ZEPHYR_INCLUDE_NET_MLD_H_
13+
#define ZEPHYR_INCLUDE_NET_MLD_H_
14+
15+
/**
16+
* @brief MLD (Multicast Listener Discovery)
17+
* @defgroup mld Multicast Listener Discovery API
18+
* @since 1.8
19+
* @version 0.8.0
20+
* @ingroup networking
21+
* @{
22+
*/
23+
24+
#include <errno.h>
25+
26+
#include <zephyr/net/net_if.h>
27+
#include <zephyr/net/net_ip.h>
28+
#include <zephyr/toolchain.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
/**
35+
* @brief Join a given multicast group.
36+
*
37+
* @param iface Network interface where join message is sent
38+
* @param addr Multicast group to join
39+
*
40+
* @return 0 if joining was done, <0 otherwise.
41+
*/
42+
#if defined(CONFIG_NET_IPV6_MLD)
43+
int net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr);
44+
#else
45+
static inline int
46+
net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr)
47+
{
48+
ARG_UNUSED(addr);
49+
ARG_UNUSED(iface);
50+
51+
return -ENOTSUP;
52+
}
53+
#endif /* CONFIG_NET_IPV6_MLD */
54+
55+
/**
56+
* @brief Leave a given multicast group.
57+
*
58+
* @param iface Network interface where leave message is sent
59+
* @param addr Multicast group to leave
60+
*
61+
* @return 0 if leaving is done, <0 otherwise.
62+
*/
63+
#if defined(CONFIG_NET_IPV6_MLD)
64+
int net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr);
65+
#else
66+
static inline int
67+
net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr)
68+
{
69+
ARG_UNUSED(iface);
70+
ARG_UNUSED(addr);
71+
72+
return -ENOTSUP;
73+
}
74+
#endif /* CONFIG_NET_IPV6_MLD */
75+
76+
#ifdef __cplusplus
77+
}
78+
#endif
79+
80+
/**
81+
* @}
82+
*/
83+
84+
#endif /* ZEPHYR_INCLUDE_NET_MLD_H_ */

samples/net/sockets/coap_server/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
LOG_MODULE_REGISTER(net_coap_service_sample, LOG_LEVEL_DBG);
99

1010
#include <zephyr/net/coap_service.h>
11+
#include <zephyr/net/mld.h>
1112

1213
#ifdef CONFIG_NET_IPV6
1314
#include "net_private.h"

subsys/net/ip/ipv6.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -198,48 +198,6 @@ static inline int net_ipv6_finalize(struct net_pkt *pkt,
198198
}
199199
#endif
200200

201-
/**
202-
* @brief Join a given multicast group.
203-
*
204-
* @param iface Network interface where join message is sent
205-
* @param addr Multicast group to join
206-
*
207-
* @return Return 0 if joining was done, <0 otherwise.
208-
*/
209-
#if defined(CONFIG_NET_IPV6_MLD)
210-
int net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr);
211-
#else
212-
static inline int
213-
net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr)
214-
{
215-
ARG_UNUSED(iface);
216-
ARG_UNUSED(addr);
217-
218-
return -ENOTSUP;
219-
}
220-
#endif /* CONFIG_NET_IPV6_MLD */
221-
222-
/**
223-
* @brief Leave a given multicast group.
224-
*
225-
* @param iface Network interface where leave message is sent
226-
* @param addr Multicast group to leave
227-
*
228-
* @return Return 0 if leaving is done, <0 otherwise.
229-
*/
230-
#if defined(CONFIG_NET_IPV6_MLD)
231-
int net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr);
232-
#else
233-
static inline int
234-
net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr)
235-
{
236-
ARG_UNUSED(iface);
237-
ARG_UNUSED(addr);
238-
239-
return -ENOTSUP;
240-
}
241-
#endif /* CONFIG_NET_IPV6_MLD */
242-
243201
/**
244202
* @brief Send MLDv2 report message with a single entry.
245203
*

subsys/net/ip/ipv6_mld.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
LOG_MODULE_DECLARE(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL);
1313

1414
#include <errno.h>
15+
#include <zephyr/net/mld.h>
1516
#include <zephyr/net/net_core.h>
1617
#include <zephyr/net/net_pkt.h>
1718
#include <zephyr/net/net_stats.h>

subsys/net/ip/net_if.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL);
1717
#include <string.h>
1818
#include <zephyr/net/igmp.h>
1919
#include <zephyr/net/ipv4_autoconf.h>
20+
#include <zephyr/net/mld.h>
2021
#include <zephyr/net/net_core.h>
2122
#include <zephyr/net/net_event.h>
2223
#include <zephyr/net/net_pkt.h>

subsys/net/lib/dns/llmnr_responder.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ LOG_MODULE_REGISTER(net_llmnr_responder, CONFIG_LLMNR_RESPONDER_LOG_LEVEL);
2121
#include <errno.h>
2222
#include <stdlib.h>
2323

24+
#include <zephyr/net/mld.h>
2425
#include <zephyr/net/net_ip.h>
2526
#include <zephyr/net/net_pkt.h>
2627
#include <zephyr/net/dns_resolve.h>

subsys/net/lib/dns/mdns_responder.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(net_mdns_responder, CONFIG_MDNS_RESPONDER_LOG_LEVEL);
2222
#include <errno.h>
2323
#include <stdlib.h>
2424

25+
#include <zephyr/net/mld.h>
2526
#include <zephyr/net/net_core.h>
2627
#include <zephyr/net/net_ip.h>
2728
#include <zephyr/net/net_pkt.h>

subsys/net/lib/shell/ipv6.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <zephyr/logging/log.h>
99
LOG_MODULE_DECLARE(net_shell);
1010

11+
#include <zephyr/net/mld.h>
12+
1113
#include "net_shell_private.h"
1214
#include "../ip/ipv6.h"
1315

subsys/net/lib/sockets/sockets_inet.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
LOG_MODULE_DECLARE(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL);
1212

1313
#include <zephyr/kernel.h>
14+
#include <zephyr/net/mld.h>
1415
#include <zephyr/net/net_context.h>
1516
#include <zephyr/net/net_pkt.h>
1617
#include <zephyr/tracing/tracing.h>

subsys/net/lib/zperf/zperf_udp_receiver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
1212

1313
#include <zephyr/kernel.h>
1414

15+
#include <zephyr/net/mld.h>
1516
#include <zephyr/net/socket.h>
1617
#include <zephyr/net/socket_service.h>
1718
#include <zephyr/net/zperf.h>

0 commit comments

Comments
 (0)