lwres_buffer.docbook revision 938440694b33cd752e9e4b71a526368b4811c177
f743002678eb67b99bbc29fee116b65d9530fec0wrowe<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
efe780dcf13b2b95effabf897d694d8f23feac74trawick [<!ENTITY mdash "—">]>
135ddda3a989215d2bedbcf1529bfb269c3eda23niq - Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
135ddda3a989215d2bedbcf1529bfb269c3eda23niq - Copyright (C) 2000, 2001 Internet Software Consortium.
166b66614fb67e1b95c200433925787457657a0ajim - Permission to use, copy, modify, and/or distribute this software for any
166b66614fb67e1b95c200433925787457657a0ajim - purpose with or without fee is hereby granted, provided that the above
166b66614fb67e1b95c200433925787457657a0ajim - copyright notice and this permission notice appear in all copies.
3f414998b6d7e96a9f699621352fc61516b1a316chrisd - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
3f414998b6d7e96a9f699621352fc61516b1a316chrisd - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9d766f93eefb9358f9a24bb99ff424ad399b9b39minfrin - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
9d766f93eefb9358f9a24bb99ff424ad399b9b39minfrin - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9d766f93eefb9358f9a24bb99ff424ad399b9b39minfrin - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5725c3eb0c6c572049ba61dedd92b4e5da078081minfrin - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5725c3eb0c6c572049ba61dedd92b4e5da078081minfrin - PERFORMANCE OF THIS SOFTWARE.
1122585e1e00bb81e9d0f054bf5c318cec23aa7dminfrin <refentryinfo>
b4e664baba9a4be0457c31f84b3dcc4c31f2cb07kbrand </refentryinfo>
33124689065ade0dfc8c54d8ebb734f9439cb89btrawick <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
33124689065ade0dfc8c54d8ebb734f9439cb89btrawick </copyright>
33124689065ade0dfc8c54d8ebb734f9439cb89btrawick <copyright>
3ccfc257819b3bad063cd3ac9dd1670d5d2ae4d2kbrand </copyright>
9b0076ddd1103e5fa9c1f9bafde4b06ce244fbaecovener <refnamediv>
6001d914962deabb83a46251001612e969bdf67ajim <refpurpose>lightweight resolver buffer management</refpurpose>
c4e8006db0cf457c68876d7d4c30dcc451d8cba7jkaluza </refnamediv>
c4e8006db0cf457c68876d7d4c30dcc451d8cba7jkaluza <refsynopsisdiv>
652bacc79dd7f980249784cc8c4838e8f1de7e8acovener <funcsynopsis>
652bacc79dd7f980249784cc8c4838e8f1de7e8acovener<funcsynopsisinfo>
f4db898517ccc6ef1a403630de56918286d3a47eminfrin</funcsynopsisinfo>
f4db898517ccc6ef1a403630de56918286d3a47eminfrin<funcprototype>
067698ad30941e38ef5d7f95f1c2736c2ebc5cb9humbedooh <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
067698ad30941e38ef5d7f95f1c2736c2ebc5cb9humbedooh <paramdef>void *<parameter>base</parameter></paramdef>
d8a6de5eec06d4136839c8f7a56a6ab5acd2d3behumbedooh <paramdef>unsigned int <parameter>length</parameter></paramdef>
6e1e45624d6f32110383bb0bd06c254c1dba8123humbedooh </funcprototype>
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc<funcprototype>
921d32d80d8271da08f12fc374a69cb36d1d63b3covener<function>lwres_buffer_invalidate</function></funcdef>
921d32d80d8271da08f12fc374a69cb36d1d63b3covener <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
921d32d80d8271da08f12fc374a69cb36d1d63b3covener </funcprototype>
3e097af23e40c45aa32602545155f0964ab5c69dcovener<funcprototype>
faea99bb676ec50ece38da6b1879aa37546483a2covener <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
faea99bb676ec50ece38da6b1879aa37546483a2covener <paramdef>unsigned int <parameter>n</parameter></paramdef>
86a5604df726638a2b8085e993b4b79c4b3a5262covener </funcprototype>
344f755169e100ea8ce51e847a0bf30a13b46917covener<funcprototype>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <paramdef>unsigned int <parameter>n</parameter></paramdef>
50cfe8bbbaf4279375802531268e2bf0155215fetrawick </funcprototype>
50cfe8bbbaf4279375802531268e2bf0155215fetrawick<funcprototype>
ffaa9771884a8664f0e6267efbe9d26b40000461trawick <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
ffaa9771884a8664f0e6267efbe9d26b40000461trawick </funcprototype>
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick<funcprototype>
4d12805e6c18253040223ea637acd6b3b3c18f60jorton <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
4d12805e6c18253040223ea637acd6b3b3c18f60jorton </funcprototype>
e5d909f2b06bd880fb3675cd49363df981caa631trawick<funcprototype>
cb666b29f81df1d11d65002250153353568021fccovener <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
cb666b29f81df1d11d65002250153353568021fccovener <paramdef>unsigned int <parameter>n</parameter></paramdef>
cb666b29f81df1d11d65002250153353568021fccovener </funcprototype>
6a80c3c6f4b8ea7ba5e89402b8b779b09ce020e0covener<funcprototype>
75a230a728338d84dcfe81edd375352f34de22d0covener <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener <paramdef>unsigned int <parameter>n</parameter></paramdef>
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener </funcprototype>
63a5ea80bddcc84a462e40f402b4f330e0e05411covener<funcprototype>
63a5ea80bddcc84a462e40f402b4f330e0e05411covenerlwres_uint8_t
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin </funcprototype>
65a4e663b82f8bce28ac22ab2edfd7502de36998sf<funcprototype>
c7de1955eb0eaeabf7042902476397692672d549sf <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin <paramdef>lwres_uint8_t <parameter>val</parameter></paramdef>
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin </funcprototype>
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin<funcprototype>
a511a29faf2ff7ead3b67680154a624effb31aafminfrinlwres_uint16_t
a511a29faf2ff7ead3b67680154a624effb31aafminfrin<function>lwres_buffer_getuint16</function></funcdef>
a511a29faf2ff7ead3b67680154a624effb31aafminfrin <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
a511a29faf2ff7ead3b67680154a624effb31aafminfrin </funcprototype>
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin<funcprototype>
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin<function>lwres_buffer_putuint16</function></funcdef>
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin <paramdef>lwres_uint16_t <parameter>val</parameter></paramdef>
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin </funcprototype>
4c02bab56a528a180bbe394d8b6e6fd9c1a3ac1esf<funcprototype>
4c02bab56a528a180bbe394d8b6e6fd9c1a3ac1esflwres_uint32_t
2c487ac43b583db869e743772a7a10b278aa2bcfminfrin<function>lwres_buffer_getuint32</function></funcdef>
684e0cfc200f66287a93bbd1708d1dd8a92a7eefcovener <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
684e0cfc200f66287a93bbd1708d1dd8a92a7eefcovener </funcprototype>
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes<funcprototype>
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq <paramdef>lwres_uint32_t <parameter>val</parameter></paramdef>
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq </funcprototype>
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq<funcprototype>
c12917da693bae4028a1d5a5e8224bceed8c739dsf <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf <paramdef>const unsigned char *<parameter>base</parameter></paramdef>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf <paramdef>unsigned int <parameter>length</parameter></paramdef>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf </funcprototype>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf<funcprototype>
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf <paramdef>unsigned char *<parameter>base</parameter></paramdef>
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf <paramdef>unsigned int <parameter>length</parameter></paramdef>
9811aed12bbc71783d2e544ccb5fecd193843eadsf </funcprototype>
9811aed12bbc71783d2e544ccb5fecd193843eadsf</funcsynopsis>
1366443dc565c33e7b449ae428bbfc4c86f33935drh </refsynopsisdiv>
bd3f5647b96d378d9c75c954e3f13582af32c643sf These functions provide bounds checked access to a region of memory
bd3f5647b96d378d9c75c954e3f13582af32c643sf where data is being read or written.
bd3f5647b96d378d9c75c954e3f13582af32c643sf They are based on, and similar to, the
2a7beea91d46beb41f043a84eaad060047ee04aafabien functions in the ISC library.
584a85dd4047e38d3ed3a29b6662fcc9d100ae4csf A buffer is a region of memory, together with a set of related
584a85dd4047e38d3ed3a29b6662fcc9d100ae4csf subregions.
f21e9e3d0bfb7a507ecc5bc963f2159d693503d1sf their union is the buffer's region.
f21e9e3d0bfb7a507ecc5bc963f2159d693503d1sf The used region extends from the beginning of the buffer region to the
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf last used byte.
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf The available region extends from one byte greater than the last used
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf byte to the end of the buffer's region.
132ee6ac1c26d6e8953836316ba50734eefab47bsf The size of the used region can be changed using various
132ee6ac1c26d6e8953836316ba50734eefab47bsf buffer commands.
132ee6ac1c26d6e8953836316ba50734eefab47bsf Initially, the used region is empty.
85eacfc96a04547ef25aabbc06440039715084c2jorton The used region is further subdivided into two disjoint regions: the
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick <emphasis>consumed region</emphasis> and the <emphasis>remaining region</emphasis>.
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick The union of these two regions is the used region.
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick The consumed region extends from the beginning of the used region to
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick the byte before the <emphasis>current</emphasis> offset (if any).
79c5787b92ac5f0e1cc82393816c77a006399316trawick The <emphasis>remaining</emphasis> region the current pointer to the end
79c5787b92ac5f0e1cc82393816c77a006399316trawick of the used
79c5787b92ac5f0e1cc82393816c77a006399316trawick The size of the consumed region can be changed using various
c967bf3bc89e8aa60dbd30d9da388e448ddc1cc4trawick buffer commands.
79c5787b92ac5f0e1cc82393816c77a006399316trawick Initially, the consumed region is empty.
79c5787b92ac5f0e1cc82393816c77a006399316trawick The <emphasis>active region</emphasis> is an (optional) subregion of the
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton It extends from the current offset to an offset in the
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton remaining region.
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton Initially, the active region is empty.
536e48c08d674acac5d44929318f2ad928edc361jorton If the current offset advances beyond the chosen offset,
536e48c08d674acac5d44929318f2ad928edc361jorton the active region will also be empty.
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton /------------entire length---------------\\
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton /----- used region -----\\/-- available --\\
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton +----------------------------------------+
53e9b27aba029b18be814df40bcf6f0428771d1efuankg | consumed | remaining | |
53e9b27aba029b18be814df40bcf6f0428771d1efuankg +----------------------------------------+
53e9b27aba029b18be814df40bcf6f0428771d1efuankg </programlisting>
6bb524f1895f30265a1431afc460977d391cb36bsf a == base of buffer.
ca61ccd0c306c2c72df153688ba1b49f3eceed80sf b == current pointer. Can be anywhere between a and d.
6bb524f1895f30265a1431afc460977d391cb36bsf c == active pointer. Meaningful between b and d.
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin d == used pointer.
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin e == length of buffer.
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin </programlisting>
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin a-e == entire length of buffer.
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin a-d == used region.
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin a-b == consumed region.
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung b-d == remaining region.
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung b-c == optional active region.
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung</programlisting>
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung initializes the
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick and assocates it with the memory region of size
0827cb14e550f6f65018431c22c2c913631c8f25kbrand bytes starting at location
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick <para><function>lwres_buffer_invalidate()</function>
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim as invalid. Invalidating a buffer after use is not required,
cfa64348224b66dd1c9979b809406c4d15b1c137fielding but makes it possible to catch its possible accidental use.
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim The functions