From nobody Fri Apr 26 20:01:59 2024 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VR3Xl10cGz5J7ZT for ; Fri, 26 Apr 2024 20:02:15 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VR3Xk1r6wz48Bf for ; Fri, 26 Apr 2024 20:02:14 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20230601.gappssmtp.com header.s=20230601 header.b=B4rezhPu; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2a00:1450:4864:20::236) smtp.mailfrom=wlosh@bsdimp.com Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2d8a24f8a3cso30958381fa.1 for ; Fri, 26 Apr 2024 13:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1714161731; x=1714766531; darn=freebsd.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=druCQ0bU4KTF4+MMOPSFQhXrxnuAIZDe9VxeLprC4YM=; b=B4rezhPuxvMSNQ20NslJOjYJzjBLv1led5zD0CE7Ta0KkLb7d68KvfvpRnwcAAv8ch +1IjfpdpNKU8r0GObeAnWmC7uBkcdBKXYFgmGJgX/sVnFVA1RDw4gR4y3Q/0LrQojyrL oJIKqtPwrr1K+/opZjmdyXcSt3UoPjPxJqp2fZzH1XjeS/4geZzkuoUodyuewi66Zvlc rg49mW5sRnrMkI9QJEEfNT9PNhKv3NI0HNcHQPnQc9OzdgMH2H2eNYLorMJSPeDsrV8z gcFdLf4L2lLnoSLS35BHwxDZF9xoTRvXW5bePJcIx5UF0A4iRuS/F3DiA0Rf+XDQ1BqS DCUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714161731; x=1714766531; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=druCQ0bU4KTF4+MMOPSFQhXrxnuAIZDe9VxeLprC4YM=; b=N/Y876rpTR8kaWwvPqkW8HpBLT++QejlogkZFu8V6AG566LYso33pGQxz0L/cPgWOY I85yZPFiuhBmbbtml8wk/weKdXWbS/5U+bLfIODoaAxIdt6DmMsTF6UK60M5o3R2n9rb VW4wLuPZABfD5+0WO2155kxJ7K4qhKLqo5+z7DTaYkphgftuLdYvkssh3DWartWiIU0u 9bCPfPi0ZFxUT0g0Gp1qhNSZMR3PPo+DMyPOnjc4AfiopHDPQpfVLFmwAJnZWDtOz2/U Rltf/b7+t0wWmgFLYN+CDc9CVi2zSXoK/oxHkNZ5KIxEoJmVReXfkZZRBmxXUK9zDWKn xA/w== X-Gm-Message-State: AOJu0YyYjODVyvfG0Z+mzsitkis7o4WUHdoqkdHEZLsZ5A4sff+LFuyj 8w1TPhKXzsNa23z7sh7sPO1Kg2mwXUuajWgdc+FoD6lfsjy9poY9i3h/HSw6yiJerP5sBITjai8 8iBiTOeCHYKU4FYOt14pn6iceZU4bHC40EjDdAezggK9iJ94l78KrwA== X-Google-Smtp-Source: AGHT+IFDeleFlWpRM/pnIi63QrMl+2RlAX95WR0CgIL++LbNvK3lVQCp2LsmV9W8pANeFqiK+v7/YA1oodoZE/L5Jr8= X-Received: by 2002:a05:6512:44a:b0:51c:348:3ba9 with SMTP id y10-20020a056512044a00b0051c03483ba9mr2270381lfk.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--