9 #include <netinet/in6.h>
11 const char *inet_ntop(int af, const void *cp, char *buf, size_t len)
22 a.l = ((const struct in_addr *)cp)->s_addr;
24 xlen = snprintf(buf, len, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
30 const struct in6_addr *s = (const struct in6_addr *)cp;
32 xlen = snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x",
33 ntohs(s->s6_addr16[0]), ntohs(s->s6_addr16[1]),
34 ntohs(s->s6_addr16[2]), ntohs(s->s6_addr16[3]),
35 ntohs(s->s6_addr16[4]), ntohs(s->s6_addr16[5]),
36 ntohs(s->s6_addr16[6]), ntohs(s->s6_addr16[7]));