Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / lwres / include / lwres / lwpacket.h
blobc1ae1dec74e06331ef1ec5b432226657844e7797
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: lwpacket.h,v 1.17.2.1 2004/03/09 06:12:37 marka Exp $ */
20 #ifndef LWRES_LWPACKET_H
21 #define LWRES_LWPACKET_H 1
23 #include <lwres/lang.h>
24 #include <lwres/lwbuffer.h>
25 #include <lwres/result.h>
27 typedef struct lwres_lwpacket lwres_lwpacket_t;
29 struct lwres_lwpacket {
30 lwres_uint32_t length;
31 lwres_uint16_t version;
32 lwres_uint16_t pktflags;
33 lwres_uint32_t serial;
34 lwres_uint32_t opcode;
35 lwres_uint32_t result;
36 lwres_uint32_t recvlength;
37 lwres_uint16_t authtype;
38 lwres_uint16_t authlength;
41 #define LWRES_LWPACKET_LENGTH (4 * 5 + 2 * 4)
43 #define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */
46 #define LWRES_LWPACKETVERSION_0 0
49 * "length" is the overall packet length, including the entire packet header.
51 * "version" specifies the header format. Currently, there is only one
52 * format, LWRES_LWPACKETVERSION_0.
54 * "flags" specifies library-defined flags for this packet. None of these
55 * are definable by the caller, but library-defined values can be set by
56 * the caller. For example, one bit in this field indicates if the packet
57 * is a request or a response.
59 * "serial" is set by the requestor and is returned in all replies. If two
60 * packets from the same source have the same serial number and are from
61 * the same source, they are assumed to be duplicates and the latter ones
62 * may be dropped. (The library does not do this by default on replies, but
63 * does so on requests.)
65 * "opcode" is application defined. Opcodes between 0x04000000 and 0xffffffff
66 * are application defined. Opcodes between 0x00000000 and 0x03ffffff are
67 * reserved for library use.
69 * "result" is application defined, and valid only on replies.
70 * Results between 0x04000000 and 0xffffffff are application defined.
71 * Results between 0x00000000 and 0x03ffffff are reserved for library use.
72 * (This is the same reserved range defined in <isc/resultclass.h>, so it
73 * would be trivial to map ISC_R_* result codes into packet result codes
74 * when appropriate.)
76 * "recvlength" is set to the maximum buffer size that the receiver can
77 * handle on requests, and the size of the buffer needed to satisfy a request
78 * when the buffer is too large for replies.
80 * "authtype" is the packet level auth type used.
81 * Authtypes between 0x1000 and 0xffff are application defined. Authtypes
82 * between 0x0000 and 0x0fff are reserved for library use. This is currently
83 * unused and MUST be set to zero.
85 * "authlen" is the length of the authentication data. See the specific
86 * authtypes for more information on what is contained in this field. This
87 * is currently unused, and MUST be set to zero.
89 * The remainder of the packet consists of two regions, one described by
90 * "authlen" and one of "length - authlen - sizeof(lwres_lwpacket_t)".
92 * That is:
94 * pkt header
95 * authlen bytes of auth information
96 * data bytes
100 * Currently defined opcodes:
102 * NOOP. Success is always returned, with the packet contents echoed.
104 * GETADDRSBYNAME. Return all known addresses for a given name.
105 * This may return NIS or /etc/hosts info as well as DNS
106 * information. Flags will be provided to indicate ip4/ip6
107 * addresses are desired.
109 * GETNAMEBYADDR. Return the hostname for the given address. Once
110 * again, it will return data from multiple sources.
113 LWRES_LANG_BEGINDECLS
115 /* XXXMLG document */
116 lwres_result_t
117 lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt);
119 lwres_result_t
120 lwres_lwpacket_parseheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt);
122 LWRES_LANG_ENDDECLS
124 #endif /* LWRES_LWPACKET_H */