#include <assert.h>
#include <avahi-client/client.h>
+#include <avahi-client/lookup.h>
+#include <avahi-client/publish.h>
+
#include <avahi-common/error.h>
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
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,
char addr[64];
char *txtr;
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("SERVICE-RESOLVER: ServiceResolver %p timed out (%s %s)\n", (void*) r, name, type);
return;
}
void *userdata) {
char addr[64];
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n");
return;
}
AvahiAddressResolver *ar;
char addr[64];
- if (event == AVAHI_RESOLVER_TIMEOUT)
- {
+ if (event == AVAHI_RESOLVER_FAILURE) {
printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n");
return;
}
avahi_entry_group_commit (g);
}
+static void test_entry_group_update(AvahiTimeout *timeout, void* userdata) {
+ AvahiEntryGroup *g = userdata;
+
+ printf ("Updating entry group\n");
+
+ avahi_entry_group_update_service_txt(g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, "foo=bar3", NULL);
+}
+
static void terminate(AvahiTimeout *timeout, void *userdata) {
avahi_simple_poll_quit(simple_poll);
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;
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 (ret));
+ 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);
+ avahi_elapse_time(&tv, 15000, 0);
+ poll_api->timeout_new(poll_api, &tv, test_entry_group_update, group);
avahi_elapse_time(&tv, 20000, 0);
poll_api->timeout_new(poll_api, &tv, test_free_entry_group, group);
avahi_elapse_time(&tv, 25000, 0);