summaryrefslogtreecommitdiffstats
path: root/psched.h
blob: 9866f2f9a0464781151365c421d2d7c7a2e7729d (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
#ifndef foopschedhfoo
#define foopschedhfoo

typedef struct _flxQueryJob flxQueryJob;
typedef struct _flxResponseJob flxResponseJob;
typedef struct _flxPacketScheduler flxPacketScheduler;
typedef struct _flxKnownAnswer flxKnownAnswer;
typedef struct _flxProbeJob flxProbeJob;

#include "timeeventq.h"
#include "rr.h"
#include "llist.h"
#include "iface.h"

struct _flxQueryJob {
    flxPacketScheduler *scheduler;
    flxTimeEvent *time_event;
    flxKey *key;
    gboolean done;
    GTimeVal delivery;
    FLX_LLIST_FIELDS(flxQueryJob, jobs);
};

struct _flxResponseJob {
    flxPacketScheduler *scheduler;
    flxTimeEvent *time_event;
    flxRecord *record;
    flxAddress address;
    gboolean address_valid;
    gboolean done;
    GTimeVal delivery;
    gboolean flush_cache;
    FLX_LLIST_FIELDS(flxResponseJob, jobs);
};

struct _flxKnownAnswer {
    flxPacketScheduler *scheduler;
    flxRecord *record;

    FLX_LLIST_FIELDS(flxKnownAnswer, known_answer);
};

struct _flxProbeJob {
    flxPacketScheduler *scheduler;
    flxTimeEvent *time_event;
    flxRecord *record;

    gboolean chosen; /* Use for packet assembling */
    GTimeVal delivery;
    
    FLX_LLIST_FIELDS(flxProbeJob, jobs);
};

struct _flxPacketScheduler {
    flxServer *server;
    
    flxInterface *interface;

    FLX_LLIST_HEAD(flxQueryJob, query_jobs);
    FLX_LLIST_HEAD(flxResponseJob, response_jobs);
    FLX_LLIST_HEAD(flxKnownAnswer, known_answers);
    FLX_LLIST_HEAD(flxProbeJob, probe_jobs);
};

flxPacketScheduler *flx_packet_scheduler_new(flxServer *server, flxInterface *i);
void flx_packet_scheduler_free(flxPacketScheduler *s);

void flx_packet_scheduler_post_query(flxPacketScheduler *s, flxKey *key, gboolean immediately);
void flx_packet_scheduler_post_response(flxPacketScheduler *s, const flxAddress *a, flxRecord *record, gboolean flush_cache, gboolean immediately);
void flx_packet_scheduler_post_probe(flxPacketScheduler *s, flxRecord *record, gboolean immediately);

void flx_packet_scheduler_incoming_query(flxPacketScheduler *s, flxKey *key);
void flx_packet_scheduler_incoming_response(flxPacketScheduler *s, flxRecord *record);
void flx_packet_scheduler_incoming_known_answer(flxPacketScheduler *s, flxRecord *record, const flxAddress *a);

void flx_packet_scheduler_flush_responses(flxPacketScheduler *s);

#endif