]> git.meshlink.io Git - catta/commitdiff
* drop AVAHI_RESOLVER_TIMEOUT, AVAHI_RESOLVER_NOT_FOUND and AVAHI_BROWSER_NOT_FOUND...
authorLennart Poettering <lennart@poettering.net>
Wed, 12 Oct 2005 02:37:08 +0000 (02:37 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 12 Oct 2005 02:37:08 +0000 (02:37 +0000)
* 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

29 files changed:
avahi-client/browser.c
avahi-client/client-test.c
avahi-client/client.c
avahi-client/resolver.c
avahi-common/dbus.c
avahi-common/dbus.h
avahi-common/defs.h
avahi-common/error.c
avahi-common/error.h
avahi-compat-libdns_sd/compat.c
avahi-core/avahi-test.c
avahi-core/browse-dns-server.c
avahi-core/browse.c
avahi-core/querier-test.c
avahi-core/resolve-address.c
avahi-core/resolve-host-name.c
avahi-core/resolve-service.c
avahi-core/wide-area.c
avahi-daemon/AddressResolver.introspect
avahi-daemon/DomainBrowser.introspect
avahi-daemon/HostNameResolver.introspect
avahi-daemon/ServiceBrowser.introspect
avahi-daemon/ServiceResolver.introspect
avahi-daemon/ServiceTypeBrowser.introspect
avahi-daemon/dbus-protocol.c
avahi-daemon/simple-protocol.c
avahi-discover-standalone/main.c
examples/client-browse-services.c
examples/core-browse-services.c

index a83aa697da597c4d0ecfb813b817758b1a9d4c15..bdbd8c5c58da6b79731bde7a5372426f4aa99216 100644 (file)
@@ -194,17 +194,42 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE
     if (!db)
         goto fail;
 
-    if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
-        if (!dbus_message_get_args(
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_STRING, &domain,
-                DBUS_TYPE_UINT32, &flags,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set (&error)) {
-            fprintf(stderr, "Failed to parse browser event.\n");
-            goto fail;
+    switch (event) {
+        case AVAHI_BROWSER_NEW:
+        case AVAHI_BROWSER_REMOVE:
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_STRING, &domain,
+                    DBUS_TYPE_UINT32, &flags,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+
+            break;
+            
+        case AVAHI_BROWSER_CACHE_EXHAUSTED:
+        case AVAHI_BROWSER_ALL_FOR_NOW:
+            break;
+
+        case AVAHI_BROWSER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt));
+            break;
         }
     }
 
@@ -369,19 +394,41 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr
 
     if (!b)
         goto fail;
+    switch (event) {
+        case AVAHI_BROWSER_NEW:
+        case AVAHI_BROWSER_REMOVE:
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_STRING, &type,
+                    DBUS_TYPE_STRING, &domain,
+                    DBUS_TYPE_UINT32, &flags,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set(&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+            break;
+            
+        case AVAHI_BROWSER_CACHE_EXHAUSTED:
+        case AVAHI_BROWSER_ALL_FOR_NOW:
+            break;
 
-    if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
-        if (!dbus_message_get_args(
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_STRING, &type,
-                DBUS_TYPE_STRING, &domain,
-                DBUS_TYPE_UINT32, &flags,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set(&error)) {
-            fprintf(stderr, "Failed to parse browser event.\n");
-            goto fail;
+        case AVAHI_BROWSER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
+            break;
         }
     }
 
@@ -528,7 +575,7 @@ int avahi_service_browser_free (AvahiServiceBrowser *b) {
 }
 
 
-DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) {
+DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) {
     AvahiServiceBrowser *b = NULL;
     DBusError error;
     const char *path;
@@ -548,19 +595,43 @@ DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowser
     if (!b)
         goto fail;
 
-    if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
-        if (!dbus_message_get_args (
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_STRING, &name,
-                DBUS_TYPE_STRING, &type,
-                DBUS_TYPE_STRING, &domain,
-                DBUS_TYPE_UINT32, &flags,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set(&error)) {
-            fprintf(stderr, "Failed to parse browser event.\n");
-            goto fail;
+    switch (event) {
+        case AVAHI_BROWSER_NEW:
+        case AVAHI_BROWSER_REMOVE:
+            
+            if (!dbus_message_get_args (
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_STRING, &name,
+                    DBUS_TYPE_STRING, &type,
+                    DBUS_TYPE_STRING, &domain,
+                    DBUS_TYPE_UINT32, &flags,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set(&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+            break;
+
+        case AVAHI_BROWSER_CACHE_EXHAUSTED:
+        case AVAHI_BROWSER_ALL_FOR_NOW:
+            break;
+
+        case AVAHI_BROWSER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse browser event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
+            break;
         }
     }
 
index 15af93f45722706618e5cfad363375ec8c580e8e..c7789baedc68e5b13f73dd1eecb008c9b85e7c81 100644 (file)
@@ -71,8 +71,7 @@ static void avahi_service_resolver_callback(
     
     char addr[64];
     char *txtr;
-    if (event == AVAHI_RESOLVER_TIMEOUT)
-    {
+    if (event == AVAHI_RESOLVER_FAILURE) {
         printf ("SERVICE-RESOLVER: ServiceResolver %p timed out (%s %s)\n", (void*) r, name, type);
         return;
     }
@@ -129,8 +128,7 @@ static void avahi_address_resolver_callback (
     void *userdata) {
     
     char addr[64];
-    if (event == AVAHI_RESOLVER_TIMEOUT)
-    {
+    if (event == AVAHI_RESOLVER_FAILURE) {
         printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n");
         return;
     }
@@ -152,8 +150,7 @@ static void avahi_host_name_resolver_callback (
     AvahiAddressResolver *ar;
     char addr[64];
     
-    if (event == AVAHI_RESOLVER_TIMEOUT)
-    {
+    if (event == AVAHI_RESOLVER_FAILURE) {
         printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n");
         return;
     }
index be52cc928b3689506b21ca3a4eafd7f723207a87..8b0d9579acff8fa666fba35dadc9ddc759958c95 100644 (file)
@@ -178,8 +178,6 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
         return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
     else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow")) 
         return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message);
-    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "NotFound")) 
-        return avahi_domain_browser_event(client, AVAHI_BROWSER_NOT_FOUND, message);
     else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure")) 
         return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message);
 
@@ -191,8 +189,6 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
         return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow")) 
         return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "NotFound")) 
-        return avahi_service_type_browser_event (client, AVAHI_BROWSER_NOT_FOUND, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure")) 
         return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message);
 
@@ -204,35 +200,21 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
         return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow")) 
         return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "NotFound")) 
-        return avahi_service_browser_event (client, AVAHI_BROWSER_NOT_FOUND, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure")) 
         return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message);
 
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found")) 
         return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Timeout")) 
-        return avahi_service_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "NotFound")) 
-        return avahi_service_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure")) 
         return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
 
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found")) 
         return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Timeout")) 
-        return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "NotFound")) 
-        return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure")) 
         return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
 
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found")) 
         return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Timeout")) 
