aboutsummaryrefslogtreecommitdiff
path: root/src/database.h
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-04-30 23:27:11 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-04-30 23:27:11 +0200
commitbd8e73aad283611c096f07e0fc16aa4985f9f2eb (patch)
tree9ce9d9d41387a62dd4cc3b88669a991244d7b8b7 /src/database.h
parentba7c93085b419d1453dfb722b570245c4a725c83 (diff)
downloaddns-bd8e73aad283611c096f07e0fc16aa4985f9f2eb.tar.gz
implemented database
Diffstat (limited to 'src/database.h')
-rw-r--r--src/database.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/database.h b/src/database.h
new file mode 100644
index 0000000..e6ba882
--- /dev/null
+++ b/src/database.h
@@ -0,0 +1,66 @@
+/*
+ * src/database.h
+ * (c) 2021 Jonas Gunz <himself@jonasgunz.de>
+ * License: MIT
+ */
+
+#pragma once
+
+#include <stdlib.h>
+
+#include "tree.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 2+len
+ * | ttl | len | data ... |
+ * ttl: uint32_t
+ * len: uint16_t
+ *
+ */
+
+#define DB_CLASS_LEN 3
+#define DB_RR_LEN 32
+
+struct database {
+ struct tree_node*** zone;
+};
+
+struct database_rdata {
+ char* rdata;
+ uint16_t rdlen;
+ uint32_t ttl;
+};
+
+int database_populate (
+ struct database* _database,
+ char* _zonefile
+);
+
+int database_destroy ( struct database* _database );
+
+int database_query (
+ struct database_rdata* _rdata,
+ struct database* _database,
+ const char* _qname,
+ int _qname_len,
+ uint16_t _qtype,
+ uint16_t _qclass
+);