]> git.meshlink.io Git - catta/blobdiff - avahi-client/client-test.c
* remove AVAHI_PUBLISH_IS_PROXY, it was a bad idea
[catta] / avahi-client / client-test.c
index 14b9e84d3e37700424ad2fce805c03c0577886f2..f9913e624f276a86d8d45085a6eccc5ed7f87ab0 100644 (file)
@@ -33,6 +33,7 @@
 #include <avahi-common/error.h>
 #include <avahi-common/simple-watch.h>
 #include <avahi-common/malloc.h>
+#include <avahi-common/timeval.h>
 
 static const AvahiPoll *poll_api = NULL;
 static AvahiSimplePoll *simple_poll = NULL;
@@ -45,6 +46,11 @@ static void avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState
     printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata);
 }
 
+static void avahi_entry_group2_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
+    printf ("ENTRY-GROUP2: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata);
+}
+
+
 static void avahi_domain_browser_callback(
     AvahiDomainBrowser *b,
     AvahiIfIndex interface,
@@ -124,7 +130,6 @@ static void avahi_address_resolver_callback (
     AvahiIfIndex interface,
     AvahiProtocol protocol,
     AvahiResolverEvent event,
-    AvahiProtocol aprotocol,
     const AvahiAddress *address,
     const char *name,
     AvahiLookupResultFlags flags,
@@ -136,7 +141,7 @@ static void avahi_address_resolver_callback (
         return;
     }
     avahi_address_snprint (addr, sizeof (addr), address);
-    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);
+    printf ("ADDRESS-RESOLVER: Callback on AddressResolver, interface (%d), protocol (%d), even (%d), address (%s), name (%s), data(%s)\n", interface, protocol, event, addr, name, (char*) userdata);
 }
 
 static void avahi_host_name_resolver_callback (
@@ -158,7 +163,7 @@ static void avahi_host_name_resolver_callback (
         return;
     }
     client = avahi_host_name_resolver_get_client (r);
-    ar = avahi_address_resolver_new_a (client, interface, protocol, a, 0, avahi_address_resolver_callback, "omghai6u");
+    ar = avahi_address_resolver_new(client, interface, protocol, a, 0, avahi_address_resolver_callback, "omghai6u");
     if (ar)
     {
         printf ("Succesfully created address resolver object\n");
@@ -209,11 +214,12 @@ static void terminate(AvahiTimeout *timeout, void *userdata) {
 
 int main (int argc, char *argv[]) {
     AvahiClient *avahi;
-    AvahiEntryGroup *group;
+    AvahiEntryGroup *group, *group2;
     AvahiDomainBrowser *domain;
     AvahiServiceBrowser *sb;
     AvahiServiceTypeBrowser *st;
     AvahiHostNameResolver *hnr;
+    AvahiAddress *aar;
     const char *ret;
     int error;
     uint32_t cookie;
@@ -280,6 +286,22 @@ int main (int argc, char *argv[]) {
     else
         printf ("Successfully created hostname resolver object\n");
 
+    aar = avahi_address_parse ("224.0.0.251", AF_UNSPEC, aar);
+    if (aar == NULL) {
+        printf ("failed to create address object\n");
+    } else {
+        group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, "omghai222");
+        if ((error = avahi_entry_group_add_address (group2, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "test-mdns.local.", aar)) < 0)
+        {
+            printf ("*** failed to add address to entry group: %s\n", avahi_strerror (error));
+            avahi_entry_group_free (group2);
+        } else {
+            printf ("*** success, added address\n");
+            avahi_entry_group_commit (group2);
+        }
+        
+    }
+
 
     avahi_elapse_time(&tv, 8000, 0);
     poll_api->timeout_new(poll_api, &tv, test_entry_group_reset, group);