message.h 32 KB
Newer Older
1
/*
Brian Wellington's avatar
Brian Wellington committed
2
 * Copyright (C) 1999-2001  Internet Software Consortium.
3
 *
4 5 6
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
7
 *
8 9 10 11 12 13 14 15
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 17
 */

Brian Wellington's avatar
Brian Wellington committed
18
/* $Id: message.h,v 1.94 2001/02/23 01:52:18 bwelling Exp $ */
David Lawrence's avatar
David Lawrence committed
19

20 21
#ifndef DNS_MESSAGE_H
#define DNS_MESSAGE_H 1
22 23 24 25 26

/***
 ***	Imports
 ***/

27 28
#include <isc/lang.h>
#include <isc/magic.h>
29

Michael Graff's avatar
Michael Graff committed
30
#include <dns/compress.h>
31
#include <dns/types.h>
32

33 34
#include <dst/dst.h>

35 36 37
/*
 * How this beast works:
 *
38
 * When a dns message is received in a buffer, dns_message_fromwire() is called
39 40 41 42 43
 * on the memory region.  Various items are checked including the format
 * of the message (if counts are right, if counts consume the entire sections,
 * and if sections consume the entire message) and known pseudo-RRs in the
 * additional data section are analyzed and removed.
 *
Brian Wellington's avatar
Brian Wellington committed
44 45
 * TSIG checking is also done at this layer, and any DNSSEC transaction
 * signatures should also be checked here.
46 47 48 49
 *
 * Notes on using the gettemp*() and puttemp*() functions:
 *
 * These functions return items (names, rdatasets, etc) allocated from some
50 51 52 53
 * internal state of the dns_message_t.
 *
 * Names and rdatasets must be put back into the dns_message_t in
 * one of two ways.  Assume a name was allocated via
54 55 56 57 58 59
 * dns_message_gettempname():
 *
 *	(1) insert it into a section, using dns_message_addname().
 *
 *	(2) return it to the message using dns_message_puttempname().
 *
60 61
 * The same applies to rdatasets.
 *
62
 * On the other hand, offsets, rdatalists and rdatas allocated using
63 64
 * dns_message_gettemp*() will always be freed automatically
 * when the message is reset or destroyed; calling dns_message_puttemp*()
65 66 67
 * on rdatalists and rdatas is optional and serves only to enable the item
 * to be reused multiple times during the lifetime of the message; offsets
 * cannot be reused.
68 69 70 71 72 73 74 75
 *
 * Buffers allocated using isc_buffer_allocate() can be automatically freed
 * as well by giving the buffer to the message using dns_message_takebuffer().
 * Doing this will cause the buffer to be freed using isc_buffer_free()
 * when the section lists are cleared, such as in a reset or in a destroy.
 * Since the buffer itself exists until the message is destroyed, this sort
 * of code can be written:
 *
76
 *	buffer = isc_buffer_allocate(mctx, 512);
77 78 79 80 81 82 83 84 85 86
 *	name = NULL;
 *	name = dns_message_gettempname(message, &name);
 *	dns_name_init(name, NULL);
 *	result = dns_name_fromtext(name, &source, dns_rootname, ISC_FALSE,
 *				   buffer);
 *	dns_message_takebuffer(message, &buffer);
 *
 *
 * TODO:
 *
Brian Wellington's avatar
Brian Wellington committed
87 88
 * XXX Needed:  ways to set and retrieve EDNS information, add rdata to a
 * section, move rdata from one section to another, remove rdata, etc.
89 90
 */

91 92 93 94 95
#define DNS_MESSAGEFLAG_QR		0x8000U
#define DNS_MESSAGEFLAG_AA		0x0400U
#define DNS_MESSAGEFLAG_TC		0x0200U
#define DNS_MESSAGEFLAG_RD		0x0100U
#define DNS_MESSAGEFLAG_RA		0x0080U
Bob Halley's avatar
Bob Halley committed
96 97
#define DNS_MESSAGEFLAG_AD		0x0020U
#define DNS_MESSAGEFLAG_CD		0x0010U
98

99 100
#define DNS_MESSAGEEXTFLAG_DO		0x8000U

Bob Halley's avatar
Bob Halley committed
101
#define DNS_MESSAGE_REPLYPRESERVE	(DNS_MESSAGEFLAG_RD)
102

Bob Halley's avatar
Bob Halley committed
103 104 105
#define DNS_MESSAGE_HEADERLEN		12 /* 6 isc_uint16_t's */

#define DNS_MESSAGE_MAGIC		0x4d534740U	/* MSG@ */
Michael Graff's avatar
Michael Graff committed
106
#define DNS_MESSAGE_VALID(msg)		ISC_MAGIC_VALID(msg, DNS_MESSAGE_MAGIC)
Michael Graff's avatar
Michael Graff committed
107

Michael Graff's avatar
Michael Graff committed
108 109 110 111
/*
 * Ordering here matters.  DNS_SECTION_ANY must be the lowest and negative,
 * and DNS_SECTION_MAX must be one greater than the last used section.
 */
Michael Graff's avatar
Michael Graff committed
112
typedef int dns_section_t;
Michael Graff's avatar
Michael Graff committed
113
#define DNS_SECTION_ANY			(-1)
Michael Graff's avatar
Michael Graff committed
114 115 116 117
#define DNS_SECTION_QUESTION		0
#define DNS_SECTION_ANSWER		1
#define DNS_SECTION_AUTHORITY		2
#define DNS_SECTION_ADDITIONAL		3
118
#define DNS_SECTION_MAX			4
119

120 121 122 123 124 125 126
typedef int dns_pseudosection_t;
#define DNS_PSEUDOSECTION_ANY		(-1)
#define DNS_PSEUDOSECTION_OPT           0
#define DNS_PSEUDOSECTION_TSIG          1
#define DNS_PSEUDOSECTION_SIG0          2
#define DNS_PSEUDOSECTION_MAX           3

