edns.h
Go to the documentation of this file.
1 /*
2  * edns.h
3  *
4  *
5  * a Net::DNS like library for C
6  *
7  * (c) NLnet Labs, 2004-2022
8  *
9  * See the file LICENSE for the license
10  */
11 
12 #ifndef LDNS_EDNS_H
13 #define LDNS_EDNS_H
14 
15 #include <ldns/common.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 
22 
27 {
28  LDNS_EDNS_LLQ = 1, /* RFC8764 */
29  LDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */
30  LDNS_EDNS_NSID = 3, /* RFC5001 */
31  /* 4 draft-cheshire-edns0-owner-option */
32  LDNS_EDNS_DAU = 5, /* RFC6975 */
33  LDNS_EDNS_DHU = 6, /* RFC6975 */
34  LDNS_EDNS_N3U = 7, /* RFC6975 */
35  LDNS_EDNS_CLIENT_SUBNET = 8, /* RFC7871 */
36  LDNS_EDNS_EXPIRE = 9, /* RFC7314 */
37  LDNS_EDNS_COOKIE = 10, /* RFC7873 */
38  LDNS_EDNS_KEEPALIVE = 11, /* RFC7828*/
39  LDNS_EDNS_PADDING = 12, /* RFC7830 */
40  LDNS_EDNS_CHAIN = 13, /* RFC7901 */
41  LDNS_EDNS_KEY_TAG = 14, /* RFC8145 */
42  LDNS_EDNS_EDE = 15, /* RFC8914 */
43  LDNS_EDNS_CLIENT_TAG = 16, /* draft-bellis-dnsop-edns-tags-01 */
44  LDNS_EDNS_SERVER_TAG = 17 /* draft-bellis-dnsop-edns-tags-01 */
45 };
47 
52 {
80 };
82 
99  size_t _size;
100  void *_data;
101 };
103 
104 
105 /*
106  * Array structure to store multiple EDNS options
107  */
109 {
110  size_t _option_count; /* the number of EDNS options in the list */
111  size_t _option_capacity; /* the amount of options that fit into the list */
112  size_t _options_size; /* the total size of the options serialized */
114 };
116 
117 /*
118  * Access functions
119  * do this as functions to get type checking
120  */
121 
127 size_t ldns_edns_get_size(const ldns_edns_option *edns);
128 
135 
141 uint8_t *ldns_edns_get_data(const ldns_edns_option *edns);
142 
143 
150 
151 /* Constructors and destructors*/
152 
161 ldns_edns_option *ldns_edns_new(ldns_edns_option_code code, size_t size, void *data);
162 
171 ldns_edns_option *ldns_edns_new_from_data(ldns_edns_option_code code, size_t size, const void *data);
172 
179 
185 void ldns_edns_free(ldns_edns_option *edns);
186 
192 
199 
207 
208 /* edns_option_list functions */
209 
215 size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *options_list);
216 
224  size_t index);
225 
226 
233 
243  ldns_edns_option *option, size_t index);
244 
252  ldns_edns_option *option);
253 
260 
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* LDNS_EDNS_H */
Common definitions for LDNS.
ldns_edns_option * ldns_edns_clone(ldns_edns_option *edns)
clone an EDNS option
Definition: edns.c:137
ldns_edns_option_list * ldns_edns_option_list_new(void)
allocates space for a new list of EDNS options
Definition: edns.c:170
ldns_edns_enum_ede_code
Extended DNS Error (RFC 8914) codes.
Definition: edns.h:52
@ LDNS_EDE_DNSSEC_INDETERMINATE
Definition: edns.h:58
@ LDNS_EDE_NOT_SUPPORTED
Definition: edns.h:74
@ LDNS_EDE_PROHIBITED
Definition: edns.h:71
@ LDNS_EDE_NOT_READY
Definition: edns.h:67
@ LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
Definition: edns.h:54
@ LDNS_EDE_RRSIGS_MISSING
Definition: edns.h:63
@ LDNS_EDE_NO_REACHABLE_AUTHORITY
Definition: edns.h:75
@ LDNS_EDE_SIGNATURE_EXPIRED
Definition: edns.h:60
@ LDNS_EDE_DNSSEC_BOGUS
Definition: edns.h:59
@ LDNS_EDE_CENSORED
Definition: edns.h:69
@ LDNS_EDE_STALE_NXDOMAIN_ANSWER
Definition: edns.h:72
@ LDNS_EDE_NO_ZONE_KEY_BIT_SET
Definition: edns.h:64
@ LDNS_EDE_DNSKEY_MISSING
Definition: edns.h:62
@ LDNS_EDE_NETWORK_ERROR
Definition: edns.h:76
@ LDNS_EDE_FILTERED
Definition: edns.h:70
@ LDNS_EDE_BLOCKED
Definition: edns.h:68
@ LDNS_EDE_FORGED_ANSWER
Definition: edns.h:57
@ LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
Definition: edns.h:78
@ LDNS_EDE_STALE_ANSWER
Definition: edns.h:56
@ LDNS_EDE_NOT_AUTHORITATIVE
Definition: edns.h:73
@ LDNS_EDE_CACHED_ERROR
Definition: edns.h:66
@ LDNS_EDE_NSEC_MISSING
Definition: edns.h:65
@ LDNS_EDE_OTHER
Definition: edns.h:53
@ LDNS_EDE_INVALID_DATA
Definition: edns.h:77
@ LDNS_EDE_SIGNATURE_NOT_YET_VALID
Definition: edns.h:61
@ LDNS_EDE_UNSUPPORTED_DS_DIGEST
Definition: edns.h:55
@ LDNS_EDE_TOO_EARLY
Definition: edns.h:79
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
Definition: edns.c:38
ldns_buffer * ldns_edns_get_wireformat_buffer(const ldns_edns_option *edns)
serialise the EDNS option into wireformat.
Definition: edns.c:45
void ldns_edns_option_list_free(ldns_edns_option_list *options_list)
free the EDNS option list.
Definition: edns.c:216
enum ldns_enum_edns_option ldns_edns_option_code
Definition: edns.h:46
enum ldns_edns_enum_ede_code ldns_edns_ede_code
Definition: edns.h:81
bool ldns_edns_option_list_push(ldns_edns_option_list *options_list, ldns_edns_option *option)
adds an EDNS option at the end of the list of options.
Definition: edns.c:299
ldns_edns_option * ldns_edns_new_from_data(ldns_edns_option_code code, size_t size, const void *data)
allocates a new EDNS structure and fills it.
Definition: edns.c:115
size_t ldns_edns_option_list_get_options_size(const ldns_edns_option_list *options_list)
returns the total size of all the individual EDNS options in the EDNS list.
Definition: edns.c:259
ldns_edns_option * ldns_edns_option_list_get_option(const ldns_edns_option_list *options_list, size_t index)
returns the EDNS option as the specified index in the list of EDNS options.
Definition: edns.c:248
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
Definition: edns.c:31
ldns_edns_option * ldns_edns_option_list_set_option(ldns_edns_option_list *options_list, ldns_edns_option *option, size_t index)
adds an EDNS option to the list of options at the specified index.
Definition: edns.c:270
ldns_edns_option * ldns_edns_option_list_pop(ldns_edns_option_list *options_list)
removes and returns the EDNS option at the end of the list of options.
Definition: edns.c:345
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list)
Definition: edns.c:225
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
Definition: edns.c:24
void ldns_edns_deep_free(ldns_edns_option *edns)
free the EDNS option.
Definition: edns.c:151
ldns_buffer * ldns_edns_option_list2wireformat_buffer(const ldns_edns_option_list *option_list)
serializes all the EDNS options into a single wireformat buffer
Definition: edns.c:387
size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *options_list)
returns the number of options in the EDNS options list.
Definition: edns.c:238
ldns_edns_option_list * ldns_edns_option_list_clone(ldns_edns_option_list *options_list)
clone the EDNS options list and it's contents
Definition: edns.c:185
ldns_edns_option * ldns_edns_new(ldns_edns_option_code code, size_t size, void *data)
allocates a new EDNS structure and fills it.
Definition: edns.c:100
void ldns_edns_free(ldns_edns_option *edns)
Definition: edns.c:162
ldns_enum_edns_option
EDNS option codes.
Definition: edns.h:27
@ LDNS_EDNS_NSID
Definition: edns.h:30
@ LDNS_EDNS_KEEPALIVE
Definition: edns.h:38
@ LDNS_EDNS_DHU
Definition: edns.h:33
@ LDNS_EDNS_PADDING
Definition: edns.h:39
@ LDNS_EDNS_COOKIE
Definition: edns.h:37
@ LDNS_EDNS_DAU
Definition: edns.h:32
@ LDNS_EDNS_N3U
Definition: edns.h:34
@ LDNS_EDNS_UL
Definition: edns.h:29
@ LDNS_EDNS_CLIENT_SUBNET
Definition: edns.h:35
@ LDNS_EDNS_KEY_TAG
Definition: edns.h:41
@ LDNS_EDNS_CHAIN
Definition: edns.h:40
@ LDNS_EDNS_CLIENT_TAG
Definition: edns.h:43
@ LDNS_EDNS_EDE
Definition: edns.h:42
@ LDNS_EDNS_LLQ
Definition: edns.h:28
@ LDNS_EDNS_SERVER_TAG
Definition: edns.h:44
@ LDNS_EDNS_EXPIRE
Definition: edns.h:36
implementation of buffers to ease operations
Definition: buffer.h:51
ldns_edns_option ** _options
Definition: edns.h:113
The struct that stores an ordered EDNS option.
Definition: edns.h:97
ldns_edns_option_code _code
Definition: edns.h:98