display ipv6 addresses if supported
authorKen Raeburn <raeburn@mit.edu>
Sun, 17 Oct 1999 07:27:19 +0000 (07:27 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sun, 17 Oct 1999 07:27:19 +0000 (07:27 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11864 dc483132-0cff-0310-8789-dd5450dbe970

src/clients/klist/ChangeLog
src/clients/klist/klist.c

index 98cd6e6625fb85bbb397c16ccea6e22e0a80d816..c9303a0382848a57b00c6c67e1437d61a70ce5c3 100644 (file)
@@ -1,3 +1,9 @@
+1999-10-17  Ken Raeburn  <raeburn@raeburn.org>
+
+       * klist.c (one_addr): Use getipnodebyaddr and inet_ntop if
+       available.  Display ADDRTYPE_INET6 addresses if AF_INET6 is
+       defined.
+
 1999-09-01  Danilo Almeida  <dalmeida@mit.edu>
 
        * klist.c (do_ccache, show_credential): Use krb5_free_unparsed_name
index 333142c14b04e278a9c41d43c2903db54835a837..56bd535df66eb707e1bfda4ca310c87a8988a876 100644 (file)
@@ -546,21 +546,46 @@ void one_addr(a)
 {
     struct hostent *h;
 
-    if ((a->addrtype == ADDRTYPE_INET) &&
-       (a->length == 4)) {
+    if ((a->addrtype == ADDRTYPE_INET && a->length == 4)
+#ifdef AF_INET6
+       || (a->addrtype == ADDRTYPE_INET6 && a->length == 16)
+#endif
+       ) {
        if (!no_resolve) {
+#ifdef HAVE_GETIPNODEBYADDR
+           int err;
+           h = getipnodebyaddr(a->contents, 16, AF_INET6, &err);
+           if (h) {
+               printf("%s", h->h_name);
+               freehostent(h);
+           }
+#else
            h = gethostbyaddr(a->contents, 4, AF_INET);
            if (h) {
                printf("%s", h->h_name);
            }
+#endif
+           if (h)
+               return;
        }
        if (no_resolve || !h) {
-           printf("%d.%d.%d.%d", a->contents[0], a->contents[1],
-                  a->contents[2], a->contents[3]);
+           char buf[46];
+#ifdef HAVE_INET_NTOP
+           char *name = inet_ntop(a->addrtype, a->contents, buf, sizeof(buf));
+           if (name) {
+               printf ("%s", name);
+               return;
+           }
+#else
+           if (a->addrtype == ADDRTYPE_INET) {
+               printf("%d.%d.%d.%d", a->contents[0], a->contents[1],
+                      a->contents[2], a->contents[3]);
+               return;
+           }
+#endif
        }
-    } else {
-       printf("unknown addr type %d", a->addrtype);
     }
+    printf("unknown addr type %d", a->addrtype);
 }
 
 void