]> git.meshlink.io Git - catta/blob - server.h
3960ee5f4a1a9ee2637ec1599892121a82e7a4a2
[catta] / server.h
1 #ifndef fooflxserverhfoo
2 #define fooflxserverhfoo
3
4 #include "flx.h"
5 #include "iface.h"
6 #include "prioq.h"
7 #include "llist.h"
8 #include "timeeventq.h"
9 #include "announce.h"
10 #include "subscribe.h"
11
12 struct _flxEntry {
13     flxServer *server;
14     flxEntryGroup *group;
15
16     gboolean dead;
17     
18     flxEntryFlags flags;
19     flxRecord *record;
20     gint interface;
21     guchar protocol;
22
23     FLX_LLIST_FIELDS(flxEntry, entries);
24     FLX_LLIST_FIELDS(flxEntry, by_key);
25     FLX_LLIST_FIELDS(flxEntry, by_group);
26     
27     FLX_LLIST_HEAD(flxAnnouncement, announcements);
28 };
29
30 struct _flxEntryGroup {
31     flxServer *server;
32     gboolean dead;
33
34     flxEntryGroupState state;
35     gpointer userdata;
36     flxEntryGroupCallback callback;
37
38     guint n_probing;
39     
40     FLX_LLIST_FIELDS(flxEntryGroup, groups);
41     FLX_LLIST_HEAD(flxEntry, entries);
42 };
43
44 struct _flxServer {
45     GMainContext *context;
46     flxInterfaceMonitor *monitor;
47
48     FLX_LLIST_HEAD(flxEntry, entries);
49     GHashTable *entries_by_key;
50
51     FLX_LLIST_HEAD(flxEntryGroup, groups);
52     
53     FLX_LLIST_HEAD(flxSubscription, subscriptions);
54     GHashTable *subscription_hashtable;
55
56     gboolean need_entry_cleanup, need_group_cleanup;
57     
58     flxTimeEventQueue *time_event_queue;
59     
60     gchar *hostname;
61
62     gint fd_ipv4, fd_ipv6;
63
64     GPollFD pollfd_ipv4, pollfd_ipv6;
65     GSource *source;
66
67     gboolean ignore_bad_ttl;
68 };
69
70 gboolean flx_server_entry_match_interface(flxEntry *e, flxInterface *i);
71
72 void flx_server_post_query(flxServer *s, gint interface, guchar protocol, flxKey *key);
73 void flx_server_post_response(flxServer *s, gint interface, guchar protocol, flxRecord *record, gboolean flush_cache);
74
75 void flx_entry_group_change_state(flxEntryGroup *g, flxEntryGroupState state);
76
77 gboolean flx_entry_commited(flxEntry *e);
78
79 #endif