X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fannounce.c;h=b66dadadb70cf831c017a29c1f00f4ec5dbb371d;hb=5e6703337b90bccb1713ef9cb1aa5f029d75698f;hp=f769e98f27a693067ce7f29c4ad050a9b5d73df7;hpb=e59d53a034f0cfdede9c439d1fd7e5f25aea5802;p=catta diff --git a/avahi-core/announce.c b/avahi-core/announce.c index f769e98..b66dada 100644 --- a/avahi-core/announce.c +++ b/avahi-core/announce.c @@ -28,6 +28,7 @@ #include "announce.h" #include "log.h" +#include "rr-util.h" #define AVAHI_ANNOUNCEMENT_JITTER_MSEC 250 #define AVAHI_PROBE_JITTER_MSEC 250 @@ -82,11 +83,11 @@ void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) { if (g->dead) return; - for (e = g->entries; e; e = e->entries_next) { + for (e = g->entries; e; e = e->by_group_next) { AvahiAnnouncer *a; for (a = e->announcers; a; a = a->by_entry_next) { - + if (a->state != AVAHI_WAITING) continue; @@ -110,8 +111,6 @@ void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) { static void next_state(AvahiAnnouncer *a) { assert(a); -/* avahi_log_debug("%i -- %u", a->state, a->n_iteration); */ - if (a->state == AVAHI_WAITING) { assert(a->entry->group); @@ -123,11 +122,6 @@ static void next_state(AvahiAnnouncer *a) { if (a->n_iteration >= 4) { /* Probing done */ -/* char *t; */ - -/* avahi_log_debug("Enough probes for record [%s]", t = avahi_record_to_string(a->entry->record)); */ -/* avahi_free(t); */ - if (a->entry->group) { assert(a->entry->group->n_probing); a->entry->group->n_probing--; @@ -164,12 +158,8 @@ static void next_state(AvahiAnnouncer *a) { avahi_server_generate_response(a->server, a->interface, NULL, NULL, 0, 0, 0); if (++a->n_iteration >= 4) { -/* char *t; */ /* Announcing done */ -/* avahi_log_debug("Enough announcements for record [%s]", t = avahi_record_to_string(a->entry->record)); */ -/* avahi_free(t); */ - a->state = AVAHI_ESTABLISHED; set_timeout(a, NULL); @@ -191,7 +181,7 @@ static void elapse_announce(AvahiTimeEvent *e, void *userdata) { next_state(userdata); } -AvahiAnnouncer *avahi_get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { +static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { AvahiAnnouncer *a; assert(s); @@ -205,7 +195,7 @@ AvahiAnnouncer *avahi_get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterfac return NULL; } -static void go_to_initial_state(AvahiAnnouncer *a, int immediately) { +static void go_to_initial_state(AvahiAnnouncer *a) { AvahiEntry *e; struct timeval tv; @@ -240,21 +230,17 @@ static void go_to_initial_state(AvahiAnnouncer *a, int immediately) { static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) { AvahiAnnouncer *a; -/* char *t; */ assert(s); assert(i); assert(e); assert(!e->dead); -/* avahi_log_debug("NEW ANNOUNCER: %s.%i [%s]", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record)); */ -/* avahi_free(t); */ - if (!avahi_interface_match(i, e->interface, e->protocol) || !i->announcing || !avahi_entry_is_commited(e)) return; /* We don't want duplicate announcers */ - if (avahi_get_announcer(s, e, i)) + if (get_announcer(s, e, i)) return; if ((!(a = avahi_new(AvahiAnnouncer, 1)))) { @@ -270,10 +256,7 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) { AVAHI_LLIST_PREPEND(AvahiAnnouncer, by_interface, i->announcers, a); AVAHI_LLIST_PREPEND(AvahiAnnouncer, by_entry, e->announcers, a); - go_to_initial_state(a, 0); - -/* avahi_log_debug("New announcer on interface %s.%i for entry [%s] state=%i", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record), a->state); */ -/* avahi_free(t); */ + go_to_initial_state(a); } void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) { @@ -328,7 +311,7 @@ int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) assert(i); assert(!e->dead); - if (!(a = avahi_get_announcer(s, e, i))) + if (!(a = get_announcer(s, e, i))) return 0; return @@ -345,10 +328,8 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { assert(i); assert(!e->dead); - if (!(a = avahi_get_announcer(s, e, i))) + if (!(a = get_announcer(s, e, i))) return 0; - -/* avahi_log_debug("state: %i", a->state); */ return a->state == AVAHI_PROBING || @@ -362,24 +343,20 @@ void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInt assert(e); assert(i); - if (!(a = avahi_get_announcer(s, e, i))) + if (!(a = get_announcer(s, e, i))) return; if (a->state == AVAHI_PROBING && a->entry->group) a->entry->group->n_probing--; - go_to_initial_state(a, 1); + go_to_initial_state(a); } static AvahiRecord *make_goodbye_record(AvahiRecord *r) { -/* char *t; */ AvahiRecord *g; assert(r); -/* avahi_log_debug("Preparing goodbye for record [%s]", t = avahi_record_to_string(r)); */ -/* avahi_free(t); */ - if (!(g = avahi_record_copy(r))) return NULL; /* OOM */ @@ -499,7 +476,7 @@ static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i assert(e); assert(!e->dead); - if (!(a = avahi_get_announcer(m->server, e, i))) + if (!(a = get_announcer(m->server, e, i))) return; reannounce(a); @@ -545,14 +522,3 @@ void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int re remove_announcer(s, e->announcers); } -void avahi_goodbye_all(AvahiServer *s, int send_goodbye, int remove) { - AvahiEntry *e; - - assert(s); - - for (e = s->entries; e; e = e->entries_next) - if (!e->dead) - avahi_goodbye_entry(s, e, send_goodbye, remove); - -} -