Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: ipv6: Make Multicast Listener Discovery API public #79274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions include/zephyr/net/mld.h
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the API existed before as internal but it seems odd to state 1.8 here since strictly speaking it's being introduced only now as public API?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API could have been called earlier too by the application even if it was internal, so I think it is ok to have the version set when the API was created.

* @version 0.8.0
* @ingroup networking
* @{
*/

#include <errno.h>

#include <zephyr/net/net_if.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/toolchain.h>

#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 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)
{

Check notice on line 47 in include/zephyr/net/mld.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/mld.h:47 -static inline int -net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr) +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 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)
{

Check notice on line 68 in include/zephyr/net/mld.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/mld.h:68 -static inline int -net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr) +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_ */
1 change: 1 addition & 0 deletions samples/net/sockets/coap_server/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
LOG_MODULE_REGISTER(net_coap_service_sample, LOG_LEVEL_DBG);

#include <zephyr/net/coap_service.h>
#include <zephyr/net/mld.h>

#ifdef CONFIG_NET_IPV6
#include "net_private.h"
Expand Down
42 changes: 0 additions & 42 deletions subsys/net/ip/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/ipv6_mld.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
LOG_MODULE_DECLARE(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL);

#include <errno.h>
#include <zephyr/net/mld.h>
#include <zephyr/net/net_core.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/net_stats.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL);
#include <string.h>
#include <zephyr/net/igmp.h>
#include <zephyr/net/ipv4_autoconf.h>
#include <zephyr/net/mld.h>
#include <zephyr/net/net_core.h>
#include <zephyr/net/net_event.h>
#include <zephyr/net/net_pkt.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/dns/llmnr_responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ LOG_MODULE_REGISTER(net_llmnr_responder, CONFIG_LLMNR_RESPONDER_LOG_LEVEL);
#include <errno.h>
#include <stdlib.h>

#include <zephyr/net/mld.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/dns_resolve.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/dns/mdns_responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(net_mdns_responder, CONFIG_MDNS_RESPONDER_LOG_LEVEL);
#include <errno.h>
#include <stdlib.h>

#include <zephyr/net/mld.h>
#include <zephyr/net/net_core.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/net/net_pkt.h>
Expand Down
2 changes: 2 additions & 0 deletions subsys/net/lib/shell/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_shell);

#include <zephyr/net/mld.h>

#include "net_shell_private.h"
#include "../ip/ipv6.h"

Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/sockets/sockets_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
LOG_MODULE_DECLARE(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL);

#include <zephyr/kernel.h>
#include <zephyr/net/mld.h>
#include <zephyr/net/net_context.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/tracing/tracing.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/zperf/zperf_udp_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);

#include <zephyr/kernel.h>

#include <zephyr/net/mld.h>
#include <zephyr/net/socket.h>
#include <zephyr/net/socket_service.h>
#include <zephyr/net/zperf.h>
Expand Down
1 change: 1 addition & 0 deletions tests/net/ipv6/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL);

#include <zephyr/ztest.h>

#include <zephyr/net/mld.h>
#include <zephyr/net/net_core.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/net_ip.h>
Expand Down
1 change: 1 addition & 0 deletions tests/net/mld/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL);

#include <zephyr/ztest.h>

#include <zephyr/net/mld.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/net_ip.h>
Expand Down
Loading