This file contains the definition of sldns_buffer, and functions to manipulate those. More...
Data Structures | |
struct | sldns_buffer |
implementation of buffers to ease operations More... | |
Macros | |
#define | INLINE static inline |
Typedefs | |
typedef struct sldns_buffer | sldns_buffer |
Functions | |
INLINE uint16_t | sldns_read_uint16 (const void *src) |
INLINE uint32_t | sldns_read_uint32 (const void *src) |
INLINE void | sldns_write_uint16 (void *dst, uint16_t data) |
INLINE void | sldns_write_uint32 (void *dst, uint32_t data) |
INLINE void | sldns_write_uint48 (void *dst, uint64_t data) |
INLINE void | sldns_buffer_invariant (sldns_buffer *buffer) |
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... | |
INLINE void | sldns_buffer_clear (sldns_buffer *buffer) |
clears the buffer and make it ready for writing. More... | |
INLINE void | sldns_buffer_flip (sldns_buffer *buffer) |
makes the buffer ready for reading the data that has been written to the buffer. More... | |
INLINE void | sldns_buffer_rewind (sldns_buffer *buffer) |
make the buffer ready for re-reading the data. More... | |
INLINE size_t | sldns_buffer_position (sldns_buffer *buffer) |
returns the current position in the buffer (as a number of bytes) More... | |
INLINE void | sldns_buffer_set_position (sldns_buffer *buffer, size_t mark) |
sets the buffer's position to MARK. More... | |
INLINE void | sldns_buffer_skip (sldns_buffer *buffer, ssize_t count) |
changes the buffer's position by COUNT bytes. More... | |
INLINE size_t | sldns_buffer_limit (sldns_buffer *buffer) |
returns the maximum size of the buffer More... | |
INLINE void | sldns_buffer_set_limit (sldns_buffer *buffer, size_t limit) |
changes the buffer's limit. More... | |
INLINE size_t | sldns_buffer_capacity (sldns_buffer *buffer) |
returns the number of bytes the buffer can hold. 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... | |
INLINE uint8_t * | sldns_buffer_at (const sldns_buffer *buffer, size_t at) |
returns a pointer to the data at the indicated position. More... | |
INLINE uint8_t * | sldns_buffer_begin (const sldns_buffer *buffer) |
returns a pointer to the beginning of the buffer (the data at position 0). More... | |
INLINE uint8_t * | sldns_buffer_end (sldns_buffer *buffer) |
returns a pointer to the end of the buffer (the data at the buffer's limit). More... | |
INLINE uint8_t * | sldns_buffer_current (sldns_buffer *buffer) |
returns a pointer to the data at the buffer's current position. More... | |
INLINE size_t | sldns_buffer_remaining_at (sldns_buffer *buffer, size_t at) |
returns the number of bytes remaining between the indicated position and the limit. More... | |
INLINE size_t | sldns_buffer_remaining (sldns_buffer *buffer) |
returns the number of bytes remaining between the buffer's position and limit. More... | |
INLINE int | sldns_buffer_available_at (sldns_buffer *buffer, size_t at, size_t count) |
checks if the buffer has at least COUNT more bytes available. More... | |
INLINE int | sldns_buffer_available (sldns_buffer *buffer, size_t count) |
checks if the buffer has count bytes available at the current position More... | |
INLINE void | sldns_buffer_write_at (sldns_buffer *buffer, size_t at, const void *data, size_t count) |
writes the given data to the buffer at the specified position More... | |
INLINE void | sldns_buffer_set_at (sldns_buffer *buffer, size_t at, int c, size_t count) |
set the given byte to the buffer at the specified position More... | |
INLINE void | sldns_buffer_write (sldns_buffer *buffer, const void *data, size_t count) |
writes count bytes of data to the current position of the buffer More... | |
INLINE void | sldns_buffer_write_string_at (sldns_buffer *buffer, size_t at, const char *str) |
copies the given (null-delimited) string to the specified position at the buffer More... | |
INLINE void | sldns_buffer_write_string (sldns_buffer *buffer, const char *str) |
copies the given (null-delimited) string to the current position at the buffer More... | |
INLINE void | sldns_buffer_write_u8_at (sldns_buffer *buffer, size_t at, uint8_t data) |
writes the given byte of data at the given position in the buffer More... | |
INLINE void | sldns_buffer_write_u8 (sldns_buffer *buffer, uint8_t data) |
writes the given byte of data at the current position in the buffer More... | |
INLINE void | sldns_buffer_write_u16_at (sldns_buffer *buffer, size_t at, uint16_t data) |
writes the given 2 byte integer at the given position in the buffer More... | |
INLINE void | sldns_buffer_write_u16 (sldns_buffer *buffer, uint16_t data) |
writes the given 2 byte integer at the current position in the buffer More... | |
INLINE void | sldns_buffer_write_u32_at (sldns_buffer *buffer, size_t at, uint32_t data) |
writes the given 4 byte integer at the given position in the buffer More... | |
INLINE void | sldns_buffer_write_u48_at (sldns_buffer *buffer, size_t at, uint64_t data) |
writes the given 6 byte integer at the given position in the buffer More... | |
INLINE void | sldns_buffer_write_u32 (sldns_buffer *buffer, uint32_t data) |
writes the given 4 byte integer at the current position in the buffer More... | |
INLINE void | sldns_buffer_write_u48 (sldns_buffer *buffer, uint64_t data) |
writes the given 6 byte integer at the current position in the buffer More... | |
INLINE void | sldns_buffer_read_at (sldns_buffer *buffer, size_t at, void *data, size_t count) |
copies count bytes of data at the given position to the given data-array More... | |
INLINE void | sldns_buffer_read (sldns_buffer *buffer, void *data, size_t count) |
copies count bytes of data at the current position to the given data-array More... | |
INLINE uint8_t | sldns_buffer_read_u8_at (sldns_buffer *buffer, size_t at) |
returns the byte value at the given position in the buffer More... | |
INLINE uint8_t | sldns_buffer_read_u8 (sldns_buffer *buffer) |
returns the byte value at the current position in the buffer More... | |
INLINE uint16_t | sldns_buffer_read_u16_at (sldns_buffer *buffer, size_t at) |
returns the 2-byte integer value at the given position in the buffer More... | |
INLINE uint16_t | sldns_buffer_read_u16 (sldns_buffer *buffer) |
returns the 2-byte integer value at the current position in the buffer More... | |
INLINE uint32_t | sldns_buffer_read_u32_at (sldns_buffer *buffer, size_t at) |
returns the 4-byte integer value at the given position in the buffer More... | |
INLINE uint32_t | sldns_buffer_read_u32 (sldns_buffer *buffer) |
returns the 4-byte integer value at the current position in the buffer More... | |
INLINE int | sldns_buffer_status (sldns_buffer *buffer) |
returns the status of the buffer More... | |
INLINE int | sldns_buffer_status_ok (sldns_buffer *buffer) |
returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise More... | |
int | sldns_buffer_printf (sldns_buffer *buffer, const char *format,...) ATTR_FORMAT(printf |
prints to the buffer, increasing the capacity if required using buffer_reserve(). More... | |
int void | sldns_buffer_free (sldns_buffer *buffer) |
frees the buffer. 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, and sldns_buffer::_status_err.
Referenced by anchors_apply_cfg(), anchors_test(), answer_callback_from_entry(), check_mod(), comm_point_create_http_out(), comm_point_create_local(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_tcp_handle_callback(), dname_test(), dstest_file(), hex_buffer2wire(), libworker_setup(), listen_create(), main(), mesh_create(), msgparse_test(), nsec3_hash_test(), outside_network_create(), pending_tcp_query(), pending_udp_query(), process_answer_detail(), send_em(), service(), verifytest_file(), zonemd_generate_test(), and zonemd_offline_verify().
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, and sldns_buffer::_status_err.
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, and sldns_buffer::_limit.
Referenced by decompress_rr_into_buffer().
INLINE void sldns_buffer_clear | ( | sldns_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 |
Referenced by anchor_read_bind_file(), auth_xfer_transfer_http_callback(), chunkline_get_line_collated(), comm_point_http_handle_write(), comm_point_tcp_handle_read(), comm_point_udp_callback(), decompress_rr_into_buffer(), dname_test_pkt_dname_len(), ds_create_dnskey_digest(), entry_to_buf(), extended_error_encode(), fill_buffer_with_reply(), hex_to_buf(), http_chunked_segment(), http_moveover_buffer(), http_nonchunk_segment(), load_rr(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_covers(), nsec3_get_hashed(), outnet_send_wait_udp(), qinfo_query_encode(), reclaim_tcp_handler(), recv_one(), reply_info_encode(), reuse_tcp_setup_read_and_timeout(), rrset_canonical(), rrset_canonicalize_to_buffer(), serviced_encode(), serviced_gen_query(), setup_http_request(), setup_tcp_handler(), skip_to_special(), sldns_buffer_copy(), ssl_handle_read(), tcp_callback_writer(), tcp_req_info_handle_writedone(), tcp_req_info_send_reply(), and tcp_req_info_start_write_buf().
INLINE void sldns_buffer_flip | ( | sldns_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 |
Referenced by anchors_test(), chunkline_get_line_collated(), comm_point_http_handle_read(), comm_point_tcp_handle_read(), comm_point_udp_callback(), decompress_rr_into_buffer(), dname_setup_bufs(), dname_test(), dname_test_pkt_dname_len(), ds_create_dnskey_digest(), entry_to_buf(), extended_error_encode(), http_chunked_segment(), http_process_chunk_header(), http_process_initial_header(), nsec3_calc_hash(), nsec3_get_hashed(), outnet_send_wait_udp(), pending_tcp_query(), pending_udp_query(), qinfo_query_encode(), rrset_canonical(), rrset_canonicalize_to_buffer(), serviced_encode(), serviced_gen_query(), setup_http_request(), sldns_buffer_copy(), ssl_handle_read(), tcp_callback_reader(), tcp_req_info_send_reply(), and tcp_req_info_start_write_buf().
INLINE void sldns_buffer_rewind | ( | sldns_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 |
Referenced by dnsc_handle_curved_request().
INLINE size_t sldns_buffer_position | ( | sldns_buffer * | buffer | ) |
returns the current position in the buffer (as a number of bytes)
[in] | buffer | the buffer |
References sldns_buffer::_position.
Referenced by analyze_dname(), analyze_rdata(), calc_size(), chunkline_count_parens(), chunkline_get_line_collated(), chunkline_remove_trailcomment(), comm_point_http_handle_read(), compress_any_dname(), compress_rdata(), decompress_rr_into_buffer(), dname_test_pkt_dname_len(), hex_buffer2wire(), hex_to_buf(), http_chunked_segment(), http_header_done(), http_header_line(), http_moveover_buffer(), http_read_more(), insert_query(), nsec_at_apex(), packed_rrset_encode(), parse_get_cname_target(), pkt_dname_len(), pkt_rrsig_covered(), readkeyword_bindfile(), setup_http_request(), sig_is_double(), sldns_parse_rdf_token(), and ssl_http_read_more().
INLINE void sldns_buffer_set_position | ( | sldns_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 |
References sldns_buffer::_limit, and sldns_buffer::_position.
Referenced by auth_zone_parse_notify_serial(), chunkline_remove_trailcomment(), comm_point_http_handle_read(), comm_point_tcp_handle_write(), createResponse(), decompress_rr_into_buffer(), dname_test_pkt_dname_len(), http_chunked_segment(), http_header_line(), http_moveover_buffer(), http_nonchunk_segment(), http_process_chunk_header(), nsec_at_apex(), parse_get_cname_target(), parse_reply_in_temp_region(), pkt_dname_len(), pkt_rrsig_covered(), rrinternal_parse_unknown(), sig_is_double(), sldns_bgetc(), ssl_handle_write(), and write_soa_serial_to_buf().
INLINE void sldns_buffer_skip | ( | sldns_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 |
References sldns_buffer::_limit, and sldns_buffer::_position.
Referenced by analyze_rdata(), analyze_rr(), calc_size(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_callback(), compress_rdata(), decompress_rr_into_buffer(), extended_error_encode(), http_chunked_segment(), http_read_more(), http_write_more(), insert_query(), nsec_at_apex(), pkt_dname_len(), pkt_rrsig_covered(), qinfo_query_encode(), query_dname_len(), readkeyword_bindfile(), sig_is_double(), skip_pkt_rr(), skip_ttl_rdata(), sldns_parse_rdf_token(), ssl_handle_read(), ssl_handle_write(), ssl_http_read_more(), and ssl_http_write_more().
INLINE size_t sldns_buffer_limit | ( | sldns_buffer * | buffer | ) |
returns the maximum size of the buffer
[in] | buffer |
References sldns_buffer::_limit.
Referenced by analyze(), auth_xfer_transfer_http_callback(), az_insert_rr_decompress(), az_remove_rr_decompress(), check_packet_ok(), check_xfer_packet(), checkformerr(), chunkline_get_line_collated(), chunkline_is_comment_line_or_empty(), chunkline_newline_removal(), comm_point_http_handle_read(), comm_point_send_reply(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), dname_pkt_compare(), dname_pkt_copy(), dname_pkt_hash(), dname_print(), dnsc_find_cert(), dnscrypt_server_curve(), dnscrypt_server_uncurve(), ds_create_dnskey_digest(), extended_error_encode(), hex_to_buf(), http_chunked_segment(), http_header_done(), http_header_line(), http_nonchunk_segment(), log_buf(), lookup_serviced(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_covers(), nsec3_get_hashed(), outnet_udp_cb(), pending_tcp_query(), pending_udp_query(), perftestpkt(), pkt_dname_len(), pkt_dname_tolower(), qlist_add_line(), query_info_parse(), reply_info_encode(), ring_add(), server_stats_insrcode(), serviced_check_qname(), serviced_create(), sldns_bgetc(), sldns_buffer_copy(), smart_compare(), ssl_handle_read(), ssl_handle_write(), tcp_req_info_send_reply(), test_buffers(), testpkt(), worker_check_request(), write_q(), write_soa_serial_to_buf(), xfer_link_data(), and zonemd_simple_rrset().
INLINE void sldns_buffer_set_limit | ( | sldns_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 |
References sldns_buffer::_capacity, sldns_buffer::_limit, and sldns_buffer::_position.
Referenced by chunkline_newline_removal(), comm_point_tcp_handle_read(), do_proxy(), http_chunked_segment(), http_process_chunk_header(), recv_one(), reply_info_encode(), ring_pop(), ssl_handle_read(), tcp_req_info_handle_readdone(), and write_soa_serial_to_buf().
INLINE size_t sldns_buffer_capacity | ( | sldns_buffer * | buffer | ) |
returns the number of bytes the buffer can hold.
[in] | buffer | the buffer |
References sldns_buffer::_capacity.
Referenced by anchor_read_file(), comm_point_get_mem(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), do_list_local_data(), do_proxy(), http_chunked_segment(), http_nonchunk_segment(), listen_get_mem(), outnet_get_mem(), pending_tcp_query(), pending_udp_query(), perfreply(), service_recv(), setup_http_request(), setup_qinfo_edns(), sldns_buffer_copy(), ssl_handle_read(), tcp_relay_read(), write_soa_serial_to_buf(), xfr_probe_lookup_host(), and xfr_transfer_lookup_host().
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 |
INLINE uint8_t* sldns_buffer_at | ( | const sldns_buffer * | buffer, |
size_t | at | ||
) |
returns a pointer to the data at the indicated position.
[in] | buffer | the buffer |
[in] | at | position |
References sldns_buffer::_data, and sldns_buffer::_limit.
Referenced by comm_point_tcp_handle_read(), dname_pkt_compare(), dname_pkt_copy(), dname_pkt_hash(), dname_print(), dname_test_pdtl(), http_moveover_buffer(), perftestpkt(), pkt_dname_tolower(), serviced_check_qname(), sldns_buffer_begin(), sldns_buffer_current(), sldns_buffer_end(), smart_compare(), ssl_handle_read(), test_buffers(), and testpkt().
INLINE uint8_t* sldns_buffer_begin | ( | const sldns_buffer * | buffer | ) |
returns a pointer to the beginning of the buffer (the data at position 0).
[in] | buffer | the buffer |
References sldns_buffer_at().
Referenced by add_bg_result(), anchor_read_bind_file(), anchor_read_file(), apply_http(), auth_answer_encode(), auth_error_encode(), az_insert_rr_decompress(), az_remove_rr_decompress(), check_xfer_packet(), checkformerr(), comm_point_send_reply(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_callback(), consume_pp2_header(), decompress_rr_into_buffer(), dname_test_qdtl(), dnsc_find_cert(), dnscrypt_server_curve(), dnscrypt_server_uncurve(), do_list_local_data(), do_proxy(), ds_create_dnskey_digest(), hex_buffer2wire(), http_chunked_segment(), http_moveover_buffer(), http_parse_add_rr(), http_parse_origin(), http_parse_ttl(), http_zonefile_syntax_check(), load_msg(), load_msg_cache(), load_ref(), load_rr(), load_rrset(), load_rrset_cache(), log_buf(), lookup_serviced(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_covers(), nsec3_get_hashed(), parse_get_cname_target(), pending_tcp_query(), pending_udp_query(), perfreply(), perftestpkt(), pkt_rrsig_covered(), qlist_add_line(), query_info_parse(), recv_one(), ring_add(), ring_pop(), rpz_local_encode(), rrset_canonical(), service_recv(), serviced_check_qname(), serviced_create(), skip_to_special(), sldns_buffer_copy(), ssl_handle_read(), tcp_relay_read(), tcp_req_info_send_reply(), test_buffers(), testpkt(), xfer_link_data(), and zonemd_simple_rrset().
INLINE uint8_t* sldns_buffer_end | ( | sldns_buffer * | buffer | ) |
returns a pointer to the end of the buffer (the data at the buffer's limit).
[in] | buffer | the buffer |
References sldns_buffer::_limit, and sldns_buffer_at().
Referenced by pkt_dname_tolower().
INLINE uint8_t* sldns_buffer_current | ( | sldns_buffer * | buffer | ) |
returns a pointer to the data at the buffer's current position.
[in] | buffer | the buffer |
References sldns_buffer::_position, and sldns_buffer_at().
Referenced by analyze_dname(), analyze_rdata(), calc_size(), canonicalize_rdata(), comm_point_tcp_handle_write(), decompress_rr_into_buffer(), extended_error_encode(), find_rrset(), http_chunked_segment(), http_header_line(), http_read_more(), http_write_more(), insert_can_owner(), insert_query(), rrset_canonicalize_to_buffer(), sldns_parse_rdf_token(), ssl_handle_write(), ssl_http_read_more(), and ssl_http_write_more().
INLINE size_t sldns_buffer_remaining_at | ( | sldns_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 |
Referenced by sldns_buffer_available_at(), and sldns_buffer_remaining().
INLINE size_t sldns_buffer_remaining | ( | sldns_buffer * | buffer | ) |
returns the number of bytes remaining between the buffer's position and limit.
[in] | buffer | the buffer |
References sldns_buffer::_position, and sldns_buffer_remaining_at().
Referenced by add_bg_result(), analyze(), calc_size(), chunkline_get_line(), chunkline_get_line_collated(), comm_point_http_handle_read(), comm_point_http_handle_write(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_callback(), compress_owner(), compress_rdata(), consume_pp2_header(), context_serialize_answer(), dname_buffer_write(), http_chunked_segment(), http_moveover_buffer(), http_read_more(), http_write_more(), insert_query(), nsec_at_apex(), packed_rrset_encode(), parse_packet(), parse_section(), pkt_dname_len(), pkt_rrsig_covered(), qinfo_query_encode(), query_dname_len(), readkeyword_bindfile(), reply_info_encode(), rrset_canonical(), rrset_canonicalize_to_buffer(), sig_is_double(), skip_pkt_rr(), skip_ttl_rdata(), sldns_parse_rdf_token(), ssl_handle_read(), ssl_handle_write(), ssl_http_read_more(), ssl_http_write_more(), and write_compressed_dname().
INLINE int sldns_buffer_available_at | ( | sldns_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 |
References sldns_buffer_remaining_at().
Referenced by sldns_bgetc(), sldns_bskipcs(), sldns_buffer_available(), sldns_buffer_read_at(), sldns_buffer_read_u16_at(), sldns_buffer_read_u32_at(), sldns_buffer_read_u8_at(), sldns_buffer_set_at(), sldns_buffer_write_at(), sldns_buffer_write_u16_at(), sldns_buffer_write_u32_at(), sldns_buffer_write_u48_at(), and sldns_buffer_write_u8_at().
INLINE int sldns_buffer_available | ( | sldns_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 |
References sldns_buffer::_position, and sldns_buffer_available_at().
Referenced by decompress_rr_into_buffer().
INLINE void sldns_buffer_write_at | ( | sldns_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 |
References sldns_buffer::_data, and sldns_buffer_available_at().
Referenced by dname_test_qdtl(), and sldns_buffer_write().
INLINE void sldns_buffer_set_at | ( | sldns_buffer * | buffer, |
size_t | at, | ||
int | c, | ||
size_t | count | ||
) |
set the given byte 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] | c | the byte to set to the buffer |
[in] | count | the number of bytes of bytes to write |
References sldns_buffer::_data, and sldns_buffer_available_at().
INLINE void sldns_buffer_write | ( | sldns_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 length of the data to write |
References sldns_buffer::_position, and sldns_buffer_write_at().
Referenced by compress_owner(), compress_rdata(), decompress_rr_into_buffer(), dname_buffer_write(), dname_test_pkt_dname_len(), ds_create_dnskey_digest(), entry_to_buf(), extended_error_encode(), http_chunked_segment(), insert_can_owner(), insert_query(), nsec3_calc_hash(), nsec3_get_hashed(), outnet_send_wait_udp(), packed_rrset_encode(), pending_tcp_query(), pending_udp_query(), qinfo_query_encode(), rrset_canonical(), rrset_canonicalize_to_buffer(), serviced_encode(), serviced_gen_query(), sldns_buffer_copy(), tcp_req_info_send_reply(), tcp_req_info_start_write_buf(), and write_compressed_dname().
INLINE void sldns_buffer_write_string_at | ( | sldns_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 |
INLINE void sldns_buffer_write_string | ( | sldns_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 |
INLINE void sldns_buffer_write_u8_at | ( | sldns_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 |
References sldns_buffer::_data, and sldns_buffer_available_at().
Referenced by chunkline_get_line_collated(), chunkline_newline_removal(), http_header_line(), and sldns_buffer_write_u8().
INLINE void sldns_buffer_write_u8 | ( | sldns_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 |
References sldns_buffer::_position, and sldns_buffer_write_u8_at().
Referenced by chunkline_get_line(), compress_owner(), dname_buffer_write(), dname_setup_bufs(), skip_to_special(), and write_compressed_dname().
INLINE void sldns_buffer_write_u16_at | ( | sldns_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 |
References sldns_buffer_available_at().
Referenced by compress_rdata(), decompress_rr_into_buffer(), handle_newq(), libworker_attach_mesh(), libworker_fg(), qlist_add_line(), qlist_parse_line(), sldns_buffer_write_u16(), and xfr_create_soa_probe_packet().
INLINE void sldns_buffer_write_u16 | ( | sldns_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 |
References sldns_buffer::_position, and sldns_buffer_write_u16_at().
Referenced by decompress_rr_into_buffer(), dname_setup_bufs(), extended_error_encode(), insert_query(), packed_rrset_encode(), qinfo_query_encode(), serviced_encode(), serviced_gen_query(), write_compressed_dname(), and write_soa_serial_to_buf().
INLINE void sldns_buffer_write_u32_at | ( | sldns_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 |
References sldns_buffer_available_at().
Referenced by sldns_buffer_write_u32().
INLINE void sldns_buffer_write_u48_at | ( | sldns_buffer * | buffer, |
size_t | at, | ||
uint64_t | data | ||
) |
writes the given 6 byte integer at the given position in the buffer
[in] | buffer | the buffer |
[in] | at | the position in the buffer |
[in] | data | the (lower) 48 bits to write |
References sldns_buffer_available_at().
Referenced by sldns_buffer_write_u48().
INLINE void sldns_buffer_write_u32 | ( | sldns_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 |
References sldns_buffer::_position, and sldns_buffer_write_u32_at().
Referenced by decompress_rr_into_buffer(), packed_rrset_encode(), and rrset_canonicalize_to_buffer().
INLINE void sldns_buffer_write_u48 | ( | sldns_buffer * | buffer, |
uint64_t | data | ||
) |
writes the given 6 byte integer at the current position in the buffer
[in] | buffer | the buffer |
[in] | data | the 48 bits to write |
References sldns_buffer::_position, and sldns_buffer_write_u48_at().
INLINE void sldns_buffer_read_at | ( | sldns_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 |
References sldns_buffer::_data, and sldns_buffer_available_at().
Referenced by sldns_buffer_read().
INLINE void sldns_buffer_read | ( | sldns_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 |
References sldns_buffer::_position, and sldns_buffer_read_at().
INLINE uint8_t sldns_buffer_read_u8_at | ( | sldns_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 |
References sldns_buffer::_data, and sldns_buffer_available_at().
Referenced by chunkline_count_parens(), chunkline_is_comment_line_or_empty(), chunkline_newline_removal(), chunkline_remove_trailcomment(), http_header_done(), http_header_line(), readkeyword_bindfile(), sldns_bskipcs(), and sldns_buffer_read_u8().
INLINE uint8_t sldns_buffer_read_u8 | ( | sldns_buffer * | buffer | ) |
returns the byte value at the current position in the buffer
[in] | buffer | the buffer |
References sldns_buffer::_position, and sldns_buffer_read_u8_at().
Referenced by nsec_at_apex(), pkt_dname_len(), query_dname_len(), and sldns_bgetc().
INLINE uint16_t sldns_buffer_read_u16_at | ( | sldns_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 |
References sldns_buffer_available_at().
Referenced by auth_answer_encode(), auth_error_encode(), comm_point_tcp_handle_read(), log_reply_info(), rpz_local_encode(), server_stats_insquery(), serviced_callbacks(), sldns_buffer_read_u16(), and ssl_handle_read().
INLINE uint16_t sldns_buffer_read_u16 | ( | sldns_buffer * | buffer | ) |
returns the 2-byte integer value at the current position in the buffer
[in] | buffer | the buffer |
References sldns_buffer::_position, and sldns_buffer_read_u16_at().
Referenced by analyze(), analyze_rr(), calc_size(), nsec_at_apex(), pkt_rrsig_covered(), sig_is_double(), and skip_ttl_rdata().
INLINE uint32_t sldns_buffer_read_u32_at | ( | sldns_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 |
References sldns_buffer_available_at().
Referenced by sldns_buffer_read_u32().
INLINE uint32_t sldns_buffer_read_u32 | ( | sldns_buffer * | buffer | ) |
returns the 4-byte integer value at the current position in the buffer
[in] | buffer | the buffer |
References sldns_buffer::_position, and sldns_buffer_read_u32_at().
Referenced by analyze_rr().
INLINE int sldns_buffer_status | ( | sldns_buffer * | buffer | ) |
returns the status of the buffer
[in] | buffer |
References sldns_buffer::_status_err.
Referenced by sldns_buffer_status_ok().
INLINE int sldns_buffer_status_ok | ( | sldns_buffer * | buffer | ) |
returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise
[in] | buffer | the buffer |
References sldns_buffer_status().
int sldns_buffer_printf | ( | sldns_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.
Referenced by pr_flags(), pr_rrs(), setup_http_request(), and setup_http_user_agent().
int 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_http_out(), 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(), libworker_setup(), listen_delete(), mesh_delete(), outnet_serviced_query_stop(), outside_network_delete(), send_em(), worker_delete(), zonemd_generate_test(), and zonemd_offline_verify().
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(), mesh_make_new_space(), and reply_and_prefetch().