Our versions of these functions (originally taken from BIND) simply
don't work correctly for AF_INET6. These were removed from BIND itself
quite a while ago, but OpenBSD has made quite a few fixes in the mean
time, so import their code.
Add tests for both functions.
MFC after: 1 week
Obtained from: OpenBSD (lib/libc/net)
Reported by: Nico Sonack <nsonack@herrhotzenplotz.de>
PR: 289198