|
.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
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 ,
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
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
/* 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) */
/*