git: 40e4e12bd841 - main - netdb.h: re-enable EAI_ADDRFAMILY, EAI_NODATA

From: Mike Karels <karels_at_FreeBSD.org>
Date: Wed, 02 Nov 2022 16:04:28 UTC
The branch main has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=40e4e12bd84154626d5b46c3e862c79da25bc403

commit 40e4e12bd84154626d5b46c3e862c79da25bc403
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2022-11-02 15:43:04 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2022-11-02 16:03:30 +0000

    netdb.h: re-enable EAI_ADDRFAMILY, EAI_NODATA
    
    EAI_ADDRFAMILY and EAI_NODATA are not in RFC 3493, but are available
    and used in many other systems.  It is desirable to have at least one
    of them in order to distinguish between names that do not resolve and
    those that do not have the requested address type.  A change to
    getaddrinfo() will use EAI_ADDRFAMILY.  Both were "#if 0"; re-enable,
    conditioned on __BSD_VISIBLE, and update comments.  Also add comments
    and __BSD_VISIBLE conditional for the last three EAI errors, which
    are not in the RFC or POSIX.  Note, all of these are available in
    NetBSD and OpenBSD, and EAI_ADDRFAMILY and EAI_NODATA are available
    in Linux (glibc).
    
    Reviewed in https://reviews.freebsd.org/D37139 with related changes.
    
    Reviewed by:    bz
    MFC after:      1 month
---
 include/netdb.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/netdb.h b/include/netdb.h
index 93e0ebae4718..7eba378482a1 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -161,8 +161,8 @@ struct addrinfo {
 /*
  * Error return codes from gai_strerror(3), see RFC 3493.
  */
-#if 0
-/* Obsoleted on RFC 3493 */
+#if __BSD_VISIBLE	/* not in POSIX */
+/* EAI_ADDRFAMILY was obsoleted by RFC 3493, used as extension */
 #define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
 #endif
 #define	EAI_AGAIN	 2	/* name could not be resolved at this time */
@@ -170,17 +170,20 @@ struct addrinfo {
 #define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
 #define	EAI_FAMILY	 5	/* address family not recognized */
 #define	EAI_MEMORY	 6	/* memory allocation failure */
-#if 0
-/* Obsoleted on RFC 3493 */
+#if __BSD_VISIBLE	/* not in POSIX */
+/* EAI_NODATA was obsoleted by RFC 3493, retained here as extension */
 #define	EAI_NODATA	 7	/* no address associated with hostname */
 #endif
 #define	EAI_NONAME	 8	/* name does not resolve */
 #define	EAI_SERVICE	 9	/* service not recognized for socket type */
 #define	EAI_SOCKTYPE	10	/* intended socket type was not recognized */
 #define	EAI_SYSTEM	11	/* system error returned in errno */
+#if __BSD_VISIBLE	/* not in POSIX */
+/* The following 3 are not in RFC 3493 or POSIX, retained for compatibility */
 #define	EAI_BADHINTS	12	/* invalid value for hints */
 #define	EAI_PROTOCOL	13	/* resolved protocol is unknown */
 #define	EAI_OVERFLOW	14	/* argument buffer overflow */
+#endif
 #define	EAI_MAX		15
 
 /*