gpos_27.c 3.68 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.
 */

James Brister's avatar
James Brister committed
18
 /* $Id: gpos_27.c,v 1.12 2000/03/16 01:31:03 brister Exp $ */
Mark Andrews's avatar
Mark Andrews committed
19
20
21

 /* RFC 1712 */

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

25
static inline isc_result_t
26
fromtext_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type,
Mark Andrews's avatar
Mark Andrews committed
27
28
29
	      isc_lex_t *lexer, dns_name_t *origin,
	      isc_boolean_t downcase, isc_buffer_t *target)
{
Mark Andrews's avatar
Mark Andrews committed
30
31
32
33
34
	isc_token_t token;
	int i;

	REQUIRE(type == 27);

James Brister's avatar
James Brister committed
35
36
37
	UNUSED(rdclass);
	UNUSED(origin);
	UNUSED(downcase);
Mark Andrews's avatar
Mark Andrews committed
38
39
40
41
42
43

	for (i = 0; i < 3 ; i++) {
		RETERR(gettoken(lexer, &token, isc_tokentype_qstring,
				ISC_FALSE));
		RETERR(txt_fromtext(&token.value.as_textregion, target));
	}
James Brister's avatar
James Brister committed
44
	return(DNS_R_SUCCESS);
Mark Andrews's avatar
Mark Andrews committed
45
46
}

47
static inline isc_result_t
48
49
50
totext_gpos(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, 
	    isc_buffer_t *target) 
{
Mark Andrews's avatar
Mark Andrews committed
51
52
53
54
55
	isc_region_t region;
	int i;

	REQUIRE(rdata->type == 27);

James Brister's avatar
James Brister committed
56
	UNUSED(tctx);
Mark Andrews's avatar
Mark Andrews committed
57
58
59
60
61
62
63
64
65

	dns_rdata_toregion(rdata, &region);

	for (i = 0; i < 3 ; i++) {
		RETERR(txt_totext(&region, target));
		if (i != 2)
			RETERR(str_totext(" ", target));
	}

James Brister's avatar
James Brister committed
66
	return(DNS_R_SUCCESS);
Mark Andrews's avatar
Mark Andrews committed
67
68
}

69
static inline isc_result_t
70
fromwire_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type,
Mark Andrews's avatar
Mark Andrews committed
71
72
73
	      isc_buffer_t *source, dns_decompress_t *dctx,
	      isc_boolean_t downcase, isc_buffer_t *target)
{
Mark Andrews's avatar
Mark Andrews committed
74
75
76
77
	int i;

	REQUIRE(type == 27);

James Brister's avatar
James Brister committed
78
79
80
	UNUSED(dctx);
	UNUSED(rdclass);
	UNUSED(downcase);
Mark Andrews's avatar
Mark Andrews committed
81
82
83

	for (i = 0 ; i < 3; i++)
		RETERR(txt_fromwire(source, target));
James Brister's avatar
James Brister committed
84
	return(DNS_R_SUCCESS);
Mark Andrews's avatar
Mark Andrews committed
85
86
}

87
static inline isc_result_t
James Brister's avatar
James Brister committed
88
89
towire_gpos(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
{
Mark Andrews's avatar
Mark Andrews committed
90
91
92

	REQUIRE(rdata->type == 27);

James Brister's avatar
James Brister committed
93
	UNUSED(cctx);
Mark Andrews's avatar
Mark Andrews committed
94

James Brister's avatar
James Brister committed
95
	return(mem_tobuffer(target, rdata->data, rdata->length));
Mark Andrews's avatar
Mark Andrews committed
96
97
}

98
static inline int
James Brister's avatar
James Brister committed
99
100
compare_gpos(dns_rdata_t *rdata1, dns_rdata_t *rdata2)
{
Mark Andrews's avatar
Mark Andrews committed
101
102
103
104
	isc_region_t r1;
	isc_region_t r2;
	
	REQUIRE(rdata1->type == rdata2->type);
105
	REQUIRE(rdata1->rdclass == rdata2->rdclass);
Mark Andrews's avatar
Mark Andrews committed
106
107
108
109
	REQUIRE(rdata1->type == 27);

	dns_rdata_toregion(rdata1, &r1);
	dns_rdata_toregion(rdata2, &r2);
James Brister's avatar
James Brister committed
110
	return(compare_region(&r1, &r2));
Mark Andrews's avatar
Mark Andrews committed
111
112
}

113
static inline isc_result_t
114
fromstruct_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
Mark Andrews's avatar
Mark Andrews committed
115
116
		isc_buffer_t *target)
{
Mark Andrews's avatar
Mark Andrews committed
117
118
119

	REQUIRE(type == 27);

James Brister's avatar
James Brister committed
120
	UNUSED(rdclass);
Mark Andrews's avatar
Mark Andrews committed
121
122
123
124

	source = source;
	target = target;

James Brister's avatar
James Brister committed
125
	return(DNS_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
126
127
}

128
static inline isc_result_t
James Brister's avatar
James Brister committed
129
130
tostruct_gpos(dns_rdata_t *rdata, void *target, isc_mem_t *mctx)
{
Mark Andrews's avatar
Mark Andrews committed
131
132
133
134

	REQUIRE(rdata->type == 27);

	target = target;
135
	mctx = mctx;
Mark Andrews's avatar
Mark Andrews committed
136

James Brister's avatar
James Brister committed
137
	return(DNS_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
138
}
139

140
static inline void
James Brister's avatar
James Brister committed
141
142
freestruct_gpos(void *source)
{
143
144
145
	REQUIRE(source != NULL);
	REQUIRE(ISC_FALSE);	/* XXX */
}
146

147
static inline isc_result_t
148
149
150
151
152
153
154
155
additionaldata_gpos(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
		    void *arg)
{
	REQUIRE(rdata->type == 27);

	(void)add;
	(void)arg;

James Brister's avatar
James Brister committed
156
	return(DNS_R_SUCCESS);
157
158
}

159
static inline isc_result_t
James Brister's avatar
James Brister committed
160
161
digest_gpos(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg)
{
Bob Halley's avatar
Bob Halley committed
162
163
164
165
166
167
	isc_region_t r;

	REQUIRE(rdata->type == 27);

	dns_rdata_toregion(rdata, &r);

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

171
#endif	/* RDATA_GENERIC_GPOS_27_C */