mf_4.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: mf_4.c,v 1.47 2009/12/04 22:06:37 tbox Exp $ */
00019 
00020 /* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */
00021 
00022 #ifndef RDATA_GENERIC_MF_4_C
00023 #define RDATA_GENERIC_MF_4_C
00024 
00025 #define RRTYPE_MF_ATTRIBUTES (0)
00026 
00027 static inline isc_result_t
00028 fromtext_mf(ARGS_FROMTEXT) {
00029         isc_token_t token;
00030         dns_name_t name;
00031         isc_buffer_t buffer;
00032 
00033         REQUIRE(type == 4);
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_mf(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 == 4);
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_mf(ARGS_FROMWIRE) {
00072         dns_name_t name;
00073 
00074         REQUIRE(type == 4);
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_mf(ARGS_TOWIRE) {
00087         dns_name_t name;
00088         dns_offsets_t offsets;
00089         isc_region_t region;
00090 
00091         REQUIRE(rdata->type == 4);
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_mf(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 == 4);
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_mf(ARGS_FROMSTRUCT) {
00130         dns_rdata_mf_t *mf = source;
00131         isc_region_t region;
00132 
00133         REQUIRE(type == 4);
00134         REQUIRE(source != NULL);
00135         REQUIRE(mf->common.rdtype == type);
00136         REQUIRE(mf->common.rdclass == rdclass);
00137 
00138         UNUSED(type);
00139         UNUSED(rdclass);
00140 
00141         dns_name_toregion(&mf->mf, &region);
00142         return (isc_buffer_copyregion(target, &region));
00143 }
00144 
00145 static inline isc_result_t
00146 tostruct_mf(ARGS_TOSTRUCT) {
00147         dns_rdata_mf_t *mf = target;
00148         isc_region_t r;
00149         dns_name_t name;
00150 
00151         REQUIRE(rdata->type == 4);
00152         REQUIRE(target != NULL);
00153         REQUIRE(rdata->length != 0);
00154 
00155         mf->common.rdclass = rdata->rdclass;
00156         mf->common.rdtype = rdata->type;
00157         ISC_LINK_INIT(&mf->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(&mf->mf, NULL);
00163         RETERR(name_duporclone(&name, mctx, &mf->mf));
00164         mf->mctx = mctx;
00165         return (ISC_R_SUCCESS);
00166 }
00167 
00168 static inline void
00169 freestruct_mf(ARGS_FREESTRUCT) {
00170         dns_rdata_mf_t *mf = source;
00171 
00172         REQUIRE(source != NULL);
00173         REQUIRE(mf->common.rdtype == 4);
00174 
00175         if (mf->mctx == NULL)
00176                 return;
00177         dns_name_free(&mf->mf, mf->mctx);
00178         mf->mctx = NULL;
00179 }
00180 
00181 static inline isc_result_t
00182 additionaldata_mf(ARGS_ADDLDATA) {
00183         dns_name_t name;
00184         dns_offsets_t offsets;
00185         isc_region_t region;
00186 
00187         REQUIRE(rdata->type == 4);
00188 
00189         dns_name_init(&name, offsets);
00190         dns_rdata_toregion(rdata, &region);
00191         dns_name_fromregion(&name, &region);
00192 
00193         return ((add)(arg, &name, dns_rdatatype_a));
00194 }
00195 
00196 static inline isc_result_t
00197 digest_mf(ARGS_DIGEST) {
00198         isc_region_t r;
00199         dns_name_t name;
00200 
00201         REQUIRE(rdata->type == 4);
00202 
00203         dns_rdata_toregion(rdata, &r);
00204         dns_name_init(&name, NULL);
00205         dns_name_fromregion(&name, &r);
00206 
00207         return (dns_name_digest(&name, digest, arg));
00208 }
00209 
00210 static inline isc_boolean_t
00211 checkowner_mf(ARGS_CHECKOWNER) {
00212 
00213         REQUIRE(type == 4);
00214 
00215         UNUSED(name);
00216         UNUSED(type);
00217         UNUSED(rdclass);
00218         UNUSED(wildcard);
00219 
00220         return (ISC_TRUE);
00221 }
00222 
00223 static inline isc_boolean_t
00224 checknames_mf(ARGS_CHECKNAMES) {
00225 
00226         REQUIRE(rdata->type == 4);
00227 
00228         UNUSED(rdata);
00229         UNUSED(owner);
00230         UNUSED(bad);
00231 
00232         return (ISC_TRUE);
00233 }
00234 
00235 static inline int
00236 casecompare_mf(ARGS_COMPARE) {
00237         return (compare_mf(rdata1, rdata2));
00238 }
00239 
00240 #endif  /* RDATA_GENERIC_MF_4_C */

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