diff options
Diffstat (limited to 'avahi-common/address.c')
-rw-r--r-- | avahi-common/address.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/avahi-common/address.c b/avahi-common/address.c index 3484707..3e6fc97 100644 --- a/avahi-common/address.c +++ b/avahi-common/address.c @@ -115,10 +115,20 @@ AvahiAddress *avahi_address_parse(const char *s, guchar family, AvahiAddress *re g_assert(ret_addr); g_assert(s); - if (inet_pton(family, s, ret_addr->data.data) < 0) - return NULL; - - ret_addr->family = family; + if (family == AF_UNSPEC) { + if (inet_pton(AF_INET, s, ret_addr->data.data) <= 0) { + if (inet_pton(AF_INET6, s, ret_addr->data.data) <= 0) + return NULL; + else + ret_addr->family = AF_INET6; + } else + ret_addr->family = AF_INET; + } else { + if (inet_pton(family, s, ret_addr->data.data) <= 0) + return NULL; + + ret_addr->family = family; + } return ret_addr; } |