summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritojun <>2000-04-26 12:31:44 +0000
committeritojun <>2000-04-26 12:31:44 +0000
commitdd94dd2de552d0706a8ebbbf09e7102fc3bf5790 (patch)
treea81d46039d34cc2e0d8870ca9f66c3d29d203034
parent2051e1f08a469e2635c005741fdb1cc84f29f53b (diff)
downloadopenbsd-dd94dd2de552d0706a8ebbbf09e7102fc3bf5790.tar.gz
openbsd-dd94dd2de552d0706a8ebbbf09e7102fc3bf5790.tar.bz2
openbsd-dd94dd2de552d0706a8ebbbf09e7102fc3bf5790.zip
sync with latest kame.
- completely disable AI_ADDRCONFIG support (post RFC2553) since it does not work for PF_UNSPEC. - remove unused variables, some delint.
-rw-r--r--src/lib/libc/net/getaddrinfo.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c
index 960d7d3584..d8fccc57db 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.18 2000/04/25 13:39:02 itojun Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.19 2000/04/26 12:31:44 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.
@@ -76,7 +76,9 @@
76 * friends. 76 * friends.
77 */ 77 */
78 78
79#ifndef INET6
79#define INET6 80#define INET6
81#endif
80 82
81#include <sys/types.h> 83#include <sys/types.h>
82#include <sys/param.h> 84#include <sys/param.h>
@@ -218,7 +220,7 @@ static struct addrinfo *get_ai __P((const struct addrinfo *,
218static int get_portmatch __P((const struct addrinfo *, const char *)); 220static int get_portmatch __P((const struct addrinfo *, const char *));
219static int get_port __P((struct addrinfo *, const char *, int)); 221static int get_port __P((struct addrinfo *, const char *, int));
220static const struct afd *find_afd __P((int)); 222static const struct afd *find_afd __P((int));
221#ifdef AI_ADDRCONFIG 223#if 0
222static int addrconfig __P((const struct addrinfo *)); 224static int addrconfig __P((const struct addrinfo *));
223#endif 225#endif
224#ifdef INET6 226#ifdef INET6
@@ -280,6 +282,7 @@ do { \
280 /* external reference: error, and label bad */ \ 282 /* external reference: error, and label bad */ \
281 error = (err); \ 283 error = (err); \
282 goto bad; \ 284 goto bad; \
285 /*NOTREACHED*/ \
283} while (/*CONSTCOND*/0) 286} while (/*CONSTCOND*/0)
284 287
285#define MATCH_FAMILY(x, y, w) \ 288#define MATCH_FAMILY(x, y, w) \
@@ -515,10 +518,11 @@ explore_fqdn(pai, hostname, servname, res)
515 518
516 result = NULL; 519 result = NULL;
517 520
518#ifdef AI_ADDRCONFIG 521#if 0
519 /* 522 /*
520 * If AI_ADDRCONFIG is specified, check if we are expected to 523 * If AI_ADDRCONFIG is specified, check if we are expected to
521 * return the address family or not. 524 * return the address family or not.
525 * XXX does not handle PF_UNSPEC case, should filter final result
522 */ 526 */
523 if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai)) 527 if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai))
524 return 0; 528 return 0;
@@ -647,7 +651,6 @@ explore_numeric(pai, hostname, servname, res)
647 struct addrinfo sentinel; 651 struct addrinfo sentinel;
648 int error; 652 int error;
649 char pton[PTON_MAX]; 653 char pton[PTON_MAX];
650 int flags;
651 654
652 *res = NULL; 655 *res = NULL;
653 sentinel.ai_next = NULL; 656 sentinel.ai_next = NULL;
@@ -660,7 +663,6 @@ explore_numeric(pai, hostname, servname, res)
660 return 0; 663 return 0;
661 664
662 afd = find_afd(pai->ai_family); 665 afd = find_afd(pai->ai_family);
663 flags = pai->ai_flags;
664 666
665 switch (afd->a_af) { 667 switch (afd->a_af) {
666#if 0 /*X/Open spec*/ 668#if 0 /*X/Open spec*/
@@ -765,7 +767,7 @@ explore_numeric_scope(pai, hostname, servname, res)
765 for (cur = *res; cur; cur = cur->ai_next) { 767 for (cur = *res; cur; cur = cur->ai_next) {
766 if (cur->ai_family != AF_INET6) 768 if (cur->ai_family != AF_INET6)
767 continue; 769 continue;
768 sin6 = (struct sockaddr_in6 *)cur->ai_addr; 770 sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
769 if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) { 771 if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) {
770 free(hostname2); 772 free(hostname2);
771 return(EAI_NONAME); /* XXX: is return OK? */ 773 return(EAI_NONAME); /* XXX: is return OK? */
@@ -810,12 +812,12 @@ get_ai(pai, afd, addr)
810 return NULL; 812 return NULL;
811 813
812 memcpy(ai, pai, sizeof(struct addrinfo)); 814 memcpy(ai, pai, sizeof(struct addrinfo));
813 ai->ai_addr = (struct sockaddr *)(ai + 1); 815 ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
814 memset(ai->ai_addr, 0, (size_t)afd->a_socklen); 816 memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
815 ai->ai_addr->sa_len = afd->a_socklen; 817 ai->ai_addr->sa_len = afd->a_socklen;
816 ai->ai_addrlen = afd->a_socklen; 818 ai->ai_addrlen = afd->a_socklen;
817 ai->ai_addr->sa_family = ai->ai_family = afd->a_af; 819 ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
818 p = (char *)(ai->ai_addr); 820 p = (char *)(void *)(ai->ai_addr);
819 memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); 821 memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
820 return ai; 822 return ai;
821} 823}
@@ -827,6 +829,7 @@ get_portmatch(ai, servname)
827{ 829{
828 830
829 /* get_port does not touch first argument. when matchonly == 1. */ 831 /* get_port does not touch first argument. when matchonly == 1. */
832 /* LINTED const cast */
830 return get_port((struct addrinfo *)ai, servname, 1); 833 return get_port((struct addrinfo *)ai, servname, 1);
831} 834}
832 835
@@ -894,11 +897,13 @@ get_port(ai, servname, matchonly)
894 if (!matchonly) { 897 if (!matchonly) {
895 switch (ai->ai_family) { 898 switch (ai->ai_family) {
896 case AF_INET: 899 case AF_INET:
897 ((struct sockaddr_in *)ai->ai_addr)->sin_port = port; 900 ((struct sockaddr_in *)(void *)
901 ai->ai_addr)->sin_port = port;
898 break; 902 break;
899#ifdef INET6 903#ifdef INET6
900 case AF_INET6: 904 case AF_INET6:
901 ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port; 905 ((struct sockaddr_in6 *)(void *)
906 ai->ai_addr)->sin6_port = port;
902 break; 907 break;
903#endif 908#endif
904 } 909 }
@@ -922,7 +927,7 @@ find_afd(af)
922 return NULL; 927 return NULL;
923} 928}
924 929
925#ifdef AI_ADDRCONFIG 930#if 0
926/* 931/*
927 * post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend 932 * post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend
928 * will take care of it. 933 * will take care of it.
@@ -1011,14 +1016,12 @@ getanswer(answer, anslen, qname, qtype, pai)
1011 int type, class, buflen, ancount, qdcount; 1016 int type, class, buflen, ancount, qdcount;
1012 int haveanswer, had_error; 1017 int haveanswer, had_error;
1013 char tbuf[MAXDNAME]; 1018 char tbuf[MAXDNAME];
1014 const char *tname;
1015 int (*name_ok) __P((const char *)); 1019 int (*name_ok) __P((const char *));
1016 char hostbuf[8*1024]; 1020 char hostbuf[8*1024];
1017 1021
1018 memset(&sentinel, 0, sizeof(sentinel)); 1022 memset(&sentinel, 0, sizeof(sentinel));
1019 cur = &sentinel; 1023 cur = &sentinel;
1020 1024
1021 tname = qname;
1022 canonname = NULL; 1025 canonname = NULL;
1023 eom = answer->buf + anslen; 1026 eom = answer->buf + anslen;
1024 switch (qtype) { 1027 switch (qtype) {
@@ -1153,7 +1156,7 @@ getanswer(answer, anslen, qname, qtype, pai)
1153 cp += n; 1156 cp += n;
1154 continue; 1157 continue;
1155 } 1158 }
1156 cur->ai_next = get_ai(&ai, afd, cp); 1159 cur->ai_next = get_ai(&ai, afd, (const char *)cp);
1157 if (cur->ai_next == NULL) 1160 if (cur->ai_next == NULL)
1158 had_error++; 1161 had_error++;
1159 while (cur && cur->ai_next) 1162 while (cur && cur->ai_next)
@@ -1189,7 +1192,6 @@ _dns_getaddrinfo(name, pai)
1189 querybuf buf, buf2; 1192 querybuf buf, buf2;
1190 struct addrinfo sentinel, *cur; 1193 struct addrinfo sentinel, *cur;
1191 struct res_target q, q2; 1194 struct res_target q, q2;
1192 int ancount;
1193 1195
1194 memset(&q, 0, sizeof(q2)); 1196 memset(&q, 0, sizeof(q2));
1195 memset(&q2, 0, sizeof(q2)); 1197 memset(&q2, 0, sizeof(q2));
@@ -1224,7 +1226,7 @@ _dns_getaddrinfo(name, pai)
1224 default: 1226 default:
1225 return NULL; 1227 return NULL;
1226 } 1228 }
1227 if ((ancount = res_searchN(name, &q)) < 0) 1229 if (res_searchN(name, &q) < 0)
1228 return NULL; 1230 return NULL;
1229 ai = getanswer(&buf, q.n, q.name, q.type, pai); 1231 ai = getanswer(&buf, q.n, q.name, q.type, pai);
1230 if (ai) { 1232 if (ai) {
@@ -1359,13 +1361,13 @@ _yphostent(line, pai)
1359 const char *addr, *canonname; 1361 const char *addr, *canonname;
1360 char *nextline; 1362 char *nextline;
1361 char *cp; 1363 char *cp;
1362 int more;
1363 1364
1364 addr = canonname = NULL; 1365 addr = canonname = NULL;
1365 1366
1366nextline: 1367 memset(&sentinel, 0, sizeof(sentinel));
1367 more = 0; 1368 cur = &sentinel;
1368 1369
1370nextline:
1369 /* terminate line */ 1371 /* terminate line */
1370 cp = strchr(p, '\n'); 1372 cp = strchr(p, '\n');
1371 if (cp) { 1373 if (cp) {