127 128 129 130
typedef int dns_messagetextflag_t;
#define DNS_MESSAGETEXTFLAG_NOCOMMENTS	0x0001
#define DNS_MESSAGETEXTFLAG_NOHEADERS	0x0002
#define DNS_MESSAGETEXTFLAG_OMITDOT	0x0004
131

132
/*
Andreas Gustafsson's avatar
Andreas Gustafsson committed
133
 * Dynamic update names for these sections.
134 135 136 137
 */
#define DNS_SECTION_ZONE		DNS_SECTION_QUESTION
#define DNS_SECTION_PREREQUISITE	DNS_SECTION_ANSWER
#define DNS_SECTION_UPDATE		DNS_SECTION_AUTHORITY
Michael Graff's avatar
Michael Graff committed
138 139

/*
Michael Graff's avatar
Michael Graff committed
140
 * These tell the message library how the created dns_message_t will be used.
Michael Graff's avatar
Michael Graff committed
141
 */
Michael Graff's avatar
Michael Graff committed
142 143 144
#define DNS_MESSAGE_INTENTUNKNOWN	0 /* internal use only */
#define DNS_MESSAGE_INTENTPARSE		1 /* parsing messages */
#define DNS_MESSAGE_INTENTRENDER	2 /* rendering */
Michael Graff's avatar
Michael Graff committed
145

146 147 148 149 150 151 152
/*
 * Control behavior of parsing
 */
#define DNS_MESSAGEPARSE_PRESERVEORDER	0x0001	/* preserve rdata order */
#define DNS_MESSAGEPARSE_BESTEFFORT	0x0002	/* return a message if a
						   recoverable parse error
						   occurs */
153 154
#define DNS_MESSAGEPARSE_CLONEBUFFER	0x0004	/* save a copy of the
						   source buffer */
155

Michael Graff's avatar
Michael Graff committed
156 157 158 159 160
/*
 * Control behavior of rendering
 */
#define DNS_MESSAGERENDER_ORDERED	0x0001	/* don't change order */

Michael Graff's avatar
Michael Graff committed
161 162
typedef struct dns_msgblock dns_msgblock_t;

Bob Halley's avatar
Bob Halley committed
163
struct dns_message {
Michael Graff's avatar
Michael Graff committed
164
	/* public from here down */
Michael Graff's avatar
Michael Graff committed
165
	unsigned int			magic;
166

167
	dns_messageid_t			id;
Michael Graff's avatar
Michael Graff committed
168
	unsigned int			flags;
169
	dns_rcode_t			rcode;
Michael Graff's avatar
Michael Graff committed
170
	unsigned int			opcode;
Michael Graff's avatar
Michael Graff committed
171
	dns_rdataclass_t		rdclass;
Michael Graff's avatar
Michael Graff committed
172

173
	/* 4 real, 1 pseudo */
Michael Graff's avatar
Michael Graff committed
174
	unsigned int			counts[DNS_SECTION_MAX];
Michael Graff's avatar
Michael Graff committed
175 176

	/* private from here down */
Michael Graff's avatar
Michael Graff committed
177 178
	dns_namelist_t			sections[DNS_SECTION_MAX];
	dns_name_t		       *cursors[DNS_SECTION_MAX];
Bob Halley's avatar
Bob Halley committed
179
	dns_rdataset_t		       *opt;
180
	dns_rdataset_t		       *sig0;
181
	dns_rdataset_t		       *tsig;
182

Michael Graff's avatar
Michael Graff committed
183
	int				state;
Michael Graff's avatar
Michael Graff committed
184
	unsigned int			from_to_wire : 2;
185
	unsigned int			need_cctx_cleanup : 1;
Bob Halley's avatar
Bob Halley committed
186 187
	unsigned int			header_ok : 1;
	unsigned int			question_ok : 1;
188
	unsigned int			tcp_continuation : 1;
189 190
	unsigned int			verified_sig : 1;
	unsigned int			verify_attempted : 1;
191 192
	unsigned int			free_query : 1;
	unsigned int			free_saved : 1;
193

194
	unsigned int			opt_reserved;
195
	unsigned int			sig_reserved;
196
	unsigned int			reserved; /* reserved space (render) */
197

198
	isc_buffer_t		       *buffer;
Michael Graff's avatar
Michael Graff committed
199
	dns_compress_t			cctx;
200

Michael Graff's avatar
Michael Graff committed
201
	isc_mem_t		       *mctx;
202 203 204
	isc_mempool_t		       *namepool;
	isc_mempool_t		       *rdspool;

205
	isc_bufferlist_t		scratchpad;
206 207
	isc_bufferlist_t		cleanup;

Michael Graff's avatar
Michael Graff committed
208 209
	ISC_LIST(dns_msgblock_t)	rdatas;
	ISC_LIST(dns_msgblock_t)	rdatalists;
210
	ISC_LIST(dns_msgblock_t)	offsets;
211 212 213

	ISC_LIST(dns_rdata_t)		freerdata;
	ISC_LIST(dns_rdatalist_t)	freerdatalist;
214 215 216

	dns_rcode_t			tsigstatus;
	dns_rcode_t			querytsigstatus;
217
	dns_name_t		       *tsigname;
218
	dns_rdataset_t		       *querytsig;
219
	dns_tsigkey_t		       *tsigkey;
Brian Wellington's avatar
Brian Wellington committed
220
	dst_context_t		       *tsigctx;
221
	int				sigstart;
222
	int				timeadjust;
223

224
	dns_name_t		       *sig0name;
225 226
	dst_key_t		       *sig0key;
	dns_rcode_t			sig0status;
227 228
	isc_region_t			query;
	isc_region_t			saved;
229 230 231

