summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-16 12:53:36 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-16 12:53:36 +0000
commitf6cd7878a148a3c10422c2493fd104659c78c41e (patch)
tree953bdd34f9537638f59aba9ef069f772075d7ead
parent816c60190dec93655db2a4bf0ef1f34cd86d50e2 (diff)
add more comments from recent kame.
prepare to swap extended scoped address notation. fe80::1%de0 is the most promised candidate, but since it is still very draft, i'm not sure when to switch - if you have any idea please let me know. in other words, do i allowed to change it every week? :-P (NOTE it is only for "extended" scoped address notation, which is not for daily use)
-rw-r--r--lib/libc/net/getaddrinfo.c42
-rw-r--r--lib/libc/net/getnameinfo.c15
2 files changed, 51 insertions, 6 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index efcbb72a566..378206e6ee6 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo.c,v 1.11 2000/02/15 18:53:08 itojun Exp $ */
+/* $OpenBSD: getaddrinfo.c,v 1.12 2000/02/16 12:53:35 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -50,6 +50,25 @@
* when globbing NULL hostname (to loopback, or wildcard). Is it the right
* thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG
* in ai_flags?
+ * - (post-2553) semantics of AI_ADDRCONFIG itself is too vague.
+ * (1) what should we do against numeric hostname (2) what should we do
+ * against NULL hostname (3) what is AI_ADDRCONFIG itself. AF not ready?
+ * non-loopback address configured? global address configured?
+ * - The code makes use of following calls when asked to resolver with
+ * ai_family = PF_UNSPEC:
+ * getipnodebyname(host, AF_INET6);
+ * getipnodebyname(host, AF_INET);
+ * This will result in the following queries if the node is configure to
+ * prefer /etc/hosts than DNS:
+ * lookup /etc/hosts for IPv6 address
+ * lookup DNS for IPv6 address
+ * lookup /etc/hosts for IPv4 address
+ * lookup DNS for IPv4 address
+ * which may not meet people's requirement.
+ * The right thing to happen is to have underlying layer which does
+ * PF_UNSPEC lookup (lookup both) and return chain of addrinfos.
+ * This would result in a bit of code duplicate with _dns_ghbyname() and
+ * friends.
*/
#define INET6
@@ -523,7 +542,7 @@ explore_fqdn(pai, hostname, servname, res)
for (i = 0; aplist[i] != NULL; i++) {
af = hp->h_addrtype;
ap = aplist[i];
-#ifdef AF_INET6
+#ifdef INET6
if (af == AF_INET6
&& IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
af = AF_INET;
@@ -716,7 +735,7 @@ explore_numeric_scope(pai, hostname, servname, res)
const struct afd *afd;
struct addrinfo *cur;
int error;
- char *cp, *hostname2 = NULL, *scope;
+ char *cp, *hostname2 = NULL, *scope, *addr;
struct sockaddr_in6 *sin6;
/*
@@ -733,6 +752,7 @@ explore_numeric_scope(pai, hostname, servname, res)
if (cp == NULL)
return explore_numeric(pai, hostname, servname, res);
+#if 1
/*
* Handle special case of <scope id><delimiter><scoped_address>
*/
@@ -742,9 +762,21 @@ explore_numeric_scope(pai, hostname, servname, res)
/* terminate at the delimiter */
hostname2[cp - hostname] = '\0';
scope = hostname2;
- cp++;
+ addr = cp + 1;
+#else
+ /*
+ * Handle special case of <scoped_address><delimiter><scope id>
+ */
+ hostname2 = strdup(hostname);
+ if (hostname2 == NULL)
+ return EAI_MEMORY;
+ /* terminate at the delimiter */
+ hostname2[cp - hostname] = '\0';
+ addr = hostname2;
+ scope = cp + 1;
+#endif
- error = explore_numeric(pai, cp, servname, res);
+ error = explore_numeric(pai, addr, servname, res);
if (error == 0) {
int scopeid;
diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c
index e203cd5d16f..808182c6e67 100644
--- a/lib/libc/net/getnameinfo.c
+++ b/lib/libc/net/getnameinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnameinfo.c,v 1.8 2000/02/09 12:22:09 itojun Exp $ */
+/* $OpenBSD: getnameinfo.c,v 1.9 2000/02/16 12:53:35 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -235,6 +235,10 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (scopelen + 1 + numaddrlen + 1 > hostlen)
return ENI_MEMORY;
+#if 1
+ /*
+ * construct <scopeid><delim><numeric-addr>
+ */
/*
* Shift the host string to allocate
* space for the scope ID part.
@@ -245,6 +249,15 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
memcpy(host, scopebuf, scopelen);
host[scopelen] = SCOPE_DELIMITER;
host[scopelen + 1 + numaddrlen] = '\0';
+#else
+ /*
+ * construct <numeric-addr><delim><scopeid>
+ */
+ memcpy(host + numaddrlen + 1, scopebuf,
+ scopelen);
+ host[numaddrlen] = SCOPE_DELIMITER;
+ host[numaddrlen + 1 + scopelen] = '\0';
+#endif
}
}
#endif /* INET6 */