isdn_20.c revision 82ca33427bdd4f3bc4ed3431e86bd810fe751674
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews/*
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 1999, 2000 Internet Software Consortium.
2f072c2982861ec2e86e97f8a3ed199fe45c1f70Michael Graff *
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * Permission to use, copy, modify, and distribute this software for any
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * purpose with or without fee is hereby granted, provided that the above
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * copyright notice and this permission notice appear in all copies.
2f072c2982861ec2e86e97f8a3ed199fe45c1f70Michael Graff *
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * SOFTWARE.
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews */
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson/* $Id: isdn_20.c,v 1.17 2000/04/28 01:24:01 gson Exp $ */
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington/* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington/* RFC 1183 */
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#ifndef RDATA_GENERIC_ISDN_20_C
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#define RDATA_GENERIC_ISDN_20_C
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff#define RRTYPE_ISDN_ATTRIBUTES (0)
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
d981ca645597116d227a48bf37cc5edc061c854dBob Halleyfromtext_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_lex_t *lexer, dns_name_t *origin,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_boolean_t downcase, isc_buffer_t *target)
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews{
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_token_t token;
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(rdclass);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(origin);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(downcase);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington REQUIRE(type == 20);
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews /* ISDN-address */
5dcb42f5bbd41da02a0b32a11a1912f7b90686a8Andreas Gustafsson RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews RETERR(txt_fromtext(&token.value.as_textregion, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews /* sa: optional */
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE));
5dcb42f5bbd41da02a0b32a11a1912f7b90686a8Andreas Gustafsson if (token.type != isc_tokentype_string &&
5dcb42f5bbd41da02a0b32a11a1912f7b90686a8Andreas Gustafsson token.type != isc_tokentype_qstring) {
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_lex_ungettoken(lexer, &token);
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews }
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews return (txt_fromtext(&token.value.as_textregion, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssontotext_isdn(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_buffer_t *target)
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson{
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_region_t region;
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(tctx);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington REQUIRE(rdata->type == 20);
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews dns_rdata_toregion(rdata, &region);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews RETERR(txt_totext(&region, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews if (region.length == 0)
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews RETERR(str_totext(" ", target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews return (txt_totext(&region, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
d981ca645597116d227a48bf37cc5edc061c854dBob Halleyfromwire_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_buffer_t *source, dns_decompress_t *dctx,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_boolean_t downcase, isc_buffer_t *target)
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews{
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(dctx);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(rdclass);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(downcase);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington REQUIRE(type == 20);
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews RETERR(txt_fromwire(source, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews if (buffer_empty(source))
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews return (txt_fromwire(source, target));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewstowire_isdn(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(cctx);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews REQUIRE(rdata->type == 20);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews return (mem_tobuffer(target, rdata->data, rdata->length));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline int
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewscompare_isdn(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_region_t r1;
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_region_t r2;
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews REQUIRE(rdata1->type == rdata2->type);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley REQUIRE(rdata1->rdclass == rdata2->rdclass);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews REQUIRE(rdata1->type == 20);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews dns_rdata_toregion(rdata1, &r1);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews dns_rdata_toregion(rdata2, &r2);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews return (compare_region(&r1, &r2));
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
d981ca645597116d227a48bf37cc5edc061c854dBob Halleyfromstruct_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_buffer_t *target)
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews{
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(rdclass);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(source);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(target);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington REQUIRE(type == 20);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_NOTIMPLEMENTED);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrewstostruct_isdn(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson REQUIRE(rdata->type == 20);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(rdata);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(target);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(mctx);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_NOTIMPLEMENTED);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews}
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline void
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrewsfreestruct_isdn(void *source) {
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews REQUIRE(source != NULL);
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews REQUIRE(ISC_FALSE); /*XXX*/
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(source);
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
d981ca645597116d227a48bf37cc5edc061c854dBob Halleyadditionaldata_isdn(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
d981ca645597116d227a48bf37cc5edc061c854dBob Halley void *arg)
d981ca645597116d227a48bf37cc5edc061c854dBob Halley{
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson REQUIRE(rdata->type == 20);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(rdata);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(add);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington UNUSED(arg);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halleydigest_isdn(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley isc_region_t r;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley REQUIRE(rdata->type == 20);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_rdata_toregion(rdata, &r);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley return ((digest)(arg, &r));
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley}
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#endif /* RDATA_GENERIC_ISDN_20_C */