	dns_rdatasetorderfunc_t		order;
	void *				order_arg;
Bob Halley's avatar
Bob Halley committed
232
};
233

234 235 236 237 238 239
/***
 *** Functions
 ***/

ISC_LANG_BEGINDECLS

240
isc_result_t
241
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp);
242

243
/*
Michael Graff's avatar
Michael Graff committed
244
 * Create msg structure.
245
 *
Michael Graff's avatar
Michael Graff committed
246
 * This function will allocate some internal blocks of memory that are
Michael Graff's avatar
Michael Graff committed
247
 * expected to be needed for parsing or rendering nearly any type of message.
Michael Graff's avatar
Michael Graff committed
248 249 250
 *
 * Requires:
 *	'mctx' be a valid memory context.
251
 *
Michael Graff's avatar
Michael Graff committed
252
 *	'msgp' be non-null and '*msg' be NULL.
Michael Graff's avatar
Michael Graff committed
253
 *
Andreas Gustafsson's avatar
typo  
Andreas Gustafsson committed
254 255
 *	'intent' must be one of DNS_MESSAGE_INTENTPARSE or
 *	DNS_MESSAGE_INTENTRENDER.
Michael Graff's avatar
Michael Graff committed
256 257
 *
 * Ensures:
Michael Graff's avatar
Michael Graff committed
258
 *	The data in "*msg" is set to indicate an unused and empty msg
Michael Graff's avatar
Michael Graff committed
259 260 261
 *	structure.
 *
 * Returns:
262 263
 *	ISC_R_NOMEMORY		-- out of memory
 *	ISC_R_SUCCESS		-- success
264 265
 */

Michael Graff's avatar
Michael Graff committed
266
void
Bob Halley's avatar
Bob Halley committed
267
dns_message_reset(dns_message_t *msg, unsigned int intent);
Michael Graff's avatar
Michael Graff committed
268 269 270 271 272 273
/*
 * Reset a message structure to default state.  All internal lists are freed
 * or reset to a default state as well.  This is simply a more efficient
 * way to call dns_message_destroy() followed by dns_message_allocate(),
 * since it avoid many memory allocations.
 *
Michael Graff's avatar
Michael Graff committed
274 275 276
 * If any data loanouts (buffers, names, rdatas, etc) were requested,
 * the caller must no longer use them after this call.
 *
Bob Halley's avatar
Bob Halley committed
277 278
 * The intended next use of the message will be 'intent'.
 *
Michael Graff's avatar
Michael Graff committed
279 280 281
 * Requires:
 *
 *	'msg' be valid.
Bob Halley's avatar
Bob Halley committed
282 283
 *
 *	'intent' is DNS_MESSAGE_INTENTPARSE or DNS_MESSAGE_INTENTRENDER
Michael Graff's avatar
Michael Graff committed
284
 */
Michael Graff's avatar
Michael Graff committed
285

Michael Graff's avatar
Michael Graff committed
286
void
Michael Graff's avatar
Michael Graff committed
287
dns_message_destroy(dns_message_t **msgp);
Michael Graff's avatar
Michael Graff committed
288
/*
Michael Graff's avatar
Michael Graff committed
289 290 291 292
 * Destroy all state in the message.
 *
 * Requires:
 *
Michael Graff's avatar
Michael Graff committed
293
 *	'msgp' be valid.
Michael Graff's avatar
Michael Graff committed
294 295
 *
 * Ensures:
Michael Graff's avatar
Michael Graff committed
296
 *	'*msgp' == NULL
Michael Graff's avatar
Michael Graff committed
297 298
 */

299 300
isc_result_t
dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
301
			  dns_messagetextflag_t flags,
302
			  isc_buffer_t *target);
303 304 305 306

isc_result_t
dns_message_pseudosectiontotext(dns_message_t *msg,
				dns_pseudosection_t section,
307
				dns_messagetextflag_t flags,
308
				isc_buffer_t *target);
309
/*
310
 * Convert section 'section' or 'pseudosection' of message 'msg' to
311
 * a cleartext representation
312 313
 *
 * Notes:
314
 *      See dns_message_totext for meanings of flags.
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
 *
 * Requires:
 *
 *	'msg' is a valid message.
 *
 *	'target' is a valid buffer.
 *
 *	'section' is a valid section label.
 *
 * Ensures:
 *
 *	If the result is success:
 *
 *		The used space in 'target' is updated.
 *
 * Returns:
 *
 *	ISC_R_SUCCESS
 *	ISC_R_NOSPACE
 *	ISC_R_NOMORE
 *
336
 *	Note: On error return, *target may be partially filled with data.
337 338 339
*/

isc_result_t
340
dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
341 342 343 344 345
		   isc_buffer_t *target);
/*
 * Convert all sections of message 'msg' to a cleartext representation
 *
 * Notes:
346
 *      In flags, If DNS_MESSAGETEXTFLAG_OMITDOT is set, then the
347
 *      final '.' in absolute names will not be emitted.  If
348
 *      DNS_MESSAGETEXTFLAG_NOCOMMENTS is cleared, lines beginning
349 350
 *      with ";;" will be emitted indicating section name.  If
 *      DNS_MESSAGETEXTFLAG_NOHEADERS is cleared, header lines will
351
 *      be emitted.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
 *
 * Requires:
 *
 *	'msg' is a valid message.
 *
 *	'target' is a valid buffer.
 *
 * Ensures:
 *
 *	If the result is success:
 *
 *		The used space in 'target' is updated.
 *
 * Returns:
 *
 *	ISC_R_SUCCESS
 *	ISC_R_NOSPACE
 *	ISC_R_NOMORE
 *
371 372
 *	Note: On error return, *target may be partially filled with data.
 */
373

