Move some direct command calls to functions, in preparation for adding ipv4/ipv6 logic
Added second patch, which adds logic to deal with IPv6 as well as IPv4
Added second patch, which adds logic to deal with IPv6 as well as IPv4