]> git.meshlink.io Git - catta/blob - cache.h
add packet scheduler
[catta] / cache.h
1 #ifndef foocachehfoo
2 #define foocachehfoo
3
4 #include <glib.h>
5
6 struct _flxCache;
7 typedef struct _flxCache flxCache;
8
9 #include "prioq.h"
10 #include "server.h"
11 #include "llist.h"
12
13 typedef enum {
14     FLX_CACHE_VALID,
15     FLX_CACHE_EXPIRY1,
16     FLX_CACHE_EXPIRY2,
17     FLX_CACHE_EXPIRY3
18         
19 } flxCacheEntryState;
20
21 typedef struct flxCacheEntry flxCacheEntry;
22
23 struct flxCacheEntry {
24     flxRecord *record;
25     GTimeVal timestamp;
26     GTimeVal expiry;
27     
28     flxAddress origin;
29
30     flxCacheEntryState state;
31
32     FLX_LLIST_FIELDS(flxCacheEntry, by_name);
33
34     flxPrioQueueNode *node;
35     
36 };
37
38 struct _flxCache {
39     flxServer *server;
40     
41     flxInterface *interface;
42     
43     GHashTable *hash_table;
44 };
45
46 flxCache *flx_cache_new(flxServer *server, flxInterface *interface);
47 void flx_cache_free(flxCache *c);
48
49 flxCacheEntry *flx_cache_lookup_key(flxCache *c, flxKey *k);
50 flxCacheEntry *flx_cache_lookup_record(flxCache *c, flxRecord *r);
51
52 flxCacheEntry *flx_cache_update(flxCache *c, flxRecord *r, gboolean unique, const flxAddress *a);
53
54 void flx_cache_drop_key(flxCache *c, flxKey *k);
55 void flx_cache_drop_record(flxCache *c,  flxRecord *r);
56
57 void flx_cache_dump(flxCache *c, FILE *f);
58
59 #endif