sbuffer.h File Reference

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_buffersldns_buffer_new (size_t capacity)
 creates a new buffer with the specified capacity.
 
void sldns_buffer_new_frm_data (sldns_buffer *buffer, void *data, size_t size)
 creates a buffer with the specified data.
 
void sldns_buffer_init_frm_data (sldns_buffer *buffer, void *data, size_t size)
 Setup a buffer with the data pointed to.
 
INLINE void sldns_buffer_clear (sldns_buffer *buffer)
 clears the buffer and make it ready for writing.
 
INLINE void sldns_buffer_flip (sldns_buffer *buffer)
 makes the buffer ready for reading the data that has been written to the buffer.
 
INLINE void sldns_buffer_rewind (sldns_buffer *buffer)
 make the buffer ready for re-reading the data.
 
INLINE size_t sldns_buffer_position (sldns_buffer *buffer)
 returns the current position in the buffer (as a number of bytes)
 
INLINE void sldns_buffer_set_position (sldns_buffer *buffer, size_t mark)
 sets the buffer's position to MARK.
 
INLINE void sldns_buffer_skip (sldns_buffer *buffer, ssize_t count)
 changes the buffer's position by COUNT bytes.
 
INLINE size_t sldns_buffer_limit (sldns_buffer *buffer)
 returns the maximum size of the buffer
 
INLINE void sldns_buffer_set_limit (sldns_buffer *buffer, size_t limit)
 changes the buffer's limit.
 
INLINE size_t sldns_buffer_capacity (sldns_buffer *buffer)
 returns the number of bytes the buffer can hold.
 
int sldns_buffer_set_capacity (sldns_buffer *buffer, size_t capacity)
 changes the buffer's capacity.
 
int sldns_buffer_reserve (sldns_buffer *buffer, size_t amount)
 ensures BUFFER can contain at least AMOUNT more bytes.
 
INLINE uint8_t * sldns_buffer_at (const sldns_buffer *buffer, size_t at)
 returns a pointer to the data at the indicated position.
 
INLINE uint8_t * sldns_buffer_begin (const sldns_buffer *buffer)
 returns a pointer to the beginning of the buffer (the data at position 0).
 
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).
 
INLINE uint8_t * sldns_buffer_current (sldns_buffer *buffer)
 returns a pointer to the data at the buffer's current position.
 
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.
 
INLINE size_t sldns_buffer_remaining (sldns_buffer *buffer)
 returns the number of bytes remaining between the buffer's position and limit.
 
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.
 
INLINE int sldns_buffer_available (sldns_buffer *buffer, size_t count)
 checks if the buffer has count bytes available at the current position
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
INLINE uint8_t sldns_buffer_read_u8 (sldns_buffer *buffer)
 returns the byte value at the current position in the buffer
 
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
 
INLINE uint16_t sldns_buffer_read_u16 (sldns_buffer *buffer)
 returns the 2-byte integer value at the current position in the buffer
 
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
 
INLINE uint32_t sldns_buffer_read_u32 (sldns_buffer *buffer)
 returns the 4-byte integer value at the current position in the buffer
 
INLINE int sldns_buffer_status (sldns_buffer *buffer)
 returns the status of the buffer
 
INLINE int sldns_buffer_status_ok (sldns_buffer *buffer)
 returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise
 
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().
 
int void sldns_buffer_free (sldns_buffer *buffer)
 frees the buffer.
 
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.
 

Detailed Description

This file contains the definition of sldns_buffer, and functions to manipulate those.

Function Documentation

◆ sldns_buffer_new()

◆ sldns_buffer_new_frm_data()

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().

Parameters
[in]bufferpointer to the buffer to put the data in
[in]datathe data to encapsulate in the buffer
[in]sizethe 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().

◆ sldns_buffer_init_frm_data()

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.

Parameters
[in]bufferpointer to the buffer to put the data in
[in]datathe data to encapsulate in the buffer
[in]sizethe size of the data

References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, and sldns_buffer::_limit.

