in6.h: expose s6_addr* definitions to user level

The only element of of in6_addr that is specified in RFC 3493 or
in POSIX.1-2017 is s6_addr, implemented via a #define to a union
member.  However, FreeBSD and other BSD systems have additional
definitions for the other union members, s6_addr{8,16,32} which
are defined for the kernel and loader.  Some Linux applications
also use them, and they seem to be allowed by the RFC and POSIX.
Remove the current ifdefs, exposing the additional fields to user
level, and replace with #if __BSD_VISIBLE.  Add an explanatory
comment expanding on the previous "nonstandard" comment.

MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D44979
This commit is contained in:
Mike Karels 2024-05-02 10:24:37 -05:00
parent eee88ef45f
commit eb3dbf2dbe

View file

@ -100,7 +100,13 @@ struct in6_addr {
};
#define s6_addr __u6_addr.__u6_addr8
#if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */
#if __BSD_VISIBLE
/*
* s6_addr is the only in6_addr element specified in RFCs 2553 and 3493,
* also in POSIX 1003.1-2017. The following three definitions were not
* exposed to user programs in FreeBSD before 14.1, or in other BSDs,
* and are thus less portable than s6_addr.
*/
#define s6_addr8 __u6_addr.__u6_addr8
#define s6_addr16 __u6_addr.__u6_addr16
#define s6_addr32 __u6_addr.__u6_addr32