summaryrefslogtreecommitdiff
path: root/doc/man/lwres/lwres_packet.3
blob: 9f776092ee35771d686008c28168d622fac5b9e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.\" Copyright (C) 2000, 2001  Internet Software Consortium.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
.\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
.\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
.\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
.\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
.\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.\" $Id: lwres_packet.3,v 1.5.4.1 2001/01/09 22:43:04 bwelling Exp $

.Dd Jun 30, 2000
.Dt LWRES_PACKET 3
.Os BIND9 9
.ds vT BIND9 Programmer's Manual
.Sh NAME
.Nm lwres_lwpacket_renderheader ,
.Nm lwres_lwpacket_parseheader
.Nd lightweight resolver packet handling functions
.Sh SYNOPSIS
.Fd #include <lwres/lwbuffer.h>
.Fd #include <lwres/lwpacket.h>
.Fd #include <lwres/result.h>
.Fd
.Ft lwres_result_t
.Fo lwres_lwpacket_renderheader
.Fa "lwres_buffer_t *b"
.Fa "lwres_lwpacket_t *pkt"
.Fc
.Ft lwres_result_t
.Fo lwres_lwpacket_parseheader
.Fa "lwres_buffer_t *b"
.Fa "lwres_lwpacket_t *pkt"
.Fc
.Sh DESCRIPTION
These functions rely on a
.Dv "struct lwres_lwpacket"
which is defined in
.Pa lwres/lwpacket.h .
.Bd -literal -offset indent
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;
};
.Ed
.Pp
.Pp
The elements of this structure are:
.Bl -tag -width recvlength
.It Li length
the overall packet length, including the entire packet header.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
.It Li version
the header format. There is currently only one format,
.Dv LWRES_LWPACKETVERSION_0 .
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
.It Li pktflags
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.
.It Li serial
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.
.It Li opcode
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.
.It Li result
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.
.It Li recvlength
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.
.It Li authtype
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.
.It Li authlen
gives the length of the authentication data.
Since packet authentication is currently not used, this must be zero.
.El
.Pp
The following opcodes are currently defined:
.Bl -tag -width GETADDRSBYNAME
.It Li NOOP
Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.
.It Li GETADDRSBYNAME
returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.
.It Li GETNAMEBYADDR
return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.
.El
.Pp
.Fn lwres_lwpacket_renderheader
transfers the contents of lightweight resolver packet structure
.Dv lwres_lwpacket_t
.Fa *pkt
in network byte order to the lightweight resolver buffer,
.Fa *b .
.Pp
.Fn lwres_lwpacket_parseheader
performs the converse operation.
It transfers data in network byte order from buffer
.Fa *b
to resolver packet
.Fa *pkt .
The contents of the buffer
.Fa b
should correspond to a
.Dv "lwres_lwpacket_t" .
.Pp
Both functions have assertion checks to ensure that
.Fa b
and
.Fa pkt
are not
.Dv NULL .
.Sh RETURN VALUES
Successful calls to
.Fn lwres_lwpacket_renderheader
and
.Fn lwres_lwpacket_parseheader
return
.Er LWRES_R_SUCCESS .
If there is insufficient space to copy data between the buffer
.Fa *b
and lightweight resolver packet
.Fa *pkt
both functions return
.Er LWRES_R_UNEXPECTEDEND .