fixedname.h 1.7 KB
Newer Older
Bob Halley's avatar
add  
Bob Halley committed
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4 5 6
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 8 9
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
Bob Halley's avatar
add  
Bob Halley committed
10 11
 */

Automatic Updater's avatar
Automatic Updater committed
12
/* $Id: fixedname.h,v 1.19 2007/06/19 23:47:16 tbox Exp $ */
David Lawrence's avatar
David Lawrence committed
13

Bob Halley's avatar
add  
Bob Halley committed
14 15 16 17 18 19 20
#ifndef DNS_FIXEDNAME_H
#define DNS_FIXEDNAME_H 1

/*****
 ***** Module Info
 *****/

21
/*! \file dns/fixedname.h
22
 * \brief
Bob Halley's avatar
add  
Bob Halley committed
23 24 25 26 27 28
 * Fixed-size Names
 *
 * dns_fixedname_t is a convenience type containing a name, an offsets table,
 * and a dedicated buffer big enough for the longest possible name.
 *
 * MP:
29
 *\li	The caller must ensure any required synchronization.
Bob Halley's avatar
add  
Bob Halley committed
30 31
 *
 * Reliability:
32
 *\li	No anticipated impact.
Bob Halley's avatar
add  
Bob Halley committed
33 34
 *
 * Resources:
35 36
 *\li	Per dns_fixedname_t:
 *\code
Bob Halley's avatar
add  
Bob Halley committed
37 38
 *		sizeof(dns_name_t) + sizeof(dns_offsets_t) +
 *		sizeof(isc_buffer_t) + 255 bytes + structure padding
39
 *\endcode
Bob Halley's avatar
add  
Bob Halley committed
40 41
 *
 * Security:
42
 *\li	No anticipated impact.
Bob Halley's avatar
add  
Bob Halley committed
43 44
 *
 * Standards:
45
 *\li	None.
Bob Halley's avatar
add  
Bob Halley committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59
 */

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

#include <isc/buffer.h>

#include <dns/name.h>

/*****
 ***** Types
 *****/

60 61 62 63
struct dns_fixedname {
	dns_name_t			name;
	dns_offsets_t			offsets;
	isc_buffer_t			buffer;
64
	unsigned char			data[DNS_NAME_MAXWIRE];
65
};
Bob Halley's avatar
add  
Bob Halley committed
66 67 68 69

#define dns_fixedname_init(fn) \
	do { \
		dns_name_init(&((fn)->name), (fn)->offsets); \
70
		isc_buffer_init(&((fn)->buffer), (fn)->data, \
71
				  DNS_NAME_MAXWIRE); \
Bob Halley's avatar
add  
Bob Halley committed
72 73 74 75 76 77
		dns_name_setbuffer(&((fn)->name), &((fn)->buffer)); \
	} while (0)

#define dns_fixedname_invalidate(fn) \
	dns_name_invalidate(&((fn)->name))

78 79
#define dns_fixedname_name(fn)		(&((fn)->name))

Bob Halley's avatar
add  
Bob Halley committed
80
#endif /* DNS_FIXEDNAME_H */