getaddrinfo.c (d53978e3c02e3833042ec455076bce11ffbefc40) | getaddrinfo.c (4d756307806b581ce8582deb291baf78e89c6701) |
---|---|
1/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 151 unchanged lines hidden (view full) --- 160 int e_wild; 161#define WILD_AF(ex) ((ex)->e_wild & 0x01) 162#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) 163#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) 164}; 165 166static const struct explore explore[] = { 167#if 0 | 1/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 151 unchanged lines hidden (view full) --- 160 int e_wild; 161#define WILD_AF(ex) ((ex)->e_wild & 0x01) 162#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) 163#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) 164}; 165 166static const struct explore explore[] = { 167#if 0 |
168 { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 }, | 168 { PF_LOCAL, ANY, ANY, NULL, 0x01 }, |
169#endif 170#ifdef INET6 171 { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 172 { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, | 169#endif 170#ifdef INET6 171 { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 172 { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, |
173 { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 }, 174 { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 }, |
|
173 { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, 174#endif 175 { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 176 { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, | 175 { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, 176#endif 177 { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 178 { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, |
179 { PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 }, 180 { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 }, |
|
177 { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, 178 { PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 179 { PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, | 181 { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, 182 { PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, 183 { PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, |
184 { PF_UNSPEC, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 }, 185 { PF_UNSPEC, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 }, |
|
180 { PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 }, 181 { -1, 0, 0, NULL, 0 }, 182}; 183 184#ifdef INET6 185#define PTON_MAX 16 186#else 187#define PTON_MAX 4 --- 224 unchanged lines hidden (view full) --- 412 for (ex = explore; ex->e_af >= 0; ex++) { 413 if (pai->ai_family != ex->e_af) 414 continue; 415 if (ex->e_socktype == ANY) 416 continue; 417 if (ex->e_protocol == ANY) 418 continue; 419 if (pai->ai_socktype == ex->e_socktype && | 186 { PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 }, 187 { -1, 0, 0, NULL, 0 }, 188}; 189 190#ifdef INET6 191#define PTON_MAX 16 192#else 193#define PTON_MAX 4 --- 224 unchanged lines hidden (view full) --- 418 for (ex = explore; ex->e_af >= 0; ex++) { 419 if (pai->ai_family != ex->e_af) 420 continue; 421 if (ex->e_socktype == ANY) 422 continue; 423 if (ex->e_protocol == ANY) 424 continue; 425 if (pai->ai_socktype == ex->e_socktype && |
420 pai->ai_protocol != ex->e_protocol) { 421 ERR(EAI_BADHINTS); 422 } | 426 pai->ai_protocol == ex->e_protocol) 427 break; |
423 } | 428 } |
429 430 if (ex->e_af < 0) 431 ERR(EAI_BADHINTS); |
|
424 } 425 } 426 427 /* 428 * check for special cases. (1) numeric servname is disallowed if 429 * socktype/protocol are left unspecified. (2) servname is disallowed 430 * for raw and other inet{,6} sockets. 431 */ --- 907 unchanged lines hidden (view full) --- 1339 return 0; 1340 } 1341 1342 switch (ai->ai_socktype) { 1343 case SOCK_RAW: 1344 return EAI_SERVICE; 1345 case SOCK_DGRAM: 1346 case SOCK_STREAM: | 432 } 433 } 434 435 /* 436 * check for special cases. (1) numeric servname is disallowed if 437 * socktype/protocol are left unspecified. (2) servname is disallowed 438 * for raw and other inet{,6} sockets. 439 */ --- 907 unchanged lines hidden (view full) --- 1347 return 0; 1348 } 1349 1350 switch (ai->ai_socktype) { 1351 case SOCK_RAW: 1352 return EAI_SERVICE; 1353 case SOCK_DGRAM: 1354 case SOCK_STREAM: |
1355 case SOCK_SEQPACKET: |
|
1347 allownumeric = 1; 1348 break; 1349 case ANY: 1350 switch (ai->ai_family) { 1351 case AF_INET: 1352#ifdef AF_INET6 1353 case AF_INET6: 1354#endif --- 13 unchanged lines hidden (view full) --- 1368 if (!allownumeric) 1369 return EAI_SERVICE; 1370 if (port < 0 || port > 65535) 1371 return EAI_SERVICE; 1372 port = htons(port); 1373 } else { 1374 if (ai->ai_flags & AI_NUMERICSERV) 1375 return EAI_NONAME; | 1356 allownumeric = 1; 1357 break; 1358 case ANY: 1359 switch (ai->ai_family) { 1360 case AF_INET: 1361#ifdef AF_INET6 1362 case AF_INET6: 1363#endif --- 13 unchanged lines hidden (view full) --- 1377 if (!allownumeric) 1378 return EAI_SERVICE; 1379 if (port < 0 || port > 65535) 1380 return EAI_SERVICE; 1381 port = htons(port); 1382 } else { 1383 if (ai->ai_flags & AI_NUMERICSERV) 1384 return EAI_NONAME; |
1376 switch (ai->ai_socktype) { 1377 case SOCK_DGRAM: | 1385 1386 switch (ai->ai_protocol) { 1387 case IPPROTO_UDP: |
1378 proto = "udp"; 1379 break; | 1388 proto = "udp"; 1389 break; |
1380 case SOCK_STREAM: | 1390 case IPPROTO_TCP: |
1381 proto = "tcp"; 1382 break; | 1391 proto = "tcp"; 1392 break; |
1393 case IPPROTO_SCTP: 1394 proto = "sctp"; 1395 break; |
|
1383 default: 1384 proto = NULL; 1385 break; 1386 } 1387 1388 if ((sp = getservbyname(servname, proto)) == NULL) 1389 return EAI_SERVICE; 1390 port = sp->s_port; --- 1361 unchanged lines hidden --- | 1396 default: 1397 proto = NULL; 1398 break; 1399 } 1400 1401 if ((sp = getservbyname(servname, proto)) == NULL) 1402 return EAI_SERVICE; 1403 port = sp->s_port; --- 1361 unchanged lines hidden --- |