-        return avahi_address_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
-    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "NotFound")) 
-        return avahi_address_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
     else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure")) 
         return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
     
index 494d3cce7aa5ff4866a357e9f8ed742d31557e46..889088f3a2b772ecf771443d2ed0230f4054e131 100644 (file)
@@ -61,95 +61,113 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
     if (!r)
         goto fail;
 
-    if (event == AVAHI_RESOLVER_FOUND) {
-        int j;
-        int32_t interface, protocol, aprotocol;
-        uint32_t flags;
-        char *name, *type, *domain, *host, *address;
-        uint16_t port;
-        DBusMessageIter iter, sub;
-        AvahiAddress a;
-        
-        if (!dbus_message_get_args(
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_STRING, &name,
-                DBUS_TYPE_STRING, &type,
-                DBUS_TYPE_STRING, &domain,
-                DBUS_TYPE_STRING, &host,
-                DBUS_TYPE_INT32, &aprotocol,
-                DBUS_TYPE_STRING, &address,
-                DBUS_TYPE_UINT16, &port,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set (&error)) {
+    switch (event) {
+        case AVAHI_RESOLVER_FOUND: {
+            int j;
+            int32_t interface, protocol, aprotocol;
+            uint32_t flags;
+            char *name, *type, *domain, *host, *address;
+            uint16_t port;
+            DBusMessageIter iter, sub;
+            AvahiAddress a;
             
-            fprintf(stderr, "Failed to parse resolver event.\n");
-            goto fail;
-        }
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_STRING, &name,
+                    DBUS_TYPE_STRING, &type,
+                    DBUS_TYPE_STRING, &domain,
+                    DBUS_TYPE_STRING, &host,
+                    DBUS_TYPE_INT32, &aprotocol,
+                    DBUS_TYPE_STRING, &address,
+                    DBUS_TYPE_UINT16, &port,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+            
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
         
-        dbus_message_iter_init(message, &iter);
+            dbus_message_iter_init(message, &iter);
         
-        for (j = 0; j < 9; j++)
-            dbus_message_iter_next(&iter);
+            for (j = 0; j < 9; j++)
+                dbus_message_iter_next(&iter);
         
-        if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
-            dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) {
-            fprintf(stderr, "Error parsing service resolving message\n");
-            goto fail;
-        }
+            if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
+                dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) {
+                fprintf(stderr, "Error parsing service resolving message\n");
+                goto fail;
+            }
         
-        strlst = NULL;
-        dbus_message_iter_recurse(&iter, &sub);
+            strlst = NULL;
+            dbus_message_iter_recurse(&iter, &sub);
         
-        for (;;) {
-            DBusMessageIter sub2;
-            int at;
+            for (;;) {
+                DBusMessageIter sub2;
+                int at;
             
-            if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
-                break;
+                if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
+                    break;
             
-            assert(at == DBUS_TYPE_ARRAY);
+                assert(at == DBUS_TYPE_ARRAY);
             
-            if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
-                fprintf(stderr, "Error parsing service resolving message\n");
-                goto fail;
-            }
+                if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
+                    fprintf(stderr, "Error parsing service resolving message\n");
+                    goto fail;
+                }
             
-            dbus_message_iter_recurse(&sub, &sub2);
+                dbus_message_iter_recurse(&sub, &sub2);
 
-            if (dbus_message_iter_get_array_len(&sub2) > 0) {
-                uint8_t *k;
-                int n;
+                if (dbus_message_iter_get_array_len(&sub2) > 0) {
+                    uint8_t *k;
+                    int n;
                 
-                dbus_message_iter_get_fixed_array(&sub2, &k, &n);
-                strlst = avahi_string_list_add_arbitrary(strlst, k, n);
-            }
+                    dbus_message_iter_get_fixed_array(&sub2, &k, &n);
+                    strlst = avahi_string_list_add_arbitrary(strlst, k, n);
+                }
             
-            dbus_message_iter_next(&sub);
-        }
+                dbus_message_iter_next(&sub);
+            }
 
-        dbus_message_iter_next(&iter);
+            dbus_message_iter_next(&iter);
 
-        if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
-            fprintf(stderr, "Failed to parse resolver event.\n");
-            goto fail;
-        }
+            if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
 
