Package: net-tools
Version: 1.60-19
Severity: wishlist

This fix is from [EMAIL PROTECTED]  However, I think it needs work
before it can be merged with the latest cvs.

--- a/hostname.c
+++ b/hostname.c
@@ -36,6 +36,10 @@
 #include <getopt.h>
 #include <string.h>
 #include <netdb.h>
+#ifdef IPV6
+#include <sys/socket.h> /* for PF_INET6 */
+#include <sys/types.h>  /* for inet_ntop */
+#endif /* IPV6 */
 #include <errno.h>
 #include <sys/param.h>
 #include <netinet/in.h>
@@ -125,15 +129,23 @@ static void setdname(char *dname)
 static void showhname(char *hname, int c)
 {
     struct hostent *hp;
+#ifdef IPV6
+    struct in6_addr **ip6;
+#endif /* IPV6 */
     register char *p, **alias;
     struct in_addr **ip;
 
     if (opt_v)
        fprintf(stderr, _("Resolving `%s' ...\n"), hname);
-    if (!(hp = gethostbyname(hname))) {
+    if (
+#ifdef IPV6
+        !(hp = gethostbyname2(hname, PF_INET6)) && 
+#endif /* IPV6 */
+        !(hp = gethostbyname(hname))) {
        herror(program_name);
        exit(1);
     }
+
     if (opt_v) {
        fprintf(stderr, _("Result: h_name=`%s'\n"),
                hp->h_name);
@@ -142,11 +154,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++));
+#ifdef IPV6
+        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 /* IPV6 */
+       {
+           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,10 +187,32 @@ 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++));
-       printf("\n");
-       break;
+#ifdef IPV6
+        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);
+                }
+                printf("\n");
+            }
+        } else
+#endif /* IPV6 */
+        {
+           while (hp->h_addr_list[0])
+               printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++));
+            printf("\n");
+        }
+        break;
     case 'd':
        printf("%s\n", ++p);
        break;
-- 
1.5.5

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.24.4 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages net-tools depends on:
ii  libc6                         2.7-8      GNU C Library: Shared libraries

net-tools recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to