374
isc_result_t
375
dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
376
		  unsigned int options);
Michael Graff's avatar
Michael Graff committed
377
/*
Michael Graff's avatar
Michael Graff committed
378 379 380 381
 * Parse raw wire data pointed to by "buffer" and bounded by "buflen" as a
 * DNS message.
 *
 * OPT records are detected and stored in the pseudo-section "opt".
Brian Wellington's avatar
Brian Wellington committed
382
 * TSIGs are detected and stored in the pseudo-section "tsig".
Michael Graff's avatar
Michael Graff committed
383
 *
384 385 386
 * If DNS_MESSAGEPARSE_PRESERVEORDER is set, or if the opcode of the message
 * is UPDATE, a separate dns_name_t object will be created for each RR in the
 * message.  Each such dns_name_t will have a single rdataset containing the
Brian Wellington's avatar
Brian Wellington committed
387
 * single RR, and the order of the RRs in the message is preserved.
388 389
 * Otherwise, only one dns_name_t object will be created for each unique
 * owner name in the section, and each such dns_name_t will have a list
390 391
 * of rdatasets.  To access the names and their data, use
 * dns_message_firstname() and dns_message_nextname().
392
 *
393 394 395 396
 * If DNS_MESSAGEPARSE_BESTEFFORT is set, errors in message content will
 * not be considered FORMERRs.  If the entire message can be parsed, it
 * will be returned and DNS_R_RECOVERABLE will be returned.
 *
397 398 399
 * OPT and TSIG records are always handled specially, regardless of the
 * 'preserve_order' setting.
 *
Michael Graff's avatar
Michael Graff committed
400 401 402
 * Requires:
 *	"msg" be valid.
 *
403
 *	"buffer" be a wire format buffer.
Michael Graff's avatar
Michael Graff committed
404 405 406 407
 *
 * Ensures:
 *	The buffer's data format is correct.
 *
Michael Graff's avatar
Michael Graff committed
408 409
 *	The buffer's contents verify as correct regarding header bits, buffer
 * 	and rdata sizes, etc.
Michael Graff's avatar
Michael Graff committed
410 411
 *
 * Returns:
412 413
 *	ISC_R_SUCCESS		-- all is well
 *	ISC_R_NOMEMORY		-- no memory
414 415
 *	DNS_R_RECOVERABLE	-- the message parsed properly, but contained
 *				   errors.
Michael Graff's avatar
Michael Graff committed
416
 *	Many other errors possible XXXMLG
Michael Graff's avatar
Michael Graff committed
417 418
 */

419
isc_result_t
Michael Graff's avatar
Michael Graff committed
420
dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer);
Michael Graff's avatar
Michael Graff committed
421
/*
Michael Graff's avatar
Michael Graff committed
422 423
 * Begin rendering on a message.  Only one call can be made to this function
 * per message.
Michael Graff's avatar
Michael Graff committed
424
 *
Andreas Gustafsson's avatar
Andreas Gustafsson committed
425
 * The buffer is "owned" by the message library until dns_message_renderend()
Michael Graff's avatar
Michael Graff committed
426 427
 * is called.
 *
Michael Graff's avatar
Michael Graff committed
428
 * Requires:
Michael Graff's avatar
Michael Graff committed
429 430
 *
 *	'msg' be valid.
431
 *
432
 *	'buffer' is a valid buffer.
Michael Graff's avatar
Michael Graff committed
433 434 435 436
 *
 * Side Effects:
 *
 *	The buffer is cleared before it is used.
437
 *
Michael Graff's avatar
Michael Graff committed
438
 * Returns:
439 440
 *	ISC_R_SUCCESS		-- all is well
 *	ISC_R_NOSPACE		-- output buffer is too small
Michael Graff's avatar
Michael Graff committed
441
 *	Anything that dns_compress_init() can return.
Michael Graff's avatar
Michael Graff committed
442 443
 */

444
isc_result_t
445 446 447
dns_message_renderchangebuffer(dns_message_t *msg, isc_buffer_t *buffer);
/*
 * Reset the buffer.  This can be used after growing the old buffer
448
 * on a ISC_R_NOSPACE return from most of the render functions.
449
 *
Michael Graff's avatar
Michael Graff committed
450 451 452 453
 * On successful completion, the old buffer is no longer used by the
 * library.  The new buffer is owned by the library until
 * dns_message_renderend() is called.
 *
454 455 456 457 458 459 460 461 462
 * Requires:
 *
 *	'msg' be valid.
 *
 *	dns_message_renderbegin() was called.
 *
 *	buffer != NULL.
 *
 * Returns:
463 464
 *	ISC_R_NOSPACE		-- new buffer is too small
 *	ISC_R_SUCCESS		-- all is well.
465 466
 */

467
isc_result_t
468
dns_message_renderreserve(dns_message_t *msg, unsigned int space);
Michael Graff's avatar
Michael Graff committed
469
/*
Michael Graff's avatar
Michael Graff committed
470 471 472
 * XXXMLG should use size_t rather than unsigned int once the buffer
 * API is cleaned up
 *
Michael Graff's avatar
Michael Graff committed
473 474 475 476 477
 * Reserve "space" bytes in the given buffer.
 *
 * Requires:
 *
 *	'msg' be valid.
Michael Graff's avatar
Michael Graff committed
478
 *
479 480
 *	dns_message_renderbegin() was called.
 *
Michael Graff's avatar
Michael Graff committed
481
 * Returns:
482 483
 *	ISC_R_SUCCESS		-- all is well.
 *	ISC_R_NOSPACE		-- not enough free space in the buffer.
Michael Graff's avatar
Michael Graff committed
484 485
 */

