Home | History | Annotate | Line # | Download | only in rpc
rpcb_st_xdr.c revision 1.9
      1 /*	$NetBSD: rpcb_st_xdr.c,v 1.9 2012/06/25 22:32:45 abs 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.9 2012/06/25 22:32:45 abs 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(XDR *xdrs, rpcbs_addrlist *objp)
     65 {
     66 
     67 	_DIAGASSERT(objp != NULL);
     68 
     69 	    if (!xdr_u_int32_t(xdrs, &objp->prog)) {
     70 		return (FALSE);
     71 	    }
     72 	    if (!xdr_u_int32_t(xdrs, &objp->vers)) {
     73 		return (FALSE);
     74 	    }
     75 	    if (!xdr_int(xdrs, &objp->success)) {
     76 		return (FALSE);
     77 	    }
     78 	    if (!xdr_int(xdrs, &objp->failure)) {
     79 		return (FALSE);
     80 	    }
     81 	    if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
     82 		return (FALSE);
     83 	    }
     84 
     85 	    if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
     86 			(u_int)sizeof (rpcbs_addrlist),
     87 			(xdrproc_t)xdr_rpcbs_addrlist)) {
     88 		return (FALSE);
     89 	    }
     90 
     91 	return (TRUE);
     92 }
     93 
     94 /* Link list of all the stats about rmtcall */
     95 
     96 bool_t
     97 xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
     98 {
     99 	int32_t *buf;
    100 
    101 	_DIAGASSERT(xdrs != NULL);
    102 	_DIAGASSERT(objp != NULL);
    103 
    104 	if (xdrs->x_op == XDR_ENCODE) {
    105 	buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
    106 	if (buf == NULL) {
    107 		if (!xdr_u_int32_t(xdrs, &objp->prog)) {
    108 			return (FALSE);
    109 		}
    110 		if (!xdr_u_int32_t(xdrs, &objp->vers)) {
    111 			return (FALSE);
    112 		}
    113 		if (!xdr_u_int32_t(xdrs, &objp->proc)) {
    114 			return (FALSE);
    115 		}
    116 		if (!xdr_int(xdrs, &objp->success)) {
    117 			return (FALSE);
    118 		}
    119 		if (!xdr_int(xdrs, &objp->failure)) {
    120 			return (FALSE);
    121 		}
    122 		if (!xdr_int(xdrs, &objp->indirect)) {
    123 			return (FALSE);
    124 		}
    125 	} else {
    126 		IXDR_PUT_U_INT32(buf, objp->prog);
    127 		IXDR_PUT_U_INT32(buf, objp->vers);
    128 		IXDR_PUT_U_INT32(buf, objp->proc);
    129 		IXDR_PUT_INT32(buf, objp->success);
    130 		IXDR_PUT_INT32(buf, objp->failure);
    131 		IXDR_PUT_INT32(buf, objp->indirect);
    132 	}
    133 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
    134 		return (FALSE);
    135 	}
    136 	if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
    137 			(u_int)sizeof (rpcbs_rmtcalllist),
    138 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
    139 		return (FALSE);
    140 	}
    141 	return (TRUE);
    142 	} else if (xdrs->x_op == XDR_DECODE) {
    143 	buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
    144 	if (buf == NULL) {
    145 		if (!xdr_u_int32_t(xdrs, &objp->prog)) {
    146 			return (FALSE);
    147 		}
    148 		if (!xdr_u_int32_t(xdrs, &objp->vers)) {
    149 			return (FALSE);
    150 		}
    151 		if (!xdr_u_int32_t(xdrs, &objp->proc)) {
    152 			return (FALSE);
    153 		}
    154 		if (!xdr_int(xdrs, &objp->success)) {
    155 			return (FALSE);
    156 		}
    157 		if (!xdr_int(xdrs, &objp->failure)) {
    158 			return (FALSE);
    159 		}
    160 		if (!xdr_int(xdrs, &objp->indirect)) {
    161 			return (FALSE);
    162 		}
    163 	} else {
    164 		objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
    165 		objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
    166 		objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
    167 		objp->success = (int)IXDR_GET_INT32(buf);
    168 		objp->failure = (int)IXDR_GET_INT32(buf);
    169 		objp->indirect = (int)IXDR_GET_INT32(buf);
    170 	}
    171 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
    172 		return (FALSE);
    173 	}
    174 	if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
    175 			(u_int)sizeof (rpcbs_rmtcalllist),
    176 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
    177 		return (FALSE);
    178 	}
    179 	return (TRUE);
    180 	}
    181 	if (!xdr_u_int32_t(xdrs, &objp->prog)) {
    182 		return (FALSE);
    183 	}
    184 	if (!xdr_u_int32_t(xdrs, &objp->vers)) {
    185 		return (FALSE);
    186 	}
    187 	if (!xdr_u_int32_t(xdrs, &objp->proc)) {
    188 		return (FALSE);
    189 	}
    190 	if (!xdr_int(xdrs, &objp->success)) {
    191 		return (FALSE);
    192 	}
    193 	if (!xdr_int(xdrs, &objp->failure)) {
    194 		return (FALSE);
    195 	}
    196 	if (!xdr_int(xdrs, &objp->indirect)) {
    197 		return (FALSE);
    198 	}
    199 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
    200 		return (FALSE);
    201 	}
    202 	if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
    203 			(u_int)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(XDR *xdrs, rpcbs_proc objp)
    212 {
    213 	if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC,
    214 	    (u_int)sizeof (int), (xdrproc_t)xdr_int)) {
    215 		return (FALSE);
    216 	}
    217 	return (TRUE);
    218 }
    219 
    220 bool_t
    221 xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp)
    222 {
    223 	if (!xdr_pointer(xdrs, (char **)objp, (u_int)sizeof (rpcbs_addrlist),
    224 			(xdrproc_t)xdr_rpcbs_addrlist)) {
    225 		return (FALSE);
    226 	}
    227 	return (TRUE);
    228 }
    229 
    230 bool_t
    231 xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
    232 {
    233 	if (!xdr_pointer(xdrs, (char **)objp, (u_int)sizeof (rpcbs_rmtcalllist),
    234 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
    235 		return (FALSE);
    236 	}
    237 	return (TRUE);
    238 }
    239 
    240 bool_t
    241 xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
    242 {
    243 
    244 	_DIAGASSERT(objp != NULL);
    245 
    246 	if (!xdr_rpcbs_proc(xdrs, objp->info)) {
    247 		return (FALSE);
    248 	}
    249 	if (!xdr_int(xdrs, &objp->setinfo)) {
    250 		return (FALSE);
    251 	}
    252 	if (!xdr_int(xdrs, &objp->unsetinfo)) {
    253 		return (FALSE);
    254 	}
    255 	if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) {
    256 		return (FALSE);
    257 	}
    258 	return (TRUE);
    259 }
    260 
    261 /*
    262  * One rpcb_stat structure is returned for each version of rpcbind
    263  * being monitored.
    264  */
    265 bool_t
    266 xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
    267 {
    268 	if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT,
    269 	    (u_int)sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
    270 		return (FALSE);
    271 	}
    272 	return (TRUE);
    273 }
    274