noinst_HEADERS = internal.h
-noinst_PROGRAMS = client-test
+noinst_PROGRAMS = \
+ client-test \
+ srv-test
lib_LTLIBRARIES = libavahi-client.la
client_test_CFLAGS = $(AM_CFLAGS)
client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
+srv_test_SOURCES = srv-test.c
+srv_test_CFLAGS = $(AM_CFLAGS)
+srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
+
endif
AvahiProtocol protocol,
const char *domain,
AvahiDomainBrowserType btype,
+ AvahiLookupFlags flags,
AvahiDomainBrowserCallback callback,
void *userdata) {
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
char *path;
- int32_t i_interface, i_protocol, bt;
+ int32_t i_interface, i_protocol, i_flags, bt;
assert(client);
assert(callback);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_flags = (int32_t) flags;
bt = btype;
if (!(dbus_message_append_args(
DBUS_TYPE_INT32, &i_protocol,
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_INT32, &bt,
+ DBUS_TYPE_INT32, &flags,
DBUS_TYPE_INVALID))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
AvahiDomainBrowser *db = NULL;
DBusError error;
const char *path;
- char *domain;
- int32_t interface, protocol;
+ char *domain = NULL;
+ int32_t interface = AVAHI_IF_UNSPEC, protocol = AVAHI_PROTO_UNSPEC, flags = 0;
assert(client);
assert(message);
if (!db)
goto fail;
- if (!dbus_message_get_args(
- message, &error,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_INVALID) ||
- dbus_error_is_set (&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- 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_INT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
}
- db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, db->userdata);
+ db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
+ AvahiLookupFlags flags,
AvahiServiceTypeBrowserCallback callback,
void *userdata) {
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
char *path;
- int32_t i_interface, i_protocol;
+ int32_t i_interface, i_protocol, i_flags;
assert(client);
assert(callback);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_flags = (int32_t) flags;
if (!dbus_message_append_args(
message,
- DBUS_TYPE_INT32, &interface,
- DBUS_TYPE_INT32, &protocol,
+ DBUS_TYPE_INT32, &i_interface,
+ DBUS_TYPE_INT32, &i_protocol,
DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_INT32, &i_flags,
DBUS_TYPE_INVALID)) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
AvahiServiceTypeBrowser *b = NULL;
DBusError error;
const char *path;
- char *domain, *type;
- int32_t interface, protocol;
+ char *domain = NULL, *type = NULL;
+ int32_t interface = AVAHI_IF_UNSPEC, protocol = AVAHI_PROTO_UNSPEC, flags = 0;
assert(client);
assert(message);
if (!b)
goto fail;
- 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_INVALID) ||
- dbus_error_is_set(&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- 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, &type,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_INT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set(&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
}
- b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, type, domain, b->userdata);
+ b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, type, domain, (AvahiLookupResultFlags) flags, b->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
AvahiProtocol protocol,
const char *type,
const char *domain,
+ AvahiLookupFlags flags,
AvahiServiceBrowserCallback callback,
void *userdata) {
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
char *path;
- int32_t i_protocol, i_interface;
+ int32_t i_protocol, i_interface, i_flags;
assert(client);
assert(type);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
-
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_flags = (int32_t) flags;
if (!dbus_message_append_args(
message,
DBUS_TYPE_INT32, &i_protocol,
DBUS_TYPE_STRING, &type,
DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_INT32, &i_flags,
DBUS_TYPE_INVALID)) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
AvahiServiceBrowser *b = NULL;
DBusError error;
const char *path;
- char *name, *type, *domain;
- int32_t interface, protocol;
+ char *name = NULL, *type = NULL, *domain = NULL;
+ int32_t interface = AVAHI_IF_UNSPEC, protocol = AVAHI_PROTO_UNSPEC, flags = 0;
dbus_error_init (&error);
if (!b)
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_INVALID) ||
- dbus_error_is_set(&error)) {
- fprintf(stderr, "Failed to parse browser event.\n");
- 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_INT32, &flags,
+ DBUS_TYPE_INVALID) ||
+ dbus_error_is_set(&error)) {
+ fprintf(stderr, "Failed to parse browser event.\n");
+ goto fail;
+ }
}
- b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, type, domain, b->userdata);
+ b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, type, domain, (AvahiLookupResultFlags) flags, b->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
#include <config.h>
#endif
+#include <stdio.h>
+#include <assert.h>
+
#include <avahi-client/client.h>
#include <avahi-common/error.h>
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
-#include <stdio.h>
-#include <assert.h>
static const AvahiPoll *poll_api = NULL;
static AvahiSimplePoll *simple_poll = NULL;
-
-static void
-avahi_client_callback (AvahiClient *c, AvahiClientState state, void *user_data)
-{
- printf ("CLIENT: Callback on %p, state -> %d, data -> %s\n", (void*) c, state, (char*)user_data);
+static void avahi_client_callback (AvahiClient *c, AvahiClientState state, void *userdata) {
+ printf ("CLIENT: Callback on %p, state -> %d, data -> %s\n", (void*) c, state, (char*)userdata);
}
-static void
-avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *user_data)
-{
- printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)user_data);
+static void avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
+ printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata);
}
-static void
-avahi_domain_browser_callback (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *user_data)
-{
- printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain, (char*)user_data);
+static void avahi_domain_browser_callback(
+ AvahiDomainBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *domain,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
+ printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain, (char*)userdata);
}
-static void
-avahi_service_resolver_callback (AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt, void *user_data)
-{
+static void avahi_service_resolver_callback(
+ AvahiServiceResolver *r,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const char *name,
+ const char *type,
+ const char *domain,
+ const char *host_name,
+ const AvahiAddress *a,
+ uint16_t port,
+ AvahiStringList *txt,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
char addr[64];
char *txtr;
if (event == AVAHI_RESOLVER_TIMEOUT)
}
avahi_address_snprint (addr, sizeof (addr), a);
txtr = avahi_string_list_to_string (txt);
- printf ("SERVICE-RESOLVER: Callback on ServiceResolver, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), host_name (%s), address (%s), port (%d), txtdata (%s), data(%s)\n", interface, protocol, event, name, type, domain, host_name, addr, port, txtr, (char*)user_data);
+ printf ("SERVICE-RESOLVER: Callback on ServiceResolver, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), host_name (%s), address (%s), port (%d), txtdata (%s), data(%s)\n", interface, protocol, event, name, type, domain, host_name, addr, port, txtr, (char*)userdata);
avahi_free(txtr);
}
-static void
-avahi_service_browser_callback (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *user_data)
-{
+static void avahi_service_browser_callback (
+ AvahiServiceBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *name,
+ const char *type,
+ const char *domain,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
AvahiServiceResolver *sr;
- printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name, type, domain, (char*)user_data);
+ printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name, type, domain, (char*)userdata);
if (b && name)
{
- sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AF_UNSPEC, avahi_service_resolver_callback, "xxXXxx");
+ sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_service_resolver_callback, "xxXXxx");
printf("New service resolver %p\n", (void*) sr);
}
}
-static void
-avahi_service_type_browser_callback (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *user_data)
-{
- printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type, domain, (char*)user_data);
+static void avahi_service_type_browser_callback (
+ AvahiServiceTypeBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *type,
+ const char *domain,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
+ printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type, domain, (char*)userdata);
}
-static void
-avahi_address_resolver_callback (AvahiAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiProtocol aprotocol, const AvahiAddress *address, const char *name, void *userdata)
-{
+static void avahi_address_resolver_callback (
+ AvahiAddressResolver *r,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ AvahiProtocol aprotocol,
+ const AvahiAddress *address,
+ const char *name,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
char addr[64];
if (event == AVAHI_RESOLVER_TIMEOUT)
{
printf ("ADDRESS-RESOLVER: Callback on AddressResolver, interface (%d), protocol (%d), even (%d), aprotocol (%d), address (%s), name (%s), data(%s)\n", interface, protocol, event, aprotocol, addr, name, (char*) userdata);
}
-static void
-avahi_host_name_resolver_callback (AvahiHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const AvahiAddress *a, void *user_data)
-{
+static void avahi_host_name_resolver_callback (
+ AvahiHostNameResolver *r,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const char *name,
+ const AvahiAddress *a,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
AvahiClient *client;
AvahiAddressResolver *ar;
char addr[64];
return;
}
client = avahi_host_name_resolver_get_client (r);
- ar = avahi_address_resolver_new_a (client, interface, protocol, a, avahi_address_resolver_callback, "omghai6u");
+ ar = avahi_address_resolver_new_a (client, interface, protocol, a, 0, avahi_address_resolver_callback, "omghai6u");
if (ar)
{
printf ("Succesfully created address resolver object\n");
printf ("Failed to create AddressResolver\n");
}
avahi_address_snprint (addr, sizeof (addr), a);
- printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, interface (%d), protocol (%d), event (%d), name (%s), address (%s), data (%s)\n", interface, protocol, event, name, addr, (char*)user_data);
+ printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, interface (%d), protocol (%d), event (%d), name (%s), address (%s), data (%s)\n", interface, protocol, event, name, addr, (char*)userdata);
}
static void test_free_domain_browser(AvahiTimeout *timeout, void* userdata)
{
printf ("Resetting entry group\n");
avahi_entry_group_reset (g);
- avahi_entry_group_add_service (g, AVAHI_IF_UNSPEC, AF_UNSPEC, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar2", NULL);
+ avahi_entry_group_add_service (g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar2", NULL);
avahi_entry_group_commit (g);
}
printf("Sucessfully created entry group %p\n", (void*) group);
- avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AF_UNSPEC, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL);
+ avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL);
avahi_entry_group_commit (group);
- domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AF_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, avahi_domain_browser_callback, "omghai3u");
+ domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, "omghai3u");
if (domain == NULL)
printf ("Failed to create domain browser object\n");
else
printf ("Sucessfully created domain browser %p\n", (void*) domain);
- st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AF_UNSPEC, "", avahi_service_type_browser_callback, "omghai3u");
+ st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, avahi_service_type_browser_callback, "omghai3u");
if (st == NULL)
printf ("Failed to create service type browser object\n");
else
printf ("Sucessfully created service type browser %p\n", (void*) st);
- sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AF_UNSPEC, "_http._tcp", "", avahi_service_browser_callback, "omghai3u");
+ sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, avahi_service_browser_callback, "omghai3u");
if (sb == NULL)
printf ("Failed to create service browser object\n");
else
printf ("Sucessfully created service browser %p\n", (void*) sb);
- hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AF_UNSPEC, "ecstasy.local", AF_UNSPEC, avahi_host_name_resolver_callback, "omghai4u");
+ hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_PROTO_UNSPEC, 0, avahi_host_name_resolver_callback, "omghai4u");
if (hnr == NULL)
printf ("Failed to create hostname resolver object\n");
else
return avahi_domain_browser_event(client, AVAHI_BROWSER_NEW, message);
else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_REMOVE, message);
+ else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted"))
+ 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);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_NEW, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_REMOVE, message);
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted"))
+ 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);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew"))
return avahi_service_browser_event (client, AVAHI_BROWSER_NEW, message);
else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove"))
return avahi_service_browser_event (client, AVAHI_BROWSER_REMOVE, message);
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted"))
+ 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);
return DBUS_HANDLER_RESULT_HANDLED;
typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
/** The function prototype for the callback of an AvahiDomainBrowser */
-typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
+typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void *userdata);
/** The function prototype for the callback of an AvahiServiceBrowser */
-typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
+typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata);
/** The function prototype for the callback of an AvahiServiceTypeBrowser */
-typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
+typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata);
/** The function prototype for the callback of an AvahiServiceResolver */
typedef void (*AvahiServiceResolverCallback) (
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
+ AvahiLookupResultFlags flags,
void *userdata);
/** The function prototype for the callback of an AvahiHostNameResolver */
AvahiResolverEvent event,
const char *name,
const AvahiAddress *a,
+ AvahiLookupResultFlags flags,
void *userdata);
/** The function prototype for the callback of an AvahiAddressResolver */
AvahiProtocol aprotocol,
const AvahiAddress *a,
const char *name,
+ AvahiLookupResultFlags flags,
void *userdata);
/** Creates a new client instance */
va_list va);
/** Browse for domains on the local network */
-AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- const char *domain,
- AvahiDomainBrowserType btype,
- AvahiDomainBrowserCallback callback,
- void *userdata);
+AvahiDomainBrowser* avahi_domain_browser_new (
+ AvahiClient *client,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ const char *domain,
+ AvahiDomainBrowserType btype,
+ AvahiLookupFlags flags,
+ AvahiDomainBrowserCallback callback,
+ void *userdata);
/** Get the parent client of an AvahiDomainBrowser object */
AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
/** Browse for service types on the local network */
AvahiServiceTypeBrowser* avahi_service_type_browser_new (
- AvahiClient *client,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- const char *domain,
- AvahiServiceTypeBrowserCallback callback,
- void *userdata);
+ AvahiClient *client,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ const char *domain,
+ AvahiLookupFlags flags,
+ AvahiServiceTypeBrowserCallback callback,
+ void *userdata);
/** Get the parent client of an AvahiServiceTypeBrowser object */
AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
/** Browse for services of a type on the local network */
AvahiServiceBrowser* avahi_service_browser_new (
- AvahiClient *client,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- const char *type,
- const char *domain,
- AvahiServiceBrowserCallback callback,
- void *userdata);
+ AvahiClient *client,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ const char *type,
+ const char *domain,
+ AvahiLookupFlags flags,
+ AvahiServiceBrowserCallback callback,
+ void *userdata);
/** Get the parent client of an AvahiServiceBrowser object */
AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
const char *type,
const char *domain,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiServiceResolverCallback callback,
void *userdata);
AvahiProtocol protocol,
const char *name,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiHostNameResolverCallback callback,
void *userdata);
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *address,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata);
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *a,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata);
if (event == AVAHI_RESOLVER_FOUND) {
int j;
- int32_t interface;
- AvahiProtocol protocol, aprotocol;
+ int32_t interface, flags, protocol, aprotocol;
char *name, *type, *domain, *host, *address;
uint16_t port;
DBusMessageIter iter, sub;
DBUS_TYPE_UINT16, &port,
DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
+
fprintf(stderr, "Failed to parse resolver event.\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");
+ fprintf(stderr, "Error parsing service resolving message\n");
goto fail;
}
assert(at == DBUS_TYPE_ARRAY);
if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
- fprintf(stderr, "Error parsing service resolving message");
+ fprintf(stderr, "Error parsing service resolving message\n");
goto fail;
}
dbus_message_iter_next(&sub);
}
+ dbus_message_iter_next(&iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) {
+ fprintf(stderr, "Failed to parse resolver event. XXX %i\n", dbus_message_iter_get_arg_type(&iter));
+ goto fail;
+ }
+
+ 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;
}
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, &a, port, strlst, 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 {
- assert(event == AVAHI_RESOLVER_TIMEOUT);
-
- r->callback(r, (AvahiIfIndex) 0, (AvahiProtocol) 0, AVAHI_RESOLVER_TIMEOUT, NULL, NULL, NULL, NULL, NULL, 0, NULL, r->userdata);
- }
+ } else
+ r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, r->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
const char *type,
const char *domain,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiServiceResolverCallback callback,
void *userdata) {
DBusError error;
AvahiServiceResolver *r;
DBusMessage *message = NULL, *reply = NULL;
- int32_t i_interface, i_protocol, i_aprotocol;
+ int32_t i_interface, i_protocol, i_aprotocol, i_flags;
char *path;
assert(client);
- assert(name);
assert(type);
if (!domain)
domain = "";
+
+ if (!name)
+ name = "";
dbus_error_init (&error);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
- i_aprotocol = aprotocol;
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_aprotocol = (int32_t) aprotocol;
+ i_flags = (int32_t) flags;
if (!(dbus_message_append_args(
message,
DBUS_TYPE_STRING, &type,
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_INT32, &i_aprotocol,
+ DBUS_TYPE_INT32, &i_flags,
DBUS_TYPE_INVALID))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
goto fail;
if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface;
- AvahiProtocol protocol, aprotocol;
+ int32_t interface, protocol, aprotocol, flags;
char *name, *address;
AvahiAddress a;
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INT32, &aprotocol,
DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INT32, &flags,
DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, r->userdata);
-
- } else {
+ r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, flags, r->userdata);
- assert(event == AVAHI_RESOLVER_TIMEOUT);
-
- r->callback(r, (AvahiIfIndex) 0, (AvahiProtocol) 0, AVAHI_RESOLVER_TIMEOUT, NULL, NULL, r->userdata);
- }
+ } else
+ r->callback(r, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, NULL, 0, r->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
AvahiProtocol protocol,
const char *name,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiHostNameResolverCallback callback,
void *userdata) {
DBusError error;
AvahiHostNameResolver *r;
DBusMessage *message = NULL, *reply = NULL;
- int32_t i_interface, i_protocol, i_aprotocol;
+ int32_t i_interface, i_protocol, i_aprotocol, i_flags;
char *path;
assert(client);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
- i_aprotocol = aprotocol;
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_aprotocol = (int32_t) aprotocol;
+ i_flags = (int32_t) flags;
if (!(dbus_message_append_args(
message,
DBUS_TYPE_INT32, &i_protocol,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INT32, &i_aprotocol,
+ DBUS_TYPE_INT32, &i_flags,
DBUS_TYPE_INVALID))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
goto fail;
if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface;
- AvahiProtocol protocol, aprotocol;
+ int32_t interface, protocol, aprotocol, flags;
char *name, *address;
AvahiAddress a;
DBUS_TYPE_INT32, &aprotocol,
DBUS_TYPE_STRING, &address,
DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INT32, &flags,
DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
- r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, (AvahiProtocol) aprotocol, &a, name, r->userdata);
- } else {
-
- assert(event == AVAHI_RESOLVER_TIMEOUT);
-
- r->callback(r, (AvahiIfIndex) 0, (AvahiProtocol) 0, AVAHI_RESOLVER_TIMEOUT, (AvahiProtocol) 0, NULL, NULL, r->userdata);
- }
+ 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;
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *a,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata) {
return NULL;
}
- return avahi_address_resolver_new (
+ return avahi_address_resolver_new(
client, interface, protocol,
- addr,
+ addr, flags,
callback, userdata);
}
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *address,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata) {
DBusError error;
AvahiAddressResolver *r;
DBusMessage *message = NULL, *reply = NULL;
- int32_t i_interface;
- AvahiProtocol i_protocol;
+ int32_t i_interface, i_protocol, i_flags;
char *path;
assert(client);
goto fail;
}
- i_interface = interface;
- i_protocol = protocol;
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ i_flags = (int32_t) flags;
if (!(dbus_message_append_args(
message,
DBUS_TYPE_INT32, &i_interface,
DBUS_TYPE_INT32, &i_protocol,
DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INT32, &i_flags,
DBUS_TYPE_INVALID))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
--- /dev/null
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <avahi-client/client.h>
+#include <avahi-common/error.h>
+#include <avahi-common/simple-watch.h>
+#include <avahi-common/malloc.h>
+
+static void callback(
+ AvahiServiceResolver *r,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const char *name,
+ const char *type,
+ const char *domain,
+ const char *host_name,
+ const AvahiAddress *a,
+ uint16_t port,
+ AvahiStringList *txt,
+ AvahiLookupResultFlags flags,
+ void *userdata) {
+
+ fprintf(stderr, "%i name=%s type=%s domain=%s host=%s\n", event, name, type, domain, host_name);
+}
+
+int main(int argc, char *argv[]) {
+
+ AvahiSimplePoll *simple_poll;
+ const AvahiPoll *poll_api;
+ AvahiClient *client;
+ AvahiServiceResolver *r;
+
+ simple_poll = avahi_simple_poll_new();
+ assert(simple_poll);
+
+ poll_api = avahi_simple_poll_get(simple_poll);
+ assert(poll_api);
+
+ client = avahi_client_new(poll_api, NULL, NULL, NULL);
+ assert(client);
+
+ r = avahi_service_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, "_domain._udp", "0pointer.de", AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_NO_TXT, callback, simple_poll);
+ assert(r);
+
+ for (;;)
+ if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
+ break;
+
+ avahi_client_free(client);
+ avahi_simple_poll_free(simple_poll);
+
+ return 0;
+}