486
void
Michael Graff's avatar
Michael Graff committed
487 488
dns_message_renderrelease(dns_message_t *msg, unsigned int space);
/*
Michael Graff's avatar
Michael Graff committed
489 490 491
 * XXXMLG should use size_t rather than unsigned int once the buffer
 * API is cleaned up
 *
Michael Graff's avatar
Michael Graff committed
492 493 494 495 496 497
 * Release "space" bytes in the given buffer that was previously reserved.
 *
 * Requires:
 *
 *	'msg' be valid.
 *
498 499
 *	'space' is less than or equal to the total amount of space reserved
 *	via prior calls to dns_message_renderreserve().
500
 *
501
 *	dns_message_renderbegin() was called.
Michael Graff's avatar
Michael Graff committed
502 503
 */

504
isc_result_t
505
dns_message_rendersection(dns_message_t *msg, dns_section_t section,
Michael Graff's avatar
Michael Graff committed
506
			  unsigned int options);
Michael Graff's avatar
Michael Graff committed
507
/*
Michael Graff's avatar
Michael Graff committed
508 509
 * Render all names, rdatalists, etc from the given section at the
 * specified priority or higher.
Michael Graff's avatar
Michael Graff committed
510 511
 *
 * Requires:
Michael Graff's avatar
Michael Graff committed
512 513 514
 *	'msg' be valid.
 *
 *	'section' be a valid section.
Michael Graff's avatar
Michael Graff committed
515
 *
516 517
 *	dns_message_renderbegin() was called.
 *
Michael Graff's avatar
Michael Graff committed
518
 * Returns:
519
 *	ISC_R_SUCCESS		-- all records were written, and there are
Michael Graff's avatar
Michael Graff committed
520
 *				   no more records for this section.
521
 *	ISC_R_NOSPACE		-- Not enough room in the buffer to write
Michael Graff's avatar
Michael Graff committed
522 523 524
 *				   all records requested.
 *	DNS_R_MOREDATA		-- All requested records written, and there
 *				   are records remaining for this section.
Michael Graff's avatar
Michael Graff committed
525 526
 */

527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
void
dns_message_renderheader(dns_message_t *msg, isc_buffer_t *target);
/*
 * Render the message header.  This is implicitly called by
 * dns_message_renderend().
 *
 * Requires:
 *
 *	'msg' be a valid message.
 *
 *	dns_message_renderbegin() was called.
 *
 *	'target' is a valid buffer with enough space to hold a message header
 */

542
isc_result_t
543
dns_message_renderend(dns_message_t *msg);
Michael Graff's avatar
Michael Graff committed
544
/*
Michael Graff's avatar
Michael Graff committed
545 546 547 548 549 550 551 552
 * Finish rendering to the buffer.  Note that more data can be in the
 * 'msg' structure.  Destroying the structure will free this, or in a multi-
 * part EDNS1 message this data can be rendered to another buffer later.
 *
 * Requires:
 *
 *	'msg' be a valid message.
 *
553 554
 *	dns_message_renderbegin() was called.
 *
Michael Graff's avatar
Michael Graff committed
555
 * Returns:
556
 *	ISC_R_SUCCESS		-- all is well.
Michael Graff's avatar
Michael Graff committed
557
 */
558

Bob Halley's avatar
Bob Halley committed
559 560 561 562 563 564 565 566 567 568 569 570 571 572
void
dns_message_renderreset(dns_message_t *msg);
/*
 * Reset the message so that it may be rendered again.
 *
 * Notes:
 *
 *	If dns_message_renderbegin() has been called, dns_message_renderend()
 *	must be called before calling this function.
 *
 * Requires:
 *
 *	'msg' be a valid message with rendering intent.
 */
Michael Graff's avatar
Michael Graff committed
573

574
isc_result_t
Michael Graff's avatar
Michael Graff committed
575 576 577 578
dns_message_firstname(dns_message_t *msg, dns_section_t section);
/*
 * Set internal per-section name pointer to the beginning of the section.
 *
Michael Graff's avatar
Michael Graff committed
579
 * The functions dns_message_firstname() and dns_message_nextname() may
580
 * be used for iterating over the owner names in a section.
Michael Graff's avatar
Michael Graff committed
581
 *
Michael Graff's avatar
Michael Graff committed
582 583 584 585 586 587 588
 * Requires:
 *
 *   	'msg' be valid.
 *
 *	'section' be a valid section.
 *
 * Returns:
589 590
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMORE		-- No names on given section.
Michael Graff's avatar
Michael Graff committed
591 592
 */

593
isc_result_t
Michael Graff's avatar
Michael Graff committed
594 595 596 597 598 599 600 601 602 603 604
dns_message_nextname(dns_message_t *msg, dns_section_t section);
/*
 * Sets the internal per-section name pointer to point to the next name
 * in that section.
 *
 * Requires:
 *
 *   	'msg' be valid.
 *
 *	'section' be a valid section.
 *
Michael Graff's avatar
Michael Graff committed
605
 *	dns_message_firstname() must have been called on this section,
606
 *	and the result was ISC_R_SUCCESS.
Michael Graff's avatar
Michael Graff committed
607
 *
Michael Graff's avatar
Michael Graff committed
608
 * Returns:
609 610
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMORE		-- No names in given section.
Michael Graff's avatar
Michael Graff committed
611 612
 */

Michael Graff's avatar
Michael Graff committed
613
void
Michael Graff's avatar
Michael Graff committed
614 615 616 617 618 619
dns_message_currentname(dns_message_t *msg, dns_section_t section,
			dns_name_t **name);
