summaryrefslogtreecommitdiffstats
path: root/avahi-client
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-25 20:15:19 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-25 20:15:19 +0000
commit7da8bb6e9a1990413c943dcfd54c71d8744fcb00 (patch)
treed5d71f0a6a310415b66bf02d561f998964591ce8 /avahi-client
parent2c453196ee040e17e357f3431b0647391c88d616 (diff)
* fix some bugs
* update to current DBUS API * add test for resolving standalone SRV records git-svn-id: file:///home/lennart/svn/public/avahi/trunk@610 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-client')
-rw-r--r--avahi-client/Makefile.am8
-rw-r--r--avahi-client/browser.c119
-rw-r--r--avahi-client/client-test.c128
-rw-r--r--avahi-client/client.c37
-rw-r--r--avahi-client/client.h57
-rw-r--r--avahi-client/resolver.c95
-rw-r--r--avahi-client/srv-test.c79
7 files changed, 362 insertions, 161 deletions
diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am
index 77b8c35..57b8cb0 100644
--- a/avahi-client/Makefile.am
+++ b/avahi-client/Makefile.am
@@ -29,7 +29,9 @@ avahi_clientinclude_HEADERS = client.h
noinst_HEADERS = internal.h
-noinst_PROGRAMS = client-test
+noinst_PROGRAMS = \
+ client-test \
+ srv-test
lib_LTLIBRARIES = libavahi-client.la
@@ -47,4 +49,8 @@ client_test_SOURCES = client-test.c
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
diff --git a/avahi-client/browser.c b/avahi-client/browser.c
index 34a3601..1aaae8c 100644
--- a/avahi-client/browser.c
+++ b/avahi-client/browser.c
@@ -44,6 +44,7 @@ AvahiDomainBrowser* avahi_domain_browser_new(
AvahiProtocol protocol,
const char *domain,
AvahiDomainBrowserType btype,
+ AvahiLookupFlags flags,
AvahiDomainBrowserCallback callback,
void *userdata) {
@@ -51,7 +52,7 @@ AvahiDomainBrowser* avahi_domain_browser_new(
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);
@@ -83,8 +84,9 @@ AvahiDomainBrowser* avahi_domain_browser_new(
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(
@@ -93,6 +95,7 @@ AvahiDomainBrowser* avahi_domain_browser_new(
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;
@@ -171,8 +174,8 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE
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);
@@ -189,18 +192,21 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE
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;
@@ -215,6 +221,7 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new(
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
+ AvahiLookupFlags flags,
AvahiServiceTypeBrowserCallback callback,
void *userdata) {
@@ -222,7 +229,7 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new(
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);
@@ -254,14 +261,16 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new(
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;
@@ -339,8 +348,8 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr
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);
@@ -357,19 +366,22 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr
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;
@@ -386,6 +398,7 @@ AvahiServiceBrowser* avahi_service_browser_new(
AvahiProtocol protocol,
const char *type,
const char *domain,
+ AvahiLookupFlags flags,
AvahiServiceBrowserCallback callback,
void *userdata) {
@@ -393,7 +406,7 @@ AvahiServiceBrowser* avahi_service_browser_new(
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);
@@ -426,9 +439,9 @@ AvahiServiceBrowser* avahi_service_browser_new(
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,
@@ -436,6 +449,7 @@ AvahiServiceBrowser* avahi_service_browser_new(
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;
@@ -513,8 +527,8 @@ DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowser
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);
@@ -528,20 +542,23 @@ DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowser
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;
diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c
index 96c9f1e..24576dd 100644
--- a/avahi-client/client-test.c
+++ b/avahi-client/client-test.c
@@ -23,38 +23,52 @@
#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)
@@ -64,33 +78,56 @@ avahi_service_resolver_callback (AvahiServiceResolver *r, AvahiIfIndex interface
}
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)
{
@@ -101,9 +138,16 @@ avahi_address_resolver_callback (AvahiAddressResolver *r, AvahiIfIndex interface
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];
@@ -114,7 +158,7 @@ avahi_host_name_resolver_callback (AvahiHostNameResolver *r, AvahiIfIndex interf
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");
@@ -122,7 +166,7 @@ avahi_host_name_resolver_callback (AvahiHostNameResolver *r, AvahiIfIndex interf
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)
{
@@ -145,7 +189,7 @@ static void test_entry_group_reset (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);
}
@@ -199,30 +243,30 @@ int main (int argc, char *argv[]) {
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
diff --git a/avahi-client/client.c b/avahi-client/client.c
index f28d4e3..6df3e03 100644
--- a/avahi-client/client.c
+++ b/avahi-client/client.c
@@ -174,32 +174,67 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
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;
diff --git a/avahi-client/client.h b/avahi-client/client.h
index 0cafed3..4a915ac 100644
--- a/avahi-client/client.h
+++ b/avahi-client/client.h
@@ -88,13 +88,13 @@ typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, voi
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) (
@@ -109,6 +109,7 @@ typedef void (*AvahiServiceResolverCallback) (
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
+ AvahiLookupResultFlags flags,
void *userdata);
/** The function prototype for the callback of an AvahiHostNameResolver */
@@ -119,6 +120,7 @@ typedef void (*AvahiHostNameResolverCallback) (
AvahiResolverEvent event,
const char *name,
const AvahiAddress *a,
+ AvahiLookupResultFlags flags,
void *userdata);
/** The function prototype for the callback of an AvahiAddressResolver */
@@ -130,6 +132,7 @@ typedef void (*AvahiAddressResolverCallback) (
AvahiProtocol aprotocol,
const AvahiAddress *a,
const char *name,
+ AvahiLookupResultFlags flags,
void *userdata);
/** Creates a new client instance */
@@ -214,13 +217,15 @@ int avahi_entry_group_add_service_va(
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 *);
@@ -230,12 +235,13 @@ int avahi_domain_browser_free (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 *);
@@ -245,13 +251,14 @@ int avahi_service_type_browser_free (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 *);
@@ -268,6 +275,7 @@ AvahiServiceResolver * avahi_service_resolver_new(
const char *type,
const char *domain,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiServiceResolverCallback callback,
void *userdata);
@@ -284,6 +292,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new(
AvahiProtocol protocol,
const char *name,
AvahiProtocol aprotocol,
+ AvahiLookupFlags flags,
AvahiHostNameResolverCallback callback,
void *userdata);
@@ -299,6 +308,7 @@ AvahiAddressResolver * avahi_address_resolver_new(
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *address,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata);
@@ -308,6 +318,7 @@ AvahiAddressResolver* avahi_address_resolver_new_a(
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *a,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata);
diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c
index ddea755..f08ce77 100644
--- a/avahi-client/resolver.c
+++ b/avahi-client/resolver.c
@@ -63,8 +63,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
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;
@@ -83,6 +82,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
DBUS_TYPE_UINT16, &port,
DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
+
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
@@ -94,7 +94,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
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;
}
@@ -111,7 +111,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
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;
}
@@ -128,21 +128,27 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv
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;
@@ -162,21 +168,24 @@ AvahiServiceResolver * avahi_service_resolver_new(
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);
@@ -202,9 +211,10 @@ AvahiServiceResolver * avahi_service_resolver_new(
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,
@@ -214,6 +224,7 @@ AvahiServiceResolver * avahi_service_resolver_new(
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;
@@ -313,8 +324,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso
goto fail;
if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface;
- AvahiProtocol protocol, aprotocol;
+ int32_t interface, protocol, aprotocol, flags;
char *name, *address;
AvahiAddress a;
@@ -325,6 +335,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso
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");
@@ -337,14 +348,10 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso
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;
@@ -360,13 +367,14 @@ AvahiHostNameResolver * avahi_host_name_resolver_new(
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);
@@ -396,9 +404,10 @@ AvahiHostNameResolver * avahi_host_name_resolver_new(
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,
@@ -406,6 +415,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new(
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;
@@ -504,8 +514,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv
goto fail;
if (event == AVAHI_RESOLVER_FOUND) {
- int32_t interface;
- AvahiProtocol protocol, aprotocol;
+ int32_t interface, protocol, aprotocol, flags;
char *name, *address;
AvahiAddress a;
@@ -516,6 +525,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv
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");
@@ -528,13 +538,9 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv
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;
@@ -548,6 +554,7 @@ AvahiAddressResolver * avahi_address_resolver_new_a(
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *a,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata) {
@@ -560,9 +567,9 @@ AvahiAddressResolver * avahi_address_resolver_new_a(
return NULL;
}
- return avahi_address_resolver_new (
+ return avahi_address_resolver_new(
client, interface, protocol,
- addr,
+ addr, flags,
callback, userdata);
}
@@ -571,14 +578,14 @@ AvahiAddressResolver * avahi_address_resolver_new(
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);
@@ -607,14 +614,16 @@ AvahiAddressResolver * avahi_address_resolver_new(
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;
diff --git a/avahi-client/srv-test.c b/avahi-client/srv-test.c
new file mode 100644
index 0000000..1a453bc
--- /dev/null
+++ b/avahi-client/srv-test.c
@@ -0,0 +1,79 @@
+/* $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;
+}