2015-09-18 07:43:43 +10:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2015-09-18 07:43:43 +10:00
|
|
|
*
|
2021-06-03 08:37:05 +02:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2015-09-18 07:43:43 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RDATA_GENERIC_TALINK_58_C
|
|
|
|
#define RDATA_GENERIC_TALINK_58_C
|
|
|
|
|
|
|
|
#define RRTYPE_TALINK_ATTRIBUTES 0
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_talink(ARGS_FROMTEXT) {
|
|
|
|
isc_token_t token;
|
|
|
|
dns_name_t name;
|
2015-09-18 07:43:43 +10:00
|
|
|
isc_buffer_t buffer;
|
2020-02-13 14:44:37 -08:00
|
|
|
int i;
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
REQUIRE(type == dns_rdatatype_talink);
|
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(callbacks);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (origin == NULL) {
|
2015-09-18 07:43:43 +10:00
|
|
|
origin = dns_rootname;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token,
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_tokentype_string, false));
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
buffer_fromregion(&buffer, &token.value.as_region);
|
2020-02-12 13:59:18 +01:00
|
|
|
RETTOK(dns_name_fromtext(&name, &buffer, origin, options,
|
|
|
|
target));
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_talink(ARGS_TOTEXT) {
|
2015-09-18 07:43:43 +10:00
|
|
|
isc_region_t dregion;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t prev;
|
|
|
|
dns_name_t next;
|
|
|
|
dns_name_t prefix;
|
|
|
|
bool sub;
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
dns_name_init(&prev, NULL);
|
|
|
|
dns_name_init(&next, NULL);
|
|
|
|
dns_name_init(&prefix, NULL);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &dregion);
|
|
|
|
|
|
|
|
dns_name_fromregion(&prev, &dregion);
|
|
|
|
isc_region_consume(&dregion, name_length(&prev));
|
|
|
|
|
|
|
|
dns_name_fromregion(&next, &dregion);
|
|
|
|
isc_region_consume(&dregion, name_length(&next));
|
|
|
|
|
|
|
|
sub = name_prefix(&prev, tctx->origin, &prefix);
|
|
|
|
RETERR(dns_name_totext(&prefix, sub, target));
|
|
|
|
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
sub = name_prefix(&next, tctx->origin, &prefix);
|
2020-02-12 13:59:18 +01:00
|
|
|
return (dns_name_totext(&prefix, sub, target));
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_talink(ARGS_FROMWIRE) {
|
2015-09-18 07:43:43 +10:00
|
|
|
dns_name_t prev;
|
|
|
|
dns_name_t next;
|
|
|
|
|
|
|
|
REQUIRE(type == dns_rdatatype_talink);
|
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
|
2022-05-05 16:36:52 +01:00
|
|
|
dctx = dns_decompress_setpermitted(dctx, false);
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
dns_name_init(&prev, NULL);
|
|
|
|
dns_name_init(&next, NULL);
|
|
|
|
|
|
|
|
RETERR(dns_name_fromwire(&prev, source, dctx, options, target));
|
2020-02-12 13:59:18 +01:00
|
|
|
return (dns_name_fromwire(&next, source, dctx, options, target));
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_talink(ARGS_TOWIRE) {
|
|
|
|
isc_region_t sregion;
|
|
|
|
dns_name_t prev;
|
|
|
|
dns_name_t next;
|
2015-09-18 07:43:43 +10:00
|
|
|
dns_offsets_t moffsets;
|
|
|
|
dns_offsets_t roffsets;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
2022-05-05 14:52:44 +01:00
|
|
|
dns_compress_setpermitted(cctx, false);
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
dns_name_init(&prev, moffsets);
|
|
|
|
dns_name_init(&next, roffsets);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sregion);
|
|
|
|
|
|
|
|
dns_name_fromregion(&prev, &sregion);
|
|
|
|
isc_region_consume(&sregion, name_length(&prev));
|
|
|
|
RETERR(dns_name_towire(&prev, cctx, target));
|
|
|
|
|
|
|
|
dns_name_fromregion(&next, &sregion);
|
|
|
|
isc_region_consume(&sregion, name_length(&next));
|
2020-02-12 13:59:18 +01:00
|
|
|
return (dns_name_towire(&next, cctx, target));
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_talink(ARGS_COMPARE) {
|
2015-09-18 07:43:43 +10:00
|
|
|
isc_region_t region1;
|
|
|
|
isc_region_t region2;
|
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_talink);
|
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, ®ion1);
|
|
|
|
dns_rdata_toregion(rdata2, ®ion2);
|
|
|
|
return (isc_region_compare(®ion1, ®ion2));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_talink(ARGS_FROMSTRUCT) {
|
2015-09-18 07:43:43 +10:00
|
|
|
dns_rdata_talink_t *talink = source;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_region_t region;
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
REQUIRE(type == dns_rdatatype_talink);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(talink != NULL);
|
2015-09-18 07:43:43 +10:00
|
|
|
REQUIRE(talink->common.rdtype == type);
|
|
|
|
REQUIRE(talink->common.rdclass == rdclass);
|
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
|
|
|
|
dns_name_toregion(&talink->prev, ®ion);
|
|
|
|
RETERR(isc_buffer_copyregion(target, ®ion));
|
|
|
|
dns_name_toregion(&talink->next, ®ion);
|
2020-02-12 13:59:18 +01:00
|
|
|
return (isc_buffer_copyregion(target, ®ion));
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_talink(ARGS_TOSTRUCT) {
|
|
|
|
isc_region_t region;
|
2015-09-18 07:43:43 +10:00
|
|
|
dns_rdata_talink_t *talink = target;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t name;
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(talink != NULL);
|
2015-09-18 07:43:43 +10:00
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
talink->common.rdclass = rdata->rdclass;
|
|
|
|
talink->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&talink->common, link);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_fromregion(&name, ®ion);
|
|
|
|
isc_region_consume(®ion, name_length(&name));
|
|
|
|
dns_name_init(&talink->prev, NULL);
|
2021-10-06 12:57:24 +02:00
|
|
|
name_duporclone(&name, mctx, &talink->prev);
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
dns_name_fromregion(&name, ®ion);
|
|
|
|
isc_region_consume(®ion, name_length(&name));
|
|
|
|
dns_name_init(&talink->next, NULL);
|
2021-10-06 12:57:24 +02:00
|
|
|
name_duporclone(&name, mctx, &talink->next);
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
talink->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
freestruct_talink(ARGS_FREESTRUCT) {
|
2015-09-18 07:43:43 +10:00
|
|
|
dns_rdata_talink_t *talink = source;
|
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(talink != NULL);
|
2015-09-18 07:43:43 +10:00
|
|
|
REQUIRE(talink->common.rdtype == dns_rdatatype_talink);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (talink->mctx == NULL) {
|
2015-09-18 07:43:43 +10:00
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2015-09-18 07:43:43 +10:00
|
|
|
|
|
|
|
dns_name_free(&talink->prev, talink->mctx);
|
|
|
|
dns_name_free(&talink->next, talink->mctx);
|
|
|
|
talink->mctx = NULL;
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
additionaldata_talink(ARGS_ADDLDATA) {
|
2019-07-05 16:20:20 +10:00
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
|
|
|
|
2015-09-18 07:43:43 +10:00
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2015-09-18 07:43:43 +10:00
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
digest_talink(ARGS_DIGEST) {
|
2015-09-18 07:43:43 +10:00
|
|
|
isc_region_t r;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
return ((digest)(arg, &r));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checkowner_talink(ARGS_CHECKOWNER) {
|
2015-09-18 07:43:43 +10:00
|
|
|
REQUIRE(type == dns_rdatatype_talink);
|
|
|
|
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(wildcard);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames_talink(ARGS_CHECKNAMES) {
|
2015-09-18 07:43:43 +10:00
|
|
|
REQUIRE(rdata->type == dns_rdatatype_talink);
|
|
|
|
|
|
|
|
UNUSED(bad);
|
|
|
|
UNUSED(owner);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2015-09-18 07:43:43 +10:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
casecompare_talink(ARGS_COMPARE) {
|
2015-09-18 07:43:43 +10:00
|
|
|
return (compare_talink(rdata1, rdata2));
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_TALINK_58_C */
|