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