1999-01-22 05:02:49 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-09-15 23:03:43 +00:00
|
|
|
*
|
1999-01-22 05:02:49 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
1999-09-15 23:03:43 +00:00
|
|
|
*
|
1999-01-22 05:02:49 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
/* $Id: isdn_20.c,v 1.18 2000/05/05 05:49:46 marka Exp $ */
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-03-16 00:54:24 +00:00
|
|
|
/* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */
|
|
|
|
|
|
|
|
/* RFC 1183 */
|
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
|
1999-08-02 22:18:31 +00:00
|
|
|
fromtext_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_lex_t *lexer, dns_name_t *origin,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_token_t token;
|
|
|
|
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(origin);
|
|
|
|
UNUSED(downcase);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-03-16 00:54:24 +00:00
|
|
|
REQUIRE(type == 20);
|
|
|
|
|
1999-01-22 05:02:49 +00:00
|
|
|
/* ISDN-address */
|
1999-05-19 09:14:58 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
|
1999-01-22 05:02:49 +00:00
|
|
|
RETERR(txt_fromtext(&token.value.as_textregion, target));
|
|
|
|
|
|
|
|
/* sa: optional */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_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
|
|
|
}
|
|
|
|
return (txt_fromtext(&token.value.as_textregion, target));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-06-08 10:35:23 +00:00
|
|
|
totext_isdn(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
|
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
1999-01-22 05:02:49 +00:00
|
|
|
isc_region_t region;
|
|
|
|
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(tctx);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-03-16 00:54:24 +00:00
|
|
|
REQUIRE(rdata->type == 20);
|
|
|
|
|
1999-01-22 05:02:49 +00:00
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
RETERR(txt_totext(®ion, target));
|
|
|
|
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));
|
|
|
|
return (txt_totext(®ion, target));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromwire_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_buffer_t *source, dns_decompress_t *dctx,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(dctx);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(downcase);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-03-16 00:54:24 +00:00
|
|
|
REQUIRE(type == 20);
|
|
|
|
|
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
|
1999-01-22 05:02:49 +00:00
|
|
|
towire_isdn(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(cctx);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == 20);
|
|
|
|
|
|
|
|
return (mem_tobuffer(target, rdata->data, rdata->length));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline int
|
1999-01-22 05:02:49 +00:00
|
|
|
compare_isdn(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
1999-01-22 05:02:49 +00:00
|
|
|
REQUIRE(rdata1->type == 20);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
return (compare_region(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromstruct_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
2000-03-16 02:08:51 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(source);
|
|
|
|
UNUSED(target);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-03-16 00:54:24 +00:00
|
|
|
REQUIRE(type == 20);
|
1999-01-22 05:02:49 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
1999-01-22 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-05-07 03:24:15 +00:00
|
|
|
tostruct_isdn(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_isdn_t *isdn = target;
|
|
|
|
isc_region_t r;
|
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
REQUIRE(rdata->type == 20);
|
2000-05-05 05:50:14 +00:00
|
|
|
REQUIRE(target != NULL);
|
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);
|
|
|
|
if (isdn->isdn_len > 0) {
|
|
|
|
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);
|
|
|
|
} else
|
|
|
|
isdn->isdn = NULL;
|
|
|
|
|
|
|
|
isdn->subaddress_len = uint8_fromregion(&r);
|
|
|
|
isc_region_consume(&r, 1);
|
|
|
|
if (isdn->subaddress_len > 0) {
|
|
|
|
isdn->subaddress = mem_maybedup(mctx, r.base,
|
|
|
|
isdn->subaddress_len);
|
|
|
|
if (isdn->subaddress == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
} else
|
|
|
|
isdn->subaddress = NULL;
|
|
|
|
|
|
|
|
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
|
1999-05-07 03:24:15 +00:00
|
|
|
freestruct_isdn(void *source) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_isdn_t *isdn = source;
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
REQUIRE(source != NULL);
|
|
|
|
|
|
|
|
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
|
1999-08-02 22:18:31 +00:00
|
|
|
additionaldata_isdn(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
|
|
|
|
void *arg)
|
|
|
|
{
|
2000-04-28 01:24:18 +00:00
|
|
|
REQUIRE(rdata->type == 20);
|
|
|
|
|
|
|
|
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
|
1999-08-31 22:05:55 +00:00
|
|
|
digest_isdn(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
|
|
|
|
isc_region_t r;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 20);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
|
|
|
|
return ((digest)(arg, &r));
|
|
|
|
}
|
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#endif /* RDATA_GENERIC_ISDN_20_C */
|