inet_pton returns 1 when it succeeds so the test was wrong. When
it fails its either returns 0 if not a correct ipv6 address or
-1 when the protocol family is not known. Checked the man page
for both Linux and Solaris and this seems like an oversight as
the definition is the same on these OSes and probably on all others
as these functions tend to be rather portable.
Also did some small rewrite of the code so its easier to read and
the braces are easier to interpret.
addr->set_type(IPADDR::R_MULTIPLE);
addr->set_addr4(&inaddr);
addr_list->append(addr);
- } else
#ifdef HAVE_IPV6
- if (inet_pton(AF_INET6, host, &inaddr6) > 1) {
+ } else if (inet_pton(AF_INET6, host, &inaddr6) == 1) {
addr = New(IPADDR(AF_INET6));
addr->set_type(IPADDR::R_MULTIPLE);
addr->set_addr6(&inaddr6);
addr_list->append(addr);
- } else
#endif
- {
+ } else {
if (family != 0) {
errmsg = resolv_host(family, host, addr_list);
if (errmsg) {