From d90e699ca2566289cddc68cd0862d05780b54551 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 12 Oct 2017 18:02:04 +0000 Subject: [PATCH] Libinfo-517.30.1.tar.gz --- lookup.subproj/getaddrinfo.3 | 36 +++++++++++++++++++++++++++++++++++- lookup.subproj/libinfo.c | 4 ++++ lookup.subproj/netdb.h | 4 ++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lookup.subproj/getaddrinfo.3 b/lookup.subproj/getaddrinfo.3 index 333fb40..be60d3e 100644 --- a/lookup.subproj/getaddrinfo.3 +++ b/lookup.subproj/getaddrinfo.3 @@ -252,9 +252,38 @@ is defined as ( | .Dv AI_ADDRCONFIG ). +.It Dv AI_UNUSABLE +To override the automatic +.Dv AI_DEFAULT +behavior that occurs when +.Fa ai_flags +is zero pass +.Dv AI_UNUSABLE +instead of zero. +This suppresses the implicit setting of +.Dv AI_V4MAPPED_CFG +and +.Dv AI_ADDRCONFIG , +thereby causing unusable addresses to be included in the results. .El .El .Pp +If +.Fa ai_flags +is zero, +.Fn getaddrinfo +gives the +.Dv AI_DEFAULT +behavior ( +.Dv AI_V4MAPPED_CFG +| +.Dv AI_ADDRCONFIG +). To override this default behavior, pass any nonzero value for +.Fa ai_flags , +by setting any desired flag values, or setting +.Dv AI_UNUSABLE +if no other flags are desired. +.Pp All other elements of the .Li addrinfo structure passed via @@ -272,7 +301,12 @@ with set to .Dv PF_UNSPEC and all other elements set to zero or -.Dv NULL . +.Dv NULL +(which includes treating the +.Fa ai_flags +field as effectively zero, giving the automatic default +.Dv AI_DEFAULT +behavior). .Pp After a successful call to .Fn getaddrinfo , diff --git a/lookup.subproj/libinfo.c b/lookup.subproj/libinfo.c index 93921cc..e263f03 100755 --- a/lookup.subproj/libinfo.c +++ b/lookup.subproj/libinfo.c @@ -2354,6 +2354,8 @@ _getaddrinfo_internal(const char *nodename, const char *servname, const struct a flags = hints->ai_flags; } + if (flags == 0) flags = AI_DEFAULT; + #ifdef CALL_TRACE fprintf(stderr, "-> %s %s %s %u %u %u 0x%08x %s\n", __func__, nodename, servname, family, socktype, protocol, flags, (interface == NULL) ? "" : interface); #endif @@ -2631,6 +2633,8 @@ _getaddrinfo_interface_async_call(const char *nodename, const char *servname, co flags = hints->ai_flags; } + if (flags == 0) flags = AI_DEFAULT; + #ifdef CALL_TRACE fprintf(stderr, ">> %s %s %s %u %u %u 0x%08x\n", __func__, nodename, servname, family, socktype, protocol, flags); #endif diff --git a/lookup.subproj/netdb.h b/lookup.subproj/netdb.h index 762d465..ea30449 100644 --- a/lookup.subproj/netdb.h +++ b/lookup.subproj/netdb.h @@ -228,6 +228,10 @@ struct rpcent { /* special recommended flags for getipnodebyname */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) +/* If the hints pointer is null or ai_flags is zero, getaddrinfo() automatically defaults to the AI_DEFAULT behavior. + * To override this default behavior, thereby causing unusable addresses to be included in the results, pass any nonzero + * value for ai_flags, by setting any desired flag values, or by setting AI_UNUSABLE if no other flags are desired. */ +#define AI_UNUSABLE 0x10000000 /* return addresses even if unusable (i.e. opposite of AI_DEFAULT) */ #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ /* -- 2.7.4