naptr_35.c revision 2f072c2982861ec2e86e97f8a3ed199fe45c1f70
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/*
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Copyright (C) 1999 Internet Software Consortium.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd *
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Permission to use, copy, modify, and distribute this software for any
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * purpose with or without fee is hereby granted, provided that the above
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * copyright notice and this permission notice appear in all copies.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd *
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * SOFTWARE.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* $Id: naptr_35.c,v 1.13 1999/09/15 23:03:35 explorer Exp $ */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* RFC 2168 */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd#ifndef RDATA_IN_1_NAPTR_35_C
6876da76f91687fee15a706830b990a2c0d55157Trang Do#define RDATA_IN_1_NAPTR_35_C
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sdstatic inline dns_result_t
14ea4bb737263733ad80a36b4f73f681c30a6b45sdfromtext_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_lex_t *lexer, dns_name_t *origin,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_boolean_t downcase, isc_buffer_t *target)
535ec645ca371f1ce298eaf76bf8feb73494f923dduvall{
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_token_t token;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_t name;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_buffer_t buffer;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(type == 35);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdclass == 1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* priority */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh RETERR(uint16_tobuffer(token.value.as_ulong, target));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* weight */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(uint16_tobuffer(token.value.as_ulong, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* flags */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(txt_fromtext(&token.value.as_textregion, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* service */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(txt_fromtext(&token.value.as_textregion, target));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* regexp */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh RETERR(txt_fromtext(&token.value.as_textregion, target));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* replacement */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_init(&name, NULL);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd buffer_fromregion(&buffer, &token.value.as_region,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd ISC_BUFFERTYPE_TEXT);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd origin = (origin != NULL) ? origin : dns_rootname;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd}
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sdstatic inline dns_result_t
dd566498928f08e7c9a79797a40db893c6a4b9fbvntotext_in_naptr(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_buffer_t *target)
dd566498928f08e7c9a79797a40db893c6a4b9fbvn{
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_t region;
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh dns_name_t name;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_t prefix;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_boolean_t sub;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn char buf[sizeof "64000"];
dd566498928f08e7c9a79797a40db893c6a4b9fbvn unsigned short num;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->type == 35);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd REQUIRE(rdata->rdclass == 1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_name_init(&name, NULL);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_name_init(&prefix, NULL);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* priority */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_rdata_toregion(rdata, &region);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd num = uint16_fromregion(&region);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_region_consume(&region, 2);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd sprintf(buf, "%u", num);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(str_totext(buf, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(str_totext(" ", target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
6876da76f91687fee15a706830b990a2c0d55157Trang Do /* weight */
6876da76f91687fee15a706830b990a2c0d55157Trang Do num = uint16_fromregion(&region);
6876da76f91687fee15a706830b990a2c0d55157Trang Do isc_region_consume(&region, 2);
6876da76f91687fee15a706830b990a2c0d55157Trang Do sprintf(buf, "%u", num);
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(str_totext(buf, target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(str_totext(" ", target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do
6876da76f91687fee15a706830b990a2c0d55157Trang Do /* flags */
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(txt_totext(&region, target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(str_totext(" ", target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do
6876da76f91687fee15a706830b990a2c0d55157Trang Do /* service */
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(txt_totext(&region, target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(str_totext(" ", target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do
6876da76f91687fee15a706830b990a2c0d55157Trang Do /* regexp */
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(txt_totext(&region, target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do RETERR(str_totext(" ", target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do
6876da76f91687fee15a706830b990a2c0d55157Trang Do /* replacement */
6876da76f91687fee15a706830b990a2c0d55157Trang Do dns_name_fromregion(&name, &region);
6876da76f91687fee15a706830b990a2c0d55157Trang Do sub = name_prefix(&name, tctx->origin, &prefix);
6876da76f91687fee15a706830b990a2c0d55157Trang Do return(dns_name_totext(&prefix, sub, target));
6876da76f91687fee15a706830b990a2c0d55157Trang Do}
6876da76f91687fee15a706830b990a2c0d55157Trang Do
6876da76f91687fee15a706830b990a2c0d55157Trang Dostatic inline dns_result_t
6876da76f91687fee15a706830b990a2c0d55157Trang Dofromwire_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_buffer_t *source, dns_decompress_t *dctx,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_boolean_t downcase, isc_buffer_t *target)
14ea4bb737263733ad80a36b4f73f681c30a6b45sd{
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_t name;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_region_t sr;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd REQUIRE(type == 35);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd REQUIRE(rdclass == 1);
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx))
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd else
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_name_init(&name, NULL);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* priority, weight */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_buffer_active(source, &sr);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (sr.length < 4)
dd566498928f08e7c9a79797a40db893c6a4b9fbvn return (DNS_R_UNEXPECTEDEND);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(mem_tobuffer(target, sr.base, 4));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_buffer_forward(source, 4);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
1557e65f9d0c6fde875d807c12fc03ea20f50280vn /* flags */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(txt_fromwire(source, target));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* service */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(txt_fromwire(source, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* regexp */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd RETERR(txt_fromwire(source, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* replacement */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (dns_name_fromwire(&name, source, dctx, downcase, target));
14ea4bb737263733ad80a36b4f73f681c30a6b45sd}
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sdstatic inline dns_result_t
dd566498928f08e7c9a79797a40db893c6a4b9fbvntowire_in_naptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_name_t name;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_t sr;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->type == 35);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd REQUIRE(rdata->rdclass == 1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (dns_compress_getedns(cctx) >= 1)
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd else
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* priority, weight */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd dns_rdata_toregion(rdata, &sr);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(mem_tobuffer(target, sr.base, 4));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_consume(&sr, 4);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* flags */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_consume(&sr, sr.base[0] + 1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* service */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
535ec645ca371f1ce298eaf76bf8feb73494f923dduvall isc_region_consume(&sr, sr.base[0] + 1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
1557e65f9d0c6fde875d807c12fc03ea20f50280vn /* regexp */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_consume(&sr, sr.base[0] + 1);
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
1557e65f9d0c6fde875d807c12fc03ea20f50280vn /* replacement */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_init(&name, NULL);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_fromregion(&name, &sr);
535ec645ca371f1ce298eaf76bf8feb73494f923dduvall return (dns_name_towire(&name, cctx, target));
1557e65f9d0c6fde875d807c12fc03ea20f50280vn}
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
1557e65f9d0c6fde875d807c12fc03ea20f50280vnstatic inline int
1557e65f9d0c6fde875d807c12fc03ea20f50280vncompare_in_naptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
1557e65f9d0c6fde875d807c12fc03ea20f50280vn dns_name_t name1;
1557e65f9d0c6fde875d807c12fc03ea20f50280vn dns_name_t name2;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_t region1;
6876da76f91687fee15a706830b990a2c0d55157Trang Do isc_region_t region2;
1557e65f9d0c6fde875d807c12fc03ea20f50280vn int result;
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
1557e65f9d0c6fde875d807c12fc03ea20f50280vn REQUIRE(rdata1->type == rdata2->type);
1da218965c488f7b3d6e513e49cda33fdbc08b7fvn REQUIRE(rdata1->rdclass == rdata2->rdclass);
ef8846857fcf954444cdc77e72249afef48377d2rb REQUIRE(rdata1->type == 35);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata1->rdclass == 1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_rdata_toregion(rdata1, &region1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_rdata_toregion(rdata2, &region2);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* priority, weight */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn result = memcmp(region1.base, region2.base, 4);
535ec645ca371f1ce298eaf76bf8feb73494f923dduvall if (result != 0)
ef8846857fcf954444cdc77e72249afef48377d2rb return (result < 0 ? -1 : 1);
ef8846857fcf954444cdc77e72249afef48377d2rb isc_region_consume(&region1, 4);
ef8846857fcf954444cdc77e72249afef48377d2rb isc_region_consume(&region2, 4);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh /* flags */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh result = memcmp(region1.base, region2.base, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh if (result != 0)
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh return (result < 0 ? -1 : 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region1, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region2, region2.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh /* service */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh result = memcmp(region1.base, region2.base, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh if (result != 0)
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh return (result < 0 ? -1 : 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region1, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region2, region2.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh /* regexp */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh result = memcmp(region1.base, region2.base, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh if (result != 0)
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh return (result < 0 ? -1 : 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region1, region1.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh isc_region_consume(&region2, region2.base[0] + 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh /* replacement */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh dns_name_init(&name1, NULL);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh dns_name_init(&name2, NULL);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh dns_name_fromregion(&name1, &region1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh dns_name_fromregion(&name2, &region2);
6876da76f91687fee15a706830b990a2c0d55157Trang Do
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh return (dns_name_rdatacompare(&name1, &name2));
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh}
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephhstatic inline dns_result_t
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephhfromstruct_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh void *source, isc_buffer_t *target)
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh{
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh REQUIRE(type == 35);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh REQUIRE(rdclass == 1);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh source = source;
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh target = target;
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh return (DNS_R_NOTIMPLEMENTED);
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh}
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephhstatic inline dns_result_t
dd566498928f08e7c9a79797a40db893c6a4b9fbvntostruct_in_naptr(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
ef8846857fcf954444cdc77e72249afef48377d2rb
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->type == 35);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->rdclass == 1);
ef8846857fcf954444cdc77e72249afef48377d2rb
dd566498928f08e7c9a79797a40db893c6a4b9fbvn target = target;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn mctx = mctx;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn return (DNS_R_NOTIMPLEMENTED);
13faa91230bde46da937bf33010b9accc5bdeb59sd}
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
ef8846857fcf954444cdc77e72249afef48377d2rbstatic inline void
dd566498928f08e7c9a79797a40db893c6a4b9fbvnfreestruct_in_naptr(void *source) {
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(source != NULL);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(ISC_FALSE);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn}
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
535ec645ca371f1ce298eaf76bf8feb73494f923dduvallstatic inline dns_result_t
13faa91230bde46da937bf33010b9accc5bdeb59sdadditionaldata_in_naptr(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
13faa91230bde46da937bf33010b9accc5bdeb59sd void *arg)
13faa91230bde46da937bf33010b9accc5bdeb59sd{
13faa91230bde46da937bf33010b9accc5bdeb59sd REQUIRE(rdata->type == 35);
6876da76f91687fee15a706830b990a2c0d55157Trang Do REQUIRE(rdata->rdclass == 1);
13faa91230bde46da937bf33010b9accc5bdeb59sd
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /*
13faa91230bde46da937bf33010b9accc5bdeb59sd * We do not currently do type SRV additional data section
13faa91230bde46da937bf33010b9accc5bdeb59sd * processing for terminal NAPTRs.
13faa91230bde46da937bf33010b9accc5bdeb59sd */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn (void)add;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn (void)arg;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (DNS_R_SUCCESS);
13faa91230bde46da937bf33010b9accc5bdeb59sd}
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
13faa91230bde46da937bf33010b9accc5bdeb59sdstatic inline dns_result_t
dd566498928f08e7c9a79797a40db893c6a4b9fbvndigest_in_naptr(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_t r1, r2;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn unsigned int length, n;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_result_t result;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_name_t name;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->type == 35);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn REQUIRE(rdata->rdclass == 1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn dns_rdata_toregion(rdata, &r1);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn r2 = r1;
1557e65f9d0c6fde875d807c12fc03ea20f50280vn length = 0;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* priority, weight */
1557e65f9d0c6fde875d807c12fc03ea20f50280vn length += 4;
1557e65f9d0c6fde875d807c12fc03ea20f50280vn isc_region_consume(&r2, 4);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* flags */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn n = r2.base[0] + 1;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn length += n;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_consume(&r2, n);
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* service */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn n = r2.base[0] + 1;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn length += n;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn isc_region_consume(&r2, n);
1557e65f9d0c6fde875d807c12fc03ea20f50280vn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* regexp */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd n = r2.base[0] + 1;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd length += n;
14ea4bb737263733ad80a36b4f73f681c30a6b45sd isc_region_consume(&r2, n);
ef8846857fcf954444cdc77e72249afef48377d2rb
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /*
ef8846857fcf954444cdc77e72249afef48377d2rb * Digest the RR up to the replacement name.
dd566498928f08e7c9a79797a40db893c6a4b9fbvn */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn r1.length = length;
ef8846857fcf954444cdc77e72249afef48377d2rb result = (digest)(arg, &r1);
ef8846857fcf954444cdc77e72249afef48377d2rb if (result != DNS_R_SUCCESS)
dd566498928f08e7c9a79797a40db893c6a4b9fbvn return (result);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvn /* replacement */
ef8846857fcf954444cdc77e72249afef48377d2rb
9d2d3daa90dc2bc61e6773e7aa4dc4930f1fb20avn dns_name_init(&name, NULL);
9d2d3daa90dc2bc61e6773e7aa4dc4930f1fb20avn dns_name_fromregion(&name, &r2);
9d2d3daa90dc2bc61e6773e7aa4dc4930f1fb20avn
9d2d3daa90dc2bc61e6773e7aa4dc4930f1fb20avn return (dns_name_digest(&name, digest, arg));
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen}
ef8846857fcf954444cdc77e72249afef48377d2rb
dd566498928f08e7c9a79797a40db893c6a4b9fbvn#endif /* RDATA_IN_1_NAPTR_35_C */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn