From 80275baf44fe18876d94b1f7ae2c3acba7b6afc5 Mon Sep 17 00:00:00 2001 From: sperreault <> Date: Mon, 28 Apr 2014 21:38:59 +0000 Subject: [PATCH] Implement AI_ADDRCONFIG This is a getaddrinfo() flag that is defined thusly in RFC 3493: If the AI_ADDRCONFIG flag is specified, IPv4 addresses shall be returned only if an IPv4 address is configured on the local system, and IPv6 addresses shall be returned only if an IPv6 address is configured on the local system. The loopback address is not considered for this case as valid as a configured address. For example, when using the DNS, a query for AAAA records should occur only if the node has at least one IPv6 address configured (other than IPv6 loopback) and a query for A records should occur only if the node has at least one IPv4 address configured (other than the IPv4 loopback). The flag is set by default when hints is NULL. ok Eric Faurot, Jason McIntyre --- src/include/netdb.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/netdb.h b/src/include/netdb.h index a5a1c6b4..a1769222 100644 --- a/src/include/netdb.h +++ b/src/include/netdb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netdb.h,v 1.31 2012/09/15 00:47:08 guenther Exp $ */ +/* $OpenBSD: netdb.h,v 1.32 2014/04/28 21:38:59 sperreault Exp $ */ /* * ++Copyright++ 1980, 1983, 1988, 1993 @@ -167,9 +167,11 @@ extern int h_errno; #define AI_EXT 8 /* enable non-portable extensions */ #define AI_NUMERICSERV 16 /* don't ever try servname lookup */ #define AI_FQDN 32 /* return the FQDN that was resolved */ +#define AI_ADDRCONFIG 64 /* return configured address families only */ /* valid flags for addrinfo */ #define AI_MASK \ - (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN) + (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN | \ + AI_ADDRCONFIG) #define NI_NUMERICHOST 1 /* return the host address, not the name */ #define NI_NUMERICSERV 2 /* return the service address, not the name */