-        dbus_message_iter_get_basic(&iter, &flags);
+            dbus_message_iter_get_basic(&iter, &flags);
                                     
-        assert(address);
-        if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
-            fprintf(stderr, "Failed to parse address\n");
-            goto fail;
-        }
+            assert(address);
+            if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+                fprintf(stderr, "Failed to parse address\n");
+                goto fail;
+            }
     
-        r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, &a, port, strlst, (AvahiLookupResultFlags) flags, r->userdata);
+            r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, &a, port, strlst, (AvahiLookupResultFlags) flags, r->userdata);
         
-        avahi_string_list_free(strlst);
-
-    } else
-        r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, r->userdata);
+            avahi_string_list_free(strlst);
+            break;
+        }
+            
+        case AVAHI_RESOLVER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+            r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, r->userdata);
+            break;
+        }
+    }
 
     return DBUS_HANDLER_RESULT_HANDLED;
 
@@ -324,36 +342,54 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso
     if (!r)
         goto fail;
 
-    if (event == AVAHI_RESOLVER_FOUND) {
-        int32_t interface, protocol, aprotocol;
-        uint32_t flags;
-        char *name, *address;
-        AvahiAddress a;
-        
-        if (!dbus_message_get_args(
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_STRING, &name,
-                DBUS_TYPE_INT32, &aprotocol,
-                DBUS_TYPE_STRING, &address,
-                DBUS_TYPE_UINT32, &flags,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set (&error)) {
-            fprintf(stderr, "Failed to parse resolver event.\n");
-            goto fail;
+    switch (event) {
+        case AVAHI_RESOLVER_FOUND: {
+            int32_t interface, protocol, aprotocol;
+            uint32_t flags;
+            char *name, *address;
+            AvahiAddress a;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_STRING, &name,
+                    DBUS_TYPE_INT32, &aprotocol,
+                    DBUS_TYPE_STRING, &address,
+                    DBUS_TYPE_UINT32, &flags,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
+            
+            assert(address);
+            if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+                fprintf(stderr, "Failed to parse address\n");
+                goto fail;
+            }
+            
+            r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata);
+            break;
         }
-        
-        assert(address);
-        if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
-            fprintf(stderr, "Failed to parse address\n");
-            goto fail;
+            
+        case AVAHI_RESOLVER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+            r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, 0, r->userdata);
+            break;
         }
-    
-        r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata);
-
-    } else
-        r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, 0, r->userdata);
+    }
 
     return DBUS_HANDLER_RESULT_HANDLED;
     
@@ -516,35 +552,54 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv
     if (!r)
         goto fail;
 
-    if (event == AVAHI_RESOLVER_FOUND) {
-        int32_t interface, protocol, aprotocol;
-        uint32_t flags;
-        char *name, *address;
-        AvahiAddress a;
-        
-        if (!dbus_message_get_args(
-                message, &error,
-                DBUS_TYPE_INT32, &interface,
-                DBUS_TYPE_INT32, &protocol,
-                DBUS_TYPE_INT32, &aprotocol,
-                DBUS_TYPE_STRING, &address,
-                DBUS_TYPE_STRING, &name,
-                DBUS_TYPE_UINT32, &flags,
-                DBUS_TYPE_INVALID) ||
-            dbus_error_is_set (&error)) {
-            fprintf(stderr, "Failed to parse resolver event.\n");
-            goto fail;
+    switch (event) {
+        case AVAHI_RESOLVER_FOUND: {
+            int32_t interface, protocol, aprotocol;
+            uint32_t flags;
+            char *name, *address;
+            AvahiAddress a;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_INT32, &interface,
+                    DBUS_TYPE_INT32, &protocol,
+                    DBUS_TYPE_INT32, &aprotocol,
+                    DBUS_TYPE_STRING, &address,
+                    DBUS_TYPE_STRING, &name,
+                    DBUS_TYPE_UINT32, &flags,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
+            
+            assert(address);
+            if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+                fprintf(stderr, "Failed to parse address\n");
+                goto fail;
+            }
+            
+            r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, (AvahiProtocol) aprotocol, &a, name, (AvahiLookupResultFlags) flags, r->userdata);
+            break;
         }
-        
-        assert(address);
-        if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
-            fprintf(stderr, "Failed to parse address\n");
-            goto fail;
+
+        case AVAHI_RESOLVER_FAILURE: {
+            char *etxt;
+            
+            if (!dbus_message_get_args(
+                    message, &error,
+                    DBUS_TYPE_STRING, &etxt,
+                    DBUS_TYPE_INVALID) ||
+                dbus_error_is_set (&error)) {
+                fprintf(stderr, "Failed to parse resolver event.\n");
+                goto fail;
+            }
+            
+            avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+            r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, AVAHI_PROTO_UNSPEC, NULL, NULL, 0, r->userdata);
+            break;
         }
-    
-        r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, (AvahiProtocol) aprotocol, &a, name, (AvahiLookupResultFlags) flags, r->userdata);
-    } else
-        r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, AVAHI_PROTO_UNSPEC, NULL, NULL, 0, r->userdata);
+    }
 
     return DBUS_HANDLER_RESULT_HANDLED;
     
