summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2005-01-27 14:41:56 +0000
committerume <ume@FreeBSD.org>2005-01-27 14:41:56 +0000
commit1f1fe48dc9a77d0ec832c8d740c61402285c96a9 (patch)
treee3d196c2e25277b46b8587446d19e969885f4f20 /lib/libc
parent20455e62c2eedc112ec8b6f390b89c9f70fb7d5f (diff)
downloadFreeBSD-src-1f1fe48dc9a77d0ec832c8d740c61402285c96a9.zip
FreeBSD-src-1f1fe48dc9a77d0ec832c8d740c61402285c96a9.tar.gz
fill ai_canonname field for numeric hostname, by the given hostname.
follow new recommendation in RFC3493. Obtained from: KAME MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/net/getaddrinfo.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 87f96c2..bbd73f4 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -237,7 +237,7 @@ static int str_isnumber(const char *);
static int explore_null(const struct addrinfo *,
const char *, struct addrinfo **);
static int explore_numeric(const struct addrinfo *, const char *,
- const char *, struct addrinfo **);
+ const char *, struct addrinfo **, const char *);
static int explore_numeric_scope(const struct addrinfo *, const char *,
const char *, struct addrinfo **);
static int get_canonname(const struct addrinfo *,
@@ -548,7 +548,8 @@ getaddrinfo(hostname, servname, hints, res)
if (hostname == NULL)
error = explore_null(pai, servname, &cur->ai_next);
else
- error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
+ error = explore_numeric_scope(pai, hostname, servname,
+ &cur->ai_next);
if (error)
goto free;
@@ -1171,11 +1172,12 @@ free:
* numeric hostname
*/
static int
-explore_numeric(pai, hostname, servname, res)
+explore_numeric(pai, hostname, servname, res, canonname)
const struct addrinfo *pai;
const char *hostname;
const char *servname;
struct addrinfo **res;
+ const char *canonname;
{
const struct afd *afd;
struct addrinfo *cur;
@@ -1205,6 +1207,14 @@ explore_numeric(pai, hostname, servname, res)
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
+ if ((pai->ai_flags & AI_CANONNAME)) {
+ /*
+ * Set the numeric address itself as
+ * the canonical name, based on a
+ * clarification in rfc3493.
+ */
+ GET_CANONNAME(cur->ai_next, canonname);
+ }
while (cur && cur->ai_next)
cur = cur->ai_next;
} else
@@ -1218,6 +1228,14 @@ explore_numeric(pai, hostname, servname, res)
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
+ if ((pai->ai_flags & AI_CANONNAME)) {
+ /*
+ * Set the numeric address itself as
+ * the canonical name, based on a
+ * clarification in rfc3493.
+ */
+ GET_CANONNAME(cur->ai_next, canonname);
+ }
while (cur && cur->ai_next)
cur = cur->ai_next;
} else
@@ -1247,7 +1265,7 @@ explore_numeric_scope(pai, hostname, servname, res)
struct addrinfo **res;
{
#if !defined(SCOPE_DELIMITER) || !defined(INET6)
- return explore_numeric(pai, hostname, servname, res);
+ return explore_numeric(pai, hostname, servname, res, hostname);
#else
const struct afd *afd;
struct addrinfo *cur;
@@ -1266,11 +1284,11 @@ explore_numeric_scope(pai, hostname, servname, res)
return 0;
if (!afd->a_scoped)
- return explore_numeric(pai, hostname, servname, res);
+ return explore_numeric(pai, hostname, servname, res, hostname);
cp = strchr(hostname, SCOPE_DELIMITER);
if (cp == NULL)
- return explore_numeric(pai, hostname, servname, res);
+ return explore_numeric(pai, hostname, servname, res, hostname);
/*
* Handle special case of <scoped_address><delimiter><scope id>
@@ -1283,7 +1301,7 @@ explore_numeric_scope(pai, hostname, servname, res)
addr = hostname2;
scope = cp + 1;
- error = explore_numeric(pai, addr, servname, res);
+ error = explore_numeric(pai, addr, servname, res, hostname);
if (error == 0) {
u_int32_t scopeid;
OpenPOWER on IntegriCloud