diff options
author | ray <> | 2007-02-17 20:56:38 +0000 |
---|---|---|
committer | ray <> | 2007-02-17 20:56:38 +0000 |
commit | 0c706b7d00bdcb6771bc25f051ec4cd5a47322bc (patch) | |
tree | 1eee125d8d1ca1277dd8e729f6c50c283f7c0b11 /src/lib | |
parent | 98707c71b210ee87ba7dd15e0fb2194b21ca915c (diff) | |
download | openbsd-0c706b7d00bdcb6771bc25f051ec4cd5a47322bc.tar.gz openbsd-0c706b7d00bdcb6771bc25f051ec4cd5a47322bc.tar.bz2 openbsd-0c706b7d00bdcb6771bc25f051ec4cd5a47322bc.zip |
Remove duplicate code. No functional change.
OK itojun@, moritz@, and millert@.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/getaddrinfo.c | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c index f462b2a2c9..bf74bc9926 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.59 2007/02/15 04:25:35 ray Exp $ */ | 1 | /* $OpenBSD: getaddrinfo.c,v 1.60 2007/02/17 20:56:38 ray 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 | /* |
@@ -613,14 +613,13 @@ explore_null(const struct addrinfo *pai, const char *servname, | |||
613 | /* xxx meaningless? | 613 | /* xxx meaningless? |
614 | * GET_CANONNAME(cur->ai_next, "anyaddr"); | 614 | * GET_CANONNAME(cur->ai_next, "anyaddr"); |
615 | */ | 615 | */ |
616 | GET_PORT(cur->ai_next, servname); | ||
617 | } else { | 616 | } else { |
618 | GET_AI(cur->ai_next, afd, afd->a_loopback); | 617 | GET_AI(cur->ai_next, afd, afd->a_loopback); |
619 | /* xxx meaningless? | 618 | /* xxx meaningless? |
620 | * GET_CANONNAME(cur->ai_next, "localhost"); | 619 | * GET_CANONNAME(cur->ai_next, "localhost"); |
621 | */ | 620 | */ |
622 | GET_PORT(cur->ai_next, servname); | ||
623 | } | 621 | } |
622 | GET_PORT(cur->ai_next, servname); | ||
624 | cur = cur->ai_next; | 623 | cur = cur->ai_next; |
625 | 624 | ||
626 | *res = sentinel.ai_next; | 625 | *res = sentinel.ai_next; |
@@ -662,47 +661,31 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, | |||
662 | switch (afd->a_af) { | 661 | switch (afd->a_af) { |
663 | #if 0 /*X/Open spec*/ | 662 | #if 0 /*X/Open spec*/ |
664 | case AF_INET: | 663 | case AF_INET: |
665 | if (inet_aton(hostname, (struct in_addr *)pton) == 1) { | 664 | error = inet_aton(hostname, (struct in_addr *)pton); |
666 | if (pai->ai_family == afd->a_af || | ||
667 | pai->ai_family == PF_UNSPEC /*?*/) { | ||
668 | GET_AI(cur->ai_next, afd, pton); | ||
669 | GET_PORT(cur->ai_next, servname); | ||
670 | if ((pai->ai_flags & AI_CANONNAME)) { | ||
671 | /* | ||
672 | * Set the numeric address itself as | ||
673 | * the canonical name, based on a | ||
674 | * clarification in rfc2553bis-03. | ||
675 | */ | ||
676 | GET_CANONNAME(cur->ai_next, canonname); | ||
677 | } | ||
678 | while (cur && cur->ai_next) | ||
679 | cur = cur->ai_next; | ||
680 | } else | ||
681 | ERR(EAI_FAMILY); /*xxx*/ | ||
682 | } | ||
683 | break; | 665 | break; |
684 | #endif | 666 | #endif |
685 | default: | 667 | default: |
686 | if (inet_pton(afd->a_af, hostname, pton) == 1) { | 668 | error = inet_pton(afd->a_af, hostname, pton); |
687 | if (pai->ai_family == afd->a_af || | ||
688 | pai->ai_family == PF_UNSPEC /*?*/) { | ||
689 | GET_AI(cur->ai_next, afd, pton); | ||
690 | GET_PORT(cur->ai_next, servname); | ||
691 | if ((pai->ai_flags & AI_CANONNAME)) { | ||
692 | /* | ||
693 | * Set the numeric address itself as | ||
694 | * the canonical name, based on a | ||
695 | * clarification in rfc2553bis-03. | ||
696 | */ | ||
697 | GET_CANONNAME(cur->ai_next, canonname); | ||
698 | } | ||
699 | while (cur && cur->ai_next) | ||
700 | cur = cur->ai_next; | ||
701 | } else | ||
702 | ERR(EAI_FAMILY); /*xxx*/ | ||
703 | } | ||
704 | break; | 669 | break; |
705 | } | 670 | } |
671 | if (error == 1) { | ||
672 | if (pai->ai_family == afd->a_af || | ||
673 | pai->ai_family == PF_UNSPEC /*?*/) { | ||
674 | GET_AI(cur->ai_next, afd, pton); | ||
675 | GET_PORT(cur->ai_next, servname); | ||
676 | if ((pai->ai_flags & AI_CANONNAME)) { | ||
677 | /* | ||
678 | * Set the numeric address itself as | ||
679 | * the canonical name, based on a | ||
680 | * clarification in rfc2553bis-03. | ||
681 | */ | ||
682 | GET_CANONNAME(cur->ai_next, canonname); | ||
683 | } | ||
684 | while (cur && cur->ai_next) | ||
685 | cur = cur->ai_next; | ||
686 | } else | ||
687 | ERR(EAI_FAMILY); /*xxx*/ | ||
688 | } | ||
706 | 689 | ||
707 | *res = sentinel.ai_next; | 690 | *res = sentinel.ai_next; |
708 | return 0; | 691 | return 0; |