summaryrefslogtreecommitdiffstats
path: root/test-localuser.c
diff options
context:
space:
mode:
Diffstat (limited to 'test-localuser.c')
-rw-r--r--test-localuser.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test-localuser.c b/test-localuser.c
index ed27138..7029fd9 100644
--- a/test-localuser.c
+++ b/test-localuser.c
@@ -20,6 +20,7 @@
* THE SOFTWARE.
*/
#include <stdio.h>
+#include <stdint.h>
#include <netdb.h>
void dumphostent(char *tag, char *arg, struct hostent *h)
@@ -33,6 +34,12 @@ void dumphostent(char *tag, char *arg, struct hostent *h)
(int)(unsigned char)h->h_addr_list[0][1],
(int)(unsigned char)h->h_addr_list[0][2],
(int)(unsigned char)h->h_addr_list[0][3]);
+ else if (h->h_addrtype == AF_INET6)
+ printf("ipv6: %08lx.%08lx.%08lx.%08lx\n",
+ (long)ntohl(((uint32_t*)h->h_addr_list[0])[0]),
+ (long)ntohl(((uint32_t*)h->h_addr_list[0])[1]),
+ (long)ntohl(((uint32_t*)h->h_addr_list[0])[2]),
+ (long)ntohl(((uint32_t*)h->h_addr_list[0])[3]));
} else {
printf("NULL!\n");
}
@@ -51,6 +58,14 @@ int main(int ac, char **av)
h = gethostbyaddr(h->h_addr_list[0], h->h_length, h->h_addrtype);
dumphostent("addr->name", *av, h);
}
+
+ h = gethostbyname2(*av, AF_INET6);
+ dumphostent("name->addr", *av, h);
+
+ if (h) {
+ h = gethostbyaddr(h->h_addr_list[0], h->h_length, h->h_addrtype);
+ dumphostent("addr->name", *av, h);
+ }
}
return 0;
}