Add IPv6 support to getifaddrs() on Linux (#1415)
Some checks failed
build / matrix_on_mode () (push) Has been cancelled
build / matrix_on_mode (optlinux) (push) Has been cancelled
build / matrix_on_mode (rel) (push) Has been cancelled
build / matrix_on_mode (tiny) (push) Has been cancelled
build / matrix_on_mode (tinylinux) (push) Has been cancelled

This commit is contained in:
Hugues Morisset 2025-05-21 10:20:22 +02:00 committed by GitHub
parent 2fe8338f92
commit f1e83d5240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 256 additions and 33 deletions

View file

@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_
#include "libc/sock/struct/sockaddr.h"
#include "libc/sock/struct/sockaddr6.h"
COSMOPOLITAN_C_START_
#define IF_NAMESIZE 16
@ -11,6 +12,14 @@ struct ifreq {
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
} ifr_ifrn;
union {
struct {
uint16_t sa_family;
uint16_t ifr6_ifindex; /* Interface index */
uint16_t ifr6_flags; /* Flags */
uint8_t ifr6_scope; /* Addr scope */
uint8_t ifr6_prefixlen; /* Prefix length */
struct in6_addr ifr6_addr;
} in6;
struct sockaddr ifru_addr; /* SIOCGIFADDR */
struct sockaddr ifru_dstaddr; /* SIOCGIFDSTADDR */
struct sockaddr ifru_netmask; /* SIOCGIFNETMASK */
@ -29,5 +38,11 @@ struct ifreq {
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_ifindex ifr_ifru.ifru_ivalue
#define ifr6_addr ifr_ifru.in6.ifr6_addr /* IP6 Addr */
#define ifr6_scope ifr_ifru.in6.ifr6_scope /* IP6 Addr scope */
#define ifr6_prefixlen ifr_ifru.in6.ifr6_prefixlen /* IP6 Prefix length */
#define ifr6_ifindex ifr_ifru.in6.ifr6_ifindex /* IP6 If index */
#define ifr6_flags ifr_ifru.in6.ifr6_flags /* IP6 If flags */
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_ */