summaryrefslogtreecommitdiffstats
path: root/server.h
blob: daaa815ebd967cc129f63b2f8a81494762ebb3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef fooflxserverhfoo
#define fooflxserverhfoo

struct _flxEntry;
typedef struct _flxEntry flxEntry;

#include "flx.h"
#include "iface.h"
#include "prioq.h"

struct _flxEntry {
    flxRecord rr;
    gint id;
    gint interface;
    guchar protocol;

    gboolean unique;

    flxEntry *next, *prev;
    flxEntry *next_by_name, *prev_by_name;
    flxEntry *next_by_id, *prev_by_id;
};

typedef struct _flxQueryJob {
    gint ref;
    GTimeVal time;
    flxQuery query;
} flxQueryJob;

typedef struct _flxQueryJobInstance {
    flxPrioQueueNode *node;
    flxQueryJob *job;
    gint interface;
    guchar protocol;
} flxQueryJobInstance;

typedef struct _flxResponseJob {
    gint ref;
    GTimeVal time;
    flxRecord response;
} flxResponseJob;

typedef struct _flxResponseJobInstance {
    flxPrioQueueNode *node;
    flxResponseJob *job;
    gint interface;
    guchar protocol;
} flxResponseJobInstance;

struct _flxServer {
    GMainContext *context;
    flxInterfaceMonitor *monitor;

    gint current_id;
    
    GHashTable *rrset_by_id;
    GHashTable *rrset_by_name;

    flxEntry *entries;

    flxPrioQueue *query_job_queue;
    flxPrioQueue *response_job_queue;

    gint hinfo_rr_id;

    gchar *hostname;
};

flxQueryJob* flx_query_job_new(void);
flxQueryJob* flx_query_job_ref(flxQueryJob *job);
void flx_query_job_unref(flxQueryJob *job);

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 flx_server_remove_query_job_instance(flxServer *s, flxQueryJobInstance *i);

gboolean flx_query_equal(const flxQuery *a, const flxQuery *b);

#endif