1/* 2 * Copyright (C) 2004, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (C) 1998-2002 Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and/or 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/* $Id$ */ 19 20/* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ 21 22#ifndef RDATA_GENERIC_NULL_10_C 23#define RDATA_GENERIC_NULL_10_C 24 25#define RRTYPE_NULL_ATTRIBUTES (0) 26 27static inline isc_result_t 28fromtext_null(ARGS_FROMTEXT) { 29 REQUIRE(type == 10); 30 31 UNUSED(rdclass); 32 UNUSED(type); 33 UNUSED(lexer); 34 UNUSED(origin); 35 UNUSED(options); 36 UNUSED(target); 37 UNUSED(callbacks); 38 39 return (DNS_R_SYNTAX); 40} 41 42static inline isc_result_t 43totext_null(ARGS_TOTEXT) { 44 REQUIRE(rdata->type == 10); 45 46 return (unknown_totext(rdata, tctx, target)); 47} 48 49static inline isc_result_t 50fromwire_null(ARGS_FROMWIRE) { 51 isc_region_t sr; 52 53 REQUIRE(type == 10); 54 55 UNUSED(type); 56 UNUSED(rdclass); 57 UNUSED(dctx); 58 UNUSED(options); 59 60 isc_buffer_activeregion(source, &sr); 61 isc_buffer_forward(source, sr.length); 62 return (mem_tobuffer(target, sr.base, sr.length)); 63} 64 65static inline isc_result_t 66towire_null(ARGS_TOWIRE) { 67 REQUIRE(rdata->type == 10); 68 69 UNUSED(cctx); 70 71 return (mem_tobuffer(target, rdata->data, rdata->length)); 72} 73 74static inline int 75compare_null(ARGS_COMPARE) { 76 isc_region_t r1; 77 isc_region_t r2; 78 79 REQUIRE(rdata1->type == rdata2->type); 80 REQUIRE(rdata1->rdclass == rdata2->rdclass); 81 REQUIRE(rdata1->type == 10); 82 83 dns_rdata_toregion(rdata1, &r1); 84 dns_rdata_toregion(rdata2, &r2); 85 return (isc_region_compare(&r1, &r2)); 86} 87 88static inline isc_result_t 89fromstruct_null(ARGS_FROMSTRUCT) { 90 dns_rdata_null_t *null = source; 91 92 REQUIRE(type == 10); 93 REQUIRE(source != NULL); 94 REQUIRE(null->common.rdtype == type); 95 REQUIRE(null->common.rdclass == rdclass); 96 REQUIRE(null->data != NULL || null->length == 0); 97 98 UNUSED(type); 99 UNUSED(rdclass); 100 101 return (mem_tobuffer(target, null->data, null->length)); 102} 103 104static inline isc_result_t 105tostruct_null(ARGS_TOSTRUCT) { 106 dns_rdata_null_t *null = target; 107 isc_region_t r; 108 109 REQUIRE(rdata->type == 10); 110 REQUIRE(target != NULL); 111 112 null->common.rdclass = rdata->rdclass; 113 null->common.rdtype = rdata->type; 114 ISC_LINK_INIT(&null->common, link); 115 116 dns_rdata_toregion(rdata, &r); 117 null->length = r.length; 118 null->data = mem_maybedup(mctx, r.base, r.length); 119 if (null->data == NULL) 120 return (ISC_R_NOMEMORY); 121 122 null->mctx = mctx; 123 return (ISC_R_SUCCESS); 124} 125 126static inline void 127freestruct_null(ARGS_FREESTRUCT) { 128 dns_rdata_null_t *null = source; 129 130 REQUIRE(source != NULL); 131 REQUIRE(null->common.rdtype == 10); 132 133 if (null->mctx == NULL) 134 return; 135 136 if (null->data != NULL) 137 isc_mem_free(null->mctx, null->data); 138 null->mctx = NULL; 139} 140 141static inline isc_result_t 142additionaldata_null(ARGS_ADDLDATA) { 143 UNUSED(rdata); 144 UNUSED(add); 145 UNUSED(arg); 146 147 REQUIRE(rdata->type == 10); 148 149 return (ISC_R_SUCCESS); 150} 151 152static inline isc_result_t 153digest_null(ARGS_DIGEST) { 154 isc_region_t r; 155 156 REQUIRE(rdata->type == 10); 157 158 dns_rdata_toregion(rdata, &r); 159 160 return ((digest)(arg, &r)); 161} 162 163static inline isc_boolean_t 164checkowner_null(ARGS_CHECKOWNER) { 165 166 REQUIRE(type == 10); 167 168 UNUSED(name); 169 UNUSED(type); 170 UNUSED(rdclass); 171 UNUSED(wildcard); 172 173 return (ISC_TRUE); 174} 175 176static inline isc_boolean_t 177checknames_null(ARGS_CHECKNAMES) { 178 179 REQUIRE(rdata->type == 10); 180 181 UNUSED(rdata); 182 UNUSED(owner); 183 UNUSED(bad); 184 185 return (ISC_TRUE); 186} 187 188static inline int 189casecompare_null(ARGS_COMPARE) { 190 return (compare_null(rdata1, rdata2)); 191} 192 193#endif /* RDATA_GENERIC_NULL_10_C */ 194