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

sipXtackLib home page