/contrib/bind9/lib/lwres/man/lwres_packet.docbook
Unknown | 292 lines | 279 code | 13 blank | 0 comment | 0 complexity | 5557aa23971d80f8f6878268605c8977 MD5 | raw file
1<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 2 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" 3 [<!ENTITY mdash "—">]> 4<!-- 5 - Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") 6 - Copyright (C) 2000, 2001 Internet Software Consortium. 7 - 8 - Permission to use, copy, modify, and/or distribute this software for any 9 - purpose with or without fee is hereby granted, provided that the above 10 - copyright notice and this permission notice appear in all copies. 11 - 12 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 13 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 14 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 15 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 16 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 17 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 - PERFORMANCE OF THIS SOFTWARE. 19--> 20 21<!-- $Id$ --> 22<refentry> 23 24 <refentryinfo> 25 <date>Jun 30, 2000</date> 26 </refentryinfo> 27 28 <refmeta> 29 <refentrytitle>lwres_packet</refentrytitle> 30 <manvolnum>3</manvolnum> 31 <refmiscinfo>BIND9</refmiscinfo> 32 </refmeta> 33 34 <docinfo> 35 <copyright> 36 <year>2004</year> 37 <year>2005</year> 38 <year>2007</year> 39 <year>2012</year> 40 <holder>Internet Systems Consortium, Inc. ("ISC")</holder> 41 </copyright> 42 <copyright> 43 <year>2000</year> 44 <year>2001</year> 45 <holder>Internet Software Consortium.</holder> 46 </copyright> 47 </docinfo> 48 49 <refnamediv> 50 <refname>lwres_lwpacket_renderheader</refname> 51 <refname>lwres_lwpacket_parseheader</refname> 52 <refpurpose>lightweight resolver packet handling functions</refpurpose> 53 </refnamediv> 54 <refsynopsisdiv> 55 <funcsynopsis> 56<funcsynopsisinfo>#include <lwres/lwpacket.h></funcsynopsisinfo> 57<funcprototype> 58 <funcdef> 59lwres_result_t 60<function>lwres_lwpacket_renderheader</function></funcdef> 61 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef> 62 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef> 63 </funcprototype> 64<funcprototype> 65 <funcdef> 66lwres_result_t 67<function>lwres_lwpacket_parseheader</function></funcdef> 68 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef> 69 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef> 70 </funcprototype> 71</funcsynopsis> 72 </refsynopsisdiv> 73 <refsect1> 74 <title>DESCRIPTION</title> 75 <para> 76 These functions rely on a 77 <type>struct lwres_lwpacket</type> 78 which is defined in 79 <filename>lwres/lwpacket.h</filename>. 80 </para> 81 82 <para><programlisting> 83typedef struct lwres_lwpacket lwres_lwpacket_t; 84 </programlisting> 85 </para> 86 <para><programlisting> 87struct lwres_lwpacket { 88 lwres_uint32_t length; 89 lwres_uint16_t version; 90 lwres_uint16_t pktflags; 91 lwres_uint32_t serial; 92 lwres_uint32_t opcode; 93 lwres_uint32_t result; 94 lwres_uint32_t recvlength; 95 lwres_uint16_t authtype; 96 lwres_uint16_t authlength; 97}; 98</programlisting> 99 </para> 100 101 <para> 102 The elements of this structure are: 103 <variablelist> 104 <varlistentry> 105 <term><constant>length</constant></term> 106 <listitem> 107 <para> 108 the overall packet length, including the entire packet header. 109 This field is filled in by the lwres_gabn_*() and lwres_gnba_*() 110 calls. 111 </para> 112 </listitem> 113 </varlistentry> 114 <varlistentry> 115 <term><constant>version</constant></term> 116 <listitem> 117 <para> 118 the header format. There is currently only one format, 119 <type>LWRES_LWPACKETVERSION_0</type>. 120 121 This field is filled in by the lwres_gabn_*() and lwres_gnba_*() 122 calls. 123 </para> 124 </listitem> 125 </varlistentry> 126 <varlistentry> 127 <term><constant>pktflags</constant></term> 128 <listitem> 129 <para> 130 library-defined flags for this packet: for instance whether the 131 packet 132 is a request or a reply. Flag values can be set, but not defined 133 by 134 the caller. 135 This field is filled in by the application wit the exception of 136 the 137 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in 138 the 139 lwres_gabn_*() and lwres_gnba_*() calls. 140 </para> 141 </listitem> 142 </varlistentry> 143 <varlistentry> 144 <term><constant>serial</constant></term> 145 <listitem> 146 <para> 147 is set by the requestor and is returned in all replies. If two 148 or more 149 packets from the same source have the same serial number and are 150 from 151 the same source, they are assumed to be duplicates and the 152 latter ones 153 may be dropped. 154 This field must be set by the application. 155 </para> 156 </listitem> 157 </varlistentry> 158 <varlistentry> 159 <term><constant>opcode</constant></term> 160 <listitem> 161 <para> 162 indicates the operation. 163 Opcodes between 0x00000000 and 0x03ffffff are 164 reserved for use by the lightweight resolver library. Opcodes 165 between 166 0x04000000 and 0xffffffff are application defined. 167 This field is filled in by the lwres_gabn_*() and lwres_gnba_*() 168 calls. 169 </para> 170 </listitem> 171 </varlistentry> 172 <varlistentry> 173 <term><constant>result</constant></term> 174 <listitem> 175 <para> 176 is only valid for replies. 177 Results between 0x04000000 and 0xffffffff are application 178 defined. 179 Results between 0x00000000 and 0x03ffffff are reserved for 180 library use. 181 This field is filled in by the lwres_gabn_*() and lwres_gnba_*() 182 calls. 183 </para> 184 </listitem> 185 </varlistentry> 186 <varlistentry> 187 <term><constant>recvlength</constant></term> 188 <listitem> 189 <para> 190 is the maximum buffer size that the receiver can handle on 191 requests 192 and the size of the buffer needed to satisfy a request when the 193 buffer 194 is too large for replies. 195 This field is supplied by the application. 196 </para> 197 </listitem> 198 </varlistentry> 199 <varlistentry> 200 <term><constant>authtype</constant></term> 201 <listitem> 202 <para> 203 defines the packet level authentication that is used. 204 Authorisation types between 0x1000 and 0xffff are application 205 defined 206 and types between 0x0000 and 0x0fff are reserved for library 207 use. 208 Currently these are not used and must be zero. 209 </para> 210 </listitem> 211 </varlistentry> 212 <varlistentry> 213 <term><constant>authlen</constant></term> 214 <listitem> 215 <para> 216 gives the length of the authentication data. 217 Since packet authentication is currently not used, this must be 218 zero. 219 </para> 220 </listitem> 221 </varlistentry> 222 </variablelist> 223 </para> 224 <para> 225 The following opcodes are currently defined: 226 <variablelist> 227 <varlistentry> 228 <term><constant>NOOP</constant></term> 229 <listitem> 230 <para> 231 Success is always returned and the packet contents are echoed. 232 The lwres_noop_*() functions should be used for this type. 233 </para> 234 </listitem> 235 </varlistentry> 236 <varlistentry> 237 <term><constant>GETADDRSBYNAME</constant></term> 238 <listitem> 239 <para> 240 returns all known addresses for a given name. 241 The lwres_gabn_*() functions should be used for this type. 242 </para> 243 </listitem> 244 </varlistentry> 245 <varlistentry> 246 <term><constant>GETNAMEBYADDR</constant></term> 247 <listitem> 248 <para> 249 return the hostname for the given address. 250 The lwres_gnba_*() functions should be used for this type. 251 </para> 252 </listitem> 253 </varlistentry> 254 </variablelist> 255 </para> 256 257 <para><function>lwres_lwpacket_renderheader()</function> 258 transfers the contents of lightweight resolver packet structure 259 <type>lwres_lwpacket_t</type> <parameter>*pkt</parameter> in 260 network byte order to the lightweight resolver buffer, 261 <parameter>*b</parameter>. 262 </para> 263 264 <para><function>lwres_lwpacket_parseheader()</function> 265 performs the converse operation. It transfers data in network 266 byte order from buffer <parameter>*b</parameter> to resolver 267 packet <parameter>*pkt</parameter>. The contents of the buffer 268 <parameter>b</parameter> should correspond to a 269 <type>lwres_lwpacket_t</type>. 270 </para> 271 272 </refsect1> 273 274 <refsect1> 275 <title>RETURN VALUES</title> 276 <para> 277 Successful calls to 278 <function>lwres_lwpacket_renderheader()</function> and 279 <function>lwres_lwpacket_parseheader()</function> return 280 <errorcode>LWRES_R_SUCCESS</errorcode>. If there is insufficient 281 space to copy data between the buffer <parameter>*b</parameter> and 282 lightweight resolver packet <parameter>*pkt</parameter> both 283 functions 284 return <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>. 285 </para> 286 287 </refsect1> 288</refentry><!-- 289 - Local variables: 290 - mode: sgml 291 - End: 292-->