lwres_packet.html revision d6fa26d0adaec6c910115be34fe7a5a5f402c14f
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - This Source Code Form is subject to the terms of the Mozilla Public
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - License, v. 2.0. If a copy of the MPL was not distributed with this
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<a name="id-1"></a><div class="titlepage"></div>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader — lightweight resolver packet handling functions</p>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<pre class="funcsynopsisinfo">#include <lwres/lwpacket.h></pre>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_lwpacket_renderheader</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_lwpacket_parseheader</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These functions rely on a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein which is defined in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeintypedef struct lwres_lwpacket lwres_lwpacket_t;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct lwres_lwpacket {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint32_t length;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t version;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t pktflags;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint32_t serial;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint32_t opcode;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint32_t result;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint32_t recvlength;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t authtype;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t authlength;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The elements of this structure are:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<div class="variablelist"><dl class="variablelist">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">length</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein the overall packet length, including the entire packet header.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">version</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein the header format. There is currently only one format,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">LWRES_LWPACKETVERSION_0</span>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">pktflags</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein library-defined flags for this packet: for instance whether the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is a request or a reply. Flag values can be set, but not defined
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is filled in by the application wit the exception of
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gabn_*() and lwres_gnba_*() calls.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">serial</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is set by the requestor and is returned in all replies. If two
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein packets from the same source have the same serial number and are
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein the same source, they are assumed to be duplicates and the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein may be dropped.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field must be set by the application.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">opcode</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein indicates the operation.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Opcodes between 0x00000000 and 0x03ffffff are
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein reserved for use by the lightweight resolver library. Opcodes
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 0x04000000 and 0xffffffff are application defined.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">result</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is only valid for replies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Results between 0x04000000 and 0xffffffff are application
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Results between 0x00000000 and 0x03ffffff are reserved for
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein library use.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">recvlength</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is the maximum buffer size that the receiver can handle on
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein and the size of the buffer needed to satisfy a request when the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is too large for replies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This field is supplied by the application.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">authtype</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein defines the packet level authentication that is used.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Authorisation types between 0x1000 and 0xffff are application
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein and types between 0x0000 and 0x0fff are reserved for library
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Currently these are not used and must be zero.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">authlen</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein gives the length of the authentication data.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Since packet authentication is currently not used, this must be
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The following opcodes are currently defined:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<div class="variablelist"><dl class="variablelist">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NOOP</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Success is always returned and the packet contents are echoed.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The lwres_noop_*() functions should be used for this type.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">GETADDRSBYNAME</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein returns all known addresses for a given name.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The lwres_gabn_*() functions should be used for this type.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">GETNAMEBYADDR</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return the hostname for the given address.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The lwres_gnba_*() functions should be used for this type.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><code class="function">lwres_lwpacket_renderheader()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein transfers the contents of lightweight resolver packet structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_lwpacket_t</span> <em class="parameter"><code>*pkt</code></em> in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein network byte order to the lightweight resolver buffer,
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><code class="function">lwres_lwpacket_parseheader()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein performs the converse operation. It transfers data in network
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein byte order from buffer <em class="parameter"><code>*b</code></em> to resolver
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein packet <em class="parameter"><code>*pkt</code></em>. The contents of the buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>b</code></em> should correspond to a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Successful calls to
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_lwpacket_renderheader()</code> and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_lwpacket_parseheader()</code> return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="errorcode">LWRES_R_SUCCESS</span>. If there is insufficient
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein space to copy data between the buffer <em class="parameter"><code>*b</code></em> and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lightweight resolver packet <em class="parameter"><code>*pkt</code></em> both
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>.