00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef RDATA_GENERIC_MR_9_C
00023 #define RDATA_GENERIC_MR_9_C
00024
00025 #define RRTYPE_MR_ATTRIBUTES (0)
00026
00027 static inline isc_result_t
00028 fromtext_mr(ARGS_FROMTEXT) {
00029 isc_token_t token;
00030 dns_name_t name;
00031 isc_buffer_t buffer;
00032
00033 REQUIRE(type == 9);
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_mr(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 == 9);
00057 REQUIRE(rdata->length != 0);
00058
00059 dns_name_init(&name, NULL);
00060 dns_name_init(&prefix, NULL);
00061
00062 dns_rdata_toregion(rdata, ®ion);
00063 dns_name_fromregion(&name, ®ion);
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_mr(ARGS_FROMWIRE) {
00072 dns_name_t name;
00073
00074 REQUIRE(type == 9);
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_mr(ARGS_TOWIRE) {
00087 dns_name_t name;
00088 dns_offsets_t offsets;
00089 isc_region_t region;
00090
00091 REQUIRE(rdata->type == 9);
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, ®ion);
00098 dns_name_fromregion(&name, ®ion);
00099
00100 return (dns_name_towire(&name, cctx, target));
00101 }
00102
00103 static inline int
00104 compare_mr(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 == 9);
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, ®ion1);
00120 dns_rdata_toregion(rdata2, ®ion2);
00121
00122 dns_name_fromregion(&name1, ®ion1);
00123 dns_name_fromregion(&name2, ®ion2);
00124
00125 return (dns_name_rdatacompare(&name1, &name2));
00126 }
00127
00128 static inline isc_result_t
00129 fromstruct_mr(ARGS_FROMSTRUCT) {
00130 dns_rdata_mr_t *mr = source;
00131 isc_region_t region;
00132
00133 REQUIRE(type == 9);
00134 REQUIRE(source != NULL);
00135 REQUIRE(mr->common.rdtype == type);
00136 REQUIRE(mr->common.rdclass == rdclass);
00137
00138 UNUSED(type);
00139 UNUSED(rdclass);
00140
00141 dns_name_toregion(&mr->mr, ®ion);
00142 return (isc_buffer_copyregion(target, ®ion));
00143 }
00144
00145 static inline isc_result_t
00146 tostruct_mr(ARGS_TOSTRUCT) {
00147 isc_region_t region;
00148 dns_rdata_mr_t *mr = target;
00149 dns_name_t name;
00150
00151 REQUIRE(rdata->type == 9);
00152 REQUIRE(target != NULL);
00153 REQUIRE(rdata->length != 0);
00154
00155 mr->common.rdclass = rdata->rdclass;
00156 mr->common.rdtype = rdata->type;
00157 ISC_LINK_INIT(&mr->common, link);
00158
00159 dns_name_init(&name, NULL);
00160 dns_rdata_toregion(rdata, ®ion);
00161 dns_name_fromregion(&name, ®ion);
00162 dns_name_init(&mr->mr, NULL);
00163 RETERR(name_duporclone(&name, mctx, &mr->mr));
00164 mr->mctx = mctx;
00165 return (ISC_R_SUCCESS);
00166 }
00167
00168 static inline void
00169 freestruct_mr(ARGS_FREESTRUCT) {
00170 dns_rdata_mr_t *mr = source;
00171
00172 REQUIRE(source != NULL);
00173 REQUIRE(mr->common.rdtype == 9);
00174
00175 if (mr->mctx == NULL)
00176 return;
00177 dns_name_free(&mr->mr, mr->mctx);
00178 mr->mctx = NULL;
00179 }
00180
00181 static inline isc_result_t
00182 additionaldata_mr(ARGS_ADDLDATA) {
00183 REQUIRE(rdata->type == 9);
00184
00185 UNUSED(rdata);
00186 UNUSED(add);
00187 UNUSED(arg);
00188
00189 return (ISC_R_SUCCESS);
00190 }
00191
00192 static inline isc_result_t
00193 digest_mr(ARGS_DIGEST) {
00194 isc_region_t r;
00195 dns_name_t name;
00196
00197 REQUIRE(rdata->type == 9);
00198
00199 dns_rdata_toregion(rdata, &r);
00200 dns_name_init(&name, NULL);
00201 dns_name_fromregion(&name, &r);
00202
00203 return (dns_name_digest(&name, digest, arg));
00204 }
00205
00206 static inline isc_boolean_t
00207 checkowner_mr(ARGS_CHECKOWNER) {
00208
00209 REQUIRE(type == 9);
00210
00211 UNUSED(name);
00212 UNUSED(type);
00213 UNUSED(rdclass);
00214 UNUSED(wildcard);
00215
00216 return (ISC_TRUE);
00217 }
00218
00219 static inline isc_boolean_t
00220 checknames_mr(ARGS_CHECKNAMES) {
00221
00222 REQUIRE(rdata->type == 9);
00223
00224 UNUSED(rdata);
00225 UNUSED(owner);
00226 UNUSED(bad);
00227
00228 return (ISC_TRUE);
00229 }
00230
00231 static inline int
00232 casecompare_mr(ARGS_COMPARE) {
00233 return (compare_mr(rdata1, rdata2));
00234 }
00235
00236 #endif