diff options
author | Trent Lloyd <lathiat@bur.st> | 2005-08-26 18:25:39 +0000 |
---|---|---|
committer | Trent Lloyd <lathiat@bur.st> | 2005-08-26 18:25:39 +0000 |
commit | 45bf63f4c05690420fd2d701a6399550160aba02 (patch) | |
tree | bffef8a78a3c8d8063d98f8a2d9fa22c81e19379 /avahi-client/client-test.c | |
parent | ffa44c461dca3b61904b3b2cfe12c9e25b637ec4 (diff) |
* Implement the HostNameResolver in the avahi-client C api
* Add HostNameResolver and ServiceResolver to client-test
* Add get_client functions to all avahi-client browsers/resolvers
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@449 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-client/client-test.c')
-rw-r--r-- | avahi-client/client-test.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 5f7f030..4142172 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -53,8 +53,28 @@ avahi_domain_browser_callback (AvahiDomainBrowser *b, AvahiIfIndex interface, Av } 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) +{ + char addr[64]; + char *txtr; + if (event == AVAHI_RESOLVER_TIMEOUT) + { + printf ("ServiceResolver timed out\n"); + return; + } + avahi_address_snprint (addr, sizeof (addr), a); + txtr = avahi_string_list_to_string (txt); + printf ("XXX: 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); +} + +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) { + AvahiServiceResolver *sr; + 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"); + } printf ("XXX: Callback on %s, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", avahi_service_browser_get_dbus_path (b), interface, protocol, event, name, type, domain, (char*)user_data); } @@ -64,6 +84,20 @@ avahi_service_type_browser_callback (AvahiServiceTypeBrowser *b, AvahiIfIndex in printf ("XXX: Callback on %s, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", avahi_service_type_browser_get_dbus_path (b), interface, protocol, event, type, domain, (char*)user_data); } +static void +avahi_host_name_resolver_callback (AvahiHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const AvahiAddress *a, void *user_data) +{ + char addr[64]; + + if (event == AVAHI_RESOLVER_TIMEOUT) + { + printf ("XXX: Callback on HostNameResolver, timed out.\n"); + return; + } + avahi_address_snprint (addr, sizeof (addr), a); + printf ("XXX: 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) { AvahiServiceBrowser *b = userdata; @@ -101,6 +135,7 @@ int main (int argc, char *argv[]) { AvahiDomainBrowser *domain; AvahiServiceBrowser *sb; AvahiServiceTypeBrowser *st; + AvahiHostNameResolver *hnr; const char *ret; int error; struct timeval tv; @@ -157,6 +192,12 @@ int main (int argc, char *argv[]) { else printf ("Sucessfully created service browser, path %s\n", avahi_service_browser_get_dbus_path (sb)); + hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AF_UNSPEC, "hotbox.local", AF_UNSPEC, avahi_host_name_resolver_callback, "omghai4u"); + if (hnr == NULL) + printf ("Failed to create hostname resolver object\n"); + else + printf ("Successfully created hostname resolver object\n"); + avahi_elapse_time(&tv, 8000, 0); poll_api->timeout_new(poll_api, &tv, test_entry_group_reset, group); |