16 #define LDNS_OPTIONLIST_INIT 8
49 assert(ede_code != NULL);
55 *ede_code = (uint16_t) ntohs(*((uint16_t*) edns->
_data));
64 assert(ede_text != NULL);
74 *ede_text = (
char*) malloc((edns->
_size - 1) *
sizeof(char));
76 memset(*ede_text, 0, edns->
_size - 1);
77 memcpy(*ede_text, &((
char*)edns->
_data)[2], edns->
_size - 2);
101 if (buffer == NULL) {
105 ldns_buffer_write_u16(buffer, option);
106 ldns_buffer_write_u16(buffer, size);
107 ldns_buffer_write(buffer, data, size);
109 ldns_buffer_flip(buffer);
118 assert(edns != NULL);
125 assert(edns != NULL);
133 assert(edns != NULL);
146 ldns_edns_set_code(edns, code);
147 ldns_edns_set_size(edns, size);
148 ldns_edns_set_data(edns, data);
168 ldns_edns_set_code(edns, code);
169 ldns_edns_set_size(edns, size);
170 memcpy(edns->
_data, data, size);
180 assert(edns != NULL);
290 assert(option_list->
_options[index]);
291 return option_list->
_options[index];
314 assert(option_list != NULL);
320 if (option == NULL) {
333 option_list->
_options[index] = option;
344 assert(option_list != NULL);
346 if (option == NULL) {
354 if (option_count+1 > cap) {
390 assert(option_list != NULL);
428 size_t i, list_size, options_size, option, size;
431 uint8_t* data = NULL;
449 for (i = 0; i < list_size; i++) {
462 if (!(ldns_buffer_available(buffer, size + 4))) {
467 ldns_buffer_write_u16(buffer, option);
468 ldns_buffer_write_u16(buffer, size);
469 ldns_buffer_write(buffer, data, size);
472 ldns_buffer_flip(buffer);
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
ldns_edns_option * ldns_edns_clone(ldns_edns_option *edns)
clone an EDNS option
ldns_edns_option_list * ldns_edns_option_list_new(void)
allocates space for a new list of EDNS options
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
ldns_buffer * ldns_edns_get_wireformat_buffer(const ldns_edns_option *edns)
serialise the EDNS option into wireformat.
#define LDNS_OPTIONLIST_INIT
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_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_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_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
ldns_edns_option_list * ldns_edns_option_list_clone(ldns_edns_option_list *old_list)
clone the EDNS options list and it's contents
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.
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_status ldns_edns_ede_get_text(const ldns_edns_option *edns, char **ede_text)
extract the optional RFC 8914 extended error code text.
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
void ldns_edns_deep_free(ldns_edns_option *edns)
free the EDNS option.
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)
ldns_buffer * ldns_edns_option_list2wireformat_buffer(const ldns_edns_option_list *option_list)
serializes all the EDNS options into a single wireformat buffer
ldns_edns_option * ldns_edns_new(ldns_edns_option_code code, size_t size, void *data)
allocates a new EDNS structure and fills it.
void ldns_edns_free(ldns_edns_option *edns)
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_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.
enum ldns_enum_edns_option ldns_edns_option_code
@ LDNS_STATUS_EDE_OPTION_MALFORMED
enum ldns_enum_status ldns_status
Including this file will include all ldns files, and define some lookup tables.
implementation of buffers to ease operations
ldns_edns_option ** _options
The struct that stores an ordered EDNS option.
ldns_edns_option_code _code
#define LDNS_MALLOC(type)
Memory management macros.
#define LDNS_XMALLOC(type, count)
#define LDNS_XREALLOC(ptr, type, count)