summaryrefslogtreecommitdiffstats
path: root/lib/libc/net
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2003-10-22 15:41:38 +0000
committerume <ume@FreeBSD.org>2003-10-22 15:41:38 +0000
commit241d46a98895e0938c9155b3f511f5361cd6aff0 (patch)
tree1658c1ff3dfe2848b17cbdc5ae8656de174000e3 /lib/libc/net
parentb9e84a669733e25242bc9cd963a465afc79331cb (diff)
downloadFreeBSD-src-241d46a98895e0938c9155b3f511f5361cd6aff0.zip
FreeBSD-src-241d46a98895e0938c9155b3f511f5361cd6aff0.tar.gz
make ai_errlist struct. this is preparation for RFC3493
(EAI_NODATA is depricated). Obtained from: KAME
Diffstat (limited to 'lib/libc/net')
-rw-r--r--lib/libc/net/getaddrinfo.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 2a8ccae..b25e566 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -239,22 +239,32 @@ static int res_searchN(const char *, struct res_target *);
static int res_querydomainN(const char *, const char *,
struct res_target *);
-static char *ai_errlist[] = {
- "Success",
- "Address family for hostname not supported", /* EAI_ADDRFAMILY */
- "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 */
- "No address associated with hostname", /* EAI_NODATA */
- "hostname nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "System error returned in errno", /* EAI_SYSTEM */
- "Invalid value for hints", /* EAI_BADHINTS */
- "Resolved protocol is unknown", /* EAI_PROTOCOL */
- "Unknown error", /* EAI_MAX */
+static struct ai_errlist {
+ const char *str;
+ 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, },
+ { "System error returned in errno", EAI_SYSTEM, },
+ { "Invalid value for hints", EAI_BADHINTS, },
+ { "Resolved protocol is unknown", EAI_PROTOCOL, },
+ /* backward compatibility with userland code prior to 2553bis-02 */
+ { "Address family for hostname not supported", 1, },
+ { "No address associated with hostname", 7, },
+ { NULL, -1, },
};
/*
@@ -314,9 +324,12 @@ char *
gai_strerror(ecode)
int ecode;
{
- if (ecode < 0 || ecode > EAI_MAX)
- ecode = EAI_MAX;
- return ai_errlist[ecode];
+ struct ai_errlist *p;
+
+ for (p = ai_errlist; p->str; p++) {
+ if (p->code == ecode)
+ return (char *)p->str;
+ }
}
void
OpenPOWER on IntegriCloud