This file contains the definition of ldns_buffer, and functions to manipulate those. More...
Go to the source code of this file.
Data Structures | |
struct | ldns_struct_buffer |
implementation of buffers to ease operations More... | |
Defines | |
#define | LDNS_MIN_BUFLEN 512 |
number of initial bytes in buffer of which we cannot tell the size before hand | |
Typedefs | |
typedef struct ldns_struct_buffer | ldns_buffer |
Functions | |
INLINE void | ldns_buffer_invariant (ldns_buffer *buffer) |
ldns_buffer * | ldns_buffer_new (size_t capacity) |
creates a new buffer with the specified capacity. | |
void | ldns_buffer_new_frm_data (ldns_buffer *buffer, void *data, size_t size) |
creates a buffer with the specified data. | |
INLINE void | ldns_buffer_clear (ldns_buffer *buffer) |
clears the buffer and make it ready for writing. | |
INLINE void | ldns_buffer_flip (ldns_buffer *buffer) |
makes the buffer ready for reading the data that has been written to the buffer. | |
INLINE void | ldns_buffer_rewind (ldns_buffer *buffer) |
make the buffer ready for re-reading the data. | |
INLINE size_t | ldns_buffer_position (ldns_buffer *buffer) |
returns the current position in the buffer (as a number of bytes) | |
INLINE void | ldns_buffer_set_position (ldns_buffer *buffer, size_t mark) |
sets the buffer's position to MARK. | |
INLINE void | ldns_buffer_skip (ldns_buffer *buffer, ssize_t count) |
changes the buffer's position by COUNT bytes. | |
INLINE size_t | ldns_buffer_limit (ldns_buffer *buffer) |
returns the maximum size of the buffer | |
INLINE void | ldns_buffer_set_limit (ldns_buffer *buffer, size_t limit) |
changes the buffer's limit. | |
INLINE size_t | ldns_buffer_capacity (ldns_buffer *buffer) |
returns the number of bytes the buffer can hold. | |
bool | ldns_buffer_set_capacity (ldns_buffer *buffer, size_t capacity) |
changes the buffer's capacity. | |
bool | ldns_buffer_reserve (ldns_buffer *buffer, size_t amount) |
ensures BUFFER can contain at least AMOUNT more bytes. | |
INLINE uint8_t * | ldns_buffer_at (const ldns_buffer *buffer, size_t at) |
returns a pointer to the data at the indicated position. | |
INLINE uint8_t * | ldns_buffer_begin (const ldns_buffer *buffer) |
returns a pointer to the beginning of the buffer (the data at position 0). | |
INLINE uint8_t * | ldns_buffer_end (ldns_buffer *buffer) |
returns a pointer to the end of the buffer (the data at the buffer's limit). | |
INLINE uint8_t * | ldns_buffer_current (ldns_buffer *buffer) |
returns a pointer to the data at the buffer's current position. | |
INLINE size_t | ldns_buffer_remaining_at (ldns_buffer *buffer, size_t at) |
returns the number of bytes remaining between the indicated position and the limit. | |
INLINE size_t | ldns_buffer_remaining (ldns_buffer *buffer) |
returns the number of bytes remaining between the buffer's position and limit. | |
INLINE int | ldns_buffer_available_at (ldns_buffer *buffer, size_t at, size_t count) |
checks if the buffer has at least COUNT more bytes available. | |
INLINE int | ldns_buffer_available (ldns_buffer *buffer, size_t count) |
checks if the buffer has count bytes available at the current position | |
INLINE void | ldns_buffer_write_at (ldns_buffer *buffer, size_t at, const void *data, size_t count) |
writes the given data to the buffer at the specified position | |
INLINE void | ldns_buffer_write (ldns_buffer *buffer, const void *data, size_t count) |
writes count bytes of data to the current position of the buffer | |
INLINE void | ldns_buffer_write_string_at (ldns_buffer *buffer, size_t at, const char *str) |
copies the given (null-delimited) string to the specified position at the buffer | |
INLINE void | ldns_buffer_write_string (ldns_buffer *buffer, const char *str) |
copies the given (null-delimited) string to the current position at the buffer | |
INLINE void | ldns_buffer_write_u8_at (ldns_buffer *buffer, size_t at, uint8_t data) |
writes the given byte of data at the given position in the buffer | |
INLINE void | ldns_buffer_write_u8 (ldns_buffer *buffer, uint8_t data) |
writes the given byte of data at the current position in the buffer | |
INLINE void | ldns_buffer_write_u16_at (ldns_buffer *buffer, size_t at, uint16_t data) |
writes the given 2 byte integer at the given position in the buffer | |
INLINE void | ldns_buffer_write_u16 (ldns_buffer *buffer, uint16_t data) |
writes the given 2 byte integer at the current position in the buffer | |
INLINE void | ldns_buffer_write_u32_at (ldns_buffer *buffer, size_t at, uint32_t data) |
writes the given 4 byte integer at the given position in the buffer | |
INLINE void | ldns_buffer_write_u32 (ldns_buffer *buffer, uint32_t data) |
writes the given 4 byte integer at the current position in the buffer | |
INLINE void | ldns_buffer_read_at (ldns_buffer *buffer, size_t at, void *data, size_t count) |
copies count bytes of data at the given position to the given data-array | |
INLINE void | ldns_buffer_read (ldns_buffer *buffer, void *data, size_t count) |
copies count bytes of data at the current position to the given data-array | |
INLINE uint8_t | ldns_buffer_read_u8_at (ldns_buffer *buffer, size_t at) |
returns the byte value at the given position in the buffer | |
INLINE uint8_t | ldns_buffer_read_u8 (ldns_buffer *buffer) |
returns the byte value at the current position in the buffer | |
INLINE uint16_t | ldns_buffer_read_u16_at (ldns_buffer *buffer, size_t at) |
returns the 2-byte integer value at the given position in the buffer | |
INLINE uint16_t | ldns_buffer_read_u16 (ldns_buffer *buffer) |
returns the 2-byte integer value at the current position in the buffer | |
INLINE uint32_t | ldns_buffer_read_u32_at (ldns_buffer *buffer, size_t at) |
returns the 4-byte integer value at the given position in the buffer | |
INLINE uint32_t | ldns_buffer_read_u32 (ldns_buffer *buffer) |
returns the 4-byte integer value at the current position in the buffer | |
INLINE ldns_status | ldns_buffer_status (ldns_buffer *buffer) |
returns the status of the buffer | |
INLINE bool | ldns_buffer_status_ok (ldns_buffer *buffer) |
returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise | |
int | ldns_buffer_printf (ldns_buffer *buffer, const char *format,...) |
prints to the buffer, increasing the capacity if required using buffer_reserve(). | |
void | ldns_buffer_free (ldns_buffer *buffer) |
frees the buffer. | |
void * | ldns_buffer_export (ldns_buffer *buffer) |
Makes the buffer fixed and returns a pointer to the data. | |
void | ldns_buffer_copy (ldns_buffer *result, ldns_buffer *from) |
Copy contents of the other buffer to this buffer. |
This file contains the definition of ldns_buffer, and functions to manipulate those.
Definition in file buffer.h.
#define LDNS_MIN_BUFLEN 512 |
typedef struct ldns_struct_buffer ldns_buffer |
INLINE void ldns_buffer_invariant | ( | ldns_buffer * | buffer | ) |
Definition at line 82 of file buffer.h.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_data, ldns_struct_buffer::_limit, and ldns_struct_buffer::_position.
ldns_buffer* ldns_buffer_new | ( | size_t | capacity | ) |
creates a new buffer with the specified capacity.
[in] | capacity | the size (in bytes) to allocate for the buffer |
Definition at line 16 of file buffer.c.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_data, ldns_struct_buffer::_fixed, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, ldns_struct_buffer::_status, ldns_buffer_invariant(), LDNS_FREE, LDNS_MALLOC, LDNS_STATUS_OK, and LDNS_XMALLOC.
void ldns_buffer_new_frm_data | ( | ldns_buffer * | buffer, |
void * | data, | ||
size_t | size | ||
) |
creates a buffer with the specified data.
The data IS copied and MEMORY allocations are done. The buffer is not fixed and can be resized using buffer_reserve().
[in] | buffer | pointer to the buffer to put the data in |
[in] | data | the data to encapsulate in the buffer |
[in] | size | the size of the data |
Definition at line 41 of file buffer.c.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_data, ldns_struct_buffer::_fixed, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, ldns_struct_buffer::_status, ldns_buffer_invariant(), LDNS_STATUS_MEM_ERR, LDNS_STATUS_OK, and LDNS_XMALLOC.
INLINE void ldns_buffer_clear | ( | ldns_buffer * | buffer | ) |
clears the buffer and make it ready for writing.
The buffer's limit is set to the capacity and the position is set to 0.
[in] | buffer | the buffer to clear |
Definition at line 115 of file buffer.h.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, and ldns_buffer_invariant().
INLINE void ldns_buffer_flip | ( | ldns_buffer * | buffer | ) |
makes the buffer ready for reading the data that has been written to the buffer.
The buffer's limit is set to the current position and the position is set to 0.
[in] | buffer | the buffer to flip |
Definition at line 133 of file buffer.h.
References ldns_struct_buffer::_limit, ldns_struct_buffer::_position, and ldns_buffer_invariant().
INLINE void ldns_buffer_rewind | ( | ldns_buffer * | buffer | ) |
make the buffer ready for re-reading the data.
The buffer's position is reset to 0.
[in] | buffer | the buffer to rewind |
Definition at line 146 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_invariant().
INLINE size_t ldns_buffer_position | ( | ldns_buffer * | buffer | ) |
returns the current position in the buffer (as a number of bytes)
[in] | buffer | the buffer |
Definition at line 159 of file buffer.h.
References ldns_struct_buffer::_position.
INLINE void ldns_buffer_set_position | ( | ldns_buffer * | buffer, |
size_t | mark | ||
) |
sets the buffer's position to MARK.
The position must be less than or equal to the buffer's limit.
[in] | buffer | the buffer |
[in] | mark | the mark to use |
Definition at line 171 of file buffer.h.
References ldns_struct_buffer::_limit, and ldns_struct_buffer::_position.
INLINE void ldns_buffer_skip | ( | ldns_buffer * | buffer, |
ssize_t | count | ||
) |
changes the buffer's position by COUNT bytes.
The position must not be moved behind the buffer's limit or before the beginning of the buffer.
[in] | buffer | the buffer |
[in] | count | the count to use |
Definition at line 185 of file buffer.h.
References ldns_struct_buffer::_limit, and ldns_struct_buffer::_position.
INLINE size_t ldns_buffer_limit | ( | ldns_buffer * | buffer | ) |
returns the maximum size of the buffer
[in] | buffer |
Definition at line 197 of file buffer.h.
References ldns_struct_buffer::_limit.
INLINE void ldns_buffer_set_limit | ( | ldns_buffer * | buffer, |
size_t | limit | ||
) |
changes the buffer's limit.
If the buffer's position is greater than the new limit the position is set to the limit.
[in] | buffer | the buffer |
[in] | limit | the new limit |
Definition at line 209 of file buffer.h.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_limit, and ldns_struct_buffer::_position.
INLINE size_t ldns_buffer_capacity | ( | ldns_buffer * | buffer | ) |
returns the number of bytes the buffer can hold.
[in] | buffer | the buffer |
Definition at line 223 of file buffer.h.
References ldns_struct_buffer::_capacity.
bool ldns_buffer_set_capacity | ( | ldns_buffer * | buffer, |
size_t | capacity | ||
) |
changes the buffer's capacity.
The data is reallocated so any pointers to the data may become invalid. The buffer's limit is set to the buffer's new capacity.
[in] | buffer | the buffer |
[in] | capacity | the capacity to use |
Definition at line 60 of file buffer.c.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_data, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, ldns_struct_buffer::_status, ldns_buffer_invariant(), LDNS_STATUS_MEM_ERR, and LDNS_XREALLOC.
bool ldns_buffer_reserve | ( | ldns_buffer * | buffer, |
size_t | amount | ||
) |
ensures BUFFER can contain at least AMOUNT more bytes.
The buffer's capacity is increased if necessary using buffer_set_capacity().
The buffer's limit is always set to the (possibly increased) capacity.
[in] | buffer | the buffer |
[in] | amount | amount to use |
Definition at line 79 of file buffer.c.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_fixed, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, ldns_struct_buffer::_status, ldns_buffer_invariant(), ldns_buffer_set_capacity(), and LDNS_STATUS_MEM_ERR.
INLINE uint8_t* ldns_buffer_at | ( | const ldns_buffer * | buffer, |
size_t | at | ||
) |
returns a pointer to the data at the indicated position.
[in] | buffer | the buffer |
[in] | at | position |
Definition at line 257 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_struct_buffer::_limit.
INLINE uint8_t* ldns_buffer_begin | ( | const ldns_buffer * | buffer | ) |
returns a pointer to the beginning of the buffer (the data at position 0).
[in] | buffer | the buffer |
Definition at line 270 of file buffer.h.
References ldns_buffer_at().
INLINE uint8_t* ldns_buffer_end | ( | ldns_buffer * | buffer | ) |
returns a pointer to the end of the buffer (the data at the buffer's limit).
[in] | buffer | the buffer |
Definition at line 282 of file buffer.h.
References ldns_struct_buffer::_limit, and ldns_buffer_at().
INLINE uint8_t* ldns_buffer_current | ( | ldns_buffer * | buffer | ) |
returns a pointer to the data at the buffer's current position.
[in] | buffer | the buffer |
Definition at line 293 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_at().
INLINE size_t ldns_buffer_remaining_at | ( | ldns_buffer * | buffer, |
size_t | at | ||
) |
returns the number of bytes remaining between the indicated position and the limit.
[in] | buffer | the buffer |
[in] | at | indicated position |
Definition at line 306 of file buffer.h.
References ldns_struct_buffer::_limit, and ldns_buffer_invariant().
INLINE size_t ldns_buffer_remaining | ( | ldns_buffer * | buffer | ) |
returns the number of bytes remaining between the buffer's position and limit.
[in] | buffer | the buffer |
Definition at line 320 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_remaining_at().
INLINE int ldns_buffer_available_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
size_t | count | ||
) |
checks if the buffer has at least COUNT more bytes available.
Before reading or writing the caller needs to ensure enough space is available!
[in] | buffer | the buffer |
[in] | at | indicated position |
[in] | count | how much is available |
Definition at line 335 of file buffer.h.
References ldns_buffer_remaining_at().
INLINE int ldns_buffer_available | ( | ldns_buffer * | buffer, |
size_t | count | ||
) |
checks if the buffer has count bytes available at the current position
[in] | buffer | the buffer |
[in] | count | how much is available |
Definition at line 347 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_available_at().
INLINE void ldns_buffer_write_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
const void * | data, | ||
size_t | count | ||
) |
writes the given data to the buffer at the specified position
[in] | buffer | the buffer |
[in] | at | the position (in number of bytes) to write the data at |
[in] | data | pointer to the data to write to the buffer |
[in] | count | the number of bytes of data to write |
Definition at line 360 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE void ldns_buffer_write | ( | ldns_buffer * | buffer, |
const void * | data, | ||
size_t | count | ||
) |
writes count bytes of data to the current position of the buffer
[in] | buffer | the buffer |
[in] | data | the data to write |
[in] | count | the lenght of the data to write |
Definition at line 373 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_write_at().
INLINE void ldns_buffer_write_string_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
const char * | str | ||
) |
copies the given (null-delimited) string to the specified position at the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
[in] | str | the string to write |
Definition at line 386 of file buffer.h.
References ldns_buffer_write_at().
INLINE void ldns_buffer_write_string | ( | ldns_buffer * | buffer, |
const char * | str | ||
) |
copies the given (null-delimited) string to the current position at the buffer
[in] | buffer | the buffer |
[in] | str | the string to write |
Definition at line 397 of file buffer.h.
References ldns_buffer_write().
INLINE void ldns_buffer_write_u8_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
uint8_t | data | ||
) |
writes the given byte of data at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
[in] | data | the 8 bits to write |
Definition at line 409 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE void ldns_buffer_write_u8 | ( | ldns_buffer * | buffer, |
uint8_t | data | ||
) |
writes the given byte of data at the current position in the buffer
[in] | buffer | the buffer |
[in] | data | the 8 bits to write |
Definition at line 421 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_write_u8_at().
INLINE void ldns_buffer_write_u16_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
uint16_t | data | ||
) |
writes the given 2 byte integer at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
[in] | data | the 16 bits to write |
Definition at line 434 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE void ldns_buffer_write_u16 | ( | ldns_buffer * | buffer, |
uint16_t | data | ||
) |
writes the given 2 byte integer at the current position in the buffer
[in] | buffer | the buffer |
[in] | data | the 16 bits to write |
Definition at line 446 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_write_u16_at().
INLINE void ldns_buffer_write_u32_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
uint32_t | data | ||
) |
writes the given 4 byte integer at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
[in] | data | the 32 bits to write |
Definition at line 459 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE void ldns_buffer_write_u32 | ( | ldns_buffer * | buffer, |
uint32_t | data | ||
) |
writes the given 4 byte integer at the current position in the buffer
[in] | buffer | the buffer |
[in] | data | the 32 bits to write |
Definition at line 471 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_write_u32_at().
INLINE void ldns_buffer_read_at | ( | ldns_buffer * | buffer, |
size_t | at, | ||
void * | data, | ||
size_t | count | ||
) |
copies count bytes of data at the given position to the given data-array
[in] | buffer | the buffer |
[in] | at | the position in the buffer to start |
[out] | data | buffer to copy to |
[in] | count | the length of the data to copy |
Definition at line 485 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE void ldns_buffer_read | ( | ldns_buffer * | buffer, |
void * | data, | ||
size_t | count | ||
) |
copies count bytes of data at the current position to the given data-array
[in] | buffer | the buffer |
[out] | data | buffer to copy to |
[in] | count | the length of the data to copy |
Definition at line 498 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_read_at().
INLINE uint8_t ldns_buffer_read_u8_at | ( | ldns_buffer * | buffer, |
size_t | at | ||
) |
returns the byte value at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
Definition at line 511 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE uint8_t ldns_buffer_read_u8 | ( | ldns_buffer * | buffer | ) |
returns the byte value at the current position in the buffer
[in] | buffer | the buffer |
Definition at line 523 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_read_u8_at().
INLINE uint16_t ldns_buffer_read_u16_at | ( | ldns_buffer * | buffer, |
size_t | at | ||
) |
returns the 2-byte integer value at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | position in the buffer |
Definition at line 537 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE uint16_t ldns_buffer_read_u16 | ( | ldns_buffer * | buffer | ) |
returns the 2-byte integer value at the current position in the buffer
[in] | buffer | the buffer |
Definition at line 549 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_read_u16_at().
INLINE uint32_t ldns_buffer_read_u32_at | ( | ldns_buffer * | buffer, |
size_t | at | ||
) |
returns the 4-byte integer value at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | position in the buffer |
Definition at line 563 of file buffer.h.
References ldns_struct_buffer::_data, and ldns_buffer_available_at().
INLINE uint32_t ldns_buffer_read_u32 | ( | ldns_buffer * | buffer | ) |
returns the 4-byte integer value at the current position in the buffer
[in] | buffer | the buffer |
Definition at line 575 of file buffer.h.
References ldns_struct_buffer::_position, and ldns_buffer_read_u32_at().
INLINE ldns_status ldns_buffer_status | ( | ldns_buffer * | buffer | ) |
returns the status of the buffer
[in] | buffer |
Definition at line 588 of file buffer.h.
References ldns_struct_buffer::_status.
INLINE bool ldns_buffer_status_ok | ( | ldns_buffer * | buffer | ) |
returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise
[in] | buffer | the buffer |
Definition at line 599 of file buffer.h.
References ldns_buffer_status(), and LDNS_STATUS_OK.
int ldns_buffer_printf | ( | ldns_buffer * | buffer, |
const char * | format, | ||
... | |||
) |
prints to the buffer, increasing the capacity if required using buffer_reserve().
The buffer's position is set to the terminating '\0' Returns the number of characters written (not including the terminating '\0') or -1 on failure.
Definition at line 99 of file buffer.c.
References ldns_struct_buffer::_capacity, ldns_struct_buffer::_limit, ldns_struct_buffer::_position, ldns_struct_buffer::_status, ldns_buffer_current(), ldns_buffer_invariant(), ldns_buffer_remaining(), ldns_buffer_reserve(), ldns_buffer_status_ok(), LDNS_STATUS_INTERNAL_ERR, and LDNS_STATUS_MEM_ERR.
void ldns_buffer_free | ( | ldns_buffer * | buffer | ) |
frees the buffer.
[in] | *buffer | the buffer to be freed |
Definition at line 137 of file buffer.c.
References ldns_struct_buffer::_data, and LDNS_FREE.
void* ldns_buffer_export | ( | ldns_buffer * | buffer | ) |
Makes the buffer fixed and returns a pointer to the data.
The caller is responsible for free'ing the result.
[in] | *buffer | the buffer to be exported |
Definition at line 149 of file buffer.c.
References ldns_struct_buffer::_data, and ldns_struct_buffer::_fixed.
void ldns_buffer_copy | ( | ldns_buffer * | result, |
ldns_buffer * | from | ||
) |
Copy contents of the other buffer to this buffer.
Silently truncated if this buffer is too small.
[out] | *result | resulting buffer which is copied to. |
[in] | *from | what to copy to result. |
Definition at line 167 of file buffer.c.
References ldns_buffer_begin(), ldns_buffer_capacity(), ldns_buffer_clear(), ldns_buffer_flip(), ldns_buffer_limit(), and ldns_buffer_write().