edns.h File Reference

Go to the source code of this file.

Data Structures

struct  ldns_struct_edns_option
 The struct that stores an ordered EDNS option. More...
 
struct  ldns_struct_edns_option_list
 

Typedefs

typedef enum ldns_enum_edns_option ldns_edns_option_code
 
typedef enum ldns_edns_enum_ede_code ldns_edns_ede_code
 
typedef struct ldns_struct_edns_option ldns_edns_option
 
typedef struct ldns_struct_edns_option_list ldns_edns_option_list
 

Enumerations

enum  ldns_enum_edns_option {
  LDNS_EDNS_LLQ = 1 , LDNS_EDNS_UL = 2 , LDNS_EDNS_NSID = 3 , LDNS_EDNS_DAU = 5 ,
  LDNS_EDNS_DHU = 6 , LDNS_EDNS_N3U = 7 , LDNS_EDNS_CLIENT_SUBNET = 8 , LDNS_EDNS_EXPIRE = 9 ,
  LDNS_EDNS_COOKIE = 10 , LDNS_EDNS_KEEPALIVE = 11 , LDNS_EDNS_PADDING = 12 , LDNS_EDNS_CHAIN = 13 ,
  LDNS_EDNS_KEY_TAG = 14 , LDNS_EDNS_EDE = 15 , LDNS_EDNS_CLIENT_TAG = 16 , LDNS_EDNS_SERVER_TAG = 17
}
 EDNS option codes. More...
 
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
}
 Extended DNS Error (RFC 8914) codes. More...
 

Functions

size_t ldns_edns_get_size (const ldns_edns_option *edns)
 returns the size of the EDNS data. More...
 
ldns_edns_option_code ldns_edns_get_code (const ldns_edns_option *edns)
 returns the option code of the EDNS data. More...
 
uint8_t * ldns_edns_get_data (const ldns_edns_option *edns)
 returns the EDNS option data. More...
 
ldns_bufferldns_edns_get_wireformat_buffer (const ldns_edns_option *edns)
 serialise the EDNS option into wireformat. More...
 
ldns_edns_optionldns_edns_new (ldns_edns_option_code code, size_t size, void *data)
 allocates a new EDNS structure and fills it. More...
 
ldns_edns_optionldns_edns_new_from_data (ldns_edns_option_code code, size_t size, const void *data)
 allocates a new EDNS structure and fills it. More...
 
ldns_edns_optionldns_edns_clone (ldns_edns_option *edns)
 clone an EDNS option More...
 
void ldns_edns_deep_free (ldns_edns_option *edns)
 free the EDNS option. More...
 
void ldns_edns_free (ldns_edns_option *edns)
 
ldns_edns_option_listldns_edns_option_list_new (void)
 allocates space for a new list of EDNS options More...
 
ldns_edns_option_listldns_edns_option_list_clone (ldns_edns_option_list *options_list)
 clone the EDNS options list and it's contents More...
 
void ldns_edns_option_list_free (ldns_edns_option_list *options_list)
 free the EDNS option list. More...
 
void ldns_edns_option_list_deep_free (ldns_edns_option_list *options_list)
 
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. More...
 
ldns_edns_optionldns_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. More...
 
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. More...
 
ldns_edns_optionldns_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. More...
 
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. More...
 
ldns_edns_optionldns_edns_option_list_pop (ldns_edns_option_list *options_list)
 removes and returns the EDNS option at the end of the list of options. More...
 
ldns_bufferldns_edns_option_list2wireformat_buffer (const ldns_edns_option_list *option_list)
 serializes all the EDNS options into a single wireformat buffer More...
 

Typedef Documentation

◆ ldns_edns_option_code

Definition at line 1 of file edns.h.

◆ ldns_edns_ede_code

Definition at line 1 of file edns.h.

◆ ldns_edns_option

Definition at line 1 of file edns.h.

◆ ldns_edns_option_list

Definition at line 1 of file edns.h.

Enumeration Type Documentation

◆ ldns_enum_edns_option

EDNS option codes.

Enumerator
LDNS_EDNS_LLQ 
LDNS_EDNS_UL 
LDNS_EDNS_NSID 
LDNS_EDNS_DAU 
LDNS_EDNS_DHU 
LDNS_EDNS_N3U 
LDNS_EDNS_CLIENT_SUBNET 
LDNS_EDNS_EXPIRE 
LDNS_EDNS_COOKIE 
LDNS_EDNS_KEEPALIVE 
LDNS_EDNS_PADDING 
LDNS_EDNS_CHAIN 
LDNS_EDNS_KEY_TAG 
LDNS_EDNS_EDE 
LDNS_EDNS_CLIENT_TAG 
LDNS_EDNS_SERVER_TAG 