index d65886887b3e63ef8ddfab6172b77febcc1aa5a6..179b1eda9b8cb645366d24d11f266cde7d80af4f 100644 (file)
@@ -64,7 +64,19 @@ static const char * const table[- AVAHI_ERR_MAX] = {
     AVAHI_DBUS_ERR_NOT_FOUND,
     AVAHI_DBUS_ERR_INVALID_CONFIG,
     AVAHI_DBUS_ERR_VERSION_MISMATCH,
-    AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE
+    AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE,
+    AVAHI_DBUS_ERR_INVALID_PACKET,
+    AVAHI_DBUS_ERR_INVALID_DNS_ERROR,
+    AVAHI_DBUS_ERR_DNS_FORMERR,
+    AVAHI_DBUS_ERR_DNS_SERVFAIL,
+    AVAHI_DBUS_ERR_DNS_NXDOMAIN,
+    AVAHI_DBUS_ERR_DNS_NOTIMP,
+    AVAHI_DBUS_ERR_DNS_REFUSED,
+    AVAHI_DBUS_ERR_DNS_YXDOMAIN,
+    AVAHI_DBUS_ERR_DNS_YXRRSET,
+    AVAHI_DBUS_ERR_DNS_NXRRSET,
+    AVAHI_DBUS_ERR_DNS_NOTAUTH,
+    AVAHI_DBUS_ERR_DNS_NOTZONE,
 };
 
 int avahi_error_dbus_to_number(const char *s) {
index cb7ba1912989833ad5c61195f83d067299e2f636..9806f587b2352b5f115385670ae125e26cf78cf2 100644 (file)
@@ -75,6 +75,18 @@ AVAHI_C_DECL_BEGIN
 #define AVAHI_DBUS_ERR_INVALID_CONFIG "org.freedesktop.Avahi.InvalidConfigurationError"
 #define AVAHI_DBUS_ERR_VERSION_MISMATCH "org.freedesktop.Avahi.VersionMismatchError"
 #define AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE "org.freedesktop.Avahi.InvalidServiceSubtypeError"
+#define AVAHI_DBUS_ERR_INVALID_PACKET "org.freedesktop.Avahi.InvalidPacketError"
+#define AVAHI_DBUS_ERR_INVALID_DNS_ERROR "org.freedesktop.Avahi.InvalidDNSError"
+#define AVAHI_DBUS_ERR_DNS_FORMERR "org.freedesktop.Avahi.DNSFORMERR"
+#define AVAHI_DBUS_ERR_DNS_SERVFAIL "org.freedesktop.Avahi.DNSSERVFAIL"
+#define AVAHI_DBUS_ERR_DNS_NXDOMAIN "org.freedesktop.Avahi.DNSNXDOMAIN"
+#define AVAHI_DBUS_ERR_DNS_NOTIMP "org.freedesktop.Avahi.DNSNOTIMP"
+#define AVAHI_DBUS_ERR_DNS_REFUSED "org.freedesktop.Avahi.DNSREFUSED"
+#define AVAHI_DBUS_ERR_DNS_YXDOMAIN "org.freedesktop.Avahi.DNSYXDOMAIN"
+#define AVAHI_DBUS_ERR_DNS_YXRRSET "org.freedesktop.Avahi.DNSYXRRSET"
+#define AVAHI_DBUS_ERR_DNS_NXRRSET "org.freedesktop.Avahi.DNSNXRRSET"
+#define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH"
+#define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE"
 
 /** Convert a DBus error string into an Avahi error number */
 int avahi_error_dbus_to_number(const char *s);
index be8022e574116b5845921422fa01b9e353d5370c..4d9c40f8ab738536d4b8548dd6bc1a525b820aa6 100644 (file)
@@ -139,7 +139,7 @@ typedef enum {
     AVAHI_ENTRY_GROUP_UNCOMMITED,    /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */
     AVAHI_ENTRY_GROUP_REGISTERING,   /**< The entries of the group are currently being registered */
     AVAHI_ENTRY_GROUP_ESTABLISHED,   /**< The entries have successfully been established */
-    AVAHI_ENTRY_GROUP_COLLISION      /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */ 
+    AVAHI_ENTRY_GROUP_COLLISION,     /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */
 } AvahiEntryGroupState;
 
 /** The type of domain to browse for */
@@ -187,16 +187,13 @@ 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_FAILURE            /**< Issued when using wide area DNS-SD to inform about server failures */
+    AVAHI_BROWSER_FAILURE            /**< Browsing failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */
 } AvahiBrowserEvent;
 
 /** Type of callback event when resolving */
 typedef enum {
     AVAHI_RESOLVER_FOUND,          /**< RR found, resolving successful */
-    AVAHI_RESOLVER_TIMEOUT,        /**< Noone responded within the timeout, resolving failed */
-    AVAHI_RESOLVER_NOT_FOUND,      /**< Query was done using wide area DNS-SD and the server told us that the entry is nto available */
-    AVAHI_RESOLVER_FAILURE         /**< Query was done using wide area DNS-SD and the server failed */
+    AVAHI_RESOLVER_FAILURE         /**< Resolving failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */
 } AvahiResolverEvent;
 
 /** States of a server object */
