summaryrefslogtreecommitdiffstats
path: root/avahi-daemon
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-12 02:37:08 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-12 02:37:08 +0000
commitbb14e0a8aa3173c8a6d80b1a9c8b300a452ee9f1 (patch)
treed29ec90346b7523aa877207ae29e461b767460c6 /avahi-daemon
parent7484feb19b10878042dcb8cea618d10df5440c1c (diff)
* drop AVAHI_RESOLVER_TIMEOUT, AVAHI_RESOLVER_NOT_FOUND and AVAHI_BROWSER_NOT_FOUND, use AVAHI_xxx_FAILURE instead
* set the client/server errno variable when AVAHI_xxx_FAILURE happens * update DBUS interface accordingly, pass errno value with Failure events * Pass DNS return codes to the app by wrapping them in avahi error codes git-svn-id: file:///home/lennart/svn/public/avahi/trunk@732 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-daemon')
-rw-r--r--avahi-daemon/AddressResolver.introspect8
-rw-r--r--avahi-daemon/DomainBrowser.introspect6
-rw-r--r--avahi-daemon/HostNameResolver.introspect8
-rw-r--r--avahi-daemon/ServiceBrowser.introspect7
-rw-r--r--avahi-daemon/ServiceResolver.introspect8
-rw-r--r--avahi-daemon/ServiceTypeBrowser.introspect6
-rw-r--r--avahi-daemon/dbus-protocol.c67
-rw-r--r--avahi-daemon/simple-protocol.c23
8 files changed, 65 insertions, 68 deletions
diff --git a/avahi-daemon/AddressResolver.introspect b/avahi-daemon/AddressResolver.introspect
index 61a6e9c..273ce8f 100644
--- a/avahi-daemon/AddressResolver.introspect
+++ b/avahi-daemon/AddressResolver.introspect
@@ -24,11 +24,9 @@
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
diff --git a/avahi-daemon/DomainBrowser.introspect b/avahi-daemon/DomainBrowser.introspect
index 85e7e73..daabdb8 100644
--- a/avahi-daemon/DomainBrowser.introspect
+++ b/avahi-daemon/DomainBrowser.introspect
@@ -29,9 +29,9 @@
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
diff --git a/avahi-daemon/HostNameResolver.introspect b/avahi-daemon/HostNameResolver.introspect
index d3337f9..d71ed8a 100644
--- a/avahi-daemon/HostNameResolver.introspect
+++ b/avahi-daemon/HostNameResolver.introspect
@@ -24,11 +24,9 @@
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
diff --git a/avahi-daemon/ServiceBrowser.introspect b/avahi-daemon/ServiceBrowser.introspect
index 350026d..9638eaa 100644
--- a/avahi-daemon/ServiceBrowser.introspect
+++ b/avahi-daemon/ServiceBrowser.introspect
@@ -33,14 +33,13 @@
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
<signal name="CacheExhausted"/>
-
</interface>
</node>
diff --git a/avahi-daemon/ServiceResolver.introspect b/avahi-daemon/ServiceResolver.introspect
index 7b752e3..771f179 100644
--- a/avahi-daemon/ServiceResolver.introspect
+++ b/avahi-daemon/ServiceResolver.introspect
@@ -29,11 +29,9 @@
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
diff --git a/avahi-daemon/ServiceTypeBrowser.introspect b/avahi-daemon/ServiceTypeBrowser.introspect
index 1540a8f..04e7db9 100644
--- a/avahi-daemon/ServiceTypeBrowser.introspect
+++ b/avahi-daemon/ServiceTypeBrowser.introspect
@@ -31,9 +31,9 @@
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index 96d0118..25a9e8e 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -430,7 +430,7 @@ static DBusHandlerResult respond_error(DBusConnection *c, DBusMessage *m, int er
if (!text)
text = avahi_strerror(error);
- reply = dbus_message_new_error(m, avahi_error_number_to_dbus (error), text);
+ reply = dbus_message_new_error(m, avahi_error_number_to_dbus(error), text);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
@@ -504,6 +504,17 @@ static DBusHandlerResult respond_path(DBusConnection *c, DBusMessage *m, const c
return DBUS_HANDLER_RESULT_HANDLED;
}
+static void append_server_error(DBusMessage *reply) {
+ const char *t;
+
+ t = avahi_error_number_to_dbus(avahi_server_errno(avahi_server));
+
+ dbus_message_append_args(
+ reply,
+ DBUS_TYPE_STRING, &t,
+ DBUS_TYPE_INVALID);
+}
+
static char *file_get_contents(char *fname) {
int fd = -1;
struct stat st;
@@ -560,7 +571,6 @@ static const char *map_browse_signal_name(AvahiBrowserEvent e) {
case AVAHI_BROWSER_NEW : return "ItemNew";
case AVAHI_BROWSER_REMOVE : return "ItemRemove";
case AVAHI_BROWSER_FAILURE : return "Failure";
- case AVAHI_BROWSER_NOT_FOUND : return "NotFound";
case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CacheExhausted";
case AVAHI_BROWSER_ALL_FOR_NOW : return "AllForNow";
}
@@ -571,25 +581,12 @@ static const char *map_browse_signal_name(AvahiBrowserEvent e) {
static const char *map_resolve_signal_name(AvahiResolverEvent e) {
switch (e) {
case AVAHI_RESOLVER_FOUND : return "Found";
- case AVAHI_RESOLVER_TIMEOUT : return "Timeout";
case AVAHI_RESOLVER_FAILURE : return "Failure";
- case AVAHI_RESOLVER_NOT_FOUND : return "NotFound";
}
abort();
}
-static int map_resolve_error(AvahiResolverEvent e) {
-
- switch(e) {
- case AVAHI_RESOLVER_FOUND : abort();
- case AVAHI_RESOLVER_TIMEOUT : return AVAHI_ERR_TIMEOUT;
- case AVAHI_RESOLVER_FAILURE : return AVAHI_ERR_FAILURE;
- case AVAHI_RESOLVER_NOT_FOUND : return AVAHI_ERR_NOT_FOUND;
- }
-
- abort();
-}
static DBusHandlerResult handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname) {
char *path, *contents;
@@ -979,8 +976,10 @@ static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfI
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_host_name_resolver_free(i);
}
@@ -1019,8 +1018,10 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_address_resolver_free(i);
}
@@ -1093,7 +1094,8 @@ static void domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interfa
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
- }
+ } else if (event == AVAHI_BROWSER_FAILURE)
+ append_server_error(m);
dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
@@ -1170,7 +1172,8 @@ static void service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIn
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
- }
+ } else if (event == AVAHI_BROWSER_FAILURE)
+ append_server_error(m);
dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
@@ -1250,7 +1253,8 @@ static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex inter
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
- }
+ } else if (event == AVAHI_BROWSER_FAILURE)
+ append_server_error(m);
dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
@@ -1340,8 +1344,12 @@ static void sync_service_resolver_callback(
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_service_resolver_free(i);
}
@@ -1353,7 +1361,7 @@ static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInd
assert(r);
assert(i);
- reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_browse_signal_name(event));
+ reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_resolve_signal_name(event));
if (event == AVAHI_RESOLVER_FOUND) {
char t[256], *pt = t;
@@ -1379,6 +1387,9 @@ static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInd
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ append_server_error(reply);
}
dbus_message_set_destination(reply, i->client->name);
@@ -1462,6 +1473,9 @@ static void async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIf
DBUS_TYPE_STRING, &pt,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ append_server_error(reply);
}
dbus_message_set_destination(reply, i->client->name);
@@ -1574,6 +1588,9 @@ static void async_service_resolver_callback(
reply,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ append_server_error(reply);
}
dbus_message_set_destination(reply, i->client->name);
diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c
index 0c9989a..d53987d 100644
--- a/avahi-daemon/simple-protocol.c
+++ b/avahi-daemon/simple-protocol.c
@@ -178,12 +178,8 @@ static void host_name_resolver_callback(
assert(c);
- if (event == AVAHI_RESOLVER_TIMEOUT)
- client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_TIMEOUT);
- else if (event == AVAHI_RESOLVER_FAILURE)
- client_output_printf(c, "%+i Query failed\n", AVAHI_ERR_FAILURE);
- else if (event == AVAHI_RESOLVER_NOT_FOUND)
- client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_NOT_FOUND);
+ if (event == AVAHI_RESOLVER_FAILURE)
+ client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server)));
else if (event == AVAHI_RESOLVER_FOUND) {
char t[64];
avahi_address_snprint(t, sizeof(t), a);
@@ -207,12 +203,8 @@ static void address_resolver_callback(
assert(c);
- if (event == AVAHI_RESOLVER_TIMEOUT)
- client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_TIMEOUT);
- else if (event == AVAHI_RESOLVER_FAILURE)
- client_output_printf(c, "%+i Query failed\n", AVAHI_ERR_FAILURE);
- else if (event == AVAHI_RESOLVER_NOT_FOUND)
- client_output_printf(c, "%+i Not found\n", AVAHI_ERR_NOT_FOUND);
+ if (event == AVAHI_RESOLVER_FAILURE)
+ client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server)));
else if (event == AVAHI_RESOLVER_FOUND)
client_output_printf(c, "+ %i %u %s\n", iface, protocol, hostname);
@@ -240,12 +232,7 @@ static void dns_server_browser_callback(
switch (event) {
case AVAHI_BROWSER_FAILURE:
- client_output_printf(c, "%+i Query failed\n", AVAHI_ERR_FAILURE);
- c->state = CLIENT_DEAD;
- break;
-
- case AVAHI_BROWSER_NOT_FOUND:
- client_output_printf(c, "%+i Not found\n", AVAHI_ERR_FAILURE);
+ client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server)));
c->state = CLIENT_DEAD;
break;