From 4fdff1ba632be8d2ae81563578f1b998d6dc28c5 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 28 Dec 2021 00:10:49 -0800 Subject: [PATCH] LibC: Add in6addr_loopback and IN6ADDR_LOOPBACK_INIT constant Much like the existing in6addr_any global and the IN6ADDR_ANY_INIT macro, our LibC is also expected to export the in6addr_loopback global and the IN6ADDR_LOOPBACK_INIT constant. These were found by the stress-ng port. --- Kernel/API/POSIX/netinet/in.h | 8 +++++++- Userland/Libraries/LibC/net.cpp | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Kernel/API/POSIX/netinet/in.h b/Kernel/API/POSIX/netinet/in.h index ae8eed6523e..be3d1aba6a7 100644 --- a/Kernel/API/POSIX/netinet/in.h +++ b/Kernel/API/POSIX/netinet/in.h @@ -95,7 +95,13 @@ struct in6_addr { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ } -extern struct in6_addr in6addr_any; +#define IN6ADDR_LOOPBACK_INIT \ + { \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 \ + } + +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; struct sockaddr_in6 { sa_family_t sin6_family; // AF_INET6. diff --git a/Userland/Libraries/LibC/net.cpp b/Userland/Libraries/LibC/net.cpp index 145ef4b1536..aa76ec0a6ca 100644 --- a/Userland/Libraries/LibC/net.cpp +++ b/Userland/Libraries/LibC/net.cpp @@ -8,7 +8,8 @@ #include #include -in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; unsigned int if_nametoindex([[maybe_unused]] const char* ifname) {