Referenced by chunk_rrlist_get_current(), decompress_rr_into_buffer(), log_rrlist_position(), pending_tcp_query(), sldns_str2wire_ipseckey_buf(), sldns_str2wire_nsec_buf(), sldns_str2wire_wks_buf(), and use_free_buffer().

◆ sldns_buffer_clear()

INLINE void sldns_buffer_clear ( sldns_buffer buffer)

◆ sldns_buffer_flip()

◆ sldns_buffer_rewind()

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.

Parameters
[in]bufferthe buffer to rewind

References sldns_buffer::_position.

Referenced by dnsc_handle_curved_request(), and worker_handle_request().

◆ sldns_buffer_position()

◆ sldns_buffer_set_position()

◆ sldns_buffer_skip()

◆ sldns_buffer_limit()

INLINE size_t sldns_buffer_limit ( sldns_buffer buffer)

returns the maximum size of the buffer

Parameters
[in]buffer
Returns
the size

References sldns_buffer::_limit.

Referenced by analyze(), auth_xfer_transfer_http_callback(), az_insert_rr_decompress(), az_remove_rr_decompress(), chaos_replystr(), 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(), consume_pp2_header(), 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(), fill_buffer_with_reply(), handle_query(), hex_to_buf(), http_chunked_segment(), http_header_done(), http_header_line(), http_nonchunk_segment(), libworker_event_done_cb(), libworker_fillup_fg(), log_buf(), log_dns_msg(), log_reply_info(), lookup_serviced(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_covers(), nsec3_get_hashed(), outnet_tcp_cb(), outnet_udp_cb(), pending_tcp_query(), pending_udp_query(), pending_udp_query(), perf_encode(), perftestpkt(), pkt_dname_len(), pkt_dname_tolower(), qlist_add_line(), query_info_parse(), read_entry(), recv_one(), reply_info_answer_encode(), reply_info_encode(), ring_add(), send_em(), server_stats_insrcode(), service_send(), serviced_callbacks(), 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(), worker_handle_request(), write_q(), write_soa_serial_to_buf(), xfer_link_data(), xfr_create_ixfr_packet(), zonemd_simple_rrset(), and zonemd_simple_rrsig().

◆ sldns_buffer_set_limit()

INLINE void sldns_buffer_set_limit ( sldns_buffer buffer,
size_t  limit 
)

◆ sldns_buffer_capacity()

◆ sldns_buffer_set_capacity()

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.

Parameters
[in]bufferthe buffer
[in]capacitythe capacity to use
Returns
whether this failed or succeeded

References sldns_buffer::_capacity, sldns_buffer::_data, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, and sldns_buffer::_status_err.

Referenced by sldns_buffer_reserve().

◆ sldns_buffer_reserve()

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.

Parameters
[in]bufferthe buffer
[in]amountamount to use
Returns
whether this failed or succeeded

References sldns_buffer::_capacity, sldns_buffer::_fixed, sldns_buffer::_limit, sldns_buffer::_position, sldns_buffer::_status_err, and sldns_buffer_set_capacity().

◆ sldns_buffer_at()

INLINE uint8_t * sldns_buffer_at ( const sldns_buffer buffer,
size_t  at 
)

◆ sldns_buffer_begin()

INLINE uint8_t * sldns_buffer_begin ( const sldns_buffer buffer)

returns a pointer to the beginning of the buffer (the data at position 0).

Parameters
[in]bufferthe buffer
Returns
the pointer

References sldns_buffer_at().

Referenced by add_bg_result(), anchor_read_bind_file(), anchor_read_file(), anchor_store_str(), answer_notify(), apply_http(), auth_answer_encode(), auth_error_encode(), auth_zone_parse_notify_serial(), az_insert_rr_decompress(), az_remove_rr_decompress(), chaos_replystr(), check_packet_ok(), 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(), context_serialize_answer(), decompress_rr_into_buffer(), dname_test_qdtl(), dname_to_buf(), dnsc_find_cert(), dnscrypt_server_curve(), dnscrypt_server_uncurve(), do_list_local_data(), do_proxy(), ds_create_dnskey_digest(), fill_buffer_with_reply(), get_additional_name(), handle_query(), hex_buffer2wire(), http_chunked_segment(), http_moveover_buffer(), http_parse_add_rr(), http_parse_origin(), http_parse_ttl(), http_zonefile_syntax_check(), libworker_event_done_cb(), libworker_fillup_fg(), libworker_handle_service_reply(), load_msg(), load_msg_cache(), load_ref(), load_rr(), load_rrset(), load_rrset_cache(), local_encode(), local_error_encode(), log_buf(), log_dns_msg(), log_rrlist_position(), lookup_serviced(), mesh_send_reply(), msgtostr(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_covers(), nsec3_get_hashed(), outnet_tcp_cb(), outnet_udp_cb(), parse_edns_from_query_pkt(), parse_get_cname_target(), pending_tcp_query(), pending_udp_query(), pending_udp_query(), perfreply(), perftestpkt(), pkt_rrsig_covered(), process_bind_contents(), qlist_add_line(), qlist_parse_line(), query_info_parse(), rdata_copy(), read_entry(), read_fixed(), recv_one(), reply_info_encode(), ring_add(), ring_pop(), rpz_local_encode(), rrset_canonical(), sanitize_nsec_is_overreach(), select_id(), send_em(), server_stats_insquery(), server_stats_insrcode(), service_recv(), service_send(), serviced_callbacks(), serviced_check_qname(), serviced_create(), serviced_encode(), serviced_tcp_callback(), serviced_udp_callback(), skip_to_special(), sldns_buffer_copy(), ssl_handle_read(), ssl_read_buf(), tcp_relay_read(), tcp_req_info_send_reply(), test_buffers(), testpkt(), worker_check_request(), worker_handle_request(), worker_handle_service_reply(), write_q(), xfer_link_data(), zonemd_simple_rrset(), and zonemd_simple_rrsig().

◆ sldns_buffer_end()

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).

Parameters
[in]bufferthe buffer
Returns
the pointer

References sldns_buffer::_limit, and sldns_buffer_at().

Referenced by pkt_dname_tolower().

◆ sldns_buffer_current()

◆ sldns_buffer_remaining_at()

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.

Parameters
[in]bufferthe buffer
[in]atindicated position
Returns
number of bytes

References sldns_buffer::_limit.

Referenced by sldns_buffer_available_at(), and sldns_buffer_remaining().

◆ sldns_buffer_remaining()

◆ sldns_buffer_available_at()

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!

Parameters
[in]bufferthe buffer
[in]atindicated position
[in]counthow much is available
Returns
true or false (as int?)

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().

◆ sldns_buffer_available()

INLINE int sldns_buffer_available ( sldns_buffer buffer,
size_t  count 
)

checks if the buffer has count bytes available at the current position

Parameters
[in]bufferthe buffer
[in]counthow much is available
Returns
true or false (as int?)

References sldns_buffer::_position, and sldns_buffer_available_at().

Referenced by decompress_rr_into_buffer().

◆ sldns_buffer_write_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position (in number of bytes) to write the data at
[in]datapointer to the data to write to the buffer
[in]countthe number of bytes of data to write

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by dname_test_qdtl(), dnscrypt_server_curve(), mesh_send_reply(), sldns_buffer_write(), sldns_buffer_write_string_at(), and worker_handle_request().

◆ sldns_buffer_set_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position (in number of bytes) to write the data at
[in]cthe byte to set to the buffer
[in]countthe number of bytes of bytes to write

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by dnscrypt_server_curve().

◆ sldns_buffer_write()

◆ sldns_buffer_write_string_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
[in]strthe string to write

References sldns_buffer_write_at().

◆ sldns_buffer_write_string()

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

Parameters
[in]bufferthe buffer
[in]strthe string to write

References sldns_buffer_write().

◆ sldns_buffer_write_u8_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
[in]datathe 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().

◆ sldns_buffer_write_u8()

INLINE void sldns_buffer_write_u8 ( sldns_buffer buffer,
uint8_t  data 
)

◆ sldns_buffer_write_u16_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
[in]datathe 16 bits to write

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by chaos_replystr(), compress_rdata(), decompress_rr_into_buffer(), handle_newq(), libworker_attach_mesh(), libworker_fg(), qlist_add_line(), qlist_parse_line(), reply_info_encode(), sldns_buffer_write_u16(), write_q(), xfr_create_ixfr_packet(), and xfr_create_soa_probe_packet().

◆ sldns_buffer_write_u16()

INLINE void sldns_buffer_write_u16 ( sldns_buffer buffer,
uint16_t  data 
)

◆ sldns_buffer_write_u32_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
[in]datathe 32 bits to write

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by sldns_buffer_write_u32().

◆ sldns_buffer_write_u48_at()

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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
[in]datathe (lower) 48 bits to write

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by sldns_buffer_write_u48().

◆ sldns_buffer_write_u32()

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

Parameters
[in]bufferthe buffer
[in]datathe 32 bits to write

References sldns_buffer::_position, and sldns_buffer_write_u32_at().

Referenced by chaos_replystr(), decompress_rr_into_buffer(), packed_rrset_encode(), rrset_canonicalize_to_buffer(), write_soa_serial_to_buf(), and xfr_create_ixfr_packet().

◆ sldns_buffer_write_u48()

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

Parameters
[in]bufferthe buffer
[in]datathe 48 bits to write

References sldns_buffer::_position, and sldns_buffer_write_u48_at().

◆ sldns_buffer_read_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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer to start
[out]databuffer to copy to
[in]countthe length of the data to copy

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by sldns_buffer_read().

◆ 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

Parameters
[in]bufferthe buffer
[out]databuffer to copy to
[in]countthe length of the data to copy

References sldns_buffer::_position, and sldns_buffer_read_at().

Referenced by parse_packet(), and parse_section().

◆ sldns_buffer_read_u8_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

Parameters
[in]bufferthe buffer
[in]atthe position in the buffer
Returns
1 byte integer

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(), recv_one(), sldns_bskipcs(), and sldns_buffer_read_u8().

◆ 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

Parameters
[in]bufferthe buffer
Returns
1 byte integer

References sldns_buffer::_position, and sldns_buffer_read_u8_at().

Referenced by nsec_at_apex(), parse_edns_from_query_pkt(), pkt_dname_len(), query_dname_len(), and sldns_bgetc().

◆ sldns_buffer_read_u16_at()

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

Parameters
[in]bufferthe buffer
[in]atposition in the buffer
Returns
2 byte integer

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by answer_notify(), auth_answer_encode(), auth_error_encode(), comm_point_tcp_handle_read(), local_encode(), local_error_encode(), log_reply_info(), mesh_send_reply(), rpz_local_encode(), server_stats_insquery(), serviced_callbacks(), sldns_buffer_read_u16(), ssl_handle_read(), and worker_handle_request().

◆ sldns_buffer_read_u16()

INLINE uint16_t sldns_buffer_read_u16 ( sldns_buffer buffer)

◆ sldns_buffer_read_u32_at()

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

Parameters
[in]bufferthe buffer
[in]atposition in the buffer
Returns
4 byte integer

References sldns_buffer::_data, and sldns_buffer_available_at().

Referenced by check_xfer_packet(), and sldns_buffer_read_u32().

◆ 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

Parameters
[in]bufferthe buffer
Returns
4 byte integer

References sldns_buffer::_position, and sldns_buffer_read_u32_at().

Referenced by analyze_rr(), auth_zone_parse_notify_serial(), check_packet_ok(), check_xfer_packet(), and chunk_rrlist_get_current().

◆ sldns_buffer_status()

INLINE int sldns_buffer_status ( sldns_buffer buffer)

returns the status of the buffer

Parameters
[in]buffer
Returns
the status

References sldns_buffer::_status_err.

Referenced by sldns_buffer_status_ok().

◆ 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

Parameters
[in]bufferthe buffer
Returns
true or false

References sldns_buffer_status().

◆ sldns_buffer_printf()

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.

◆ sldns_buffer_free()

◆ sldns_buffer_copy()

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.

Parameters
[out]*resultresulting buffer which is copied to.
[in]*fromwhat 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(), mesh_send_reply(), outnet_comm_point_for_tcp(), and reply_and_prefetch().