1lfk.22.1714161730810; Fri, 26 Apr 2024 13:02:10 -0700 (PDT) List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@FreeBSD.org MIME-Version: 1.0 From: Warner Losh Date: Fri, 26 Apr 2024 14:01:59 -0600 Message-ID: Subject: Question about netinet6/in6.h To: FreeBSD Net Content-Type: multipart/alternative; boundary="0000000000000d9ca5061705613d" X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.99 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.994]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20230601.gappssmtp.com:s=20230601]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCPT_COUNT_ONE(0.00)[1]; R_SPF_NA(0.00)[no SPF record]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MISSING_XM_UA(0.00)[]; DMARC_NA(0.00)[bsdimp.com]; TO_DN_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-net@freebsd.org]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::236:from]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; DKIM_TRACE(0.00)[bsdimp-com.20230601.gappssmtp.com:+] X-Rspamd-Queue-Id: 4VR3Xk1r6wz48Bf --0000000000000d9ca5061705613d Content-Type: text/plain; charset="UTF-8" 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 --0000000000000d9ca5061705613d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 's= truct in6_addr'
=C2=A0 =C2=A095 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 ipv6->sin6_addr.s6_addr32[3] =3D 0;
=C2=A0 =C2= =A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ~~~~~~= ~~~~~~~~~ ^
but yet, we kinda define them, but only for the kerne= l and boot loader:
/*
=C2=A0* IPv6 address
=C2=A0*/
stru= ct in6_addr {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 union {
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t =C2=A0 =C2=A0 =C2=A0 =C2=A0 = __u6_addr8[16];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = uint16_t =C2=A0 =C2=A0 =C2=A0 =C2=A0__u6_addr16[8];
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint32_t =C2=A0 =C2=A0 =C2=A0 =C2=A0__u= 6_addr32[4];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 } __u6_addr; =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* 128-bit IP6 address = */
};

#define s6_addr =C2=A0 __u6_addr.__u6_addr8
#if defined(= _KERNEL) || defined(_STANDALONE) /* XXX nonstandard */
#define s6_addr8 = =C2=A0__u6_addr.__u6_addr8
#define s6_addr16 __u6_addr.__u6_addr16
#d= efine s6_addr32 __u6_addr.__u6_addr32
#endif

I&= #39;m wondering if anybody why it's like that? git blame suggests we im= ported that from kame, with
only tweaks by people that are now de= ceased.

Why not just expose them?

Warner
--0000000000000d9ca5061705613d--