unbound
0.1
|
This file contains the definition of sldns_buffer, and functions to manipulate those. More...
Functions | |
sldns_buffer * | sldns_buffer_new (size_t capacity) |
creates a new buffer with the specified capacity. More... | |
void | sldns_buffer_new_frm_data (sldns_buffer *buffer, void *data, size_t size) |
creates a buffer with the specified data. More... | |
void | sldns_buffer_init_frm_data (sldns_buffer *buffer, void *data, size_t size) |
Setup a buffer with the data pointed to. More... | |
void | sldns_buffer_init_vfixed_frm_data (sldns_buffer *buffer, void *data, size_t size) |
Setup a buffer with the data pointed to. More... | |
int | sldns_buffer_set_capacity (sldns_buffer *buffer, size_t capacity) |
changes the buffer's capacity. More... | |
int | sldns_buffer_reserve (sldns_buffer *buffer, size_t amount) |
ensures BUFFER can contain at least AMOUNT more bytes. More... | |
int | sldns_buffer_printf (sldns_buffer *buffer, const char *format,...) |
void | sldns_buffer_free (sldns_buffer *buffer) |
frees the buffer. More... | |
void * | sldns_buffer_export (sldns_buffer *buffer) |
Makes the buffer fixed and returns a pointer to the data. More... | |
void | sldns_buffer_copy (sldns_buffer *result, sldns_buffer *from) |
Copy contents of the from buffer to the result buffer and then flips the result buffer. More... | |
This file contains the definition of sldns_buffer, and functions to manipulate those.
sldns_buffer* sldns_buffer_new | ( | size_t | capacity | ) |
creates a new buffer with the specified capacity.
[in] | capacity | the size (in bytes) to allocate for the buffer |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, sldns_buffer::_status_err, and sldns_buffer::_vfixed.
Referenced by anchors_apply_cfg(), anchors_test(), answer_callback_from_entry(), check_mod(), comm_point_create_local(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_tcp_handle_callback(), dname_test(), dstest_file(), fake_front_query(), hex_buffer2wire(), libworker_setup(), listen_create(), log_dns_msg(), main(), mesh_create(), msgparse_test(), msgtostr(), nsec3_hash_test(), outside_network_create(), pending_tcp_query(), pending_udp_query(), process_answer_detail(), send_em(), service(), and verifytest_file().
void sldns_buffer_new_frm_data | ( | sldns_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 |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, sldns_buffer::_status_err, and sldns_buffer::_vfixed.
Referenced by hex_buffer2wire().
void sldns_buffer_init_frm_data | ( | sldns_buffer * | buffer, |
void * | data, | ||
size_t | size | ||
) |
Setup a buffer with the data pointed to.
No data copied, no memory allocs. The buffer is fixed.
[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 |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, and sldns_buffer::_vfixed.
Referenced by sldns_str2wire_ipseckey_buf(), sldns_str2wire_nsec_buf(), and sldns_str2wire_wks_buf().
void sldns_buffer_init_vfixed_frm_data | ( | sldns_buffer * | buffer, |
void * | data, | ||
size_t | size | ||
) |
Setup a buffer with the data pointed to.
No data copied, no memory allocs. The buffer is "virtually" fixed. Writes beyond size (the capacity) will only update position, but no data will be written beyond capacity. This allows to determine how big the buffer should have been to contain all the written data, by looking at the position with sldns_buffer_position(), similarly to the return value of POSIX's snprintf.
[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 |
References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, and sldns_buffer::_vfixed.
int sldns_buffer_set_capacity | ( | sldns_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 |
int sldns_buffer_reserve | ( | sldns_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 |
void sldns_buffer_free | ( | sldns_buffer * | buffer | ) |
frees the buffer.
[in] | *buffer | the buffer to be freed |
References sldns_buffer::_data, and sldns_buffer::_fixed.
Referenced by anchors_apply_cfg(), anchors_test(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_delete(), comm_point_drop_reply(), delete_fake_pending(), delete_replay_answer(), delete_replylist(), dname_test(), libworker_delete_env(), listen_delete(), log_dns_msg(), mesh_delete(), msgparse_test(), outnet_serviced_query_stop(), outside_network_delete(), and worker_delete().
void* sldns_buffer_export | ( | sldns_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 |
References sldns_buffer::_data, and sldns_buffer::_fixed.
void sldns_buffer_copy | ( | sldns_buffer * | result, |
sldns_buffer * | from | ||
) |
Copy contents of the from buffer to the result buffer and then flips the result buffer.
Data will be silently truncated if the result buffer is too small.
[out] | *result | resulting buffer which is copied to. |
[in] | *from | what to copy to result. |
References sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_clear(), sldns_buffer_flip(), sldns_buffer_limit(), and sldns_buffer_write().
Referenced by entry_to_buf(), and mesh_make_new_space().