summaryrefslogtreecommitdiffstats
path: root/contrib/bind/lib/irs
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2002-05-13 19:31:58 +0000
committernectar <nectar@FreeBSD.org>2002-05-13 19:31:58 +0000
commite044c1fb924b46fc1bd38b298ebea9ff73ea93a8 (patch)
treead4e7f0a2c657d90248bf0c8bd8fac9e5f66a622 /contrib/bind/lib/irs
parentebeabb1ba32f14e308ae9aff9a2a7151265259cf (diff)
downloadFreeBSD-src-e044c1fb924b46fc1bd38b298ebea9ff73ea93a8.zip
FreeBSD-src-e044c1fb924b46fc1bd38b298ebea9ff73ea93a8.tar.gz
Import of ISC BIND 8.3.2-T1B.
Diffstat (limited to 'contrib/bind/lib/irs')
-rw-r--r--contrib/bind/lib/irs/dns_ho.c246
-rw-r--r--contrib/bind/lib/irs/dns_nw.c65
-rw-r--r--contrib/bind/lib/irs/getaddrinfo.c9
-rw-r--r--contrib/bind/lib/irs/getnameinfo.c22
4 files changed, 212 insertions, 130 deletions
diff --git a/contrib/bind/lib/irs/dns_ho.c b/contrib/bind/lib/irs/dns_ho.c
index e340f02..7d64e53 100644
--- a/contrib/bind/lib/irs/dns_ho.c
+++ b/contrib/bind/lib/irs/dns_ho.c
@@ -52,7 +52,7 @@
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_ho.c,v 1.33 2001/10/05 04:30:21 marka Exp $";
+static const char rcsid[] = "$Id: dns_ho.c,v 1.35 2002/05/08 01:49:27 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@@ -256,47 +256,55 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
char tmp[NS_MAXDNAME];
const char *cp;
struct addrinfo ai;
- struct dns_res_target q, q2, *p;
+ struct dns_res_target *q, *q2, *p;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
return (NULL);
- memset(&q, 0, sizeof(q2));
- memset(&q2, 0, sizeof(q2));
+ q = memget(sizeof(*q));
+ q2 = memget(sizeof(*q2));
+ if (q == NULL || q2 == NULL) {
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
+ errno = ENOMEM;
+ goto cleanup;
+ }
+ memset(q, 0, sizeof(q));
+ memset(q2, 0, sizeof(q2));
switch (af) {
case AF_INET:
size = INADDRSZ;
- q.qclass = C_IN;
- q.qtype = T_A;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.action = RESTGT_DOALWAYS;
+ q->qclass = C_IN;
+ q->qtype = T_A;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->action = RESTGT_DOALWAYS;
break;
case AF_INET6:
size = IN6ADDRSZ;
- q.qclass = C_IN;
- q.qtype = ns_t_a6;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.next = &q2;
+ q->qclass = C_IN;
+ q->qtype = ns_t_a6;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
- q.action = RESTGT_IGNORE;
+ q->action = RESTGT_IGNORE;
else
#endif
- q.action = RESTGT_DOALWAYS;
- q2.qclass = C_IN;
- q2.qtype = T_AAAA;
- q2.answer = q2.qbuf.buf;
- q2.anslen = sizeof(q2.qbuf);
- q2.action = RESTGT_AFTERFAILURE;
+ q->action = RESTGT_DOALWAYS;
+ q2->qclass = C_IN;
+ q2->qtype = T_AAAA;
+ q2->answer = q2->qbuf.buf;
+ q2->anslen = sizeof(q2->qbuf);
+ q2->action = RESTGT_AFTERFAILURE;
break;
default:
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = EAFNOSUPPORT;
- return (NULL);
+ hp = NULL;
+ goto cleanup;
}
/*
@@ -308,7 +316,7 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
tmp, sizeof tmp)))
name = cp;
- for (p = &q; p; p = p->next) {
+ for (p = q; p; p = p->next) {
switch(p->action) {
case RESTGT_DOALWAYS:
break;
@@ -331,13 +339,18 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
if ((hp = gethostans(this, p->answer, n, name, p->qtype,
af, size, NULL,
(const struct addrinfo *)&ai)) != NULL)
- return(hp); /* no more loop is necessary */
+ goto cleanup; /* no more loop is necessary */
querystate = RESQRY_FAIL;
continue;
}
- return(hp); /* should be NULL */
+ cleanup:
+ if (q != NULL)
+ memput(q, sizeof(*q));
+ if (q2 != NULL)
+ memput(q2, sizeof(*q2));
+ return(hp);
}
static struct hostent *
@@ -346,17 +359,24 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
struct pvt *pvt = (struct pvt *)this->private;
const u_char *uaddr = addr;
char *qp;
- struct hostent *hp;
+ struct hostent *hp = NULL;
struct addrinfo ai;
- struct dns_res_target q, q2, *p;
+ struct dns_res_target *q, *q2, *p;
int n, size;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
return (NULL);
- memset(&q, 0, sizeof(q2));
- memset(&q2, 0, sizeof(q2));
+ q = memget(sizeof(*q));
+ q2 = memget(sizeof(*q2));
+ if (q == NULL || q2 == NULL) {
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
+ errno = ENOMEM;
+ goto cleanup;
+ }
+ memset(q, 0, sizeof(q));
+ memset(q2, 0, sizeof(q2));
if (af == AF_INET6 && len == IN6ADDRSZ &&
(!memcmp(uaddr, mapped, sizeof mapped) ||
@@ -371,45 +391,47 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
switch (af) {
case AF_INET:
size = INADDRSZ;
- q.qclass = C_IN;
- q.qtype = T_PTR;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.action = RESTGT_DOALWAYS;
+ q->qclass = C_IN;
+ q->qtype = T_PTR;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->action = RESTGT_DOALWAYS;
break;
case AF_INET6:
size = IN6ADDRSZ;
- q.qclass = C_IN;
- q.qtype = T_PTR;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.next = &q2;
+ q->qclass = C_IN;
+ q->qtype = T_PTR;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->next = q2;
if ((pvt->res->options & RES_NO_BITSTRING) != 0)
- q.action = RESTGT_IGNORE;
+ q->action = RESTGT_IGNORE;
else
- q.action = RESTGT_DOALWAYS;
- q2.qclass = C_IN;
- q2.qtype = T_PTR;
- q2.answer = q2.qbuf.buf;
- q2.anslen = sizeof(q2.qbuf);
+ q->action = RESTGT_DOALWAYS;
+ q2->qclass = C_IN;
+ q2->qtype = T_PTR;
+ q2->answer = q2->qbuf.buf;
+ q2->anslen = sizeof(q2->qbuf);
if ((pvt->res->options & RES_NO_NIBBLE) != 0)
- q2.action = RESTGT_IGNORE;
+ q2->action = RESTGT_IGNORE;
else
- q2.action = RESTGT_AFTERFAILURE;
+ q2->action = RESTGT_AFTERFAILURE;
break;
default:
errno = EAFNOSUPPORT;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
- return (NULL);
+ hp = NULL;
+ goto cleanup;
}
if (size > len) {
errno = EINVAL;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
- return (NULL);
+ hp = NULL;
+ goto cleanup;
}
switch (af) {
case AF_INET:
- qp = q.qname;
+ qp = q->qname;
(void) sprintf(qp, "%u.%u.%u.%u.in-addr.arpa",
(uaddr[3] & 0xff),
(uaddr[2] & 0xff),
@@ -417,16 +439,16 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
(uaddr[0] & 0xff));
break;
case AF_INET6:
- if (q.action != RESTGT_IGNORE) {
- qp = q.qname;
+ if (q->action != RESTGT_IGNORE) {
+ qp = q->qname;
qp += SPRINTF((qp, "\\[x"));
for (n = 0; n < IN6ADDRSZ; n++)
qp += SPRINTF((qp, "%02x", uaddr[n]));
SPRINTF((qp, "/128].%s",
res_get_bitstringsuffix(pvt->res)));
}
- if (q2.action != RESTGT_IGNORE) {
- qp = q2.qname;
+ if (q2->action != RESTGT_IGNORE) {
+ qp = q2->qname;
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
qp += SPRINTF((qp, "%x.%x.",
uaddr[n] & 0xf,
@@ -439,7 +461,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
abort();
}
- for (p = &q; p; p = p->next) {
+ for (p = q; p; p = p->next) {
switch(p->action) {
case RESTGT_DOALWAYS:
break;
@@ -477,10 +499,16 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
}
RES_SET_H_ERRNO(pvt->res, NETDB_SUCCESS);
- return (hp); /* no more loop is necessary. */
+ goto cleanup; /* no more loop is necessary. */
}
-
- return(NULL); /* H_ERRNO was set by subroutines */
+ hp = NULL; /* H_ERRNO was set by subroutines */
+
+ cleanup:
+ if (q != NULL)
+ memput(q, sizeof(*q));
+ if (q2 != NULL)
+ memput(q2, sizeof(*q2));
+ return(hp);
}
static struct hostent *
@@ -536,74 +564,83 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
int n;
char tmp[NS_MAXDNAME];
const char *cp;
- struct dns_res_target q, q2, q3, *p;
+ struct dns_res_target *q, *q2, *q3, *p;
struct addrinfo sentinel, *cur;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
return (NULL);
- memset(&q, 0, sizeof(q2));
- memset(&q2, 0, sizeof(q2));
- memset(&q3, 0, sizeof(q3));
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
+ q = memget(sizeof(*q));
+ q2 = memget(sizeof(*q2));
+ q3 = memget(sizeof(*q3));
+ if (q == NULL || q2 == NULL || q3 == NULL) {
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
+ errno = ENOMEM;
+ goto cleanup;
+ }
+ memset(q, 0, sizeof(q2));
+ memset(q2, 0, sizeof(q2));
+ memset(q3, 0, sizeof(q3));
+
switch (pai->ai_family) {
case AF_UNSPEC:
/* prefer IPv6 */
- q.qclass = C_IN;
- q.qtype = ns_t_a6;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.next = &q2;
+ q->qclass = C_IN;
+ q->qtype = ns_t_a6;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
- q.action = RESTGT_IGNORE;
+ q->action = RESTGT_IGNORE;
else
#endif
- q.action = RESTGT_DOALWAYS;
- q2.qclass = C_IN;
- q2.qtype = T_AAAA;
- q2.answer = q2.qbuf.buf;
- q2.anslen = sizeof(q2.qbuf);
- q2.next = &q3;
+ q->action = RESTGT_DOALWAYS;
+ q2->qclass = C_IN;
+ q2->qtype = T_AAAA;
+ q2->answer = q2->qbuf.buf;
+ q2->anslen = sizeof(q2->qbuf);
+ q2->next = q3;
/* try AAAA only when A6 query fails */
- q2.action = RESTGT_AFTERFAILURE;
- q3.qclass = C_IN;
- q3.qtype = T_A;
- q3.answer = q3.qbuf.buf;
- q3.anslen = sizeof(q3.qbuf);
- q3.action = RESTGT_DOALWAYS;
+ q2->action = RESTGT_AFTERFAILURE;
+ q3->qclass = C_IN;
+ q3->qtype = T_A;
+ q3->answer = q3->qbuf.buf;
+ q3->anslen = sizeof(q3->qbuf);
+ q3->action = RESTGT_DOALWAYS;
break;
case AF_INET:
- q.qclass = C_IN;
- q.qtype = T_A;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.action = RESTGT_DOALWAYS;
+ q->qclass = C_IN;
+ q->qtype = T_A;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->action = RESTGT_DOALWAYS;
break;
case AF_INET6:
- q.qclass = C_IN;
- q.qtype = ns_t_a6;
- q.answer = q.qbuf.buf;
- q.anslen = sizeof(q.qbuf);
- q.next = &q2;
+ q->qclass = C_IN;
+ q->qtype = ns_t_a6;
+ q->answer = q->qbuf.buf;
+ q->anslen = sizeof(q->qbuf);
+ q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
- q.action = RESTGT_IGNORE;
+ q->action = RESTGT_IGNORE;
else
#endif
- q.action = RESTGT_DOALWAYS;
- q2.qclass = C_IN;
- q2.qtype = T_AAAA;
- q2.answer = q2.qbuf.buf;
- q2.anslen = sizeof(q2.qbuf);
- q2.action = RESTGT_AFTERFAILURE;
+ q->action = RESTGT_DOALWAYS;
+ q2->qclass = C_IN;
+ q2->qtype = T_AAAA;
+ q2->answer = q2->qbuf.buf;
+ q2->anslen = sizeof(q2->qbuf);
+ q2->action = RESTGT_AFTERFAILURE;
break;
default:
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* better error? */
- return(NULL);
+ goto cleanup;
}
/*
@@ -615,7 +652,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
tmp, sizeof tmp)))
name = cp;
- for (p = &q; p; p = p->next) {
+ for (p = q; p; p = p->next) {
struct addrinfo *ai;
switch(p->action) {
@@ -647,6 +684,13 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
querystate = RESQRY_FAIL;
}
+ cleanup:
+ if (q != NULL)
+ memput(q, sizeof(*q));
+ if (q2 != NULL)
+ memput(q2, sizeof(*q2));
+ if (q3 != NULL)
+ memput(q3, sizeof(*q3));
return(sentinel.ai_next);
}
@@ -1153,8 +1197,6 @@ gethostans(struct irs_ho *this,
eor = cp + n;
if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 ||
qtype == T_ANY) && type == T_CNAME) {
- if (ap >= &pvt->host_aliases[MAXALIASES-1])
- continue;
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
if (n < 0 || !maybe_ok(pvt->res, tbuf, name_ok)) {
had_error++;
@@ -1162,6 +1204,8 @@ gethostans(struct irs_ho *this,
}
cp += n;
/* Store alias. */
+ if (ap >= &pvt->host_aliases[MAXALIASES-1])
+ continue;
*ap++ = bp;
n = strlen(bp) + 1; /* for the \0 */
bp += n;
diff --git a/contrib/bind/lib/irs/dns_nw.c b/contrib/bind/lib/irs/dns_nw.c
index 8e0e965..fbc613f 100644
--- a/contrib/bind/lib/irs/dns_nw.c
+++ b/contrib/bind/lib/irs/dns_nw.c
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_nw.c,v 1.21 2001/11/30 00:36:53 marka Exp $";
+static const char rcsid[] = "$Id: dns_nw.c,v 1.22 2002/02/27 03:50:10 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@@ -240,22 +240,33 @@ nw_res_set(struct irs_nw *this, struct __res_state *res,
static struct nwent *
get1101byname(struct irs_nw *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
- u_char ansbuf[MAXPACKET];
+ u_char *ansbuf;
int anslen;
+ struct nwent *result;
- anslen = res_nsearch(pvt->res, name, C_IN, T_PTR,
- ansbuf, sizeof ansbuf);
- if (anslen < 0)
+ ansbuf = memget(MAXPACKET);
+ if (ansbuf == NULL) {
+ errno = ENOMEM;
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
return (NULL);
- return (get1101mask(this, get1101answer(this, ansbuf, anslen, by_name,
- AF_INET, name, NULL, 0)));
+ }
+ anslen = res_nsearch(pvt->res, name, C_IN, T_PTR, ansbuf, MAXPACKET);
+ if (anslen < 0) {
+ memput(ansbuf, MAXPACKET);
+ return (NULL);
+ }
+ result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_name,
+ AF_INET, name, NULL, 0));
+ memput(ansbuf, MAXPACKET);
+ return (result);
}
static struct nwent *
get1101byaddr(struct irs_nw *this, u_char *net, int len) {
struct pvt *pvt = (struct pvt *)this->private;
char qbuf[sizeof "255.255.255.255.in-addr.arpa"];
- u_char ansbuf[MAXPACKET];
+ struct nwent *result;
+ u_char *ansbuf;
int anslen;
if (len < 1 || len > 32) {
@@ -265,12 +276,21 @@ get1101byaddr(struct irs_nw *this, u_char *net, int len) {
}
if (make1101inaddr(net, len, qbuf, sizeof qbuf) < 0)
return (NULL);
- anslen = res_nquery(pvt->res, qbuf, C_IN, T_PTR,
- ansbuf, sizeof ansbuf);
- if (anslen < 0)
+ ansbuf = memget(MAXPACKET);
+ if (ansbuf == NULL) {
+ errno = ENOMEM;
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
+ return (NULL);
+ }
+ anslen = res_nquery(pvt->res, qbuf, C_IN, T_PTR, ansbuf, MAXPACKET);
+ if (anslen < 0) {
+ memput(ansbuf, MAXPACKET);
return (NULL);
- return (get1101mask(this, get1101answer(this, ansbuf, anslen, by_addr,
- AF_INET, NULL, net, len)));
+ }
+ result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_addr,
+ AF_INET, NULL, net, len));
+ memput(ansbuf, MAXPACKET);
+ return (result);
}
static struct nwent *
@@ -430,7 +450,7 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
struct pvt *pvt = (struct pvt *)this->private;
char qbuf[sizeof "255.255.255.255.in-addr.arpa"], owner[MAXDNAME];
int anslen, type, class, ancount, qdcount;
- u_char ansbuf[MAXPACKET], *cp, *eom;
+ u_char *ansbuf, *cp, *eom;
HEADER *hp;
if (!nwent)
@@ -441,10 +461,18 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
return (nwent);
}
+ ansbuf = memget(MAXPACKET);
+ if (ansbuf == NULL) {
+ errno = ENOMEM;
+ RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
+ return (NULL);
+ }
/* Query for the A RR that would hold this network's mask. */
- anslen = res_nquery(pvt->res, qbuf, C_IN, T_A, ansbuf, sizeof ansbuf);
- if (anslen < HFIXEDSZ)
+ anslen = res_nquery(pvt->res, qbuf, C_IN, T_A, ansbuf, MAXPACKET);
+ if (anslen < HFIXEDSZ) {
+ memput(ansbuf, MAXPACKET);
return (nwent);
+ }
/* Initialize, and parse header. */
hp = (HEADER *)ansbuf;
@@ -454,8 +482,10 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
while (qdcount-- > 0) {
int n = dn_skipname(cp, eom);
cp += n + QFIXEDSZ;
- if (n < 0 || cp > eom)
+ if (n < 0 || cp > eom) {
+ memput(ansbuf, MAXPACKET);
return (nwent);
+ }
}
ancount = ntohs(hp->ancount);
@@ -489,6 +519,7 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
}
cp += n; /* RDATA */
}
+ memput(ansbuf, MAXPACKET);
return (nwent);
}
diff --git a/contrib/bind/lib/irs/getaddrinfo.c b/contrib/bind/lib/irs/getaddrinfo.c
index f2c533d..243f106 100644
--- a/contrib/bind/lib/irs/getaddrinfo.c
+++ b/contrib/bind/lib/irs/getaddrinfo.c
@@ -172,13 +172,6 @@ static const struct explore explore[] = {
#define PTON_MAX 16
-#define MAXPACKET (1024*64)
-
-typedef union {
- HEADER hdr;
- u_char buf[MAXPACKET];
-} querybuf;
-
static int str_isnumber __P((const char *));
static int explore_fqdn __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
@@ -320,7 +313,7 @@ getaddrinfo(hostname, servname, hints, res)
struct addrinfo sentinel;
struct addrinfo *cur;
int error = 0;
- struct addrinfo ai, ai0, *afai;
+ struct addrinfo ai, ai0, *afai = NULL;
struct addrinfo *pai;
const struct explore *ex;
diff --git a/contrib/bind/lib/irs/getnameinfo.c b/contrib/bind/lib/irs/getnameinfo.c
index 0e86cc1..9b26c64 100644
--- a/contrib/bind/lib/irs/getnameinfo.c
+++ b/contrib/bind/lib/irs/getnameinfo.c
@@ -105,9 +105,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
int family, i;
const char *addr;
char *p;
- u_char pfx;
char numserv[512];
char numaddr[512];
+ const struct sockaddr_in6 *sin6;
if (sa == NULL)
return EAI_FAIL;
@@ -157,9 +157,23 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
flags |= NI_NUMERICHOST;
break;
case AF_INET6:
- pfx = *addr;
- if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
- flags |= NI_NUMERICHOST;
+ sin6 = (const struct sockaddr_in6 *)sa;
+ switch (sin6->sin6_addr.s6_addr[0]) {
+ case 0x00:
+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+ ;
+ else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
+ ;
+ else
+ flags |= NI_NUMERICHOST;
+ break;
+ default:
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
+ flags |= NI_NUMERICHOST;
+ else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
+ flags |= NI_NUMERICHOST;
+ break;
+ }
break;
}
if (host == NULL || hostlen == 0) {
OpenPOWER on IntegriCloud