isdn_20.c revision e27a69f8bd9538e08f775265167ba6cc5f47c587
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy/*
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright (C) 1999 Internet Software Consortium.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Permission to use, copy, modify, and distribute this software for any
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * purpose with or without fee is hereby granted, provided that the above
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * copyright notice and this permission notice appear in all copies.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * SOFTWARE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /* $Id: isdn_20.c,v 1.9 1999/08/31 22:05:53 halley Exp $ */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /* RFC 1183 */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#ifndef RDATA_GENERIC_ISDN_20_C
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#define RDATA_GENERIC_ISDN_20_C
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic inline dns_result_t
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyfromtext_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_lex_t *lexer, dns_name_t *origin,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_boolean_t downcase, isc_buffer_t *target)
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy{
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_token_t token;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy REQUIRE(type == 20);
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy rdclass = rdclass; /*unused*/
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy origin = origin; /*unused*/
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy downcase = downcase; /*unused*/
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /* ISDN-address */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy RETERR(txt_fromtext(&token.value.as_textregion, target));
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /* sa: optional */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE));
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy if (token.type != isc_tokentype_string &&
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy token.type != isc_tokentype_qstring) {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_lex_ungettoken(lexer, &token);
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy return (DNS_R_SUCCESS);
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy }
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy return (txt_fromtext(&token.value.as_textregion, target));
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy}
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic inline dns_result_t
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedytotext_isdn(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_buffer_t *target)
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy{
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy isc_region_t region;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy REQUIRE(rdata->type == 20);
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy tctx = tctx; /*unused*/
dns_rdata_toregion(rdata, &region);
RETERR(txt_totext(&region, target));
if (region.length == 0)
return (DNS_R_SUCCESS);
RETERR(str_totext(" ", target));
return (txt_totext(&region, target));
}
static inline dns_result_t
fromwire_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target)
{
REQUIRE(type == 20);
dctx = dctx; /* unused */
rdclass = rdclass; /* unused */
downcase = downcase; /* unused */
RETERR(txt_fromwire(source, target));
if (buffer_empty(source))
return (DNS_R_SUCCESS);
return (txt_fromwire(source, target));
}
static inline dns_result_t
towire_isdn(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 20);
cctx = cctx; /*unused*/
return (mem_tobuffer(target, rdata->data, rdata->length));
}
static inline int
compare_isdn(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
isc_region_t r1;
isc_region_t r2;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == 20);
dns_rdata_toregion(rdata1, &r1);
dns_rdata_toregion(rdata2, &r2);
return (compare_region(&r1, &r2));
}
static inline dns_result_t
fromstruct_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
REQUIRE(type == 20);
rdclass = rdclass; /*unused*/
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static inline dns_result_t
tostruct_isdn(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
REQUIRE(rdata->type == 20);
target = target;
mctx = mctx;
return (DNS_R_NOTIMPLEMENTED);
}
static inline void
freestruct_isdn(void *source) {
REQUIRE(source != NULL);
REQUIRE(ISC_FALSE); /*XXX*/
}
static inline dns_result_t
additionaldata_isdn(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
void *arg)
{
REQUIRE(rdata->type == 20);
(void)add;
(void)arg;
return (DNS_R_SUCCESS);
}
static inline dns_result_t
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));
}
#endif /* RDATA_GENERIC_ISDN_20_C */