I used to think the second argument for inet_ntop
should always be a struct in_addr
or struct in6_addr
. But then I looked up the POSIX definition:
const char *inet_ntop(int af, const void *restrict src,
char *restrict dst, socklen_t size);
[...] The src argument points to a buffer holding an IPv4 address if the af argument is AF_INET, or an IPv6 address if the af argument is AF_INET6; the address must be in network byte order. [...]
As you can see both the function prototype and the description are vague.
Why is this? And what are allowed/portable choices for src
?