summaryrefslogtreecommitdiffstats
path: root/avahi-daemon
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-18 19:52:03 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-18 19:52:03 +0000
commit6b391bb81f0dce0193a722254016b26c12a17643 (patch)
tree913abdf1f71f07e4efbf0ab2d0590494f456f9fe /avahi-daemon
parent8b22b43669d936ab75914732209f93a0b7ee81f4 (diff)
* remove AVAHI_PUBLISH_IS_PROXY, it was a bad idea
* drop avahi_service_is_service_local(), avahi_client_is_service_local() * add new lookup result flags AVAHI_LOOKUP_RESULT_OUR_OWN and AVAHI_LOOKUP_RESULT_LOCAL * remove avahi_address_resolver_new() and replace it by avahi_address_resolver_new_a() * avahi-client: save query data in browse/resolve objects so that we can return it on failure * other cleanups git-svn-id: file:///home/lennart/svn/public/avahi/trunk@811 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-daemon')
-rw-r--r--avahi-daemon/Server.introspect10
-rw-r--r--avahi-daemon/dbus-protocol.c79
-rw-r--r--avahi-daemon/static-services.c2
3 files changed, 42 insertions, 49 deletions
diff --git a/avahi-daemon/Server.introspect b/avahi-daemon/Server.introspect
index 5d5e862..2e36a21 100644
--- a/avahi-daemon/Server.introspect
+++ b/avahi-daemon/Server.introspect
@@ -107,16 +107,6 @@
<arg name="flags" type="u" direction="out"/>
</method>
- <method name="IsServiceLocal">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
-
- <arg name="is_local" type="b" direction="out"/>
- </method>
-
<method name="EntryGroupNew">
<arg name="path" type="o" direction="out"/>
</method>
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index d2d2d8f..7611156 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -805,22 +805,13 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
return respond_ok(c, m);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) {
- DBusMessage *reply;
- int b;
-
+
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_log_warn("Error parsing EntryGroup::IsEmpty message");
goto fail;
}
- b = !!avahi_s_entry_group_is_empty(i->entry_group);
-
- reply = dbus_message_new_method_return(m);
- dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID);
- dbus_connection_send(c, reply, NULL);
- dbus_message_unref(reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ return respond_boolean(c, m, !!avahi_s_entry_group_is_empty(i->entry_group));
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) {
AvahiEntryGroupState state;
@@ -1271,6 +1262,21 @@ fail:
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+static int is_our_own_service(Client *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) {
+ AvahiSEntryGroup *g;
+
+
+ if (avahi_server_get_group_of_service(avahi_server, interface, protocol, name, type, domain, &g) == AVAHI_OK) {
+ EntryGroupInfo *egi;
+
+ for (egi = c->entry_groups; egi; egi = egi->entry_groups_next)
+ if (egi->entry_group == g)
+ return 1;
+ }
+
+ return 0;
+}
+
static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata) {
ServiceBrowserInfo *i = userdata;
DBusMessage *m;
@@ -1286,6 +1292,13 @@ static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex inter
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, map_browse_signal_name(event));
+ if (event == AVAHI_BROWSER_NEW) {
+ /* Patch in AVAHI_LOOKUP_RESULT_OUR_OWN */
+
+ if (is_our_own_service(i->client, interface, protocol, name, type, domain) > 0)
+ flags |= AVAHI_LOOKUP_RESULT_OUR_OWN;
+ }
+
if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
assert(name);
assert(type);
@@ -1359,13 +1372,23 @@ static void sync_service_resolver_callback(
if (!name)
name = "";
-
- assert(a);
- avahi_address_snprint(t, sizeof(t), a);
+ if (a)
+ avahi_address_snprint(t, sizeof(t), a);
+ else
+ t[0] = 0;
+
+ /* Patch in AVAHI_LOOKUP_RESULT_OUR_OWN */
+
+ if (is_our_own_service(i->client, interface, protocol, name, type, domain) > 0)
+ flags |= AVAHI_LOOKUP_RESULT_OUR_OWN;
+
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
- i_aprotocol = (int32_t) a->proto;
+ if (a)
+ i_aprotocol = (int32_t) a->proto;
+ else
+ i_aprotocol = AVAHI_PROTO_UNSPEC;
u_flags = (uint32_t) flags;
reply = dbus_message_new_method_return(i->message);
@@ -1391,7 +1414,6 @@ static void sync_service_resolver_callback(
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
-
} else {
assert(event == AVAHI_RESOLVER_FAILURE);
@@ -1613,6 +1635,9 @@ static void async_service_resolver_callback(
if (!name)
name = "";
+ if (is_our_own_service(i->client, interface, protocol, name, type, domain) > 0)
+ flags |= AVAHI_LOOKUP_RESULT_OUR_OWN;
+
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
if (a)
@@ -1762,28 +1787,6 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
return respond_uint32(c, m, avahi_server_get_local_service_cookie(avahi_server));
- } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "IsServiceLocal")) {
- int32_t interface, protocol;
- char *name, *type, *domain;
- int b;
-
- if (!dbus_message_get_args(
- m, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_INVALID) || !name || !type || !domain) {
- avahi_log_warn("Error parsing Server::IsServiceLocal message");
- goto fail;
- }
-
- if ((b = avahi_server_is_service_local(avahi_server, interface, protocol, name, type, domain)) < 0)
- return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
-
- return respond_boolean(c, m, b);
-
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) {
int32_t idx;
int fd;
diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c
index 36f1608..09777cc 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,
- s->host_name ? AVAHI_PUBLISH_IS_PROXY : 0,
+ 0,
g->chosen_name, s->type,
s->domain_name, s->host_name, s->port,
s->txt_records) < 0) {