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