index 76a05fdb525699433ac045cf63a0a92c7d346512..af104227cc9861f235e0ffc4fddf727f8f1a3cea 100644 (file)
@@ -38,6 +38,7 @@ const char *avahi_strerror(int error) {
         "Resource record key is pattern",
         "Local name collision",
         "Invalid record",
+
         "Invalid service name",
         "Invalid service type",
         "Invalid port number",
@@ -48,6 +49,7 @@ const char *avahi_strerror(int error) {
         "Too many objects",
         "Too many entries",
         "OS Error",
+
         "Access denied",
         "Invalid operation",
         "An unexpected DBUS error occured",
@@ -58,10 +60,24 @@ const char *avahi_strerror(int error) {
         "Invalid interface index",
         "Invalid protocol specification",
         "Invalid flags",
+
         "Not found",
         "Invalid configuration",
         "Version mismatch",
-        "Invalid service subtype"
+        "Invalid service subtype",
+        "Invalid packet",
+        "Invalid DNS return code",
+        "DNS failure: FORMERR",
+        "DNS failure: SERVFAIL",
+        "DNS failure: NXDOMAIN",
+        "DNS failure: NOTIMP",
+
+        "DNS failure: REFUSED",
+        "DNS failure: YXDOMAIN",
+        "DNS failure: YXRRSET",
+        "DNS failure: NXRRSET",
+        "DNS failure: NOTAUTH",
+        "DNS failure: NOTZONE"
     };
 
     if (-error < 0 || -error >= -AVAHI_ERR_MAX)
index 623620acfdded7e8b6cc903cea3553e45fd4162b..55c388bfb707ce47924dc50e71e41cfc3da44c7e 100644 (file)
@@ -42,6 +42,7 @@ enum {
     AVAHI_ERR_IS_PATTERN = -7,               /**< RR key is pattern */
     AVAHI_ERR_LOCAL_COLLISION = -8,          /**< Local name collision */
     AVAHI_ERR_INVALID_RECORD = -9,           /**< Invalid RR */
+
     AVAHI_ERR_INVALID_SERVICE_NAME = -10,    /**< Invalid service name */
     AVAHI_ERR_INVALID_SERVICE_TYPE = -11,    /**< Invalid service type */
     AVAHI_ERR_INVALID_PORT = -12,            /**< Invalid port number */
@@ -52,6 +53,7 @@ enum {
     AVAHI_ERR_TOO_MANY_OBJECTS = -17,        /**< Too many objects */
     AVAHI_ERR_TOO_MANY_ENTRIES = -18,        /**< Too many entries */
     AVAHI_ERR_OS = -19,                      /**< OS error */
+
     AVAHI_ERR_ACCESS_DENIED = -20,           /**< Access denied */
     AVAHI_ERR_INVALID_OPERATION = -21,       /**< Invalid operation */
     AVAHI_ERR_DBUS_ERROR = -22,              /**< An unexpected DBUS error occured */
@@ -62,11 +64,25 @@ enum {
     AVAHI_ERR_INVALID_INTERFACE = -27,       /**< Invalid interface */
     AVAHI_ERR_INVALID_PROTOCOL = -28,        /**< Invalid protocol */
     AVAHI_ERR_INVALID_FLAGS = -29,           /**< Invalid flags */
+
     AVAHI_ERR_NOT_FOUND = -30,               /**< Not found */
     AVAHI_ERR_INVALID_CONFIG = -31,          /**< Configuration error */
     AVAHI_ERR_VERSION_MISMATCH = -32,        /**< Verson mismatch */
     AVAHI_ERR_INVALID_SERVICE_SUBTYPE = -33, /**< Invalid service subtype */
+    AVAHI_ERR_INVALID_PACKET = -34,          /**< Invalid packet */
+    AVAHI_ERR_INVALID_DNS_ERROR = -35,       /**< Invlaid DNS return code */
+    AVAHI_ERR_DNS_FORMERR = -36,
+    AVAHI_ERR_DNS_SERVFAIL = -37,
+    AVAHI_ERR_DNS_NXDOMAIN = -38,
+    AVAHI_ERR_DNS_NOTIMP = -39,
 
+    AVAHI_ERR_DNS_REFUSED = -40,
+    AVAHI_ERR_DNS_YXDOMAIN = -41,
+    AVAHI_ERR_DNS_YXRRSET = -42,
+    AVAHI_ERR_DNS_NXRRSET = -43,
+    AVAHI_ERR_DNS_NOTAUTH = -44,
+    AVAHI_ERR_DNS_NOTZONE = -45,
+    
     /****
      ****    IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
      ****    IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND
@@ -75,7 +91,7 @@ enum {
      ****    Also remember to update the MAX value below.
      ****/
     
-    AVAHI_ERR_MAX = -34
+    AVAHI_ERR_MAX = -46
 };
 
 /** Return a human readable error string for the specified error code */
index 02c04eebbf2239da7b9e3ec2221610e6272ad04b..fda5b59262f3b88d2e688b1874b96795d63700b8 100644 (file)
@@ -448,11 +448,7 @@ static void service_browser_callback(
             break;
 
         case AVAHI_BROWSER_FAILURE:
-            sdref->service_browser_callback(sdref, 0, interface, kDNSServiceErr_Unknown, NULL, NULL, NULL, sdref->context);
-            break;
-            
-        case AVAHI_BROWSER_NOT_FOUND:
-            sdref->service_browser_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, NULL, NULL, NULL, sdref->context);
+            sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context);
             break;
             
         case AVAHI_BROWSER_CACHE_EXHAUSTED:
@@ -594,13 +590,8 @@ static void service_resolver_callback(
             break;
         }
 
-        case AVAHI_RESOLVER_TIMEOUT:
-        case AVAHI_RESOLVER_NOT_FOUND:
-            sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, NULL, NULL, 0, 0, NULL, sdref->context);
-            break;
-            
         case AVAHI_RESOLVER_FAILURE:
-            sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_Unknown, NULL, NULL, 0, 0, NULL, sdref->context);
+            sdref->service_resolver_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, 0, 0, NULL, sdref->context);
             
     }
 }
@@ -713,11 +704,7 @@ static void domain_browser_callback(
             break;
 
         case AVAHI_BROWSER_FAILURE:
-            sdref->domain_browser_callback(sdref, 0, interface, kDNSServiceErr_Unknown, domain, sdref->context);
-            break;
-            
-        case AVAHI_BROWSER_NOT_FOUND:
-            sdref->domain_browser_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, domain, sdref->context);
+            sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context);
             break;
             
         case AVAHI_BROWSER_CACHE_EXHAUSTED:
