naptr_35.c revision 85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews/*
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington * Copyright (C) 1999-2001 Internet Software Consortium.
c52dde922980a55e22f6f9f9f97544922a9d67f8Tinderbox User *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Permission to use, copy, modify, and distribute this software for any
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * purpose with or without fee is hereby granted, provided that the above
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * copyright notice and this permission notice appear in all copies.
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User *
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* $Id: naptr_35.c,v 1.42 2001/06/21 04:00:45 marka Exp $ */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* RFC 2915 */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User#ifndef RDATA_IN_1_NAPTR_35_C
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User#define RDATA_IN_1_NAPTR_35_C
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User#define RRTYPE_NAPTR_ATTRIBUTES (0)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userstatic inline isc_result_t
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userfromtext_in_naptr(ARGS_FROMTEXT) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_token_t token;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t name;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_buffer_t buffer;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(type == 35);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdclass == 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User UNUSED(type);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User UNUSED(rdclass);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Order.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
c52dde922980a55e22f6f9f9f97544922a9d67f8Tinderbox User ISC_FALSE));
c52dde922980a55e22f6f9f9f97544922a9d67f8Tinderbox User if (token.value.as_ulong > 0xffff)
c52dde922980a55e22f6f9f9f97544922a9d67f8Tinderbox User RETTOK(ISC_R_RANGE);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(token.value.as_ulong, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Preference.
c52dde922980a55e22f6f9f9f97544922a9d67f8Tinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ISC_FALSE));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (token.value.as_ulong > 0xffff)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(ISC_R_RANGE);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(token.value.as_ulong, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Flags.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ISC_FALSE));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Service.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ISC_FALSE));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Regexp.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ISC_FALSE));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein ISC_FALSE));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_name_init(&name, NULL);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein buffer_fromregion(&buffer, &token.value.as_region);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein origin = (origin != NULL) ? origin : dns_rootname;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (ISC_R_SUCCESS);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User}
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userstatic inline isc_result_t
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Usertotext_in_naptr(ARGS_TOTEXT) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_t region;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t name;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t prefix;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_boolean_t sub;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User char buf[sizeof "64000"];
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User unsigned short num;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata->type == 35);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata->rdclass == 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata->length != 0);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_init(&name, NULL);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_name_init(&prefix, NULL);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_rdata_toregion(rdata, &region);
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Order.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater */
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater num = uint16_fromregion(&region);
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater isc_region_consume(&region, 2);
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater sprintf(buf, "%u", num);
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater RETERR(str_totext(buf, target));
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User RETERR(str_totext(" ", target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Preference.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User num = uint16_fromregion(&region);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater isc_region_consume(&region, 2);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater sprintf(buf, "%u", num);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(str_totext(buf, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(str_totext(" ", target));
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Flags.
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater */
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User RETERR(txt_totext(&region, target));
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater RETERR(str_totext(" ", target));
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater /*
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User * Service.
9d557856c2a19ec95ee73245f60a92f8675cf5baTinderbox User */
43b94483957d3168796a816ed86cf097518817dcTinderbox User RETERR(txt_totext(&region, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(str_totext(" ", target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater /*
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User * Regexp.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User RETERR(txt_totext(&region, target));
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User RETERR(str_totext(" ", target));
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User */
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_name_fromregion(&name, &region);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User sub = name_prefix(&name, tctx->origin, &prefix);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User return (dns_name_totext(&prefix, sub, target));
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User}
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox Userstatic inline isc_result_t
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userfromwire_in_naptr(ARGS_FROMWIRE) {
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater dns_name_t name;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_t sr;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater REQUIRE(type == 35);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater REQUIRE(rdclass == 1);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User UNUSED(type);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User UNUSED(rdclass);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater dns_name_init(&name, NULL);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Order, preference.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_buffer_activeregion(source, &sr);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (sr.length < 4)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (ISC_R_UNEXPECTEDEND);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(mem_tobuffer(target, sr.base, 4));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_buffer_forward(source, 4);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Flags.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(txt_fromwire(source, target));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Service.
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(txt_fromwire(source, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User /*
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User * Regexp.
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User */
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User RETERR(txt_fromwire(source, target));
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User /*
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User * Replacement.
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User */
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User return (dns_name_fromwire(&name, source, dctx, downcase, target));
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User}
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox Userstatic inline isc_result_t
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Usertowire_in_naptr(ARGS_TOWIRE) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t name;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_offsets_t offsets;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_t sr;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata->type == 35);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata->rdclass == 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata->length != 0);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Order, preference.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_rdata_toregion(rdata, &sr);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(mem_tobuffer(target, sr.base, 4));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&sr, 4);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Flags.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&sr, sr.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Service.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater */
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&sr, sr.base[0] + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater /*
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater * Regexp.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater isc_region_consume(&sr, sr.base[0] + 1);
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater /*
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater * Replacement.
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater */
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater dns_name_init(&name, offsets);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_fromregion(&name, &sr);
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater return (dns_name_towire(&name, cctx, target));
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater}
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater
60a900e83bab52c3f023be66654f3ab023172778Automatic Updaterstatic inline int
60a900e83bab52c3f023be66654f3ab023172778Automatic Updatercompare_in_naptr(ARGS_COMPARE) {
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater dns_name_t name1;
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater dns_name_t name2;
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater isc_region_t region1;
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater isc_region_t region2;
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater int order, len;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata1->type == rdata2->type);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata1->rdclass == rdata2->rdclass);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata1->type == 35);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata1->rdclass == 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdata1->length != 0);
2628293c6edaa41ed1407c42bb196083901e087bAutomatic Updater REQUIRE(rdata2->length != 0);
2628293c6edaa41ed1407c42bb196083901e087bAutomatic Updater
2628293c6edaa41ed1407c42bb196083901e087bAutomatic Updater dns_rdata_toregion(rdata1, &region1);
2628293c6edaa41ed1407c42bb196083901e087bAutomatic Updater dns_rdata_toregion(rdata2, &region2);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Order, preference.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User order = memcmp(region1.base, region2.base, 4);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (order != 0)
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User return (order < 0 ? -1 : 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&region1, 4);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&region2, 4);
6f1205897504b8f50b1785975482c995888dd630Tinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Flags.
6f1205897504b8f50b1785975482c995888dd630Tinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User len = ISC_MIN(region1.base[0], region2.base[0]);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User order = memcmp(region1.base, region2.base, len + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (order != 0)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (order < 0 ? -1 : 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&region1, region1.base[0] + 1);
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews isc_region_consume(&region2, region2.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Service.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein len = ISC_MIN(region1.base[0], region2.base[0]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein order = memcmp(region1.base, region2.base, len + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (order != 0)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (order < 0 ? -1 : 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&region1, region1.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&region2, region2.base[0] + 1);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Regexp.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein len = ISC_MIN(region1.base[0], region2.base[0]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein order = memcmp(region1.base, region2.base, len + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (order != 0)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (order < 0 ? -1 : 1);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews isc_region_consume(&region1, region1.base[0] + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&region2, region2.base[0] + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews /*
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User * Replacement.
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User */
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews dns_name_init(&name1, NULL);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews dns_name_init(&name2, NULL);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews dns_name_fromregion(&name1, &region1);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews dns_name_fromregion(&name2, &region2);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (dns_name_rdatacompare(&name1, &name2));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein}
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userstatic inline isc_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfromstruct_in_naptr(ARGS_FROMSTRUCT) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_rdata_in_naptr_t *naptr = source;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_t region;
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews REQUIRE(type == 35);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(rdclass == 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(source != NULL);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->common.rdtype == type);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->common.rdclass == rdclass);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->flags != NULL || naptr->flags_len == 0);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(naptr->service != NULL && naptr->service_len == 0);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->regexp != NULL && naptr->regexp_len == 0);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein UNUSED(type);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein UNUSED(rdclass);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(uint16_tobuffer(naptr->order, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(naptr->preference, target));
97e74139b19368e385a3564746d42db70879195eAutomatic Updater RETERR(uint8_tobuffer(naptr->flags_len, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(mem_tobuffer(target, naptr->flags, naptr->flags_len));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint8_tobuffer(naptr->service_len, target));
43b94483957d3168796a816ed86cf097518817dcTinderbox User RETERR(mem_tobuffer(target, naptr->service, naptr->service_len));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User RETERR(uint8_tobuffer(naptr->regexp_len, target));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User RETERR(mem_tobuffer(target, naptr->regexp, naptr->regexp_len));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User dns_name_toregion(&naptr->replacement, &region);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (isc_buffer_copyregion(target, &region));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User}
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userstatic inline isc_result_t
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Usertostruct_in_naptr(ARGS_TOSTRUCT) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_rdata_in_naptr_t *naptr = target;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_t r;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_result_t result;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t name;
52ece689e0265f9a3e518de5b2539e749f6d35acMark Andrews
52ece689e0265f9a3e518de5b2539e749f6d35acMark Andrews REQUIRE(rdata->type == 35);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata->rdclass == 1);
52ece689e0265f9a3e518de5b2539e749f6d35acMark Andrews REQUIRE(target != NULL);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User REQUIRE(rdata->length != 0);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User naptr->common.rdclass = rdata->rdclass;
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User naptr->common.rdtype = rdata->type;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ISC_LINK_INIT(&naptr->common, link);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User naptr->flags = NULL;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->service = NULL;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->regexp = NULL;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User dns_rdata_toregion(rdata, &r);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->order = uint16_fromregion(&r);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r, 2);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User naptr->preference = uint16_fromregion(&r);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r, 2);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->flags_len = uint8_fromregion(&r);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r, 1);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User INSIST(naptr->flags_len <= r.length);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (naptr->flags == NULL)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User goto cleanup;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r, naptr->flags_len);
52ece689e0265f9a3e518de5b2539e749f6d35acMark Andrews
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->service_len = uint8_fromregion(&r);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r, 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein INSIST(naptr->service_len <= r.length);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->service = mem_maybedup(mctx, r.base, naptr->service_len);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (naptr->service == NULL)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein goto cleanup;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&r, naptr->service_len);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->regexp_len = uint8_fromregion(&r);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews isc_region_consume(&r, 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User INSIST(naptr->regexp_len <= r.length);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews if (naptr->regexp == NULL)
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User goto cleanup;
dba3c818ae00b10388d31703e86a28415db398acTinderbox User isc_region_consume(&r, naptr->regexp_len);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User
dba3c818ae00b10388d31703e86a28415db398acTinderbox User dns_name_init(&name, NULL);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User dns_name_fromregion(&name, &r);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User dns_name_init(&naptr->replacement, NULL);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User result = name_duporclone(&name, mctx, &naptr->replacement);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User if (result != ISC_R_SUCCESS)
dba3c818ae00b10388d31703e86a28415db398acTinderbox User goto cleanup;
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User naptr->mctx = mctx;
dba3c818ae00b10388d31703e86a28415db398acTinderbox User return (ISC_R_SUCCESS);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User cleanup:
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (mctx != NULL && naptr->flags != NULL)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_mem_free(mctx, naptr->flags);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (mctx != NULL && naptr->service != NULL)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_mem_free(mctx, naptr->service);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (mctx != NULL && naptr->regexp != NULL)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_mem_free(mctx, naptr->regexp);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (ISC_R_NOMEMORY);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User}
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updaterstatic inline void
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updaterfreestruct_in_naptr(ARGS_FREESTRUCT) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_rdata_in_naptr_t *naptr = source;
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updater
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updater REQUIRE(source != NULL);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(naptr->common.rdclass == 1);
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updater REQUIRE(naptr->common.rdtype == 35);
1c51f79aba598e5e20bde66aea0237e347f6d5ceAutomatic Updater
1c51f79aba598e5e20bde66aea0237e347f6d5ceAutomatic Updater if (naptr->mctx == NULL)
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updater return;
1c51f79aba598e5e20bde66aea0237e347f6d5ceAutomatic Updater
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updater if (naptr->flags != NULL)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_mem_free(naptr->mctx, naptr->flags);
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User if (naptr->service != NULL)
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater isc_mem_free(naptr->mctx, naptr->service);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (naptr->regexp != NULL)
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User isc_mem_free(naptr->mctx, naptr->regexp);
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater dns_name_free(&naptr->replacement, naptr->mctx);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->mctx = NULL;
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater}
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater
9d557856c2a19ec95ee73245f60a92f8675cf5baTinderbox Userstatic inline isc_result_t
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updateradditionaldata_in_naptr(ARGS_ADDLDATA) {
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater dns_name_t name;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User dns_offsets_t offsets;
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User isc_region_t sr;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User dns_rdatatype_t atype;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User unsigned int i, flagslen;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User char *cp;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata->type == 35);
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User REQUIRE(rdata->rdclass == 1);
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User * Order, preference.
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_rdata_toregion(rdata, &sr);
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User isc_region_consume(&sr, 4);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User /*
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User * Flags.
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User */
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater atype = 0;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User flagslen = sr.base[0];
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein cp = (char *)&sr.base[1];
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User for (i = 0; i < flagslen; i++, cp++) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (*cp == 'S' || *cp == 's') {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein atype = dns_rdatatype_srv;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein break;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein }
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (*cp == 'A' || *cp == 'a') {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein atype = dns_rdatatype_a;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein break;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein }
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein }
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(&sr, flagslen + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Service.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&sr, sr.base[0] + 1);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Regexp.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&sr, sr.base[0] + 1);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Replacement.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater */
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater dns_name_init(&name, offsets);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_fromregion(&name, &sr);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if (atype != 0)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return ((add)(arg, &name, atype));
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater return (ISC_R_SUCCESS);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User}
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updaterstatic inline isc_result_t
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userdigest_in_naptr(ARGS_DIGEST) {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_t r1, r2;
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater unsigned int length, n;
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater isc_result_t result;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_t name;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater REQUIRE(rdata->type == 35);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(rdata->rdclass == 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater dns_rdata_toregion(rdata, &r1);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater r2 = r1;
9d557856c2a19ec95ee73245f60a92f8675cf5baTinderbox User length = 0;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Order, preference.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User length += 4;
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater isc_region_consume(&r2, 4);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Flags.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater n = r2.base[0] + 1;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User length += n;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r2, n);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater /*
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Service.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User n = r2.base[0] + 1;
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater length += n;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(&r2, n);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Regexp.
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater */
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater n = r2.base[0] + 1;
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater length += n;
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater isc_region_consume(&r2, n);
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater /*
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater * Digest the RR up to the replacement name.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater */
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater r1.length = length;
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater result = (digest)(arg, &r1);
a3f8c8e20780e488141d200acdfea6c5f3303513Automatic Updater if (result != ISC_R_SUCCESS)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (result);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /*
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_init(&name, NULL);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_name_fromregion(&name, &r2);
f3d1a0ba5228251d902a6acf3c8b05cb6842f992Automatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (dns_name_digest(&name, digest, arg));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User}
f3d1a0ba5228251d902a6acf3c8b05cb6842f992Automatic Updater
f3d1a0ba5228251d902a6acf3c8b05cb6842f992Automatic Updater#endif /* RDATA_IN_1_NAPTR_35_C */
f3d1a0ba5228251d902a6acf3c8b05cb6842f992Automatic Updater