1/*
2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* $Id: isdn_20.c,v 1.13 2020/09/14 08:40:43 florian Exp $ */
18
19/* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */
20
21/* RFC1183 */
22
23#ifndef RDATA_GENERIC_ISDN_20_C
24#define RDATA_GENERIC_ISDN_20_C
25
26static inline isc_result_t
27totext_isdn(ARGS_TOTEXT) {
28	isc_region_t region;
29
30	REQUIRE(rdata->type == dns_rdatatype_isdn);
31	REQUIRE(rdata->length != 0);
32
33	UNUSED(tctx);
34
35	dns_rdata_toregion(rdata, &region);
36	RETERR(txt_totext(&region, 1, target));
37	if (region.length == 0)
38		return (ISC_R_SUCCESS);
39	RETERR(isc_str_tobuffer(" ", target));
40	return (txt_totext(&region, 1, target));
41}
42
43static inline isc_result_t
44fromwire_isdn(ARGS_FROMWIRE) {
45	REQUIRE(type == dns_rdatatype_isdn);
46
47	UNUSED(type);
48	UNUSED(dctx);
49	UNUSED(rdclass);
50	UNUSED(options);
51
52	RETERR(txt_fromwire(source, target));
53	if (buffer_empty(source))
54		return (ISC_R_SUCCESS);
55	return (txt_fromwire(source, target));
56}
57
58static inline isc_result_t
59towire_isdn(ARGS_TOWIRE) {
60	UNUSED(cctx);
61
62	REQUIRE(rdata->type == dns_rdatatype_isdn);
63	REQUIRE(rdata->length != 0);
64
65	return (isc_mem_tobuffer(target, rdata->data, rdata->length));
66}
67
68#endif	/* RDATA_GENERIC_ISDN_20_C */
69