/*
 * Sets 'name' to point to the name where the per-section internal name
 * pointer is currently set.
 *
Michael Graff's avatar
Michael Graff committed
620 621 622
 * This function returns the name in the database, so any data associated
 * with it (via the name's "list" member) contains the actual rdatasets.
 *
Michael Graff's avatar
Michael Graff committed
623 624 625 626 627 628 629 630
 * Requires:
 *
 *	'msg' be valid.
 *
 *	'name' be non-NULL, and *name be NULL.
 *
 *	'section' be a valid section.
 *
Michael Graff's avatar
Michael Graff committed
631 632
 *	dns_message_firstname() must have been called on this section,
 *	and the result of it and any dns_message_nextname() calls was
633
 *	ISC_R_SUCCESS.
Michael Graff's avatar
Michael Graff committed
634 635
 */

636
isc_result_t
Michael Graff's avatar
Michael Graff committed
637 638
dns_message_findname(dns_message_t *msg, dns_section_t section,
		     dns_name_t *target, dns_rdatatype_t type,
Bob Halley's avatar
Bob Halley committed
639 640
		     dns_rdatatype_t covers, dns_name_t **foundname,
		     dns_rdataset_t **rdataset);
Michael Graff's avatar
Michael Graff committed
641
/*
Michael Graff's avatar
Michael Graff committed
642 643
 * Search for a name in the specified section.  If it is found, *name is
 * set to point to the name, and *rdataset is set to point to the found
Bob Halley's avatar
Bob Halley committed
644
 * rdataset (if type is specified as other than dns_rdatatype_any).
Michael Graff's avatar
Michael Graff committed
645 646 647 648 649 650
 *
 * Requires:
 *	'msg' be valid.
 *
 *	'section' be a valid section.
 *
Michael Graff's avatar
Michael Graff committed
651 652
 *	If a pointer to the name is desired, 'foundname' should be non-NULL.
 *	If it is non-NULL, '*foundname' MUST be NULL.
Michael Graff's avatar
Michael Graff committed
653 654 655
 *
 *	If a type other than dns_datatype_any is searched for, 'rdataset'
 *	may be non-NULL, '*rdataset' be NULL, and will point at the found
Michael Graff's avatar
Michael Graff committed
656
 *	rdataset.  If the type is dns_datatype_any, 'rdataset' must be NULL.
Michael Graff's avatar
Michael Graff committed
657 658 659 660 661
 *
 *	'target' be a valid name.
 *
 *	'type' be a valid type.
 *
662 663 664
 *	If 'type' is dns_rdatatype_sig, 'covers' must be a valid type.
 *	Otherwise it should be 0.
 *
Michael Graff's avatar
Michael Graff committed
665
 * Returns:
666
 *	ISC_R_SUCCESS		-- all is well.
Michael Graff's avatar
Michael Graff committed
667
 *	DNS_R_NXDOMAIN		-- name does not exist in that section.
668
 *	DNS_R_NXRRSET		-- The name does exist, but the desired
Michael Graff's avatar
Michael Graff committed
669
 *				   type does not.
Michael Graff's avatar
Michael Graff committed
670 671
 */

672
isc_result_t
673 674 675 676 677 678 679 680 681 682 683
dns_message_findtype(dns_name_t *name, dns_rdatatype_t type,
		     dns_rdatatype_t covers, dns_rdataset_t **rdataset);
/*
 * Search the name for the specified type.  If it is found, *rdataset is
 * filled in with a pointer to that rdataset.
 *
 * Requires:
 *	if '**rdataset' is non-NULL, *rdataset needs to be NULL.
 *
 *	'type' be a valid type, and NOT dns_rdatatype_any.
 *
684 685 686
 *	If 'type' is dns_rdatatype_sig, 'covers' must be a valid type.
 *	Otherwise it should be 0.
 *
687
 * Returns:
688 689
 *	ISC_R_SUCCESS		-- all is well.
 *	ISC_R_NOTFOUND		-- the desired type does not exist.
690 691
 */

Michael Graff's avatar
Michael Graff committed
692 693 694 695
void
dns_message_movename(dns_message_t *msg, dns_name_t *name,
		     dns_section_t fromsection,
		     dns_section_t tosection);
Michael Graff's avatar
Michael Graff committed
696 697
/*
 * Move a name from one section to another.
Michael Graff's avatar
Michael Graff committed
698 699 700 701 702
 *
 * Requires:
 *
 *	'msg' be valid.
 *
Michael Graff's avatar
Michael Graff committed
703
 *	'name' must be a name already in 'fromsection'.
Michael Graff's avatar
Michael Graff committed
704 705 706
 *
 *	'fromsection' must be a valid section.
 *
Michael Graff's avatar
Michael Graff committed
707
 *	'tosection' must be a valid section.
Michael Graff's avatar
Michael Graff committed
708 709
 */

Michael Graff's avatar
Michael Graff committed
710 711 712
void
dns_message_addname(dns_message_t *msg, dns_name_t *name,
		    dns_section_t section);
Michael Graff's avatar
Michael Graff committed
713 714 715
/*
 * Adds the name to the given section.
 *
Michael Graff's avatar
Michael Graff committed
716 717
 * It is the caller's responsibility to enforce any unique name requirements
 * in a section.
Michael Graff's avatar
Michael Graff committed
718 719 720 721 722 723 724 725
 *
 * Requires:
 *
 *	'msg' be valid, and be a renderable message.
 *
 *	'name' be a valid name.
 *
 *	'section' be a named section.
Michael Graff's avatar
Michael Graff committed
726
 */
727

728 729 730 731 732 733 734 735
/*
 * LOANOUT FUNCTIONS
 *
 * Each of these functions loan a particular type of data to the caller.
 * The storage for these will vanish when the message is destroyed or
 * reset, and must NOT be used after these operations.
 */

736
isc_result_t
737 738 739
dns_message_gettempname(dns_message_t *msg, dns_name_t **item);
/*
 * Return a name that can be used for any temporary purpose, including
740 741 742
 * inserting into the message's linked lists.  The name must be returned
 * to the message code using dns_message_puttempname() or inserted into
 * one of the message's sections before the message is destroyed.
743 744 745 746 747 748 749 750 751
 *
 * It is the caller's responsibility to initialize this name.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item == NULL
 *
 * Returns:
752 753
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMEMORY		-- No item can be allocated.
754 755
 */

