This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit dfb2f57d6f9309aebb1de7044d3caea330ec0181 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Oct 12 01:20:13 2026 +0200 include/netinet/in.h: Add in6addr_loopback and the multicast scope macros. POSIX defines in6addr_loopback next to in6addr_any, and the IN6_IS_ADDR_MC_NODELOCAL(), _SITELOCAL(), _ORGLOCAL() and _GLOBAL() macros next to IN6_IS_ADDR_MC_LINKLOCAL(); NuttX had only the latter of each. Add them, with the multicast scopes of RFC 4291. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- include/netinet/in.h | 15 ++++++++++++++- libs/libc/net/lib_addrconfig.c | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/netinet/in.h b/include/netinet/in.h index 9647922d662..96e05437996 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -233,9 +233,21 @@ (a)->s6_addr32[1] == 0 && \ (a)->s6_addr32[2] == HTONL(0xffff)) +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x1) + #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x2) +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x5) + +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x8) + +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0xe) + #define IN6_IS_ADDR_SITELOCAL(a) \ (((a)->s6_addr16[0] & HTONS(0xffc0)) == HTONS(0xfec0)) @@ -369,9 +381,10 @@ extern "C" #define EXTERN extern #endif -/* Global IPv6 in6addr_any */ +/* Global IPv6 in6addr_any and in6addr_loopback */ EXTERN const struct in6_addr in6addr_any; +EXTERN const struct in6_addr in6addr_loopback; /**************************************************************************** * Public Function Prototypes diff --git a/libs/libc/net/lib_addrconfig.c b/libs/libc/net/lib_addrconfig.c index 8fb739265b7..1590f4d3040 100644 --- a/libs/libc/net/lib_addrconfig.c +++ b/libs/libc/net/lib_addrconfig.c @@ -49,6 +49,7 @@ ****************************************************************************/ const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; /**************************************************************************** * Public Functions
