* t_std_conf.c: Include fake-addrinfo.h.
authorKen Raeburn <raeburn@mit.edu>
Tue, 11 Jun 2002 01:09:12 +0000 (01:09 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 11 Jun 2002 01:09:12 +0000 (01:09 +0000)
(test_locate_kdc): Update arg list to locate_kdc.  Print IPv6 as well as IPv4
addresses.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14491 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ChangeLog
src/lib/krb5/os/t_std_conf.c

index 1a6e2cca8ccd93785dd61033ddb8aa7c77e43cac..43e911aa7f8237a90ad9f276c568840600bffde9 100644 (file)
@@ -1,5 +1,9 @@
 2002-06-10  Ken Raeburn  <raeburn@mit.edu>
 
+       * t_std_conf.c: Include fake-addrinfo.h.
+       (test_locate_kdc): Update arg list to locate_kdc.  Print IPv6 as
+       well as IPv4 addresses.
+
        * t_locate_kdc.c (main): Free storage allocated by library before
        exiting.
 
index bd2bf933d1c21637d09e1e600ad7143de6674555..8eae312d88f9a791c82d635ed008cd5a4a9f119f 100644 (file)
@@ -3,6 +3,7 @@
  *     values from the krb5 config file(s).
  */
 
+#include "fake-addrinfo.h"
 #include "k5-int.h"
 
 #include <stdio.h>
@@ -108,7 +109,6 @@ static void test_locate_kdc(ctx, realm)
        char    *realm;
 {
        struct addrlist addrs;
-       struct sockaddr_in *s_sin;
        int     i;
        int     get_masters=0;
        krb5_data rlm;
@@ -116,16 +116,42 @@ static void test_locate_kdc(ctx, realm)
 
        rlm.data = realm;
        rlm.length = strlen(realm);
-       retval = krb5_locate_kdc(ctx, &rlm, &addrs, get_masters);
+       retval = krb5_locate_kdc(ctx, &rlm, &addrs, get_masters, 0);
        if (retval) {
                com_err("krb5_locate_kdc", retval, 0);
                return;
        }
        printf("krb_locate_kdc(%s) returned:", realm);
        for (i=0; i < addrs.naddrs; i++) {
-           s_sin = (struct sockaddr_in *) addrs.addrs[i];
-           printf(" %s/%d", inet_ntoa(s_sin->sin_addr), 
-                  ntohs(s_sin->sin_port));
+           struct addrinfo *ai = addrs.addrs[i];
+           switch (ai->ai_family) {
+           case AF_INET:
+           {
+               struct sockaddr_in *s_sin;
+               s_sin = (struct sockaddr_in *) ai->ai_addr;
+               printf(" inet:%s/%d", inet_ntoa(s_sin->sin_addr), 
+                      ntohs(s_sin->sin_port));
+           }
+           break;
+#ifdef KRB5_USE_INET6
+           case AF_INET6:
+           {
+               struct sockaddr_in6 *s_sin6;
+               int j;
+               s_sin6 = (struct sockaddr_in6 *) ai->ai_addr;
+               printf(" inet6");
+               for (j = 0; j < 8; j++)
+                   printf(":%x",
+                          (s_sin6->sin6_addr.s6_addr[2*j] * 256
+                           + s_sin6->sin6_addr.s6_addr[2*j+1]));
+               printf("/%d", ntohs(s_sin6->sin6_port));
+               break;
+           }
+#endif
+           default:
+               printf(" unknown-af-%d", ai->ai_family);
+               break;
+           }
        }
        krb5int_free_addrlist(&addrs);
        printf("\n");