Maintained by: NLnet Labs
Data Structures | Macros | Typedefs | Functions
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...
 
void sldns_buffer_init_vfixed_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_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...
 

Detailed Description

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

Function Documentation

◆ sldns_buffer_new()

sldns_buffer* sldns_buffer_new ( size_t  capacity)

◆ 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, sldns_buffer::_status_err, and sldns_buffer::_vfixed.

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, sldns_buffer::_limit, and sldns_buffer::_vfixed.

Referenced by sldns_str2wire_ipseckey_buf(), sldns_str2wire_nsec_buf(), and sldns_str2wire_wks_buf().

◆ sldns_buffer_init_vfixed_frm_data()

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.

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, and sldns_buffer::_vfixed.

◆ sldns_buffer_clear()

INLINE void sldns_buffer_clear ( sldns_buffer buffer)

◆ sldns_buffer_flip()

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.

Parameters
[in]bufferthe buffer to flip
Returns
void

Referenced by anchors_test(), attach_edns_record(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), dname_setup_bufs(), dname_test(), dname_test_pkt_dname_len(), ds_create_dnskey_digest(), entry_to_buf(), error_encode(), nsec3_calc_hash(), nsec3_get_hashed(), outnet_send_wait_udp(), pending_tcp_query(), pending_udp_query(), qinfo_query_encode(), rrset_canonical(), serviced_encode(), serviced_gen_query(), sldns_buffer_copy(), and tcp_callback_reader().

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

◆ sldns_buffer_position()

INLINE size_t sldns_buffer_position ( sldns_buffer buffer)

◆ sldns_buffer_set_position()

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.

Parameters
[in]bufferthe buffer
[in]markthe mark to use

References sldns_buffer::_limit, sldns_buffer::_position, and sldns_buffer::_vfixed.

Referenced by attach_edns_record(), comm_point_tcp_handle_write(), createResponse(), dname_test_pkt_dname_len(), nsec_at_apex(), parse_reply(), pkt_dname_len(), pkt_rrsig_covered(), rrinternal_parse_unknown(), sig_is_double(), sldns_bgetc(), and ssl_handle_write().

◆ sldns_buffer_skip()

INLINE void sldns_buffer_skip ( sldns_buffer buffer,
ssize_t  count 
)

◆ sldns_buffer_limit()

INLINE size_t sldns_buffer_limit ( sldns_buffer buffer)

◆ 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 comm_point_tcp_handle_read(), do_proxy(), recv_one(), reply_info_encode(), ring_pop(), and ssl_handle_read().

◆ sldns_buffer_capacity()

INLINE size_t sldns_buffer_capacity ( sldns_buffer buffer)

◆ 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

Referenced by sldns_buffer_capacity().

◆ 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

Referenced by sldns_buffer_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)

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

INLINE uint8_t* sldns_buffer_current ( sldns_buffer buffer)

returns a pointer to the data at the buffer's current position.

Parameters
[in]bufferthe buffer
Returns
the pointer

References sldns_buffer::_position, and sldns_buffer_at().

Referenced by analyze_dname(), analyze_rdata(), calc_size(), canonicalize_rdata(), comm_point_tcp_handle_write(), error_encode(), find_rrset(), insert_can_owner(), insert_query(), process_bind_contents(), sldns_parse_rdf_token(), and ssl_handle_write().

◆ 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(), sldns_buffer_remaining(), sldns_buffer_set_at(), and sldns_buffer_write_at().

◆ sldns_buffer_remaining()

INLINE size_t sldns_buffer_remaining ( sldns_buffer buffer)

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

◆ 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, sldns_buffer::_vfixed, sldns_buffer_available_at(), and sldns_buffer_remaining_at().

Referenced by dname_test_qdtl(), sldns_buffer_write(), and sldns_buffer_write_string_at().

◆ 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, sldns_buffer::_vfixed, sldns_buffer_available_at(), and sldns_buffer_remaining_at().

◆ sldns_buffer_write()

INLINE void sldns_buffer_write ( sldns_buffer buffer,
const void *  data,
size_t  count 
)

◆ 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, sldns_buffer::_limit, sldns_buffer::_vfixed, and sldns_buffer_available_at().

Referenced by 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 attach_edns_record(), compress_owner(), dname_buffer_write(), dname_setup_bufs(), process_bind_contents(), 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::_limit, sldns_buffer::_vfixed, and sldns_buffer_available_at().

Referenced by attach_edns_record(), compress_rdata(), handle_newq(), libworker_attach_mesh(), libworker_fg(), qlist_add_line(), qlist_parse_line(), sldns_buffer_write_u16(), and write_q().

◆ 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 attach_edns_record(), dname_setup_bufs(), error_encode(), insert_query(), packed_rrset_encode(), qinfo_query_encode(), serviced_encode(), serviced_gen_query(), and write_compressed_dname().

◆ 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::_limit, sldns_buffer::_vfixed, 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::_limit, sldns_buffer::_vfixed, 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 packed_rrset_encode().

◆ 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 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 attach_edns_record(), comm_point_tcp_handle_read(), local_encode(), local_error_encode(), log_reply_info(), 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_copy(), sldns_buffer_export(), sldns_buffer_free(), sldns_buffer_printf(), and 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(), and sldns_buffer_status_ok().

◆ sldns_buffer_free()

int void sldns_buffer_free ( sldns_buffer buffer)

◆ sldns_buffer_export()

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.

Parameters
[in]*bufferthe buffer to be exported
Returns
void

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

Referenced by sldns_buffer_status_ok().

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