buffer.c File Reference

#include <config.h>
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/string.h>
#include <isc/util.h>

Go to the source code of this file.

Functions

void isc__buffer_init (isc_buffer_t *b, void *base, unsigned int length)
 Make 'b' refer to the 'length'-byte region starting at base.
void isc__buffer_initnull (isc_buffer_t *b)
 Initialize a buffer 'b' with a null data and zero length/.
void isc_buffer_reinit (isc_buffer_t *b, void *base, unsigned int length)
 Make 'b' refer to the 'length'-byte region starting at base. Any existing data will be copied.
void isc__buffer_invalidate (isc_buffer_t *b)
 Make 'b' an invalid buffer.
void isc__buffer_region (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the region of 'b'.
void isc__buffer_usedregion (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the used region of 'b'.
void isc__buffer_availableregion (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the available region of 'b'.
void isc__buffer_add (isc_buffer_t *b, unsigned int n)
 Increase the 'used' region of 'b' by 'n' bytes.
void isc__buffer_subtract (isc_buffer_t *b, unsigned int n)
 Decrease the 'used' region of 'b' by 'n' bytes.
void isc__buffer_clear (isc_buffer_t *b)
 Make the used region empty.
void isc__buffer_consumedregion (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the consumed region of 'b'.
void isc__buffer_remainingregion (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the remaining region of 'b'.
void isc__buffer_activeregion (isc_buffer_t *b, isc_region_t *r)
 Make 'r' refer to the active region of 'b'.
void isc__buffer_setactive (isc_buffer_t *b, unsigned int n)
 Sets the end of the active region 'n' bytes after current.
void isc__buffer_first (isc_buffer_t *b)
 Make the consumed region empty.
void isc__buffer_forward (isc_buffer_t *b, unsigned int n)
 Increase the 'consumed' region of 'b' by 'n' bytes.
void isc__buffer_back (isc_buffer_t *b, unsigned int n)
 Decrease the 'consumed' region of 'b' by 'n' bytes.
void isc_buffer_compact (isc_buffer_t *b)
 Compact the used region by moving the remaining region so it occurs at the start of the buffer. The used region is shrunk by the size of the consumed region, and the consumed region is then made empty.
isc_uint8_t isc_buffer_getuint8 (isc_buffer_t *b)
 Read an unsigned 8-bit integer from 'b' and return it.
void isc__buffer_putuint8 (isc_buffer_t *b, isc_uint8_t val)
 Store an unsigned 8-bit integer from 'val' into 'b'.
isc_uint16_t isc_buffer_getuint16 (isc_buffer_t *b)
 Read an unsigned 16-bit integer in network byte order from 'b', convert it to host byte order, and return it.
void isc__buffer_putuint16 (isc_buffer_t *b, isc_uint16_t val)
 Store an unsigned 16-bit integer in host byte order from 'val' into 'b' in network byte order.
void isc__buffer_putuint24 (isc_buffer_t *b, isc_uint32_t val)
isc_uint32_t isc_buffer_getuint32 (isc_buffer_t *b)
 Read an unsigned 32-bit integer in network byte order from 'b', convert it to host byte order, and return it.
void isc__buffer_putuint32 (isc_buffer_t *b, isc_uint32_t val)
 Store an unsigned 32-bit integer in host byte order from 'val' into 'b' in network byte order.
isc_uint64_t isc_buffer_getuint48 (isc_buffer_t *b)
 Read an unsigned 48-bit integer in network byte order from 'b', convert it to host byte order, and return it.
void isc__buffer_putuint48 (isc_buffer_t *b, isc_uint64_t val)
 Store an unsigned 48-bit integer in host byte order from 'val' into 'b' in network byte order.
void isc__buffer_putmem (isc_buffer_t *b, const unsigned char *base, unsigned int length)
 Copy 'length' bytes of memory at 'base' into 'b'.
void isc__buffer_putstr (isc_buffer_t *b, const char *source)
 Copy 'source' into 'b', not including terminating NUL.
isc_result_t isc_buffer_copyregion (isc_buffer_t *b, const isc_region_t *r)
 Copy the contents of 'r' into 'b'.
isc_result_t isc_buffer_allocate (isc_mem_t *mctx, isc_buffer_t **dynbuffer, unsigned int length)
 Allocate a dynamic linkable buffer which has "length" bytes in the data region.
isc_result_t isc_buffer_reallocate (isc_buffer_t **dynbuffer, unsigned int length)
 Reallocate the buffer to be "length" bytes long. The buffer pointer may move when you call this function.
isc_result_t isc_buffer_reserve (isc_buffer_t **dynbuffer, unsigned int size)
 Make "size" bytes of space available in the buffer. The buffer pointer may move when you call this function.
void isc_buffer_free (isc_buffer_t **dynbuffer)
 Release resources allocated for a dynamic buffer.


Detailed Description

Definition in file buffer.c.


Function Documentation

void isc__buffer_init ( isc_buffer_t b,
void *  base,
unsigned int  length 
)

Make 'b' refer to the 'length'-byte region starting at base.

Requires:

Definition at line 29 of file buffer.c.

References ISC__BUFFER_INIT, and REQUIRE.

void isc__buffer_initnull ( isc_buffer_t b  ) 

Initialize a buffer 'b' with a null data and zero length/.

Definition at line 41 of file buffer.c.

References ISC__BUFFER_INIT.

void isc_buffer_reinit ( isc_buffer_t b,
void *  base,
unsigned int  length 
)

Make 'b' refer to the 'length'-byte region starting at base. Any existing data will be copied.

Requires:

Definition at line 51 of file buffer.c.

References isc_buffer::base, isc_buffer::length, and REQUIRE.

Referenced by grow_headerspace(), render_404(), render_500(), and render_xsl().

void isc__buffer_invalidate ( isc_buffer_t b  ) 

Make 'b' an invalid buffer.

Requires:

Ensures:

Definition at line 70 of file buffer.c.

References ISC__BUFFER_INVALIDATE, ISC_BUFFER_VALID, ISC_LINK_LINKED, isc_buffer::mctx, and REQUIRE.

void isc__buffer_region ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the region of 'b'.

Requires:

Definition at line 83 of file buffer.c.

References ISC__BUFFER_REGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_usedregion ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the used region of 'b'.

Requires:

Definition at line 95 of file buffer.c.

References ISC__BUFFER_USEDREGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_availableregion ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the available region of 'b'.

Requires:

Definition at line 107 of file buffer.c.

References ISC__BUFFER_AVAILABLEREGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_add ( isc_buffer_t b,
unsigned int  n 
)

Increase the 'used' region of 'b' by 'n' bytes.

Requires:

Definition at line 119 of file buffer.c.

References ISC__BUFFER_ADD, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

void isc__buffer_subtract ( isc_buffer_t b,
unsigned int  n 
)

Decrease the 'used' region of 'b' by 'n' bytes.

Requires:

Definition at line 131 of file buffer.c.

References ISC__BUFFER_SUBTRACT, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

void isc__buffer_clear ( isc_buffer_t b  ) 

Make the used region empty.

Requires:

Ensures:

Definition at line 143 of file buffer.c.

References ISC__BUFFER_CLEAR, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_consumedregion ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the consumed region of 'b'.

Requires:

Definition at line 154 of file buffer.c.

References ISC__BUFFER_CONSUMEDREGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_remainingregion ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the remaining region of 'b'.

Requires:

Definition at line 166 of file buffer.c.

References ISC__BUFFER_REMAININGREGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_activeregion ( isc_buffer_t b,
isc_region_t r 
)

Make 'r' refer to the active region of 'b'.

Requires:

Definition at line 178 of file buffer.c.

References ISC__BUFFER_ACTIVEREGION, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_setactive ( isc_buffer_t b,
unsigned int  n 
)

Sets the end of the active region 'n' bytes after current.

Requires:

Definition at line 190 of file buffer.c.

References isc_buffer::current, ISC__BUFFER_SETACTIVE, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_first ( isc_buffer_t b  ) 

Make the consumed region empty.

Requires:

Ensures:

Definition at line 202 of file buffer.c.

References ISC__BUFFER_FIRST, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_forward ( isc_buffer_t b,
unsigned int  n 
)

Increase the 'consumed' region of 'b' by 'n' bytes.

Requires:

Definition at line 213 of file buffer.c.

References isc_buffer::current, ISC__BUFFER_FORWARD, ISC_BUFFER_VALID, and REQUIRE.

void isc__buffer_back ( isc_buffer_t b,
unsigned int  n 
)

Decrease the 'consumed' region of 'b' by 'n' bytes.

Requires:

Definition at line 225 of file buffer.c.

References ISC__BUFFER_BACK, ISC_BUFFER_VALID, and REQUIRE.

void isc_buffer_compact ( isc_buffer_t b  ) 

Compact the used region by moving the remaining region so it occurs at the start of the buffer. The used region is shrunk by the size of the consumed region, and the consumed region is then made empty.

Requires:

Ensures:

Definition at line 237 of file buffer.c.

References isc_buffer::active, isc_buffer::base, isc_buffer::current, isc_buffer_current, isc_buffer_remaininglength, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

Referenced by isc_lex_gettoken().

isc_uint8_t isc_buffer_getuint8 ( isc_buffer_t b  ) 

Read an unsigned 8-bit integer from 'b' and return it.

Requires:

Ensures:

Returns:

Definition at line 262 of file buffer.c.

References isc_buffer::current, isc_buffer_current, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

Referenced by dns_ncache_current(), dns_ncache_getrdataset(), dns_ncache_getsigrdataset(), dst_key_fromdns(), isc_lex_gettoken(), process_ecs(), and render_ecs().

void isc__buffer_putuint8 ( isc_buffer_t b,
isc_uint8_t  val 
)

Store an unsigned 8-bit integer from 'val' into 'b'.

Requires:

Ensures:

Definition at line 281 of file buffer.c.

References ISC__BUFFER_PUTUINT8, ISC_BUFFER_VALID, isc_buffer::length, REQUIRE, and isc_buffer::used.

isc_uint16_t isc_buffer_getuint16 ( isc_buffer_t b  ) 

Read an unsigned 16-bit integer in network byte order from 'b', convert it to host byte order, and return it.

Requires:

Ensures:

Returns:

Definition at line 289 of file buffer.c.

References isc_buffer::current, isc_buffer_current, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

Referenced by dns_message_parse(), dns_message_peekheader(), dns_message_pseudosectiontotext(), dns_ncache_current(), dns_ncache_getrdataset(), dns_ncache_getsigrdataset(), dns_ncache_towire(), dst_key_fromdns(), get_edns_expire(), getquestions(), getsection(), load_raw(), process_ecs(), process_opt(), read_one_rr(), render_ecs(), and tcp_length_done().

void isc__buffer_putuint16 ( isc_buffer_t b,
isc_uint16_t  val 
)

Store an unsigned 16-bit integer in host byte order from 'val' into 'b' in network byte order.

Requires:

Ensures:

Definition at line 310 of file buffer.c.

References ISC__BUFFER_PUTUINT16, ISC_BUFFER_VALID, isc_buffer::length, REQUIRE, and isc_buffer::used.

void isc__buffer_putuint24 ( isc_buffer_t b,
isc_uint32_t  val 
)

Store an unsigned 24-bit integer in host byte order from 'val' into 'b' in network byte order.

Requires:

The length of the unused region of 'b' is at least 3.

Ensures:

Definition at line 318 of file buffer.c.

References ISC__BUFFER_PUTUINT24, ISC_BUFFER_VALID, isc_buffer::length, REQUIRE, and isc_buffer::used.

isc_uint32_t isc_buffer_getuint32 ( isc_buffer_t b  ) 

Read an unsigned 32-bit integer in network byte order from 'b', convert it to host byte order, and return it.

Requires:

Ensures:

Returns:

Definition at line 326 of file buffer.c.

References isc_buffer::current, isc_buffer_current, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

Referenced by dns_db_getsoaserial(), dns_message_pseudosectiontotext(), get_edns_expire(), getsection(), load_header(), load_raw(), and read_one_rr().

void isc__buffer_putuint32 ( isc_buffer_t b,
isc_uint32_t  val 
)

Store an unsigned 32-bit integer in host byte order from 'val' into 'b' in network byte order.

Requires:

Ensures:

Definition at line 349 of file buffer.c.

References ISC__BUFFER_PUTUINT32, ISC_BUFFER_VALID, isc_buffer::length, REQUIRE, and isc_buffer::used.

isc_uint64_t isc_buffer_getuint48 ( isc_buffer_t b  ) 

Read an unsigned 48-bit integer in network byte order from 'b', convert it to host byte order, and return it.

Requires:

Ensures:

Returns:

Definition at line 357 of file buffer.c.

References isc_buffer::current, isc_buffer_current, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

void isc__buffer_putuint48 ( isc_buffer_t b,
isc_uint64_t  val 
)

Store an unsigned 48-bit integer in host byte order from 'val' into 'b' in network byte order.

Requires:

Ensures:

Definition at line 382 of file buffer.c.

References ISC__BUFFER_PUTUINT16, ISC__BUFFER_PUTUINT32, ISC_BUFFER_VALID, isc_buffer::length, REQUIRE, and isc_buffer::used.

void isc__buffer_putmem ( isc_buffer_t b,
const unsigned char *  base,
unsigned int  length 
)

Copy 'length' bytes of memory at 'base' into 'b'.

Requires:

Definition at line 396 of file buffer.c.

References ISC__BUFFER_PUTMEM, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

void isc__buffer_putstr ( isc_buffer_t b,
const char *  source 
)

Copy 'source' into 'b', not including terminating NUL.

Requires:

Definition at line 406 of file buffer.c.

References isc_buffer_availablelength, isc_buffer_used, ISC_BUFFER_VALID, REQUIRE, and isc_buffer::used.

isc_result_t isc_buffer_copyregion ( isc_buffer_t b,
const isc_region_t r 
)

Copy the contents of 'r' into 'b'.

Requires:

Returns:

Definition at line 426 of file buffer.c.

References isc_region::base, isc_buffer_availablelength, isc_buffer_used, ISC_BUFFER_VALID, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_region::length, REQUIRE, and isc_buffer::used.

Referenced by addoptout(), copy_rdataset(), dns_client_updaterec(), dns_request_createraw4(), dns_sdb_putrdata(), dns_zone_forwardupdate(), dst_gssapi_acceptctx(), dst_gssapi_initctx(), dst_key_fromgssapi(), dump_rdataset_raw(), fromstruct_afsdb(), fromstruct_caa(), fromstruct_ch_a(), fromstruct_cname(), fromstruct_dname(), fromstruct_in_a6(), fromstruct_in_kx(), fromstruct_in_nsap_ptr(), fromstruct_in_px(), fromstruct_in_srv(), fromstruct_ipseckey(), fromstruct_lp(), fromstruct_mb(), fromstruct_md(), fromstruct_mf(), fromstruct_mg(), fromstruct_minfo(), fromstruct_mr(), fromstruct_mx(), fromstruct_naptr(), fromstruct_ns(), fromstruct_nsec(), fromstruct_nxt(), fromstruct_ptr(), fromstruct_rp(), fromstruct_rt(), fromstruct_soa(), name_tobuffer(), ns_client_sendraw(), pushandgrow(), recv_done(), req_render(), req_response(), and unknown_fromtext().

isc_result_t isc_buffer_allocate ( isc_mem_t mctx,
isc_buffer_t **  dynbuffer,
unsigned int  length 
)

Allocate a dynamic linkable buffer which has "length" bytes in the data region.

Requires:

Returns: Note:

Definition at line 447 of file buffer.c.

References isc_buffer_init, isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, and REQUIRE.

Referenced by add_rdata_to_list(), ATF_TC_BODY(), build_name_from_str(), buildquery(), control_recvmessage(), copy_name(), dns_dnssec_sign(), dns_dnssec_signmessage(), dns_keytable_dump(), dns_message_buildopt(), dns_message_create(), dns_message_getquerytsig(), dns_message_setquerytsig(), dns_message_signer(), dns_ntatable_dump(), dns_request_createraw4(), dns_sdb_putrdata(), dns_sdlz_putrr(), dns_tkey_builddhquery(), dns_tkey_processdhresponse(), dns_tsig_sign(), dns_zone_forwardupdate(), dst_gssapi_acceptctx(), dst_key_fromgssapi(), dumpnode(), main(), modrdataset(), new_source(), newbuffer(), notify_createmessage(), parse_name(), parse_rdata(), printmessage(), printrdata(), process_dhtkey(), pushandgrow(), query_dns64(), query_filter64(), query_newnamebuf(), recv_done(), req_render(), req_response(), say_message(), setup_text_key(), show_message(), start_lookup(), and unknown_fromtext().

isc_result_t isc_buffer_reallocate ( isc_buffer_t **  dynbuffer,
unsigned int  length 
)

Reallocate the buffer to be "length" bytes long. The buffer pointer may move when you call this function.

Requires:

Returns: Ensures:

Definition at line 469 of file buffer.c.

References isc_buffer::base, INSIST, ISC_BUFFER_VALID, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_buffer::length, isc_buffer::mctx, and REQUIRE.

Referenced by ATF_TC_BODY(), ATF_TP_ADD_TCS(), and isc_buffer_reserve().

isc_result_t isc_buffer_reserve ( isc_buffer_t **  dynbuffer,
unsigned int  size 
)

Make "size" bytes of space available in the buffer. The buffer pointer may move when you call this function.

Requires:

Returns: Ensures:

Definition at line 503 of file buffer.c.

References ISC_BUFFER_INCR, isc_buffer_reallocate(), ISC_BUFFER_VALID, ISC_R_NOMEMORY, ISC_R_NOSPACE, ISC_R_SUCCESS, and REQUIRE.

Referenced by ATF_TC_BODY(), ATF_TP_ADD_TCS(), isccc_cc_towire(), ns_server_testgen(), putmem(), putstr(), putuint8(), table_towire(), and value_towire().

void isc_buffer_free ( isc_buffer_t **  dynbuffer  ) 

Release resources allocated for a dynamic buffer.

Requires:

Ensures:

Definition at line 532 of file buffer.c.

References isc_buffer_invalidate, ISC_BUFFER_VALID, isc_mem_put, isc_buffer::length, isc_buffer::mctx, mctx, and REQUIRE.

Referenced by ATF_TC_BODY(), build_name_from_str(), buildquery(), control_recvmessage(), destroy_libs(), destroy_lookup(), destroynode(), dns_dnssec_sign(), dns_dnssec_signmessage(), dns_keytable_dump(), dns_message_create(), dns_ntatable_dump(), dns_sdlz_putrr(), dns_tkey_builddhquery(), dns_tkey_processdhresponse(), dns_tsig_sign(), dst_key_free(), dumpnode(), fctx_cancelquery(), forward_destroy(), isc_lex_close(), main(), maybe_free(), maybe_free_connection(), modrdataset(), msgreset(), newconnection(), parse_rdata(), printmessage(), printrdata(), process_dhtkey(), process_gsstkey(), pushandgrow(), query_dns64(), query_filter64(), query_reset(), recv_done(), req_destroy(), req_render(), req_response(), say_message(), sendstream(), setup_text_key(), show_message(), start_lookup(), unknown_fromtext(), xfrin_recv_done(), xfrin_reset(), xfrin_send_request(), and xfrout_ctx_destroy().


Generated on Tue Apr 28 17:41:14 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha