lwres_packet.html revision ddccd5811feff696ba460dabfb666ce61040f545
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo<!--
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - Copyright (C) 2000, 2001 Internet Software Consortium.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo -
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - Permission to use, copy, modify, and distribute this software for any
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - purpose with or without fee is hereby granted, provided that the above
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - copyright notice and this permission notice appear in all copies.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo -
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo-->
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo<HTML
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><HEAD
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><TITLE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>lwres_packet</TITLE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><META
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="GENERATOR"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCONTENT="Modular DocBook HTML Stylesheet Version 1.61
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo"></HEAD
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><BODY
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="REFENTRY"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoBGCOLOR="#FFFFFF"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoTEXT="#000000"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoLINK="#0000FF"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoVLINK="#840084"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoALINK="#0000FF"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><H1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="AEN1"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>lwres_packet</A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></H1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="REFNAMEDIV"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="AEN8"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>Name</H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader&nbsp;--&nbsp;lightweight resolver packet handling functions</DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="REFSYNOPSISDIV"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="AEN12"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>Synopsis</H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="FUNCSYNOPSIS"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="AEN13"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></A
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg><P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="FUNCSYNOPSISINFO"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>#include &lt;lwres/lwbuffer.h&gt;</PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="FUNCSYNOPSISINFO"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>#include &lt;lwres/lwpacket.h&gt;</PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="FUNCSYNOPSISINFO"
1d4b38e0077763e7c9b20768eacb841957e787bcrsmaeda>#include &lt;lwres/result.h&gt;</PRE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><P
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg><CODE
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg><CODE
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jgCLASS="FUNCDEF"
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg>lwres_result_t
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jglwres_lwpacket_renderheader</CODE
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg>(lwres_buffer_t *b, lwres_lwpacket_t *pkt);</CODE
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg></P
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg><P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><CODE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><CODE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="FUNCDEF"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>lwres_result_t
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppolwres_lwpacket_parseheader</CODE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>(lwres_buffer_t *b, lwres_lwpacket_t *pkt);</CODE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><DIV
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="REFSECT1"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoNAME="AEN27"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo></A
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>DESCRIPTION</H2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo><P
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>These functions rely on a
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo<SPAN
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCLASS="TYPE"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>struct lwres_lwpacket</SPAN
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppowhich is defined in
<TT
CLASS="FILENAME"
>lwres/lwpacket.h</TT
>.
<PRE
CLASS="PROGRAMLISTING"
>typedef struct lwres_lwpacket lwres_lwpacket_t;
struct lwres_lwpacket {
lwres_uint32_t length;
lwres_uint16_t version;
lwres_uint16_t pktflags;
lwres_uint32_t serial;
lwres_uint32_t opcode;
lwres_uint32_t result;
lwres_uint32_t recvlength;
lwres_uint16_t authtype;
lwres_uint16_t authlength;
};</PRE
></P
><P
></P
><P
>The elements of this structure are:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>length</TT
></DT
><DD
><P
>the overall packet length, including the entire packet header.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>version</TT
></DT
><DD
><P
>the header format. There is currently only one format,
<SPAN
CLASS="TYPE"
>LWRES_LWPACKETVERSION_0</SPAN
>.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>pktflags</TT
></DT
><DD
><P
>library-defined flags for this packet: for instance whether the packet
is a request or a reply. Flag values can be set, but not defined by
the caller.
This field is filled in by the application wit the exception of the
LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in the
lwres_gabn_*() and lwres_gnba_*() calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>serial</TT
></DT
><DD
><P
>is set by the requestor and is returned in all replies. If two or more
packets from the same source have the same serial number and are from
the same source, they are assumed to be duplicates and the latter ones
may be dropped.
This field must be set by the application.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>opcode</TT
></DT
><DD
><P
>indicates the operation.
Opcodes between 0x00000000 and 0x03ffffff are
reserved for use by the lightweight resolver library. Opcodes between
0x04000000 and 0xffffffff are application defined.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>result</TT
></DT
><DD
><P
>is only valid for replies.
Results between 0x04000000 and 0xffffffff are application defined.
Results between 0x00000000 and 0x03ffffff are reserved for library use.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>recvlength</TT
></DT
><DD
><P
>is the maximum buffer size that the receiver can handle on requests
and the size of the buffer needed to satisfy a request when the buffer
is too large for replies.
This field is supplied by the application.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>authtype</TT
></DT
><DD
><P
>defines the packet level authentication that is used.
Authorisation types between 0x1000 and 0xffff are application defined
and types between 0x0000 and 0x0fff are reserved for library use.
Currently these are not used and must be zero.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>authlen</TT
></DT
><DD
><P
>gives the length of the authentication data.
Since packet authentication is currently not used, this must be zero.</P
></DD
></DL
></DIV
></P
><P
>The following opcodes are currently defined:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>NOOP</TT
></DT
><DD
><P
>Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>GETADDRSBYNAME</TT
></DT
><DD
><P
>returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>GETNAMEBYADDR</TT
></DT
><DD
><P
>return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.</P
></DD
></DL
></DIV
></P
><P
><TT
CLASS="FUNCTION"
>lwres_lwpacket_renderheader()</TT
>
transfers the contents of lightweight resolver packet structure
<SPAN
CLASS="TYPE"
>lwres_lwpacket_t</SPAN
>
<TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
>
in network byte order to the lightweight resolver buffer,
<TT
CLASS="PARAMETER"
><I
>*b</I
></TT
>.&#13;</P
><P
><TT
CLASS="FUNCTION"
>lwres_lwpacket_parseheader()</TT
>
performs the converse operation.
It transfers data in network byte order from buffer
<TT
CLASS="PARAMETER"
><I
>*b</I
></TT
>
to resolver packet
<TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
>.
The contents of the buffer
<TT
CLASS="PARAMETER"
><I
>b</I
></TT
>
should correspond to a
<SPAN
CLASS="TYPE"
>lwres_lwpacket_t</SPAN
>.&#13;</P
><P
>Both functions have assertion checks to ensure that
<TT
CLASS="PARAMETER"
><I
>b</I
></TT
>
and
<TT
CLASS="PARAMETER"
><I
>pkt</I
></TT
>
are not
<SPAN
CLASS="TYPE"
>NULL</SPAN
>.&#13;</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN114"
></A
><H2
>RETURN VALUES</H2
><P
>Successful calls to
<TT
CLASS="FUNCTION"
>lwres_lwpacket_renderheader()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_lwpacket_parseheader()</TT
>
return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_SUCCESS</SPAN
>.
If there is insufficient space to copy data between the buffer
<TT
CLASS="PARAMETER"
><I
>*b</I
></TT
>
and lightweight resolver packet
<TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
>
both functions return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_UNEXPECTEDEND</SPAN
>.&#13;</P
></DIV
></BODY
></HTML
>