if (!db)
goto fail;
- if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set (&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- goto fail;
+ switch (event) {
+ case AVAHI_BROWSER_NEW:
+ case AVAHI_BROWSER_REMOVE:
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+
+ break;
+
+ case AVAHI_BROWSER_CACHE_EXHAUSTED:
+ case AVAHI_BROWSER_ALL_FOR_NOW:
+ break;
+
+ case AVAHI_BROWSER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt));
+ break;
}
}
if (!b)
goto fail;
+ switch (event) {
+ case AVAHI_BROWSER_NEW:
+ case AVAHI_BROWSER_REMOVE:
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_STRING, &type,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set(&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+ break;
+
+ case AVAHI_BROWSER_CACHE_EXHAUSTED:
+ case AVAHI_BROWSER_ALL_FOR_NOW:
+ break;
- if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set(&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- goto fail;
+ case AVAHI_BROWSER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
+ break;
}
}
}
-DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) {
+DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) {
AvahiServiceBrowser *b = NULL;
DBusError error;
const char *path;
if (!b)
goto fail;
- if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
- if (!dbus_message_get_args (
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set(&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- goto fail;
+ switch (event) {
+ case AVAHI_BROWSER_NEW:
+ case AVAHI_BROWSER_REMOVE:
+
+ if (!dbus_message_get_args (
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &type,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set(&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+ break;
+
+ case AVAHI_BROWSER_CACHE_EXHAUSTED:
+ case AVAHI_BROWSER_ALL_FOR_NOW:
+ break;
+
+ case AVAHI_BROWSER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
+ break;
}
}
char addr[64];
char *txtr;
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("SERVICE-RESOLVER: ServiceResolver %p timed out (%s %s)\n", (void*) r, name, type);
return;
}
void *userdata) {
char addr[64];
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n");
return;
}
AvahiAddressResolver *ar;
char addr[64];
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n");
return;
}
return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "NotFound"))
- return avahi_domain_browser_event(client, AVAHI_BROWSER_NOT_FOUND, message);
else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message);
return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "NotFound"))
- return avahi_service_type_browser_event (client, AVAHI_BROWSER_NOT_FOUND, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message);
return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow"))
return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "NotFound"))
- return avahi_service_browser_event (client, AVAHI_BROWSER_NOT_FOUND, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure"))
return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"))
return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Timeout"))
- return avahi_service_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "NotFound"))
- return avahi_service_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure"))
return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"))
return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Timeout"))
- return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "NotFound"))
- return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure"))
return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"))
return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Timeout"))
- return avahi_address_resolver_event (client, AVAHI_RESOLVER_TIMEOUT, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "NotFound"))
- return avahi_address_resolver_event (client, AVAHI_RESOLVER_NOT_FOUND, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure"))
return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
if (!r)
goto fail;
- if (event == AVAHI_RESOLVER_FOUND) {
- int j;
- int32_t interface, protocol, aprotocol;
- uint32_t flags;
- char *name, *type, *domain, *host, *address;
- uint16_t port;
- DBusMessageIter iter, sub;
- AvahiAddress a;
-
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_STRING, &host,
- DBUS_TYPE_INT32, &aprotocol,
- DBUS_TYPE_STRING, &address,
- DBUS_TYPE_UINT16, &port,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set (&error)) {
+ switch (event) {
+ case AVAHI_RESOLVER_FOUND: {
+ int j;
+ int32_t interface, protocol, aprotocol;
+ uint32_t flags;
+ char *name, *type, *domain, *host, *address;
+ uint16_t port;
+ DBusMessageIter iter, sub;
+ AvahiAddress a;
- fprintf(stderr, "Failed to parse resolver event.\n");
- goto fail;
- }
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &type,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_STRING, &host,
+ DBUS_TYPE_INT32, &aprotocol,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_UINT16, &port,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
- dbus_message_iter_init(message, &iter);
+ dbus_message_iter_init(message, &iter);
- for (j = 0; j < 9; j++)
- dbus_message_iter_next(&iter);
+ for (j = 0; j < 9; j++)
+ dbus_message_iter_next(&iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
- dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) {
- fprintf(stderr, "Error parsing service resolving message\n");
- goto fail;
- }
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
+ dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) {
+ fprintf(stderr, "Error parsing service resolving message\n");
+ goto fail;
+ }
- strlst = NULL;
- dbus_message_iter_recurse(&iter, &sub);
+ strlst = NULL;
+ dbus_message_iter_recurse(&iter, &sub);
- for (;;) {
- DBusMessageIter sub2;
- int at;
+ for (;;) {
+ DBusMessageIter sub2;
+ int at;
- if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
- break;
+ if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
+ break;
- assert(at == DBUS_TYPE_ARRAY);
+ assert(at == DBUS_TYPE_ARRAY);
- if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
- fprintf(stderr, "Error parsing service resolving message\n");
- goto fail;
- }
+ if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
+ fprintf(stderr, "Error parsing service resolving message\n");
+ goto fail;
+ }
- dbus_message_iter_recurse(&sub, &sub2);
+ dbus_message_iter_recurse(&sub, &sub2);
- if (dbus_message_iter_get_array_len(&sub2) > 0) {
- uint8_t *k;
- int n;
+ if (dbus_message_iter_get_array_len(&sub2) > 0) {
+ uint8_t *k;
+ int n;
- dbus_message_iter_get_fixed_array(&sub2, &k, &n);
- strlst = avahi_string_list_add_arbitrary(strlst, k, n);
- }
+ dbus_message_iter_get_fixed_array(&sub2, &k, &n);
+ strlst = avahi_string_list_add_arbitrary(strlst, k, n);
+ }
- dbus_message_iter_next(&sub);
- }
+ dbus_message_iter_next(&sub);
+ }
- dbus_message_iter_next(&iter);
+ dbus_message_iter_next(&iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
- fprintf(stderr, "Failed to parse resolver event.\n");
- goto fail;
- }
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
- dbus_message_iter_get_basic(&iter, &flags);
+ dbus_message_iter_get_basic(&iter, &flags);
- assert(address);
- if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
- fprintf(stderr, "Failed to parse address\n");
- goto fail;
- }
+ assert(address);
+ if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+ fprintf(stderr, "Failed to parse address\n");
+ goto fail;
+ }
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, &a, port, strlst, (AvahiLookupResultFlags) flags, r->userdata);
+ r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, &a, port, strlst, (AvahiLookupResultFlags) flags, r->userdata);
- avahi_string_list_free(strlst);
-
- } else
- r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, r->userdata);
+ avahi_string_list_free(strlst);
+ break;
+ }
+
+ case AVAHI_RESOLVER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+ r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, r->userdata);
+ break;
+ }
+ }
return DBUS_HANDLER_RESULT_HANDLED;
if (!r)
goto fail;
- if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface, protocol, aprotocol;
- uint32_t flags;
- char *name, *address;
- AvahiAddress a;
-
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INT32, &aprotocol,
- DBUS_TYPE_STRING, &address,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set (&error)) {
- fprintf(stderr, "Failed to parse resolver event.\n");
- goto fail;
+ switch (event) {
+ case AVAHI_RESOLVER_FOUND: {
+ int32_t interface, protocol, aprotocol;
+ uint32_t flags;
+ char *name, *address;
+ AvahiAddress a;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INT32, &aprotocol,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
+
+ assert(address);
+ if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+ fprintf(stderr, "Failed to parse address\n");
+ goto fail;
+ }
+
+ r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata);
+ break;
}
-
- assert(address);
- if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
- fprintf(stderr, "Failed to parse address\n");
- goto fail;
+
+ case AVAHI_RESOLVER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+ r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, 0, r->userdata);
+ break;
}
-
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata);
-
- } else
- r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, 0, r->userdata);
+ }
return DBUS_HANDLER_RESULT_HANDLED;
if (!r)
goto fail;
- if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface, protocol, aprotocol;
- uint32_t flags;
- char *name, *address;
- AvahiAddress a;
-
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_INT32, &aprotocol,
- DBUS_TYPE_STRING, &address,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set (&error)) {
- fprintf(stderr, "Failed to parse resolver event.\n");
- goto fail;
+ switch (event) {
+ case AVAHI_RESOLVER_FOUND: {
+ int32_t interface, protocol, aprotocol;
+ uint32_t flags;
+ char *name, *address;
+ AvahiAddress a;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_INT32, &interface,
+ DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_INT32, &aprotocol,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
+
+ assert(address);
+ if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
+ fprintf(stderr, "Failed to parse address\n");
+ goto fail;
+ }
+
+ r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, (AvahiProtocol) aprotocol, &a, name, (AvahiLookupResultFlags) flags, r->userdata);
+ break;
}
-
- assert(address);
- if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
- fprintf(stderr, "Failed to parse address\n");
- goto fail;
+
+ case AVAHI_RESOLVER_FAILURE: {
+ char *etxt;
+
+ if (!dbus_message_get_args(
+ message, &error,
+ DBUS_TYPE_STRING, &etxt,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse resolver event.\n");
+ goto fail;
+ }
+
+ avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
+ r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, AVAHI_PROTO_UNSPEC, NULL, NULL, 0, r->userdata);
+ break;
}
-
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, (AvahiProtocol) aprotocol, &a, name, (AvahiLookupResultFlags) flags, r->userdata);
- } else
- r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, AVAHI_PROTO_UNSPEC, NULL, NULL, 0, r->userdata);
+ }
return DBUS_HANDLER_RESULT_HANDLED;
AVAHI_DBUS_ERR_NOT_FOUND,
AVAHI_DBUS_ERR_INVALID_CONFIG,
AVAHI_DBUS_ERR_VERSION_MISMATCH,
- AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE
+ AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE,
+ AVAHI_DBUS_ERR_INVALID_PACKET,
+ AVAHI_DBUS_ERR_INVALID_DNS_ERROR,
+ AVAHI_DBUS_ERR_DNS_FORMERR,
+ AVAHI_DBUS_ERR_DNS_SERVFAIL,
+ AVAHI_DBUS_ERR_DNS_NXDOMAIN,
+ AVAHI_DBUS_ERR_DNS_NOTIMP,
+ AVAHI_DBUS_ERR_DNS_REFUSED,
+ AVAHI_DBUS_ERR_DNS_YXDOMAIN,
+ AVAHI_DBUS_ERR_DNS_YXRRSET,
+ AVAHI_DBUS_ERR_DNS_NXRRSET,
+ AVAHI_DBUS_ERR_DNS_NOTAUTH,
+ AVAHI_DBUS_ERR_DNS_NOTZONE,
};
int avahi_error_dbus_to_number(const char *s) {
#define AVAHI_DBUS_ERR_INVALID_CONFIG "org.freedesktop.Avahi.InvalidConfigurationError"
#define AVAHI_DBUS_ERR_VERSION_MISMATCH "org.freedesktop.Avahi.VersionMismatchError"
#define AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE "org.freedesktop.Avahi.InvalidServiceSubtypeError"
+#define AVAHI_DBUS_ERR_INVALID_PACKET "org.freedesktop.Avahi.InvalidPacketError"
+#define AVAHI_DBUS_ERR_INVALID_DNS_ERROR "org.freedesktop.Avahi.InvalidDNSError"
+#define AVAHI_DBUS_ERR_DNS_FORMERR "org.freedesktop.Avahi.DNSFORMERR"
+#define AVAHI_DBUS_ERR_DNS_SERVFAIL "org.freedesktop.Avahi.DNSSERVFAIL"
+#define AVAHI_DBUS_ERR_DNS_NXDOMAIN "org.freedesktop.Avahi.DNSNXDOMAIN"
+#define AVAHI_DBUS_ERR_DNS_NOTIMP "org.freedesktop.Avahi.DNSNOTIMP"
+#define AVAHI_DBUS_ERR_DNS_REFUSED "org.freedesktop.Avahi.DNSREFUSED"
+#define AVAHI_DBUS_ERR_DNS_YXDOMAIN "org.freedesktop.Avahi.DNSYXDOMAIN"
+#define AVAHI_DBUS_ERR_DNS_YXRRSET "org.freedesktop.Avahi.DNSYXRRSET"
+#define AVAHI_DBUS_ERR_DNS_NXRRSET "org.freedesktop.Avahi.DNSNXRRSET"
+#define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH"
+#define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE"
/** Convert a DBus error string into an Avahi error number */
int avahi_error_dbus_to_number(const char *s);
AVAHI_ENTRY_GROUP_UNCOMMITED, /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */
AVAHI_ENTRY_GROUP_REGISTERING, /**< The entries of the group are currently being registered */
AVAHI_ENTRY_GROUP_ESTABLISHED, /**< The entries have successfully been established */
- AVAHI_ENTRY_GROUP_COLLISION /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */
+ AVAHI_ENTRY_GROUP_COLLISION, /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */
} AvahiEntryGroupState;
/** The type of domain to browse for */
AVAHI_BROWSER_REMOVE, /**< The object has been removed from the network */
AVAHI_BROWSER_CACHE_EXHAUSTED, /**< One-time event, to notify the user that all entries from the caches have been send */
AVAHI_BROWSER_ALL_FOR_NOW, /**< One-time event, to notify the user that more records will probably not show up in the near future, i.e. all cache entries have been read and all static servers been queried */
- AVAHI_BROWSER_NOT_FOUND, /**< Issued when using wide area DNS-SD to inform that a record is not existing */
- AVAHI_BROWSER_FAILURE /**< Issued when using wide area DNS-SD to inform about server failures */
+ AVAHI_BROWSER_FAILURE /**< Browsing failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */
} AvahiBrowserEvent;
/** Type of callback event when resolving */
typedef enum {
AVAHI_RESOLVER_FOUND, /**< RR found, resolving successful */
- AVAHI_RESOLVER_TIMEOUT, /**< Noone responded within the timeout, resolving failed */
- AVAHI_RESOLVER_NOT_FOUND, /**< Query was done using wide area DNS-SD and the server told us that the entry is nto available */
- AVAHI_RESOLVER_FAILURE /**< Query was done using wide area DNS-SD and the server failed */
+ AVAHI_RESOLVER_FAILURE /**< Resolving failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */
} AvahiResolverEvent;
/** States of a server object */
"Resource record key is pattern",
"Local name collision",
"Invalid record",
+
"Invalid service name",
"Invalid service type",
"Invalid port number",
"Too many objects",
"Too many entries",
"OS Error",
+
"Access denied",
"Invalid operation",
"An unexpected DBUS error occured",
"Invalid interface index",
"Invalid protocol specification",
"Invalid flags",
+
"Not found",
"Invalid configuration",
"Version mismatch",
- "Invalid service subtype"
+ "Invalid service subtype",
+ "Invalid packet",
+ "Invalid DNS return code",
+ "DNS failure: FORMERR",
+ "DNS failure: SERVFAIL",
+ "DNS failure: NXDOMAIN",
+ "DNS failure: NOTIMP",
+
+ "DNS failure: REFUSED",
+ "DNS failure: YXDOMAIN",
+ "DNS failure: YXRRSET",
+ "DNS failure: NXRRSET",
+ "DNS failure: NOTAUTH",
+ "DNS failure: NOTZONE"
};
if (-error < 0 || -error >= -AVAHI_ERR_MAX)
AVAHI_ERR_IS_PATTERN = -7, /**< RR key is pattern */
AVAHI_ERR_LOCAL_COLLISION = -8, /**< Local name collision */
AVAHI_ERR_INVALID_RECORD = -9, /**< Invalid RR */
+
AVAHI_ERR_INVALID_SERVICE_NAME = -10, /**< Invalid service name */
AVAHI_ERR_INVALID_SERVICE_TYPE = -11, /**< Invalid service type */
AVAHI_ERR_INVALID_PORT = -12, /**< Invalid port number */
AVAHI_ERR_TOO_MANY_OBJECTS = -17, /**< Too many objects */
AVAHI_ERR_TOO_MANY_ENTRIES = -18, /**< Too many entries */
AVAHI_ERR_OS = -19, /**< OS error */
+
AVAHI_ERR_ACCESS_DENIED = -20, /**< Access denied */
AVAHI_ERR_INVALID_OPERATION = -21, /**< Invalid operation */
AVAHI_ERR_DBUS_ERROR = -22, /**< An unexpected DBUS error occured */
AVAHI_ERR_INVALID_INTERFACE = -27, /**< Invalid interface */
AVAHI_ERR_INVALID_PROTOCOL = -28, /**< Invalid protocol */
AVAHI_ERR_INVALID_FLAGS = -29, /**< Invalid flags */
+
AVAHI_ERR_NOT_FOUND = -30, /**< Not found */
AVAHI_ERR_INVALID_CONFIG = -31, /**< Configuration error */
AVAHI_ERR_VERSION_MISMATCH = -32, /**< Verson mismatch */
AVAHI_ERR_INVALID_SERVICE_SUBTYPE = -33, /**< Invalid service subtype */
+ AVAHI_ERR_INVALID_PACKET = -34, /**< Invalid packet */
+ AVAHI_ERR_INVALID_DNS_ERROR = -35, /**< Invlaid DNS return code */
+ AVAHI_ERR_DNS_FORMERR = -36,
+ AVAHI_ERR_DNS_SERVFAIL = -37,
+ AVAHI_ERR_DNS_NXDOMAIN = -38,
+ AVAHI_ERR_DNS_NOTIMP = -39,
+ AVAHI_ERR_DNS_REFUSED = -40,
+ AVAHI_ERR_DNS_YXDOMAIN = -41,
+ AVAHI_ERR_DNS_YXRRSET = -42,
+ AVAHI_ERR_DNS_NXRRSET = -43,
+ AVAHI_ERR_DNS_NOTAUTH = -44,
+ AVAHI_ERR_DNS_NOTZONE = -45,
+
/****
**** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
**** IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND
**** Also remember to update the MAX value below.
****/
- AVAHI_ERR_MAX = -34
+ AVAHI_ERR_MAX = -46
};
/** Return a human readable error string for the specified error code */
break;
case AVAHI_BROWSER_FAILURE:
- sdref->service_browser_callback(sdref, 0, interface, kDNSServiceErr_Unknown, NULL, NULL, NULL, sdref->context);
- break;
-
- case AVAHI_BROWSER_NOT_FOUND:
- sdref->service_browser_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, NULL, NULL, NULL, sdref->context);
+ sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context);
break;
case AVAHI_BROWSER_CACHE_EXHAUSTED:
break;
}
- case AVAHI_RESOLVER_TIMEOUT:
- case AVAHI_RESOLVER_NOT_FOUND:
- sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, NULL, NULL, 0, 0, NULL, sdref->context);
- break;
-
case AVAHI_RESOLVER_FAILURE:
- sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_Unknown, NULL, NULL, 0, 0, NULL, sdref->context);
+ sdref->service_resolver_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, 0, 0, NULL, sdref->context);
}
}
break;
case AVAHI_BROWSER_FAILURE:
- sdref->domain_browser_callback(sdref, 0, interface, kDNSServiceErr_Unknown, domain, sdref->context);
- break;
-
- case AVAHI_BROWSER_NOT_FOUND:
- sdref->domain_browser_callback(sdref, 0, interface, kDNSServiceErr_NoSuchName, domain, sdref->context);
+ sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context);
break;
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
case AVAHI_BROWSER_FAILURE : return "FAILURE";
- case AVAHI_BROWSER_NOT_FOUND : return "NOT_FOUND";
}
abort();
static const char *resolver_event_to_string(AvahiResolverEvent event) {
switch (event) {
case AVAHI_RESOLVER_FOUND: return "FOUND";
- case AVAHI_RESOLVER_TIMEOUT: return "TIMEOUT";
- case AVAHI_RESOLVER_NOT_FOUND: return "NOT_FOUND";
case AVAHI_RESOLVER_FAILURE: return "FAILURE";
}
abort();
break;
}
- case AVAHI_RESOLVER_NOT_FOUND:
case AVAHI_RESOLVER_FAILURE:
- case AVAHI_RESOLVER_TIMEOUT:
/* Ignore */
break;
}
}
case AVAHI_BROWSER_FAILURE:
- case AVAHI_BROWSER_NOT_FOUND:
case AVAHI_BROWSER_ALL_FOR_NOW:
case AVAHI_BROWSER_CACHE_EXHAUSTED:
abort();
case AVAHI_BROWSER_ALL_FOR_NOW:
- case AVAHI_BROWSER_NOT_FOUND:
case AVAHI_BROWSER_FAILURE:
b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, flags, b->userdata);
break;
case AVAHI_BROWSER_CACHE_EXHAUSTED:
- case AVAHI_BROWSER_NOT_FOUND:
case AVAHI_BROWSER_FAILURE:
/* Not defined for multicast DNS */
abort();
if (n < 0) {
/* sending of the initial query failed */
+ avahi_server_set_errno(b->server, AVAHI_ERR_FAILURE);
+
b->callback(
b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
case AVAHI_BROWSER_FAILURE : return "FAILURE";
- case AVAHI_BROWSER_NOT_FOUND : return "NOT_FOUND";
}
abort();
}
switch (event) {
- case AVAHI_RESOLVER_NOT_FOUND:
- case AVAHI_RESOLVER_TIMEOUT:
case AVAHI_RESOLVER_FAILURE:
r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
break;
assert(e);
assert(r);
- finish(r, AVAHI_RESOLVER_TIMEOUT);
+ avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+ finish(r, AVAHI_RESOLVER_FAILURE);
}
static void start_timeout(AvahiSAddressResolver *r) {
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
- case AVAHI_BROWSER_NOT_FOUND:
+ case AVAHI_BROWSER_FAILURE:
if (r->retry_with_multicast) {
r->retry_with_multicast = 0;
}
}
- /* Fallthrough */
-
- case AVAHI_BROWSER_FAILURE:
r->flags = flags;
- finish(r, event == AVAHI_BROWSER_NOT_FOUND ? AVAHI_RESOLVER_NOT_FOUND : AVAHI_RESOLVER_FAILURE);
-
+ finish(r, AVAHI_RESOLVER_FAILURE);
+ break;
}
}
}
- case AVAHI_RESOLVER_TIMEOUT:
- case AVAHI_RESOLVER_NOT_FOUND:
case AVAHI_RESOLVER_FAILURE:
r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
assert(e);
assert(r);
- finish(r, AVAHI_RESOLVER_TIMEOUT);
+ avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+ finish(r, AVAHI_RESOLVER_FAILURE);
}
static void start_timeout(AvahiSHostNameResolver *r) {
break;
case AVAHI_BROWSER_FAILURE:
- case AVAHI_BROWSER_NOT_FOUND:
/* Stop browsers */
r->record_browser_a = r->record_browser_aaaa = NULL;
r->flags = flags;
- finish(r, event == AVAHI_BROWSER_FAILURE ? AVAHI_RESOLVER_FAILURE : AVAHI_RESOLVER_NOT_FOUND);
+ finish(r, AVAHI_RESOLVER_FAILURE);
break;
}
}
switch (event) {
case AVAHI_RESOLVER_FAILURE:
- case AVAHI_RESOLVER_NOT_FOUND:
- case AVAHI_RESOLVER_TIMEOUT:
r->callback(
r,
assert(e);
assert(r);
- avahi_log_debug("timeout");
-
- finish(r, AVAHI_RESOLVER_TIMEOUT);
+ avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
+ finish(r, AVAHI_RESOLVER_FAILURE);
}
static void start_timeout(AvahiSServiceResolver *r) {
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
- case AVAHI_BROWSER_NOT_FOUND:
case AVAHI_BROWSER_FAILURE:
-
if (rr == r->record_browser_a && r->record_browser_aaaa) {
/* We were looking for both AAAA and A, and the other query is still living, so we'll not die */
break;
}
-
/* Hmm, everything's lost, tell the user */
if (r->record_browser_srv)
r->record_browser_srv = r->record_browser_txt = r->record_browser_a = r->record_browser_aaaa = NULL;
- finish(r, event == AVAHI_BROWSER_FAILURE ? AVAHI_RESOLVER_FAILURE : AVAHI_RESOLVER_NOT_FOUND);
+ finish(r, AVAHI_RESOLVER_FAILURE);
break;
}
}
#include <stdlib.h>
#include <avahi-common/malloc.h>
+#include <avahi-common/error.h>
#include "server.h"
#include "browse.h"
if (l->n_send >= 6) {
avahi_log_warn(__FILE__": Query timed out.");
+ avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT);
l->callback(l->engine, AVAHI_BROWSER_FAILURE, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
avahi_wide_area_lookup_free(l);
return;
run_callbacks(e, r);
}
+static int map_dns_error(uint16_t error) {
+ static const int table[16] = {
+ AVAHI_OK,
+ AVAHI_ERR_DNS_FORMERR,
+ AVAHI_ERR_DNS_SERVFAIL,
+ AVAHI_ERR_DNS_NXDOMAIN,
+ AVAHI_ERR_DNS_NOTIMP,
+ AVAHI_ERR_DNS_REFUSED,
+ AVAHI_ERR_DNS_YXDOMAIN,
+ AVAHI_ERR_DNS_YXRRSET,
+ AVAHI_ERR_DNS_NXRRSET,
+ AVAHI_ERR_DNS_NOTAUTH,
+ AVAHI_ERR_DNS_NOTZONE,
+ AVAHI_ERR_INVALID_DNS_ERROR,
+ AVAHI_ERR_INVALID_DNS_ERROR,
+ AVAHI_ERR_INVALID_DNS_ERROR,
+ AVAHI_ERR_INVALID_DNS_ERROR,
+ AVAHI_ERR_INVALID_DNS_ERROR
+ };
+
+ assert(error <= 15);
+
+ return table[error];
+}
+
static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p, AvahiAddress *a) {
AvahiWideAreaLookup *l = NULL;
int i, r;
if ((r = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & 15) != 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0) {
+ avahi_server_set_errno(e->server, r == 0 ? AVAHI_ERR_NOT_FOUND : map_dns_error(r));
/* Tell the user about the failure */
- final_event = r == 3 ? AVAHI_BROWSER_NOT_FOUND : AVAHI_BROWSER_FAILURE;
+ final_event = AVAHI_BROWSER_FAILURE;
/* We go on here, since some of the records contained in the
reply might be interesting in some way */
if (!(k = avahi_dns_packet_consume_key(p, NULL))) {
avahi_log_warn(__FILE__": Wide area response packet too short.");
+ avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
final_event = AVAHI_BROWSER_FAILURE;
goto finish;
}
if (!(rr = avahi_dns_packet_consume_record(p, NULL))) {
avahi_log_warn(__FILE__": Wide area response packet too short (2).");
+ avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
final_event = AVAHI_BROWSER_FAILURE;
goto finish;
}
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
<signal name="CacheExhausted"/>
-
</interface>
</node>
<arg name="flags" type="u" direction="out"/>
</signal>
- <signal name="Timeout"/>
-
- <signal name="NotFound"/>
-
- <signal name="Failure"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
</interface>
</node>
<arg name="flags" type="u"/>
</signal>
- <signal name="Failure"/>
-
- <signal name="NotFound"/>
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
<signal name="AllForNow"/>
if (!text)
text = avahi_strerror(error);
- reply = dbus_message_new_error(m, avahi_error_number_to_dbus (error), text);
+ reply = dbus_message_new_error(m, avahi_error_number_to_dbus(error), text);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
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;
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";
}
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;
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_host_name_resolver_free(i);
}
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_address_resolver_free(i);
}
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_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_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_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
- } else
- respond_error(server->bus, i->message, map_resolve_error(event), NULL);
+
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+
+ respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
+ }
sync_service_resolver_free(i);
}
assert(r);
assert(i);
- reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_browse_signal_name(event));
+ reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_resolve_signal_name(event));
if (event == AVAHI_RESOLVER_FOUND) {
char t[256], *pt = t;
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_TYPE_STRING, &pt,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
+ } else {
+ assert(event == AVAHI_RESOLVER_FAILURE);
+ append_server_error(reply);
}
dbus_message_set_destination(reply, i->client->name);
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);
assert(c);
- if (event == AVAHI_RESOLVER_TIMEOUT)
- client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_TIMEOUT);
- else if (event == AVAHI_RESOLVER_FAILURE)
- client_output_printf(c, "%+i Query failed\n", AVAHI_ERR_FAILURE);
- else if (event == AVAHI_RESOLVER_NOT_FOUND)
- client_output_printf(c, "%+i Query timed out\n", AVAHI_ERR_NOT_FOUND);
+ if (event == AVAHI_RESOLVER_FAILURE)
+ client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server)));
else if (event == AVAHI_RESOLVER_FOUND) {
char t[64];
avahi_address_snprint(t, sizeof(t), a);
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);
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;
#include <gtk/gtk.h>
#include <glade/glade.h>
+
#include <avahi-core/core.h>
#include <avahi-core/lookup.h>
+
#include <avahi-common/strlst.h>
#include <avahi-common/domain.h>
+#include <avahi-common/error.h>
+
#include <avahi-glib/glib-watch.h>
#include <avahi-glib/glib-malloc.h>
return;
}
- if (event == AVAHI_RESOLVER_TIMEOUT)
- gtk_label_set_markup(info_label, "<i>Failed to resolve: Timeout.</i>");
- else if (event == AVAHI_RESOLVER_FAILURE)
- gtk_label_set_markup(info_label, "<i>Failed to resolve: Failure.</i>");
- else if (event == AVAHI_RESOLVER_NOT_FOUND)
- gtk_label_set_markup(info_label, "<i>Failed to resolve: Not found.</i>");
- else if (event == AVAHI_RESOLVER_FOUND)
+ if (event == AVAHI_RESOLVER_FAILURE) {
+ char t[256];
+ snprintf(t, sizeof(t), "<i>Failed to resolve: %s.</i>", avahi_strerror(avahi_server_errno(server)));
+ gtk_label_set_markup(info_label, t);
+ } else if (event == AVAHI_RESOLVER_FOUND)
update_label(s, host_name, a, port, txt);
}
/* Called whenever a service has been resolved successfully or timed out */
switch (event) {
- case AVAHI_RESOLVER_TIMEOUT:
- case AVAHI_RESOLVER_NOT_FOUND:
case AVAHI_RESOLVER_FAILURE:
- fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain,
- event == AVAHI_RESOLVER_TIMEOUT ? "TIMEOUT" : (event == AVAHI_RESOLVER_NOT_FOUND ? "NOT_FOUND" : "FAILURE"));
+ fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
break;
case AVAHI_RESOLVER_FOUND: {
switch (event) {
case AVAHI_BROWSER_FAILURE:
- case AVAHI_BROWSER_NOT_FOUND:
- fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_FAILURE ? "FAILURE" : "NOT_FOUND");
+ fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
avahi_simple_poll_quit(simple_poll);
return;
/* Called whenever a service has been resolved successfully or timed out */
switch (event) {
- case AVAHI_RESOLVER_TIMEOUT:
- case AVAHI_RESOLVER_NOT_FOUND:
case AVAHI_RESOLVER_FAILURE:
- fprintf(stderr, "Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain,
- event == AVAHI_RESOLVER_TIMEOUT ? "TIMEOUT" : (event == AVAHI_RESOLVER_NOT_FOUND ? "NOT_FOUND" : "FAILURE"));
+ fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_server_errno(server)));
break;
case AVAHI_RESOLVER_FOUND: {
char a[128], *t;
- fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
+ fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
switch (event) {
case AVAHI_BROWSER_FAILURE:
- case AVAHI_BROWSER_NOT_FOUND:
- fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_FAILURE ? "FAILURE" : "NOT_FOUND");
+ fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_server_errno(server)));
avahi_simple_poll_quit(simple_poll);
return;