15 #define LDNS_OPTIONLIST_INIT 8
66 ldns_buffer_write_u16(buffer, option);
67 ldns_buffer_write_u16(buffer, size);
68 ldns_buffer_write(buffer, data, size);
70 ldns_buffer_flip(buffer);
131 memcpy(edns->
_data, data, size);
141 assert(edns != NULL);
251 assert(option_list->
_options[index]);
252 return option_list->
_options[index];
275 assert(option_list != NULL);
281 if (option == NULL) {
294 option_list->
_options[index] = option;
305 assert(option_list != NULL);
307 if (option == NULL) {
315 if (option_count+1 > cap) {
351 assert(option_list != NULL);
389 size_t i, list_size, options_size, option, size;
392 uint8_t* data = NULL;
410 for (i = 0; i < list_size; i++) {
423 if (!(ldns_buffer_available(buffer, size + 4))) {
428 ldns_buffer_write_u16(buffer, option);
429 ldns_buffer_write_u16(buffer, size);
430 ldns_buffer_write(buffer, data, size);
433 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
bool 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.
void ldns_edns_set_code(ldns_edns_option *edns, ldns_edns_option_code code)
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_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.
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.
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_set_size(ldns_edns_option *edns, size_t size)
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_list * ldns_edns_option_list_new()
allocates space for a new list of EDNS options
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)
void ldns_edns_set_data(ldns_edns_option *edns, void *data)
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
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)