OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / openswan / lib / libdns / include / dns / fixedname.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $ISC-Id:fixedname.h,v 1.12.206.1 2004/03/06 08:13:55 marka Exp $ */
19 /* $Id: fixedname.h,v 1.1 2005/08/05 01:05:26 mcr Exp $ */
20
21 #ifndef DNS_FIXEDNAME_H
22 #define DNS_FIXEDNAME_H 1
23
24 /*****
25  ***** Module Info
26  *****/
27
28 /*
29  * Fixed-size Names
30  *
31  * dns_fixedname_t is a convenience type containing a name, an offsets table,
32  * and a dedicated buffer big enough for the longest possible name.
33  *
34  * MP:
35  *      The caller must ensure any required synchronization.
36  *
37  * Reliability:
38  *      No anticipated impact.
39  *
40  * Resources:
41  *      Per dns_fixedname_t:
42  *              sizeof(dns_name_t) + sizeof(dns_offsets_t) +
43  *              sizeof(isc_buffer_t) + 255 bytes + structure padding
44  *
45  * Security:
46  *      No anticipated impact.
47  *
48  * Standards:
49  *      None.
50  */
51
52 /*****
53  ***** Imports
54  *****/
55
56 #include <isc/buffer.h>
57
58 #include <dns/name.h>
59
60 /*****
61  ***** Types
62  *****/
63
64 struct dns_fixedname {
65         dns_name_t                      name;
66         dns_offsets_t                   offsets;
67         isc_buffer_t                    buffer;
68         unsigned char                   data[DNS_NAME_MAXWIRE];
69 };
70
71 #define dns_fixedname_init(fn) \
72         do { \
73                 dns_name_init(&((fn)->name), (fn)->offsets); \
74                 isc_buffer_init(&((fn)->buffer), (fn)->data, \
75                                   DNS_NAME_MAXWIRE); \
76                 dns_name_setbuffer(&((fn)->name), &((fn)->buffer)); \
77         } while (0)
78
79 #define dns_fixedname_invalidate(fn) \
80         dns_name_invalidate(&((fn)->name))
81
82 #define dns_fixedname_name(fn)          (&((fn)->name))
83
84 #endif /* DNS_FIXEDNAME_H */