summaryrefslogtreecommitdiff
path: root/contrib/unbound/util/edns.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/unbound/util/edns.h')
-rw-r--r--contrib/unbound/util/edns.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/unbound/util/edns.h b/contrib/unbound/util/edns.h
index a4ee7def634c..cf9f8707e808 100644
--- a/contrib/unbound/util/edns.h
+++ b/contrib/unbound/util/edns.h
@@ -42,12 +42,69 @@
#ifndef UTIL_EDNS_H
#define UTIL_EDNS_H
+#include "util/storage/dnstree.h"
+
struct edns_data;
struct config_file;
struct comm_point;
struct regional;
/**
+ * Structure containing all EDNS tags.
+ */
+struct edns_tags {
+ /** Tree of EDNS client tags to use in upstream queries, per address
+ * prefix. Contains nodes of type edns_tag_addr. */
+ rbtree_type client_tags;
+ /** EDNS opcode to use for client tags */
+ uint16_t client_tag_opcode;
+ /** region to allocate tree nodes in */
+ struct regional* region;
+};
+
+/**
+ * EDNS tag. Node of rbtree, containing tag and prefix.
+ */
+struct edns_tag_addr {
+ /** node in address tree, used for tree lookups. Need to be the first
+ * member of this struct. */
+ struct addr_tree_node node;
+ /** tag data, in host byte ordering */
+ uint16_t tag_data;
+};
+
+/**
+ * Create structure to hold EDNS tags
+ * @return: newly created edns_tags, NULL on alloc failure.
+ */
+struct edns_tags* edns_tags_create(void);
+
+/** Delete EDNS tags structure
+ * @param edns_tags: struct to delete
+ */
+void edns_tags_delete(struct edns_tags* edns_tags);
+
+/**
+ * Add configured EDNS tags
+ * @param edns_tags: edns tags to apply config to
+ * @param config: struct containing EDNS tags configuration
+ * @return 0 on error
+ */
+int edns_tags_apply_cfg(struct edns_tags* edns_tags,
+ struct config_file* config);
+
+/**
+ * Find tag for address.
+ * @param tree: tree containing EDNS tags per address prefix.
+ * @param addr: address to use for tree lookup
+ * @param addrlen: length of address
+ * @return: matching tree node, NULL otherwise
+ */
+struct edns_tag_addr*
+edns_tag_addr_lookup(rbtree_type* tree, struct sockaddr_storage* addr,
+ socklen_t addrlen);
+
+/**
* Apply common EDNS options.
*
* @param edns_out: initialised edns information with outbound edns.