From 714eaa92851fba3afaf515deda7b26a92360e0a7 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 11 Jun 2002 01:09:12 +0000 Subject: [PATCH] * t_std_conf.c: Include fake-addrinfo.h. (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 | 4 ++++ src/lib/krb5/os/t_std_conf.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 1a6e2cca8..43e911aa7 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,5 +1,9 @@ 2002-06-10 Ken Raeburn + * 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. diff --git a/src/lib/krb5/os/t_std_conf.c b/src/lib/krb5/os/t_std_conf.c index bd2bf933d..8eae312d8 100644 --- a/src/lib/krb5/os/t_std_conf.c +++ b/src/lib/krb5/os/t_std_conf.c @@ -3,6 +3,7 @@ * values from the krb5 config file(s). */ +#include "fake-addrinfo.h" #include "k5-int.h" #include @@ -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"); -- 2.26.2