index 7ed59919f4af981168f7c6314556de807a96b634..46e68d55710c5ab57846c5bbdfbf0e7080446bba 100644 (file)
@@ -71,7 +71,6 @@ static const char *browser_event_to_string(AvahiBrowserEvent event) {
         case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
         case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
         case AVAHI_BROWSER_FAILURE : return "FAILURE";
-        case AVAHI_BROWSER_NOT_FOUND : return "NOT_FOUND";
     }
 
     abort();
@@ -80,8 +79,6 @@ static const char *browser_event_to_string(AvahiBrowserEvent event) {
 static const char *resolver_event_to_string(AvahiResolverEvent event) {
     switch (event) {
         case AVAHI_RESOLVER_FOUND: return "FOUND";
-        case AVAHI_RESOLVER_TIMEOUT: return "TIMEOUT";
-        case AVAHI_RESOLVER_NOT_FOUND: return "NOT_FOUND";
         case AVAHI_RESOLVER_FAILURE: return "FAILURE";
     }
     abort();
index 52dafc288199e50fbc245f070158e4e211ff1694..2c907c3fef31acf9b44f288216f9e2d24834a98f 100644 (file)
@@ -128,9 +128,7 @@ static void host_name_resolver_callback(
             break;
         }
 
-        case AVAHI_RESOLVER_NOT_FOUND:
         case AVAHI_RESOLVER_FAILURE:
-        case AVAHI_RESOLVER_TIMEOUT:
             /* Ignore */
             break;
     }
@@ -215,7 +213,6 @@ static void record_browser_callback(
         }
 
         case AVAHI_BROWSER_FAILURE:
-        case AVAHI_BROWSER_NOT_FOUND:
         case AVAHI_BROWSER_ALL_FOR_NOW:
         case AVAHI_BROWSER_CACHE_EXHAUSTED:
 
index 5617395cae60037608c3b00d2237f8151640c33c..a133c62bdcc5603b39a2c5814115cbd0c4af0c99 100644 (file)
@@ -222,7 +222,6 @@ static void lookup_wide_area_callback(
             abort();
 
         case AVAHI_BROWSER_ALL_FOR_NOW:
-        case AVAHI_BROWSER_NOT_FOUND:
         case AVAHI_BROWSER_FAILURE:
 
             b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, flags, b->userdata);
@@ -292,7 +291,6 @@ static void lookup_multicast_callback(
             break;
 
         case AVAHI_BROWSER_CACHE_EXHAUSTED:
-        case AVAHI_BROWSER_NOT_FOUND:
         case AVAHI_BROWSER_FAILURE:
             /* Not defined for multicast DNS */
             abort();
@@ -464,6 +462,8 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) {
     if (n < 0) {
         /* sending of the initial query failed */
 
+        avahi_server_set_errno(b->server, AVAHI_ERR_FAILURE);
+
         b->callback(
             b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
             b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
index 254ecbb49054c5e1b42c70a00136ad278eae43cc..41efc2ce2ad9381e04112d348c238d5c52fdbacc 100644 (file)
@@ -49,7 +49,6 @@ static const char *browser_event_to_string(AvahiBrowserEvent event) {
         case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
         case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
         case AVAHI_BROWSER_FAILURE : return "FAILURE";
-        case AVAHI_BROWSER_NOT_FOUND : return "NOT_FOUND";
     }
 
     abort();
index 704dab48bfadd7a3b574b0e1eff9fdd3218b4c00..661982d4989c267e37e3e3ab23272c58647b0536 100644 (file)
@@ -62,8 +62,6 @@ static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
     }
 
     switch (event) {
-        case AVAHI_RESOLVER_NOT_FOUND:
-        case AVAHI_RESOLVER_TIMEOUT:
         case AVAHI_RESOLVER_FAILURE:
             r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
             break;
@@ -81,7 +79,8 @@ static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
     assert(e);
     assert(r);
 
-    finish(r, AVAHI_RESOLVER_TIMEOUT);
+    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+    finish(r, AVAHI_RESOLVER_FAILURE);
 }
 
 static void start_timeout(AvahiSAddressResolver *r) {
@@ -155,7 +154,7 @@ static void record_browser_callback(
         case AVAHI_BROWSER_ALL_FOR_NOW:
             break;
 
-        case AVAHI_BROWSER_NOT_FOUND:
+        case AVAHI_BROWSER_FAILURE:
 
             if (r->retry_with_multicast) {
                 r->retry_with_multicast = 0;
@@ -169,12 +168,9 @@ static void record_browser_callback(
                 }
             }
 
-            /* Fallthrough */
-
-        case AVAHI_BROWSER_FAILURE:
             r->flags = flags;
-            finish(r, event == AVAHI_BROWSER_NOT_FOUND ? AVAHI_RESOLVER_NOT_FOUND : AVAHI_RESOLVER_FAILURE);
-
+            finish(r, AVAHI_RESOLVER_FAILURE);
+            break;
     }
 }
 
index 6315dbb7b38b4cf7c61b5bdf6ef270b1694b9711..a38c0014736657ab58eda8fd18b74245d4589e36 100644 (file)
@@ -89,8 +89,6 @@ static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) {
 
         }
             
-        case AVAHI_RESOLVER_TIMEOUT:
-        case AVAHI_RESOLVER_NOT_FOUND:
         case AVAHI_RESOLVER_FAILURE:
             
             r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
@@ -104,7 +102,8 @@ static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
     assert(e);
     assert(r);
 
-    finish(r, AVAHI_RESOLVER_TIMEOUT);
+    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+    finish(r, AVAHI_RESOLVER_FAILURE);
 }
 
 static void start_timeout(AvahiSHostNameResolver *r) {
@@ -188,7 +187,6 @@ static void record_browser_callback(
             break;
 
         case AVAHI_BROWSER_FAILURE:
-        case AVAHI_BROWSER_NOT_FOUND:
 
             /* Stop browsers */
             
@@ -200,7 +198,7 @@ static void record_browser_callback(
             r->record_browser_a = r->record_browser_aaaa = NULL;
             r->flags = flags;
             
-            finish(r, event == AVAHI_BROWSER_FAILURE ? AVAHI_RESOLVER_FAILURE : AVAHI_RESOLVER_NOT_FOUND);
+            finish(r, AVAHI_RESOLVER_FAILURE);
             break;
     }
 }
index 85ac3d5ffa500cdeb16ecff34c91c53bb3f32fa8..a8975466f1118962e456f725bb742cf91b73ef90 100644 (file)
@@ -81,8 +81,6 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
     
     switch (event) {
         case AVAHI_RESOLVER_FAILURE:
-        case AVAHI_RESOLVER_NOT_FOUND:
-        case AVAHI_RESOLVER_TIMEOUT:
             
             r->callback(
                 r,
@@ -151,9 +149,8 @@ static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
     assert(e);
     assert(r);
 
-    avahi_log_debug("timeout");
-    
-    finish(r, AVAHI_RESOLVER_TIMEOUT);
+    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+    finish(r, AVAHI_RESOLVER_FAILURE);
 }
 
 static void start_timeout(AvahiSServiceResolver *r) {
@@ -346,9 +343,7 @@ static void record_browser_callback(
         case AVAHI_BROWSER_ALL_FOR_NOW:
             break;
 
-        case AVAHI_BROWSER_NOT_FOUND:
         case AVAHI_BROWSER_FAILURE:
-
             
             if (rr == r->record_browser_a && r->record_browser_aaaa) {
                 /* We were looking for both AAAA and A, and the other query is still living, so we'll not die */
@@ -364,7 +359,6 @@ static void record_browser_callback(
                 break;
             }
 
-
             /* Hmm, everything's lost, tell the user */
             
             if (r->record_browser_srv)
@@ -378,7 +372,7 @@ static void record_browser_callback(
 
             r->record_browser_srv = r->record_browser_txt = r->record_browser_a = r->record_browser_aaaa = NULL;
 
-            finish(r, event == AVAHI_BROWSER_FAILURE ? AVAHI_RESOLVER_FAILURE : AVAHI_RESOLVER_NOT_FOUND);
+            finish(r, AVAHI_RESOLVER_FAILURE);
             break;
     }
 }
index 8c8b96212d5589b79cf9b393e43205df16cfd43c..1075084090b8aa8855e7178d0e97b5682e6dfa51 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 
 #include <avahi-common/malloc.h>
+#include <avahi-common/error.h>
 
 #include "server.h"
 #include "browse.h"
@@ -173,6 +174,7 @@ static void sender_timeout_callback(AvahiTimeEvent *e, void *userdata) {
     
     if (l->n_send >= 6) {
         avahi_log_warn(__FILE__": Query timed out.");
+        avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT);
         l->callback(l->engine, AVAHI_BROWSER_FAILURE, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
         avahi_wide_area_lookup_free(l);
         return;
@@ -447,6 +449,31 @@ finish:
         run_callbacks(e, r);
 }
 
+static int map_dns_error(uint16_t error) {
+    static const int table[16] = {
+        AVAHI_OK,
+        AVAHI_ERR_DNS_FORMERR,
+        AVAHI_ERR_DNS_SERVFAIL,
+        AVAHI_ERR_DNS_NXDOMAIN,
+        AVAHI_ERR_DNS_NOTIMP,
+        AVAHI_ERR_DNS_REFUSED,
+        AVAHI_ERR_DNS_YXDOMAIN,
+        AVAHI_ERR_DNS_YXRRSET,
+        AVAHI_ERR_DNS_NXRRSET,
+        AVAHI_ERR_DNS_NOTAUTH,
+        AVAHI_ERR_DNS_NOTZONE,
+        AVAHI_ERR_INVALID_DNS_ERROR,
+        AVAHI_ERR_INVALID_DNS_ERROR,
+        AVAHI_ERR_INVALID_DNS_ERROR,
+        AVAHI_ERR_INVALID_DNS_ERROR,
+        AVAHI_ERR_INVALID_DNS_ERROR
+    };
+
+    assert(error <= 15);
+
+    return table[error];
+}
+
 static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p, AvahiAddress *a) {
     AvahiWideAreaLookup *l = NULL;
     int i, r;
@@ -470,8 +497,9 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p, Avahi
     if ((r = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & 15) != 0 ||
         avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0) {
 
+        avahi_server_set_errno(e->server, r == 0 ? AVAHI_ERR_NOT_FOUND : map_dns_error(r));
         /* Tell the user about the failure */
-        final_event = r == 3 ? AVAHI_BROWSER_NOT_FOUND : AVAHI_BROWSER_FAILURE;
+        final_event = AVAHI_BROWSER_FAILURE;
 
         /* We go on here, since some of the records contained in the
            reply might be interesting in some way */
@@ -483,6 +511,7 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p, Avahi
         
         if (!(k = avahi_dns_packet_consume_key(p, NULL))) {
             avahi_log_warn(__FILE__": Wide area response packet too short.");
+            avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
             final_event = AVAHI_BROWSER_FAILURE;
             goto finish;
         }
@@ -499,6 +528,7 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p, Avahi
 
         if (!(rr = avahi_dns_packet_consume_record(p, NULL))) {
             avahi_log_warn(__FILE__": Wide area response packet too short (2).");
+            avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
             final_event = AVAHI_BROWSER_FAILURE;
             goto finish;
         }
index 61a6e9ce453a690589f5fca3a819d922b9e92b71..273ce8f77504da8048de25df95d479d0b39aaa8f 100644 (file)
       <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>
index 85e7e73eaf2522354af938cba4935ae7f840ba45..daabdb8df8e10ac66ca8b5902b0cc35ea267cced 100644 (file)
@@ -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"/>
 
index d3337f9fbeafd7dccc9ef68dbd287cfcdcc7b6d7..d71ed8afa220a447f3f11cdebe51a838ee2960d2 100644 (file)
       <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>
index 350026d06f234960d7df97c236571195e2038c81..9638eaa9b09ea98c876fc9d590f4b022760a17de 100644 (file)
       <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>
index 7b752e3b8aa594fdece790f16a2e7da0e8bf252f..771f179cb47a0a886b97c32129ad5fb570fa3f67 100644 (file)
       <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>
index 1540a8f36378eec24b2fddf3acf071b05bcc0f3d..04e7db92d9f67656a0da6aacfe48f544c3ddcad0 100644 (file)
@@ -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"/>
 
index 96d011803004b15f3a7a96824aa743140a3ec095..25a9e8ebb96321e77f636788205cd7c36c49441e 100644 (file)
@@ -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);  
index 0c9989a20ad89b94ecb2a4e8e64fbe34f5b9aa4b..d53987d610fa4d99acecf86aa87520cf1f0a7799 100644 (file)
@@ -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;
 
index c6e9cc47e1a43bec4c919fac9c9e630f5c68ee88..296b56db59405c460494cf3b33ccdad911939e31 100644 (file)
 
 #include <gtk/gtk.h>
 #include <glade/glade.h>
+
 #include <avahi-core/core.h>
 #include <avahi-core/lookup.h>
+
 #include <avahi-common/strlst.h>
 #include <avahi-common/domain.h>
+#include <avahi-common/error.h>
+
 #include <avahi-glib/glib-watch.h>
 #include <avahi-glib/glib-malloc.h>
 
@@ -312,13 +316,11 @@ static void service_resolver_callback(
         return;
     }
 
-    if (event == AVAHI_RESOLVER_TIMEOUT)
-        gtk_label_set_markup(info_label, "<i>Failed to resolve: Timeout.</i>");
-    else if (event == AVAHI_RESOLVER_FAILURE)
-        gtk_label_set_markup(info_label, "<i>Failed to resolve: Failure.</i>");
-    else if (event == AVAHI_RESOLVER_NOT_FOUND)
-        gtk_label_set_markup(info_label, "<i>Failed to resolve: Not found.</i>");
-    else if (event == AVAHI_RESOLVER_FOUND)
+    if (event == AVAHI_RESOLVER_FAILURE) {
+        char t[256];
+        snprintf(t, sizeof(t), "<i>Failed to resolve: %s.</i>", avahi_strerror(avahi_server_errno(server)));
+        gtk_label_set_markup(info_label, t);
+    } else if (event == AVAHI_RESOLVER_FOUND)
         update_label(s, host_name, a, port, txt);
 }
 
index ac65ac42c1221efb6137f91af638b0a5fce84bfc..7a6940b2cdbe6c40dfa0d4488f8e582cab8c734b 100644 (file)
@@ -55,11 +55,8 @@ static void resolve_callback(
     /* Called whenever a service has been resolved successfully or timed out */
 
     switch (event) {
-        case AVAHI_RESOLVER_TIMEOUT:
-        case AVAHI_RESOLVER_NOT_FOUND:
         case AVAHI_RESOLVER_FAILURE:
-            fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain,
-                    event == AVAHI_RESOLVER_TIMEOUT ? "TIMEOUT" : (event == AVAHI_RESOLVER_NOT_FOUND ? "NOT_FOUND" : "FAILURE"));
+            fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
             break;
 
         case AVAHI_RESOLVER_FOUND: {
@@ -110,9 +107,8 @@ static void browse_callback(
 
     switch (event) {
         case AVAHI_BROWSER_FAILURE:
-        case AVAHI_BROWSER_NOT_FOUND:
             
-            fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_FAILURE ? "FAILURE" : "NOT_FOUND");
+            fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
             avahi_simple_poll_quit(simple_poll);
             return;
 
index d2a5e98b2bdf29e4f829ccca1e00a1259820c290..5de47b3ae2e4399ed4849b6295b9018a42d55611 100644 (file)
@@ -68,17 +68,14 @@ static void resolve_callback(
     /* Called whenever a service has been resolved successfully or timed out */
 
     switch (event) {
-        case AVAHI_RESOLVER_TIMEOUT:
-        case AVAHI_RESOLVER_NOT_FOUND:
         case AVAHI_RESOLVER_FAILURE:
-            fprintf(stderr, "Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain,
-                    event == AVAHI_RESOLVER_TIMEOUT ? "TIMEOUT" : (event == AVAHI_RESOLVER_NOT_FOUND ? "NOT_FOUND" : "FAILURE"));
+            fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_server_errno(server)));
             break;
 
         case AVAHI_RESOLVER_FOUND: {
             char a[128], *t;
             
-            fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
+            fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
             
             avahi_address_snprint(a, sizeof(a), address);
             t = avahi_string_list_to_string(txt);
@@ -123,9 +120,8 @@ static void browse_callback(
     switch (event) {
 
         case AVAHI_BROWSER_FAILURE:
-        case AVAHI_BROWSER_NOT_FOUND:
             
-            fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_FAILURE ? "FAILURE" : "NOT_FOUND");
+            fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_server_errno(server)));
             avahi_simple_poll_quit(simple_poll);
             return;