How to know the IP address for interfaces in C using IPv6
问题 Suppose I'd like a list of all IP addresses on my Linux machine by their interface names, using both IPv6 and IPv4. The best advice I could find is to use getifaddrs() that should support IPv6, similarly to a post from here. However, the getifaddrs() uses struct ifaddrs which uses struct sockaddr which is incompatible with IPv6. Instead, it should be a pointer to a union with struct in6_addr as well. How is this handled? How does getifaddrs() support IPv6? Is the documentation obsolete? 回答1: