summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--avahi-core/resolve-address.c17
-rw-r--r--avahi-core/resolve-host-name.c22
2 files changed, 10 insertions, 29 deletions
diff --git a/avahi-core/resolve-address.c b/avahi-core/resolve-address.c
index a278bee..25d21ac 100644
--- a/avahi-core/resolve-address.c
+++ b/avahi-core/resolve-address.c
@@ -193,18 +193,11 @@ AvahiSAddressResolver *avahi_s_address_resolver_new(
assert(address);
assert(callback);
- assert(address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6);
-
- if (!AVAHI_IF_VALID(interface)) {
- avahi_server_set_errno(server, AVAHI_ERR_INVALID_INTERFACE);
- return NULL;
- }
-
- if (!AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
- avahi_server_set_errno(server, AVAHI_ERR_INVALID_FLAGS);
- return NULL;
- }
-
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+
avahi_reverse_lookup_name(address, n, sizeof(n));
if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
diff --git a/avahi-core/resolve-host-name.c b/avahi-core/resolve-host-name.c
index a38c001..69a3adf 100644
--- a/avahi-core/resolve-host-name.c
+++ b/avahi-core/resolve-host-name.c
@@ -220,22 +220,11 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
assert(host_name);
assert(callback);
- assert(aprotocol == AVAHI_PROTO_UNSPEC || aprotocol == AVAHI_PROTO_INET || aprotocol == AVAHI_PROTO_INET6);
-
- if (!AVAHI_IF_VALID(interface)) {
- avahi_server_set_errno(server, AVAHI_ERR_INVALID_INTERFACE);
- return NULL;
- }
-
- if (!avahi_is_valid_domain_name(host_name)) {
- avahi_server_set_errno(server, AVAHI_ERR_INVALID_HOST_NAME);
- return NULL;
- }
-
- if (!AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
- avahi_server_set_errno(server, AVAHI_ERR_INVALID_FLAGS);
- return NULL;
- }
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_is_valid_domain_name(host_name), AVAHI_ERR_INVALID_DOMAIN_NAME);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(aprotocol), AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
if (!(r = avahi_new(AvahiSHostNameResolver, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
@@ -259,7 +248,6 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
r->record_browser_aaaa = r->record_browser_a = NULL;
-
if (aprotocol == AVAHI_PROTO_INET || aprotocol == AVAHI_PROTO_UNSPEC) {
k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
r->record_browser_a = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);