]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/simple-protocol.c
first pass at updating to the 0.6 apis
[catta] / avahi-daemon / simple-protocol.c
index 0c9989a20ad89b94ecb2a4e8e64fbe34f5b9aa4b..6c6f125974b32d79bbb1233e515503776bf47ccb 100644 (file)
 #include <avahi-common/llist.h>
 #include <avahi-common/malloc.h>
 #include <avahi-common/error.h>
+
 #include <avahi-core/log.h>
 #include <avahi-core/lookup.h>
+#include <avahi-core/dns-srv-rr.h>
 
 #include "simple-protocol.h"
 #include "main.h"
@@ -178,14 +180,10 @@ 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];
+        char t[AVAHI_ADDRESS_STR_MAX];
         avahi_address_snprint(t, sizeof(t), a);
         client_output_printf(c, "+ %i %u %s %s\n", iface, protocol, hostname, t);
     }
@@ -207,12 +205,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);
 
@@ -231,7 +225,7 @@ static void dns_server_browser_callback(
     void* userdata) {
     
     Client *c = userdata;
-    char t[64];
+    char t[AVAHI_ADDRESS_STR_MAX];
     
     assert(c);
 
@@ -240,12 +234,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;
 
@@ -294,19 +283,19 @@ static void handle_line(Client *c, const char *s) {
         c->state = CLIENT_DEAD;
     } else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV4") == 0 && n_args == 2) {
         c->state = CLIENT_RESOLVE_HOSTNAME;
-        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET, 0, host_name_resolver_callback, c)))
+        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c)))
             goto fail;
 
         avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
     } else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV6") == 0 && n_args == 2) {
         c->state = CLIENT_RESOLVE_HOSTNAME;
-        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET6, 0, host_name_resolver_callback, c)))
+        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET6, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c)))
             goto fail;
 
         avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
     } else if (strcmp(cmd, "RESOLVE-HOSTNAME") == 0 && n_args == 2) {
         c->state = CLIENT_RESOLVE_HOSTNAME;
-        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_UNSPEC, 0, host_name_resolver_callback, c)))
+        if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c)))
             goto fail;
 
         avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
@@ -318,7 +307,7 @@ static void handle_line(Client *c, const char *s) {
             c->state = CLIENT_DEAD;
         } else {
             c->state = CLIENT_RESOLVE_ADDRESS;
-            if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, &addr, 0, address_resolver_callback, c)))
+            if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, &addr, AVAHI_LOOKUP_USE_MULTICAST, address_resolver_callback, c)))
                 goto fail;
         }
 
@@ -326,7 +315,7 @@ static void handle_line(Client *c, const char *s) {
 
     } else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV4") == 0 && n_args == 1) {
         c->state = CLIENT_BROWSE_DNS_SERVERS;
-        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET, 0, dns_server_browser_callback, c)))
+        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c)))
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
@@ -334,7 +323,7 @@ static void handle_line(Client *c, const char *s) {
 
     } else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV6") == 0 && n_args == 1) {
         c->state = CLIENT_BROWSE_DNS_SERVERS;
-        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET6, 0, dns_server_browser_callback, c)))
+        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET6, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c)))
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
@@ -342,7 +331,7 @@ static void handle_line(Client *c, const char *s) {
 
     } else if (strcmp(cmd, "BROWSE-DNS-SERVERS") == 0 && n_args == 1) {
         c->state = CLIENT_BROWSE_DNS_SERVERS;
-        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_UNSPEC, 0, dns_server_browser_callback, c)))
+        if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c)))
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
@@ -534,7 +523,7 @@ void simple_protocol_restart_queries(void) {
     for (c = server->clients; c; c = c->clients_next)
         if (c->state == CLIENT_BROWSE_DNS_SERVERS && c->dns_server_browser) {
             avahi_s_dns_server_browser_free(c->dns_server_browser);
-            c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, 0, dns_server_browser_callback, c);
+            c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c);
         }
 }