blob: 742885d24c1522ea95407b1c48a419886e491e0d (
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
|
/*
* src/database.h
* (c) 2021 Jonas Gunz <himself@jonasgunz.de>
* License: MIT
*/
#pragma once
#include <stdlib.h>
#include "tree.h"
#include "log.h"
/* TODO remove */
#include "dns.h"
/*
* Structure
*
* |-CLASS_IN
* | |-RR_A tree
* | |-RR_AAAA tree
* | |-...
* |-CLASS_CS
* | |-...
* |-...
*
* !! Always substract 1 from CLASS and RR Types, they start with 1
*
* Anything other than IN is probably never needed, but easier to do now than later.
*
* Data format in tree void*
* 0 4 6 6+len
* | ttl | len | data ... |
* ttl: uint32_t
* len: uint16_t
*
*/
#define DB_CLASS_LEN 3
#define DB_RR_LEN 32
typedef struct database {
tree_node_t*** zone;
} database_t;
typedef struct database_rdata {
char* rdata;
uint16_t rdlen;
uint32_t ttl;
} database_rdata_t;
int database_init ( database_t* _database );
int database_destroy ( database_t* _database );
int database_query (
database_rdata_t* _rdata,
database_t* _database,
const char* _qname,
int _qname_len,
uint16_t _qtype,
uint16_t _qclass
);
|