move commonly usable code to dnscommon.