edns.h
Go to the documentation of this file.
/*
* edns.h
*
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2004-2022
*
* See the file LICENSE for the license
*/
#ifndef LDNS_EDNS_H
#define LDNS_EDNS_H
#include <ldns/common.h>
#ifdef __cplusplus
extern "C" {
#endif
enum ldns_enum_edns_option
{
LDNS_EDNS_LLQ = 1, /* RFC8764 */
LDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */
LDNS_EDNS_NSID = 3, /* RFC5001 */
/* 4 draft-cheshire-edns0-owner-option */
LDNS_EDNS_DAU = 5, /* RFC6975 */
LDNS_EDNS_DHU = 6, /* RFC6975 */
LDNS_EDNS_N3U = 7, /* RFC6975 */
LDNS_EDNS_CLIENT_SUBNET = 8, /* RFC7871 */
LDNS_EDNS_EXPIRE = 9, /* RFC7314 */
LDNS_EDNS_COOKIE = 10, /* RFC7873 */
LDNS_EDNS_KEEPALIVE = 11, /* RFC7828*/
LDNS_EDNS_PADDING = 12, /* RFC7830 */
LDNS_EDNS_CHAIN = 13, /* RFC7901 */
LDNS_EDNS_KEY_TAG = 14, /* RFC8145 */
LDNS_EDNS_EDE = 15, /* RFC8914 */
LDNS_EDNS_CLIENT_TAG = 16, /* draft-bellis-dnsop-edns-tags-01 */
LDNS_EDNS_SERVER_TAG = 17 /* draft-bellis-dnsop-edns-tags-01 */
};
typedef enum ldns_enum_edns_option ldns_edns_option_code;
enum ldns_edns_enum_ede_code
{
LDNS_EDE_OTHER = 0,
LDNS_EDE_UNSUPPORTED_DNSKEY_ALG = 1,
LDNS_EDE_UNSUPPORTED_DS_DIGEST = 2,
LDNS_EDE_STALE_ANSWER = 3,
LDNS_EDE_FORGED_ANSWER = 4,
LDNS_EDE_DNSSEC_INDETERMINATE = 5,
LDNS_EDE_DNSSEC_BOGUS = 6,
LDNS_EDE_SIGNATURE_EXPIRED = 7,
LDNS_EDE_SIGNATURE_NOT_YET_VALID = 8,
LDNS_EDE_DNSKEY_MISSING = 9,
LDNS_EDE_RRSIGS_MISSING = 10,
LDNS_EDE_NO_ZONE_KEY_BIT_SET = 11,
LDNS_EDE_NSEC_MISSING = 12,
LDNS_EDE_CACHED_ERROR = 13,
LDNS_EDE_NOT_READY = 14,
LDNS_EDE_BLOCKED = 15,
LDNS_EDE_CENSORED = 16,
LDNS_EDE_FILTERED = 17,
LDNS_EDE_PROHIBITED = 18,
LDNS_EDE_STALE_NXDOMAIN_ANSWER = 19,
LDNS_EDE_NOT_AUTHORITATIVE = 20,
LDNS_EDE_NOT_SUPPORTED = 21,
LDNS_EDE_NO_REACHABLE_AUTHORITY = 22,
LDNS_EDE_NETWORK_ERROR = 23,
LDNS_EDE_INVALID_DATA = 24,
LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID = 25,
LDNS_EDE_TOO_EARLY = 26
};
typedef enum ldns_edns_enum_ede_code ldns_edns_ede_code;
struct ldns_struct_edns_option {
ldns_edns_option_code _code;
size_t _size;
void *_data;
};
typedef struct ldns_struct_edns_option ldns_edns_option;
/*
* Array structure to store multiple EDNS options
*/
struct ldns_struct_edns_option_list
{
size_t _option_count; /* the number of EDNS options in the list */
size_t _option_capacity; /* the amount of options that fit into the list */
size_t _options_size; /* the total size of the options serialized */
ldns_edns_option **_options;
};
typedef struct ldns_struct_edns_option_list ldns_edns_option_list;
/*
* Access functions
* do this as functions to get type checking
*/
size_t ldns_edns_get_size(const ldns_edns_option *edns);
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns);
uint8_t *ldns_edns_get_data(const ldns_edns_option *edns);
ldns_status ldns_edns_ede_get_code(const ldns_edns_option *edns, uint16_t *ede_code);
ldns_status ldns_edns_ede_get_text(const ldns_edns_option* edns, char **ede_text);
ldns_buffer *ldns_edns_get_wireformat_buffer(const ldns_edns_option *edns);
/* Constructors and destructors*/
ldns_edns_option *ldns_edns_new(ldns_edns_option_code code, size_t size, void *data);
ldns_edns_option *ldns_edns_new_from_data(ldns_edns_option_code code, size_t size, const void *data);
ldns_edns_option *ldns_edns_clone(ldns_edns_option *edns);
void ldns_edns_deep_free(ldns_edns_option *edns);
void ldns_edns_free(ldns_edns_option *edns);
ldns_edns_option_list* ldns_edns_option_list_new(void);
ldns_edns_option_list *ldns_edns_option_list_clone(ldns_edns_option_list *options_list);
void ldns_edns_option_list_free(ldns_edns_option_list *options_list);
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list);
/* edns_option_list functions */
size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *options_list);
ldns_edns_option* ldns_edns_option_list_get_option(const ldns_edns_option_list *options_list,
size_t index);
size_t ldns_edns_option_list_get_options_size(const ldns_edns_option_list *options_list);
ldns_edns_option *ldns_edns_option_list_set_option(ldns_edns_option_list *options_list,
ldns_edns_option *option, size_t index);
bool ldns_edns_option_list_push(ldns_edns_option_list *options_list,
ldns_edns_option *option);
ldns_edns_option* ldns_edns_option_list_pop(ldns_edns_option_list *options_list);
ldns_buffer *ldns_edns_option_list2wireformat_buffer(const ldns_edns_option_list *option_list);
#ifdef __cplusplus
}
#endif
#endif /* LDNS_EDNS_H */
ldns_buffer
struct ldns_struct_buffer ldns_buffer
Definition buffer.h:72
common.h
Common definitions for LDNS.
ldns_edns_option_list_set_option
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_enum_ede_code
ldns_edns_enum_ede_code
Extended DNS Error (RFC 8914) codes.
Definition edns.h:52
LDNS_EDE_DNSSEC_INDETERMINATE
@ LDNS_EDE_DNSSEC_INDETERMINATE
Definition edns.h:58
LDNS_EDE_NOT_SUPPORTED
@ LDNS_EDE_NOT_SUPPORTED
Definition edns.h:74
LDNS_EDE_PROHIBITED
@ LDNS_EDE_PROHIBITED
Definition edns.h:71
LDNS_EDE_NOT_READY
@ LDNS_EDE_NOT_READY
Definition edns.h:67
LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
@ LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
Definition edns.h:54
LDNS_EDE_RRSIGS_MISSING
@ LDNS_EDE_RRSIGS_MISSING
Definition edns.h:63
LDNS_EDE_NO_REACHABLE_AUTHORITY
@ LDNS_EDE_NO_REACHABLE_AUTHORITY
Definition edns.h:75
LDNS_EDE_SIGNATURE_EXPIRED
@ LDNS_EDE_SIGNATURE_EXPIRED
Definition edns.h:60
LDNS_EDE_DNSSEC_BOGUS
@ LDNS_EDE_DNSSEC_BOGUS
Definition edns.h:59
LDNS_EDE_CENSORED
@ LDNS_EDE_CENSORED
Definition edns.h:69
LDNS_EDE_STALE_NXDOMAIN_ANSWER
@ LDNS_EDE_STALE_NXDOMAIN_ANSWER
Definition edns.h:72
LDNS_EDE_NO_ZONE_KEY_BIT_SET
@ LDNS_EDE_NO_ZONE_KEY_BIT_SET
Definition edns.h:64
LDNS_EDE_DNSKEY_MISSING
@ LDNS_EDE_DNSKEY_MISSING
Definition edns.h:62
LDNS_EDE_NETWORK_ERROR
@ LDNS_EDE_NETWORK_ERROR
Definition edns.h:76
LDNS_EDE_FILTERED
@ LDNS_EDE_FILTERED
Definition edns.h:70
LDNS_EDE_BLOCKED
@ LDNS_EDE_BLOCKED
Definition edns.h:68
LDNS_EDE_FORGED_ANSWER
@ LDNS_EDE_FORGED_ANSWER
Definition edns.h:57
LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
@ LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
Definition edns.h:78
LDNS_EDE_STALE_ANSWER
@ LDNS_EDE_STALE_ANSWER
Definition edns.h:56
LDNS_EDE_NOT_AUTHORITATIVE
@ LDNS_EDE_NOT_AUTHORITATIVE
Definition edns.h:73
LDNS_EDE_CACHED_ERROR
@ LDNS_EDE_CACHED_ERROR
Definition edns.h:66
LDNS_EDE_NSEC_MISSING
@ LDNS_EDE_NSEC_MISSING
Definition edns.h:65
LDNS_EDE_OTHER
@ LDNS_EDE_OTHER
Definition edns.h:53
LDNS_EDE_INVALID_DATA
@ LDNS_EDE_INVALID_DATA
Definition edns.h:77
LDNS_EDE_SIGNATURE_NOT_YET_VALID
@ LDNS_EDE_SIGNATURE_NOT_YET_VALID
Definition edns.h:61
LDNS_EDE_UNSUPPORTED_DS_DIGEST
@ LDNS_EDE_UNSUPPORTED_DS_DIGEST
Definition edns.h:55
LDNS_EDE_TOO_EARLY
@ LDNS_EDE_TOO_EARLY
Definition edns.h:79
ldns_edns_option_list2wireformat_buffer
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
ldns_edns_get_wireformat_buffer
ldns_buffer * ldns_edns_get_wireformat_buffer(const ldns_edns_option *edns)
serialise the EDNS option into wireformat.
Definition edns.c:84
ldns_edns_option_list_free
void ldns_edns_option_list_free(ldns_edns_option_list *options_list)
free the EDNS option list.
Definition edns.c:255
ldns_edns_option_code
enum ldns_enum_edns_option ldns_edns_option_code
Definition edns.h:46
ldns_edns_ede_code
enum ldns_edns_enum_ede_code ldns_edns_ede_code
Definition edns.h:81
ldns_edns_ede_get_code
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_get_data
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
Definition edns.c:39
ldns_edns_new
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
ldns_edns_new_from_data
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
ldns_edns_option_list_get_options_size
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_list
struct ldns_struct_edns_option_list ldns_edns_option_list
Definition edns.h:115
ldns_edns_get_code
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_list_new
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_option_list_pop
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_edns_ede_get_text
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
ldns_edns_option_list_push
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
ldns_edns_option_list_clone
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_list_deep_free
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list)
Definition edns.c:264
ldns_edns_option
struct ldns_struct_edns_option ldns_edns_option
Definition edns.h:102
ldns_edns_get_size
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
Definition edns.c:25
ldns_edns_deep_free
void ldns_edns_deep_free(ldns_edns_option *edns)
free the EDNS option.
Definition edns.c:190
ldns_edns_clone
ldns_edns_option * ldns_edns_clone(ldns_edns_option *edns)
clone an EDNS option
Definition edns.c:176
ldns_edns_option_list_get_option
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_list_get_count
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_free
void ldns_edns_free(ldns_edns_option *edns)
Definition edns.c:201
ldns_enum_edns_option
ldns_enum_edns_option
EDNS option codes.
Definition edns.h:27
LDNS_EDNS_NSID
@ LDNS_EDNS_NSID
Definition edns.h:30
LDNS_EDNS_KEEPALIVE
@ LDNS_EDNS_KEEPALIVE
Definition edns.h:38
LDNS_EDNS_DHU
@ LDNS_EDNS_DHU
Definition edns.h:33
LDNS_EDNS_PADDING
@ LDNS_EDNS_PADDING
Definition edns.h:39
LDNS_EDNS_COOKIE
@ LDNS_EDNS_COOKIE
Definition edns.h:37
LDNS_EDNS_DAU
@ LDNS_EDNS_DAU
Definition edns.h:32
LDNS_EDNS_N3U
@ LDNS_EDNS_N3U
Definition edns.h:34
LDNS_EDNS_UL
@ LDNS_EDNS_UL
Definition edns.h:29
LDNS_EDNS_CLIENT_SUBNET
@ LDNS_EDNS_CLIENT_SUBNET
Definition edns.h:35
LDNS_EDNS_KEY_TAG
@ LDNS_EDNS_KEY_TAG
Definition edns.h:41
LDNS_EDNS_CHAIN
@ LDNS_EDNS_CHAIN
Definition edns.h:40
LDNS_EDNS_CLIENT_TAG
@ LDNS_EDNS_CLIENT_TAG
Definition edns.h:43
LDNS_EDNS_EDE
@ LDNS_EDNS_EDE
Definition edns.h:42
LDNS_EDNS_LLQ
@ LDNS_EDNS_LLQ
Definition edns.h:28
LDNS_EDNS_SERVER_TAG
@ LDNS_EDNS_SERVER_TAG
Definition edns.h:44
LDNS_EDNS_EXPIRE
@ LDNS_EDNS_EXPIRE
Definition edns.h:36
ldns_status
enum ldns_enum_status ldns_status
Definition error.h:148
ldns_struct_edns_option_list
Definition edns.h:109
ldns_struct_edns_option_list::_option_capacity
size_t _option_capacity
Definition edns.h:111
ldns_struct_edns_option_list::_options_size
size_t _options_size
Definition edns.h:112
ldns_struct_edns_option_list::_options
ldns_edns_option ** _options
Definition edns.h:113
ldns_struct_edns_option_list::_option_count
size_t _option_count
Definition edns.h:110
ldns_struct_edns_option
The struct that stores an ordered EDNS option.
Definition edns.h:97
ldns_struct_edns_option::_size
size_t _size
Definition edns.h:99
ldns_struct_edns_option::_code
ldns_edns_option_code _code
Definition edns.h:98
ldns_struct_edns_option::_data
void * _data
Definition edns.h:100