From: Lennart Poettering Date: Sat, 27 Aug 2005 18:25:29 +0000 (+0000) Subject: * fix some small issues in client-test X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=5dcaa3101f1088bb33d770a43191f3f0e3397896;p=catta * fix some small issues in client-test * add protocol argument avahi_adress_resolver_new_a() git-svn-id: file:///home/lennart/svn/public/avahi/trunk@458 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 037867d..67b977a 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -86,7 +86,7 @@ avahi_service_type_browser_callback (AvahiServiceTypeBrowser *b, AvahiIfIndex in } static void -avahi_address_resolver_callback (AvahiAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiProtocol aprotocol, const AvahiAddress *address, const char *name, const char *userdata) +avahi_address_resolver_callback (AvahiAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiProtocol aprotocol, const AvahiAddress *address, const char *name, void *userdata) { char addr[64]; if (event == AVAHI_RESOLVER_TIMEOUT) @@ -95,7 +95,7 @@ avahi_address_resolver_callback (AvahiAddressResolver *r, AvahiIfIndex interface avahi_address_resolver_free (r); return; } - avahi_address_snprint (&addr, sizeof (addr), address); + avahi_address_snprint (addr, sizeof (addr), address); printf ("Callback on AddressResolver, interface (%d), protocol (%d), even (%d), aprotocol (%d), address (%s), name (%s), data(%s)\n", interface, protocol, event, aprotocol, addr, name); } @@ -113,14 +113,14 @@ 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, AVAHI_IF_UNSPEC, a, avahi_address_resolver_callback, "omghai6u"); + ar = avahi_address_resolver_new_a (client, interface, protocol, a, avahi_address_resolver_callback, "omghai6u"); if (ar) { printf ("Succesfully created address resolver object\n"); } else { printf ("Failed to create AddressResolver\n"); } - avahi_address_snprint (&addr, sizeof (addr), a); + avahi_address_snprint (addr, sizeof (addr), a); printf ("Callback on HostNameResolver, interface (%d), protocol (%d), event (%d), name (%s), address (%s), data (%s)\n", interface, protocol, event, name, addr, (char*)user_data); } static void test_free_domain_browser(AvahiTimeout *timeout, void* userdata) diff --git a/avahi-client/client.h b/avahi-client/client.h index c544c44..9d57c50 100644 --- a/avahi-client/client.h +++ b/avahi-client/client.h @@ -311,7 +311,7 @@ int avahi_host_name_resolver_free(AvahiHostNameResolver *r); /** Block until the resolving is complete */ int avahi_host_name_resolver_block(AvahiHostNameResolver *r); -/** Create a new address resolver object from an address string. Set protocol to AF_UNSPEC for protocol detection. */ +/** Create a new address resolver object from an address string. Set aprotocol to AF_UNSPEC for protocol detection. */ AvahiAddressResolver * avahi_address_resolver_new( AvahiClient *client, AvahiIfIndex interface, @@ -324,6 +324,7 @@ AvahiAddressResolver * avahi_address_resolver_new( AvahiAddressResolver* avahi_address_resolver_new_a( AvahiClient *client, AvahiIfIndex interface, + AvahiProtocol protocol, const AvahiAddress *a, AvahiAddressResolverCallback callback, void *userdata); diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c index aaff502..c564a97 100644 --- a/avahi-client/resolver.c +++ b/avahi-client/resolver.c @@ -517,6 +517,7 @@ int avahi_host_name_resolver_block(AvahiHostNameResolver *r) { AvahiAddressResolver * avahi_address_resolver_new_a( AvahiClient *client, AvahiIfIndex interface, + AvahiProtocol protocol, const AvahiAddress *a, AvahiAddressResolverCallback callback, void *userdata) { @@ -525,11 +526,15 @@ AvahiAddressResolver * avahi_address_resolver_new_a( assert (a); - avahi_address_snprint (addr, sizeof (addr), a); + if (!avahi_address_snprint (addr, sizeof (addr), a)) { + avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); + return NULL; + } - return avahi_address_resolver_new (client, interface, - a->family, addr, - callback, userdata); + return avahi_address_resolver_new ( + client, interface, protocol, + addr, + callback, userdata); } AvahiAddressResolver * avahi_address_resolver_new(