X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=server.h;h=ba1af789f2b7b5dbc46446d96dff36372d7634cc;hb=7dce450bdc23ea306a61e00f914481e29ebcb176;hp=4134638dd6fd88d5dae95d787f9bf1142d4c076c;hpb=927f8b06fe3550f45c8d7b119acaa77d9b22888c;p=catta diff --git a/server.h b/server.h index 4134638..ba1af78 100644 --- a/server.h +++ b/server.h @@ -1,75 +1,79 @@ -#ifndef fooflxserverhfoo -#define fooflxserverhfoo +#ifndef fooAvahiserverhfoo +#define fooAvahiserverhfoo -#include "flx.h" +#include "Avahi.h" #include "iface.h" #include "prioq.h" +#include "llist.h" +#include "timeeventq.h" +#include "announce.h" +#include "subscribe.h" -struct _flxEntry; -typedef struct _flxEntry flxEntry; -struct _flxEntry { - flxRecord rr; - gint id; +struct _AvahiEntry { + AvahiServer *server; + AvahiEntryGroup *group; + + gboolean dead; + + AvahiEntryFlags flags; + AvahiRecord *record; gint interface; guchar protocol; - gboolean unique; - - flxEntry *next, *prev; - flxEntry *next_by_name, *prev_by_name; - flxEntry *next_by_id, *prev_by_id; + AVAHI_LLIST_FIELDS(AvahiEntry, entries); + AVAHI_LLIST_FIELDS(AvahiEntry, by_key); + AVAHI_LLIST_FIELDS(AvahiEntry, by_group); + + AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements); }; -typedef struct _flxQueryJob { - gint ref; - GTimeVal time; - flxQuery query; -} flxQueryJob; +struct _AvahiEntryGroup { + AvahiServer *server; + gboolean dead; -typedef struct _flxQueryJobInstance { - flxPrioQueueNode *node; - flxQueryJob *job; - gint interface; - guchar protocol; -} flxQueryJobInstance; + AvahiEntryGroupState state; + gpointer userdata; + AvahiEntryGroupCallback callback; -typedef struct _flxResponseJob { - gint ref; - GTimeVal time; - flxRecord response; -} flxResponseJob; - -typedef struct _flxResponseJobInstance { - flxPrioQueueNode *node; - flxResponseJob *job; - gint interface; - guchar protocol; -} flxResponseJobInstance; + guint n_probing; + + AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups); + AVAHI_LLIST_HEAD(AvahiEntry, entries); +}; -struct _flxServer { +struct _AvahiServer { GMainContext *context; - flxInterfaceMonitor *monitor; + AvahiInterfaceMonitor *monitor; + + AVAHI_LLIST_HEAD(AvahiEntry, entries); + GHashTable *entries_by_key; - gint current_id; + AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); - GHashTable *rrset_by_id; - GHashTable *rrset_by_name; + AVAHI_LLIST_HEAD(AvahiSubscription, subscriptions); + GHashTable *subscription_hashtable; + + gboolean need_entry_cleanup, need_group_cleanup; + + AvahiTimeEventQueue *time_event_queue; + + gchar *hostname; + + gint fd_ipv4, fd_ipv6; - flxEntry *entries; + GPollFD pollfd_ipv4, pollfd_ipv6; + GSource *source; - flxPrioQueue *query_job_queue; - flxPrioQueue *response_job_queue; + gboolean ignore_bad_ttl; }; -flxQueryJob* flx_query_job_new(void); -flxQueryJob* flx_query_job_ref(flxQueryJob *job); -void flx_query_job_unref(flxQueryJob *job); +gboolean avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i); -void flx_server_post_query_job(flxServer *s, gint interface, guchar protocol, const GTimeVal *tv, const flxQuery *q); -void flx_server_drop_query_job(flxServer *s, gint interface, guchar protocol, const flxQuery *q); +void avahi_server_post_query(AvahiServer *s, gint interface, guchar protocol, AvahiKey *key); +void avahi_server_post_response(AvahiServer *s, gint interface, guchar protocol, AvahiRecord *record, gboolean flush_cache); -void flx_server_remove_query_job_instance(flxServer *s, flxQueryJobInstance *i); +void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state); -gboolean flx_query_equal(const flxQuery *a, const flxQuery *b); +gboolean avahi_entry_commited(AvahiEntry *e); #endif