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