]> git.meshlink.io Git - catta/blob - server.h
daaa815ebd967cc129f63b2f8a81494762ebb3b0
[catta] / server.h
1 #ifndef fooflxserverhfoo
2 #define fooflxserverhfoo
3
4 struct _flxEntry;
5 typedef struct _flxEntry flxEntry;
6
7 #include "flx.h"
8 #include "iface.h"
9 #include "prioq.h"
10
11 struct _flxEntry {
12     flxRecord rr;
13     gint id;
14     gint interface;
15     guchar protocol;
16
17     gboolean unique;
18
19     flxEntry *next, *prev;
20     flxEntry *next_by_name, *prev_by_name;
21     flxEntry *next_by_id, *prev_by_id;
22 };
23
24 typedef struct _flxQueryJob {
25     gint ref;
26     GTimeVal time;
27     flxQuery query;
28 } flxQueryJob;
29
30 typedef struct _flxQueryJobInstance {
31     flxPrioQueueNode *node;
32     flxQueryJob *job;
33     gint interface;
34     guchar protocol;
35 } flxQueryJobInstance;
36
37 typedef struct _flxResponseJob {
38     gint ref;
39     GTimeVal time;
40     flxRecord response;
41 } flxResponseJob;
42
43 typedef struct _flxResponseJobInstance {
44     flxPrioQueueNode *node;
45     flxResponseJob *job;
46     gint interface;
47     guchar protocol;
48 } flxResponseJobInstance;
49
50 struct _flxServer {
51     GMainContext *context;
52     flxInterfaceMonitor *monitor;
53
54     gint current_id;
55     
56     GHashTable *rrset_by_id;
57     GHashTable *rrset_by_name;
58
59     flxEntry *entries;
60
61     flxPrioQueue *query_job_queue;
62     flxPrioQueue *response_job_queue;
63
64     gint hinfo_rr_id;
65
66     gchar *hostname;
67 };
68
69 flxQueryJob* flx_query_job_new(void);
70 flxQueryJob* flx_query_job_ref(flxQueryJob *job);
71 void flx_query_job_unref(flxQueryJob *job);
72
73 void flx_server_post_query_job(flxServer *s, gint interface, guchar protocol, const GTimeVal *tv, const flxQuery *q);
74 void flx_server_drop_query_job(flxServer *s, gint interface, guchar protocol, const flxQuery *q);
75
76 void flx_server_remove_query_job_instance(flxServer *s, flxQueryJobInstance *i);
77
78 gboolean flx_query_equal(const flxQuery *a, const flxQuery *b);
79
80 #endif