From 3839bb837f7ed2e7cb03834469b0f35adad3ecc5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 18 Oct 2005 22:39:14 +0000 Subject: [PATCH] in order to reduce our code/API size, drop support for reverse IPv6 name lookups ending in .in-addr.int. Use in-addr.arpa exclusively from now on. git-svn-id: file:///home/lennart/svn/public/avahi/trunk@817 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-common/address.c | 20 +++++++------------- avahi-common/address.h | 5 +---- avahi-core/entry.c | 13 +------------ avahi-core/resolve-address.c | 2 +- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/avahi-common/address.c b/avahi-common/address.c index 722d528..f3f3a67 100644 --- a/avahi-common/address.c +++ b/avahi-common/address.c @@ -59,7 +59,10 @@ char *avahi_address_snprint(char *s, size_t length, const AvahiAddress *a) { 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) { @@ -69,9 +72,9 @@ 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, @@ -103,16 +106,7 @@ static char *reverse_lookup_name_ipv6(const AvahiIPv6Address *a, const char *suf 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) { diff --git a/avahi-common/address.h b/avahi-common/address.h index 72a0e5e..f1ac428 100644 --- a/avahi-common/address.h +++ b/avahi-common/address.h @@ -106,10 +106,7 @@ uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa); 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 */ diff --git a/avahi-core/entry.c b/avahi-core/entry.c index e4008bc..23ab5e0 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.c @@ -428,18 +428,7 @@ int avahi_server_add_address( 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; } diff --git a/avahi-core/resolve-address.c b/avahi-core/resolve-address.c index 94e07f5..08168b6 100644 --- a/avahi-core/resolve-address.c +++ b/avahi-core/resolve-address.c @@ -205,7 +205,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( 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); -- 2.39.5