assert(length);
assert(a);
- return (char*) inet_ntop(avahi_proto_to_af(a->proto), a->data.data, s, length);
+ if (!(inet_ntop(avahi_proto_to_af(a->proto), a->data.data, s, length)))
+ return NULL;
+
+ return s;
}
char* avahi_reverse_lookup_name_ipv4(const AvahiIPv4Address *a) {
return avahi_strdup_printf("%u.%u.%u.%u.in-addr.arpa", n & 0xFF, (n >> 8) & 0xFF, (n >> 16) & 0xFF, n >> 24);
}
-static char *reverse_lookup_name_ipv6(const AvahiIPv6Address *a, const char *suffix) {
+char *avahi_reverse_lookup_name_ipv6(const AvahiIPv6Address *a) {
- return avahi_strdup_printf("%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%s",
+ return avahi_strdup_printf("%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa",
a->address[15] & 0xF,
a->address[15] >> 4,
a->address[14] & 0xF,
a->address[1] & 0xF,
a->address[1] >> 4,
a->address[0] & 0xF,
- a->address[0] >> 4,
- suffix);
-}
-
-char *avahi_reverse_lookup_name_ipv6_arpa(const AvahiIPv6Address *a) {
- return reverse_lookup_name_ipv6(a, "ip6.arpa");
-}
-
-char *avahi_reverse_lookup_name_ipv6_int(const AvahiIPv6Address *a) {
- return reverse_lookup_name_ipv6(a, "ip6.int");
+ a->address[0] >> 4);
}
AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddress *ret_addr) {
char* avahi_reverse_lookup_name_ipv4(const AvahiIPv4Address *a);
/** Generate the modern DNS reverse lookup name for an IPv6 address, ending in ipv6.arpa. avahi_free() the result! */
-char* avahi_reverse_lookup_name_ipv6_arpa(const AvahiIPv6Address *a);
-
-/** Generate the historic DNS reverse lookup name for an IPv6 address, ending in ipv6.int. avahi_free() the result! */
-char* avahi_reverse_lookup_name_ipv6_int(const AvahiIPv6Address *a);
+char* avahi_reverse_lookup_name_ipv6(const AvahiIPv6Address *a);
/** Check whether the specified IPv6 address is in fact an
* encapsulated IPv4 address, returns 1 if yes, 0 otherwise */
if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) {
char *reverse;
- if (!(reverse = avahi_reverse_lookup_name_ipv6_arpa(&a->data.ipv6))) {
- ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
- goto fail;
- }
-
- ret = avahi_server_add_ptr(s, g, interface, protocol, flags | AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse, name);
- avahi_free(reverse);
-
- if (ret < 0)
- goto fail;
-
- if (!(reverse = avahi_reverse_lookup_name_ipv6_int(&a->data.ipv6))) {
+ if (!(reverse = avahi_reverse_lookup_name_ipv6(&a->data.ipv6))) {
ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
goto fail;
}
if (address->proto == AVAHI_PROTO_INET)
n = avahi_reverse_lookup_name_ipv4(&address->data.ipv4);
else
- n = avahi_reverse_lookup_name_ipv6_arpa(&address->data.ipv6);
+ n = avahi_reverse_lookup_name_ipv6(&address->data.ipv6);
if (!n) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);