From 37b3e941672a71200ddbfabe3e19aff7b5ed73f8 Mon Sep 17 00:00:00 2001 From: Hajimu UMEMOTO Date: Thu, 23 Oct 2003 13:55:36 +0000 Subject: [PATCH] EAI_ADDRFAMILY and EAI_NODATA was deprecated in RFC3493 (aka RFC2553bis). Now, getaddrinfo(3) returns EAI_NONAME instead of EAI_NODATA. Our getaddrinfo(3) nor getnameinfo(3) didn't use EAI_ADDRFAMILY. Obtained from: KAME --- contrib/telnet/telnet/commands.c | 4 ++-- lib/libc/net/getaddrinfo.3 | 7 ------- lib/libc/net/getaddrinfo.c | 14 ++++---------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c index 32aca9f751c4..2635a20e490a 100644 --- a/contrib/telnet/telnet/commands.c +++ b/contrib/telnet/telnet/commands.c @@ -2241,7 +2241,7 @@ tn(int argc, char *argv[]) hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(src_addr, 0, &hints, &src_res); - if (error == EAI_NODATA) { + if (error == EAI_NONAME) { hints.ai_flags = 0; error = getaddrinfo(src_addr, 0, &hints, &src_res); } @@ -2950,7 +2950,7 @@ sourceroute(struct addrinfo *ai, char *arg, char **cpp, int *lenp, int *protop, hints.ai_flags = AI_NUMERICHOST; error = getaddrinfo(cp, NULL, &hints, &res); - if (error == EAI_NODATA) { + if (error == EAI_NONAME) { hints.ai_flags = 0; error = getaddrinfo(cp, NULL, &hints, &res); } diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index c1932af432cd..36922dab8521 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -520,10 +520,6 @@ Non-zero error codes are defined in and as follows: .Pp .Bl -tag -width EAI_ADDRFAMILY -compact -.It Dv EAI_ADDRFAMILY -Address family for -.Fa nodename -not supported. .It Dv EAI_AGAIN Temporary failure in name resolution. .It Dv EAI_BADFLAGS @@ -538,9 +534,6 @@ address family is not supported. .It Dv EAI_MEMORY Memory allocation failure. -.It Dv EAI_NODATA -No address associated with -.Fa nodename . .It Dv EAI_NONAME Neither .Fa nodename diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index b298928e09c7..3173dc1287e9 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -244,17 +244,11 @@ static struct ai_errlist { int code; } ai_errlist[] = { { "Success", 0, }, -#ifdef EAI_ADDRFAMILY - { "Address family for hostname not supported", EAI_ADDRFAMILY, }, -#endif { "Temporary failure in name resolution", EAI_AGAIN, }, { "Invalid value for ai_flags", EAI_BADFLAGS, }, { "Non-recoverable failure in name resolution", EAI_FAIL, }, { "ai_family not supported", EAI_FAMILY, }, { "Memory allocation failure", EAI_MEMORY, }, -#ifdef EAI_NODATA - { "No address associated with hostname", EAI_NODATA, }, -#endif { "hostname nor servname provided, or not known", EAI_NONAME, }, { "servname not supported for ai_socktype", EAI_SERVICE, }, { "ai_socktype not supported", EAI_SOCKTYPE, }, @@ -524,10 +518,10 @@ getaddrinfo(hostname, servname, hints, res) if (sentinel.ai_next) goto good; + if (hostname == NULL) + ERR(EAI_NONAME); /* used to be EAI_NODATA */ if (pai->ai_flags & AI_NUMERICHOST) ERR(EAI_NONAME); - if (hostname == NULL) - ERR(EAI_NODATA); if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(&ai0)) ERR(EAI_FAIL); @@ -628,7 +622,7 @@ explore_fqdn(pai, hostname, servname, res) error = EAI_FAIL; goto free; case NS_NOTFOUND: - error = EAI_NODATA; + error = EAI_NONAME; goto free; case NS_SUCCESS: error = 0; @@ -843,7 +837,7 @@ explore_numeric_scope(pai, hostname, servname, res) sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr; if (ip6_str2scopeid(scope, sin6, &scopeid) == -1) { free(hostname2); - return(EAI_NODATA); /* XXX: is return OK? */ + return(EAI_NONAME); /* XXX: is return OK? */ } sin6->sin6_scope_id = scopeid; }