summaryrefslogtreecommitdiffstats
path: root/announce.c
diff options
context:
space:
mode:
Diffstat (limited to 'announce.c')
-rw-r--r--announce.c194
1 files changed, 97 insertions, 97 deletions
diff --git a/announce.c b/announce.c
index 4be60b8..538ba2e 100644
--- a/announce.c
+++ b/announce.c
@@ -1,68 +1,68 @@
#include "announce.h"
#include "util.h"
-#define FLX_ANNOUNCEMENT_JITTER_MSEC 250
-#define FLX_PROBE_JITTER_MSEC 250
-#define FLX_PROBE_INTERVAL_MSEC 250
+#define AVAHI_ANNOUNCEMENT_JITTER_MSEC 250
+#define AVAHI_PROBE_JITTER_MSEC 250
+#define AVAHI_PROBE_INTERVAL_MSEC 250
-static void remove_announcement(flxServer *s, flxAnnouncement *a) {
+static void remove_announcement(AvahiServer *s, AvahiAnnouncement *a) {
g_assert(s);
g_assert(a);
if (a->time_event)
- flx_time_event_queue_remove(s->time_event_queue, a->time_event);
+ avahi_time_event_queue_remove(s->time_event_queue, a->time_event);
- FLX_LLIST_REMOVE(flxAnnouncement, by_interface, a->interface->announcements, a);
- FLX_LLIST_REMOVE(flxAnnouncement, by_entry, a->entry->announcements, a);
+ AVAHI_LLIST_REMOVE(AvahiAnnouncement, by_interface, a->interface->announcements, a);
+ AVAHI_LLIST_REMOVE(AvahiAnnouncement, by_entry, a->entry->announcements, a);
g_free(a);
}
-static void elapse_announce(flxTimeEvent *e, void *userdata);
+static void elapse_announce(AvahiTimeEvent *e, void *userdata);
-static void set_timeout(flxAnnouncement *a, const GTimeVal *tv) {
+static void set_timeout(AvahiAnnouncement *a, const GTimeVal *tv) {
g_assert(a);
if (!tv) {
if (a->time_event) {
- flx_time_event_queue_remove(a->server->time_event_queue, a->time_event);
+ avahi_time_event_queue_remove(a->server->time_event_queue, a->time_event);
a->time_event = NULL;
}
} else {
if (a->time_event)
- flx_time_event_queue_update(a->server->time_event_queue, a->time_event, tv);
+ avahi_time_event_queue_update(a->server->time_event_queue, a->time_event, tv);
else
- a->time_event = flx_time_event_queue_add(a->server->time_event_queue, tv, elapse_announce, a);
+ a->time_event = avahi_time_event_queue_add(a->server->time_event_queue, tv, elapse_announce, a);
}
}
-static void next_state(flxAnnouncement *a);
+static void next_state(AvahiAnnouncement *a);
-void flx_entry_group_check_probed(flxEntryGroup *g, gboolean immediately) {
- flxEntry *e;
+void avahi_entry_group_check_probed(AvahiEntryGroup *g, gboolean immediately) {
+ AvahiEntry *e;
g_assert(g);
g_assert(!g->dead);
/* Check whether all group members have been probed */
- if (g->state != FLX_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
+ if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
return;
- flx_entry_group_change_state(g, FLX_ENTRY_GROUP_ESTABLISHED);
+ avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
if (g->dead)
return;
for (e = g->entries; e; e = e->entries_next) {
- flxAnnouncement *a;
+ AvahiAnnouncement *a;
for (a = e->announcements; a; a = a->by_entry_next) {
- if (a->state != FLX_WAITING)
+ if (a->state != AVAHI_WAITING)
continue;
- a->state = FLX_ANNOUNCING;
+ a->state = AVAHI_ANNOUNCING;
if (immediately) {
/* Shortcut */
@@ -72,32 +72,32 @@ void flx_entry_group_check_probed(flxEntryGroup *g, gboolean immediately) {
} else {
GTimeVal tv;
a->n_iteration = 0;
- flx_elapse_time(&tv, 0, FLX_ANNOUNCEMENT_JITTER_MSEC);
+ avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
set_timeout(a, &tv);
}
}
}
}
-static void next_state(flxAnnouncement *a) {
+static void next_state(AvahiAnnouncement *a) {
g_assert(a);
/* g_message("%i -- %u", a->state, a->n_iteration); */
- if (a->state == FLX_WAITING) {
+ if (a->state == AVAHI_WAITING) {
g_assert(a->entry->group);
- flx_entry_group_check_probed(a->entry->group, TRUE);
+ avahi_entry_group_check_probed(a->entry->group, TRUE);
- } else if (a->state == FLX_PROBING) {
+ } else if (a->state == AVAHI_PROBING) {
if (a->n_iteration >= 4) {
/* Probing done */
gchar *t;
- g_message("Enough probes for record [%s]", t = flx_record_to_string(a->entry->record));
+ g_message("Enough probes for record [%s]", t = avahi_record_to_string(a->entry->record));
g_free(t);
if (a->entry->group) {
@@ -105,10 +105,10 @@ static void next_state(flxAnnouncement *a) {
a->entry->group->n_probing--;
}
- if (a->entry->group && a->entry->group->state == FLX_ENTRY_GROUP_REGISTERING)
- a->state = FLX_WAITING;
+ if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING)
+ a->state = AVAHI_WAITING;
else {
- a->state = FLX_ANNOUNCING;
+ a->state = AVAHI_ANNOUNCING;
a->n_iteration = 1;
}
@@ -117,31 +117,31 @@ static void next_state(flxAnnouncement *a) {
} else {
GTimeVal tv;
- flx_interface_post_probe(a->interface, a->entry->record, FALSE);
+ avahi_interface_post_probe(a->interface, a->entry->record, FALSE);
- flx_elapse_time(&tv, FLX_PROBE_INTERVAL_MSEC, 0);
+ avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0);
set_timeout(a, &tv);
a->n_iteration++;
}
- } else if (a->state == FLX_ANNOUNCING) {
+ } else if (a->state == AVAHI_ANNOUNCING) {
- flx_interface_post_response(a->interface, NULL, a->entry->record, a->entry->flags & FLX_ENTRY_UNIQUE, FALSE);
+ avahi_interface_post_response(a->interface, NULL, a->entry->record, a->entry->flags & AVAHI_ENTRY_UNIQUE, FALSE);
if (++a->n_iteration >= 4) {
gchar *t;
/* Announcing done */
- g_message("Enough announcements for record [%s]", t = flx_record_to_string(a->entry->record));
+ g_message("Enough announcements for record [%s]", t = avahi_record_to_string(a->entry->record));
g_free(t);
- a->state = FLX_ESTABLISHED;
+ a->state = AVAHI_ESTABLISHED;
set_timeout(a, NULL);
} else {
GTimeVal tv;
- flx_elapse_time(&tv, a->sec_delay*1000, FLX_ANNOUNCEMENT_JITTER_MSEC);
+ avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
if (a->n_iteration < 10)
a->sec_delay *= 2;
@@ -151,14 +151,14 @@ static void next_state(flxAnnouncement *a) {
}
}
-static void elapse_announce(flxTimeEvent *e, void *userdata) {
+static void elapse_announce(AvahiTimeEvent *e, void *userdata) {
g_assert(e);
next_state(userdata);
}
-flxAnnouncement *flx_get_announcement(flxServer *s, flxEntry *e, flxInterface *i) {
- flxAnnouncement *a;
+AvahiAnnouncement *avahi_get_announcement(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
+ AvahiAnnouncement *a;
g_assert(s);
g_assert(e);
@@ -171,8 +171,8 @@ flxAnnouncement *flx_get_announcement(flxServer *s, flxEntry *e, flxInterface *i
return NULL;
}
-static void new_announcement(flxServer *s, flxInterface *i, flxEntry *e) {
- flxAnnouncement *a;
+static void new_announcement(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
+ AvahiAnnouncement *a;
GTimeVal tv;
gchar *t;
@@ -181,59 +181,59 @@ static void new_announcement(flxServer *s, flxInterface *i, flxEntry *e) {
g_assert(e);
g_assert(!e->dead);
-/* g_message("NEW ANNOUNCEMENT: %s.%i [%s]", i->hardware->name, i->protocol, t = flx_record_to_string(e->record)); */
+/* g_message("NEW ANNOUNCEMENT: %s.%i [%s]", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record)); */
/* g_free(t); */
- if (!flx_interface_match(i, e->interface, e->protocol) || !i->announcing || !flx_entry_commited(e))
+ if (!avahi_interface_match(i, e->interface, e->protocol) || !i->announcing || !avahi_entry_commited(e))
return;
/* We don't want duplicate announcements */
- if (flx_get_announcement(s, e, i))
+ if (avahi_get_announcement(s, e, i))
return;
- a = g_new(flxAnnouncement, 1);
+ a = g_new(AvahiAnnouncement, 1);
a->server = s;
a->interface = i;
a->entry = e;
- if ((e->flags & FLX_ENTRY_UNIQUE) && !(e->flags & FLX_ENTRY_NOPROBE))
- a->state = FLX_PROBING;
- else if (!(e->flags & FLX_ENTRY_NOANNOUNCE)) {
+ if ((e->flags & AVAHI_ENTRY_UNIQUE) && !(e->flags & AVAHI_ENTRY_NOPROBE))
+ a->state = AVAHI_PROBING;
+ else if (!(e->flags & AVAHI_ENTRY_NOANNOUNCE)) {
- if (!e->group || e->group->state == FLX_ENTRY_GROUP_ESTABLISHED)
- a->state = FLX_ANNOUNCING;
+ if (!e->group || e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED)
+ a->state = AVAHI_ANNOUNCING;
else
- a->state = FLX_WAITING;
+ a->state = AVAHI_WAITING;
} else
- a->state = FLX_ESTABLISHED;
+ a->state = AVAHI_ESTABLISHED;
- g_message("New announcement on interface %s.%i for entry [%s] state=%i", i->hardware->name, i->protocol, t = flx_record_to_string(e->record), a->state);
+ g_message("New announcement on interface %s.%i for entry [%s] state=%i", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record), a->state);
g_free(t);
a->n_iteration = 1;
a->sec_delay = 1;
a->time_event = NULL;
- if (a->state == FLX_PROBING)
+ if (a->state == AVAHI_PROBING)
if (e->group)
e->group->n_probing++;
- FLX_LLIST_PREPEND(flxAnnouncement, by_interface, i->announcements, a);
- FLX_LLIST_PREPEND(flxAnnouncement, by_entry, e->announcements, a);
+ AVAHI_LLIST_PREPEND(AvahiAnnouncement, by_interface, i->announcements, a);
+ AVAHI_LLIST_PREPEND(AvahiAnnouncement, by_entry, e->announcements, a);
- if (a->state == FLX_PROBING) {
- flx_elapse_time(&tv, 0, FLX_PROBE_JITTER_MSEC);
+ if (a->state == AVAHI_PROBING) {
+ avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC);
set_timeout(a, &tv);
- } else if (a->state == FLX_ANNOUNCING) {
- flx_elapse_time(&tv, 0, FLX_ANNOUNCEMENT_JITTER_MSEC);
+ } else if (a->state == AVAHI_ANNOUNCING) {
+ avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
set_timeout(a, &tv);
}
}
-void flx_announce_interface(flxServer *s, flxInterface *i) {
- flxEntry *e;
+void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
+ AvahiEntry *e;
g_assert(s);
g_assert(i);
@@ -246,8 +246,8 @@ void flx_announce_interface(flxServer *s, flxInterface *i) {
new_announcement(s, i, e);
}
-static void announce_walk_callback(flxInterfaceMonitor *m, flxInterface *i, gpointer userdata) {
- flxEntry *e = userdata;
+static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
+ AvahiEntry *e = userdata;
g_assert(m);
g_assert(i);
@@ -257,100 +257,100 @@ static void announce_walk_callback(flxInterfaceMonitor *m, flxInterface *i, gpoi
new_announcement(m->server, i, e);
}
-void flx_announce_entry(flxServer *s, flxEntry *e) {
+void avahi_announce_entry(AvahiServer *s, AvahiEntry *e) {
g_assert(s);
g_assert(e);
g_assert(!e->dead);
- flx_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
+ avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
}
-void flx_announce_group(flxServer *s, flxEntryGroup *g) {
- flxEntry *e;
+void avahi_announce_group(AvahiServer *s, AvahiEntryGroup *g) {
+ AvahiEntry *e;
g_assert(s);
g_assert(g);
for (e = g->entries; e; e = e->by_group_next)
if (!e->dead)
- flx_announce_entry(s, e);
+ avahi_announce_entry(s, e);
}
-gboolean flx_entry_registered(flxServer *s, flxEntry *e, flxInterface *i) {
- flxAnnouncement *a;
+gboolean avahi_entry_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
+ AvahiAnnouncement *a;
g_assert(s);
g_assert(e);
g_assert(i);
g_assert(!e->dead);
- if (!(a = flx_get_announcement(s, e, i)))
+ if (!(a = avahi_get_announcement(s, e, i)))
return FALSE;
- return a->state == FLX_ANNOUNCING || a->state == FLX_ESTABLISHED;
+ return a->state == AVAHI_ANNOUNCING || a->state == AVAHI_ESTABLISHED;
}
-gboolean flx_entry_registering(flxServer *s, flxEntry *e, flxInterface *i) {
- flxAnnouncement *a;
+gboolean avahi_entry_registering(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
+ AvahiAnnouncement *a;
g_assert(s);
g_assert(e);
g_assert(i);
g_assert(!e->dead);
- if (!(a = flx_get_announcement(s, e, i)))
+ if (!(a = avahi_get_announcement(s, e, i)))
return FALSE;
- return a->state == FLX_PROBING || a->state == FLX_WAITING;
+ return a->state == AVAHI_PROBING || a->state == AVAHI_WAITING;
}
-static flxRecord *make_goodbye_record(flxRecord *r) {
+static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
/* gchar *t; */
- flxRecord *g;
+ AvahiRecord *g;
g_assert(r);
-/* g_message("Preparing goodbye for record [%s]", t = flx_record_to_string(r)); */
+/* g_message("Preparing goodbye for record [%s]", t = avahi_record_to_string(r)); */
/* g_free(t); */
- g = flx_record_copy(r);
+ g = avahi_record_copy(r);
g_assert(g->ref == 1);
g->ttl = 0;
return g;
}
-static void send_goodbye_callback(flxInterfaceMonitor *m, flxInterface *i, gpointer userdata) {
- flxEntry *e = userdata;
- flxRecord *g;
+static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
+ AvahiEntry *e = userdata;
+ AvahiRecord *g;
g_assert(m);
g_assert(i);
g_assert(e);
g_assert(!e->dead);
- if (!flx_interface_match(i, e->interface, e->protocol))
+ if (!avahi_interface_match(i, e->interface, e->protocol))
return;
- if (e->flags & FLX_ENTRY_NOANNOUNCE)
+ if (e->flags & AVAHI_ENTRY_NOANNOUNCE)
return;
- if (!flx_entry_registered(m->server, e, i))
+ if (!avahi_entry_registered(m->server, e, i))
return;
g = make_goodbye_record(e->record);
- flx_interface_post_response(i, NULL, g, e->flags & FLX_ENTRY_UNIQUE, TRUE);
- flx_record_unref(g);
+ avahi_interface_post_response(i, NULL, g, e->flags & AVAHI_ENTRY_UNIQUE, TRUE);
+ avahi_record_unref(g);
}
-void flx_goodbye_interface(flxServer *s, flxInterface *i, gboolean goodbye) {
+void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, gboolean goodbye) {
g_assert(s);
g_assert(i);
/* g_message("goodbye interface: %s.%u", i->hardware->name, i->protocol); */
- if (goodbye && flx_interface_relevant(i)) {
- flxEntry *e;
+ if (goodbye && avahi_interface_relevant(i)) {
+ AvahiEntry *e;
for (e = s->entries; e; e = e->entries_next)
if (!e->dead)
@@ -364,14 +364,14 @@ void flx_goodbye_interface(flxServer *s, flxInterface *i, gboolean goodbye) {
}
-void flx_goodbye_entry(flxServer *s, flxEntry *e, gboolean goodbye) {
+void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, gboolean goodbye) {
g_assert(s);
g_assert(e);
/* g_message("goodbye entry: %p", e); */
if (goodbye && !e->dead)
- flx_interface_monitor_walk(s->monitor, 0, AF_UNSPEC, send_goodbye_callback, e);
+ avahi_interface_monitor_walk(s->monitor, 0, AF_UNSPEC, send_goodbye_callback, e);
while (e->announcements)
remove_announcement(s, e->announcements);
@@ -380,8 +380,8 @@ void flx_goodbye_entry(flxServer *s, flxEntry *e, gboolean goodbye) {
}
-void flx_goodbye_all(flxServer *s, gboolean goodbye) {
- flxEntry *e;
+void avahi_goodbye_all(AvahiServer *s, gboolean goodbye) {
+ AvahiEntry *e;
g_assert(s);
@@ -389,7 +389,7 @@ void flx_goodbye_all(flxServer *s, gboolean goodbye) {
for (e = s->entries; e; e = e->entries_next)
if (!e->dead)
- flx_goodbye_entry(s, e, goodbye);
+ avahi_goodbye_entry(s, e, goodbye);
/* g_message("goodbye all done"); */