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