X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fentry.c;h=18fe4314013038fa30ee8eacc9729472ce4e7c75;hb=16d9e30dd7fa052bd7e6dd37927d7f27bec90ef1;hp=be215ddf1c97482fb80630c349c480b604ef4b6c;hpb=a6442df016687a958b0871c5dc1dccedafafd6b4;p=catta diff --git a/avahi-core/entry.c b/avahi-core/entry.c index be215dd..18fe431 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.c @@ -38,12 +38,13 @@ #include #include -#include "server.h" +#include "internal.h" #include "iface.h" #include "socket.h" #include "browse.h" #include "log.h" #include "util.h" +#include "dns-srv-rr.h" void avahi_entry_free(AvahiServer*s, AvahiEntry *e) { AvahiEntry *t; @@ -171,7 +172,6 @@ int avahi_server_add( AVAHI_PUBLISH_NO_PROBE| AVAHI_PUBLISH_UNIQUE| AVAHI_PUBLISH_ALLOW_MULTIPLE| - AVAHI_PUBLISH_IS_PROXY| AVAHI_PUBLISH_UPDATE)) return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS); @@ -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; } @@ -483,58 +472,6 @@ static int server_add_txt_strlst_nocopy( return ret; } -int avahi_server_add_txt_strlst( - AvahiServer *s, - AvahiSEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - uint32_t ttl, - const char *name, - AvahiStringList *strlst) { - - assert(s); - - return server_add_txt_strlst_nocopy(s, g, interface, protocol, flags, ttl, name, avahi_string_list_copy(strlst)); -} - -int avahi_server_add_txt_va( - AvahiServer *s, - AvahiSEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - uint32_t ttl, - const char *name, - va_list va) { - - assert(s); - - return server_add_txt_strlst_nocopy(s, g, interface, protocol, flags, ttl, name, avahi_string_list_new_va(va)); -} - -int avahi_server_add_txt( - AvahiServer *s, - AvahiSEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - uint32_t ttl, - const char *name, - ...) { - - va_list va; - int ret; - - assert(s); - - va_start(va, name); - ret = avahi_server_add_txt_va(s, g, interface, protocol, flags, ttl, name, va); - va_end(va); - - return ret; -} - static AvahiStringList *add_magic_cookie( AvahiServer *s, AvahiStringList *strlst) { @@ -574,7 +511,7 @@ static int server_add_service_strlst_nocopy( AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL); - AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE|AVAHI_PUBLISH_IS_PROXY|AVAHI_PUBLISH_UPDATE), AVAHI_ERR_INVALID_FLAGS); + AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE|AVAHI_PUBLISH_UPDATE), AVAHI_ERR_INVALID_FLAGS); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME); @@ -600,7 +537,7 @@ static int server_add_service_strlst_nocopy( /* Add service enumeration PTR record */ - if ((ret = avahi_server_add_ptr(s, g, interface, protocol, flags & AVAHI_PUBLISH_IS_PROXY, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0) + if ((ret = avahi_server_add_ptr(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0) goto fail; /* Add SRV record */ @@ -615,7 +552,7 @@ static int server_add_service_strlst_nocopy( r->data.srv.port = port; r->data.srv.name = h; h = NULL; - ret = avahi_server_add(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY) | AVAHI_PUBLISH_UNIQUE, r); + ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, r); avahi_record_unref(r); if (ret < 0) @@ -626,7 +563,7 @@ static int server_add_service_strlst_nocopy( if (!(flags & AVAHI_PUBLISH_NO_COOKIE)) strlst = add_magic_cookie(s, strlst); - ret = server_add_txt_strlst_nocopy(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY) | AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst); + ret = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst); strlst = NULL; if (ret < 0) @@ -634,7 +571,7 @@ static int server_add_service_strlst_nocopy( /* Add service type enumeration record */ - ret = avahi_server_add_ptr(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY), AVAHI_DEFAULT_TTL, enum_ptr, ptr_name); + ret = avahi_server_add_ptr(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name); fail: @@ -664,26 +601,6 @@ int avahi_server_add_service_strlst( return server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_copy(strlst)); } -int avahi_server_add_service_va( - AvahiServer *s, - AvahiSEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - const char *host, - uint16_t port, - va_list va) { - - assert(s); - assert(type); - assert(name); - - return server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_new_va(va)); -} - int avahi_server_add_service( AvahiServer *s, AvahiSEntryGroup *g, @@ -701,7 +618,7 @@ int avahi_server_add_service( int ret; va_start(va, port); - ret = avahi_server_add_service_va(s, g, interface, protocol, flags, name, type, domain, host, port, va); + ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_new_va(va)); va_end(va); return ret; @@ -727,7 +644,7 @@ static int server_update_service_txt_strlst_nocopy( AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL); - AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_IS_PROXY|AVAHI_PUBLISH_NO_COOKIE), AVAHI_ERR_INVALID_FLAGS); + AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE), AVAHI_ERR_INVALID_FLAGS); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME); @@ -744,7 +661,7 @@ static int server_update_service_txt_strlst_nocopy( if (!(flags & AVAHI_PUBLISH_NO_COOKIE)) strlst = add_magic_cookie(s, strlst); - ret = server_add_txt_strlst_nocopy(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_UPDATE, AVAHI_DEFAULT_TTL, svc_name, strlst); + ret = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_UPDATE, AVAHI_DEFAULT_TTL, svc_name, strlst); strlst = NULL; fail: @@ -768,21 +685,6 @@ int avahi_server_update_service_txt_strlst( return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_copy(strlst)); } -/** Update the TXT record for a service with the NULL terminated list of strings of the va_list. */ -int avahi_server_update_service_txt_va( - AvahiServer *s, - AvahiSEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - va_list va) { - - return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_new_va(va)); -} - /** Update the TXT record for a service with the NULL termonate list of strings */ int avahi_server_update_service_txt( AvahiServer *s, @@ -799,7 +701,7 @@ int avahi_server_update_service_txt( int ret; va_start(va, domain); - ret = avahi_server_update_service_txt_va(s, g, interface, protocol, flags, name, type, domain, va); + ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_new_va(va)); va_end(va); return ret; @@ -840,7 +742,7 @@ int avahi_server_add_service_subtype( goto fail; } - if ((ret = avahi_server_add_ptr(s, g, interface, protocol, flags & AVAHI_PUBLISH_IS_PROXY, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0) + if ((ret = avahi_server_add_ptr(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0) goto fail; fail: @@ -988,7 +890,7 @@ int avahi_server_add_dns_server_name( r->data.srv.weight = 0; r->data.srv.port = port; r->data.srv.name = n; - ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_NULL, r); + ret = avahi_server_add(s, g, interface, protocol, 0, r); avahi_record_unref(r); return ret;