summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-29 22:37:27 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-29 22:37:27 +0000
commit2f5ff259bdb6fa7ddbb3d03dd683f3e034cddad6 (patch)
tree390ecfe6ce64c37b593d039a6a58768dbe1d5165
parent473af0094573aca62e50051344ec2fd5f6723e6d (diff)
Add new flag AVAHI_PUBLISH_IS_PROXY and activate it for static services with a host name set
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@658 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--avahi-common/defs.h11
-rw-r--r--avahi-core/server.c15
-rw-r--r--avahi-daemon/static-services.c2
3 files changed, 15 insertions, 13 deletions
diff --git a/avahi-common/defs.h b/avahi-common/defs.h
index 06b48a6..4da597c 100644
--- a/avahi-common/defs.h
+++ b/avahi-common/defs.h
@@ -156,11 +156,12 @@ typedef enum {
typedef enum {
AVAHI_PUBLISH_NULL = 0,
AVAHI_PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */
- AVAHI_PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
- AVAHI_PUBLISH_NO_ANNOUNCE = 4, /**< For raw records: Do not announce this RR to other hosts */
- AVAHI_PUBLISH_ALLOW_MULTIPLE = 8, /**< For raw records: Allow multiple local records of this type, even if they are intended to be unique */
+ AVAHI_PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
+ AVAHI_PUBLISH_NO_ANNOUNCE = 4, /**< For raw records: Do not announce this RR to other hosts */
+ AVAHI_PUBLISH_ALLOW_MULTIPLE = 8, /**< For raw records: Allow multiple local records of this type, even if they are intended to be unique */
AVAHI_PUBLISH_NO_REVERSE = 16, /**< For address records: don't create a reverse (PTR) entry */
- AVAHI_PUBLISH_NO_COOKIE = 32 /**< For service records: do not implicitly add the local service cookie to TXT data */
+ AVAHI_PUBLISH_NO_COOKIE = 32, /**< For service records: do not implicitly add the local service cookie to TXT data */
+ AVAHI_PUBLISH_IS_PROXY = 64 /**< For service records: this is a proxy for another host. This modifies behaviour of avahi_server_is_service_local() */
} AvahiPublishFlags;
/** Some flags for lookup functions */
@@ -186,7 +187,7 @@ typedef enum {
AVAHI_BROWSER_REMOVE, /**< The object has been removed from the network */
AVAHI_BROWSER_CACHE_EXHAUSTED, /**< One-time event, to notify the user that all entries from the caches have been send */
AVAHI_BROWSER_ALL_FOR_NOW, /**< One-time event, to notify the user that more records will probably not show up in the near future, i.e. all cache entries have been read and all static servers been queried */
- AVAHI_BROWSER_NOT_FOUND, /**< Issued when using wide area DNS-SD to inform that a record is not existing */
+ AVAHI_BROWSER_NOT_FOUND, /**< Issued when using wide area DNS-SD to inform that a record is not existing */
AVAHI_BROWSER_FAILURE /**< Issued when using wide area DNS-SD to inform about server failures */
} AvahiBrowserEvent;
diff --git a/avahi-core/server.c b/avahi-core/server.c
index cdf31e8..6d076d0 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -1582,7 +1582,7 @@ int avahi_server_add(
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))
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_ANNOUNCE|AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_UNIQUE|AVAHI_PUBLISH_ALLOW_MULTIPLE|AVAHI_PUBLISH_IS_PROXY))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
if (!avahi_is_valid_domain_name(r->key->name))
@@ -1962,7 +1962,7 @@ static int server_add_service_strlst_nocopy(
if (!AVAHI_PROTO_VALID(protocol))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
- if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE))
+ if (!AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE|AVAHI_PUBLISH_IS_PROXY))
return avahi_server_set_errno(s, AVAHI_ERR_INVALID_FLAGS);
if (!avahi_is_valid_service_name(name))
@@ -1995,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, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0)
+ if ((ret = avahi_server_add_ptr(s, g, interface, protocol, flags & AVAHI_PUBLISH_IS_PROXY, 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))) {
@@ -2008,7 +2008,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, AVAHI_PUBLISH_UNIQUE, r);
+ ret = avahi_server_add(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY) | AVAHI_PUBLISH_UNIQUE, r);
avahi_record_unref(r);
if (ret < 0)
@@ -2017,14 +2017,14 @@ 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, AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, 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);
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, 0, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name);
+ ret = avahi_server_add_ptr(s, g, interface, protocol, (flags & AVAHI_PUBLISH_IS_PROXY), AVAHI_DEFAULT_TTL, enum_ptr, ptr_name);
fail:
@@ -2620,7 +2620,8 @@ int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiP
for (e = avahi_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next) {
if ((e->interface == interface || e->interface <= 0 || interface <= 0) &&
- (e->protocol == protocol || e->protocol == AVAHI_PROTO_UNSPEC || protocol == AVAHI_PROTO_UNSPEC)) {
+ (e->protocol == protocol || e->protocol == AVAHI_PROTO_UNSPEC || protocol == AVAHI_PROTO_UNSPEC) &&
+ !(e->flags & AVAHI_PUBLISH_IS_PROXY)) {
ret = 1;
break;
}
diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c
index 09777cc..36f1608 100644
--- a/avahi-daemon/static-services.c
+++ b/avahi-daemon/static-services.c
@@ -222,7 +222,7 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
avahi_server,
g->entry_group,
AVAHI_IF_UNSPEC, s->protocol,
- 0,
+ s->host_name ? AVAHI_PUBLISH_IS_PROXY : 0,
g->chosen_name, s->type,
s->domain_name, s->host_name, s->port,
s->txt_records) < 0) {