Watt-32 tcp/ip  2.2 dev-rel.10
nameser.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 1983, 1989, 1993
7  * The Regents of the University of California. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  * must display the following acknowledgement:
19  * This product includes software developed by the University of
20  * California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  * may be used to endorse or promote products derived from this software
23  * without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  * -
38  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
39  *
40  * Permission to use, copy, modify, and distribute this software for any
41  * purpose with or without fee is hereby granted, provided that the above
42  * copyright notice and this permission notice appear in all copies, and that
43  * the name of Digital Equipment Corporation not be used in advertising or
44  * publicity pertaining to distribution of the document or software without
45  * specific, written prior permission.
46  *
47  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
48  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
49  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
50  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
51  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
52  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
53  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
54  * SOFTWARE.
55  * -
56  * --Copyright--
57  *
58  * @(#)nameser.h 8.2 (Berkeley) 2/16/94
59  * From Id: nameser.h,v 4.9.1.15 1994/07/19 22:51:24 vixie Exp
60  * $Id: nameser.h,v 1.8 1996/08/29 20:01:00 peter Exp $
61  */
62 
63 #ifndef __ARPA_NAMESER_H
64 #define __ARPA_NAMESER_H
65 
66 #ifndef __SYS_W32API_H
67 #include <sys/w32api.h>
68 #endif
69 
70 #ifndef __SYS_PARAM_H
71 #include <sys/param.h>
72 #endif
73 
74 #ifndef __SYS_WTYPES_H
75 #include <sys/wtypes.h>
76 #endif
77 
78 #ifndef __SYS_CDEFS_H
79 #include <sys/cdefs.h>
80 #endif
81 
82 /*
83  * revision information. this is the release date in YYYYMMDD format.
84  * it can change every day so the right thing to do with it is use it
85  * in preprocessor commands such as "#if (__BIND > 19931104)". do not
86  * compare for equality; rather, use it to determine whether your resolver
87  * is new enough to contain a certain feature.
88  */
89 
90 #define __BIND 19960801 /* interface version stamp */
91 
92 /*
93  * Define constants based on rfc883
94  */
95 #define PACKETSZ 512 /* maximum packet size */
96 #define MAXDNAME 1025 /* maximum domain name */
97 #define MAXCDNAME 255 /* maximum compressed domain name */
98 #define MAXLABEL 63 /* maximum length of domain label */
99 #define HFIXEDSZ 12 /* #/bytes of fixed data in header */
100 #define QFIXEDSZ 4 /* #/bytes of fixed data in query */
101 #define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
102 #define INT32SZ 4 /* for systems without 32-bit ints */
103 #define INT16SZ 2 /* for systems without 16-bit ints */
104 #define INADDRSZ 4 /* IPv4 T_A */
105 #define IN6ADDRSZ 16 /* IPv6 T_AAAA */
106 
107 
108 /*
109  * Internet nameserver port number
110  */
111 #define NAMESERVER_PORT 53
112 
113 /*
114  * Currently defined opcodes
115  */
116 #define QUERY 0x0 /* standard query */
117 #define IQUERY 0x1 /* inverse query */
118 #define STATUS 0x2 /* nameserver status query */
119 #define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
120 
121 #ifdef ALLOW_UPDATES
122  /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
123 # define UPDATEA 0x9 /* add resource record */
124 # define UPDATED 0xa /* delete a specific resource record */
125 # define UPDATEDA 0xb /* delete all named resource record */
126 # define UPDATEM 0xc /* modify a specific resource record */
127 # define UPDATEMA 0xd /* modify all named resource record */
128 # define ZONEINIT 0xe /* initial zone transfer */
129 # define ZONEREF 0xf /* incremental zone referesh */
130 #endif
131 
132 /*
133  * Currently defined response codes
134  */
135 #if !defined(WIN32) && !defined(_WIN32) /* <winerror.h> value is okay */
136 #define NOERROR 0 /* no error */
137 #endif
138 #define FORMERR 1 /* format error */
139 #define SERVFAIL 2 /* server failure */
140 #define NXDOMAIN 3 /* non existent domain */
141 #define NOTIMP 4 /* not implemented */
142 #define REFUSED 5 /* query refused */
143 
144 #ifdef ALLOW_UPDATES
145  /* non standard */
146 # define NOCHANGE 0xf /* update failed to change db */
147 #endif
148 
149 /*
150  * Type values for resources and queries
151  */
152 #define T_A 1 /* host address */
153 #define T_NS 2 /* authoritative server */
154 #define T_MD 3 /* mail destination */
155 #define T_MF 4 /* mail forwarder */
156 #define T_CNAME 5 /* canonical name */
157 #define T_SOA 6 /* start of authority zone */
158 #define T_MB 7 /* mailbox domain name */
159 #define T_MG 8 /* mail group member */
160 #define T_MR 9 /* mail rename name */
161 #define T_NULL 10 /* null resource record */
162 #define T_WKS 11 /* well known service */
163 #define T_PTR 12 /* domain name pointer */
164 #define T_HINFO 13 /* host information */
165 #define T_MINFO 14 /* mailbox information */
166 #define T_MX 15 /* mail routing information */
167 #define T_TXT 16 /* text strings */
168 #define T_RP 17 /* responsible person */
169 #define T_AFSDB 18 /* AFS cell database */
170 #define T_X25 19 /* X_25 calling address */
171 #define T_ISDN 20 /* ISDN calling address */
172 #define T_RT 21 /* router */
173 #define T_NSAP 22 /* NSAP address */
174 #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
175 #define T_SIG 24 /* security signature */
176 #define T_KEY 25 /* security key */
177 #define T_PX 26 /* X.400 mail mapping */
178 #define T_GPOS 27 /* geographical position (withdrawn) */
179 #define T_AAAA 28 /* IP6 Address */
180 #define T_LOC 29 /* Location Information */
181 #define T_NXT 30 /* Next Valid Name in Zone */
182 #define T_EID 31 /* Endpoint identifier */
183 #define T_NIMLOC 32 /* Nimrod locator */
184 #define T_SRV 33 /* Server selection */
185 #define T_ATMA 34 /* ATM Address */
186 #define T_NAPTR 35 /* Naming Authority PoinTeR */
187 #define T_OPT 41 /* Extension mechanisms for DNS (EDNS) */
188  /* non standard */
189 #define T_UINFO 100 /* user (finger) information */
190 #define T_UID 101 /* user ID */
191 #define T_GID 102 /* group ID */
192 #define T_UNSPEC 103 /* Unspecified format (binary data) */
193  /* Query type values which do not appear in resource records */
194 #define T_IXFR 251 /* incremental zone transfer */
195 #define T_AXFR 252 /* transfer zone of authority */
196 #define T_MAILB 253 /* transfer mailbox records */
197 #define T_MAILA 254 /* transfer mail agent records */
198 #define T_ANY 255 /* wildcard match */
199 
200 #define T_WINS 0xFF01 /* WINS name lookup */
201 #define T_WINSR 0xFF02 /* WINS reverse lookup */
202 
203 /*
204  * Values for class field
205  */
206 
207 #define C_IN 1 /* the arpa internet */
208 #define C_CHAOS 3 /* for chaos net (MIT) */
209 #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
210  /* Query class values which do not appear in resource records */
211 #define C_ANY 255 /* wildcard match */
212 
213 /*
214  * Status return codes for T_UNSPEC conversion routines
215  */
216 #define CONV_SUCCESS 0
217 #define CONV_OVERFLOW (-1)
218 #define CONV_BADFMT (-2)
219 #define CONV_BADCKSUM (-3)
220 #define CONV_BADBUFLEN (-4)
221 
222 #include <sys/pack_on.h>
223 
224 /*
225  * Structure for query header. The order of the fields is machine- and
226  * compiler-dependent, depending on the byte/bit order and the layout
227  * of bit fields. We use bit fields only in int variables, as this
228  * is all ANSI requires. This requires a somewhat confusing rearrangement.
229  */
230 
231 typedef struct {
232  unsigned id : 16; /* query identification number */
233 
234  /* fields in third byte */
235  unsigned rd : 1; /* recursion desired */
236  unsigned tc : 1; /* truncated message */
237  unsigned aa : 1; /* authoritative answer */
238  unsigned opcode : 4; /* purpose of message */
239  unsigned qr : 1; /* response flag */
240 
241  /* fields in fourth byte */
242  unsigned rcode : 4; /* response code */
243  unsigned cd : 1; /* checking disabled by resolver */
244  unsigned ad : 1; /* authentic data from named */
245  unsigned unused : 1; /* unused bits (MBZ as of 4.9.3a3) */
246  unsigned ra : 1; /* recursion available */
247 
248  /* remaining bytes */
249  unsigned qdcount : 16; /* number of question entries */
250  unsigned ancount : 16; /* number of answer entries */
251  unsigned nscount : 16; /* number of authority entries */
252  unsigned arcount : 16; /* number of resource entries */
253  } HEADER;
254 
255 
256 /*
257  * Defines for handling compressed domain names
258  */
259 #define INDIR_MASK 0xc0
260 
261 /*
262  * Structure for passing resource records around.
263  */
264 struct rrec {
265  u_short r_zone; /* zone number */
266  u_short r_class; /* class number */
267  u_short r_type; /* type number */
268  u_long r_ttl; /* time to live */
269  int r_size; /* size of data area */
270  char *r_data; /* pointer to data */
271  };
272 
273 #include <sys/pack_off.h>
274 
275 
276 __BEGIN_DECLS
277 
278 W32_FUNC u_short W32_CALL _getshort (const u_char *);
279 W32_FUNC u_long W32_CALL _getlong (const u_char *);
280 
281 __END_DECLS
282 
283 /*
284  * Inline versions of get/put short/long. Pointer is advanced.
285  *
286  * These macros demonstrate the property of C whereby it can be
287  * portable or it can be elegant but rarely both.
288  */
289 #define GETSHORT(s, cp) do { \
290  register u_char *t_cp = (u_char *)(cp); \
291  (s) = ((u_short)t_cp[0] << 8) \
292  | ((u_short)t_cp[1]); \
293  (cp) += INT16SZ; \
294  } while (0)
295 
296 #define GETLONG(l, cp) do { \
297  register u_char *t_cp = (u_char *)(cp); \
298  (l) = ((u_long)t_cp[0] << 24) \
299  | ((u_long)t_cp[1] << 16) \
300  | ((u_long)t_cp[2] << 8) \
301  | ((u_long)t_cp[3]); \
302  (cp) += INT32SZ; \
303  } while (0)
304 
305 #define PUTSHORT(s, cp) do { \
306  register u_short t_s = (u_short)(s); \
307  register u_char *t_cp = (u_char *)(cp); \
308  *t_cp++ = (u_char) (t_s >> 8); \
309  *t_cp = (u_char) t_s; \
310  (cp) += INT16SZ; \
311  } while (0)
312 
313 #define PUTLONG(l, cp) do { \
314  register u_long t_l = (u_long)(l); \
315  register u_char *t_cp = (u_char *)(cp); \
316  *t_cp++ = (u_char) (t_l >> 24); \
317  *t_cp++ = (u_char) (t_l >> 16); \
318  *t_cp++ = (u_char) (t_l >> 8); \
319  *t_cp = (u_char) t_l; \
320  (cp) += INT32SZ; \
321  } while (0)
322 
323 #endif
Definition: nameser.h:264