x25_19.c 3.91 KB
Newer Older
Mark Andrews's avatar
Mark Andrews committed
1
/*
Bob Halley's avatar
Bob Halley committed
2
 * Copyright (C) 1999, 2000  Internet Software Consortium.
Michael Graff's avatar
Michael Graff committed
3
 * 
Mark Andrews's avatar
Mark Andrews committed
4
5
6
 * 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.
Michael Graff's avatar
Michael Graff committed
7
 * 
Mark Andrews's avatar
Mark Andrews committed
8
9
10
11
12
13
14
15
16
17
 * 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.
 */

18
/* $Id: x25_19.c,v 1.16 2000/04/28 01:24:12 gson Exp $ */
Mark Andrews's avatar
Mark Andrews committed
19

Brian Wellington's avatar
Brian Wellington committed
20
21
22
/* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */

/* RFC 1183 */
Mark Andrews's avatar
Mark Andrews committed
23

24
25
#ifndef RDATA_GENERIC_X25_19_C
#define RDATA_GENERIC_X25_19_C
Mark Andrews's avatar
Mark Andrews committed
26

27
28
#define RRTYPE_X25_ATTRIBUTES (0)

Mark Andrews's avatar
Mark Andrews committed
29
30
#include <ctype.h>

31
static inline isc_result_t
32
fromtext_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type,
Mark Andrews's avatar
Mark Andrews committed
33
34
35
	     isc_lex_t *lexer, dns_name_t *origin,
	     isc_boolean_t downcase, isc_buffer_t *target)
{
Mark Andrews's avatar
Mark Andrews committed
36
37
38
	isc_token_t token;
	unsigned int i;

Brian Wellington's avatar
Brian Wellington committed
39
40
41
	UNUSED(rdclass);
	UNUSED(origin);
	UNUSED(downcase);
Mark Andrews's avatar
Mark Andrews committed
42

Brian Wellington's avatar
Brian Wellington committed
43
	REQUIRE(type == 19);
Mark Andrews's avatar
Mark Andrews committed
44

45
	RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE));
Brian Wellington's avatar
Brian Wellington committed
46
47
	if (token.value.as_textregion.length < 4)
		return (DNS_R_SYNTAX);
Mark Andrews's avatar
Mark Andrews committed
48
	for (i = 0; i < token.value.as_textregion.length; i++)
Brian Wellington's avatar
Brian Wellington committed
49
		if (!isdigit(token.value.as_textregion.base[i] & 0xff))
Mark Andrews's avatar
Mark Andrews committed
50
51
52
53
			return (DNS_R_RANGE);
	return (txt_fromtext(&token.value.as_textregion, target));
}

54
static inline isc_result_t
55
56
57
totext_x25(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, 
	   isc_buffer_t *target) 
{
Mark Andrews's avatar
Mark Andrews committed
58
59
	isc_region_t region;

Brian Wellington's avatar
Brian Wellington committed
60
	UNUSED(tctx);
Mark Andrews's avatar
Mark Andrews committed
61

Brian Wellington's avatar
Brian Wellington committed
62
	REQUIRE(rdata->type == 19);
Mark Andrews's avatar
Mark Andrews committed
63
64
65
66
67

	dns_rdata_toregion(rdata, &region);
	return (txt_totext(&region, target));
}

68
static inline isc_result_t
69
fromwire_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type,
Mark Andrews's avatar
Mark Andrews committed
70
71
72
	     isc_buffer_t *source, dns_decompress_t *dctx,
	     isc_boolean_t downcase, isc_buffer_t *target)
{
Brian Wellington's avatar
Brian Wellington committed
73
	isc_region_t sr;
Mark Andrews's avatar
Mark Andrews committed
74

Brian Wellington's avatar
Brian Wellington committed
75
76
77
	UNUSED(dctx);
	UNUSED(rdclass);
	UNUSED(downcase);
Mark Andrews's avatar
Mark Andrews committed
78

Brian Wellington's avatar
Brian Wellington committed
79
	REQUIRE(type == 19);
Mark Andrews's avatar
Mark Andrews committed
80

81
	isc_buffer_activeregion(source, &sr);
Brian Wellington's avatar
Brian Wellington committed
82
83
	if (sr.length < 5)
		return (DNS_R_FORMERR);
Mark Andrews's avatar
Mark Andrews committed
84
85
86
	return (txt_fromwire(source, target));
}

87
static inline isc_result_t
Mark Andrews's avatar
Mark Andrews committed
88
towire_x25(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
Brian Wellington's avatar
Brian Wellington committed
89
	UNUSED(cctx);
Mark Andrews's avatar
Mark Andrews committed
90
91
92
93
94
95

	REQUIRE(rdata->type == 19);

	return (mem_tobuffer(target, rdata->data, rdata->length));
}

96
static inline int
Mark Andrews's avatar
Mark Andrews committed
97
compare_x25(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
Brian Wellington's avatar
Brian Wellington committed
98
99
	isc_region_t r1;
	isc_region_t r2;
Mark Andrews's avatar
Mark Andrews committed
100
101
	
	REQUIRE(rdata1->type == rdata2->type);
102
	REQUIRE(rdata1->rdclass == rdata2->rdclass);
Mark Andrews's avatar
Mark Andrews committed
103
104
	REQUIRE(rdata1->type == 19);

Brian Wellington's avatar
Brian Wellington committed
105
106
107
	dns_rdata_toregion(rdata1, &r1);
	dns_rdata_toregion(rdata2, &r2);
	return (compare_region(&r1, &r2));
Mark Andrews's avatar
Mark Andrews committed
108
109
}

110
static inline isc_result_t
111
fromstruct_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
Mark Andrews's avatar
Mark Andrews committed
112
113
	       isc_buffer_t *target)
{
Brian Wellington's avatar
Brian Wellington committed
114
115
116
	UNUSED(rdclass);
	UNUSED(source);
	UNUSED(target);
Mark Andrews's avatar
Mark Andrews committed
117
118
119

	REQUIRE(type == 19);

120
	return (ISC_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
121
122
}

123
static inline isc_result_t
124
tostruct_x25(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
Mark Andrews's avatar
Mark Andrews committed
125
126
127

	REQUIRE(rdata->type == 19);

Brian Wellington's avatar
Brian Wellington committed
128
129
	UNUSED(target);
	UNUSED(mctx);
130
	UNUSED(rdata);
Mark Andrews's avatar
Mark Andrews committed
131

132
	return (ISC_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
133
}
134

135
static inline void
136
137
138
freestruct_x25(void *source) {
	REQUIRE(source != NULL);
	REQUIRE(ISC_FALSE);	/*XXX*/
139
140

	UNUSED(source);
141
}
142

143
static inline isc_result_t
144
145
146
additionaldata_x25(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
		   void *arg)
{
147
148
149
	REQUIRE(rdata->type == 19);

	UNUSED(rdata);
Brian Wellington's avatar
Brian Wellington committed
150
151
	UNUSED(add);
	UNUSED(arg);
152

153
	return (ISC_R_SUCCESS);
154
155
}

156
static inline isc_result_t
Bob Halley's avatar
Bob Halley committed
157
158
159
160
161
162
163
164
165
166
digest_x25(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
	isc_region_t r;

	REQUIRE(rdata->type == 19);

	dns_rdata_toregion(rdata, &r);

	return ((digest)(arg, &r));
}

167
#endif	/* RDATA_GENERIC_X25_19_C */