Definition at line 26 of file edns.h.

◆ ldns_edns_enum_ede_code

Extended DNS Error (RFC 8914) codes.

Enumerator
LDNS_EDE_OTHER 
LDNS_EDE_UNSUPPORTED_DNSKEY_ALG 
LDNS_EDE_UNSUPPORTED_DS_DIGEST 
LDNS_EDE_STALE_ANSWER 
LDNS_EDE_FORGED_ANSWER 
LDNS_EDE_DNSSEC_INDETERMINATE 
LDNS_EDE_DNSSEC_BOGUS 
LDNS_EDE_SIGNATURE_EXPIRED 
LDNS_EDE_SIGNATURE_NOT_YET_VALID 
LDNS_EDE_DNSKEY_MISSING 
LDNS_EDE_RRSIGS_MISSING 
LDNS_EDE_NO_ZONE_KEY_BIT_SET 
LDNS_EDE_NSEC_MISSING 
LDNS_EDE_CACHED_ERROR 
LDNS_EDE_NOT_READY 
LDNS_EDE_BLOCKED 
LDNS_EDE_CENSORED 
LDNS_EDE_FILTERED 
LDNS_EDE_PROHIBITED 
LDNS_EDE_STALE_NXDOMAIN_ANSWER 
LDNS_EDE_NOT_AUTHORITATIVE 
LDNS_EDE_NOT_SUPPORTED 
LDNS_EDE_NO_REACHABLE_AUTHORITY 
LDNS_EDE_NETWORK_ERROR 
LDNS_EDE_INVALID_DATA 
LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID 
LDNS_EDE_TOO_EARLY 

Definition at line 51 of file edns.h.

Function Documentation

◆ ldns_edns_get_size()

size_t ldns_edns_get_size ( const ldns_edns_option edns)

returns the size of the EDNS data.

Parameters
[in]*ednsthe EDNS struct to read from
Returns
uint16_t with the size

Definition at line 24 of file edns.c.

References ldns_struct_edns_option::_size.

◆ 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.

Parameters
[in]*ednsthe EDNS struct to read from
Returns
uint16_t with the size

Definition at line 31 of file edns.c.

References ldns_struct_edns_option::_code.

◆ ldns_edns_get_data()

uint8_t* ldns_edns_get_data ( const ldns_edns_option edns)

returns the EDNS option data.

Parameters
[in]*ednsthe EDNS option to read from
Returns
uint8_t* pointer to the EDNS option's data

Definition at line 38 of file edns.c.

References ldns_struct_edns_option::_data.

◆ ldns_edns_get_wireformat_buffer()

ldns_buffer* ldns_edns_get_wireformat_buffer ( const ldns_edns_option edns)

serialise the EDNS option into wireformat.

Parameters
[in]*ednsthe EDNS option to read from
Returns
ldns_buffer* the buffer containing the data

Definition at line 45 of file edns.c.

References ldns_buffer_new(), ldns_edns_get_code(), ldns_edns_get_data(), and ldns_edns_get_size().

◆ 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.

This function DOES NOT copy the contents from the data parameter.

Parameters
[in]codethe EDNS code
[in]sizesize of the buffer
[in]datapointer to the buffer to be assigned
Returns
the new EDNS structure or NULL on failure

Definition at line 100 of file edns.c.

References ldns_edns_set_code(), ldns_edns_set_data(), ldns_edns_set_size(), and LDNS_MALLOC.

◆ 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.

This function DOES copy the contents from the data parameter.

Parameters
[in]codethe EDNS code
[in]sizesize of the buffer
[in]datapointer to the buffer to be assigned
Returns
the new EDNS structure or NULL on failure

Definition at line 115 of file edns.c.

References ldns_struct_edns_option::_data, ldns_edns_set_code(), ldns_edns_set_size(), LDNS_FREE, LDNS_MALLOC, and LDNS_XMALLOC.

◆ ldns_edns_clone()

ldns_edns_option* ldns_edns_clone ( ldns_edns_option edns)

clone an EDNS option

Parameters
[in]ednsthe EDNS option
Returns
the new EDNS structure

Definition at line 137 of file edns.c.

References ldns_edns_get_code(), ldns_edns_get_data(), ldns_edns_get_size(), and ldns_edns_new_from_data().

◆ ldns_edns_deep_free()

void ldns_edns_deep_free ( ldns_edns_option edns)

