From: "Mike Frysinger" <vapier@gentoo.org> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/net-tools:master commit in: / Date: Sat, 9 Apr 2011 13:58:08 +0000 (UTC) [thread overview] Message-ID: <8022436648fc84b5015dec20339ddd58b9fbfcdf.vapier@gentoo> (raw) commit: 8022436648fc84b5015dec20339ddd58b9fbfcdf Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Sat Apr 9 13:33:13 2011 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Sat Apr 9 13:33:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=80224366 hostname: fix FQDN handling with AAAA records patch by pasi.valminen <AT> hut.fi Gentoo bug 42650 --- hostname.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hostname.c b/hostname.c index c4c5aa0..4d87b4e 100644 --- a/hostname.c +++ b/hostname.c @@ -44,6 +44,11 @@ #include "version.h" #include "../intl.h" +#if HAVE_AFINET6 +#include <sys/socket.h> /* for PF_INET6 */ +#include <sys/types.h> /* for inet_ntop */ +#endif + #if HAVE_AFDECnet #include <netdnet/dn.h> #endif @@ -125,15 +130,23 @@ static void setdname(char *dname) static void showhname(char *hname, int c) { struct hostent *hp; +#if HAVE_AFINET6 + struct in6_addr **ip6; +#endif register char *p, **alias; struct in_addr **ip; if (opt_v) fprintf(stderr, _("Resolving `%s' ...\n"), hname); - if (!(hp = gethostbyname(hname))) { + if ( +#if HAVE_AFINET6 + !(hp = gethostbyname2(hname, PF_INET6)) && +#endif + !(hp = gethostbyname(hname))) { herror(program_name); exit(1); } + if (opt_v) { fprintf(stderr, _("Result: h_name=`%s'\n"), hp->h_name); @@ -142,11 +155,28 @@ static void showhname(char *hname, int c) while (alias[0]) fprintf(stderr, _("Result: h_aliases=`%s'\n"), *alias++); - - ip = (struct in_addr **) hp->h_addr_list; - while (ip[0]) - fprintf(stderr, _("Result: h_addr_list=`%s'\n"), - inet_ntoa(**ip++)); +#if HAVE_AFINET6 + if (hp->h_addrtype == PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] = '\0'; + ip6 = (struct in6_addr **) hp->h_addr_list; + while (ip6[0]) { + if (inet_ntop(PF_INET6, *ip6++, addr, INET6_ADDRSTRLEN)) + fprintf(stderr, _("Result: h_addr_list=`%s'\n"), addr); + else if (errno == EAFNOSUPPORT) + fprintf(stderr, _("%s: protocol family not supported\n"), + program_name); + else if (errno == ENOSPC) + fprintf(stderr, _("%s: name too long\n"), program_name); + } + } else +#endif + { + ip = (struct in_addr **) hp->h_addr_list; + while (ip[0]) + fprintf(stderr, _("Result: h_addr_list=`%s'\n"), + inet_ntoa(**ip++)); + } } if (!(p = strchr(hp->h_name, '.')) && (c == 'd')) return; @@ -158,8 +188,29 @@ static void showhname(char *hname, int c) printf("\n"); break; case 'i': - while (hp->h_addr_list[0]) - printf("%s ", inet_ntoa(*(struct in_addr *) *hp->h_addr_list++)); +#if HAVE_AFINET6 + if (hp->h_addrtype == PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] = '\0'; + while (hp->h_addr_list[0]) { + if (inet_ntop(PF_INET6, (struct in6_addr *)*hp->h_addr_list++, + addr, INET6_ADDRSTRLEN)) { + printf("%s ", addr); + } else if (errno == EAFNOSUPPORT) { + fprintf(stderr, _("\n%s: protocol family not supported\n"), + program_name); + exit(1); + } else if (errno == ENOSPC) { + fprintf(stderr, _("\n%s: name too long\n"), program_name); + exit(1); + } + } + } else +#endif + { + while (hp->h_addr_list[0]) + printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++)); + } printf("\n"); break; case 'd':
WARNING: multiple messages have this Message-ID (diff)
From: "Mike Frysinger" <vapier@gentoo.org> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/net-tools:gentoo commit in: / Date: Sat, 9 Apr 2011 13:58:06 +0000 (UTC) [thread overview] Message-ID: <8022436648fc84b5015dec20339ddd58b9fbfcdf.vapier@gentoo> (raw) Message-ID: <20110409135806.5fEeC1O1QI8IegZsx33zH8xWCzt0eNHkAzOVOVSzQKA@z> (raw) commit: 8022436648fc84b5015dec20339ddd58b9fbfcdf Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Sat Apr 9 13:33:13 2011 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Sat Apr 9 13:33:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=80224366 hostname: fix FQDN handling with AAAA records patch by pasi.valminen <AT> hut.fi Gentoo bug 42650 --- hostname.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hostname.c b/hostname.c index c4c5aa0..4d87b4e 100644 --- a/hostname.c +++ b/hostname.c @@ -44,6 +44,11 @@ #include "version.h" #include "../intl.h" +#if HAVE_AFINET6 +#include <sys/socket.h> /* for PF_INET6 */ +#include <sys/types.h> /* for inet_ntop */ +#endif + #if HAVE_AFDECnet #include <netdnet/dn.h> #endif @@ -125,15 +130,23 @@ static void setdname(char *dname) static void showhname(char *hname, int c) { struct hostent *hp; +#if HAVE_AFINET6 + struct in6_addr **ip6; +#endif register char *p, **alias; struct in_addr **ip; if (opt_v) fprintf(stderr, _("Resolving `%s' ...\n"), hname); - if (!(hp = gethostbyname(hname))) { + if ( +#if HAVE_AFINET6 + !(hp = gethostbyname2(hname, PF_INET6)) && +#endif + !(hp = gethostbyname(hname))) { herror(program_name); exit(1); } + if (opt_v) { fprintf(stderr, _("Result: h_name=`%s'\n"), hp->h_name); @@ -142,11 +155,28 @@ static void showhname(char *hname, int c) while (alias[0]) fprintf(stderr, _("Result: h_aliases=`%s'\n"), *alias++); - - ip = (struct in_addr **) hp->h_addr_list; - while (ip[0]) - fprintf(stderr, _("Result: h_addr_list=`%s'\n"), - inet_ntoa(**ip++)); +#if HAVE_AFINET6 + if (hp->h_addrtype == PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] = '\0'; + ip6 = (struct in6_addr **) hp->h_addr_list; + while (ip6[0]) { + if (inet_ntop(PF_INET6, *ip6++, addr, INET6_ADDRSTRLEN)) + fprintf(stderr, _("Result: h_addr_list=`%s'\n"), addr); + else if (errno == EAFNOSUPPORT) + fprintf(stderr, _("%s: protocol family not supported\n"), + program_name); + else if (errno == ENOSPC) + fprintf(stderr, _("%s: name too long\n"), program_name); + } + } else +#endif + { + ip = (struct in_addr **) hp->h_addr_list; + while (ip[0]) + fprintf(stderr, _("Result: h_addr_list=`%s'\n"), + inet_ntoa(**ip++)); + } } if (!(p = strchr(hp->h_name, '.')) && (c == 'd')) return; @@ -158,8 +188,29 @@ static void showhname(char *hname, int c) printf("\n"); break; case 'i': - while (hp->h_addr_list[0]) - printf("%s ", inet_ntoa(*(struct in_addr *) *hp->h_addr_list++)); +#if HAVE_AFINET6 + if (hp->h_addrtype == PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] = '\0'; + while (hp->h_addr_list[0]) { + if (inet_ntop(PF_INET6, (struct in6_addr *)*hp->h_addr_list++, + addr, INET6_ADDRSTRLEN)) { + printf("%s ", addr); + } else if (errno == EAFNOSUPPORT) { + fprintf(stderr, _("\n%s: protocol family not supported\n"), + program_name); + exit(1); + } else if (errno == ENOSPC) { + fprintf(stderr, _("\n%s: name too long\n"), program_name); + exit(1); + } + } + } else +#endif + { + while (hp->h_addr_list[0]) + printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++)); + } printf("\n"); break; case 'd':
next reply other threads:[~2011-04-09 13:59 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-04-09 13:58 Mike Frysinger [this message] 2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:gentoo commit in: / Mike Frysinger -- strict thread matches above, loose matches on Subject: below -- 2011-11-21 1:38 Mike Frysinger 2011-11-21 1:35 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger 2011-11-21 1:35 Mike Frysinger 2011-11-21 1:35 Mike Frysinger 2011-08-20 4:57 Mike Frysinger 2011-08-20 4:57 Mike Frysinger 2011-04-09 13:58 Mike Frysinger 2011-04-09 13:58 Mike Frysinger 2011-04-09 13:58 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger 2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8022436648fc84b5015dec20339ddd58b9fbfcdf.vapier@gentoo \ --to=vapier@gentoo.org \ --cc=gentoo-commits@lists.gentoo.org \ --cc=gentoo-dev@lists.gentoo.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox