null_10.c 3.69 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.
 */

David Lawrence's avatar
David Lawrence committed
18
/* $Id: null_10.c,v 1.25 2000/06/01 18:26:23 tale 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
David Lawrence's avatar
David Lawrence committed
28
fromtext_null(ARGS_FROMTEXT) {
29
30
31
32
33
34
	UNUSED(rdclass);
	UNUSED(type);
	UNUSED(lexer);
	UNUSED(origin);
	UNUSED(downcase);
	UNUSED(target);
35

36
37
	REQUIRE(type == 10);

38
	return (DNS_R_SYNTAX);
39
40
}

41
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
42
totext_null(ARGS_TOTEXT) {
43
	UNUSED(rdata);
44
45
	UNUSED(tctx);
	UNUSED(target);
46

47
48
	REQUIRE(rdata->type == 10);

49
	return (DNS_R_SYNTAX);
50
51
}

52
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
53
fromwire_null(ARGS_FROMWIRE) {
54
	isc_region_t sr;
55

56
57
58
	UNUSED(rdclass);
	UNUSED(dctx);
	UNUSED(downcase);
59

60
61
	REQUIRE(type == 10);

62
	isc_buffer_activeregion(source, &sr);
63
64
	isc_buffer_forward(source, sr.length);
	return (mem_tobuffer(target, sr.base, sr.length));
65
66
}

67
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
68
towire_null(ARGS_TOWIRE) {
69
	UNUSED(cctx);
70

71
72
	REQUIRE(rdata->type == 10);

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

76
static inline int
David Lawrence's avatar
David Lawrence committed
77
compare_null(ARGS_COMPARE) {
78
79
	isc_region_t r1;
	isc_region_t r2;
80

Mark Andrews's avatar
Mark Andrews committed
81
	REQUIRE(rdata1->type == rdata1->type);
82
	REQUIRE(rdata1->rdclass == rdata2->rdclass);
Mark Andrews's avatar
Mark Andrews committed
83
	REQUIRE(rdata1->type == 10);
84

85
86
87
	dns_rdata_toregion(rdata1, &r1);
	dns_rdata_toregion(rdata2, &r2);
	return (compare_region(&r1, &r2));
88
89
}

90
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
91
fromstruct_null(ARGS_FROMSTRUCT) {
92
	dns_rdata_null_t *null = source;
93

94
	REQUIRE(type == 10);
95
96
97
98
99
	REQUIRE(source != NULL);
	REQUIRE(null->common.rdtype == type);
	REQUIRE(null->common.rdclass == rdclass);
	REQUIRE((null->data != NULL && null->length != 0) ||
		(null->data == NULL && null->length == 0));
100

101
	return (mem_tobuffer(target, null->data, null->length));
102
103
}

104
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
105
tostruct_null(ARGS_TOSTRUCT) {
106
107
	dns_rdata_null_t *null = target;
	isc_region_t r;
108

109
	REQUIRE(rdata->type == 10);
110
	REQUIRE(target != NULL);
111

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	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);
127
128
}

129
static inline void
David Lawrence's avatar
David Lawrence committed
130
freestruct_null(ARGS_FREESTRUCT) {
131
	dns_rdata_null_t *null = source;
132
	
133
	REQUIRE(source != NULL);
134
135
136
137
138
139
140
141
	REQUIRE(null->common.rdtype == 10);

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

	if (null->data != NULL)
		isc_mem_free(null->mctx, null->data);
	null->mctx = NULL;
142
}
143

144
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
145
additionaldata_null(ARGS_ADDLDATA) {
146
	UNUSED(rdata);
147
148
	UNUSED(add);
	UNUSED(arg);
149

150
151
	REQUIRE(rdata->type == 10);

152
	return (ISC_R_SUCCESS);
153
154
}

155
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
156
digest_null(ARGS_DIGEST) {
157
	isc_region_t r;
Bob Halley's avatar
Bob Halley committed
158
159
160

	REQUIRE(rdata->type == 10);

161
	dns_rdata_toregion(rdata, &r);
Bob Halley's avatar
Bob Halley committed
162

163
	return ((digest)(arg, &r));
Bob Halley's avatar
Bob Halley committed
164
165
}

166
#endif	/* RDATA_GENERIC_NULL_10_C */