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_IN_1_KX_36_C
00025 #define RDATA_IN_1_KX_36_C
00026
00027 #define RRTYPE_KX_ATTRIBUTES (0)
00028
00029 static inline isc_result_t
00030 fromtext_in_kx(ARGS_FROMTEXT) {
00031 isc_token_t token;
00032 dns_name_t name;
00033 isc_buffer_t buffer;
00034
00035 REQUIRE(type == 36);
00036 REQUIRE(rdclass == 1);
00037
00038 UNUSED(type);
00039 UNUSED(rdclass);
00040 UNUSED(callbacks);
00041
00042 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
00043 ISC_FALSE));
00044 if (token.value.as_ulong > 0xffffU)
00045 RETTOK(ISC_R_RANGE);
00046 RETERR(uint16_tobuffer(token.value.as_ulong, target));
00047
00048 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00049 ISC_FALSE));
00050 dns_name_init(&name, NULL);
00051 buffer_fromregion(&buffer, &token.value.as_region);
00052 origin = (origin != NULL) ? origin : dns_rootname;
00053 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00054 return (ISC_R_SUCCESS);
00055 }
00056
00057 static inline isc_result_t
00058 totext_in_kx(ARGS_TOTEXT) {
00059 isc_region_t region;
00060 dns_name_t name;
00061 dns_name_t prefix;
00062 isc_boolean_t sub;
00063 char buf[sizeof("64000")];
00064 unsigned short num;
00065
00066 REQUIRE(rdata->type == 36);
00067 REQUIRE(rdata->rdclass == 1);
00068 REQUIRE(rdata->length != 0);
00069
00070 dns_name_init(&name, NULL);
00071 dns_name_init(&prefix, NULL);
00072
00073 dns_rdata_toregion(rdata, ®ion);
00074 num = uint16_fromregion(®ion);
00075 isc_region_consume(®ion, 2);
00076 sprintf(buf, "%u", num);
00077 RETERR(str_totext(buf, target));
00078
00079 RETERR(str_totext(" ", target));
00080
00081 dns_name_fromregion(&name, ®ion);
00082 sub = name_prefix(&name, tctx->origin, &prefix);
00083 return (dns_name_totext(&prefix, sub, target));
00084 }
00085
00086 static inline isc_result_t
00087 fromwire_in_kx(ARGS_FROMWIRE) {
00088 dns_name_t name;
00089 isc_region_t sregion;
00090
00091 REQUIRE(type == 36);
00092 REQUIRE(rdclass == 1);
00093
00094 UNUSED(type);
00095 UNUSED(rdclass);
00096
00097 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
00098
00099 dns_name_init(&name, NULL);
00100
00101 isc_buffer_activeregion(source, &sregion);
00102 if (sregion.length < 2)
00103 return (ISC_R_UNEXPECTEDEND);
00104 RETERR(mem_tobuffer(target, sregion.base, 2));
00105 isc_buffer_forward(source, 2);
00106 return (dns_name_fromwire(&name, source, dctx, options, target));
00107 }
00108
00109 static inline isc_result_t
00110 towire_in_kx(ARGS_TOWIRE) {
00111 dns_name_t name;
00112 dns_offsets_t offsets;
00113 isc_region_t region;
00114
00115 REQUIRE(rdata->type == 36);
00116 REQUIRE(rdata->rdclass == 1);
00117 REQUIRE(rdata->length != 0);
00118
00119 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
00120 dns_rdata_toregion(rdata, ®ion);
00121 RETERR(mem_tobuffer(target, region.base, 2));
00122 isc_region_consume(®ion, 2);
00123
00124 dns_name_init(&name, offsets);
00125 dns_name_fromregion(&name, ®ion);
00126
00127 return (dns_name_towire(&name, cctx, target));
00128 }
00129
00130 static inline int
00131 compare_in_kx(ARGS_COMPARE) {
00132 dns_name_t name1;
00133 dns_name_t name2;
00134 isc_region_t region1;
00135 isc_region_t region2;
00136 int order;
00137
00138 REQUIRE(rdata1->type == rdata2->type);
00139 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00140 REQUIRE(rdata1->type == 36);
00141 REQUIRE(rdata1->rdclass == 1);
00142 REQUIRE(rdata1->length != 0);
00143 REQUIRE(rdata2->length != 0);
00144
00145 order = memcmp(rdata1->data, rdata2->data, 2);
00146 if (order != 0)
00147 return (order < 0 ? -1 : 1);
00148
00149 dns_name_init(&name1, NULL);
00150 dns_name_init(&name2, NULL);
00151
00152 dns_rdata_toregion(rdata1, ®ion1);
00153 dns_rdata_toregion(rdata2, ®ion2);
00154
00155 isc_region_consume(®ion1, 2);
00156 isc_region_consume(®ion2, 2);
00157
00158 dns_name_fromregion(&name1, ®ion1);
00159 dns_name_fromregion(&name2, ®ion2);
00160
00161 return (dns_name_rdatacompare(&name1, &name2));
00162 }
00163
00164 static inline isc_result_t
00165 fromstruct_in_kx(ARGS_FROMSTRUCT) {
00166 dns_rdata_in_kx_t *kx = source;
00167 isc_region_t region;
00168
00169 REQUIRE(type == 36);
00170 REQUIRE(rdclass == 1);
00171 REQUIRE(source != NULL);
00172 REQUIRE(kx->common.rdtype == type);
00173 REQUIRE(kx->common.rdclass == rdclass);
00174
00175 UNUSED(type);
00176 UNUSED(rdclass);
00177
00178 RETERR(uint16_tobuffer(kx->preference, target));
00179 dns_name_toregion(&kx->exchange, ®ion);
00180 return (isc_buffer_copyregion(target, ®ion));
00181 }
00182
00183 static inline isc_result_t
00184 tostruct_in_kx(ARGS_TOSTRUCT) {
00185 isc_region_t region;
00186 dns_rdata_in_kx_t *kx = target;
00187 dns_name_t name;
00188
00189 REQUIRE(rdata->type == 36);
00190 REQUIRE(rdata->rdclass == 1);
00191 REQUIRE(target != NULL);
00192 REQUIRE(rdata->length != 0);
00193
00194 kx->common.rdclass = rdata->rdclass;
00195 kx->common.rdtype = rdata->type;
00196 ISC_LINK_INIT(&kx->common, link);
00197
00198 dns_name_init(&name, NULL);
00199 dns_rdata_toregion(rdata, ®ion);
00200
00201 kx->preference = uint16_fromregion(®ion);
00202 isc_region_consume(®ion, 2);
00203
00204 dns_name_fromregion(&name, ®ion);
00205 dns_name_init(&kx->exchange, NULL);
00206 RETERR(name_duporclone(&name, mctx, &kx->exchange));
00207 kx->mctx = mctx;
00208 return (ISC_R_SUCCESS);
00209 }
00210
00211 static inline void
00212 freestruct_in_kx(ARGS_FREESTRUCT) {
00213 dns_rdata_in_kx_t *kx = source;
00214
00215 REQUIRE(source != NULL);
00216 REQUIRE(kx->common.rdclass == 1);
00217 REQUIRE(kx->common.rdtype == 36);
00218
00219 if (kx->mctx == NULL)
00220 return;
00221
00222 dns_name_free(&kx->exchange, kx->mctx);
00223 kx->mctx = NULL;
00224 }
00225
00226 static inline isc_result_t
00227 additionaldata_in_kx(ARGS_ADDLDATA) {
00228 dns_name_t name;
00229 dns_offsets_t offsets;
00230 isc_region_t region;
00231
00232 REQUIRE(rdata->type == 36);
00233 REQUIRE(rdata->rdclass == 1);
00234
00235 dns_name_init(&name, offsets);
00236 dns_rdata_toregion(rdata, ®ion);
00237 isc_region_consume(®ion, 2);
00238 dns_name_fromregion(&name, ®ion);
00239
00240 return ((add)(arg, &name, dns_rdatatype_a));
00241 }
00242
00243 static inline isc_result_t
00244 digest_in_kx(ARGS_DIGEST) {
00245 isc_region_t r1, r2;
00246 dns_name_t name;
00247
00248 REQUIRE(rdata->type == 36);
00249 REQUIRE(rdata->rdclass == 1);
00250
00251 dns_rdata_toregion(rdata, &r1);
00252 r2 = r1;
00253 isc_region_consume(&r2, 2);
00254 r1.length = 2;
00255 RETERR((digest)(arg, &r1));
00256 dns_name_init(&name, NULL);
00257 dns_name_fromregion(&name, &r2);
00258 return (dns_name_digest(&name, digest, arg));
00259 }
00260
00261 static inline isc_boolean_t
00262 checkowner_in_kx(ARGS_CHECKOWNER) {
00263
00264 REQUIRE(type == 36);
00265 REQUIRE(rdclass == 1);
00266
00267 UNUSED(name);
00268 UNUSED(type);
00269 UNUSED(rdclass);
00270 UNUSED(wildcard);
00271
00272 return (ISC_TRUE);
00273 }
00274
00275 static inline isc_boolean_t
00276 checknames_in_kx(ARGS_CHECKNAMES) {
00277
00278 REQUIRE(rdata->type == 36);
00279 REQUIRE(rdata->rdclass == 1);
00280
00281 UNUSED(rdata);
00282 UNUSED(owner);
00283 UNUSED(bad);
00284
00285 return (ISC_TRUE);
00286 }
00287
00288 static inline int
00289 casecompare_in_kx(ARGS_COMPARE) {
00290 return (compare_in_kx(rdata1, rdata2));
00291 }
00292
00293 #endif