1999-01-22 05:02:49 +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
|
|
|
*
|
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
|
|
|
|
* file, You can obtain one at http://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-22 05:02:49 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/* RFC1183 */
|
1999-01-22 05:02:49 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_GENERIC_ISDN_20_C
|
|
|
|
#define RDATA_GENERIC_ISDN_20_C
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-04-07 03:54:52 +00:00
|
|
|
#define RRTYPE_ISDN_ATTRIBUTES (0)
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromtext_isdn(ARGS_FROMTEXT) {
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_token_t token;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_isdn);
|
2001-03-16 22:53:20 +00:00
|
|
|
|
|
|
|
UNUSED(type);
|
2000-03-16 02:08:51 +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-22 05:02:49 +00:00
|
|
|
|
|
|
|
/* ISDN-address */
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(txt_fromtext(&token.value.as_textregion, target));
|
1999-01-22 05:02:49 +00:00
|
|
|
|
|
|
|
/* sa: optional */
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
|
2018-04-17 08:29:14 -07:00
|
|
|
true));
|
1999-05-19 09:14:58 +00:00
|
|
|
if (token.type != isc_tokentype_string &&
|
|
|
|
token.type != isc_tokentype_qstring) {
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_lex_ungettoken(lexer, &token);
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(txt_fromtext(&token.value.as_textregion, target));
|
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
totext_isdn(ARGS_TOTEXT) {
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_region_t region;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_isdn);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
2000-03-16 00:54:24 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(tctx);
|
|
|
|
|
1999-01-22 05:02:49 +00:00
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
2018-04-17 08:29:14 -07:00
|
|
|
RETERR(txt_totext(®ion, true, target));
|
1999-01-22 05:02:49 +00:00
|
|
|
if (region.length == 0)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-22 05:02:49 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
2018-04-17 08:29:14 -07:00
|
|
|
return (txt_totext(®ion, true, target));
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromwire_isdn(ARGS_FROMWIRE) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_isdn);
|
2001-03-16 22:53:20 +00:00
|
|
|
|
|
|
|
UNUSED(type);
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(dctx);
|
|
|
|
UNUSED(rdclass);
|
2004-02-27 20:41:51 +00:00
|
|
|
UNUSED(options);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
|
|
|
RETERR(txt_fromwire(source, target));
|
|
|
|
if (buffer_empty(source))
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-22 05:02:49 +00:00
|
|
|
return (txt_fromwire(source, target));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
towire_isdn(ARGS_TOWIRE) {
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(cctx);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_isdn);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
|
|
|
return (mem_tobuffer(target, rdata->data, rdata->length));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline int
|
2000-06-01 18:26:56 +00:00
|
|
|
compare_isdn(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-22 05:02:49 +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_isdn);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
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-22 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromstruct_isdn(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_isdn_t *isdn = source;
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_isdn);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(isdn != NULL);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(isdn->common.rdtype == type);
|
|
|
|
REQUIRE(isdn->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(isdn->isdn_len, target));
|
|
|
|
RETERR(mem_tobuffer(target, isdn->isdn, isdn->isdn_len));
|
2013-10-26 10:04:36 +11:00
|
|
|
if (isdn->subaddress == NULL)
|
2013-10-25 13:06:09 +11:00
|
|
|
return (ISC_R_SUCCESS);
|
2000-05-22 12:38:12 +00:00
|
|
|
RETERR(uint8_tobuffer(isdn->subaddress_len, target));
|
|
|
|
return (mem_tobuffer(target, isdn->subaddress, isdn->subaddress_len));
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
tostruct_isdn(ARGS_TOSTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_isdn_t *isdn = target;
|
|
|
|
isc_region_t r;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_isdn);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(isdn != NULL);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
isdn->common.rdclass = rdata->rdclass;
|
|
|
|
isdn->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&isdn->common, link);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
|
|
|
|
isdn->isdn_len = uint8_fromregion(&r);
|
|
|
|
isc_region_consume(&r, 1);
|
2001-06-21 04:00:47 +00:00
|
|
|
isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
|
|
|
|
if (isdn->isdn == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
|
|
|
isc_region_consume(&r, isdn->isdn_len);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
2013-10-25 13:06:09 +11:00
|
|
|
if (r.length == 0) {
|
|
|
|
isdn->subaddress_len = 0;
|
|
|
|
isdn->subaddress = NULL;
|
|
|
|
} else {
|
|
|
|
isdn->subaddress_len = uint8_fromregion(&r);
|
|
|
|
isc_region_consume(&r, 1);
|
|
|
|
isdn->subaddress = mem_maybedup(mctx, r.base,
|
|
|
|
isdn->subaddress_len);
|
|
|
|
if (isdn->subaddress == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
isdn->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (mctx != NULL && isdn->isdn != NULL)
|
|
|
|
isc_mem_free(mctx, isdn->isdn);
|
|
|
|
return (ISC_R_NOMEMORY);
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline void
|
2000-06-01 18:26:56 +00:00
|
|
|
freestruct_isdn(ARGS_FREESTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_isdn_t *isdn = source;
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(isdn != NULL);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
if (isdn->mctx == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (isdn->isdn != NULL)
|
|
|
|
isc_mem_free(isdn->mctx, isdn->isdn);
|
|
|
|
if (isdn->subaddress != NULL)
|
|
|
|
isc_mem_free(isdn->mctx, isdn->subaddress);
|
|
|
|
isdn->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
additionaldata_isdn(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_isdn);
|
2000-04-28 01:24:18 +00:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
2000-03-16 02:08:51 +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
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
digest_isdn(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_isdn);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
|
|
|
|
return ((digest)(arg, &r));
|
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static inline bool
|
2004-02-27 20:41:51 +00:00
|
|
|
checkowner_isdn(ARGS_CHECKOWNER) {
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_isdn);
|
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
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static inline bool
|
2004-02-27 20:41:51 +00:00
|
|
|
checknames_isdn(ARGS_CHECKNAMES) {
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_isdn);
|
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
|
|
|
}
|
|
|
|
|
2009-12-04 21:09:34 +00:00
|
|
|
static inline int
|
|
|
|
casecompare_isdn(ARGS_COMPARE) {
|
|
|
|
return (compare_isdn(rdata1, rdata2));
|
|
|
|
}
|
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#endif /* RDATA_GENERIC_ISDN_20_C */
|