1999-02-01 00:15:55 +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-02-01 00:15:55 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/* RFC1712 */
|
1999-02-01 00:15:55 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_GENERIC_GPOS_27_C
|
|
|
|
#define RDATA_GENERIC_GPOS_27_C
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2000-04-07 03:54:52 +00:00
|
|
|
#define RRTYPE_GPOS_ATTRIBUTES (0)
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_gpos(ARGS_FROMTEXT) {
|
1999-02-01 00:15:55 +00:00
|
|
|
isc_token_t token;
|
2020-02-13 14:44:37 -08:00
|
|
|
int i;
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_gpos);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-03-16 01:31:03 +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-02-01 00:15:55 +00:00
|
|
|
|
2001-11-27 00:56:32 +00:00
|
|
|
for (i = 0; i < 3; 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-02-01 00:15:55 +00:00
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_gpos(ARGS_TOTEXT) {
|
1999-02-01 00:15:55 +00:00
|
|
|
isc_region_t region;
|
2020-02-13 14:44:37 -08:00
|
|
|
int i;
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_gpos);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2000-03-16 01:31:03 +00:00
|
|
|
UNUSED(tctx);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
|
2001-11-27 00:56:32 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2018-04-17 08:29:14 -07:00
|
|
|
RETERR(txt_totext(®ion, true, target));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (i != 2) {
|
1999-02-01 00:15:55 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_gpos(ARGS_FROMWIRE) {
|
1999-02-01 00:15:55 +00:00
|
|
|
int i;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_gpos);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-03-16 01:31:03 +00:00
|
|
|
UNUSED(dctx);
|
|
|
|
UNUSED(rdclass);
|
2004-02-27 20:41:51 +00:00
|
|
|
UNUSED(options);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2022-03-13 13:05:27 +01:00
|
|
|
for (i = 0; i < 3; i++) {
|
1999-02-01 00:15:55 +00:00
|
|
|
RETERR(txt_fromwire(source, target));
|
2022-03-13 13:05:27 +01:00
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_gpos(ARGS_TOWIRE) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_gpos);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2000-03-16 01:31:03 +00:00
|
|
|
UNUSED(cctx);
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2000-03-16 02:00:37 +00:00
|
|
|
return (mem_tobuffer(target, rdata->data, rdata->length));
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_gpos(ARGS_COMPARE) {
|
1999-02-01 00:15:55 +00:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-02-01 00:15:55 +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_gpos);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
1999-02-01 00:15:55 +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-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_gpos(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_gpos_t *gpos = source;
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_gpos);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(gpos != NULL);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(gpos->common.rdtype == type);
|
|
|
|
REQUIRE(gpos->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(gpos->long_len, target));
|
|
|
|
RETERR(mem_tobuffer(target, gpos->longitude, gpos->long_len));
|
|
|
|
RETERR(uint8_tobuffer(gpos->lat_len, target));
|
|
|
|
RETERR(mem_tobuffer(target, gpos->latitude, gpos->lat_len));
|
|
|
|
RETERR(uint8_tobuffer(gpos->alt_len, target));
|
|
|
|
return (mem_tobuffer(target, gpos->altitude, gpos->alt_len));
|
1999-02-01 00:15:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_gpos(ARGS_TOSTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_gpos_t *gpos = target;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_region_t region;
|
1999-02-01 00:15:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_gpos);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(gpos != NULL);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
gpos->common.rdclass = rdata->rdclass;
|
|
|
|
gpos->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&gpos->common, link);
|
|
|
|
|
2000-05-19 13:05:51 +00:00
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
2000-05-05 05:50:14 +00:00
|
|
|
gpos->long_len = uint8_fromregion(®ion);
|
|
|
|
isc_region_consume(®ion, 1);
|
2001-06-21 04:00:47 +00:00
|
|
|
gpos->longitude = mem_maybedup(mctx, region.base, gpos->long_len);
|
|
|
|
isc_region_consume(®ion, gpos->long_len);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
gpos->lat_len = uint8_fromregion(®ion);
|
|
|
|
isc_region_consume(®ion, 1);
|
2001-06-21 04:00:47 +00:00
|
|
|
gpos->latitude = mem_maybedup(mctx, region.base, gpos->lat_len);
|
|
|
|
isc_region_consume(®ion, gpos->lat_len);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
gpos->alt_len = uint8_fromregion(®ion);
|
|
|
|
isc_region_consume(®ion, 1);
|
|
|
|
if (gpos->lat_len > 0) {
|
2020-02-12 13:59:18 +01:00
|
|
|
gpos->altitude = mem_maybedup(mctx, region.base, gpos->alt_len);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2000-05-05 05:50:14 +00:00
|
|
|
gpos->altitude = NULL;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
gpos->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-01 00:15:55 +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_gpos(ARGS_FREESTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_gpos_t *gpos = source;
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(gpos != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(gpos->common.rdtype == dns_rdatatype_gpos);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (gpos->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 (gpos->longitude != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(gpos->mctx, gpos->longitude);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (gpos->latitude != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(gpos->mctx, gpos->latitude);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (gpos->altitude != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(gpos->mctx, gpos->altitude);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
gpos->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_gpos(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_gpos);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2000-03-21 23:48:20 +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_gpos(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_gpos);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
|
2000-03-16 02:00:37 +00:00
|
|
|
return ((digest)(arg, &r));
|
1999-08-31 22:05:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checkowner_gpos(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_gpos);
|
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_gpos(ARGS_CHECKNAMES) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_gpos);
|
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_gpos(ARGS_COMPARE) {
|
2009-12-04 21:09:34 +00:00
|
|
|
return (compare_gpos(rdata1, rdata2));
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_GPOS_27_C */
|