xref: /openbsd/usr.bin/dig/lib/dns/rdata/generic/gpos_27.c (revision 09467b48)
1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14  * PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /* $Id: gpos_27.c,v 1.12 2020/02/26 18:47:59 florian Exp $ */
18 
19 /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
20 
21 /* RFC1712 */
22 
23 #ifndef RDATA_GENERIC_GPOS_27_C
24 #define RDATA_GENERIC_GPOS_27_C
25 
26 static inline isc_result_t
27 totext_gpos(ARGS_TOTEXT) {
28 	isc_region_t region;
29 	int i;
30 
31 	REQUIRE(rdata->type == dns_rdatatype_gpos);
32 	REQUIRE(rdata->length != 0);
33 
34 	UNUSED(tctx);
35 
36 	dns_rdata_toregion(rdata, &region);
37 
38 	for (i = 0; i < 3; i++) {
39 		RETERR(txt_totext(&region, ISC_TRUE, target));
40 		if (i != 2)
41 			RETERR(isc_str_tobuffer(" ", target));
42 	}
43 
44 	return (ISC_R_SUCCESS);
45 }
46 
47 static inline isc_result_t
48 fromwire_gpos(ARGS_FROMWIRE) {
49 	int i;
50 
51 	REQUIRE(type == dns_rdatatype_gpos);
52 
53 	UNUSED(type);
54 	UNUSED(dctx);
55 	UNUSED(rdclass);
56 	UNUSED(options);
57 
58 	for (i = 0; i < 3; i++)
59 		RETERR(txt_fromwire(source, target));
60 	return (ISC_R_SUCCESS);
61 }
62 
63 static inline isc_result_t
64 towire_gpos(ARGS_TOWIRE) {
65 
66 	REQUIRE(rdata->type == dns_rdatatype_gpos);
67 	REQUIRE(rdata->length != 0);
68 
69 	UNUSED(cctx);
70 
71 	return (isc_mem_tobuffer(target, rdata->data, rdata->length));
72 }
73 
74 #endif	/* RDATA_GENERIC_GPOS_27_C */
75