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_CNAME_5_C
00023 #define RDATA_GENERIC_CNAME_5_C
00024
00025 #define RRTYPE_CNAME_ATTRIBUTES \
00026 (DNS_RDATATYPEATTR_EXCLUSIVE | DNS_RDATATYPEATTR_SINGLETON)
00027
00028 static inline isc_result_t
00029 fromtext_cname(ARGS_FROMTEXT) {
00030 isc_token_t token;
00031 dns_name_t name;
00032 isc_buffer_t buffer;
00033
00034 REQUIRE(type == 5);
00035
00036 UNUSED(type);
00037 UNUSED(rdclass);
00038 UNUSED(callbacks);
00039
00040 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00041 ISC_FALSE));
00042
00043 dns_name_init(&name, NULL);
00044 buffer_fromregion(&buffer, &token.value.as_region);
00045 origin = (origin != NULL) ? origin : dns_rootname;
00046 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00047 return (ISC_R_SUCCESS);
00048 }
00049
00050 static inline isc_result_t
00051 totext_cname(ARGS_TOTEXT) {
00052 isc_region_t region;
00053 dns_name_t name;
00054 dns_name_t prefix;
00055 isc_boolean_t sub;
00056
00057 REQUIRE(rdata->type == 5);
00058 REQUIRE(rdata->length != 0);
00059
00060 dns_name_init(&name, NULL);
00061 dns_name_init(&prefix, NULL);
00062
00063 dns_rdata_toregion(rdata, ®ion);
00064 dns_name_fromregion(&name, ®ion);
00065
00066 sub = name_prefix(&name, tctx->origin, &prefix);
00067
00068 return (dns_name_totext(&prefix, sub, target));
00069 }
00070
00071 static inline isc_result_t
00072 fromwire_cname(ARGS_FROMWIRE) {
00073 dns_name_t name;
00074
00075 REQUIRE(type == 5);
00076
00077 UNUSED(type);
00078 UNUSED(rdclass);
00079
00080 dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
00081
00082 dns_name_init(&name, NULL);
00083 return (dns_name_fromwire(&name, source, dctx, options, target));
00084 }
00085
00086 static inline isc_result_t
00087 towire_cname(ARGS_TOWIRE) {
00088 dns_name_t name;
00089 dns_offsets_t offsets;
00090 isc_region_t region;
00091
00092 REQUIRE(rdata->type == 5);
00093 REQUIRE(rdata->length != 0);
00094
00095 dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
00096
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_cname(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 == 5);
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_cname(ARGS_FROMSTRUCT) {
00131 dns_rdata_cname_t *cname = source;
00132 isc_region_t region;
00133
00134 REQUIRE(type == 5);
00135 REQUIRE(source != NULL);
00136 REQUIRE(cname->common.rdtype == type);
00137 REQUIRE(cname->common.rdclass == rdclass);
00138
00139 UNUSED(type);
00140 UNUSED(rdclass);
00141
00142 dns_name_toregion(&cname->cname, ®ion);
00143 return (isc_buffer_copyregion(target, ®ion));
00144 }
00145
00146 static inline isc_result_t
00147 tostruct_cname(ARGS_TOSTRUCT) {
00148 isc_region_t region;
00149 dns_rdata_cname_t *cname = target;
00150 dns_name_t name;
00151
00152 REQUIRE(rdata->type == 5);
00153 REQUIRE(target != NULL);
00154 REQUIRE(rdata->length != 0);
00155
00156 cname->common.rdclass = rdata->rdclass;
00157 cname->common.rdtype = rdata->type;
00158 ISC_LINK_INIT(&cname->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(&cname->cname, NULL);
00164 RETERR(name_duporclone(&name, mctx, &cname->cname));
00165 cname->mctx = mctx;
00166 return (ISC_R_SUCCESS);
00167 }
00168
00169 static inline void
00170 freestruct_cname(ARGS_FREESTRUCT) {
00171 dns_rdata_cname_t *cname = source;
00172
00173 REQUIRE(source != NULL);
00174
00175 if (cname->mctx == NULL)
00176 return;
00177
00178 dns_name_free(&cname->cname, cname->mctx);
00179 cname->mctx = NULL;
00180 }
00181
00182 static inline isc_result_t
00183 additionaldata_cname(ARGS_ADDLDATA) {
00184 UNUSED(rdata);
00185 UNUSED(add);
00186 UNUSED(arg);
00187
00188 REQUIRE(rdata->type == 5);
00189
00190 return (ISC_R_SUCCESS);
00191 }
00192
00193 static inline isc_result_t
00194 digest_cname(ARGS_DIGEST) {
00195 isc_region_t r;
00196 dns_name_t name;
00197
00198 REQUIRE(rdata->type == 5);
00199
00200 dns_rdata_toregion(rdata, &r);
00201 dns_name_init(&name, NULL);
00202 dns_name_fromregion(&name, &r);
00203
00204 return (dns_name_digest(&name, digest, arg));
00205 }
00206
00207 static inline isc_boolean_t
00208 checkowner_cname(ARGS_CHECKOWNER) {
00209
00210 REQUIRE(type == 5);
00211
00212 UNUSED(name);
00213 UNUSED(type);
00214 UNUSED(rdclass);
00215 UNUSED(wildcard);
00216
00217 return (ISC_TRUE);
00218 }
00219
00220 static inline isc_boolean_t
00221 checknames_cname(ARGS_CHECKNAMES) {
00222
00223 REQUIRE(rdata->type == 5);
00224
00225 UNUSED(rdata);
00226 UNUSED(owner);
00227 UNUSED(bad);
00228
00229 return (ISC_TRUE);
00230 }
00231
00232 static inline int
00233 casecompare_cname(ARGS_COMPARE) {
00234 return (compare_cname(rdata1, rdata2));
00235 }
00236
00237 #endif