1 /* 2 * Copyright (c) 2009, Sun Microsystems, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * - Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * - Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * - Neither the name of Sun Microsystems, Inc. nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 /* 29 * Copyright 1991 Sun Microsystems, Inc. 30 * rpcb_stat_xdr.c 31 */ 32 33 /* 34 * This file was generated from rpcb_prot.x, but includes only those 35 * routines used with the rpcbind stats facility. 36 */ 37 38 //#include <sys/cdefs.h> 39 40 #include <wintirpc.h> 41 #include <rpc/rpc.h> 42 #ifdef __REACTOS__ // CVE-2017-8779 43 #include "rpc_com.h" 44 #endif 45 46 /* Link list of all the stats about getport and getaddr */ 47 48 bool_t 49 xdr_rpcbs_addrlist(xdrs, objp) 50 XDR *xdrs; 51 rpcbs_addrlist *objp; 52 { 53 54 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 55 return (FALSE); 56 } 57 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 58 return (FALSE); 59 } 60 if (!xdr_int(xdrs, &objp->success)) { 61 return (FALSE); 62 } 63 if (!xdr_int(xdrs, &objp->failure)) { 64 return (FALSE); 65 } 66 #ifdef __REACTOS__ // CVE-2017-8779 67 if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { 68 #else 69 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 70 #endif 71 return (FALSE); 72 } 73 74 if (!xdr_pointer(xdrs, (char **)&objp->next, 75 sizeof (rpcbs_addrlist), 76 (xdrproc_t)xdr_rpcbs_addrlist)) { 77 return (FALSE); 78 } 79 80 return (TRUE); 81 } 82 83 /* Link list of all the stats about rmtcall */ 84 85 bool_t 86 xdr_rpcbs_rmtcalllist(xdrs, objp) 87 XDR *xdrs; 88 rpcbs_rmtcalllist *objp; 89 { 90 int32_t *buf; 91 92 if (xdrs->x_op == XDR_ENCODE) { 93 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); 94 if (buf == NULL) { 95 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 96 return (FALSE); 97 } 98 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 99 return (FALSE); 100 } 101 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 102 return (FALSE); 103 } 104 if (!xdr_int(xdrs, &objp->success)) { 105 return (FALSE); 106 } 107 if (!xdr_int(xdrs, &objp->failure)) { 108 return (FALSE); 109 } 110 if (!xdr_int(xdrs, &objp->indirect)) { 111 return (FALSE); 112 } 113 } else { 114 IXDR_PUT_U_INT32(buf, objp->prog); 115 IXDR_PUT_U_INT32(buf, objp->vers); 116 IXDR_PUT_U_INT32(buf, objp->proc); 117 IXDR_PUT_INT32(buf, objp->success); 118 IXDR_PUT_INT32(buf, objp->failure); 119 IXDR_PUT_INT32(buf, objp->indirect); 120 } 121 #ifdef __REACTOS__ // CVE-2017-8779 122 if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { 123 #else 124 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 125 #endif 126 return (FALSE); 127 } 128 if (!xdr_pointer(xdrs, (char **)&objp->next, 129 sizeof (rpcbs_rmtcalllist), 130 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 131 return (FALSE); 132 } 133 return (TRUE); 134 } else if (xdrs->x_op == XDR_DECODE) { 135 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); 136 if (buf == NULL) { 137 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 138 return (FALSE); 139 } 140 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 141 return (FALSE); 142 } 143 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 144 return (FALSE); 145 } 146 if (!xdr_int(xdrs, &objp->success)) { 147 return (FALSE); 148 } 149 if (!xdr_int(xdrs, &objp->failure)) { 150 return (FALSE); 151 } 152 if (!xdr_int(xdrs, &objp->indirect)) { 153 return (FALSE); 154 } 155 } else { 156 objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf); 157 objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf); 158 objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf); 159 objp->success = (int)IXDR_GET_INT32(buf); 160 objp->failure = (int)IXDR_GET_INT32(buf); 161 objp->indirect = (int)IXDR_GET_INT32(buf); 162 } 163 #ifdef __REACTOS__ // CVE-2017-8779 164 if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { 165 #else 166 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 167 #endif 168 return (FALSE); 169 } 170 if (!xdr_pointer(xdrs, (char **)&objp->next, 171 sizeof (rpcbs_rmtcalllist), 172 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 173 return (FALSE); 174 } 175 return (TRUE); 176 } 177 if (!xdr_u_int32_t(xdrs, &objp->prog)) { 178 return (FALSE); 179 } 180 if (!xdr_u_int32_t(xdrs, &objp->vers)) { 181 return (FALSE); 182 } 183 if (!xdr_u_int32_t(xdrs, &objp->proc)) { 184 return (FALSE); 185 } 186 if (!xdr_int(xdrs, &objp->success)) { 187 return (FALSE); 188 } 189 if (!xdr_int(xdrs, &objp->failure)) { 190 return (FALSE); 191 } 192 if (!xdr_int(xdrs, &objp->indirect)) { 193 return (FALSE); 194 } 195 #ifdef __REACTOS__ // CVE-2017-8779 196 if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { 197 #else 198 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) { 199 #endif 200 return (FALSE); 201 } 202 if (!xdr_pointer(xdrs, (char **)&objp->next, 203 sizeof (rpcbs_rmtcalllist), 204 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 205 return (FALSE); 206 } 207 return (TRUE); 208 } 209 210 bool_t 211 xdr_rpcbs_proc(xdrs, objp) 212 XDR *xdrs; 213 rpcbs_proc objp; 214 { 215 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC, 216 sizeof (int), (xdrproc_t)xdr_int)) { 217 return (FALSE); 218 } 219 return (TRUE); 220 } 221 222 bool_t 223 xdr_rpcbs_addrlist_ptr(xdrs, objp) 224 XDR *xdrs; 225 rpcbs_addrlist_ptr *objp; 226 { 227 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist), 228 (xdrproc_t)xdr_rpcbs_addrlist)) { 229 return (FALSE); 230 } 231 return (TRUE); 232 } 233 234 bool_t 235 xdr_rpcbs_rmtcalllist_ptr(xdrs, objp) 236 XDR *xdrs; 237 rpcbs_rmtcalllist_ptr *objp; 238 { 239 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist), 240 (xdrproc_t)xdr_rpcbs_rmtcalllist)) { 241 return (FALSE); 242 } 243 return (TRUE); 244 } 245 246 bool_t 247 xdr_rpcb_stat(xdrs, objp) 248 XDR *xdrs; 249 rpcb_stat *objp; 250 { 251 252 if (!xdr_rpcbs_proc(xdrs, objp->info)) { 253 return (FALSE); 254 } 255 if (!xdr_int(xdrs, &objp->setinfo)) { 256 return (FALSE); 257 } 258 if (!xdr_int(xdrs, &objp->unsetinfo)) { 259 return (FALSE); 260 } 261 if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) { 262 return (FALSE); 263 } 264 if (!xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo)) { 265 return (FALSE); 266 } 267 return (TRUE); 268 } 269 270 /* 271 * One rpcb_stat structure is returned for each version of rpcbind 272 * being monitored. 273 */ 274 bool_t 275 xdr_rpcb_stat_byvers(xdrs, objp) 276 XDR *xdrs; 277 rpcb_stat_byvers objp; 278 { 279 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT, 280 sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) { 281 return (FALSE); 282 } 283 return (TRUE); 284 } 285