null_10.c 3.76 KB
Newer Older
1
/*
David Lawrence's avatar
David Lawrence committed
2
 * Copyright (C) 1998-2000  Internet Software Consortium.
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.
7
 *
8 9 10 11 12 13 14 15
 * 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.
16 17
 */

18
/* $Id: null_10.c,v 1.30 2000/12/01 01:40:34 gson 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
	REQUIRE(rdata1->length != 0);
	REQUIRE(rdata2->length != 0);
86

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

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

96
	REQUIRE(type == 10);
97 98 99 100 101
	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));
102

103 104
	UNUSED(rdclass);

105
	return (mem_tobuffer(target, null->data, null->length));
106 107
}

108
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
109
tostruct_null(ARGS_TOSTRUCT) {
110 111
	dns_rdata_null_t *null = target;
	isc_region_t r;
112

113
	REQUIRE(rdata->type == 10);
114
	REQUIRE(target != NULL);
115

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
	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);
131 132
}

133
static inline void
David Lawrence's avatar
David Lawrence committed
134
freestruct_null(ARGS_FREESTRUCT) {
135
	dns_rdata_null_t *null = source;
136

137
	REQUIRE(source != NULL);
138 139 140 141 142 143 144 145
	REQUIRE(null->common.rdtype == 10);

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

	if (null->data != NULL)
		isc_mem_free(null->mctx, null->data);
	null->mctx = NULL;
146
}
147

148
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
149
additionaldata_null(ARGS_ADDLDATA) {
150
	UNUSED(rdata);
151 152
	UNUSED(add);
	UNUSED(arg);
153

154 155
	REQUIRE(rdata->type == 10);

156
	return (ISC_R_SUCCESS);
157 158
}

159
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
160
digest_null(ARGS_DIGEST) {
161
	isc_region_t r;
Bob Halley's avatar
Bob Halley committed
162 163 164

	REQUIRE(rdata->type == 10);

165
	dns_rdata_toregion(rdata, &r);
Bob Halley's avatar
Bob Halley committed
166

167
	return ((digest)(arg, &r));
Bob Halley's avatar
Bob Halley committed
168 169
}

170
#endif	/* RDATA_GENERIC_NULL_10_C */