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