X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fdbus-protocol.c;h=ce2152179525729973add5aa6de334cc01f6065a;hb=fee238b3a20c8fbb34af6b08995df2265131bee6;hp=b7965a3da7c124acb910160d8beeb8fd728ec27f;hpb=37baeac93cdde3a5c38092d30df6a574c7e30b75;p=catta diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index b7965a3..ce21521 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; } @@ -452,6 +461,28 @@ static DBusHandlerResult respond_int32(DBusConnection *c, DBusMessage *m, int32_ return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult respond_uint32(DBusConnection *c, DBusMessage *m, uint32_t u) { + DBusMessage *reply; + + reply = dbus_message_new_method_return(m); + dbus_message_append_args(reply, DBUS_TYPE_UINT32, &u, DBUS_TYPE_INVALID); + dbus_connection_send(c, reply, NULL); + dbus_message_unref(reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult respond_boolean(DBusConnection *c, DBusMessage *m, int b) { + DBusMessage *reply; + + reply = dbus_message_new_method_return(m); + dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID); + dbus_connection_send(c, reply, NULL); + dbus_message_unref(reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + static DBusHandlerResult respond_ok(DBusConnection *c, DBusMessage *m) { DBusMessage *reply; @@ -473,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; @@ -524,6 +566,28 @@ 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_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_FAILURE : return "Failure"; + } + + abort(); +} + + static DBusHandlerResult handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname) { char *path, *contents; DBusError error; @@ -566,7 +630,7 @@ static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage * dbus_error_init(&error); -/* avahi_log_debug("dbus: interface=%s, path=%s, member=%s", */ +/* avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", */ /* dbus_message_get_interface(m), */ /* dbus_message_get_path(m), */ /* dbus_message_get_member(m)); */ @@ -574,7 +638,7 @@ static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage * if (dbus_message_is_signal(m, DBUS_INTERFACE_LOCAL, "Disconnected")) { /* No, we shouldn't quit, but until we get somewhere * usefull such that we can restore our state, we will */ - avahi_log_warn("Disconnnected from d-bus, terminating..."); + avahi_log_warn("Disconnnected from D-BUS, terminating..."); raise(SIGQUIT); /* The signal handler will catch this and terminate the process cleanly*/ @@ -588,7 +652,7 @@ static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage * goto fail; } -/* avahi_log_info("dbus: name acquired (%s)", name); */ +/* avahi_log_info(__FILE__": name acquired (%s)", name); */ return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { @@ -603,7 +667,7 @@ static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage * Client *client; if ((client = client_get(name, FALSE))) { -/* avahi_log_info("dbus: client %s vanished", name); */ + avahi_log_debug(__FILE__": client %s vanished.", name); client_free(client); } } @@ -643,7 +707,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -685,6 +749,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, } avahi_s_entry_group_reset(i->entry_group); + i->n_entries = 0; return respond_ok(c, m); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) { @@ -718,6 +783,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) { int32_t interface, protocol; + uint32_t flags; char *type, *name, *domain, *host; uint16_t port; AvahiStringList *strlst; @@ -728,6 +794,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, m, &error, DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_UINT32, &flags, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, @@ -740,7 +807,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, dbus_message_iter_init(m, &iter); - for (j = 0; j < 7; j++) + for (j = 0; j < 8; j++) dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || @@ -786,18 +853,54 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, if (host && !*host) host = NULL; - if (avahi_server_add_service_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, host, port, strlst) < 0) { + if (avahi_server_add_service_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, host, port, strlst) < 0) { avahi_string_list_free(strlst); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } else - i->n_entries ++; - + } + + i->n_entries ++; avahi_string_list_free(strlst); return respond_ok(c, m); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) { + + int32_t interface, protocol; + uint32_t flags; + char *type, *name, *domain, *subtype; + + if (!dbus_message_get_args( + m, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_STRING, &subtype, + DBUS_TYPE_INVALID) || !type || !name || !subtype) { + avahi_log_warn("Error parsing EntryGroup::AddServiceSubtype message"); + goto fail; + } + + if (i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP) { + avahi_log_warn("Too many entries per entry group, client request failed."); + return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); + } + + if (domain && !*domain) + domain = NULL; + + if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) + return respond_error(c, m, avahi_server_errno(avahi_server), NULL); + + i->n_entries ++; + + return respond_ok(c, m); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) { int32_t interface, protocol; + uint32_t flags; char *name, *address; AvahiAddress a; @@ -805,6 +908,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, m, &error, DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_UINT32, &flags, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &address, DBUS_TYPE_INVALID) || !name || !address) { @@ -821,13 +925,13 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, return respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL); } - if (avahi_server_add_address(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, 0, name, &a) < 0) + if (avahi_server_add_address(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, &a) < 0) return respond_error(c, m, avahi_server_errno(avahi_server), NULL); - else - i->n_entries ++; + + i->n_entries ++; return respond_ok(c, m); - } + } avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); @@ -838,7 +942,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); @@ -848,6 +952,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; + uint32_t u_flags; DBusMessage *reply; assert(a); @@ -855,7 +960,8 @@ 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->family; + i_aprotocol = (int32_t) a->proto; + u_flags = (uint32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -865,20 +971,20 @@ 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_UINT32, &u_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); + assert(event == AVAHI_RESOLVER_FAILURE); + respond_error(server->bus, i->message, avahi_server_errno(avahi_server), 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); @@ -888,6 +994,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; + uint32_t u_flags; DBusMessage *reply; assert(host_name); @@ -895,7 +1002,8 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) address->family; + i_aprotocol = (int32_t) address->proto; + u_flags = (uint32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -905,13 +1013,14 @@ 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_UINT32, &u_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); + assert(event == AVAHI_RESOLVER_FAILURE); + respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL); } sync_address_resolver_free(i); @@ -927,7 +1036,7 @@ static DBusHandlerResult msg_domain_browser_impl(DBusConnection *c, DBusMessage dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -961,25 +1070,33 @@ 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; + uint32_t u_flags; assert(b); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; - 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); + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, map_browse_signal_name(event)); + + 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_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); dbus_message_unref(m); @@ -995,7 +1112,7 @@ static DBusHandlerResult msg_service_type_browser_impl(DBusConnection *c, DBusMe dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1029,27 +1146,35 @@ 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; + uint32_t u_flags; assert(b); - assert(type); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; - 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); + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, map_browse_signal_name(event)); + + 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_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); dbus_message_unref(m); @@ -1065,7 +1190,7 @@ static DBusHandlerResult msg_service_browser_impl(DBusConnection *c, DBusMessage dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1099,29 +1224,38 @@ 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; + uint32_t u_flags; assert(b); - assert(name); - assert(type); - assert(domain); assert(i); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; - 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); + m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, map_browse_signal_name(event)); + + 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_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); dbus_message_unref(m); @@ -1160,6 +1294,7 @@ static void sync_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, + AvahiLookupResultFlags flags, void* userdata) { SyncServiceResolverInfo *i = userdata; @@ -1170,16 +1305,21 @@ static void sync_service_resolver_callback( if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; int32_t i_interface, i_protocol, i_aprotocol; + uint32_t u_flags; DBusMessage *reply; assert(host_name); + + if (!name) + name = ""; assert(a); avahi_address_snprint(t, sizeof(t), a); i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) a->family; + i_aprotocol = (int32_t) a->proto; + u_flags = (uint32_t) flags; reply = dbus_message_new_method_return(i->message); dbus_message_append_args( @@ -1197,37 +1337,46 @@ static void sync_service_resolver_callback( append_string_list(reply, txt); + dbus_message_append_args( + reply, + DBUS_TYPE_UINT32, &u_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); + assert(event == AVAHI_RESOLVER_FAILURE); + + respond_error(server->bus, i->message, avahi_server_errno(avahi_server), 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_resolve_signal_name(event)); + if (event == AVAHI_RESOLVER_FOUND) { char t[256], *pt = t; int32_t i_interface, i_protocol, i_aprotocol; + uint32_t u_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->family; + i_aprotocol = (int32_t) address->proto; + u_flags = (uint32_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, @@ -1235,14 +1384,15 @@ 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_UINT32, &u_flags, DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Timeout"); + } else { + assert(event == AVAHI_RESOLVER_FAILURE); + append_server_error(reply); } + dbus_message_set_destination(reply, i->client->name); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -1257,7 +1407,7 @@ static DBusHandlerResult msg_async_address_resolver_impl(DBusConnection *c, DBus dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1291,26 +1441,29 @@ 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; + uint32_t u_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->family; + i_aprotocol = (int32_t) a->proto; + u_flags = (uint32_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, @@ -1318,13 +1471,14 @@ 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_UINT32, &u_flags, DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Timeout"); + } else { + assert(event == AVAHI_RESOLVER_FAILURE); + append_server_error(reply); } + dbus_message_set_destination(reply, i->client->name); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -1339,7 +1493,7 @@ static DBusHandlerResult msg_async_host_name_resolver_impl(DBusConnection *c, DB dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1384,29 +1538,42 @@ static void async_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, + AvahiLookupResultFlags flags, void* userdata) { AsyncServiceResolverInfo *i = userdata; DBusMessage *reply; assert(r); - assert(host_name); 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; + uint32_t u_flags; assert(host_name); + +/* avahi_log_debug(__FILE__": [%s] Successfully resolved service <%s.%s.%s>", i->path, name, type, domain); */ - assert(a); - avahi_address_snprint(t, sizeof(t), a); + if (a) + avahi_address_snprint(t, sizeof(t), a); + else + t[0] = 0; + + if (!name) + name = ""; i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) a->family; + if (a) + i_aprotocol = (int32_t) a->proto; + else + i_aprotocol = AVAHI_PROTO_UNSPEC; + u_flags = (uint32_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, @@ -1421,13 +1588,17 @@ static void async_service_resolver_callback( DBUS_TYPE_INVALID); append_string_list(reply, txt); - - } else { - assert(event == AVAHI_RESOLVER_TIMEOUT); - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Timeout"); + dbus_message_append_args( + 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); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -1442,7 +1613,7 @@ static DBusHandlerResult msg_async_service_resolver_impl(DBusConnection *c, DBus dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1480,7 +1651,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void dbus_error_init(&error); - avahi_log_debug("dbus: interface=%s, path=%s, member=%s", + avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", dbus_message_get_interface(m), dbus_message_get_path(m), dbus_message_get_member(m)); @@ -1535,6 +1706,37 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void state = avahi_server_get_state(avahi_server); return respond_int32(c, m, (int32_t) state); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetLocalServiceCookie")) { + + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { + avahi_log_warn("Error parsing Server::GetLocalServiceCookie message"); + goto fail; + } + + return respond_uint32(c, m, avahi_server_get_local_service_cookie(avahi_server)); + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "IsServiceLocal")) { + int32_t interface, protocol; + char *name, *type, *domain; + int b; + + if (!dbus_message_get_args( + m, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INVALID) || !name || !type || !domain) { + avahi_log_warn("Error parsing Server::IsServiceLocal message"); + goto fail; + } + + if ((b = avahi_server_is_service_local(avahi_server, interface, protocol, name, type, domain)) < 0) + return respond_error(c, m, avahi_server_errno(avahi_server), NULL); + + return respond_boolean(c, m, b); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) { int32_t idx; int fd; @@ -1549,7 +1751,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void return respond_string(c, m, "blah"); #else - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { char txt[256]; snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); @@ -1584,7 +1786,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void #ifdef VALGRIND_WORKAROUND return respond_int32(c, m, 1); #else - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { char txt[256]; snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); @@ -1680,6 +1882,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; + uint32_t flags; char *name; SyncHostNameResolverInfo *i; @@ -1689,6 +1892,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_UINT32, &flags, DBUS_TYPE_INVALID) || !name) { avahi_log_warn("Error parsing Server::ResolveHostName message"); goto fail; @@ -1710,7 +1914,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); } @@ -1720,6 +1924,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; + uint32_t flags; char *address; SyncAddressResolverInfo *i; AvahiAddress a; @@ -1729,6 +1934,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_UINT32, &flags, DBUS_TYPE_INVALID) || !address) { avahi_log_warn("Error parsing Server::ResolveAddress message"); goto fail; @@ -1753,7 +1959,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); } @@ -1772,6 +1978,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL }; int32_t interface, protocol, type; + uint32_t flags; char *domain; if (!dbus_message_get_args( @@ -1780,6 +1987,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_UINT32, &flags, DBUS_TYPE_INVALID) || type < 0 || type >= AVAHI_DOMAIN_BROWSER_MAX) { avahi_log_warn("Error parsing Server::DomainBrowserNew message"); goto fail; @@ -1805,7 +2013,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); } @@ -1825,6 +2033,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL }; int32_t interface, protocol; + uint32_t flags; char *domain; if (!dbus_message_get_args( @@ -1832,6 +2041,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_UINT32, &flags, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::ServiceTypeBrowserNew message"); goto fail; @@ -1858,7 +2068,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); } @@ -1878,6 +2088,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void NULL }; int32_t interface, protocol; + uint32_t flags; char *domain, *type; if (!dbus_message_get_args( @@ -1886,6 +2097,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_UINT32, &flags, DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ServiceBrowserNew message"); goto fail; @@ -1912,7 +2124,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); } @@ -1923,6 +2135,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; + uint32_t flags; char *name, *type, *domain; SyncServiceResolverInfo *i; @@ -1934,7 +2147,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_UINT32, &flags, + DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ResolveService message"); goto fail; } @@ -1951,6 +2165,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; @@ -1958,7 +2175,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); } @@ -1968,6 +2185,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; + uint32_t flags; char *name, *type, *domain; AsyncServiceResolverInfo *i; static const DBusObjectPathVTable vtable = { @@ -1987,7 +2205,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_UINT32, &flags, + DBUS_TYPE_INVALID) || !type) { avahi_log_warn("Error parsing Server::ServiceResolverNew message"); goto fail; } @@ -2002,6 +2221,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; @@ -2009,10 +2234,12 @@ 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); } + +/* avahi_log_debug(__FILE__": [%s], new service resolver for <%s.%s.%s>", i->path, name, type, domain); */ dbus_connection_register_object_path(c, i->path, &vtable, i); return respond_path(c, m, i->path); @@ -2020,6 +2247,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; + uint32_t flags; char *name; AsyncHostNameResolverInfo *i; static const DBusObjectPathVTable vtable = { @@ -2037,6 +2265,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_UINT32, &flags, DBUS_TYPE_INVALID) || !name) { avahi_log_warn("Error parsing Server::HostNameResolverNew message"); goto fail; @@ -2059,7 +2288,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); } @@ -2070,6 +2299,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; + uint32_t flags; char *address; AsyncAddressResolverInfo *i; AvahiAddress a; @@ -2087,6 +2317,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_UINT32, &flags, DBUS_TYPE_INVALID) || !address) { avahi_log_warn("Error parsing Server::AddressResolverNew message"); goto fail; @@ -2112,7 +2343,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); }