756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
isc_result_t
dns_message_gettempoffsets(dns_message_t *msg, dns_offsets_t **item);
/*
 * Return an offsets array that can be used for any temporary purpose,
 * such as attaching to a temporary name.  The offsets will be freed
 * when the message is destroyed or reset.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item == NULL
 *
 * Returns:
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMEMORY		-- No item can be allocated.
 */

773
isc_result_t
774 775 776
dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item);
/*
 * Return a rdata that can be used for any temporary purpose, including
777 778
 * inserting into the message's linked lists.  The rdata will be freed
 * when the message is destroyed or reset.
779 780 781 782 783 784 785
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item == NULL
 *
 * Returns:
786 787
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMEMORY		-- No item can be allocated.
788 789
 */

790
isc_result_t
791 792 793
dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item);
/*
 * Return a rdataset that can be used for any temporary purpose, including
794 795 796
 * inserting into the message's linked lists. The name must be returned
 * to the message code using dns_message_puttempname() or inserted into
 * one of the message's sections before the message is destroyed.
797 798 799 800 801 802 803
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item == NULL
 *
 * Returns:
804 805
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMEMORY		-- No item can be allocated.
806 807
 */

808
isc_result_t
809 810 811
dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item);
/*
 * Return a rdatalist that can be used for any temporary purpose, including
812 813
 * inserting into the message's linked lists.  The rdatalist will be
 * destroyed when the message is destroyed or reset.
814 815 816 817 818 819 820
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item == NULL
 *
 * Returns:
821 822
 *	ISC_R_SUCCESS		-- All is well.
 *	ISC_R_NOMEMORY		-- No item can be allocated.
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
 */

void
dns_message_puttempname(dns_message_t *msg, dns_name_t **item);
/*
 * Return a borrowed name to the message's name free list.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item point to a name returned by
 *	dns_message_gettempname()
 *
 * Ensures:
 *	*item == NULL
 */

void
dns_message_puttemprdata(dns_message_t *msg, dns_rdata_t **item);
/*
 * Return a borrowed rdata to the message's rdata free list.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item point to a rdata returned by
 *	dns_message_gettemprdata()
 *
 * Ensures:
 *	*item == NULL
 */

void
dns_message_puttemprdataset(dns_message_t *msg, dns_rdataset_t **item);
/*
 * Return a borrowed rdataset to the message's rdataset free list.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item point to a rdataset returned by
 *	dns_message_gettemprdataset()
 *
 * Ensures:
 *	*item == NULL
 */

void
dns_message_puttemprdatalist(dns_message_t *msg, dns_rdatalist_t **item);
/*
 * Return a borrowed rdatalist to the message's rdatalist free list.
 *
 * Requires:
 *	msg be a valid message
 *
 *	item != NULL && *item point to a rdatalist returned by
 *	dns_message_gettemprdatalist()
 *
 * Ensures:
 *	*item == NULL
 */

885
isc_result_t
Michael Graff's avatar
Michael Graff committed
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903
dns_message_peekheader(isc_buffer_t *source, dns_messageid_t *idp,
		       unsigned int *flagsp);
/*
 * Assume the remaining region of "source" is a DNS message.  Peek into
 * it and fill in "*idp" with the message id, and "*flagsp" with the flags.
 *
 * Requires:
 *
 *	source != NULL
 *
 * Ensures:
 *
 *	if (idp != NULL) *idp == message id.
 *
 *	if (flagsp != NULL) *flagsp == message flags.
 *
 * Returns:
 *
904
 *	ISC_R_SUCCESS		-- all is well.
Michael Graff's avatar
Michael Graff committed
905
 *
906
 *	ISC_R_UNEXPECTEDEND	-- buffer doesn't contain enough for a header.
Michael Graff's avatar
Michael Graff committed
907 908
 */

909
isc_result_t
Bob Halley's avatar
Bob Halley committed
910 911 912 913 914 915
dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section);
/*
 * Start formatting a reply to the query in 'msg'.
 *
 * Requires:
 *
Bob Halley's avatar
EDNS0  
Bob Halley committed
916
 *	'msg' is a valid message with parsing intent, and contains a query.
917
 *
Bob Halley's avatar
Bob Halley committed
918 919 920
 * Ensures:
 *
 *	The message will have a rendering intent.  If 'want_question_section'
921 922 923 924 925
 *	is true, the message opcode is query or notify, and the question
 *	section is present and properly formatted, then the question section
 *	will be included in the reply.  All other sections will be cleared.
 *	The QR flag will be set, the RD flag will be preserved, and all other
 *	flags will be cleared.
Bob Halley's avatar
Bob Halley committed
926 927 928
 *
 * Returns:
 *
929
 *	ISC_R_SUCCESS		-- all is well.
Bob Halley's avatar
Bob Halley committed
930
 *
Bob Halley's avatar
Bob Halley committed
931 932 933 934 935 936 937
 *	DNS_R_FORMERR		-- the header or question section of the
 *				   message is invalid, replying is impossible.
 *				   If DNS_R_FORMERR is returned when
 *				   want_question_section is ISC_FALSE, then
 *				   it's the header section that's bad;
 *				   otherwise either of the header or question
 *				   sections may be bad.
Bob Halley's avatar
Bob Halley committed
938 939
 */

Bob Halley's avatar
EDNS0  
Bob Halley committed
940 941 942 943 944 945 946 947 948 949 950 951 952 953
dns_rdataset_t *
dns_message_getopt(dns_message_t *msg);
/*
 * Get the OPT record for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message.
 *
 * Returns:
 *
 *	The OPT rdataset of 'msg', or NULL if there isn't one.
 */

