Can't manually construct libc::ifaddrs for IPv6 addresses?


I’m working on tests for a wrapper for getifaddrs, and I can’t figure out how to manually construct an ifaddrs for an IPv6 address.

There are 3 *mut sockaddr in ifaddrs. The sockaddr is a generalized version of the address types like sockaddr_un, sockaddr_in, et cetera, but it doesn’t fit sockaddr_in6. How can I create a *mut sockaddr that actually points to a sockaddr_in6 safely?

Will allocating a sockaddr_in6, taking a pointer, and then transmuting the pointer to *mut sockaddr be safe?