Date: Fri, 26 Apr 2024 14:01:59 -0600 From: Warner Losh <imp@bsdimp.com> To: FreeBSD Net <freebsd-net@freebsd.org> Subject: Question about netinet6/in6.h Message-ID: <CANCZdfrDTktpyW9Ad=3-K9qnVYmY_wCnrmyizvgwJktVfHfV3Q@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
This has to be a FAQ
I'm porting a program from Linux, I often see an error like:
../test/mock-ifaddrs.c:95:19: error: no member named 's6_addr32' in 'struct
in6_addr'
95 | ipv6->sin6_addr.s6_addr32[3] = 0;
| ~~~~~~~~~~~~~~~ ^
but yet, we kinda define them, but only for the kernel and boot loader:
/*
* IPv6 address
*/
struct in6_addr {
union {
uint8_t __u6_addr8[16];
uint16_t __u6_addr16[8];
uint32_t __u6_addr32[4];
} __u6_addr; /* 128-bit IP6 address */
};
#define s6_addr __u6_addr.__u6_addr8
#if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */
#define s6_addr8 __u6_addr.__u6_addr8
#define s6_addr16 __u6_addr.__u6_addr16
#define s6_addr32 __u6_addr.__u6_addr32
#endif
I'm wondering if anybody why it's like that? git blame suggests we imported
that from kame, with
only tweaks by people that are now deceased*.*
Why not just expose them?
Warner
[-- Attachment #2 --]
<div dir="ltr"><div>This has to be a FAQ</div><div><br></div><div>I'm porting a program from Linux, I often see an error like:</div><div>../test/mock-ifaddrs.c:95:19: error: no member named 's6_addr32' in 'struct in6_addr'<br> 95 | ipv6->sin6_addr.s6_addr32[3] = 0;<br> | ~~~~~~~~~~~~~~~ ^</div><div>but yet, we kinda define them, but only for the kernel and boot loader:</div><div>/*<br> * IPv6 address<br> */<br>struct in6_addr {<br> union {<br> uint8_t __u6_addr8[16];<br> uint16_t __u6_addr16[8];<br> uint32_t __u6_addr32[4];<br> } __u6_addr; /* 128-bit IP6 address */<br>};<br><br>#define s6_addr __u6_addr.__u6_addr8<br>#if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */<br>#define s6_addr8 __u6_addr.__u6_addr8<br>#define s6_addr16 __u6_addr.__u6_addr16<br>#define s6_addr32 __u6_addr.__u6_addr32<br>#endif</div><div><br></div><div>I'm wondering if anybody why it's like that? git blame suggests we imported that from kame, with</div><div>only tweaks by people that are now deceased<b>.</b></div><div><b><br></b></div><div>Why not just expose them?<br></div><div><br></div><div>Warner<br></div></div>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrDTktpyW9Ad=3-K9qnVYmY_wCnrmyizvgwJktVfHfV3Q>
