From: Ken Raeburn Date: Sun, 17 Oct 1999 07:27:19 +0000 (+0000) Subject: display ipv6 addresses if supported X-Git-Tag: krb5-1.2-beta1~211 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=318df69439fc0c25de8c598b684206384b1c9355;p=krb5.git display ipv6 addresses if supported git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11864 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/clients/klist/ChangeLog b/src/clients/klist/ChangeLog index 98cd6e662..c9303a038 100644 --- a/src/clients/klist/ChangeLog +++ b/src/clients/klist/ChangeLog @@ -1,3 +1,9 @@ +1999-10-17 Ken Raeburn + + * 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 * klist.c (do_ccache, show_credential): Use krb5_free_unparsed_name diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c index 333142c14..56bd535df 100644 --- a/src/clients/klist/klist.c +++ b/src/clients/klist/klist.c @@ -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