/build/ldns-NeVfgT/ldns-1.9.2/edns.c File Reference

Go to the source code of this file.

## Macros

#define | LDNS_OPTIONLIST_INIT 8

## Functions

size_t | ldns_edns_get_size (const ldns_edns_option *edns)
| returns the size of the EDNS data.
ldns_edns_option_code | ldns_edns_get_code (const ldns_edns_option *edns)
| returns the option code of the EDNS data.
uint8_t * | ldns_edns_get_data (const ldns_edns_option *edns)
| returns the EDNS option data.
ldns_status | ldns_edns_ede_get_code (const ldns_edns_option *edns, uint16_t *ede_code)
| extract the RFC 8914 extended error code value.
ldns_status | ldns_edns_ede_get_text (const ldns_edns_option *edns, char **ede_text)
| extract the optional RFC 8914 extended error code text.
ldns_buffer * | ldns_edns_get_wireformat_buffer (const ldns_edns_option *edns)
| serialise the EDNS option into wireformat.
ldns_edns_option * | ldns_edns_new (ldns_edns_option_code code, size_t size, void *data)
| allocates a new EDNS structure and fills it.
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.
ldns_edns_option * | ldns_edns_clone (ldns_edns_option *edns)
| clone an EDNS option
void | ldns_edns_deep_free (ldns_edns_option *edns)
| free the EDNS option.
void | ldns_edns_free (ldns_edns_option *edns)
ldns_edns_option_list * | ldns_edns_option_list_new (void)
| allocates space for a new list of EDNS options
ldns_edns_option_list * | ldns_edns_option_list_clone (ldns_edns_option_list *old_list)
| clone the EDNS options list and it's contents
void | ldns_edns_option_list_free (ldns_edns_option_list *option_list)
| free the EDNS option list.
void | ldns_edns_option_list_deep_free (ldns_edns_option_list *option_list)
size_t | ldns_edns_option_list_get_count (const ldns_edns_option_list *option_list)
| returns the number of options in the EDNS options list.
ldns_edns_option * | ldns_edns_option_list_get_option (const ldns_edns_option_list *option_list, size_t index)
| returns the EDNS option as the specified index in the list of EDNS options.
size_t | ldns_edns_option_list_get_options_size (const ldns_edns_option_list *option_list)
| returns the total size of all the individual EDNS options in the EDNS list.
ldns_edns_option * | ldns_edns_option_list_set_option (ldns_edns_option_list *option_list, ldns_edns_option *option, size_t index)
| adds an EDNS option to the list of options at the specified index.
signed char | ldns_edns_option_list_push (ldns_edns_option_list *option_list, ldns_edns_option *option)
| adds an EDNS option at the end of the list of options.
ldns_edns_option * | ldns_edns_option_list_pop (ldns_edns_option_list *option_list)
| removes and returns the EDNS option at the end of the list of options.
ldns_buffer * | ldns_edns_option_list2wireformat_buffer (const ldns_edns_option_list *option_list)
| serializes all the EDNS options into a single wireformat buffer

## Macro Definition Documentation

## LDNS_OPTIONLIST_INIT

#define LDNS_OPTIONLIST_INIT 8

Definition at line 16 of file edns.c.

## 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] | *edns | the EDNS struct to read from

Returns
  uint16_t with the size

Definition at line 25 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] | *edns | the EDNS struct to read from

Returns
  uint16_t with the size

Definition at line 32 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] | *edns | the EDNS option to read from

Returns
  uint8_t* pointer to the EDNS option's data

Definition at line 39 of file edns.c.

References ldns_struct_edns_option::_data.

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

Parameters

  [in] | *edns | the EDNS option to extract the extended error code from
  [in,out] | *ede_code | pointer to an uint16_t in which to store the extended error code

Returns
  LDNS_STATUS_OK or an ldns_status message with the error (LDNS_STATUS_NOT_EDE or LDNS_STATUS_EDE_OPTION_MALFORMED)

Definition at line 46 of file edns.c.

References ldns_struct_edns_option::_code, ldns_struct_edns_option::_data, ldns_struct_edns_option::_size, LDNS_EDNS_EDE, LDNS_STATUS_EDE_OPTION_MALFORMED, LDNS_STATUS_NOT_EDE, and LDNS_STATUS_OK.

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

Parameters

  [in] | *edns | the EDNS option to extract the extended error code from
  [in,out] | **ede_text | pointer to a char* in which to store the extended error text; allocated buffer must be freed by the caller, assigns NULL if no text was provided in the EDNS option

Returns
  LDNS_STATUS_OK or an ldns_status message with the error (LDNS_STATUS_NOT_EDE or LDNS_STATUS_EDE_OPTION_MALFORMED)

Definition at line 61 of file edns.c.

References ldns_struct_edns_option::_code, ldns_struct_edns_option::_data, ldns_struct_edns_option::_size, LDNS_EDNS_EDE, LDNS_STATUS_EDE_OPTION_MALFORMED, LDNS_STATUS_NOT_EDE, and LDNS_STATUS_OK.

## 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] | *edns | the EDNS option to read from

Returns
  ldns_buffer* the buffer containing the data

Definition at line 84 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] | code | the EDNS code
  [in] | size | size of the buffer
  [in] | data | pointer to the buffer to be assigned

Returns
  the new EDNS structure or NULL on failure

Definition at line 139 of file edns.c.

References 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] | code | the EDNS code
  [in] | size | size of the buffer
  [in] | data | pointer to the buffer to be assigned

Returns
  the new EDNS structure or NULL on failure

Definition at line 154 of file edns.c.

References ldns_struct_edns_option::_data, 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] | edns | the EDNS option

Returns
  the new EDNS structure

Definition at line 176 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] | edns | the EDNS option to free

Definition at line 190 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 201 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 209 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_list | the EDNS options_list to read from

Returns
  the new EDNS option list

Definition at line 224 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_list | the EDNS option to free

Definition at line 255 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 * | option_list | ) |

Definition at line 264 of file edns.c.

References ldns_edns_deep_free(), ldns_edns_option_list_free(), ldns_edns_option_list_get_count(), and ldns_edns_option_list_get_option().

## 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_list | the EDNS options_list to read from

Returns
  the number of EDNS options

Definition at line 277 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_list | the EDNS options_list to read from
  [in] | index | the 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 287 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_list | the EDNS options_list to read from

Returns
  the total size of the options combined

Definition at line 298 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_list | the EDNS options_list to add to
  [in] | option | the EDNS option to add to the list
  [in] | index | the index in the list where to set the option

Returns
  the EDNS option previously located at the index

Definition at line 309 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()

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.

Parameters

  [in] | options_list | the EDNS options_list to add to
  [in] | option | the (non-NULL) EDNS option to add to the list

Returns
  true on success and false of failure

Definition at line 338 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_list | the EDNS options_list to add to

Returns
  the EDNS option at the end of the list, or NULL on failure

Definition at line 384 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_list | the EDNS options_list to combine into one wireformat

Returns
  the filled buffer or NULL on failure

Definition at line 426 of file edns.c.

References ldns_buffer_free(), 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().