gai_strerror() - Update string error messages according to RFC 3493.

Error messages in gai_strerror(3) vary largely among OSs.

For new software we largely replaced the obsoleted EAI_NONAME and
with EAI_NODATA but we never updated the corresponding message to better
match the intended use. We also have references to ai_flags and ai_family
which are not very descriptive for non-developer end users.

Bring new new error messages based on informational RFC 3493, which has
obsoleted RFC 2553, and make them consistent among the header adn
manpage.

MFC after:	1 month
Differentical Revision:	D18630
This commit is contained in:
Pedro F. Giffuni 2018-12-23 18:15:48 +00:00
parent 2686f69ed4
commit 09ed804717
3 changed files with 34 additions and 37 deletions

View File

@ -159,24 +159,24 @@ struct addrinfo {
#define NO_ADDRESS NO_DATA /* no address, look for MX record */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */
/* /*
* Error return codes from getaddrinfo() * Error return codes from gai_strerror(3), see RFC 3493.
*/ */
#if 0 #if 0
/* obsoleted */ /* Obsoleted on RFC 2553bis-02 */
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
#endif #endif
#define EAI_AGAIN 2 /* temporary failure in name resolution */ #define EAI_AGAIN 2 /* name could not be resolved at this time */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ #define EAI_BADFLAGS 3 /* flags parameter had an invalid value */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */ #define EAI_FAMILY 5 /* address family was recognized */
#define EAI_MEMORY 6 /* memory allocation failure */ #define EAI_MEMORY 6 /* memory allocation failure */
#if 0 #if 0
/* obsoleted */ /* Obsoleted on RFC 2553bis-02 */
#define EAI_NODATA 7 /* no address associated with hostname */ #define EAI_NODATA 7 /* no address associated with hostname */
#endif #endif
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ #define EAI_NONAME 8 /* name does not resolve */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ #define EAI_SERVICE 9 /* service not recognized for socket type */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ #define EAI_SOCKTYPE 10 /* intended socket type was not recognized */
#define EAI_SYSTEM 11 /* system error returned in errno */ #define EAI_SYSTEM 11 /* system error returned in errno */
#define EAI_BADHINTS 12 /* invalid value for hints */ #define EAI_BADHINTS 12 /* invalid value for hints */
#define EAI_PROTOCOL 13 /* resolved protocol is unknown */ #define EAI_PROTOCOL 13 /* resolved protocol is unknown */

View File

@ -18,7 +18,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd May 21, 2006 .Dd December 23, 2018
.Dt GAI_STRERROR 3 .Dt GAI_STRERROR 3
.Os .Os
.Sh NAME .Sh NAME
@ -44,38 +44,30 @@ The following error codes and their meaning are defined in
.Pp .Pp
.Bl -tag -width ".Dv EAI_BADFLAGS" -offset indent -compact .Bl -tag -width ".Dv EAI_BADFLAGS" -offset indent -compact
.It Dv EAI_AGAIN .It Dv EAI_AGAIN
temporary failure in name resolution Name could not be resolved at this time
.It Dv EAI_BADFLAGS .It Dv EAI_BADFLAGS
invalid value for flags parameter had an invalid value
.Fa ai_flags
.It Dv EAI_BADHINTS .It Dv EAI_BADHINTS
invalid value for invalid value for
.Fa hints .Fa hints
.It Dv EAI_FAIL .It Dv EAI_FAIL
non-recoverable failure in name resolution Non-recoverable failure in name resolution
.It Dv EAI_FAMILY .It Dv EAI_FAMILY
.Fa ai_family Address family was not recognized
not supported
.It Dv EAI_MEMORY .It Dv EAI_MEMORY
memory allocation failure Memory allocation failure
.It Dv EAI_NONAME .It Dv EAI_NONAME
.Fa hostname Name does not resolve
or
.Fa servname
not provided, or not known
.It Dv EAI_OVERFLOW .It Dv EAI_OVERFLOW
argument buffer overflow argument buffer overflow
.It Dv EAI_PROTOCOL .It Dv EAI_PROTOCOL
resolved protocol is unknown Resolved protocol is unknown
.It Dv EAI_SERVICE .It Dv EAI_SERVICE
.Fa servname Service was not recognized for socket type
not supported for
.Fa ai_socktype
.It Dv EAI_SOCKTYPE .It Dv EAI_SOCKTYPE
.Fa ai_socktype Intended socket type was not recognized
not supported
.It Dv EAI_SYSTEM .It Dv EAI_SYSTEM
system error returned in System error returned in
.Va errno .Va errno
.El .El
.Sh RETURN VALUES .Sh RETURN VALUES
@ -90,3 +82,8 @@ is out of range, an implementation-specific error message string is returned.
.Sh SEE ALSO .Sh SEE ALSO
.Xr getaddrinfo 3 , .Xr getaddrinfo 3 ,
.Xr getnameinfo 3 .Xr getnameinfo 3
.Sh STANDARDS
.Bl -tag -width ".It RFC 2743"
.It RFC 3493
Basic Socket Interface Extensions for IPv6
.El

View File

@ -45,19 +45,19 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h" #include "un-namespace.h"
/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */ /* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
/* for backward compatibility with userland code prior to 2553bis-02 */ /* for backwards compatibility with userland code prior to RFC2553bis-02 */
static const char *ai_errlist[] = { static const char *ai_errlist[] = {
"Success", /* 0 */ "Success", /* 0 */
"Address family for hostname not supported", /* 1 */ "Address family for hostname not supported", /* 1: Obsolete */
"Temporary failure in name resolution", /* EAI_AGAIN */ "Name could not be resolved at this time", /* EAI_AGAIN */
"Invalid value for ai_flags", /* EAI_BADFLAGS */ "Flags parameter had an invalid value", /* EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /* EAI_FAIL */ "Non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */ "Address family not recognized", /* EAI_FAMILY */
"Memory allocation failure", /* EAI_MEMORY */ "Memory allocation failure", /* EAI_MEMORY */
"No address associated with hostname", /* 7 */ "No address associated with hostname", /* 7: Obsolete*/
"hostname nor servname provided, or not known", /* EAI_NONAME */ "Name does not resolve", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */ "Service was not recognized for socket type", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */ "Intended socket type was not recognized", /* EAI_SOCKTYPE */
"System error returned in errno", /* EAI_SYSTEM */ "System error returned in errno", /* EAI_SYSTEM */
"Invalid value for hints", /* EAI_BADHINTS */ "Invalid value for hints", /* EAI_BADHINTS */
"Resolved protocol is unknown", /* EAI_PROTOCOL */ "Resolved protocol is unknown", /* EAI_PROTOCOL */