diff options
author | otto <> | 2005-03-25 13:24:12 +0000 |
---|---|---|
committer | otto <> | 2005-03-25 13:24:12 +0000 |
commit | 2f490723a2e673b2457f65c4b06cacb7d700a3e8 (patch) | |
tree | c9dcd3a58da3f7404d9e626fe10abdd67c384fba /src/lib/libc/net/getaddrinfo.c | |
parent | 9a03506f8308b6023a12f108a2072feb958607a6 (diff) | |
download | openbsd-2f490723a2e673b2457f65c4b06cacb7d700a3e8.tar.gz openbsd-2f490723a2e673b2457f65c4b06cacb7d700a3e8.tar.bz2 openbsd-2f490723a2e673b2457f65c4b06cacb7d700a3e8.zip |
ansify. ok deraadt@ moritz@
Diffstat (limited to 'src/lib/libc/net/getaddrinfo.c')
-rw-r--r-- | src/lib/libc/net/getaddrinfo.c | 111 |
1 files changed, 31 insertions, 80 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c index 3db8cc82ee..c7cc0500c3 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.50 2004/06/07 21:11:23 marc Exp $ */ | 1 | /* $OpenBSD: getaddrinfo.c,v 1.51 2005/03/25 13:24:12 otto Exp $ */ |
2 | /* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */ | 2 | /* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */ |
3 | 3 | ||
4 | /* | 4 | /* |
@@ -279,8 +279,7 @@ do { \ | |||
279 | ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) | 279 | ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) |
280 | 280 | ||
281 | static int | 281 | static int |
282 | str2number(p) | 282 | str2number(const char *p) |
283 | const char *p; | ||
284 | { | 283 | { |
285 | char *ep; | 284 | char *ep; |
286 | unsigned long v; | 285 | unsigned long v; |
@@ -297,10 +296,8 @@ str2number(p) | |||
297 | } | 296 | } |
298 | 297 | ||
299 | int | 298 | int |
300 | getaddrinfo(hostname, servname, hints, res) | 299 | getaddrinfo(const char *hostname, const char *servname, |
301 | const char *hostname, *servname; | 300 | const struct addrinfo *hints, struct addrinfo **res) |
302 | const struct addrinfo *hints; | ||
303 | struct addrinfo **res; | ||
304 | { | 301 | { |
305 | struct addrinfo sentinel; | 302 | struct addrinfo sentinel; |
306 | struct addrinfo *cur; | 303 | struct addrinfo *cur; |
@@ -499,11 +496,8 @@ getaddrinfo(hostname, servname, hints, res) | |||
499 | */ | 496 | */ |
500 | 497 | ||
501 | static int | 498 | static int |
502 | explore_fqdn(pai, hostname, servname, res) | 499 | explore_fqdn(const struct addrinfo *pai, const char *hostname, |
503 | const struct addrinfo *pai; | 500 | const char *servname, struct addrinfo **res) |
504 | const char *hostname; | ||
505 | const char *servname; | ||
506 | struct addrinfo **res; | ||
507 | { | 501 | { |
508 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | 502 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); |
509 | struct addrinfo *result; | 503 | struct addrinfo *result; |
@@ -597,10 +591,8 @@ free: | |||
597 | * non-passive socket -> localhost (127.0.0.1 or ::1) | 591 | * non-passive socket -> localhost (127.0.0.1 or ::1) |
598 | */ | 592 | */ |
599 | static int | 593 | static int |
600 | explore_null(pai, servname, res) | 594 | explore_null(const struct addrinfo *pai, const char *servname, |
601 | const struct addrinfo *pai; | 595 | struct addrinfo **res) |
602 | const char *servname; | ||
603 | struct addrinfo **res; | ||
604 | { | 596 | { |
605 | int s; | 597 | int s; |
606 | const struct afd *afd; | 598 | const struct afd *afd; |
@@ -661,12 +653,8 @@ free: | |||
661 | * numeric hostname | 653 | * numeric hostname |
662 | */ | 654 | */ |
663 | static int | 655 | static int |
664 | explore_numeric(pai, hostname, servname, res, canonname) | 656 | explore_numeric(const struct addrinfo *pai, const char *hostname, |
665 | const struct addrinfo *pai; | 657 | const char *servname, struct addrinfo **res, const char *canonname) |
666 | const char *hostname; | ||
667 | const char *servname; | ||
668 | struct addrinfo **res; | ||
669 | const char *canonname; | ||
670 | { | 658 | { |
671 | const struct afd *afd; | 659 | const struct afd *afd; |
672 | struct addrinfo *cur; | 660 | struct addrinfo *cur; |
@@ -747,11 +735,8 @@ bad: | |||
747 | * numeric hostname with scope | 735 | * numeric hostname with scope |
748 | */ | 736 | */ |
749 | static int | 737 | static int |
750 | explore_numeric_scope(pai, hostname, servname, res) | 738 | explore_numeric_scope(const struct addrinfo *pai, const char *hostname, |
751 | const struct addrinfo *pai; | 739 | const char *servname, struct addrinfo **res) |
752 | const char *hostname; | ||
753 | const char *servname; | ||
754 | struct addrinfo **res; | ||
755 | { | 740 | { |
756 | #if !defined(SCOPE_DELIMITER) || !defined(INET6) | 741 | #if !defined(SCOPE_DELIMITER) || !defined(INET6) |
757 | return explore_numeric(pai, hostname, servname, res, hostname); | 742 | return explore_numeric(pai, hostname, servname, res, hostname); |
@@ -813,10 +798,7 @@ explore_numeric_scope(pai, hostname, servname, res) | |||
813 | } | 798 | } |
814 | 799 | ||
815 | static int | 800 | static int |
816 | get_canonname(pai, ai, str) | 801 | get_canonname(const struct addrinfo *pai, struct addrinfo *ai, const char *str) |
817 | const struct addrinfo *pai; | ||
818 | struct addrinfo *ai; | ||
819 | const char *str; | ||
820 | { | 802 | { |
821 | if ((pai->ai_flags & AI_CANONNAME) != 0) { | 803 | if ((pai->ai_flags & AI_CANONNAME) != 0) { |
822 | ai->ai_canonname = strdup(str); | 804 | ai->ai_canonname = strdup(str); |
@@ -827,10 +809,7 @@ get_canonname(pai, ai, str) | |||
827 | } | 809 | } |
828 | 810 | ||
829 | static struct addrinfo * | 811 | static struct addrinfo * |
830 | get_ai(pai, afd, addr) | 812 | get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr) |
831 | const struct addrinfo *pai; | ||
832 | const struct afd *afd; | ||
833 | const char *addr; | ||
834 | { | 813 | { |
835 | char *p; | 814 | char *p; |
836 | struct addrinfo *ai; | 815 | struct addrinfo *ai; |
@@ -852,9 +831,7 @@ get_ai(pai, afd, addr) | |||
852 | } | 831 | } |
853 | 832 | ||
854 | static int | 833 | static int |
855 | get_portmatch(ai, servname) | 834 | get_portmatch(const struct addrinfo *ai, const char *servname) |
856 | const struct addrinfo *ai; | ||
857 | const char *servname; | ||
858 | { | 835 | { |
859 | 836 | ||
860 | /* get_port does not touch first argument. when matchonly == 1. */ | 837 | /* get_port does not touch first argument. when matchonly == 1. */ |
@@ -863,10 +840,7 @@ get_portmatch(ai, servname) | |||
863 | } | 840 | } |
864 | 841 | ||
865 | static int | 842 | static int |
866 | get_port(ai, servname, matchonly) | 843 | get_port(struct addrinfo *ai, const char *servname, int matchonly) |
867 | struct addrinfo *ai; | ||
868 | const char *servname; | ||
869 | int matchonly; | ||
870 | { | 844 | { |
871 | const char *proto; | 845 | const char *proto; |
872 | struct servent *sp; | 846 | struct servent *sp; |
@@ -951,8 +925,7 @@ get_port(ai, servname, matchonly) | |||
951 | } | 925 | } |
952 | 926 | ||
953 | static const struct afd * | 927 | static const struct afd * |
954 | find_afd(af) | 928 | find_afd(int af) |
955 | int af; | ||
956 | { | 929 | { |
957 | const struct afd *afd; | 930 | const struct afd *afd; |
958 | 931 | ||
@@ -968,10 +941,7 @@ find_afd(af) | |||
968 | #ifdef INET6 | 941 | #ifdef INET6 |
969 | /* convert a string to a scope identifier. XXX: IPv6 specific */ | 942 | /* convert a string to a scope identifier. XXX: IPv6 specific */ |
970 | static int | 943 | static int |
971 | ip6_str2scopeid(scope, sin6, scopeid) | 944 | ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid) |
972 | char *scope; | ||
973 | struct sockaddr_in6 *sin6; | ||
974 | u_int32_t *scopeid; | ||
975 | { | 945 | { |
976 | u_long lscopeid; | 946 | u_long lscopeid; |
977 | struct in6_addr *a6 = &sin6->sin6_addr; | 947 | struct in6_addr *a6 = &sin6->sin6_addr; |
@@ -1020,12 +990,8 @@ static const char AskedForGot[] = | |||
1020 | static FILE *hostf = NULL; | 990 | static FILE *hostf = NULL; |
1021 | 991 | ||
1022 | static struct addrinfo * | 992 | static struct addrinfo * |
1023 | getanswer(answer, anslen, qname, qtype, pai) | 993 | getanswer(const querybuf *answer, int anslen, const char *qname, int qtype, |
1024 | const querybuf *answer; | 994 | const struct addrinfo *pai) |
1025 | int anslen; | ||
1026 | const char *qname; | ||
1027 | int qtype; | ||
1028 | const struct addrinfo *pai; | ||
1029 | { | 995 | { |
1030 | struct addrinfo sentinel, *cur; | 996 | struct addrinfo sentinel, *cur; |
1031 | struct addrinfo ai; | 997 | struct addrinfo ai; |
@@ -1212,9 +1178,7 @@ getanswer(answer, anslen, qname, qtype, pai) | |||
1212 | 1178 | ||
1213 | /*ARGSUSED*/ | 1179 | /*ARGSUSED*/ |
1214 | static struct addrinfo * | 1180 | static struct addrinfo * |
1215 | _dns_getaddrinfo(name, pai) | 1181 | _dns_getaddrinfo(const char *name, const struct addrinfo *pai) |
1216 | const char *name; | ||
1217 | const struct addrinfo *pai; | ||
1218 | { | 1182 | { |
1219 | struct addrinfo *ai; | 1183 | struct addrinfo *ai; |
1220 | querybuf *buf, *buf2; | 1184 | querybuf *buf, *buf2; |
@@ -1292,7 +1256,7 @@ _dns_getaddrinfo(name, pai) | |||
1292 | static FILE *hostf; | 1256 | static FILE *hostf; |
1293 | 1257 | ||
1294 | static void | 1258 | static void |
1295 | _sethtent() | 1259 | _sethtent(void) |
1296 | { | 1260 | { |
1297 | if (!hostf) | 1261 | if (!hostf) |
1298 | hostf = fopen(_PATH_HOSTS, "r" ); | 1262 | hostf = fopen(_PATH_HOSTS, "r" ); |
@@ -1301,7 +1265,7 @@ _sethtent() | |||
1301 | } | 1265 | } |
1302 | 1266 | ||
1303 | static void | 1267 | static void |
1304 | _endhtent() | 1268 | _endhtent(void) |
1305 | { | 1269 | { |
1306 | if (hostf) { | 1270 | if (hostf) { |
1307 | (void) fclose(hostf); | 1271 | (void) fclose(hostf); |
@@ -1310,9 +1274,7 @@ _endhtent() | |||
1310 | } | 1274 | } |
1311 | 1275 | ||
1312 | static struct addrinfo * | 1276 | static struct addrinfo * |
1313 | _gethtent(name, pai) | 1277 | _gethtent(const char *name, const struct addrinfo *pai) |
1314 | const char *name; | ||
1315 | const struct addrinfo *pai; | ||
1316 | { | 1278 | { |
1317 | char *p; | 1279 | char *p; |
1318 | char *cp, *tname, *cname; | 1280 | char *cp, *tname, *cname; |
@@ -1374,9 +1336,7 @@ found: | |||
1374 | 1336 | ||
1375 | /*ARGSUSED*/ | 1337 | /*ARGSUSED*/ |
1376 | static struct addrinfo * | 1338 | static struct addrinfo * |
1377 | _files_getaddrinfo(name, pai) | 1339 | _files_getaddrinfo(const char *name, const struct addrinfo *pai) |
1378 | const char *name; | ||
1379 | const struct addrinfo *pai; | ||
1380 | { | 1340 | { |
1381 | struct addrinfo sentinel, *cur; | 1341 | struct addrinfo sentinel, *cur; |
1382 | struct addrinfo *p; | 1342 | struct addrinfo *p; |
@@ -1400,9 +1360,7 @@ static char *__ypdomain; | |||
1400 | 1360 | ||
1401 | /*ARGSUSED*/ | 1361 | /*ARGSUSED*/ |
1402 | static struct addrinfo * | 1362 | static struct addrinfo * |
1403 | _yphostent(line, pai) | 1363 | _yphostent(char *line, const struct addrinfo *pai) |
1404 | char *line; | ||
1405 | const struct addrinfo *pai; | ||
1406 | { | 1364 | { |
1407 | struct addrinfo sentinel, *cur; | 1365 | struct addrinfo sentinel, *cur; |
1408 | struct addrinfo hints, *res, *res0; | 1366 | struct addrinfo hints, *res, *res0; |
@@ -1478,9 +1436,7 @@ done: | |||
1478 | 1436 | ||
1479 | /*ARGSUSED*/ | 1437 | /*ARGSUSED*/ |
1480 | static struct addrinfo * | 1438 | static struct addrinfo * |
1481 | _yp_getaddrinfo(name, pai) | 1439 | _yp_getaddrinfo(const char *name, const struct addrinfo *pai) |
1482 | const char *name; | ||
1483 | const struct addrinfo *pai; | ||
1484 | { | 1440 | { |
1485 | struct addrinfo sentinel, *cur; | 1441 | struct addrinfo sentinel, *cur; |
1486 | struct addrinfo *ai = NULL; | 1442 | struct addrinfo *ai = NULL; |
@@ -1550,9 +1506,7 @@ extern int res_opt(int, u_char *, int, int); | |||
1550 | * Caller must parse answer and determine whether it answers the question. | 1506 | * Caller must parse answer and determine whether it answers the question. |
1551 | */ | 1507 | */ |
1552 | static int | 1508 | static int |
1553 | res_queryN(name, target) | 1509 | res_queryN(const char *name, struct res_target *target) |
1554 | const char *name; /* domain name */ | ||
1555 | struct res_target *target; | ||
1556 | { | 1510 | { |
1557 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | 1511 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); |
1558 | u_char *buf; | 1512 | u_char *buf; |
@@ -1668,9 +1622,7 @@ res_queryN(name, target) | |||
1668 | * is detected. Error code, if any, is left in h_errno. | 1622 | * is detected. Error code, if any, is left in h_errno. |
1669 | */ | 1623 | */ |
1670 | static int | 1624 | static int |
1671 | res_searchN(name, target) | 1625 | res_searchN(const char *name, struct res_target *target) |
1672 | const char *name; /* domain name */ | ||
1673 | struct res_target *target; | ||
1674 | { | 1626 | { |
1675 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | 1627 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); |
1676 | const char *cp, * const *domain; | 1628 | const char *cp, * const *domain; |
@@ -1808,9 +1760,8 @@ res_searchN(name, target) | |||
1808 | * removing a trailing dot from name if domain is NULL. | 1760 | * removing a trailing dot from name if domain is NULL. |
1809 | */ | 1761 | */ |
1810 | static int | 1762 | static int |
1811 | res_querydomainN(name, domain, target) | 1763 | res_querydomainN(const char *name, const char *domain, |
1812 | const char *name, *domain; | 1764 | struct res_target *target) |
1813 | struct res_target *target; | ||
1814 | { | 1765 | { |
1815 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | 1766 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); |
1816 | char nbuf[MAXDNAME]; | 1767 | char nbuf[MAXDNAME]; |