+/* g_message("%i -- %u", a->state, a->n_iteration); */
+
+ if (a->state == AVAHI_WAITING) {
+
+ g_assert(a->entry->group);
+
+ avahi_entry_group_check_probed(a->entry->group, TRUE);
+
+ } else if (a->state == AVAHI_PROBING) {
+
+ if (a->n_iteration >= 4) {
+ /* Probing done */
+
+ gchar *t;
+
+ g_message("Enough probes for record [%s]", t = avahi_record_to_string(a->entry->record));
+ g_free(t);
+
+ if (a->entry->group) {
+ g_assert(a->entry->group->n_probing);
+ a->entry->group->n_probing--;
+ }
+
+ if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING)
+ a->state = AVAHI_WAITING;
+ else {
+ a->state = AVAHI_ANNOUNCING;
+ a->n_iteration = 1;
+ }
+
+ set_timeout(a, NULL);
+ next_state(a);
+ } else {
+ GTimeVal tv;
+
+ avahi_interface_post_probe(a->interface, a->entry->record, FALSE);
+
+ avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0);
+ set_timeout(a, &tv);
+
+ a->n_iteration++;
+ }
+
+ } else if (a->state == AVAHI_ANNOUNCING) {
+
+ 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 = avahi_record_to_string(a->entry->record));
+ g_free(t);
+
+ a->state = AVAHI_ESTABLISHED;
+
+ set_timeout(a, NULL);
+ } else {
+ GTimeVal tv;
+ avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
+
+ if (a->n_iteration < 10)
+ a->sec_delay *= 2;
+
+ set_timeout(a, &tv);
+ }
+ }
+}
+
+static void elapse_announce(AvahiTimeEvent *e, void *userdata) {
+ g_assert(e);
+
+ next_state(userdata);
+}
+
+AvahiAnnouncement *avahi_get_announcement(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
+ AvahiAnnouncement *a;