summaryrefslogtreecommitdiffstats
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-29 01:51:53 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-29 01:51:53 +0000
commit424aefe8a431b79496672799dc4f4430fa935252 (patch)
tree0975ca5ba0321a21119f5313834bc20ff6144241 /avahi-core
parent6b3876eb3740666e9f3e036d49efc7b3b3ee5b45 (diff)
* make all flags parameters UINT32 when marshalling for DBUS
* rename AvahiEntryFlags to AvahiPublishFlags * add flags parameter to add_service() and friends * validity checking of flags, interface and protocol parameters of add_service() and friends * make AVAHI_VALID_FLAGS a global macro * add new flag AVAHI_PUBLISH_NO_REVERSE, if set address records will no be created with matching reverse lookup PTR RRs * add new flag AVAHI_PUBLISH_NO_COOKIE, for not implicitly adding the service cookie to TXT records * minor cleanups Yes, this will break the mono bindings. More breakages to come. NO_REVERSE and NO_COOKIE needs testing. Lathiat, I guess the new flag NO_REVERSE makes the immediate need to add a client side API to add arbitrary RRs obsolete for now. You might consider moving it in the TODO list to "later". git-svn-id: file:///home/lennart/svn/public/avahi/trunk@648 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/announce.c14
-rw-r--r--avahi-core/avahi-test.c8
-rw-r--r--avahi-core/browse-dns-server.c2
-rw-r--r--avahi-core/browse-domain.c2
-rw-r--r--avahi-core/browse-service-type.c2
-rw-r--r--avahi-core/browse-service.c2
-rw-r--r--avahi-core/browse.c2
-rw-r--r--avahi-core/browse.h2
-rw-r--r--avahi-core/conformance-test.c2
-rw-r--r--avahi-core/core.h9
-rw-r--r--avahi-core/iface.c4
-rw-r--r--avahi-core/publish.h20
-rw-r--r--avahi-core/resolve-address.c2
-rw-r--r--avahi-core/resolve-host-name.c2
-rw-r--r--avahi-core/resolve-service.c2
-rw-r--r--avahi-core/server.c209
-rw-r--r--avahi-core/server.h4
17 files changed, 175 insertions, 113 deletions
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index c21b147..025331d 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -155,7 +155,7 @@ static void next_state(AvahiAnnouncement *a) {
} else if (a->state == AVAHI_ANNOUNCING) {
- if (a->entry->flags & AVAHI_ENTRY_UNIQUE)
+ if (a->entry->flags & AVAHI_PUBLISH_UNIQUE)
/* Send the whole rrset at once */
avahi_server_prepare_matching_responses(a->server, a->interface, a->entry->record->key, 0);
else
@@ -212,9 +212,9 @@ static void go_to_initial_state(AvahiAnnouncement *a, int immediately) {
assert(a);
e = a->entry;
- if ((e->flags & AVAHI_ENTRY_UNIQUE) && !(e->flags & AVAHI_ENTRY_NOPROBE))
+ if ((e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE))
a->state = AVAHI_PROBING;
- else if (!(e->flags & AVAHI_ENTRY_NOANNOUNCE)) {
+ else if (!(e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)) {
if (!e->group || e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED)
a->state = AVAHI_ANNOUNCING;
@@ -336,7 +336,7 @@ int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i)
return
a->state == AVAHI_ANNOUNCING ||
a->state == AVAHI_ESTABLISHED ||
- (a->state == AVAHI_WAITING && !(e->flags & AVAHI_ENTRY_UNIQUE));
+ (a->state == AVAHI_WAITING && !(e->flags & AVAHI_PUBLISH_UNIQUE));
}
int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
@@ -354,7 +354,7 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
return
a->state == AVAHI_PROBING ||
- (a->state == AVAHI_WAITING && (e->flags & AVAHI_ENTRY_UNIQUE));
+ (a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE));
}
void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
@@ -403,7 +403,7 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v
if (!avahi_interface_match(i, e->interface, e->protocol))
return;
- if (e->flags & AVAHI_ENTRY_NOANNOUNCE)
+ if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)
return;
if (!avahi_entry_is_registered(m->server, e, i))
@@ -412,7 +412,7 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v
if (!(g = make_goodbye_record(e->record)))
return; /* OOM */
- avahi_interface_post_response(i, g, e->flags & AVAHI_ENTRY_UNIQUE, NULL, 1);
+ avahi_interface_post_response(i, g, e->flags & AVAHI_PUBLISH_UNIQUE, NULL, 1);
avahi_record_unref(g);
}
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c
index 0490c84..7ed5991 100644
--- a/avahi-core/avahi-test.c
+++ b/avahi-core/avahi-test.c
@@ -164,22 +164,22 @@ static void create_entries(int new_name) {
service_name = n;
}
- if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
+ if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
avahi_log_error("Failed to add HTTP service");
goto fail;
}
- if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, service_name, "_ftp._tcp", NULL, NULL, 21, "foo", NULL) < 0) {
+ if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_ftp._tcp", NULL, NULL, 21, "foo", NULL) < 0) {
avahi_log_error("Failed to add FTP service");
goto fail;
}
- if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, service_name, "_webdav._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
+ if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0,service_name, "_webdav._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
avahi_log_error("Failed to add WEBDAV service");
goto fail;
}
- if (avahi_server_add_dns_server_address(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &a), 53) < 0) {
+ if (avahi_server_add_dns_server_address(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, NULL, AVAHI_DNS_SERVER_RESOLVE, avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &a), 53) < 0) {
avahi_log_error("Failed to add new DNS Server address");
goto fail;
}
diff --git a/avahi-core/browse-dns-server.c b/avahi-core/browse-dns-server.c
index 675000b..31da536 100644
--- a/avahi-core/browse-dns-server.c
+++ b/avahi-core/browse-dns-server.c
@@ -262,7 +262,7 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
if (!domain)
domain = server->domain_name;
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/browse-domain.c b/avahi-core/browse-domain.c
index c5d2ba8..6cbc93a 100644
--- a/avahi-core/browse-domain.c
+++ b/avahi-core/browse-domain.c
@@ -97,7 +97,7 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
if (!domain)
domain = server->domain_name;
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/browse-service-type.c b/avahi-core/browse-service-type.c
index 3ea28c0..25673fa 100644
--- a/avahi-core/browse-service-type.c
+++ b/avahi-core/browse-service-type.c
@@ -120,7 +120,7 @@ AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
if (!domain)
domain = server->domain_name;
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/browse-service.c b/avahi-core/browse-service.c
index 55fba6a..dfa6050 100644
--- a/avahi-core/browse-service.c
+++ b/avahi-core/browse-service.c
@@ -128,7 +128,7 @@ AvahiSServiceBrowser *avahi_s_service_browser_new(
if (!domain)
domain = server->domain_name;
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/browse.c b/avahi-core/browse.c
index 64680b7..f47418a 100644
--- a/avahi-core/browse.c
+++ b/avahi-core/browse.c
@@ -527,7 +527,7 @@ AvahiSRecordBrowser *avahi_s_record_browser_new(
CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
CHECK_VALIDITY_RETURN_NULL(server, !avahi_key_is_pattern(key), AVAHI_ERR_IS_PATTERN);
CHECK_VALIDITY_RETURN_NULL(server, avahi_key_is_valid(key), AVAHI_ERR_INVALID_KEY);
- CHECK_VALIDITY_RETURN_NULL(server, AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+ CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
if (!(b = avahi_new(AvahiSRecordBrowser, 1))) {
diff --git a/avahi-core/browse.h b/avahi-core/browse.h
index 70e724f..a340c7f 100644
--- a/avahi-core/browse.h
+++ b/avahi-core/browse.h
@@ -60,6 +60,4 @@ void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b);
void avahi_s_record_browser_restart(AvahiSRecordBrowser *b);
void avahi_s_record_browser_cancel(AvahiSRecordBrowser *b);
-#define AVAHI_VALID_FLAGS(flags, max) (!((flags) & ~(max)))
-
#endif
diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c
index 392dddc..1856fc5 100644
--- a/avahi-core/conformance-test.c
+++ b/avahi-core/conformance-test.c
@@ -74,7 +74,7 @@ static void create_service(const char *t) {
else
group = avahi_s_entry_group_new(avahi, entry_group_callback, NULL);
- avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
+ avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
avahi_s_entry_group_commit(group);
try++;
diff --git a/avahi-core/core.h b/avahi-core/core.h
index 4883c6b..e3bf8a3 100644
--- a/avahi-core/core.h
+++ b/avahi-core/core.h
@@ -50,15 +50,6 @@ AVAHI_C_DECL_BEGIN
/** Maximum number of defined DNS servers for wide area DNS */
#define AVAHI_MAX_WIDE_AREA_SERVERS 4
-/** Flags for server entries */
-typedef enum {
- AVAHI_ENTRY_NULL = 0, /**< No special flags */
- AVAHI_ENTRY_UNIQUE = 1, /**< The RRset is intended to be unique */
- AVAHI_ENTRY_NOPROBE = 2, /**< Though the RRset is intended to be unique no probes shall be sent */
- AVAHI_ENTRY_NOANNOUNCE = 4, /**< Do not announce this RR to other hosts */
- AVAHI_ENTRY_ALLOWMUTIPLE = 8 /**< Allow multiple local records of this type, even if they are intended to be unique */
-} AvahiEntryFlags;
-
/** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, void* userdata);
diff --git a/avahi-core/iface.c b/avahi-core/iface.c
index f882988..e3e2cd7 100644
--- a/avahi-core/iface.c
+++ b/avahi-core/iface.c
@@ -142,8 +142,8 @@ static void update_hw_interface_rr(AvahiInterfaceMonitor *m, AvahiHwInterface *h
if (!name)
return; /* OOM */
- if (avahi_server_add_service(m->server, hw->entry_group, hw->index, AVAHI_PROTO_UNSPEC, name, "_workstation._tcp", NULL, NULL, 9, NULL) < 0) {
- avahi_log_warn(__FILE__": avahi_server_add_service() failed.");
+ if (avahi_server_add_service(m->server, hw->entry_group, hw->index, AVAHI_PROTO_UNSPEC, 0, name, "_workstation._tcp", NULL, NULL, 9, NULL) < 0) {
+ avahi_log_warn(__FILE__": avahi_server_add_service() failed: %s", avahi_strerror(m->server->error));
avahi_s_entry_group_free(hw->entry_group);
hw->entry_group = NULL;
} else
diff --git a/avahi-core/publish.h b/avahi-core/publish.h
index 4e632f8..c75c067 100644
--- a/avahi-core/publish.h
+++ b/avahi-core/publish.h
@@ -93,8 +93,9 @@ int avahi_server_add(
AvahiSEntryGroup *g, /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
AvahiIfIndex interface, /**< A numeric index of a network interface to attach this record to, or AVAHI_IF_UNSPEC to attach this record to all interfaces */
AvahiProtocol protocol, /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
- AvahiEntryFlags flags, /**< Special flags for this record */
- AvahiRecord *r /**< The record to add. This function increases the reference counter of this object. */ );
+ AvahiPublishFlags flags, /**< Special flags for this record */
+ AvahiRecord *r /**< The record to add. This function increases the reference counter of this object. */);
+
/** Add a PTR RR to the server. See avahi_server_add() for more information. */
int avahi_server_add_ptr(
@@ -102,7 +103,7 @@ int avahi_server_add_ptr(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl, /**< DNS TTL for this record */
const char *name, /**< PTR record name */
const char *dest /**< pointer destination */ );
@@ -113,7 +114,7 @@ int avahi_server_add_txt(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl, /**< DNS TTL for this record */
const char *name, /**< TXT record name */
... /**< Text record data, terminated by NULL */) AVAHI_GCC_SENTINEL;
@@ -126,7 +127,7 @@ int avahi_server_add_txt_va(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
va_list va);
@@ -139,7 +140,7 @@ int avahi_server_add_txt_strlst(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
AvahiStringList *strlst /**< TXT decord data as a AvahiString. This routine makes a deep copy of this object. */ );
@@ -156,7 +157,7 @@ int avahi_server_add_address(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
const char *name,
AvahiAddress *a);
@@ -171,6 +172,7 @@ int avahi_server_add_service(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name, /**< Service name, e.g. "Lennart's Files" */
const char *type, /**< DNS-SD type, e.g. "_http._tcp" */
const char *domain,
@@ -184,6 +186,7 @@ int avahi_server_add_service_va(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -197,6 +200,7 @@ int avahi_server_add_service_strlst(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -218,6 +222,7 @@ int avahi_server_add_dns_server_address(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *domain,
AvahiDNSServerType type,
const AvahiAddress *address,
@@ -231,6 +236,7 @@ int avahi_server_add_dns_server_name(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *domain,
AvahiDNSServerType type,
const char *name,
diff --git a/avahi-core/resolve-address.c b/avahi-core/resolve-address.c
index 4fb588e..704dab4 100644
--- a/avahi-core/resolve-address.c
+++ b/avahi-core/resolve-address.c
@@ -202,7 +202,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new(
return NULL;
}
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/resolve-host-name.c b/avahi-core/resolve-host-name.c
index 622ece1..940febf 100644
--- a/avahi-core/resolve-host-name.c
+++ b/avahi-core/resolve-host-name.c
@@ -234,7 +234,7 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
return NULL;
}
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST)) {
+ 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;
}
diff --git a/avahi-core/resolve-service.c b/avahi-core/resolve-service.c
index 31b0081..1d79c5a 100644
--- a/avahi-core/resolve-service.c
+++ b/avahi-core/resolve-service.c
@@ -410,7 +410,7 @@ AvahiSServiceResolver *avahi_s_service_resolver_new(
if (!domain)
domain = server->domain_name;
- if (!AVAHI_VALID_FLAGS(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS)) {
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS)) {
avahi_server_set_errno(server, AVAHI_ERR_INVALID_FLAGS);
return NULL;
}
diff --git a/avahi-core/server.c b/avahi-core/server.c
index 6b7571e..49821d8 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -139,7 +139,7 @@ static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name
for (e = avahi_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)
if (!e->dead && avahi_entry_is_registered(s, e, i))
- callback(s, e->record, e->flags & AVAHI_ENTRY_UNIQUE, userdata);
+ callback(s, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, userdata);
avahi_key_unref(k);
}
@@ -166,7 +166,7 @@ void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry
assert(i);
assert(e);
- avahi_record_list_push(s->record_list, e->record, e->flags & AVAHI_ENTRY_UNIQUE, unicast_response, auxiliary);
+ avahi_record_list_push(s->record_list, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, unicast_response, auxiliary);
}
void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response) {
@@ -319,7 +319,7 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor
continue;
}
- if (!(e->flags & AVAHI_ENTRY_UNIQUE) && !unique)
+ if (!(e->flags & AVAHI_PUBLISH_UNIQUE) && !unique)
continue;
/* Either our entry or the other is intended to be unique, so let's check */
@@ -1195,7 +1195,7 @@ static void register_hinfo(AvahiServer *s) {
r->data.hinfo.cpu = avahi_strdup(avahi_strup(utsname.machine));
r->data.hinfo.os = avahi_strdup(avahi_strup(utsname.sysname));
- if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_ENTRY_UNIQUE, r) < 0) {
+ if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, r) < 0) {
avahi_log_warn("Failed to add HINFO RR: %s", avahi_strerror(s->error));
return;
}
@@ -1214,10 +1214,10 @@ static void register_localhost(AvahiServer *s) {
/* Add localhost entries */
avahi_address_parse("127.0.0.1", AVAHI_PROTO_INET, &a);
- avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_ENTRY_NOPROBE|AVAHI_ENTRY_NOANNOUNCE, "localhost", &a);
+ avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_NO_ANNOUNCE, "localhost", &a);
avahi_address_parse("::1", AVAHI_PROTO_INET6, &a);
- avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_ENTRY_NOPROBE|AVAHI_ENTRY_NOANNOUNCE, "ip6-localhost", &a);
+ avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_NO_ANNOUNCE, "ip6-localhost", &a);
}
static void register_browse_domain(AvahiServer *s) {
@@ -1418,7 +1418,6 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
s->legacy_unicast_reflect_slots = NULL;
s->legacy_unicast_reflect_id = 0;
-
if (s->config.enable_wide_area) {
s->wide_area_lookup_engine = avahi_wide_area_engine_new(s);
avahi_wide_area_set_servers(s->wide_area_lookup_engine, s->config.wide_area_servers, s->config.n_wide_area_servers);
@@ -1535,7 +1534,7 @@ void avahi_server_free(AvahiServer* s) {
avahi_free(s);
}
-static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiEntryFlags flags) {
+static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiPublishFlags flags) {
AvahiEntry *e;
assert(s);
@@ -1545,10 +1544,10 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr
if (e->dead)
continue;
- if (!(flags & AVAHI_ENTRY_UNIQUE) && !(e->flags & AVAHI_ENTRY_UNIQUE))
+ if (!(flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_UNIQUE))
continue;
- if ((flags & AVAHI_ENTRY_ALLOWMUTIPLE) && (e->flags & AVAHI_ENTRY_ALLOWMUTIPLE) )
+ if ((flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) && (e->flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) )
continue;
if ((interface <= 0 ||
@@ -1569,7 +1568,7 @@ int avahi_server_add(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
AvahiRecord *r) {
AvahiEntry *e, *t;
@@ -1577,6 +1576,18 @@ int avahi_server_add(
assert(s);
assert(r);
+ if (!AVAHI_IF_VALID(interface))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
+
+ if (!AVAHI_PROTO_VALID(protocol))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
+
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_ANNOUNCE|AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_UNIQUE|AVAHI_PUBLISH_ALLOW_MULTIPLE))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
+
+ if (!avahi_is_valid_domain_name(r->key->name))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
+
if (r->ttl == 0)
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_TTL);
@@ -1590,7 +1601,7 @@ int avahi_server_add(
return avahi_server_set_errno(s, AVAHI_ERR_LOCAL_COLLISION);
if (!(e = avahi_new(AvahiEntry, 1)))
- return avahi_server_set_errno(s, AVAHI_ERR_NO_NETWORK);
+ return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
e->server = s;
e->record = avahi_record_ref(r);
@@ -1671,7 +1682,7 @@ int avahi_server_add_ptr(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
const char *dest) {
@@ -1682,7 +1693,13 @@ int avahi_server_add_ptr(
assert(s);
assert(dest);
- if (!(r = avahi_record_new_full(name ? name : s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR, ttl)))
+ if ((name && !avahi_is_valid_domain_name(name)) || !avahi_is_valid_domain_name(dest))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
+
+ if (!name)
+ name = s->host_name_fqdn;
+
+ if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR, ttl)))
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
r->data.ptr.name = avahi_normalize_name(dest);
@@ -1696,30 +1713,38 @@ int avahi_server_add_address(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
const char *name,
AvahiAddress *a) {
char *n = NULL;
int ret = AVAHI_OK;
+
assert(s);
assert(a);
- if (name) {
+ if (!AVAHI_IF_VALID(interface))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
+
+ if (!AVAHI_PROTO_VALID(protocol) || !AVAHI_PROTO_VALID(a->proto))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
+
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_REVERSE|AVAHI_PUBLISH_NO_ANNOUNCE|AVAHI_PUBLISH_NO_PROBE))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
+
+ if (name && !avahi_is_valid_domain_name(name))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
+
+ if (!name)
+ name = s->host_name_fqdn;
+ else {
if (!(n = avahi_normalize_name(name)))
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
name = n;
- } else
- name = s->host_name_fqdn;
-
- if (!avahi_is_valid_domain_name(name)) {
- ret = avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
- goto fail;
}
if (a->proto == AVAHI_PROTO_INET) {
- char *reverse;
AvahiRecord *r;
if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME))) {
@@ -1728,22 +1753,25 @@ int avahi_server_add_address(
}
r->data.a.address = a->data.ipv4;
- ret = avahi_server_add(s, g, interface, protocol, flags | AVAHI_ENTRY_UNIQUE | AVAHI_ENTRY_ALLOWMUTIPLE, r);
+ ret = avahi_server_add(s, g, interface, protocol, (flags & ~ AVAHI_PUBLISH_NO_REVERSE) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
avahi_record_unref(r);
if (ret < 0)
goto fail;
-
- if (!(reverse = avahi_reverse_lookup_name_ipv4(&a->data.ipv4))) {
- ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
- goto fail;
- }
-
- ret = avahi_server_add_ptr(s, g, interface, protocol, flags | AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse, name);
- avahi_free(reverse);
+ if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) {
+ char *reverse;
+
+ if (!(reverse = avahi_reverse_lookup_name_ipv4(&a->data.ipv4))) {
+ 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);
+ }
+
} else {
- char *reverse;
AvahiRecord *r;
assert(a->proto == AVAHI_PROTO_INET6);
@@ -1754,30 +1782,34 @@ int avahi_server_add_address(
}
r->data.aaaa.address = a->data.ipv6;
- ret = avahi_server_add(s, g, interface, protocol, flags | AVAHI_ENTRY_UNIQUE | AVAHI_ENTRY_ALLOWMUTIPLE, r);
+ ret = avahi_server_add(s, g, interface, protocol, (flags & ~ AVAHI_PUBLISH_NO_REVERSE) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
avahi_record_unref(r);
if (ret < 0)
goto fail;
- 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_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse, name);
- avahi_free(reverse);
+ if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) {
+ char *reverse;
- if (ret < 0)
- goto fail;
-
- if (!(reverse = avahi_reverse_lookup_name_ipv6_int(&a->data.ipv6))) {
- ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
- goto fail;
+ 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))) {
+ 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);
}
-
- ret = avahi_server_add_ptr(s, g, interface, protocol, flags | AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse, name);
- avahi_free(reverse);
}
fail:
@@ -1792,7 +1824,7 @@ static int server_add_txt_strlst_nocopy(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
AvahiStringList *strlst) {
@@ -1801,7 +1833,7 @@ static int server_add_txt_strlst_nocopy(
int ret;
assert(s);
-
+
if (!(r = avahi_record_new_full(name ? name : s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, ttl)))
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
@@ -1817,7 +1849,7 @@ int avahi_server_add_txt_strlst(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
AvahiStringList *strlst) {
@@ -1832,7 +1864,7 @@ int avahi_server_add_txt_va(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
va_list va) {
@@ -1847,7 +1879,7 @@ int avahi_server_add_txt(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
- AvahiEntryFlags flags,
+ AvahiPublishFlags flags,
uint32_t ttl,
const char *name,
...) {
@@ -1907,6 +1939,7 @@ static int server_add_service_strlst_nocopy(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -1923,6 +1956,15 @@ static int server_add_service_strlst_nocopy(
assert(type);
assert(name);
+ if (!AVAHI_IF_VALID(interface))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
+
+ if (!AVAHI_PROTO_VALID(protocol))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
+
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
+
if (!avahi_is_valid_service_name(name))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_SERVICE_NAME);
@@ -1953,7 +1995,7 @@ static int server_add_service_strlst_nocopy(
snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d);
snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d);
- if ((ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, 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;
if (!(r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) {
@@ -1966,22 +2008,23 @@ 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, AVAHI_ENTRY_UNIQUE, r);
+ ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, r);
avahi_record_unref(r);
if (ret < 0)
goto fail;
- strlst = add_magic_cookie(s, strlst);
+ if (!(flags & AVAHI_PUBLISH_NO_COOKIE))
+ strlst = add_magic_cookie(s, strlst);
- ret = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_ENTRY_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)
goto fail;
snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d);
- ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, 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:
@@ -1999,6 +2042,7 @@ int avahi_server_add_service_strlst(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -2010,7 +2054,7 @@ int avahi_server_add_service_strlst(
assert(type);
assert(name);
- return server_add_service_strlst_nocopy(s, g, interface, protocol, name, type, domain, host, port, avahi_string_list_copy(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(
@@ -2018,6 +2062,7 @@ int avahi_server_add_service_va(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -2029,7 +2074,7 @@ int avahi_server_add_service_va(
assert(type);
assert(name);
- return server_add_service_strlst_nocopy(s, g, interface, protocol, name, type, domain, host, port, avahi_string_list_new_va(va));
+ 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(
@@ -2037,6 +2082,7 @@ int avahi_server_add_service(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *name,
const char *type,
const char *domain,
@@ -2052,7 +2098,7 @@ int avahi_server_add_service(
assert(name);
va_start(va, port);
- ret = avahi_server_add_service_va(s, g, interface, protocol, name, type, domain, host, port, va);
+ ret = avahi_server_add_service_va(s, g, interface, protocol, flags, name, type, domain, host, port, va);
va_end(va);
return ret;
}
@@ -2084,6 +2130,7 @@ int avahi_server_add_dns_server_address(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *domain,
AvahiDNSServerType type,
const AvahiAddress *address,
@@ -2095,23 +2142,33 @@ int avahi_server_add_dns_server_address(
assert(s);
assert(address);
- assert(type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE);
- assert(address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6);
+ if (!AVAHI_IF_VALID(interface))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
+
+ if (!AVAHI_PROTO_VALID(protocol) || !AVAHI_PROTO_VALID(address->proto))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
+
+ if (!AVAHI_FLAGS_VALID(flags, 0) || (type != AVAHI_DNS_SERVER_UPDATE && type != AVAHI_DNS_SERVER_RESOLVE))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
+
if (port == 0)
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PORT);
if (domain && !avahi_is_valid_domain_name(domain))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
+ if (!domain)
+ domain = s->domain_name;
+
if (address->proto == AVAHI_PROTO_INET) {
hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv4Address));
- snprintf(n, sizeof(n), "ip-%s.%s", h, s->domain_name);
+ snprintf(n, sizeof(n), "ip-%s.%s", h, domain);
r = avahi_record_new_full(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME);
r->data.a.address = address->data.ipv4;
} else {
hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv6Address));
- snprintf(n, sizeof(n), "ip6-%s.%s", h, s->domain_name);
+ snprintf(n, sizeof(n), "ip6-%s.%s", h, domain);
r = avahi_record_new_full(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, AVAHI_DEFAULT_TTL_HOST_NAME);
r->data.aaaa.address = address->data.ipv6;
}
@@ -2119,13 +2176,13 @@ int avahi_server_add_dns_server_address(
if (!r)
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
- ret = avahi_server_add(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE | AVAHI_ENTRY_ALLOWMUTIPLE, r);
+ ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
avahi_record_unref(r);
if (ret < 0)
return ret;
- return avahi_server_add_dns_server_name(s, g, interface, protocol, domain, type, n, port);
+ return avahi_server_add_dns_server_name(s, g, interface, protocol, flags, domain, type, n, port);
}
int avahi_server_add_dns_server_name(
@@ -2133,6 +2190,7 @@ int avahi_server_add_dns_server_name(
AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
+ AvahiPublishFlags flags,
const char *domain,
AvahiDNSServerType type,
const char *name,
@@ -2144,8 +2202,16 @@ int avahi_server_add_dns_server_name(
assert(s);
assert(name);
- assert(type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE);
+ if (!AVAHI_IF_VALID(interface))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
+
+ if (!AVAHI_PROTO_VALID(protocol))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
+
+ if (!AVAHI_FLAGS_VALID(flags, 0) || (type != AVAHI_DNS_SERVER_UPDATE && type != AVAHI_DNS_SERVER_RESOLVE))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
+
if (port == 0)
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PORT);
@@ -2154,7 +2220,6 @@ int avahi_server_add_dns_server_name(
if (domain && !avahi_is_valid_domain_name(domain))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
-
if (!domain)
domain = s->domain_name;
@@ -2178,7 +2243,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_ENTRY_NULL, r);
+ ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_NULL, r);
avahi_record_unref(r);
return ret;
diff --git a/avahi-core/server.h b/avahi-core/server.h
index 600e442..3e439f9 100644
--- a/avahi-core/server.h
+++ b/avahi-core/server.h
@@ -42,6 +42,8 @@ typedef struct AvahiEntry AvahiEntry;
#define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
+#define AVAHI_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
+
typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot;
struct AvahiLegacyUnicastReflectSlot {
@@ -61,7 +63,7 @@ struct AvahiEntry {
int dead;
- AvahiEntryFlags flags;
+ AvahiPublishFlags flags;
AvahiRecord *record;
AvahiIfIndex interface;
AvahiProtocol protocol;