md_3.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2007, 2009  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1998-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: md_3.c,v 1.49 2009/12/04 22:06:37 tbox Exp $ */
00019 
00020 /* Reviewed: Wed Mar 15 17:48:20 PST 2000 by bwelling */
00021 
00022 #ifndef RDATA_GENERIC_MD_3_C
00023 #define RDATA_GENERIC_MD_3_C
00024 
00025 #define RRTYPE_MD_ATTRIBUTES (0)
00026 
00027 static inline isc_result_t
00028 fromtext_md(ARGS_FROMTEXT) {
00029         isc_token_t token;
00030         dns_name_t name;
00031         isc_buffer_t buffer;
00032 
00033         REQUIRE(type == 3);
00034 
00035         UNUSED(type);
00036         UNUSED(rdclass);
00037         UNUSED(callbacks);
00038 
00039         RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00040                                       ISC_FALSE));
00041 
00042         dns_name_init(&name, NULL);
00043         buffer_fromregion(&buffer, &token.value.as_region);
00044         origin = (origin != NULL) ? origin : dns_rootname;
00045         RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00046         return (ISC_R_SUCCESS);
00047 }
00048 
00049 static inline isc_result_t
00050 totext_md(ARGS_TOTEXT) {
00051         isc_region_t region;
00052         dns_name_t name;
00053         dns_name_t prefix;
00054         isc_boolean_t sub;
00055 
00056         REQUIRE(rdata->type == 3);
00057         REQUIRE(rdata->length != 0);
00058 
00059         dns_name_init(&name, NULL);
00060         dns_name_init(&prefix, NULL);
00061 
00062         dns_rdata_toregion(rdata, &region);
00063         dns_name_fromregion(&name, &region);
00064 
00065         sub = name_prefix(&name, tctx->origin, &prefix);
00066 
00067         return (dns_name_totext(&prefix, sub, target));
00068 }
00069 
00070 static inline isc_result_t
00071 fromwire_md(ARGS_FROMWIRE) {
00072         dns_name_t name;
00073 
00074         REQUIRE(type == 3);
00075 
00076         UNUSED(type);
00077         UNUSED(rdclass);
00078 
00079         dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
00080 
00081         dns_name_init(&name, NULL);
00082         return (dns_name_fromwire(&name, source, dctx, options, target));
00083 }
00084 
00085 static inline isc_result_t
00086 towire_md(ARGS_TOWIRE) {
00087         dns_name_t name;
00088         dns_offsets_t offsets;
00089         isc_region_t region;
00090 
00091         REQUIRE(rdata->type == 3);
00092         REQUIRE(rdata->length != 0);
00093 
00094         dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
00095 
00096         dns_name_init(&name, offsets);
00097         dns_rdata_toregion(rdata, &region);
00098         dns_name_fromregion(&name, &region);
00099 
00100         return (dns_name_towire(&name, cctx, target));
00101 }
00102 
00103 static inline int
00104 compare_md(ARGS_COMPARE) {
00105         dns_name_t name1;
00106         dns_name_t name2;
00107         isc_region_t region1;
00108         isc_region_t region2;
00109 
00110         REQUIRE(rdata1->type == rdata2->type);
00111         REQUIRE(rdata1->rdclass == rdata2->rdclass);
00112         REQUIRE(rdata1->type == 3);
00113         REQUIRE(rdata1->length != 0);
00114         REQUIRE(rdata2->length != 0);
00115 
00116         dns_name_init(&name1, NULL);
00117         dns_name_init(&name2, NULL);
00118 
00119         dns_rdata_toregion(rdata1, &region1);
00120         dns_rdata_toregion(rdata2, &region2);
00121 
00122         dns_name_fromregion(&name1, &region1);
00123         dns_name_fromregion(&name2, &region2);
00124 
00125         return (dns_name_rdatacompare(&name1, &name2));
00126 }
00127 
00128 static inline isc_result_t
00129 fromstruct_md(ARGS_FROMSTRUCT) {
00130         dns_rdata_md_t *md = source;
00131         isc_region_t region;
00132 
00133         REQUIRE(type == 3);
00134         REQUIRE(source != NULL);
00135         REQUIRE(md->common.rdtype == type);
00136         REQUIRE(md->common.rdclass == rdclass);
00137 
00138         UNUSED(type);
00139         UNUSED(rdclass);
00140 
00141         dns_name_toregion(&md->md, &region);
00142         return (isc_buffer_copyregion(target, &region));
00143 }
00144 
00145 static inline isc_result_t
00146 tostruct_md(ARGS_TOSTRUCT) {
00147         dns_rdata_md_t *md = target;
00148         isc_region_t r;
00149         dns_name_t name;
00150 
00151         REQUIRE(rdata->type == 3);
00152         REQUIRE(target != NULL);
00153         REQUIRE(rdata->length != 0);
00154 
00155         md->common.rdclass = rdata->rdclass;
00156         md->common.rdtype = rdata->type;
00157         ISC_LINK_INIT(&md->common, link);
00158 
00159         dns_name_init(&name, NULL);
00160         dns_rdata_toregion(rdata, &r);
00161         dns_name_fromregion(&name, &r);
00162         dns_name_init(&md->md, NULL);
00163         RETERR(name_duporclone(&name, mctx, &md->md));
00164         md->mctx = mctx;
00165         return (ISC_R_SUCCESS);
00166 }
00167 
00168 static inline void
00169 freestruct_md(ARGS_FREESTRUCT) {
00170         dns_rdata_md_t *md = source;
00171 
00172         REQUIRE(source != NULL);
00173         REQUIRE(md->common.rdtype == 3);
00174 
00175         if (md->mctx == NULL)
00176                 return;
00177 
00178         dns_name_free(&md->md, md->mctx);
00179         md->mctx = NULL;
00180 }
00181 
00182 static inline isc_result_t
00183 additionaldata_md(ARGS_ADDLDATA) {
00184         dns_name_t name;
00185         dns_offsets_t offsets;
00186         isc_region_t region;
00187 
00188         REQUIRE(rdata->type == 3);
00189 
00190         dns_name_init(&name, offsets);
00191         dns_rdata_toregion(rdata, &region);
00192         dns_name_fromregion(&name, &region);
00193 
00194         return ((add)(arg, &name, dns_rdatatype_a));
00195 }
00196 
00197 static inline isc_result_t
00198 digest_md(ARGS_DIGEST) {
00199         isc_region_t r;
00200         dns_name_t name;
00201 
00202         REQUIRE(rdata->type == 3);
00203 
00204         dns_rdata_toregion(rdata, &r);
00205         dns_name_init(&name, NULL);
00206         dns_name_fromregion(&name, &r);
00207 
00208         return (dns_name_digest(&name, digest, arg));
00209 }
00210 
00211 static inline isc_boolean_t
00212 checkowner_md(ARGS_CHECKOWNER) {
00213 
00214         REQUIRE(type == 3);
00215 
00216         UNUSED(name);
00217         UNUSED(type);
00218         UNUSED(rdclass);
00219         UNUSED(wildcard);
00220 
00221         return (ISC_TRUE);
00222 }
00223 
00224 static inline isc_boolean_t
00225 checknames_md(ARGS_CHECKNAMES) {
00226 
00227         REQUIRE(rdata->type == 3);
00228 
00229         UNUSED(rdata);
00230         UNUSED(owner);
00231         UNUSED(bad);
00232 
00233         return (ISC_TRUE);
00234 }
00235 
00236 static inline int
00237 casecompare_md(ARGS_COMPARE) {
00238         return (compare_md(rdata1, rdata2));
00239 }
00240 
00241 #endif  /* RDATA_GENERIC_MD_3_C */

Generated on Tue Apr 28 17:41:00 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha