00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RDATA_GENERIC_DNAME_39_C
00025 #define RDATA_GENERIC_DNAME_39_C
00026
00027 #define RRTYPE_DNAME_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON)
00028
00029 static inline isc_result_t
00030 fromtext_dname(ARGS_FROMTEXT) {
00031 isc_token_t token;
00032 dns_name_t name;
00033 isc_buffer_t buffer;
00034
00035 REQUIRE(type == 39);
00036
00037 UNUSED(type);
00038 UNUSED(rdclass);
00039 UNUSED(callbacks);
00040
00041 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00042 ISC_FALSE));
00043
00044 dns_name_init(&name, NULL);
00045 buffer_fromregion(&buffer, &token.value.as_region);
00046 origin = (origin != NULL) ? origin : dns_rootname;
00047 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00048 return (ISC_R_SUCCESS);
00049 }
00050
00051 static inline isc_result_t
00052 totext_dname(ARGS_TOTEXT) {
00053 isc_region_t region;
00054 dns_name_t name;
00055 dns_name_t prefix;
00056 isc_boolean_t sub;
00057
00058 REQUIRE(rdata->type == 39);
00059 REQUIRE(rdata->length != 0);
00060
00061 dns_name_init(&name, NULL);
00062 dns_name_init(&prefix, NULL);
00063
00064 dns_rdata_toregion(rdata, ®ion);
00065 dns_name_fromregion(&name, ®ion);
00066
00067 sub = name_prefix(&name, tctx->origin, &prefix);
00068
00069 return (dns_name_totext(&prefix, sub, target));
00070 }
00071
00072 static inline isc_result_t
00073 fromwire_dname(ARGS_FROMWIRE) {
00074 dns_name_t name;
00075
00076 REQUIRE(type == 39);
00077
00078 UNUSED(type);
00079 UNUSED(rdclass);
00080
00081 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
00082
00083 dns_name_init(&name, NULL);
00084 return(dns_name_fromwire(&name, source, dctx, options, target));
00085 }
00086
00087 static inline isc_result_t
00088 towire_dname(ARGS_TOWIRE) {
00089 dns_name_t name;
00090 dns_offsets_t offsets;
00091 isc_region_t region;
00092
00093 REQUIRE(rdata->type == 39);
00094 REQUIRE(rdata->length != 0);
00095
00096 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
00097 dns_name_init(&name, offsets);
00098 dns_rdata_toregion(rdata, ®ion);
00099 dns_name_fromregion(&name, ®ion);
00100
00101 return (dns_name_towire(&name, cctx, target));
00102 }
00103
00104 static inline int
00105 compare_dname(ARGS_COMPARE) {
00106 dns_name_t name1;
00107 dns_name_t name2;
00108 isc_region_t region1;
00109 isc_region_t region2;
00110
00111 REQUIRE(rdata1->type == rdata2->type);
00112 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00113 REQUIRE(rdata1->type == 39);
00114 REQUIRE(rdata1->length != 0);
00115 REQUIRE(rdata2->length != 0);
00116
00117 dns_name_init(&name1, NULL);
00118 dns_name_init(&name2, NULL);
00119
00120 dns_rdata_toregion(rdata1, ®ion1);
00121 dns_rdata_toregion(rdata2, ®ion2);
00122
00123 dns_name_fromregion(&name1, ®ion1);
00124 dns_name_fromregion(&name2, ®ion2);
00125
00126 return (dns_name_rdatacompare(&name1, &name2));
00127 }
00128
00129 static inline isc_result_t
00130 fromstruct_dname(ARGS_FROMSTRUCT) {
00131 dns_rdata_dname_t *dname = source;
00132 isc_region_t region;
00133
00134 REQUIRE(type == 39);
00135 REQUIRE(source != NULL);
00136 REQUIRE(dname->common.rdtype == type);
00137 REQUIRE(dname->common.rdclass == rdclass);
00138
00139 UNUSED(type);
00140 UNUSED(rdclass);
00141
00142 dns_name_toregion(&dname->dname, ®ion);
00143 return (isc_buffer_copyregion(target, ®ion));
00144 }
00145
00146 static inline isc_result_t
00147 tostruct_dname(ARGS_TOSTRUCT) {
00148 isc_region_t region;
00149 dns_rdata_dname_t *dname = target;
00150 dns_name_t name;
00151
00152 REQUIRE(rdata->type == 39);
00153 REQUIRE(target != NULL);
00154 REQUIRE(rdata->length != 0);
00155
00156 dname->common.rdclass = rdata->rdclass;
00157 dname->common.rdtype = rdata->type;
00158 ISC_LINK_INIT(&dname->common, link);
00159
00160 dns_name_init(&name, NULL);
00161 dns_rdata_toregion(rdata, ®ion);
00162 dns_name_fromregion(&name, ®ion);
00163 dns_name_init(&dname->dname, NULL);
00164 RETERR(name_duporclone(&name, mctx, &dname->dname));
00165 dname->mctx = mctx;
00166 return (ISC_R_SUCCESS);
00167 }
00168
00169 static inline void
00170 freestruct_dname(ARGS_FREESTRUCT) {
00171 dns_rdata_dname_t *dname = source;
00172
00173 REQUIRE(source != NULL);
00174 REQUIRE(dname->common.rdtype == 39);
00175
00176 if (dname->mctx == NULL)
00177 return;
00178
00179 dns_name_free(&dname->dname, dname->mctx);
00180 dname->mctx = NULL;
00181 }
00182
00183 static inline isc_result_t
00184 additionaldata_dname(ARGS_ADDLDATA) {
00185 UNUSED(rdata);
00186 UNUSED(add);
00187 UNUSED(arg);
00188
00189 REQUIRE(rdata->type == 39);
00190
00191 return (ISC_R_SUCCESS);
00192 }
00193
00194 static inline isc_result_t
00195 digest_dname(ARGS_DIGEST) {
00196 isc_region_t r;
00197 dns_name_t name;
00198
00199 REQUIRE(rdata->type == 39);
00200
00201 dns_rdata_toregion(rdata, &r);
00202 dns_name_init(&name, NULL);
00203 dns_name_fromregion(&name, &r);
00204
00205 return (dns_name_digest(&name, digest, arg));
00206 }
00207
00208 static inline isc_boolean_t
00209 checkowner_dname(ARGS_CHECKOWNER) {
00210
00211 REQUIRE(type == 39);
00212
00213 UNUSED(name);
00214 UNUSED(type);
00215 UNUSED(rdclass);
00216 UNUSED(wildcard);
00217
00218 return (ISC_TRUE);
00219 }
00220
00221 static inline isc_boolean_t
00222 checknames_dname(ARGS_CHECKNAMES) {
00223
00224 REQUIRE(rdata->type == 39);
00225
00226 UNUSED(rdata);
00227 UNUSED(owner);
00228 UNUSED(bad);
00229
00230 return (ISC_TRUE);
00231 }
00232
00233 static inline int
00234 casecompare_dname(ARGS_COMPARE) {
00235 return (compare_dname(rdata1, rdata2));
00236 }
00237 #endif