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

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

◆ sldns_buffer_clear()

◆ 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

Referenced by dnsc_handle_curved_request().

◆ sldns_buffer_position()

◆ sldns_buffer_set_position()

◆ sldns_buffer_skip()

◆ sldns_buffer_limit()

◆ sldns_buffer_set_limit()

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.

Parameters
[in]bufferthe buffer
[in]limitthe 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().

◆ 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

◆ 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

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

◆ 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

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(), and sldns_buffer_write().

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

◆ 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

◆ 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

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

writes the given byte of data at the current position in the buffer

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

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

◆ sldns_buffer_write_u16()

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

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

◆ 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_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_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 decompress_rr_into_buffer(), packed_rrset_encode(), and rrset_canonicalize_to_buffer().

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

◆ 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(), 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(), 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_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().

◆ sldns_buffer_read_u16()

INLINE uint16_t sldns_buffer_read_u16 ( sldns_buffer buffer)

returns the 2-byte integer value at the current position in the buffer

Parameters
[in]bufferthe buffer
Returns
2 byte integer

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

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

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

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

Referenced by pr_flags(), pr_rrs(), setup_http_request(), and setup_http_user_agent().

◆ 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(), and reply_and_prefetch().