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

Andreas Gustafsson's avatar
Andreas Gustafsson committed
18
/* $Id: gpos_27.c,v 1.14 2000/03/21 23:48:20 gson Exp $ */
Mark Andrews's avatar
Mark Andrews committed
19

James Brister's avatar
James Brister committed
20
21
22
/* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */

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

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

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

	REQUIRE(type == 27);

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

	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
46
	return (DNS_R_SUCCESS);
Mark Andrews's avatar
Mark Andrews committed
47
48
}

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

	REQUIRE(rdata->type == 27);

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

	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
68
	return (DNS_R_SUCCESS);
Mark Andrews's avatar
Mark Andrews committed
69
70
}

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

	REQUIRE(type == 27);

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

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

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

	REQUIRE(rdata->type == 27);

James Brister's avatar
James Brister committed
95
	UNUSED(cctx);
Mark Andrews's avatar
Mark Andrews committed
96

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

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

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

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

	REQUIRE(type == 27);

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

James Brister's avatar
James Brister committed
124
125
	UNUSED(source);
	UNUSED(target);
Mark Andrews's avatar
Mark Andrews committed
126

James Brister's avatar
James Brister committed
127
	return (DNS_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
128
129
}

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

	REQUIRE(rdata->type == 27);

James Brister's avatar
James Brister committed
136
137
	UNUSED(target);
	UNUSED(mctx);
Mark Andrews's avatar
Mark Andrews committed
138

James Brister's avatar
James Brister committed
139
	return (DNS_R_NOTIMPLEMENTED);
Mark Andrews's avatar
Mark Andrews committed
140
}
141

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

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

Andreas Gustafsson's avatar
Andreas Gustafsson committed
155
156
	UNUSED(add);
	UNUSED(arg);
157

James Brister's avatar
James Brister committed
158
	return (DNS_R_SUCCESS);
159
160
}

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

	REQUIRE(rdata->type == 27);

	dns_rdata_toregion(rdata, &r);

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

173
#endif	/* RDATA_GENERIC_GPOS_27_C */