1 /* $NetBSD: rpcb_st_xdr.c,v 1.6 2003/09/09 03:56:40 itojun Exp $ */ 2 3 /* 4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 5 * unrestricted use provided that this legend is included on all tape 6 * media and as a part of the software program in whole or part. Users 7 * may copy or modify Sun RPC without charge, but are not authorized 8 * to license or distribute it to anyone else except as part of a product or 9 * program developed by the user. 10 * 11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 14 * 15 * Sun RPC is provided with no support and without any obligation on the 16 * part of Sun Microsystems, Inc. to assist in its use, correction, 17 * modification or enhancement. 18 * 19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 21 * OR ANY PART THEREOF. 22 * 23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 24 * or profits or other special, indirect and consequential damages, even if 25 * Sun has been advised of the possibility of such damages. 26 * 27 * Sun Microsystems, Inc. 28 * 2550 Garcia Avenue 29 * Mountain View, California 94043 30 */ 31 /* 32 * Copyright 1991 Sun Microsystems, Inc. 33 * rpcb_stat_xdr.c 34 */ 35 36 /* 37 * This file was generated from rpcb_prot.x, but includes only those 38 * routines used with the rpcbind stats facility. 39 */ 40 41 #include <sys/cdefs.h> 42 #if defined(LIBC_SCCS) && !defined(lint) 43 __RCSID("$NetBSD: rpcb_st_xdr.c,v 1.6 2003/09/09 03:56:40 itojun Exp $"); 44 #endif 45 46 #include "namespace.h" 47 #include <rpc/rpc.h> 48 49 #include <assert.h> 50 51 /* Link list of all the stats about getport and getaddr */ 52 53 #ifdef __weak_alias 54 __weak_alias(xdr_rpcbs_addrlist,_xdr_rpcbs_addrlist) 55 __weak_alias(xdr_rpcbs_rmtcalllist,_xdr_rpcbs_rmtcalllist) 56 __weak_alias(xdr_rpcbs_proc,_xdr_rpcbs_proc) 57 __weak_alias(xdr_rpcbs_addrlist_ptr,_xdr_rpcbs_addrlist_ptr) 58 __weak_alias(xdr_rpcbs_rmtcalllist_ptr,_xdr_rpcbs_rmtcalllist_ptr) 59 __weak_alias(xdr_rpcb_stat,_xdr_rpcb_stat) 60 __weak_alias(xdr_rpcb_stat_byvers,_xdr_rpcb_stat_byvers) 61 #endif 62 63 bool_t 64 xdr_rpcbs_addrlist(xdrs, objp) 65 XDR *xdrs; 66 rpcbs_addrlist *objp; 67 { 68 69 _DIAGASSERT(objp != NULL); 70 71 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 72 return (FALSE); 73 } 74 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 75 return (FALSE); 76 } 77 if (!xdr_int(xdrs, &objp->success)) { 78 return (FALSE); 79 } 80 if (!xdr_int(xdrs, &objp->failure)) { 81 return (FALSE); 82 } 83 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 84 return (FALSE); 85 } 86 87 if (!xdr_pointer(xdrs, (char **)&objp->next, 88 sizeof (rpcbs_addrlist), 89 (xdrproc_t)xdr_rpcbs_addrlist)) { 90 return (FALSE); 91 } 92 93 return (TRUE); 94 } 95 96 /* Link list of all the stats about rmtcall */ 97 98 bool_t 99 xdr_rpcbs_rmtcalllist(xdrs, objp) 100 XDR *xdrs; 101 rpcbs_rmtcalllist *objp; 102 { 103 int32_t *buf; 104 105 _DIAGASSERT(xdrs != NULL); 106 _DIAGASSERT(objp != NULL); 107 108 if (xdrs->x_op == XDR_ENCODE) { 109 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); 110 if (buf == NULL) { 111 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 112 return (FALSE); 113 } 114 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 115 return (FALSE); 116 } 117 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 118 return (FALSE); 119 } 120 if (!xdr_int(xdrs, &objp->success)) { 121 return (FALSE); 122 } 123 if (!xdr_int(xdrs, &objp->failure)) { 124 return (FALSE); 125 } 126 if (!xdr_int(xdrs, &objp->indirect)) { 127 return (FALSE); 128 } 129 } else { 130 IXDR_PUT_U_INT32(buf, objp->prog); 131 IXDR_PUT_U_INT32(buf, objp->vers); 132 IXDR_PUT_U_INT32(buf, objp->proc); 133 IXDR_PUT_INT32(buf, objp->success); 134 IXDR_PUT_INT32(buf, objp->failure); 135 IXDR_PUT_INT32(buf, objp->indirect); 136 } 137 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 138 return (FALSE); 139 } 140 if (!xdr_pointer(xdrs, (char **)&objp->next, 141 sizeof (rpcbs_rmtcalllist), 142 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 143 return (FALSE); 144 } 145 return (TRUE); 146 } else if (xdrs->x_op == XDR_DECODE) { 147 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); 148 if (buf == NULL) { 149 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 150 return (FALSE); 151 } 152 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 153 return (FALSE); 154 } 155 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 156 return (FALSE); 157 } 158 if (!xdr_int(xdrs, &objp->success)) { 159 return (FALSE); 160 } 161 if (!xdr_int(xdrs, &objp->failure)) { 162 return (FALSE); 163 } 164 if (!xdr_int(xdrs, &objp->indirect)) { 165 return (FALSE); 166 } 167 } else { 168 objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf); 169 objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf); 170 objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf); 171 objp->success = (int)IXDR_GET_INT32(buf); 172 objp->failure = (int)IXDR_GET_INT32(buf); 173 objp->indirect = (int)IXDR_GET_INT32(buf); 174 } 175 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 176 return (FALSE); 177 } 178 if (!xdr_pointer(xdrs, (char **)&objp->next, 179 sizeof (rpcbs_rmtcalllist), 180 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 181 return (FALSE); 182 } 183 return (TRUE); 184 } 185 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 186 return (FALSE); 187 } 188 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 189 return (FALSE); 190 } 191 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 192 return (FALSE); 193 } 194 if (!xdr_int(xdrs, &objp->success)) { 195 return (FALSE); 196 } 197 if (!xdr_int(xdrs, &objp->failure)) { 198 return (FALSE); 199 } 200 if (!xdr_int(xdrs, &objp->indirect)) { 201 return (FALSE); 202 } 203 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 204 return (FALSE); 205 } 206 if (!xdr_pointer(xdrs, (char **)&objp->next, 207 sizeof (rpcbs_rmtcalllist), 208 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 209 return (FALSE); 210 } 211 return (TRUE); 212 } 213 214 bool_t 215 xdr_rpcbs_proc(xdrs, objp) 216 XDR *xdrs; 217 rpcbs_proc objp; 218 { 219 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC, 220 sizeof (int), (xdrproc_t)xdr_int)) { 221 return (FALSE); 222 } 223 return (TRUE); 224 } 225 226 bool_t 227 xdr_rpcbs_addrlist_ptr(xdrs, objp) 228 XDR *xdrs; 229 rpcbs_addrlist_ptr *objp; 230 { 231 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist), 232 (xdrproc_t)xdr_rpcbs_addrlist)) { 233 return (FALSE); 234 } 235 return (TRUE); 236 } 237 238 bool_t 239 xdr_rpcbs_rmtcalllist_ptr(xdrs, objp) 240 XDR *xdrs; 241 rpcbs_rmtcalllist_ptr *objp; 242 { 243 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist), 244 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 245 return (FALSE); 246 } 247 return (TRUE); 248 } 249 250 bool_t 251 xdr_rpcb_stat(xdrs, objp) 252 XDR *xdrs; 253 rpcb_stat *objp; 254 { 255 256 _DIAGASSERT(objp != NULL); 257 258 if (!xdr_rpcbs_proc(xdrs, objp->info)) { 259 return (FALSE); 260 } 261 if (!xdr_int(xdrs, &objp->setinfo)) { 262 return (FALSE); 263 } 264 if (!xdr_int(xdrs, &objp->unsetinfo)) { 265 return (FALSE); 266 } 267 if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) { 268 return (FALSE); 269 } 270 return (TRUE); 271 } 272 273 /* 274 * One rpcb_stat structure is returned for each version of rpcbind 275 * being monitored. 276 */ 277 bool_t 278 xdr_rpcb_stat_byvers(xdrs, objp) 279 XDR *xdrs; 280 rpcb_stat_byvers objp; 281 { 282 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT, 283 sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) { 284 return (FALSE); 285 } 286 return (TRUE); 287 } 288