954
isc_result_t
Bob Halley's avatar
EDNS0  
Bob Halley committed
955 956 957 958 959 960 961 962 963 964 965 966 967 968
dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt);
/*
 * Set the OPT record for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message with rendering intent,
 *	dns_message_renderbegin() has been called, and no sections have been
 *	rendered.
 *
 *	'opt' is a valid OPT record.
 *
 * Ensures:
 *
969 970 971 972 973
 *	The OPT record has either been freed or ownership of it has
 *	been transferred to the message.
 *
 *	If ISC_R_SUCCESS was returned, the OPT record will be rendered 
 *	when dns_message_renderend() is called.
Bob Halley's avatar
EDNS0  
Bob Halley committed
974 975 976
 *
 * Returns:
 *
977
 *	ISC_R_SUCCESS		-- all is well.
Bob Halley's avatar
EDNS0  
Bob Halley committed
978
 *
979
 *	ISC_R_NOSPACE		-- there is no space for the OPT record.
Bob Halley's avatar
EDNS0  
Bob Halley committed
980 981
 */

982 983 984 985 986 987 988 989
dns_rdataset_t *
dns_message_gettsig(dns_message_t *msg, dns_name_t **owner);
/*
 * Get the TSIG record and owner for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message.
990
 *	'owner' is NULL or *owner is NULL.
991 992 993 994
 *
 * Returns:
 *
 *	The TSIG rdataset of 'msg', or NULL if there isn't one.
995 996 997 998
 *
 * Ensures:
 *
 * 	If 'owner' is not NULL, it will point to the owner name.
999 1000
 */

1001
isc_result_t
1002 1003 1004 1005 1006 1007 1008 1009
dns_message_settsigkey(dns_message_t *msg, dns_tsigkey_t *key);
/*
 * Set the tsig key for 'msg'.  This is only necessary for when rendering a
 * query or parsing a response.  The key (if non-NULL) is attached to, and
 * will be detached when the message is destroyed.
 *
 * Requires:
 *
1010 1011 1012
 *	'msg' is a valid message with rendering intent,
 *	dns_message_renderbegin() has been called, and no sections have been
 *	rendered.
1013
 *	'key' is a valid tsig key or NULL.
1014 1015 1016 1017 1018 1019
 *
 * Returns:
 *
 *	ISC_R_SUCCESS		-- all is well.
 *
 *	ISC_R_NOSPACE		-- there is no space for the TSIG record.
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
 */

dns_tsigkey_t *
dns_message_gettsigkey(dns_message_t *msg);
/*
 * Gets the tsig key for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message
 */

1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
isc_result_t
dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig);
/*
 * Indicates that 'querytsig' is the TSIG from the signed query for which
 * 'msg' is the response.  This is also used for chained TSIGs in TCP
 * responses.
 *
 * Requires:
 *
 *	'querytsig' is a valid buffer as returned by dns_message_getquerytsig()
 *	or NULL
 *
 *	'msg' is a valid message
 *
 * Returns:
 *
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 */

isc_result_t
dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx,
			 isc_buffer_t **querytsig);
/*
 * Gets the tsig from the TSIG from the signed query 'msg'.  This is also used
 * for chained TSIGs in TCP responses.  Unlike dns_message_gettsig, this makes
 * a copy of the data, so can be used if the message is destroyed.
 *
 * Requires:
 *
 *	'msg' is a valid signed message
 *	'mctx' is a valid memory context
 *	querytsig != NULL && *querytsig == NULL
 *
 * Returns:
 *
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 *
 * Ensures:
 * 	'tsig' points to NULL or an allocated buffer which must be freed
 * 	by the caller.
 */

1076
dns_rdataset_t *
1077
dns_message_getsig0(dns_message_t *msg, dns_name_t **owner);
1078
/*
1079
 * Get the SIG(0) record and owner for 'msg'.
1080 1081 1082 1083
 *
 * Requires:
 *
 *	'msg' is a valid message.
1084
 *	'owner' is NULL or *owner is NULL.
1085 1086 1087 1088
 *
 * Returns:
 *
 *	The SIG(0) rdataset of 'msg', or NULL if there isn't one.
1089 1090 1091 1092
 *
 * Ensures:
 *
 * 	If 'owner' is not NULL, it will point to the owner name.
1093 1094
 */

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
isc_result_t
dns_message_setsig0key(dns_message_t *msg, dst_key_t *key);
/*
 * Set the SIG(0) key for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message with rendering intent,
 *	dns_message_renderbegin() has been called, and no sections have been
 *	rendered.
 *	'key' is a valid sig key or NULL.
 *
 * Returns:
 *
 *	ISC_R_SUCCESS		-- all is well.
 *
 *	ISC_R_NOSPACE		-- there is no space for the SIG(0) record.
 */

dst_key_t *
dns_message_getsig0key(dns_message_t *msg);
/*
 * Gets the SIG(0) key for 'msg'.
 *
 * Requires:
 *
 *	'msg' is a valid message
 */

1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
void
dns_message_takebuffer(dns_message_t *msg, isc_buffer_t **buffer);
/*
 * Give the *buffer to the message code to clean up when it is no
 * longer needed.  This is usually when the message is reset or
 * destroyed.
 *
 * Requires:
 *
 *	msg be a valid message.
 *
 *	buffer != NULL && *buffer is a valid isc_buffer_t, which was
 *	dynamincally allocated via isc_buffer_allocate().
 */

Brian Wellington's avatar
Brian Wellington committed
1139
isc_result_t
1140
dns_message_signer(dns_message_t *msg, dns_name_t *signer);
Brian Wellington's avatar
Brian Wellington committed
1141
/*</