edns.h (368129) | edns.h (368693) |
---|---|
1/* 2 * util/edns.h - handle base EDNS options. 3 * 4 * Copyright (c) 2018, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 36 unchanged lines hidden (view full) --- 45#include "util/storage/dnstree.h" 46 47struct edns_data; 48struct config_file; 49struct comm_point; 50struct regional; 51 52/** | 1/* 2 * util/edns.h - handle base EDNS options. 3 * 4 * Copyright (c) 2018, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 36 unchanged lines hidden (view full) --- 45#include "util/storage/dnstree.h" 46 47struct edns_data; 48struct config_file; 49struct comm_point; 50struct regional; 51 52/** |
53 * Structure containing all EDNS tags. | 53 * Structure containing all EDNS strings. |
54 */ | 54 */ |
55struct edns_tags { 56 /** Tree of EDNS client tags to use in upstream queries, per address 57 * prefix. Contains nodes of type edns_tag_addr. */ 58 rbtree_type client_tags; 59 /** EDNS opcode to use for client tags */ 60 uint16_t client_tag_opcode; | 55struct edns_strings { 56 /** Tree of EDNS client strings to use in upstream queries, per address 57 * prefix. Contains nodes of type edns_string_addr. */ 58 rbtree_type client_strings; 59 /** EDNS opcode to use for client strings */ 60 uint16_t client_string_opcode; |
61 /** region to allocate tree nodes in */ 62 struct regional* region; 63}; 64 65/** | 61 /** region to allocate tree nodes in */ 62 struct regional* region; 63}; 64 65/** |
66 * EDNS tag. Node of rbtree, containing tag and prefix. | 66 * EDNS string. Node of rbtree, containing string and prefix. |
67 */ | 67 */ |
68struct edns_tag_addr { | 68struct edns_string_addr { |
69 /** node in address tree, used for tree lookups. Need to be the first 70 * member of this struct. */ 71 struct addr_tree_node node; | 69 /** node in address tree, used for tree lookups. Need to be the first 70 * member of this struct. */ 71 struct addr_tree_node node; |
72 /** tag data, in host byte ordering */ 73 uint16_t tag_data; | 72 /** string, ascii format */ 73 uint8_t* string; 74 /** length of string */ 75 size_t string_len; |
74}; 75 76/** | 76}; 77 78/** |
77 * Create structure to hold EDNS tags 78 * @return: newly created edns_tags, NULL on alloc failure. | 79 * Create structure to hold EDNS strings 80 * @return: newly created edns_strings, NULL on alloc failure. |
79 */ | 81 */ |
80struct edns_tags* edns_tags_create(void); | 82struct edns_strings* edns_strings_create(void); |
81 | 83 |
82/** Delete EDNS tags structure 83 * @param edns_tags: struct to delete | 84/** Delete EDNS strings structure 85 * @param edns_strings: struct to delete |
84 */ | 86 */ |
85void edns_tags_delete(struct edns_tags* edns_tags); | 87void edns_strings_delete(struct edns_strings* edns_strings); |
86 87/** | 88 89/** |
88 * Add configured EDNS tags 89 * @param edns_tags: edns tags to apply config to 90 * @param config: struct containing EDNS tags configuration | 90 * Add configured EDNS strings 91 * @param edns_strings: edns strings to apply config to 92 * @param config: struct containing EDNS strings configuration |
91 * @return 0 on error 92 */ | 93 * @return 0 on error 94 */ |
93int edns_tags_apply_cfg(struct edns_tags* edns_tags, | 95int edns_strings_apply_cfg(struct edns_strings* edns_strings, |
94 struct config_file* config); 95 96/** | 96 struct config_file* config); 97 98/** |
97 * Find tag for address. 98 * @param tree: tree containing EDNS tags per address prefix. | 99 * Find string for address. 100 * @param tree: tree containing EDNS strings per address prefix. |
99 * @param addr: address to use for tree lookup 100 * @param addrlen: length of address 101 * @return: matching tree node, NULL otherwise 102 */ | 101 * @param addr: address to use for tree lookup 102 * @param addrlen: length of address 103 * @return: matching tree node, NULL otherwise 104 */ |
103struct edns_tag_addr* 104edns_tag_addr_lookup(rbtree_type* tree, struct sockaddr_storage* addr, | 105struct edns_string_addr* 106edns_string_addr_lookup(rbtree_type* tree, struct sockaddr_storage* addr, |
105 socklen_t addrlen); 106 107/** 108 * Apply common EDNS options. 109 * 110 * @param edns_out: initialised edns information with outbound edns. 111 * @param edns_in: initialised edns information with received edns. 112 * @param cfg: configuration. 113 * @param c: comm channel. 114 * @param region: the region to allocate the edns options in. 115 */ 116int apply_edns_options(struct edns_data* edns_out, struct edns_data* edns_in, 117 struct config_file* cfg, struct comm_point* c, struct regional* region); 118 119#endif | 107 socklen_t addrlen); 108 109/** 110 * Apply common EDNS options. 111 * 112 * @param edns_out: initialised edns information with outbound edns. 113 * @param edns_in: initialised edns information with received edns. 114 * @param cfg: configuration. 115 * @param c: comm channel. 116 * @param region: the region to allocate the edns options in. 117 */ 118int apply_edns_options(struct edns_data* edns_out, struct edns_data* edns_in, 119 struct config_file* cfg, struct comm_point* c, struct regional* region); 120 121#endif |