dns.hpp: check return value of resolve_ipv4/ipv6
dns.hpp: implement reverse DNS lookups
dns.hpp: make code easier to grok

Refactor the function processing the results to avoid the annoying
code organization that in some cases you return during the switch
and in some cases you fall through.