Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/head/arpa/nameser.h
+++ new/usr/src/head/arpa/nameser.h
1 1 /*
2 2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3 3 * Use is subject to license terms.
4 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
4 5 */
5 6
6 7 /*
7 8 * Copyright (c) 1983, 1989, 1993
8 9 * The Regents of the University of California. All rights reserved.
9 10 *
10 11 * Redistribution and use in source and binary forms, with or without
11 12 * modification, are permitted provided that the following conditions
12 13 * are met:
13 14 * 1. Redistributions of source code must retain the above copyright
14 15 * notice, this list of conditions and the following disclaimer.
15 16 * 2. Redistributions in binary form must reproduce the above copyright
16 17 * notice, this list of conditions and the following disclaimer in the
17 18 * documentation and/or other materials provided with the distribution.
18 19 * 3. All advertising materials mentioning features or use of this software
19 20 * must display the following acknowledgement:
20 21 * This product includes software developed by the University of
21 22 * California, Berkeley and its contributors.
22 23 * 4. Neither the name of the University nor the names of its contributors
23 24 * may be used to endorse or promote products derived from this software
24 25 * without specific prior written permission.
25 26 *
26 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 37 * SUCH DAMAGE.
37 38 */
38 39
39 40 /*
40 41 * Portions Copyright (C) 2004, 2005, 2008, 2009
41 42 * Internet Systems Consortium, Inc. ("ISC")
42 43 * Portions Copyright (C) 1996-2003 Internet Software Consortium.
43 44 *
44 45 * Permission to use, copy, modify, and/or distribute this software for any
45 46 * purpose with or without fee is hereby granted, provided that the above
46 47 * copyright notice and this permission notice appear in all copies.
47 48 *
48 49 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
49 50 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
50 51 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
51 52 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
52 53 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
53 54 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
54 55 * PERFORMANCE OF THIS SOFTWARE.
55 56 */
56 57
57 58 /*
58 59 * $Id: nameser.h,v 8.50 2003/05/27 23:36:52 marka Exp $
59 60 */
60 61
61 62 #ifndef _ARPA_NAMESER_H
62 63 #define _ARPA_NAMESER_H
63 64
64 65 #include <sys/isa_defs.h>
65 66
66 67
67 68 #ifdef __cplusplus
68 69 extern "C" {
69 70 #endif
70 71
71 72 #define BIND_4_COMPAT
72 73
73 74 /*
74 75 * Revision information. This is the release date in YYYYMMDD format.
75 76 * It can change every day so the right thing to do with it is use it
76 77 * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
77 78 * compare for equality; rather, use it to determine whether your libresolv
78 79 * contains a new enough lib/nameser/ to support the feature you need.
79 80 */
80 81
81 82 #define __NAMESER 20090302 /* New interface version stamp. */
82 83
83 84 /*
84 85 * Define constants based on RFC 883, RFC 1034, RFC 1035
85 86 */
86 87 #define NS_PACKETSZ 512 /* default UDP packet size */
87 88 #define NS_MAXDNAME 1025 /* maximum domain name */
88 89 #define NS_MAXMSG 65535 /* maximum message size */
89 90 #define NS_MAXCDNAME 255 /* maximum compressed domain name */
90 91 #define NS_MAXLABEL 63 /* maximum length of domain label */
91 92 #define NS_MAXLABELS 128 /* theoretical max #/labels per domain name */
92 93 #define NS_MAXNNAME 256 /* maximum uncompressed (binary) domain name */
93 94 #define NS_MAXPADDR (sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"))
94 95 #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
95 96 #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
96 97 #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
97 98 #define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */
98 99 #define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */
99 100 #define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */
100 101 #define NS_INADDRSZ 4 /* IPv4 T_A */
101 102 #define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
102 103 #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
103 104 #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
104 105
105 106 /*
106 107 * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
107 108 * in synch with it.
108 109 */
109 110 typedef enum __ns_sect {
110 111 ns_s_qd = 0, /* Query: Question. */
111 112 ns_s_zn = 0, /* Update: Zone. */
112 113 ns_s_an = 1, /* Query: Answer. */
113 114 ns_s_pr = 1, /* Update: Prerequisites. */
114 115 ns_s_ns = 2, /* Query: Name servers. */
115 116 ns_s_ud = 2, /* Update: Update. */
116 117 ns_s_ar = 3, /* Query|Update: Additional records. */
117 118 ns_s_max = 4
118 119 } ns_sect;
119 120
120 121 /*
121 122 * Network name (compressed or not) type. Equivalent to a pointer when used
122 123 * in a function prototype. Can be const'd.
123 124 */
124 125 typedef uchar_t ns_nname[NS_MAXNNAME];
125 126 typedef const uchar_t *ns_nname_ct;
126 127 typedef uchar_t *ns_nname_t;
127 128
128 129 struct ns_namemap { ns_nname_ct base; int len; };
129 130 typedef struct ns_namemap *ns_namemap_t;
130 131 typedef const struct ns_namemap *ns_namemap_ct;
131 132
132 133 /*
133 134 * This is a message handle. It is caller allocated and has no dynamic data.
134 135 * This structure is intended to be opaque to all but ns_parse.c, thus the
135 136 * leading _'s on the member names. Use the accessor functions, not the _'s.
136 137 */
137 138 typedef struct __ns_msg {
138 139 const uchar_t *_msg, *_eom;
139 140 uint16_t _id, _flags, _counts[ns_s_max];
140 141 const uchar_t *_sections[ns_s_max];
141 142 ns_sect _sect;
142 143 int _rrnum;
143 144 const uchar_t *_msg_ptr;
144 145 } ns_msg;
145 146
146 147 /*
147 148 * This is a newmsg handle, used when constructing new messages with
148 149 * ns_newmsg_init, et al.
149 150 */
150 151 struct ns_newmsg {
151 152 ns_msg msg;
152 153 const uchar_t *dnptrs[25];
153 154 const uchar_t **lastdnptr;
154 155 };
155 156 typedef struct ns_newmsg ns_newmsg;
156 157
157 158 /* Private data structure - do not use from outside library. */
158 159 struct _ns_flagdata { int mask, shift; };
159 160 extern struct _ns_flagdata _ns_flagdata[];
160 161
161 162 /* Accessor macros - this is part of the public interface. */
162 163 #define ns_msg_id(handle) ((handle)._id + 0)
163 164 #define ns_msg_base(handle) ((handle)._msg + 0)
164 165 #define ns_msg_end(handle) ((handle)._eom + 0)
165 166 #define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
166 167 #define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
167 168
168 169 /*
169 170 * This is a parsed record. It is caller allocated and has no dynamic data.
170 171 */
171 172 typedef struct __ns_rr {
172 173 char name[NS_MAXDNAME];
173 174 uint16_t type;
174 175 uint16_t rr_class;
175 176 uint32_t ttl;
176 177 uint16_t rdlength;
177 178 const uchar_t *rdata;
178 179 } ns_rr;
179 180
180 181 /*
181 182 * Same thing, but using uncompressed network binary names, and real C types.
182 183 */
183 184 typedef struct __ns_rr2 {
184 185 ns_nname nname;
185 186 size_t nnamel;
186 187 int type;
187 188 int rr_class;
188 189 uint_t ttl;
189 190 int rdlength;
190 191 const uchar_t *rdata;
191 192 } ns_rr2;
192 193
193 194 /* Accessor macros - this is part of the public interface. */
194 195 #define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
195 196 #define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname)
196 197 #define ns_rr_nnamel(rr) ((rr).nnamel + 0)
197 198 #define ns_rr_type(rr) ((ns_type)((rr).type + 0))
198 199 #define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
199 200 #define ns_rr_ttl(rr) ((rr).ttl + 0)
200 201 #define ns_rr_rdlen(rr) ((rr).rdlength + 0)
201 202 #define ns_rr_rdata(rr) ((rr).rdata + 0)
202 203
203 204 /*
204 205 * These don't have to be in the same order as in the packet flags word,
205 206 * and they can even overlap in some cases, but they will need to be kept
206 207 * in synch with ns_parse.c:ns_flagdata[].
207 208 */
208 209 typedef enum __ns_flag {
209 210 ns_f_qr, /* Question/Response. */
210 211 ns_f_opcode, /* Operation code. */
211 212 ns_f_aa, /* Authoritative Answer. */
212 213 ns_f_tc, /* Truncation occurred. */
213 214 ns_f_rd, /* Recursion Desired. */
214 215 ns_f_ra, /* Recursion Available. */
215 216 ns_f_z, /* MBZ. */
216 217 ns_f_ad, /* Authentic Data (DNSSEC). */
217 218 ns_f_cd, /* Checking Disabled (DNSSEC). */
218 219 ns_f_rcode, /* Response code. */
219 220 ns_f_max
220 221 } ns_flag;
221 222
222 223 /*
223 224 * Currently defined opcodes.
224 225 */
225 226 typedef enum __ns_opcode {
226 227 ns_o_query = 0, /* Standard query. */
227 228 ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
228 229 ns_o_status = 2, /* Name server status query (unsupported). */
229 230 /* Opcode 3 is undefined/reserved. */
230 231 ns_o_notify = 4, /* Zone change notification. */
231 232 ns_o_update = 5, /* Zone update message. */
232 233 ns_o_max = 6
233 234 } ns_opcode;
234 235
235 236 /*
236 237 * Currently defined response codes.
237 238 */
238 239 typedef enum __ns_rcode {
239 240 ns_r_noerror = 0, /* No error occurred. */
240 241 ns_r_formerr = 1, /* Format error. */
241 242 ns_r_servfail = 2, /* Server failure. */
242 243 ns_r_nxdomain = 3, /* Name error. */
243 244 ns_r_notimpl = 4, /* Unimplemented. */
244 245 ns_r_refused = 5, /* Operation refused. */
245 246 /* these are for BIND_UPDATE */
246 247 ns_r_yxdomain = 6, /* Name exists */
247 248 ns_r_yxrrset = 7, /* RRset exists */
248 249 ns_r_nxrrset = 8, /* RRset does not exist */
249 250 ns_r_notauth = 9, /* Not authoritative for zone */
250 251 ns_r_notzone = 10, /* Zone of record different from zone section */
251 252 ns_r_max = 11,
252 253 /* The following are EDNS extended rcodes */
253 254 ns_r_badvers = 16,
254 255 /* The following are TSIG errors */
255 256 ns_r_badsig = 16,
256 257 ns_r_badkey = 17,
257 258 ns_r_badtime = 18
258 259 } ns_rcode;
259 260
260 261 /* BIND_UPDATE */
261 262 typedef enum __ns_update_operation {
262 263 ns_uop_delete = 0,
263 264 ns_uop_add = 1,
264 265 ns_uop_max = 2
265 266 } ns_update_operation;
266 267
267 268 /*
268 269 * This RR-like structure is particular to UPDATE.
269 270 */
270 271 struct ns_updrec {
271 272 struct ns_updrec *r_prev; /* prev record */
272 273 struct ns_updrec *r_next; /* next record */
273 274 uint8_t r_section; /* ZONE/PREREQUISITE/UPDATE */
274 275 char *r_dname; /* owner of the RR */
275 276 uint16_t r_class; /* class number */
276 277 uint16_t r_type; /* type number */
277 278 uint32_t r_ttl; /* time to live */
278 279 uchar_t *r_data; /* rdata fields as text string */
279 280 uint16_t r_size; /* size of r_data field */
280 281 int r_opcode; /* type of operation */
281 282 /* following fields for private use by the resolver/server routines */
282 283 struct ns_updrec *r_grpnext; /* next record when grouped */
283 284 struct databuf *r_dp; /* databuf to process */
284 285 struct databuf *r_deldp; /* databuf's deleted/overwritten */
285 286 uint16_t r_zone; /* zone number on server */
286 287 };
287 288 typedef struct ns_updrec ns_updrec;
288 289
289 290 /*
290 291 * This structure is used for TSIG authenticated messages
291 292 */
292 293 struct ns_tsig_key {
293 294 char name[NS_MAXDNAME], alg[NS_MAXDNAME];
294 295 unsigned char *data;
295 296 int len;
296 297 };
297 298 typedef struct ns_tsig_key ns_tsig_key;
298 299
299 300 /*
300 301 * This structure is used for TSIG authenticated TCP messages
301 302 */
302 303 struct ns_tcp_tsig_state {
303 304 int counter;
304 305 struct dst_key *key;
305 306 void *ctx;
306 307 unsigned char sig[NS_PACKETSZ];
307 308 int siglen;
308 309 };
309 310 typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
310 311
311 312 #define NS_TSIG_FUDGE 300
312 313 #define NS_TSIG_TCP_COUNT 100
313 314 #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
314 315
315 316 #define NS_TSIG_ERROR_NO_TSIG -10
316 317 #define NS_TSIG_ERROR_NO_SPACE -11
317 318 #define NS_TSIG_ERROR_FORMERR -12
318 319
319 320 /*
320 321 * Currently defined type values for resources and queries.
321 322 */
322 323 typedef enum __ns_type {
323 324 ns_t_invalid = 0, /* Cookie. */
324 325 ns_t_a = 1, /* Host address. */
325 326 ns_t_ns = 2, /* Authoritative server. */
326 327 ns_t_md = 3, /* Mail destination. */
327 328 ns_t_mf = 4, /* Mail forwarder. */
328 329 ns_t_cname = 5, /* Canonical name. */
329 330 ns_t_soa = 6, /* Start of authority zone. */
330 331 ns_t_mb = 7, /* Mailbox domain name. */
331 332 ns_t_mg = 8, /* Mail group member. */
332 333 ns_t_mr = 9, /* Mail rename name. */
333 334 ns_t_null = 10, /* Null resource record. */
334 335 ns_t_wks = 11, /* Well known service. */
335 336 ns_t_ptr = 12, /* Domain name pointer. */
336 337 ns_t_hinfo = 13, /* Host information. */
337 338 ns_t_minfo = 14, /* Mailbox information. */
338 339 ns_t_mx = 15, /* Mail routing information. */
339 340 ns_t_txt = 16, /* Text strings. */
340 341 ns_t_rp = 17, /* Responsible person. */
341 342 ns_t_afsdb = 18, /* AFS cell database. */
342 343 ns_t_x25 = 19, /* X_25 calling address. */
343 344 ns_t_isdn = 20, /* ISDN calling address. */
344 345 ns_t_rt = 21, /* Router. */
345 346 ns_t_nsap = 22, /* NSAP address. */
346 347 ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
347 348 ns_t_sig = 24, /* Security signature. */
348 349 ns_t_key = 25, /* Security key. */
349 350 ns_t_px = 26, /* X.400 mail mapping. */
350 351 ns_t_gpos = 27, /* Geographical position (withdrawn). */
351 352 ns_t_aaaa = 28, /* IPv6 Address. */
352 353 ns_t_loc = 29, /* Location Information. */
353 354 ns_t_nxt = 30, /* Next domain (security). */
354 355 ns_t_eid = 31, /* Endpoint identifier. */
355 356 ns_t_nimloc = 32, /* Nimrod Locator. */
356 357 ns_t_srv = 33, /* Server Selection. */
357 358 ns_t_atma = 34, /* ATM Address */
358 359 ns_t_naptr = 35, /* Naming Authority PoinTeR */
359 360 ns_t_kx = 36, /* Key Exchange */
360 361 ns_t_cert = 37, /* Certification record */
361 362 ns_t_a6 = 38, /* IPv6 address (deprecated) */
362 363 ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
363 364 ns_t_sink = 40, /* Kitchen sink (experimentatl) */
364 365 ns_t_opt = 41, /* EDNS0 option (meta-RR) */
365 366 ns_t_apl = 42, /* Address prefix list (RFC 3123) */
366 367 ns_t_ds = 43, /* Delegation Signer */
367 368 ns_t_sshfp = 44, /* SSH Fingerprint */
368 369 ns_t_ipseckey = 45, /* IPSEC Key */
369 370 ns_t_rrsig = 46, /* RRset Signature */
370 371 ns_t_nsec = 47, /* Negative security */
371 372 ns_t_dnskey = 48, /* DNS Key */
372 373 ns_t_dhcid = 49, /* Dynamic host configuratin identifier */
373 374 ns_t_nsec3 = 50, /* Negative security type 3 */
374 375 ns_t_nsec3param = 51, /* Negative security type 3 parameters */
375 376 ns_t_hip = 55, /* Host Identity Protocol */
376 377 ns_t_spf = 99, /* Sender Policy Framework */
377 378 ns_t_tkey = 249, /* Transaction key */
378 379 ns_t_tsig = 250, /* Transaction signature. */
379 380 ns_t_ixfr = 251, /* Incremental zone transfer. */
380 381 ns_t_axfr = 252, /* Transfer zone of authority. */
381 382 ns_t_mailb = 253, /* Transfer mailbox records. */
382 383 ns_t_maila = 254, /* Transfer mail agent records. */
383 384 ns_t_any = 255, /* Wildcard match. */
384 385 ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
385 386 ns_t_dlv = 32769, /* DNSSEC look-aside validatation. */
386 387 ns_t_max = 65536
387 388 } ns_type;
388 389
389 390 /* Exclusively a QTYPE? (not also an RTYPE) */
390 391 #define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
391 392 (t) == ns_t_mailb || (t) == ns_t_maila)
392 393 /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
393 394 #define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
394 395 /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
395 396 #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
396 397 #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
397 398 #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
398 399 (t) == ns_t_zxfr)
399 400
400 401 /*
401 402 * Values for class field
402 403 */
403 404 typedef enum __ns_class {
404 405 ns_c_invalid = 0, /* Cookie. */
405 406 ns_c_in = 1, /* Internet. */
406 407 ns_c_2 = 2, /* unallocated/unsupported. */
407 408 ns_c_chaos = 3, /* MIT Chaos-net. */
408 409 ns_c_hs = 4, /* MIT Hesiod. */
409 410 /* Query class values which do not appear in resource records */
410 411 ns_c_none = 254, /* for prereq. sections in update requests */
411 412 ns_c_any = 255, /* Wildcard match. */
412 413 ns_c_max = 65536
413 414 } ns_class;
414 415
415 416 /* DNSSEC constants. */
416 417
417 418 typedef enum __ns_key_types {
418 419 ns_kt_rsa = 1, /* key type RSA/MD5 */
419 420 ns_kt_dh = 2, /* Diffie Hellman */
420 421 ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */
421 422 ns_kt_private = 254 /* Private key type starts with OID */
422 423 } ns_key_types;
423 424
424 425 typedef enum __ns_cert_types {
425 426 cert_t_pkix = 1, /* PKIX (X.509v3) */
426 427 cert_t_spki = 2, /* SPKI */
427 428 cert_t_pgp = 3, /* PGP */
428 429 cert_t_url = 253, /* URL private type */
429 430 cert_t_oid = 254 /* OID private type */
430 431 } ns_cert_types;
431 432
432 433 /* Flags field of the KEY RR rdata. */
433 434 #define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */
434 435 #define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
435 436 #define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
436 437 #define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
437 438 #define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
438 439 /* The type bits can also be interpreted independently, as single bits: */
439 440 #define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */
440 441 #define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */
441 442 #define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
442 443 #define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */
443 444 #define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */
444 445 #define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */
445 446 #define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */
446 447 #define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */
447 448 #define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */
448 449 #define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */
449 450 #define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */
450 451 #define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */
451 452 #define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */
452 453 #define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */
453 454 #define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */
454 455 #define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */
455 456 #define NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | \
456 457 NS_KEY_RESERVED4 | \
457 458 NS_KEY_RESERVED5 | \
458 459 NS_KEY_RESERVED8 | \
459 460 NS_KEY_RESERVED9 | \
460 461 NS_KEY_RESERVED10 | \
461 462 NS_KEY_RESERVED11)
462 463 #define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */
463 464
464 465 /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
465 466 #define NS_ALG_MD5RSA 1 /* MD5 with RSA */
466 467 #define NS_ALG_DH 2 /* Diffie Hellman KEY */
467 468 #define NS_ALG_DSA 3 /* DSA KEY */
468 469 #define NS_ALG_DSS NS_ALG_DSA
469 470 #define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */
470 471 #define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */
471 472
472 473 /* Protocol values */
473 474 /* value 0 is reserved */
474 475 #define NS_KEY_PROT_TLS 1
475 476 #define NS_KEY_PROT_EMAIL 2
476 477 #define NS_KEY_PROT_DNSSEC 3
477 478 #define NS_KEY_PROT_IPSEC 4
478 479 #define NS_KEY_PROT_ANY 255
479 480
480 481 /* Signatures */
481 482 #define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */
482 483 #define NS_MD5RSA_MAX_BITS 4096
483 484 /* Total of binary mod and exp */
484 485 #define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
485 486 /* Max length of text sig block */
486 487 #define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
487 488 #define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
488 489 #define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
489 490
490 491 #define NS_DSA_SIG_SIZE 41
491 492 #define NS_DSA_MIN_SIZE 213
492 493 #define NS_DSA_MAX_BYTES 405
493 494
494 495 /* Offsets into SIG record rdata to find various values */
495 496 #define NS_SIG_TYPE 0 /* Type flags */
496 497 #define NS_SIG_ALG 2 /* Algorithm */
497 498 #define NS_SIG_LABELS 3 /* How many labels in name */
498 499 #define NS_SIG_OTTL 4 /* Original TTL */
499 500 #define NS_SIG_EXPIR 8 /* Expiration time */
500 501 #define NS_SIG_SIGNED 12 /* Signature time */
501 502 #define NS_SIG_FOOT 16 /* Key footprint */
502 503 #define NS_SIG_SIGNER 18 /* Domain name of who signed it */
503 504
504 505 /* How RR types are represented as bit-flags in NXT records */
505 506 #define NS_NXT_BITS 8
506 507 #define NS_NXT_BIT_SET(n, p) \
507 508 (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
508 509 #define NS_NXT_BIT_CLEAR(n, p) \
509 510 (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
510 511 #define NS_NXT_BIT_ISSET(n, p) \
511 512 (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
512 513 #define NS_NXT_MAX 127
513 514
514 515 /*
515 516 * EDNS0 extended flags, host order.
516 517 */
517 518 #define NS_OPT_DNSSEC_OK 0x8000U
518 519 #define NS_OPT_NSID 3
519 520
520 521 /*
521 522 * Inline versions of get/put short/long. Pointer is advanced.
522 523 */
523 524 #define NS_GET16(s, cp) do { \
524 525 register const uchar_t *t_cp = (const uchar_t *)(cp); \
525 526 (s) = ((uint16_t)t_cp[0] << 8) \
526 527 | ((uint16_t)t_cp[1]) \
527 528 ; \
528 529 (cp) += NS_INT16SZ; \
529 530 } while (0)
530 531
531 532 #define NS_GET32(l, cp) do { \
532 533 register const uchar_t *t_cp = (const uchar_t *)(cp); \
533 534 (l) = ((uint32_t)t_cp[0] << 24) \
534 535 | ((uint32_t)t_cp[1] << 16) \
535 536 | ((uint32_t)t_cp[2] << 8) \
536 537 | ((uint32_t)t_cp[3]) \
537 538 ; \
538 539 (cp) += NS_INT32SZ; \
539 540 } while (0)
540 541
541 542 #define NS_PUT16(s, cp) do { \
542 543 register uint16_t t_s = (uint16_t)(s); \
543 544 register uchar_t *t_cp = (uchar_t *)(cp); \
544 545 *t_cp++ = t_s >> 8; \
545 546 *t_cp = t_s; \
546 547 (cp) += NS_INT16SZ; \
547 548 } while (0)
548 549
549 550 #define NS_PUT32(l, cp) do { \
550 551 register uint32_t t_l = (uint32_t)(l); \
551 552 register uchar_t *t_cp = (uchar_t *)(cp); \
552 553 *t_cp++ = t_l >> 24; \
553 554 *t_cp++ = t_l >> 16; \
554 555 *t_cp++ = t_l >> 8; \
555 556 *t_cp = t_l; \
556 557 (cp) += NS_INT32SZ; \
557 558 } while (0)
558 559
559 560 /*
560 561 * ANSI C identifier hiding.
561 562 */
562 563 #define ns_msg_getflag __ns_msg_getflag
563 564 #define ns_get16 __ns_get16
564 565 #define ns_get32 __ns_get32
565 566 #define ns_put16 __ns_put16
566 567 #define ns_put32 __ns_put32
567 568 #define ns_initparse __ns_initparse
568 569 #define ns_skiprr __ns_skiprr
|
↓ open down ↓ |
555 lines elided |
↑ open up ↑ |
569 570 #define ns_parserr __ns_parserr
570 571 #define ns_parserr2 __ns_parserr2
571 572 #define ns_sprintrr __ns_sprintrr
572 573 #define ns_sprintrrf __ns_sprintrrf
573 574 #define ns_format_ttl __ns_format_ttl
574 575 #define ns_parse_ttl __ns_parse_ttl
575 576 #define ns_datetosecs __ns_datetosecs
576 577 #define ns_name_ntol __ns_name_ntol
577 578 #define ns_name_ntop __ns_name_ntop
578 579 #define ns_name_pton __ns_name_pton
580 +#define ns_name_pton2 __ns_name_pton2
579 581 #define ns_name_unpack __ns_name_unpack
580 582 #define ns_name_pack __ns_name_pack
581 583 #define ns_name_compress __ns_name_compress
582 584 #define ns_name_uncompress __ns_name_uncompress
583 585 #define ns_name_skip __ns_name_skip
584 586 #define ns_name_rollback __ns_name_rollback
585 587 #define ns_name_length __ns_name_length
586 588 #define ns_name_eq __ns_name_eq
587 589 #define ns_name_owned __ns_name_owned
588 590 #define ns_name_map __ns_name_map
589 591 #define ns_name_labels __ns_name_labels
590 592 #define ns_sign __ns_sign
591 593 #define ns_sign2 __ns_sign2
592 594 #define ns_sign_tcp __ns_sign_tcp
593 595 #define ns_sign_tcp2 __ns_sign_tcp2
594 596 #define ns_sign_tcp_init __ns_sign_tcp_init
595 597 #define ns_find_tsig __ns_find_tsig
596 598 #define ns_verify __ns_verify
597 599 #define ns_verify_tcp __ns_verify_tcp
598 600 #define ns_verify_tcp_init __ns_verify_tcp_init
599 601 #define ns_samedomain __ns_samedomain
600 602 #define ns_subdomain __ns_subdomain
601 603 #define ns_makecanon __ns_makecanon
602 604 #define ns_samename __ns_samename
603 605 #define ns_newmsg_init __ns_newmsg_init
604 606 #define ns_newmsg_copy __ns_newmsg_copy
605 607 #define ns_newmsg_id __ns_newmsg_id
606 608 #define ns_newmsg_flag __ns_newmsg_flag
607 609 #define ns_newmsg_q __ns_newmsg_q
608 610 #define ns_newmsg_rr __ns_newmsg_rr
609 611 #define ns_newmsg_done __ns_newmsg_done
610 612 #define ns_rdata_unpack __ns_rdata_unpack
611 613 #define ns_rdata_equal __ns_rdata_equal
612 614 #define ns_rdata_refers __ns_rdata_refers
613 615
614 616 int ns_msg_getflag(ns_msg, int);
615 617 uint_t ns_get16(const uchar_t *);
616 618 ulong_t ns_get32(const uchar_t *);
617 619 void ns_put16(uint_t, uchar_t *);
618 620 void ns_put32(ulong_t, uchar_t *);
619 621 int ns_initparse(const uchar_t *, int, ns_msg *);
620 622 int ns_skiprr(const uchar_t *, const uchar_t *, ns_sect, int);
621 623 int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
622 624 int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
623 625 int ns_sprintrr(const ns_msg *, const ns_rr *,
624 626 const char *, const char *, char *, size_t);
|
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
625 627 int ns_sprintrrf(const uchar_t *, size_t, const char *,
626 628 ns_class, ns_type, ulong_t, const uchar_t *,
627 629 size_t, const char *, const char *,
628 630 char *, size_t);
629 631 int ns_format_ttl(ulong_t, char *, size_t);
630 632 int ns_parse_ttl(const char *, ulong_t *);
631 633 uint32_t ns_datetosecs(const char *cp, int *errp);
632 634 int ns_name_ntol(const uchar_t *, uchar_t *, size_t);
633 635 int ns_name_ntop(const uchar_t *, char *, size_t);
634 636 int ns_name_pton(const char *, uchar_t *, size_t);
637 +int ns_name_pton2(const char *, uchar_t *, size_t, size_t *);
635 638 int ns_name_unpack(const uchar_t *, const uchar_t *,
636 639 const uchar_t *, uchar_t *, size_t);
637 640 int ns_name_pack(const uchar_t *, uchar_t *, int,
638 641 const uchar_t **, const uchar_t **);
639 642 int ns_name_uncompress(const uchar_t *, const uchar_t *,
640 643 const uchar_t *, char *, size_t);
641 644 int ns_name_compress(const char *, uchar_t *, size_t,
642 645 const uchar_t **, const uchar_t **);
643 646 int ns_name_skip(const uchar_t **, const uchar_t *);
644 647 void ns_name_rollback(const uchar_t *, const uchar_t **,
645 648 const uchar_t **);
646 649 ssize_t ns_name_length(ns_nname_ct, size_t);
647 650 int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
648 651 int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
649 652 int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
650 653 int ns_name_labels(ns_nname_ct, size_t);
651 654 int ns_sign(uchar_t *, int *, int, int, void *,
652 655 const uchar_t *, int, uchar_t *, int *, time_t);
653 656 int ns_sign2(uchar_t *, int *, int, int, void *,
654 657 const uchar_t *, int, uchar_t *, int *, time_t,
655 658 uchar_t **, uchar_t **);
656 659 int ns_sign_tcp(uchar_t *, int *, int, int,
657 660 ns_tcp_tsig_state *, int);
658 661 int ns_sign_tcp2(uchar_t *, int *, int, int,
659 662 ns_tcp_tsig_state *, int,
660 663 uchar_t **, uchar_t **);
661 664 int ns_sign_tcp_init(void *, const uchar_t *, int,
662 665 ns_tcp_tsig_state *);
663 666 uchar_t *ns_find_tsig(uchar_t *, uchar_t *);
664 667 int ns_verify(uchar_t *, int *, void *,
665 668 const uchar_t *, int, uchar_t *, int *,
666 669 time_t *, int);
667 670 int ns_verify_tcp(uchar_t *, int *, ns_tcp_tsig_state *, int);
668 671 int ns_verify_tcp_init(void *, const uchar_t *, int,
669 672 ns_tcp_tsig_state *);
670 673 int ns_samedomain(const char *, const char *);
671 674 int ns_subdomain(const char *, const char *);
672 675 int ns_makecanon(const char *, char *, size_t);
673 676 int ns_samename(const char *, const char *);
674 677 int ns_newmsg_init(uchar_t *buffer, size_t bufsiz, ns_newmsg *);
675 678 int ns_newmsg_copy(ns_newmsg *, ns_msg *);
676 679 void ns_newmsg_id(ns_newmsg *handle, uint16_t id);
677 680 void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, uint_t value);
678 681 int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
679 682 ns_type qtype, ns_class qclass);
680 683 int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
681 684 ns_nname_ct name, ns_type type,
682 685 ns_class rr_class, uint32_t ttl,
683 686 uint16_t rdlen, const uchar_t *rdata);
684 687 size_t ns_newmsg_done(ns_newmsg *handle);
685 688 ssize_t ns_rdata_unpack(const uchar_t *, const uchar_t *, ns_type,
686 689 const uchar_t *, size_t, uchar_t *, size_t);
687 690 int ns_rdata_equal(ns_type, const uchar_t *, size_t,
688 691 const uchar_t *, size_t);
689 692 int ns_rdata_refers(ns_type,
690 693 const uchar_t *, size_t,
691 694 const uchar_t *);
692 695
693 696 #ifdef BIND_4_COMPAT
694 697 #include <arpa/nameser_compat.h>
695 698 #endif
696 699
697 700 #ifdef __cplusplus
698 701 }
699 702 #endif
700 703
701 704 #endif /* !_ARPA_NAMESER_H */
|
↓ open down ↓ |
57 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX