1*46f3b50fSchristos /* $NetBSD: amq_xdr.c,v 1.2 2022/08/23 07:42:28 christos Exp $ */
2a53f50b9Schristos
3a53f50b9Schristos /*
48bae5d40Schristos * Copyright (c) 1997-2014 Erez Zadok
5a53f50b9Schristos * Copyright (c) 1990 Jan-Simon Pendry
6a53f50b9Schristos * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7a53f50b9Schristos * Copyright (c) 1990 The Regents of the University of California.
8a53f50b9Schristos * All rights reserved.
9a53f50b9Schristos *
10a53f50b9Schristos * This code is derived from software contributed to Berkeley by
11a53f50b9Schristos * Jan-Simon Pendry at Imperial College, London.
12a53f50b9Schristos *
13a53f50b9Schristos * Redistribution and use in source and binary forms, with or without
14a53f50b9Schristos * modification, are permitted provided that the following conditions
15a53f50b9Schristos * are met:
16a53f50b9Schristos * 1. Redistributions of source code must retain the above copyright
17a53f50b9Schristos * notice, this list of conditions and the following disclaimer.
18a53f50b9Schristos * 2. Redistributions in binary form must reproduce the above copyright
19a53f50b9Schristos * notice, this list of conditions and the following disclaimer in the
20a53f50b9Schristos * documentation and/or other materials provided with the distribution.
218bae5d40Schristos * 3. Neither the name of the University nor the names of its contributors
22a53f50b9Schristos * may be used to endorse or promote products derived from this software
23a53f50b9Schristos * without specific prior written permission.
24a53f50b9Schristos *
25a53f50b9Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26a53f50b9Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27a53f50b9Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28a53f50b9Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29a53f50b9Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30a53f50b9Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31a53f50b9Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32a53f50b9Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33a53f50b9Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34a53f50b9Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35a53f50b9Schristos * SUCH DAMAGE.
36a53f50b9Schristos *
37a53f50b9Schristos *
38a53f50b9Schristos * File: am-utils/amq/amq_xdr.c
39a53f50b9Schristos *
40a53f50b9Schristos */
41a53f50b9Schristos
42a53f50b9Schristos #ifdef HAVE_CONFIG_H
43a53f50b9Schristos # include <config.h>
44a53f50b9Schristos #endif /* HAVE_CONFIG_H */
45a53f50b9Schristos #include <am_defs.h>
46a53f50b9Schristos #include <amq.h>
47a53f50b9Schristos
48a53f50b9Schristos
49a53f50b9Schristos bool_t
xdr_time_type(XDR * xdrs,time_type * objp)50a53f50b9Schristos xdr_time_type(XDR *xdrs, time_type *objp)
51a53f50b9Schristos {
52*46f3b50fSchristos if (!xdr_longlong_t(xdrs, (longlong_t *) objp)) {
53a53f50b9Schristos return (FALSE);
54a53f50b9Schristos }
55a53f50b9Schristos return (TRUE);
56a53f50b9Schristos }
57a53f50b9Schristos
58a53f50b9Schristos
59a53f50b9Schristos bool_t
xdr_amq_mount_tree(XDR * xdrs,amq_mount_tree * objp)60a53f50b9Schristos xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
61a53f50b9Schristos {
62a53f50b9Schristos
63a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) {
64a53f50b9Schristos return (FALSE);
65a53f50b9Schristos }
66a53f50b9Schristos
67a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mt_directory)) {
68a53f50b9Schristos return (FALSE);
69a53f50b9Schristos }
70a53f50b9Schristos
71a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) {
72a53f50b9Schristos return (FALSE);
73a53f50b9Schristos }
74a53f50b9Schristos
75a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mt_type)) {
76a53f50b9Schristos return (FALSE);
77a53f50b9Schristos }
78a53f50b9Schristos
79a53f50b9Schristos if (!xdr_time_type(xdrs, &objp->mt_mounttime)) {
80a53f50b9Schristos return (FALSE);
81a53f50b9Schristos }
82a53f50b9Schristos
83a53f50b9Schristos if (!xdr_u_short(xdrs, &objp->mt_mountuid)) {
84a53f50b9Schristos return (FALSE);
85a53f50b9Schristos }
86a53f50b9Schristos
87a53f50b9Schristos if (!xdr_int(xdrs, &objp->mt_getattr)) {
88a53f50b9Schristos return (FALSE);
89a53f50b9Schristos }
90a53f50b9Schristos
91a53f50b9Schristos if (!xdr_int(xdrs, &objp->mt_lookup)) {
92a53f50b9Schristos return (FALSE);
93a53f50b9Schristos }
94a53f50b9Schristos
95a53f50b9Schristos if (!xdr_int(xdrs, &objp->mt_readdir)) {
96a53f50b9Schristos return (FALSE);
97a53f50b9Schristos }
98a53f50b9Schristos
99a53f50b9Schristos if (!xdr_int(xdrs, &objp->mt_readlink)) {
100a53f50b9Schristos return (FALSE);
101a53f50b9Schristos }
102a53f50b9Schristos
103a53f50b9Schristos if (!xdr_int(xdrs, &objp->mt_statfs)) {
104a53f50b9Schristos return (FALSE);
105a53f50b9Schristos }
106a53f50b9Schristos
107a53f50b9Schristos if (!xdr_pointer(xdrs,
108a53f50b9Schristos (char **) ((voidp) &objp->mt_next),
109a53f50b9Schristos sizeof(amq_mount_tree),
110a53f50b9Schristos (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
111a53f50b9Schristos return (FALSE);
112a53f50b9Schristos }
113a53f50b9Schristos
114a53f50b9Schristos if (!xdr_pointer(xdrs,
115a53f50b9Schristos (char **) ((voidp) &objp->mt_child),
116a53f50b9Schristos sizeof(amq_mount_tree),
117a53f50b9Schristos (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
118a53f50b9Schristos return (FALSE);
119a53f50b9Schristos }
120a53f50b9Schristos
121a53f50b9Schristos return (TRUE);
122a53f50b9Schristos }
123a53f50b9Schristos
124a53f50b9Schristos
125a53f50b9Schristos bool_t
xdr_amq_mount_tree_p(XDR * xdrs,amq_mount_tree_p * objp)126a53f50b9Schristos xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp)
127a53f50b9Schristos {
128a53f50b9Schristos if (!xdr_pointer(xdrs,
129a53f50b9Schristos (char **) objp,
130a53f50b9Schristos sizeof(amq_mount_tree),
131a53f50b9Schristos (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
132a53f50b9Schristos return (FALSE);
133a53f50b9Schristos }
134a53f50b9Schristos return (TRUE);
135a53f50b9Schristos }
136a53f50b9Schristos
137a53f50b9Schristos
138a53f50b9Schristos bool_t
xdr_amq_mount_info(XDR * xdrs,amq_mount_info * objp)139a53f50b9Schristos xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp)
140a53f50b9Schristos {
141a53f50b9Schristos
142a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mi_type)) {
143a53f50b9Schristos return (FALSE);
144a53f50b9Schristos }
145a53f50b9Schristos
146a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) {
147a53f50b9Schristos return (FALSE);
148a53f50b9Schristos }
149a53f50b9Schristos
150a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) {
151a53f50b9Schristos return (FALSE);
152a53f50b9Schristos }
153a53f50b9Schristos
154a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->mi_fserver)) {
155a53f50b9Schristos return (FALSE);
156a53f50b9Schristos }
157a53f50b9Schristos
158a53f50b9Schristos if (!xdr_int(xdrs, &objp->mi_error)) {
159a53f50b9Schristos return (FALSE);
160a53f50b9Schristos }
161a53f50b9Schristos
162a53f50b9Schristos if (!xdr_int(xdrs, &objp->mi_refc)) {
163a53f50b9Schristos return (FALSE);
164a53f50b9Schristos }
165a53f50b9Schristos
166a53f50b9Schristos if (!xdr_int(xdrs, &objp->mi_up)) {
167a53f50b9Schristos return (FALSE);
168a53f50b9Schristos }
169a53f50b9Schristos
170a53f50b9Schristos return (TRUE);
171a53f50b9Schristos }
172a53f50b9Schristos
173a53f50b9Schristos
174a53f50b9Schristos bool_t
xdr_amq_mount_info_list(XDR * xdrs,amq_mount_info_list * objp)175a53f50b9Schristos xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp)
176a53f50b9Schristos {
177a53f50b9Schristos if (!xdr_array(xdrs,
178a53f50b9Schristos (char **) ((voidp) &objp->amq_mount_info_list_val),
179a53f50b9Schristos (u_int *) &objp->amq_mount_info_list_len,
180a53f50b9Schristos ~0,
181a53f50b9Schristos sizeof(amq_mount_info),
182a53f50b9Schristos (XDRPROC_T_TYPE) xdr_amq_mount_info)) {
183a53f50b9Schristos return (FALSE);
184a53f50b9Schristos }
185a53f50b9Schristos return (TRUE);
186a53f50b9Schristos }
187a53f50b9Schristos
1888bae5d40Schristos bool_t
xdr_amq_map_info(XDR * xdrs,amq_map_info * objp)1898bae5d40Schristos xdr_amq_map_info(XDR *xdrs, amq_map_info *objp)
1908bae5d40Schristos {
1918bae5d40Schristos if (!xdr_amq_string(xdrs, &objp->mi_name)) {
1928bae5d40Schristos return (FALSE);
1938bae5d40Schristos }
1948bae5d40Schristos
1958bae5d40Schristos if (!xdr_amq_string(xdrs, &objp->mi_wildcard)) {
1968bae5d40Schristos return (FALSE);
1978bae5d40Schristos }
1988bae5d40Schristos
1998bae5d40Schristos if (!xdr_time_type(xdrs, &objp->mi_modify)) {
2008bae5d40Schristos return (FALSE);
2018bae5d40Schristos }
2028bae5d40Schristos
2038bae5d40Schristos if (!xdr_int(xdrs, &objp->mi_flags)) {
2048bae5d40Schristos return (FALSE);
2058bae5d40Schristos }
2068bae5d40Schristos
2078bae5d40Schristos if (!xdr_int(xdrs, &objp->mi_nentries)) {
2088bae5d40Schristos return (FALSE);
2098bae5d40Schristos }
2108bae5d40Schristos
2118bae5d40Schristos if (!xdr_int(xdrs, &objp->mi_reloads)) {
2128bae5d40Schristos return (FALSE);
2138bae5d40Schristos }
2148bae5d40Schristos
2158bae5d40Schristos if (!xdr_int(xdrs, &objp->mi_refc)) {
2168bae5d40Schristos return (FALSE);
2178bae5d40Schristos }
2188bae5d40Schristos
2198bae5d40Schristos if (!xdr_int(xdrs, &objp->mi_up)) {
2208bae5d40Schristos return (FALSE);
2218bae5d40Schristos }
2228bae5d40Schristos
2238bae5d40Schristos return (TRUE);
2248bae5d40Schristos }
2258bae5d40Schristos
2268bae5d40Schristos
2278bae5d40Schristos bool_t
xdr_amq_map_info_list(XDR * xdrs,amq_map_info_list * objp)2288bae5d40Schristos xdr_amq_map_info_list(XDR *xdrs, amq_map_info_list *objp)
2298bae5d40Schristos {
2308bae5d40Schristos if (!xdr_array(xdrs,
2318bae5d40Schristos (char **) ((voidp) &objp->amq_map_info_list_val),
2328bae5d40Schristos (u_int *) &objp->amq_map_info_list_len,
2338bae5d40Schristos ~0,
2348bae5d40Schristos sizeof(amq_map_info),
2358bae5d40Schristos (XDRPROC_T_TYPE) xdr_amq_map_info)) {
2368bae5d40Schristos return (FALSE);
2378bae5d40Schristos }
2388bae5d40Schristos return (TRUE);
2398bae5d40Schristos }
2408bae5d40Schristos
241a53f50b9Schristos
242a53f50b9Schristos bool_t
xdr_amq_mount_tree_list(XDR * xdrs,amq_mount_tree_list * objp)243a53f50b9Schristos xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp)
244a53f50b9Schristos {
245a53f50b9Schristos if (!xdr_array(xdrs,
246a53f50b9Schristos (char **) ((voidp) &objp->amq_mount_tree_list_val),
247a53f50b9Schristos (u_int *) &objp->amq_mount_tree_list_len,
248a53f50b9Schristos ~0,
249a53f50b9Schristos sizeof(amq_mount_tree_p),
250a53f50b9Schristos (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) {
251a53f50b9Schristos return (FALSE);
252a53f50b9Schristos }
253a53f50b9Schristos return (TRUE);
254a53f50b9Schristos }
255a53f50b9Schristos
256a53f50b9Schristos
257a53f50b9Schristos bool_t
xdr_amq_mount_stats(XDR * xdrs,amq_mount_stats * objp)258a53f50b9Schristos xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp)
259a53f50b9Schristos {
260a53f50b9Schristos
261a53f50b9Schristos if (!xdr_int(xdrs, &objp->as_drops)) {
262a53f50b9Schristos return (FALSE);
263a53f50b9Schristos }
264a53f50b9Schristos
265a53f50b9Schristos if (!xdr_int(xdrs, &objp->as_stale)) {
266a53f50b9Schristos return (FALSE);
267a53f50b9Schristos }
268a53f50b9Schristos
269a53f50b9Schristos if (!xdr_int(xdrs, &objp->as_mok)) {
270a53f50b9Schristos return (FALSE);
271a53f50b9Schristos }
272a53f50b9Schristos
273a53f50b9Schristos if (!xdr_int(xdrs, &objp->as_merr)) {
274a53f50b9Schristos return (FALSE);
275a53f50b9Schristos }
276a53f50b9Schristos
277a53f50b9Schristos if (!xdr_int(xdrs, &objp->as_uerr)) {
278a53f50b9Schristos return (FALSE);
279a53f50b9Schristos }
280a53f50b9Schristos
281a53f50b9Schristos return (TRUE);
282a53f50b9Schristos }
283a53f50b9Schristos
284a53f50b9Schristos
285a53f50b9Schristos bool_t
xdr_amq_opt(XDR * xdrs,amq_opt * objp)286a53f50b9Schristos xdr_amq_opt(XDR *xdrs, amq_opt *objp)
287a53f50b9Schristos {
288a53f50b9Schristos if (!xdr_enum(xdrs, (enum_t *) objp)) {
289a53f50b9Schristos return (FALSE);
290a53f50b9Schristos }
291a53f50b9Schristos return (TRUE);
292a53f50b9Schristos }
293a53f50b9Schristos
294a53f50b9Schristos
295a53f50b9Schristos bool_t
xdr_amq_setopt(XDR * xdrs,amq_setopt * objp)296a53f50b9Schristos xdr_amq_setopt(XDR *xdrs, amq_setopt *objp)
297a53f50b9Schristos {
298a53f50b9Schristos
299a53f50b9Schristos if (!xdr_amq_opt(xdrs, &objp->as_opt)) {
300a53f50b9Schristos return (FALSE);
301a53f50b9Schristos }
302a53f50b9Schristos
303a53f50b9Schristos if (!xdr_amq_string(xdrs, &objp->as_str)) {
304a53f50b9Schristos return (FALSE);
305a53f50b9Schristos }
306a53f50b9Schristos
307a53f50b9Schristos return (TRUE);
308a53f50b9Schristos }
309a53f50b9Schristos
310a53f50b9Schristos
311a53f50b9Schristos bool_t
xdr_pri_free(XDRPROC_T_TYPE xdr_args,caddr_t args_ptr)312a53f50b9Schristos xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr)
313a53f50b9Schristos {
314a53f50b9Schristos XDR xdr;
315a53f50b9Schristos
316a53f50b9Schristos xdr.x_op = XDR_FREE;
317a53f50b9Schristos return ((*xdr_args) (&xdr, (caddr_t *) args_ptr));
318a53f50b9Schristos }
319