Move determinining IPv4 and IPv6 capabilities to util.py
Fix tests that depend on an IP version so that they don't run if one is not present.  This isn't fully done because many tests implicitly listen on tcp:0, which won't work if a system doesn't have IPv4.