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