]> git.meshlink.io Git - catta/blob - cache.h
add code for recieving packets
[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     flxInterface *interface;
41     
42     GHashTable *hash_table;
43 };
44
45 flxCache *flx_cache_new(flxServer *server, flxInterface *interface);
46 void flx_cache_free(flxCache *c);
47
48 flxCacheEntry *flx_cache_lookup_key(flxCache *c, flxKey *k);
49 flxCacheEntry *flx_cache_lookup_record(flxCache *c, flxRecord *r);
50
51 flxCacheEntry *flx_cache_update(flxCache *c, flxRecord *r, gboolean unique, const flxAddress *a);
52
53 void flx_cache_drop_key(flxCache *c, flxKey *k);
54 void flx_cache_drop_record(flxCache *c,  flxRecord *r);
55
56 #endif