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_SRV_33_C
00025 #define RDATA_IN_1_SRV_33_C
00026
00027 #define RRTYPE_SRV_ATTRIBUTES (0)
00028
00029 static inline isc_result_t
00030 fromtext_in_srv(ARGS_FROMTEXT) {
00031 isc_token_t token;
00032 dns_name_t name;
00033 isc_buffer_t buffer;
00034 isc_boolean_t ok;
00035
00036 REQUIRE(type == 33);
00037 REQUIRE(rdclass == 1);
00038
00039 UNUSED(type);
00040 UNUSED(rdclass);
00041 UNUSED(callbacks);
00042
00043
00044
00045
00046 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
00047 ISC_FALSE));
00048 if (token.value.as_ulong > 0xffffU)
00049 RETTOK(ISC_R_RANGE);
00050 RETERR(uint16_tobuffer(token.value.as_ulong, target));
00051
00052
00053
00054
00055 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
00056 ISC_FALSE));
00057 if (token.value.as_ulong > 0xffffU)
00058 RETTOK(ISC_R_RANGE);
00059 RETERR(uint16_tobuffer(token.value.as_ulong, target));
00060
00061
00062
00063
00064 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
00065 ISC_FALSE));
00066 if (token.value.as_ulong > 0xffffU)
00067 RETTOK(ISC_R_RANGE);
00068 RETERR(uint16_tobuffer(token.value.as_ulong, target));
00069
00070
00071
00072
00073 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00074 ISC_FALSE));
00075 dns_name_init(&name, NULL);
00076 buffer_fromregion(&buffer, &token.value.as_region);
00077 origin = (origin != NULL) ? origin : dns_rootname;
00078 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00079 ok = ISC_TRUE;
00080 if ((options & DNS_RDATA_CHECKNAMES) != 0)
00081 ok = dns_name_ishostname(&name, ISC_FALSE);
00082 if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
00083 RETTOK(DNS_R_BADNAME);
00084 if (!ok && callbacks != NULL)
00085 warn_badname(&name, lexer, callbacks);
00086 return (ISC_R_SUCCESS);
00087 }
00088
00089 static inline isc_result_t
00090 totext_in_srv(ARGS_TOTEXT) {
00091 isc_region_t region;
00092 dns_name_t name;
00093 dns_name_t prefix;
00094 isc_boolean_t sub;
00095 char buf[sizeof("64000")];
00096 unsigned short num;
00097
00098 REQUIRE(rdata->type == 33);
00099 REQUIRE(rdata->rdclass == 1);
00100 REQUIRE(rdata->length != 0);
00101
00102 dns_name_init(&name, NULL);
00103 dns_name_init(&prefix, NULL);
00104
00105
00106
00107
00108 dns_rdata_toregion(rdata, ®ion);
00109 num = uint16_fromregion(®ion);
00110 isc_region_consume(®ion, 2);
00111 sprintf(buf, "%u", num);
00112 RETERR(str_totext(buf, target));
00113 RETERR(str_totext(" ", target));
00114
00115
00116
00117
00118 num = uint16_fromregion(®ion);
00119 isc_region_consume(®ion, 2);
00120 sprintf(buf, "%u", num);
00121 RETERR(str_totext(buf, target));
00122 RETERR(str_totext(" ", target));
00123
00124
00125
00126
00127 num = uint16_fromregion(®ion);
00128 isc_region_consume(®ion, 2);
00129 sprintf(buf, "%u", num);
00130 RETERR(str_totext(buf, target));
00131 RETERR(str_totext(" ", target));
00132
00133
00134
00135
00136 dns_name_fromregion(&name, ®ion);
00137 sub = name_prefix(&name, tctx->origin, &prefix);
00138 return (dns_name_totext(&prefix, sub, target));
00139 }
00140
00141 static inline isc_result_t
00142 fromwire_in_srv(ARGS_FROMWIRE) {
00143 dns_name_t name;
00144 isc_region_t sr;
00145
00146 REQUIRE(type == 33);
00147 REQUIRE(rdclass == 1);
00148
00149 UNUSED(type);
00150 UNUSED(rdclass);
00151
00152 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
00153
00154 dns_name_init(&name, NULL);
00155
00156
00157
00158
00159 isc_buffer_activeregion(source, &sr);
00160 if (sr.length < 6)
00161 return (ISC_R_UNEXPECTEDEND);
00162 RETERR(mem_tobuffer(target, sr.base, 6));
00163 isc_buffer_forward(source, 6);
00164
00165
00166
00167
00168 return (dns_name_fromwire(&name, source, dctx, options, target));
00169 }
00170
00171 static inline isc_result_t
00172 towire_in_srv(ARGS_TOWIRE) {
00173 dns_name_t name;
00174 dns_offsets_t offsets;
00175 isc_region_t sr;
00176
00177 REQUIRE(rdata->type == 33);
00178 REQUIRE(rdata->length != 0);
00179
00180 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
00181
00182
00183
00184 dns_rdata_toregion(rdata, &sr);
00185 RETERR(mem_tobuffer(target, sr.base, 6));
00186 isc_region_consume(&sr, 6);
00187
00188
00189
00190
00191 dns_name_init(&name, offsets);
00192 dns_name_fromregion(&name, &sr);
00193 return (dns_name_towire(&name, cctx, target));
00194 }
00195
00196 static inline int
00197 compare_in_srv(ARGS_COMPARE) {
00198 dns_name_t name1;
00199 dns_name_t name2;
00200 isc_region_t region1;
00201 isc_region_t region2;
00202 int order;
00203
00204 REQUIRE(rdata1->type == rdata2->type);
00205 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00206 REQUIRE(rdata1->type == 33);
00207 REQUIRE(rdata1->rdclass == 1);
00208 REQUIRE(rdata1->length != 0);
00209 REQUIRE(rdata2->length != 0);
00210
00211
00212
00213
00214 order = memcmp(rdata1->data, rdata2->data, 6);
00215 if (order != 0)
00216 return (order < 0 ? -1 : 1);
00217
00218
00219
00220
00221 dns_name_init(&name1, NULL);
00222 dns_name_init(&name2, NULL);
00223
00224 dns_rdata_toregion(rdata1, ®ion1);
00225 dns_rdata_toregion(rdata2, ®ion2);
00226
00227 isc_region_consume(®ion1, 6);
00228 isc_region_consume(®ion2, 6);
00229
00230 dns_name_fromregion(&name1, ®ion1);
00231 dns_name_fromregion(&name2, ®ion2);
00232
00233 return (dns_name_rdatacompare(&name1, &name2));
00234 }
00235
00236 static inline isc_result_t
00237 fromstruct_in_srv(ARGS_FROMSTRUCT) {
00238 dns_rdata_in_srv_t *srv = source;
00239 isc_region_t region;
00240
00241 REQUIRE(type == 33);
00242 REQUIRE(rdclass == 1);
00243 REQUIRE(source != NULL);
00244 REQUIRE(srv->common.rdtype == type);
00245 REQUIRE(srv->common.rdclass == rdclass);
00246
00247 UNUSED(type);
00248 UNUSED(rdclass);
00249
00250 RETERR(uint16_tobuffer(srv->priority, target));
00251 RETERR(uint16_tobuffer(srv->weight, target));
00252 RETERR(uint16_tobuffer(srv->port, target));
00253 dns_name_toregion(&srv->target, ®ion);
00254 return (isc_buffer_copyregion(target, ®ion));
00255 }
00256
00257 static inline isc_result_t
00258 tostruct_in_srv(ARGS_TOSTRUCT) {
00259 isc_region_t region;
00260 dns_rdata_in_srv_t *srv = target;
00261 dns_name_t name;
00262
00263 REQUIRE(rdata->rdclass == 1);
00264 REQUIRE(rdata->type == 33);
00265 REQUIRE(target != NULL);
00266 REQUIRE(rdata->length != 0);
00267
00268 srv->common.rdclass = rdata->rdclass;
00269 srv->common.rdtype = rdata->type;
00270 ISC_LINK_INIT(&srv->common, link);
00271
00272 dns_name_init(&name, NULL);
00273 dns_rdata_toregion(rdata, ®ion);
00274 srv->priority = uint16_fromregion(®ion);
00275 isc_region_consume(®ion, 2);
00276 srv->weight = uint16_fromregion(®ion);
00277 isc_region_consume(®ion, 2);
00278 srv->port = uint16_fromregion(®ion);
00279 isc_region_consume(®ion, 2);
00280 dns_name_fromregion(&name, ®ion);
00281 dns_name_init(&srv->target, NULL);
00282 RETERR(name_duporclone(&name, mctx, &srv->target));
00283 srv->mctx = mctx;
00284 return (ISC_R_SUCCESS);
00285 }
00286
00287 static inline void
00288 freestruct_in_srv(ARGS_FREESTRUCT) {
00289 dns_rdata_in_srv_t *srv = source;
00290
00291 REQUIRE(source != NULL);
00292 REQUIRE(srv->common.rdclass == 1);
00293 REQUIRE(srv->common.rdtype == 33);
00294
00295 if (srv->mctx == NULL)
00296 return;
00297
00298 dns_name_free(&srv->target, srv->mctx);
00299 srv->mctx = NULL;
00300 }
00301
00302 static inline isc_result_t
00303 additionaldata_in_srv(ARGS_ADDLDATA) {
00304 dns_name_t name;
00305 dns_offsets_t offsets;
00306 isc_region_t region;
00307
00308 REQUIRE(rdata->type == 33);
00309 REQUIRE(rdata->rdclass == 1);
00310
00311 dns_name_init(&name, offsets);
00312 dns_rdata_toregion(rdata, ®ion);
00313 isc_region_consume(®ion, 6);
00314 dns_name_fromregion(&name, ®ion);
00315
00316 return ((add)(arg, &name, dns_rdatatype_a));
00317 }
00318
00319 static inline isc_result_t
00320 digest_in_srv(ARGS_DIGEST) {
00321 isc_region_t r1, r2;
00322 dns_name_t name;
00323
00324 REQUIRE(rdata->type == 33);
00325 REQUIRE(rdata->rdclass == 1);
00326
00327 dns_rdata_toregion(rdata, &r1);
00328 r2 = r1;
00329 isc_region_consume(&r2, 6);
00330 r1.length = 6;
00331 RETERR((digest)(arg, &r1));
00332 dns_name_init(&name, NULL);
00333 dns_name_fromregion(&name, &r2);
00334 return (dns_name_digest(&name, digest, arg));
00335 }
00336
00337 static inline isc_boolean_t
00338 checkowner_in_srv(ARGS_CHECKOWNER) {
00339
00340 REQUIRE(type == 33);
00341 REQUIRE(rdclass == 1);
00342
00343 UNUSED(name);
00344 UNUSED(type);
00345 UNUSED(rdclass);
00346 UNUSED(wildcard);
00347
00348 return (ISC_TRUE);
00349 }
00350
00351 static inline isc_boolean_t
00352 checknames_in_srv(ARGS_CHECKNAMES) {
00353 isc_region_t region;
00354 dns_name_t name;
00355
00356 REQUIRE(rdata->type == 33);
00357 REQUIRE(rdata->rdclass == 1);
00358
00359 UNUSED(owner);
00360
00361 dns_rdata_toregion(rdata, ®ion);
00362 isc_region_consume(®ion, 6);
00363 dns_name_init(&name, NULL);
00364 dns_name_fromregion(&name, ®ion);
00365 if (!dns_name_ishostname(&name, ISC_FALSE)) {
00366 if (bad != NULL)
00367 dns_name_clone(&name, bad);
00368 return (ISC_FALSE);
00369 }
00370 return (ISC_TRUE);
00371 }
00372
00373 static inline int
00374 casecompare_in_srv(ARGS_COMPARE) {
00375 return (compare_in_srv(rdata1, rdata2));
00376 }
00377
00378 #endif