]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/nameser.h
exit.3: add the comma after an empty space
[FreeBSD/FreeBSD.git] / contrib / tcpdump / nameser.h
1 /*
2  * Copyright (c) 1983, 1989, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)nameser.h   8.2 (Berkeley) 2/16/94
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 #ifndef _NAMESER_H_
57 #define _NAMESER_H_
58
59 #include <sys/types.h>
60
61 /*
62  * Define constants based on rfc883
63  */
64 #define PACKETSZ        512             /* maximum packet size */
65 #define MAXDNAME        256             /* maximum domain name */
66 #define MAXCDNAME       255             /* maximum compressed domain name */
67 #define MAXLABEL        63              /* maximum length of domain label */
68         /* Number of bytes of fixed size data in query structure */
69 #define QFIXEDSZ        4
70         /* number of bytes of fixed size data in resource record */
71 #define RRFIXEDSZ       10
72
73 /*
74  * Currently defined opcodes
75  */
76 #define QUERY           0x0             /* standard query */
77 #define IQUERY          0x1             /* inverse query */
78 #define STATUS          0x2             /* nameserver status query */
79 #if 0
80 #define xxx             0x3             /* 0x3 reserved */
81 #endif
82         /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
83 #define UPDATEA         0x9             /* add resource record */
84 #define UPDATED         0xa             /* delete a specific resource record */
85 #define UPDATEDA        0xb             /* delete all named resource record */
86 #define UPDATEM         0xc             /* modify a specific resource record */
87 #define UPDATEMA        0xd             /* modify all named resource record */
88
89 #define ZONEINIT        0xe             /* initial zone transfer */
90 #define ZONEREF         0xf             /* incremental zone referesh */
91
92 /*
93  * Undefine various #defines from various System V-flavored OSes (Solaris,
94  * SINIX, HP-UX) so the compiler doesn't whine that we redefine them.
95  */
96 #ifdef T_NULL
97 #undef T_NULL
98 #endif
99 #ifdef T_OPT
100 #undef T_OPT
101 #endif
102 #ifdef T_UNSPEC
103 #undef T_UNSPEC
104 #endif
105 #ifdef NOERROR
106 #undef NOERROR
107 #endif
108
109 /*
110  * Currently defined response codes
111  */
112 #define NOERROR         0               /* no error */
113 #define FORMERR         1               /* format error */
114 #define SERVFAIL        2               /* server failure */
115 #define NXDOMAIN        3               /* non existent domain */
116 #define NOTIMP          4               /* not implemented */
117 #define REFUSED         5               /* query refused */
118         /* non standard */
119 #define NOCHANGE        0xf             /* update failed to change db */
120
121 /*
122  * Type values for resources and queries
123  */
124 #define T_A             1               /* host address */
125 #define T_NS            2               /* authoritative server */
126 #define T_MD            3               /* mail destination */
127 #define T_MF            4               /* mail forwarder */
128 #define T_CNAME         5               /* connonical name */
129 #define T_SOA           6               /* start of authority zone */
130 #define T_MB            7               /* mailbox domain name */
131 #define T_MG            8               /* mail group member */
132 #define T_MR            9               /* mail rename name */
133 #define T_NULL          10              /* null resource record */
134 #define T_WKS           11              /* well known service */
135 #define T_PTR           12              /* domain name pointer */
136 #define T_HINFO         13              /* host information */
137 #define T_MINFO         14              /* mailbox information */
138 #define T_MX            15              /* mail routing information */
139 #define T_TXT           16              /* text strings */
140 #define T_RP            17              /* responsible person */
141 #define T_AFSDB         18              /* AFS cell database */
142 #define T_X25           19              /* X_25 calling address */
143 #define T_ISDN          20              /* ISDN calling address */
144 #define T_RT            21              /* router */
145 #define T_NSAP          22              /* NSAP address */
146 #define T_NSAP_PTR      23              /* reverse lookup for NSAP */
147 #define T_SIG           24              /* security signature */
148 #define T_KEY           25              /* security key */
149 #define T_PX            26              /* X.400 mail mapping */
150 #define T_GPOS          27              /* geographical position (withdrawn) */
151 #define T_AAAA          28              /* IP6 Address */
152 #define T_LOC           29              /* Location Information */
153 #define T_NXT           30              /* Next Valid Name in Zone */
154 #define T_EID           31              /* Endpoint identifier */
155 #define T_NIMLOC        32              /* Nimrod locator */
156 #define T_SRV           33              /* Server selection */
157 #define T_ATMA          34              /* ATM Address */
158 #define T_NAPTR         35              /* Naming Authority PoinTeR */
159 #define T_KX            36              /* Key Exchanger */
160 #define T_CERT          37              /* Certificates in the DNS */
161 #define T_A6            38              /* IP6 address */
162 #define T_DNAME         39              /* non-terminal redirection */
163 #define T_SINK          40              /* unknown */
164 #define T_OPT           41              /* EDNS0 option (meta-RR) */
165 #define T_APL           42              /* lists of address prefixes */
166 #define T_DS            43              /* Delegation Signer */
167 #define T_SSHFP         44              /* SSH Fingerprint */
168 #define T_IPSECKEY      45              /* IPsec keying material */
169 #define T_RRSIG         46              /* new security signature */
170 #define T_NSEC          47              /* provable insecure information */
171 #define T_DNSKEY        48              /* new security key */
172 #define T_DHCID         49              /* DHCP IDentifier */
173 #define T_NSEC3         50              /* Next SECure record v3 */
174 #define T_NSEC3PARAM    51              /* NSEC3 PARAMeter */
175 #define T_TLSA          52              /* TLS Authentication */
176 #define T_SMIMEA        53              /* S/MIME Authentication */
177 /* Unassigned */
178 #define T_HIP           55              /* Host Identity Protocol */
179 #define T_NINFO         56              /* zone status information */
180 #define T_RKEY          57              /* Record encryption KEY */
181 #define T_TALINK        58              /* Trust Anchor LINK */
182 #define T_CDS           59              /* Child Delegation Signer */
183 #define T_CDNSKEY       60              /* Child DNSKEY */
184 #define T_OPENPGPKEY    61              /* OpenPGP KEY */
185 #define T_CSYNC         62              /* Child to parent SYNCronization */
186 #define T_ZONEMD        63              /* ZONE data Message Digest */
187 #define T_SVCB          64              /* SerViCe Binding */
188 #define T_HTTPS         65              /* HTTPS binding */
189         /* non standard */
190 #define T_SPF           99              /* sender policy framework */
191 #define T_UINFO         100             /* user (finger) information */
192 #define T_UID           101             /* user ID */
193 #define T_GID           102             /* group ID */
194 #define T_UNSPEC        103             /* Unspecified format (binary data) */
195 #define T_NID           104             /* Node IDentifier */
196 #define T_L32           105             /* Locator 32-bit */
197 #define T_L64           106             /* Locator 64-bit */
198 #define T_LP            107             /* Locator Pointer */
199 #define T_EUI48         108             /* an EUI-48 address */
200 #define T_EUI64         109             /* an EUI-64 address */
201         /* Query type values which do not appear in resource records */
202 #define T_TKEY          249             /* Transaction Key [RFC2930] */
203 #define T_TSIG          250             /* Transaction Signature [RFC2845] */
204 #define T_IXFR          251             /* incremental transfer [RFC1995] */
205 #define T_AXFR          252             /* transfer zone of authority */
206 #define T_MAILB         253             /* transfer mailbox records */
207 #define T_MAILA         254             /* transfer mail agent records */
208 #define T_ANY           255             /* wildcard match */
209 #define T_URI           256             /* uri records [RFC7553] */
210 #define T_CAA           257             /* Certification Authority Authorization */
211 #define T_AVC           258             /* Application Visibility and Control */
212 #define T_DOA           259             /* Digital Object Architecture */
213 #define T_AMTRELAY      260             /* Automatic Multicast Tunneling RELAY */
214 #define T_TA            32768           /* DNSSEC Trust Authorities */
215 #define T_DLV           32769           /* DNSSEC Lookaside Validation */
216
217 /*
218  * Values for class field
219  */
220
221 #define C_IN            1               /* the arpa internet */
222 #define C_CHAOS         3               /* for chaos net (MIT) */
223 #define C_HS            4               /* for Hesiod name server (MIT) (XXX) */
224         /* Query class values which do not appear in resource records */
225 #define C_ANY           255             /* wildcard match */
226 #define C_QU            0x8000          /* mDNS QU flag in queries */
227 #define C_CACHE_FLUSH   0x8000          /* mDNS cache flush flag in replies */
228
229 /*
230  * Values for EDNS option types
231  */
232 #define E_LLQ           1       /* long lived queries protocol */
233 #define E_UL            2       /* dynamic dns update leases */
234 #define E_NSID          3       /* name server identifier */
235 #define E_DAU           5       /* signal DNSSEC algorithm understood */
236 #define E_DHU           6       /* signal DS hash understood */
237 #define E_N3U           7       /* signal NSEC3 hash understood */
238 #define E_ECS           8       /* EDNS client subnet */
239 #define E_EXPIRE        9       /* zone expiration */
240 #define E_COOKIE        10      /* DNS cookies */
241 #define E_KEEPALIVE     11      /* TCP keepalive */
242 #define E_PADDING       12      /* pad DNS messages */
243 #define E_CHAIN         13      /* chain DNS queries */
244 #define E_KEYTAG        14      /* EDNS key tag */
245 #define E_CLIENTTAG     16      /* EDNS client tag */
246 #define E_SERVERTAG     17      /* EDNS server tag */
247
248 /*
249  * Values for DNSSEC Algorithms
250  * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
251  */
252
253 #define A_DELETE                0
254 #define A_RSAMD5                1
255 #define A_DH                    2
256 #define A_DSA                   3
257 #define A_RSASHA1               5
258 #define A_DSA_NSEC3_SHA1        6
259 #define A_RSASHA1_NSEC3_SHA1    7
260 #define A_RSASHA256             8
261 #define A_RSASHA512             10
262 #define A_ECC_GOST              12
263 #define A_ECDSAP256SHA256       13
264 #define A_ECDSAP384SHA384       14
265 #define A_ED25519               15
266 #define A_ED448                 16
267 #define A_INDIRECT              252
268 #define A_PRIVATEDNS            253
269 #define A_PRIVATEOID            254
270
271 /*
272  * Values for NSEC3 algorithms
273  * https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml
274  */
275 #define NSEC_SHA1   1
276
277 /*
278  * Values for delegation signer algorithms
279  * https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml
280  */
281 #define DS_SHA1     1
282 #define DS_SHA256   2
283 #define DS_GOST     3
284 #define DS_SHA384   4
285
286
287 /*
288  * Status return codes for T_UNSPEC conversion routines
289  */
290 #define CONV_SUCCESS 0
291 #define CONV_OVERFLOW -1
292 #define CONV_BADFMT -2
293 #define CONV_BADCKSUM -3
294 #define CONV_BADBUFLEN -4
295
296 /*
297  * Structure for query header.
298  */
299 typedef struct {
300         nd_uint16_t id;         /* query identification number */
301         nd_uint16_t flags;      /* QR, Opcode, AA, TC, RD, RA, RCODE */
302         nd_uint16_t qdcount;    /* number of question entries */
303         nd_uint16_t ancount;    /* number of answer entries */
304         nd_uint16_t nscount;    /* number of authority entries */
305         nd_uint16_t arcount;    /* number of resource entries */
306 } dns_header_t;
307
308 /*
309  * Macros for subfields of flag fields.
310  */
311 #define DNS_QR(flags)           ((flags) & 0x8000)      /* response flag */
312 #define DNS_OPCODE(flags)       (((flags) >> 11) & 0xF) /* purpose of message */
313 #define DNS_AA(flags)           (flags & 0x0400)        /* authoritative answer */
314 #define DNS_TC(flags)           (flags & 0x0200)        /* truncated message */
315 #define DNS_RD(flags)           (flags & 0x0100)        /* recursion desired */
316 #define DNS_RA(flags)           (flags & 0x0080)        /* recursion available */
317 #define DNS_AD(flags)           (flags & 0x0020)        /* authentic data from named */
318 #define DNS_CD(flags)           (flags & 0x0010)        /* checking disabled by resolver */
319 #define DNS_RCODE(flags)        (flags & 0x000F)        /* response code */
320
321 /*
322  * Defines for handling compressed domain names, EDNS0 labels, etc.
323  */
324 #define TYPE_MASK       0xc0    /* mask for the type bits of the item */
325 #define TYPE_INDIR      0xc0    /* 11.... - pointer */
326 #define TYPE_RESERVED   0x80    /* 10.... - reserved */
327 #define TYPE_EDNS0      0x40    /* 01.... - EDNS(0) label */
328 #define TYPE_LABEL      0x00    /* 00.... - regular label */
329 #  define EDNS0_ELT_BITLABEL 0x01
330
331 #endif /* !_NAMESER_H_ */