summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getaddrinfo.c
diff options
context:
space:
mode:
authoritojun <>2000-02-16 12:53:35 +0000
committeritojun <>2000-02-16 12:53:35 +0000
commit670f8b86a21e9943f06a44a02534f71133a96788 (patch)
tree88bc459b8feda3db774db6985954d5b8a8b2532b /src/lib/libc/net/getaddrinfo.c
parent0b25150d45a4edb0baa51ce4216185a4309beac0 (diff)
downloadopenbsd-670f8b86a21e9943f06a44a02534f71133a96788.tar.gz
openbsd-670f8b86a21e9943f06a44a02534f71133a96788.tar.bz2
openbsd-670f8b86a21e9943f06a44a02534f71133a96788.zip
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)
Diffstat (limited to 'src/lib/libc/net/getaddrinfo.c')
-rw-r--r--src/lib/libc/net/getaddrinfo.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c
index efcbb72a56..378206e6ee 100644
--- a/src/lib/libc/net/getaddrinfo.c
+++ b/src/lib/libc/net/getaddrinfo.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getaddrinfo.c,v 1.11 2000/02/15 18:53:08 itojun Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.12 2000/02/16 12:53:35 itojun Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -50,6 +50,25 @@
50 * when globbing NULL hostname (to loopback, or wildcard). Is it the right 50 * when globbing NULL hostname (to loopback, or wildcard). Is it the right
51 * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG 51 * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG
52 * in ai_flags? 52 * in ai_flags?
53 * - (post-2553) semantics of AI_ADDRCONFIG itself is too vague.
54 * (1) what should we do against numeric hostname (2) what should we do
55 * against NULL hostname (3) what is AI_ADDRCONFIG itself. AF not ready?
56 * non-loopback address configured? global address configured?
57 * - The code makes use of following calls when asked to resolver with
58 * ai_family = PF_UNSPEC:
59 * getipnodebyname(host, AF_INET6);
60 * getipnodebyname(host, AF_INET);
61 * This will result in the following queries if the node is configure to
62 * prefer /etc/hosts than DNS:
63 * lookup /etc/hosts for IPv6 address
64 * lookup DNS for IPv6 address
65 * lookup /etc/hosts for IPv4 address
66 * lookup DNS for IPv4 address
67 * which may not meet people's requirement.
68 * The right thing to happen is to have underlying layer which does
69 * PF_UNSPEC lookup (lookup both) and return chain of addrinfos.
70 * This would result in a bit of code duplicate with _dns_ghbyname() and
71 * friends.
53 */ 72 */
54 73
55#define INET6 74#define INET6
@@ -523,7 +542,7 @@ explore_fqdn(pai, hostname, servname, res)
523 for (i = 0; aplist[i] != NULL; i++) { 542 for (i = 0; aplist[i] != NULL; i++) {
524 af = hp->h_addrtype; 543 af = hp->h_addrtype;
525 ap = aplist[i]; 544 ap = aplist[i];
526#ifdef AF_INET6 545#ifdef INET6
527 if (af == AF_INET6 546 if (af == AF_INET6
528 && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { 547 && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
529 af = AF_INET; 548 af = AF_INET;
@@ -716,7 +735,7 @@ explore_numeric_scope(pai, hostname, servname, res)
716 const struct afd *afd; 735 const struct afd *afd;
717 struct addrinfo *cur; 736 struct addrinfo *cur;
718 int error; 737 int error;
719 char *cp, *hostname2 = NULL, *scope; 738 char *cp, *hostname2 = NULL, *scope, *addr;
720 struct sockaddr_in6 *sin6; 739 struct sockaddr_in6 *sin6;
721 740
722 /* 741 /*
@@ -733,6 +752,7 @@ explore_numeric_scope(pai, hostname, servname, res)
733 if (cp == NULL) 752 if (cp == NULL)
734 return explore_numeric(pai, hostname, servname, res); 753 return explore_numeric(pai, hostname, servname, res);
735 754
755#if 1
736 /* 756 /*
737 * Handle special case of <scope id><delimiter><scoped_address> 757 * Handle special case of <scope id><delimiter><scoped_address>
738 */ 758 */
@@ -742,9 +762,21 @@ explore_numeric_scope(pai, hostname, servname, res)
742 /* terminate at the delimiter */ 762 /* terminate at the delimiter */
743 hostname2[cp - hostname] = '\0'; 763 hostname2[cp - hostname] = '\0';
744 scope = hostname2; 764 scope = hostname2;
745 cp++; 765 addr = cp + 1;
766#else
767 /*
768 * Handle special case of <scoped_address><delimiter><scope id>
769 */
770 hostname2 = strdup(hostname);
771 if (hostname2 == NULL)
772 return EAI_MEMORY;
773 /* terminate at the delimiter */
774 hostname2[cp - hostname] = '\0';
775 addr = hostname2;
776 scope = cp + 1;
777#endif
746 778
747 error = explore_numeric(pai, cp, servname, res); 779 error = explore_numeric(pai, addr, servname, res);
748 if (error == 0) { 780 if (error == 0) {
749 int scopeid; 781 int scopeid;
750 782