free the EDNS option.

Use deep_free if the _data member is allocated.

Parameters
[in]ednsthe EDNS option to free

Definition at line 151 of file edns.c.

References ldns_struct_edns_option::_data, and LDNS_FREE.

◆ ldns_edns_free()

void ldns_edns_free ( ldns_edns_option edns)

Definition at line 162 of file edns.c.

References LDNS_FREE.

◆ ldns_edns_option_list_new()

ldns_edns_option_list* ldns_edns_option_list_new ( void  )

allocates space for a new list of EDNS options

Returns
the new EDNS option list or NULL on failure

Definition at line 170 of file edns.c.

References ldns_struct_edns_option_list::_option_capacity, ldns_struct_edns_option_list::_option_count, ldns_struct_edns_option_list::_options, ldns_struct_edns_option_list::_options_size, and LDNS_MALLOC.

◆ 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

Parameters
[in]options_listthe EDNS options_list to read from
Returns
the new EDNS option list

Definition at line 185 of file edns.c.

References ldns_struct_edns_option_list::_option_count, ldns_edns_clone(), ldns_edns_deep_free(), ldns_edns_option_list_deep_free(), ldns_edns_option_list_get_option(), ldns_edns_option_list_new(), and ldns_edns_option_list_push().

◆ ldns_edns_option_list_free()

void ldns_edns_option_list_free ( ldns_edns_option_list options_list)

free the EDNS option list.

Use deep_free to free the options options in the list as well.

Parameters
[in]options_listthe EDNS option to free

Definition at line 216 of file edns.c.

References ldns_struct_edns_option_list::_options, and LDNS_FREE.

◆ ldns_edns_option_list_deep_free()

void ldns_edns_option_list_deep_free ( ldns_edns_option_list options_list)

◆ 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.

Parameters
[in]options_listthe EDNS options_list to read from
Returns
the number of EDNS options

Definition at line 238 of file edns.c.

References ldns_struct_edns_option_list::_option_count.

◆ 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.

Parameters
[in]options_listthe EDNS options_list to read from
[in]indexthe location of the EDNS option to get in the list
Returns
the EDNS option located at the index or NULL on failure

Definition at line 248 of file edns.c.

References ldns_struct_edns_option_list::_options, and ldns_edns_option_list_get_count().

◆ 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.

Parameters
[in]options_listthe EDNS options_list to read from
Returns
the total size of the options combined

Definition at line 259 of file edns.c.

References ldns_struct_edns_option_list::_options_size.

◆ 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.

Also returns the option that was previously at that index.

Parameters
[in]options_listthe EDNS options_list to add to
[in]optionthe EDNS option to add to the list
[in]indexthe index in the list where to set the option
Returns
the EDNS option previously located at the index

Definition at line 270 of file edns.c.

References ldns_struct_edns_option_list::_options, ldns_struct_edns_option_list::_options_size, ldns_edns_get_size(), ldns_edns_option_list_get_count(), and ldns_edns_option_list_get_option().

◆ ldns_edns_option_list_push()

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.

Parameters
[in]options_listthe EDNS options_list to add to
[in]optionthe (non-NULL) EDNS option to add to the list
Returns
true on success and false of failure

Definition at line 299 of file edns.c.

References ldns_struct_edns_option_list::_option_capacity, ldns_struct_edns_option_list::_option_count, ldns_struct_edns_option_list::_options, ldns_edns_option_list_get_count(), ldns_edns_option_list_set_option(), LDNS_OPTIONLIST_INIT, and LDNS_XREALLOC.

◆ 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.

Parameters
[in]options_listthe EDNS options_list to add to
Returns
the EDNS option at the end of the list, or NULL on failure

Definition at line 345 of file edns.c.

References ldns_struct_edns_option_list::_option_capacity, ldns_struct_edns_option_list::_option_count, ldns_struct_edns_option_list::_options, ldns_struct_edns_option_list::_options_size, ldns_edns_get_size(), ldns_edns_option_list_get_count(), ldns_edns_option_list_get_option(), LDNS_OPTIONLIST_INIT, and LDNS_XREALLOC.

◆ 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

Parameters
[in]option_listthe EDNS options_list to combine into one wireformat
Returns
the filled buffer or NULL on failure

Definition at line 387 of file edns.c.

References ldns_buffer_new(), ldns_edns_get_code(), ldns_edns_get_data(), ldns_edns_get_size(), ldns_edns_option_list_get_count(), ldns_edns_option_list_get_option(), and ldns_edns_option_list_get_options_size().