1999-01-19 02:20:26 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00: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.
|
1999-01-19 02:20:26 +00:00
|
|
|
*/
|
|
|
|
|
2021-10-05 16:49:47 +02:00
|
|
|
#pragma once
|
1999-01-19 05:38:36 +00:00
|
|
|
|
2000-04-07 03:54:52 +00:00
|
|
|
#define RRTYPE_HINFO_ATTRIBUTES (0)
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_hinfo(ARGS_FROMTEXT) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_token_t token;
|
2020-02-13 14:44:37 -08:00
|
|
|
int i;
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-03-16 22:42:32 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(origin);
|
2004-02-27 20:41:51 +00:00
|
|
|
UNUSED(options);
|
2001-07-16 03:06:53 +00:00
|
|
|
UNUSED(callbacks);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_hinfo);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2001-11-27 00:56:32 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token,
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_tokentype_qstring, false));
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(txt_fromtext(&token.value.as_textregion, target));
|
1999-01-20 05:20:24 +00:00
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_hinfo(ARGS_TOTEXT) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_region_t region;
|
|
|
|
|
2000-03-16 22:42:32 +00:00
|
|
|
UNUSED(tctx);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
2018-04-17 08:29:14 -07:00
|
|
|
RETERR(txt_totext(®ion, true, target));
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
2018-04-17 08:29:14 -07:00
|
|
|
return (txt_totext(®ion, true, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_hinfo(ARGS_FROMWIRE) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_hinfo);
|
2001-03-16 22:53:20 +00:00
|
|
|
|
|
|
|
UNUSED(type);
|
2000-03-16 22:42:32 +00:00
|
|
|
UNUSED(dctx);
|
|
|
|
UNUSED(rdclass);
|
2004-02-27 20:41:51 +00:00
|
|
|
UNUSED(options);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(txt_fromwire(source, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
return (txt_fromwire(source, target));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_hinfo(ARGS_TOWIRE) {
|
2000-03-16 22:42:32 +00:00
|
|
|
UNUSED(cctx);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-22 05:02:49 +00:00
|
|
|
return (mem_tobuffer(target, rdata->data, rdata->length));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_hinfo(ARGS_COMPARE) {
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_hinfo);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
1999-01-22 05:02:49 +00:00
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
2002-01-05 07:05:28 +00:00
|
|
|
return (isc_region_compare(&r1, &r2));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_hinfo(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_hinfo_t *hinfo = source;
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_hinfo);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(hinfo != NULL);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(hinfo->common.rdtype == type);
|
|
|
|
REQUIRE(hinfo->common.rdclass == rdclass);
|
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-12-01 01:40:59 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
|
2000-05-22 12:38:12 +00:00
|
|
|
RETERR(uint8_tobuffer(hinfo->cpu_len, target));
|
|
|
|
RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
|
|
|
|
RETERR(uint8_tobuffer(hinfo->os_len, target));
|
|
|
|
return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_hinfo(ARGS_TOSTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_hinfo_t *hinfo = target;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_region_t region;
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(hinfo != NULL);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
hinfo->common.rdclass = rdata->rdclass;
|
|
|
|
hinfo->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&hinfo->common, link);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
hinfo->cpu_len = uint8_fromregion(®ion);
|
|
|
|
isc_region_consume(®ion, 1);
|
2001-06-21 04:00:47 +00:00
|
|
|
hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
|
|
|
|
isc_region_consume(®ion, hinfo->cpu_len);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
hinfo->os_len = uint8_fromregion(®ion);
|
|
|
|
isc_region_consume(®ion, 1);
|
2001-06-21 04:00:47 +00:00
|
|
|
hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
|
2000-05-05 05:50:14 +00:00
|
|
|
hinfo->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
freestruct_hinfo(ARGS_FREESTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_hinfo_t *hinfo = source;
|
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(hinfo != NULL);
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (hinfo->mctx == NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (hinfo->cpu != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(hinfo->mctx, hinfo->cpu);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (hinfo->os != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(hinfo->mctx, hinfo->os);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
hinfo->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
additionaldata_hinfo(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(owner);
|
2000-03-16 22:42:32 +00:00
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-08-02 22:18:31 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
digest_hinfo(ARGS_DIGEST) {
|
1999-08-31 22:05:55 +00:00
|
|
|
isc_region_t r;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
|
|
|
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_hinfo(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_hinfo);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(wildcard);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames_hinfo(ARGS_CHECKNAMES) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_hinfo);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(owner);
|
|
|
|
UNUSED(bad);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
casecompare_hinfo(ARGS_COMPARE) {
|
2009-12-04 21:09:34 +00:00
|
|
|
return (compare_hinfo(rdata1, rdata2));
|
|
|
|
}
|