ldns  1.9.2
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 {
79  LDNS_EDE_TOO_EARLY = 26, /* RFC 9250 */
81  LDNS_EDE_UNABLE_TO_CONFORM_TO_POLICY = 28, /* draft-homburg-dnsop-codcp-00 */
82  LDNS_EDE_SYNTHESIZED = 29, /* https://github.com/PowerDNS/pdns/pull/12334 */
83  LDNS_EDE_INVALID_QUERY_TYPE = 30 /* RFC 9824 */
84 };
86 
103  size_t _size;
104  void *_data;
105 };
107 
108 
109 /*
110  * Array structure to store multiple EDNS options
111  */
113 {
114  size_t _option_count; /* the number of EDNS options in the list */
115  size_t _option_capacity; /* the amount of options that fit into the list */
116  size_t _options_size; /* the total size of the options serialized */
118 };
120 
121 /*
122  * Access functions
123  * do this as functions to get type checking
124  */
125 
131 size_t ldns_edns_get_size(const ldns_edns_option *edns);
132 
139 
145 uint8_t *ldns_edns_get_data(const ldns_edns_option *edns);
146 
153 ldns_status ldns_edns_ede_get_code(const ldns_edns_option *edns, uint16_t *ede_code);
154 
161 ldns_status ldns_edns_ede_get_text(const ldns_edns_option* edns, char **ede_text);
162 
169 
170 /* Constructors and destructors*/
171 
180 ldns_edns_option *ldns_edns_new(ldns_edns_option_code code, size_t size, void *data);
181 
190 ldns_edns_option *ldns_edns_new_from_data(ldns_edns_option_code code, size_t size, const void *data);
191 
198 
204 void ldns_edns_free(ldns_edns_option *edns);
205 
211 
218 
226 
227 /* edns_option_list functions */
228 
234 size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *options_list);
235 
243  size_t index);
244 
245 
252 
262  ldns_edns_option *option, size_t index);
263 
271  ldns_edns_option *option);
272 
279 
286 
287 #ifdef __cplusplus
288 }
289 #endif
290 
291 #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:176
ldns_edns_option_list * ldns_edns_option_list_new(void)
allocates space for a new list of EDNS options
Definition: edns.c:209
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_UNABLE_TO_CONFORM_TO_POLICY
Definition: edns.h:81
@ 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_UNSUPPORTED_NSEC3_ITERATIONS_VALUE
Definition: edns.h:80
@ 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_QUERY_TYPE
Definition: edns.h:83
@ LDNS_EDE_INVALID_DATA
Definition: edns.h:77
@ LDNS_EDE_SYNTHESIZED
Definition: edns.h:82
@ 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:39
ldns_buffer * ldns_edns_get_wireformat_buffer(const ldns_edns_option *edns)
serialise the EDNS option into wireformat.
Definition: edns.c:84
void ldns_edns_option_list_free(ldns_edns_option_list *options_list)
free the EDNS option list.
Definition: edns.c:255
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:85
ldns_status ldns_edns_ede_get_code(const ldns_edns_option *edns, uint16_t *ede_code)
extract the RFC 8914 extended error code value.
Definition: edns.c:46
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:154
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:298
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:287
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
Definition: edns.c:32
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:309
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:384
ldns_status ldns_edns_ede_get_text(const ldns_edns_option *edns, char **ede_text)
extract the optional RFC 8914 extended error code text.
Definition: edns.c:61
signed char 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:338
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list)
Definition: edns.c:264
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
Definition: edns.c:25
void ldns_edns_deep_free(ldns_edns_option *edns)
free the EDNS option.
Definition: edns.c:190
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:426
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:277
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:224
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:139
void ldns_edns_free(ldns_edns_option *edns)
Definition: edns.c:201
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
enum ldns_enum_status ldns_status
Definition: error.h:152
implementation of buffers to ease operations
Definition: buffer.h:51
ldns_edns_option ** _options
Definition: edns.h:117
The struct that stores an ordered EDNS option.
Definition: edns.h:101
ldns_edns_option_code _code
Definition: edns.h:102