null_10.c 4.08 KB
Newer Older
1
/*
Bob Halley's avatar
Bob Halley committed
2
 * Copyright (C) 1998, 1999, 2000  Internet Software Consortium.
Michael Graff's avatar
Michael Graff committed
3
 * 
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
 * 
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: null_10.c,v 1.23 2000/05/05 05:50:00 marka Exp $ */
19
20

/* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
Mark Andrews's avatar
Mark Andrews committed
21

22
23
#ifndef RDATA_GENERIC_NULL_10_C
#define RDATA_GENERIC_NULL_10_C
Mark Andrews's avatar
Mark Andrews committed
24

25
26
#define RRTYPE_NULL_ATTRIBUTES (0)

27
static inline isc_result_t
28
fromtext_null(dns_rdataclass_t rdclass, dns_rdatatype_t type,
29
	      isc_lex_t *lexer, dns_name_t *origin,
Mark Andrews's avatar
Mark Andrews committed
30
31
	      isc_boolean_t downcase, isc_buffer_t *target)
{
32
33
34
35
36
37
	UNUSED(rdclass);
	UNUSED(type);
	UNUSED(lexer);
	UNUSED(origin);
	UNUSED(downcase);
	UNUSED(target);
38

39
40
	REQUIRE(type == 10);

41
	return (DNS_R_SYNTAX);
42
43
}

44
static inline isc_result_t
45
46
47
totext_null(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, 
	    isc_buffer_t *target) 
{
48
	UNUSED(rdata);
49
50
	UNUSED(tctx);
	UNUSED(target);
51

52
53
	REQUIRE(rdata->type == 10);

54
	return (DNS_R_SYNTAX);
55
56
}

57
static inline isc_result_t
58
fromwire_null(dns_rdataclass_t rdclass, dns_rdatatype_t type,
59
	      isc_buffer_t *source, dns_decompress_t *dctx,
Mark Andrews's avatar
Mark Andrews committed
60
61
	      isc_boolean_t downcase, isc_buffer_t *target)
{
62
	isc_region_t sr;
63

64
65
66
	UNUSED(rdclass);
	UNUSED(dctx);
	UNUSED(downcase);
67

68
69
	REQUIRE(type == 10);

70
	isc_buffer_activeregion(source, &sr);
71
72
	isc_buffer_forward(source, sr.length);
	return (mem_tobuffer(target, sr.base, sr.length));
73
74
}

75
static inline isc_result_t
76
77
towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
{
78
	UNUSED(cctx);
79

80
81
	REQUIRE(rdata->type == 10);

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

85
static inline int
86
87
compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2)
{
88
89
	isc_region_t r1;
	isc_region_t r2;
90

Mark Andrews's avatar
Mark Andrews committed
91
	REQUIRE(rdata1->type == rdata1->type);
92
	REQUIRE(rdata1->rdclass == rdata2->rdclass);
Mark Andrews's avatar
Mark Andrews committed
93
	REQUIRE(rdata1->type == 10);
94

95
96
97
	dns_rdata_toregion(rdata1, &r1);
	dns_rdata_toregion(rdata2, &r2);
	return (compare_region(&r1, &r2));
98
99
}

100
static inline isc_result_t
101
fromstruct_null(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
Mark Andrews's avatar
Mark Andrews committed
102
103
	        isc_buffer_t *target)
{
104
105
106
	UNUSED(rdclass);
	UNUSED(source);
	UNUSED(target);
107

108
109
	REQUIRE(type == 10);

110
	return (ISC_R_NOTIMPLEMENTED);
111
112
}

113
static inline isc_result_t
114
115
tostruct_null(dns_rdata_t *rdata, void *target, isc_mem_t *mctx)
{
116
117
	dns_rdata_null_t *null = target;
	isc_region_t r;
118

119
	REQUIRE(rdata->type == 10);
120
	REQUIRE(target != NULL);
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
	null->common.rdclass = rdata->rdclass;
	null->common.rdtype = rdata->type;
	ISC_LINK_INIT(&null->common, link);

	dns_rdata_toregion(rdata, &r);
	null->length = r.length;
	if (null->length != 0) {
		null->data = mem_maybedup(mctx, r.base, r.length);
		if (null->data == NULL)
			return (ISC_R_NOMEMORY);
	} else
		null->data = NULL;

	null->mctx = mctx;
	return (ISC_R_SUCCESS);
137
138
}

139
static inline void
140
141
freestruct_null(void *source)
{
142
	dns_rdata_null_t *null = source;
143
	
144
	REQUIRE(source != NULL);
145
146
147
148
149
150
151
152
	REQUIRE(null->common.rdtype == 10);

	if (null->mctx == NULL)
		return;

	if (null->data != NULL)
		isc_mem_free(null->mctx, null->data);
	null->mctx = NULL;
153
}
154

155
static inline isc_result_t
156
157
158
additionaldata_null(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
		    void *arg)
{
159
	UNUSED(rdata);
160
161
	UNUSED(add);
	UNUSED(arg);
162

163
164
	REQUIRE(rdata->type == 10);

165
	return (ISC_R_SUCCESS);
166
167
}

168
static inline isc_result_t
169
170
digest_null(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg)
{
171
	isc_region_t r;
Bob Halley's avatar
Bob Halley committed
172
173
174

	REQUIRE(rdata->type == 10);

175
	dns_rdata_toregion(rdata, &r);
Bob Halley's avatar
Bob Halley committed
176

177
	return ((digest)(arg, &r));
Bob Halley's avatar
Bob Halley committed
178
179
}

180
#endif	/* RDATA_GENERIC_NULL_10_C */