-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.h
45 lines (36 loc) · 849 Bytes
/
cache.h
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
#ifndef CACHE_H_
#define CACHE_H_
#include "extypes.h"
#include "dns_types.h"
//#include "dns.h"
#include "uthash.h"
#define RECORD_EXISTS (1)
#define RECORD_DNE (0)
struct hash_key_s {
uint8_t name[DNS_NAME_MAX_LEN];
// uint16_t type;
};
typedef struct hash_key_s hash_key;
struct record_s {
rr_t rr;
time_t time_created;
struct record_s *next;
struct record_s *prev;
};
typedef struct record_s record_t;
struct ht_entry_s {
hash_key key;
record_t *record;
UT_hash_handle hh;
};
typedef struct ht_entry_s ht_entry;
record_t *record_alloc(void);
void add_record(hash_key key, rr_t rr);
void add_entry(hash_key cache_key);
ht_entry *find_entry(hash_key cache_key);
a_rdata *a_rdata_alloc(void);
void load_root_a(void);
void load_root_ns(void);
void load_root_servers(void);
hash_key key_generate(char *name);
#endif