From: Lennart Poettering Date: Sun, 25 Sep 2005 20:14:02 +0000 (+0000) Subject: * adapt to recent avahi-core API changes X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=2c453196ee040e17e357f3431b0647391c88d616;p=catta * adapt to recent avahi-core API changes * make use of wide area DNS git-svn-id: file:///home/lennart/svn/public/avahi/trunk@609 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-daemon/AddressResolver.introspect b/avahi-daemon/AddressResolver.introspect index a1bd190..5d6afa7 100644 --- a/avahi-daemon/AddressResolver.introspect +++ b/avahi-daemon/AddressResolver.introspect @@ -21,9 +21,14 @@ + + + + + diff --git a/avahi-daemon/DomainBrowser.introspect b/avahi-daemon/DomainBrowser.introspect index 68e0884..3da9e00 100644 --- a/avahi-daemon/DomainBrowser.introspect +++ b/avahi-daemon/DomainBrowser.introspect @@ -19,14 +19,24 @@ + + + + + + + + + + diff --git a/avahi-daemon/HostNameResolver.introspect b/avahi-daemon/HostNameResolver.introspect index cd0af01..2484100 100644 --- a/avahi-daemon/HostNameResolver.introspect +++ b/avahi-daemon/HostNameResolver.introspect @@ -21,9 +21,14 @@ + + + + + diff --git a/avahi-daemon/Server.introspect b/avahi-daemon/Server.introspect index bf68bcb..cb4616c 100644 --- a/avahi-daemon/Server.introspect +++ b/avahi-daemon/Server.introspect @@ -61,24 +61,28 @@ + + + + @@ -88,6 +92,7 @@ + @@ -99,6 +104,7 @@ + @@ -120,6 +126,7 @@ + @@ -128,6 +135,7 @@ + @@ -137,6 +145,7 @@ + @@ -148,6 +157,7 @@ + @@ -157,6 +167,7 @@ + @@ -165,10 +176,9 @@ + - - diff --git a/avahi-daemon/ServiceBrowser.introspect b/avahi-daemon/ServiceBrowser.introspect index ddc66b3..abb065d 100644 --- a/avahi-daemon/ServiceBrowser.introspect +++ b/avahi-daemon/ServiceBrowser.introspect @@ -21,6 +21,7 @@ + @@ -29,7 +30,17 @@ + + + + + + + + + + diff --git a/avahi-daemon/ServiceResolver.introspect b/avahi-daemon/ServiceResolver.introspect index 2dc9815..8d00983 100644 --- a/avahi-daemon/ServiceResolver.introspect +++ b/avahi-daemon/ServiceResolver.introspect @@ -26,9 +26,14 @@ + + + + + diff --git a/avahi-daemon/ServiceTypeBrowser.introspect b/avahi-daemon/ServiceTypeBrowser.introspect index 12b40e4..7e080d6 100644 --- a/avahi-daemon/ServiceTypeBrowser.introspect +++ b/avahi-daemon/ServiceTypeBrowser.introspect @@ -20,6 +20,7 @@ + @@ -27,7 +28,16 @@ + + + + + + + + + diff --git a/avahi-daemon/avahi-daemon.conf b/avahi-daemon/avahi-daemon.conf index 6d88214..4761baa 100644 --- a/avahi-daemon/avahi-daemon.conf +++ b/avahi-daemon/avahi-daemon.conf @@ -8,6 +8,9 @@ use-iff-running=no enable-dbus=yes add-service-cookie=yes +[wide-area] +enable-wide-area=yes + [publish] publish-addresses=yes publish-hinfo=yes diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index d817038..7513dc6 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -43,8 +44,11 @@ #include #include #include + #include #include +#include +#include #include "dbus-protocol.h" #include "main.h" @@ -66,7 +70,7 @@ typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo; #define MAX_OBJECTS_PER_CLIENT 50 #define MAX_ENTRIES_PER_ENTRY_GROUP 20 -/* #define VALGRIND_WORKAROUND */ +/* #define VALGRIND_WORKAROUND 1 */ struct EntryGroupInfo { unsigned id; @@ -422,10 +426,15 @@ static DBusHandlerResult respond_error(DBusConnection *c, DBusMessage *m, int er assert(-error > -AVAHI_OK); assert(-error < -AVAHI_ERR_MAX); + + if (!text) + text = avahi_strerror(error); - reply = dbus_message_new_error(m, avahi_error_number_to_dbus (error), text ? text : avahi_strerror(error)); + reply = dbus_message_new_error(m, avahi_error_number_to_dbus (error), text); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); + + avahi_log_debug(__FILE__": Responding error '%s' (%i)", text, error); return DBUS_HANDLER_RESULT_HANDLED; } @@ -546,6 +555,42 @@ fail: } +static const char *map_browse_signal_name(AvahiBrowserEvent e) { + switch (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"; + } + + abort(); +} + +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; DBusError error; @@ -860,7 +905,7 @@ fail: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, void* userdata) { +static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) { SyncHostNameResolverInfo *i = userdata; assert(r); @@ -869,7 +914,7 @@ static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfI if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; DBusMessage *reply; assert(a); @@ -878,6 +923,7 @@ static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfI i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; + i_flags = (int32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -887,20 +933,18 @@ static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfI DBUS_TYPE_STRING, &host_name, DBUS_TYPE_INT32, &i_aprotocol, DBUS_TYPE_STRING, &pt, + DBUS_TYPE_INT32, &i_flags, DBUS_TYPE_INVALID); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - respond_error(server->bus, i->message, AVAHI_ERR_TIMEOUT, NULL); - } + } else + respond_error(server->bus, i->message, map_resolve_error(event), NULL); sync_host_name_resolver_free(i); } -static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, void* userdata) { +static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) { SyncAddressResolverInfo *i = userdata; assert(r); @@ -909,7 +953,7 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; DBusMessage *reply; assert(host_name); @@ -918,6 +962,7 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) address->proto; + i_flags = (int32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -927,14 +972,13 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde DBUS_TYPE_INT32, &i_aprotocol, DBUS_TYPE_STRING, &pt, DBUS_TYPE_STRING, &host_name, + DBUS_TYPE_INT32, &i_flags, DBUS_TYPE_INVALID); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - respond_error(server->bus, i->message, AVAHI_ERR_TIMEOUT, NULL); - } + } else + respond_error(server->bus, i->message, map_resolve_error(event), NULL); sync_address_resolver_free(i); } @@ -983,25 +1027,31 @@ fail: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void* userdata) { +static void domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void* userdata) { DomainBrowserInfo *i = userdata; DBusMessage *m; - int32_t i_interface, i_protocol; + int32_t i_interface, i_protocol, i_flags; assert(b); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + i_flags = (int32_t) flags; + + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, map_browse_signal_name(event)); - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, event == AVAHI_BROWSER_NEW ? "ItemNew" : "ItemRemove"); - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INVALID); + if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { + assert(domain); + dbus_message_append_args( + m, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &i_flags, + DBUS_TYPE_INVALID); + } + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); @@ -1051,27 +1101,33 @@ fail: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void* userdata) { +static void service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata) { ServiceTypeBrowserInfo *i = userdata; DBusMessage *m; - int32_t i_interface, i_protocol; + int32_t i_interface, i_protocol, i_flags; assert(b); - assert(type); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + i_flags = (int32_t) flags; + + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, map_browse_signal_name(event)); - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, event == AVAHI_BROWSER_NEW ? "ItemNew" : "ItemRemove"); - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INVALID); + if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { + assert(type); + assert(domain); + dbus_message_append_args( + m, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &i_flags, + DBUS_TYPE_INVALID); + } + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); @@ -1121,29 +1177,36 @@ fail: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void* userdata) { +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; - int32_t i_interface, i_protocol; + int32_t i_interface, i_protocol, i_flags; assert(b); - assert(name); - assert(type); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + i_flags = (int32_t) flags; + + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, map_browse_signal_name(event)); - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, event == AVAHI_BROWSER_NEW ? "ItemNew" : "ItemRemove"); - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INVALID); + if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { + assert(name); + assert(type); + assert(domain); + + dbus_message_append_args( + m, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &i_flags, + DBUS_TYPE_INVALID); + } + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); @@ -1182,6 +1245,7 @@ static void sync_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, + AvahiLookupResultFlags flags, void* userdata) { SyncServiceResolverInfo *i = userdata; @@ -1191,10 +1255,13 @@ static void sync_service_resolver_callback( if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; DBusMessage *reply; assert(host_name); + + if (!name) + name = ""; assert(a); avahi_address_snprint(t, sizeof(t), a); @@ -1202,6 +1269,7 @@ static void sync_service_resolver_callback( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; + i_flags = (int32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -1219,37 +1287,41 @@ static void sync_service_resolver_callback( append_string_list(reply, txt); + dbus_message_append_args( + reply, + DBUS_TYPE_INT32, &i_flags, + DBUS_TYPE_INVALID); + dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - respond_error(server->bus, i->message, AVAHI_ERR_TIMEOUT, NULL); - } + } else + respond_error(server->bus, i->message, map_resolve_error(event), NULL); sync_service_resolver_free(i); } -static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, void* userdata) { +static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) { AsyncAddressResolverInfo *i = userdata; DBusMessage *reply; assert(r); - assert(address); assert(i); + reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_browse_signal_name(event)); + if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; + assert(address); assert(host_name); avahi_address_snprint(t, sizeof(t), address); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) address->proto; + i_flags = (int32_t) flags; - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"); dbus_message_append_args( reply, DBUS_TYPE_INT32, &i_interface, @@ -1257,12 +1329,9 @@ static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInd DBUS_TYPE_INT32, &i_aprotocol, DBUS_TYPE_STRING, &pt, DBUS_TYPE_STRING, &host_name, + DBUS_TYPE_INT32, &i_flags, DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Timeout"); } dbus_message_set_destination(reply, i->client->name); @@ -1314,26 +1383,28 @@ fail: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, void* userdata) { +static void async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) { AsyncHostNameResolverInfo *i = userdata; DBusMessage *reply; assert(r); - assert(host_name); assert(i); + reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, map_resolve_signal_name(event)); + if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; assert(a); + assert(host_name); avahi_address_snprint(t, sizeof(t), a); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; + i_flags = (int32_t) flags; - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"); dbus_message_append_args( reply, DBUS_TYPE_INT32, &i_interface, @@ -1341,11 +1412,8 @@ static void async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIf DBUS_TYPE_STRING, &host_name, DBUS_TYPE_INT32, &i_aprotocol, DBUS_TYPE_STRING, &pt, + DBUS_TYPE_INT32, &i_flags, DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Timeout"); } dbus_message_set_destination(reply, i->client->name); @@ -1408,6 +1476,7 @@ static void async_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, + AvahiLookupResultFlags flags, void* userdata) { AsyncServiceResolverInfo *i = userdata; @@ -1416,9 +1485,11 @@ static void async_service_resolver_callback( assert(r); assert(i); + reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, map_resolve_signal_name(event)); + if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; + int32_t i_interface, i_protocol, i_aprotocol, i_flags; assert(host_name); @@ -1427,11 +1498,14 @@ static void async_service_resolver_callback( assert(a); avahi_address_snprint(t, sizeof(t), a); + if (!name) + name = ""; + i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; + i_flags = (int32_t) flags; - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"); dbus_message_append_args( reply, DBUS_TYPE_INT32, &i_interface, @@ -1446,13 +1520,11 @@ static void async_service_resolver_callback( DBUS_TYPE_INVALID); append_string_list(reply, txt); - - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); -/* avahi_log_debug(__FILE__": [%s] Failed to resolve service <%s.%s.%s>", i->path, name, type, domain); */ - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Timeout"); + dbus_message_append_args( + reply, + DBUS_TYPE_INT32, &i_flags, + DBUS_TYPE_INVALID); } dbus_message_set_destination(reply, i->client->name); @@ -1738,7 +1810,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveHostName")) { Client *client; - int32_t interface, protocol, aprotocol; + int32_t interface, protocol, aprotocol, flags; char *name; SyncHostNameResolverInfo *i; @@ -1748,6 +1820,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &name, DBUS_TYPE_INT32, &aprotocol, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || !name) { avahi_log_warn("Error parsing Server::ResolveHostName message"); goto fail; @@ -1769,7 +1842,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(SyncHostNameResolverInfo, sync_host_name_resolvers, client->sync_host_name_resolvers, i); client->n_objects++; - if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, (AvahiProtocol) aprotocol, sync_host_name_resolver_callback, i))) { + if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, sync_host_name_resolver_callback, i))) { sync_host_name_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -1778,7 +1851,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveAddress")) { Client *client; - int32_t interface, protocol; + int32_t interface, protocol, flags; char *address; SyncAddressResolverInfo *i; AvahiAddress a; @@ -1788,6 +1861,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &address, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || !address) { avahi_log_warn("Error parsing Server::ResolveAddress message"); goto fail; @@ -1812,7 +1886,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(SyncAddressResolverInfo, sync_address_resolvers, client->sync_address_resolvers, i); client->n_objects++; - if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, sync_address_resolver_callback, i))) { + if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, (AvahiLookupFlags) flags, sync_address_resolver_callback, i))) { sync_address_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -1830,7 +1904,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL, NULL }; - int32_t interface, protocol, type; + int32_t interface, protocol, type, flags; char *domain; if (!dbus_message_get_args( @@ -1839,6 +1913,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &domain, DBUS_TYPE_INT32, &type, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || type < 0 || type >= AVAHI_DOMAIN_BROWSER_MAX) { avahi_log_warn("Error parsing Server::DomainBrowserNew message"); goto fail; @@ -1864,7 +1939,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(DomainBrowserInfo, domain_browsers, client->domain_browsers, i); client->n_objects++; - if (!(i->domain_browser = avahi_s_domain_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiDomainBrowserType) type, domain_browser_callback, i))) { + if (!(i->domain_browser = avahi_s_domain_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiDomainBrowserType) type, (AvahiLookupFlags) flags, domain_browser_callback, i))) { domain_browser_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -1883,7 +1958,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL, NULL }; - int32_t interface, protocol; + int32_t interface, protocol, flags; char *domain; if (!dbus_message_get_args( @@ -1891,6 +1966,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::ServiceTypeBrowserNew message"); goto fail; @@ -1917,7 +1993,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(ServiceTypeBrowserInfo, service_type_browsers, client->service_type_browsers, i); client->n_objects++; - if (!(i->service_type_browser = avahi_s_service_type_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, service_type_browser_callback, i))) { + if (!(i->service_type_browser = avahi_s_service_type_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiLookupFlags) flags, service_type_browser_callback, i))) { service_type_browser_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -1936,7 +2012,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL, NULL }; - int32_t interface, protocol; + int32_t interface, protocol, flags; char *domain, *type; if (!dbus_message_get_args( @@ -1945,6 +2021,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ServiceBrowserNew message"); goto fail; @@ -1971,7 +2048,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(ServiceBrowserInfo, service_browsers, client->service_browsers, i); client->n_objects++; - if (!(i->service_browser = avahi_s_service_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, type, domain, service_browser_callback, i))) { + if (!(i->service_browser = avahi_s_service_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, type, domain, (AvahiLookupFlags) flags, service_browser_callback, i))) { service_browser_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -1981,7 +2058,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveService")) { Client *client; - int32_t interface, protocol, aprotocol; + int32_t interface, protocol, aprotocol, flags; char *name, *type, *domain; SyncServiceResolverInfo *i; @@ -1993,7 +2070,8 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_INVALID) || !name || !type) { + DBUS_TYPE_INT32, &flags, + DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ResolveService message"); goto fail; } @@ -2010,6 +2088,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void if (!*domain) domain = NULL; + + if (!*name) + name = NULL; i = avahi_new(SyncServiceResolverInfo, 1); i->client = client; @@ -2017,7 +2098,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(SyncServiceResolverInfo, sync_service_resolvers, client->sync_service_resolvers, i); client->n_objects++; - if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, sync_service_resolver_callback, i))) { + if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, sync_service_resolver_callback, i))) { sync_service_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -2026,7 +2107,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew")) { Client *client; - int32_t interface, protocol, aprotocol; + int32_t interface, protocol, aprotocol, flags; char *name, *type, *domain; AsyncServiceResolverInfo *i; static const DBusObjectPathVTable vtable = { @@ -2046,7 +2127,8 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_INVALID) || !name || !type) { + DBUS_TYPE_INT32, &flags, + DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ServiceResolverNew message"); goto fail; } @@ -2061,6 +2143,12 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); } + if (!*domain) + domain = NULL; + + if (!*name) + name = NULL; + i = avahi_new(AsyncServiceResolverInfo, 1); i->id = ++client->current_id; i->client = client; @@ -2068,7 +2156,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(AsyncServiceResolverInfo, async_service_resolvers, client->async_service_resolvers, i); client->n_objects++; - if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, async_service_resolver_callback, i))) { + if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, async_service_resolver_callback, i))) { async_service_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -2080,7 +2168,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "HostNameResolverNew")) { Client *client; - int32_t interface, protocol, aprotocol; + int32_t interface, protocol, aprotocol, flags; char *name; AsyncHostNameResolverInfo *i; static const DBusObjectPathVTable vtable = { @@ -2098,6 +2186,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &name, DBUS_TYPE_INT32, &aprotocol, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || !name) { avahi_log_warn("Error parsing Server::HostNameResolverNew message"); goto fail; @@ -2120,7 +2209,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(AsyncHostNameResolverInfo, async_host_name_resolvers, client->async_host_name_resolvers, i); client->n_objects++; - if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, aprotocol, async_host_name_resolver_callback, i))) { + if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, aprotocol, (AvahiLookupFlags) flags, async_host_name_resolver_callback, i))) { async_host_name_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } @@ -2130,7 +2219,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew")) { Client *client; - int32_t interface, protocol; + int32_t interface, protocol, flags; char *address; AsyncAddressResolverInfo *i; AvahiAddress a; @@ -2148,6 +2237,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &address, + DBUS_TYPE_INT32, &flags, DBUS_TYPE_INVALID) || !address) { avahi_log_warn("Error parsing Server::AddressResolverNew message"); goto fail; @@ -2173,7 +2263,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void AVAHI_LLIST_PREPEND(AsyncAddressResolverInfo, async_address_resolvers, client->async_address_resolvers, i); client->n_objects++; - if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, async_address_resolver_callback, i))) { + if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, (AvahiLookupFlags) flags, async_address_resolver_callback, i))) { async_address_resolver_free(i); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); } diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 7f5d148..5320b68 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "main.h" @@ -104,8 +105,6 @@ static char **resolv_conf = NULL; static DaemonConfig config; -#define MAX_NAME_SERVERS 10 - static int has_prefix(const char *s, const char *prefix) { size_t l; @@ -122,17 +121,14 @@ static int load_resolv_conf(const DaemonConfig *c) { avahi_strfreev(resolv_conf); resolv_conf = NULL; - if (!c->publish_resolv_conf) - return 0; - if (!(f = fopen(RESOLV_CONF, "r"))) { avahi_log_warn("Failed to open "RESOLV_CONF"."); goto finish; } - resolv_conf = avahi_new0(char*, MAX_NAME_SERVERS+1); + resolv_conf = avahi_new0(char*, AVAHI_MAX_WIDE_AREA_SERVERS+1); - while (!feof(f) && i < MAX_NAME_SERVERS) { + while (!feof(f) && i < AVAHI_MAX_WIDE_AREA_SERVERS) { char ln[128]; char *p; @@ -179,10 +175,10 @@ static AvahiSEntryGroup* add_dns_servers(AvahiServer *s, AvahiSEntryGroup* g, ch for (p = l; *p; p++) { AvahiAddress a; - if (!avahi_address_parse(*p, AF_UNSPEC, &a)) + if (!avahi_address_parse(*p, AVAHI_PROTO_UNSPEC, &a)) avahi_log_warn("Failed to parse address '%s', ignoring.", *p); else - if (avahi_server_add_dns_server_address(s, g, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, &a, 53) < 0) { + if (avahi_server_add_dns_server_address(s, g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, &a, 53) < 0) { avahi_s_entry_group_free(g); avahi_log_error("Failed to add DNS server address: %s", avahi_strerror(avahi_server_errno(s))); return NULL; @@ -203,6 +199,22 @@ static void remove_dns_server_entry_groups(void) { avahi_s_entry_group_reset(dns_servers_entry_group); } +static void update_wide_area_servers(void) { + AvahiAddress a[AVAHI_MAX_WIDE_AREA_SERVERS]; + unsigned n = 0; + char **p; + + for (p = resolv_conf; *p && n < AVAHI_MAX_WIDE_AREA_SERVERS; p++) { + if (!avahi_address_parse(*p, AVAHI_PROTO_UNSPEC, &a[n])) + avahi_log_warn("Failed to parse address '%s', ignoring.", *p); + else + n++; + } + + avahi_server_set_wide_area_servers(avahi_server, a, n); + +} + static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) { DaemonConfig *c = userdata; @@ -225,7 +237,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, void *userda remove_dns_server_entry_groups(); - if (resolv_conf && resolv_conf[0]) + if (c->publish_resolv_conf && resolv_conf && resolv_conf[0]) resolv_conf_entry_group = add_dns_servers(s, resolv_conf_entry_group, resolv_conf); if (c->publish_dns_servers && c->publish_dns_servers[0]) @@ -426,6 +438,19 @@ static int load_config_file(DaemonConfig *c) { } } + } else if (strcasecmp(g->name, "wide-area") == 0) { + AvahiIniFilePair *p; + + for (p = g->pairs; p; p = p->pairs_next) { + + if (strcasecmp(p->key, "enable-wide-area") == 0) + c->server_config.enable_wide_area = is_yes(p->value); + else { + avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); + goto finish; + } + } + } else if (strcasecmp(g->name, "reflector") == 0) { AvahiIniFilePair *p; @@ -551,8 +576,10 @@ static void signal_callback(AvahiWatch *watch, int fd, AvahiWatchEvent event, vo avahi_s_entry_group_reset(resolv_conf_entry_group); load_resolv_conf(&config); + + update_wide_area_servers(); - if (resolv_conf && resolv_conf[0]) + if (config.publish_resolv_conf && resolv_conf && resolv_conf[0]) resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf); break; @@ -620,6 +647,7 @@ static int run_server(DaemonConfig *c) { goto finish; } + update_wide_area_servers(); if (c->daemonize) daemon_retval_send(0); diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c index fe3888a..26d67ea 100644 --- a/avahi-daemon/simple-protocol.c +++ b/avahi-daemon/simple-protocol.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "simple-protocol.h" #include "main.h" @@ -171,6 +172,7 @@ static void host_name_resolver_callback( AvahiResolverEvent event, const char *hostname, const AvahiAddress *a, + AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; @@ -179,7 +181,11 @@ static void host_name_resolver_callback( if (event == AVAHI_RESOLVER_TIMEOUT) client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_TIMEOUT); - else { + 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); + else if (event == AVAHI_RESOLVER_FOUND) { char t[64]; avahi_address_snprint(t, sizeof(t), a); client_output_printf(c, "+ %i %u %s %s\n", iface, protocol, hostname, t); @@ -195,6 +201,7 @@ static void address_resolver_callback( AvahiResolverEvent event, const AvahiAddress *a, const char *hostname, + AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; @@ -203,7 +210,11 @@ static void address_resolver_callback( if (event == AVAHI_RESOLVER_TIMEOUT) client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_TIMEOUT); - else + 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); + else if (event == AVAHI_RESOLVER_FOUND) client_output_printf(c, "+ %i %u %s\n", iface, protocol, hostname); c->state = CLIENT_DEAD; @@ -217,6 +228,7 @@ static void dns_server_browser_callback( const char *host_name, const AvahiAddress *a, uint16_t port, + AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; @@ -227,8 +239,28 @@ static void dns_server_browser_callback( if (!a) return; - avahi_address_snprint(t, sizeof(t), a); - client_output_printf(c, "%c %i %u %s %u\n", event == AVAHI_BROWSER_NEW ? '>' : '<', interface, protocol, t, port); + 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); + c->state = CLIENT_DEAD; + break; + + case AVAHI_BROWSER_ALL_FOR_NOW: + case AVAHI_BROWSER_CACHE_EXHAUSTED: + break; + + case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_REMOVE: + + avahi_address_snprint(t, sizeof(t), a); + client_output_printf(c, "%c %i %u %s %u\n", event == AVAHI_BROWSER_NEW ? '>' : '<', interface, protocol, t, port); + break; + } } static void handle_line(Client *c, const char *s) { @@ -263,31 +295,31 @@ 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, -1, AF_UNSPEC, arg, c->afquery = AF_INET, 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, 0, 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, -1, AF_UNSPEC, arg, c->afquery = AF_INET6, 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, 0, 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, -1, AF_UNSPEC, arg, c->afquery = AF_UNSPEC, 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, 0, host_name_resolver_callback, c))) goto fail; avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg); } else if (strcmp(cmd, "RESOLVE-ADDRESS") == 0 && n_args == 2) { AvahiAddress addr; - if (!(avahi_address_parse(arg, AF_UNSPEC, &addr))) { + if (!(avahi_address_parse(arg, AVAHI_PROTO_UNSPEC, &addr))) { client_output_printf(c, "%+i Failed to parse address \"%s\".\n", AVAHI_ERR_INVALID_ADDRESS, arg); c->state = CLIENT_DEAD; } else { c->state = CLIENT_RESOLVE_ADDRESS; - if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, -1, AF_UNSPEC, &addr, address_resolver_callback, c))) + if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, &addr, 0, address_resolver_callback, c))) goto fail; } @@ -295,7 +327,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, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET, 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, 0, dns_server_browser_callback, c))) goto fail; client_output_printf(c, "+ Browsing ...\n"); @@ -303,7 +335,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, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET6, 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, 0, dns_server_browser_callback, c))) goto fail; client_output_printf(c, "+ Browsing ...\n"); @@ -311,7 +343,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, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_UNSPEC, 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, 0, dns_server_browser_callback, c))) goto fail; client_output_printf(c, "+ Browsing ...\n"); @@ -503,7 +535,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, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, 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, 0, dns_server_browser_callback, c); } } diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c index a1ec8d0..e459bbc 100644 --- a/avahi-daemon/static-services.c +++ b/avahi-daemon/static-services.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "main.h" #include "static-services.h"