xref: /titanic_52/usr/src/lib/libnsl/rpc/rpcb_st_xdr.c (revision e8031f0a8ed0e45c6d8847c5e09424e66fd34a4b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
2261961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*
24*e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * This file was generated from rpcb_prot.x, but includes only those
327c478bd9Sstevel@tonic-gate  * routines used with the rpcbind stats facility.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
35*e8031f0aSraf #include "mt.h"
367c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /* Link list of all the stats about getport and getaddr */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate bool_t
4161961e0fSrobinson xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
427c478bd9Sstevel@tonic-gate {
4361961e0fSrobinson 	if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
447c478bd9Sstevel@tonic-gate 		return (FALSE);
4561961e0fSrobinson 	if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
467c478bd9Sstevel@tonic-gate 		return (FALSE);
4761961e0fSrobinson 	if (!xdr_int(xdrs, &objp->success))
487c478bd9Sstevel@tonic-gate 		return (FALSE);
4961961e0fSrobinson 	if (!xdr_int(xdrs, &objp->failure))
507c478bd9Sstevel@tonic-gate 		return (FALSE);
5161961e0fSrobinson 	return (xdr_string(xdrs, &objp->netid, ~0));
527c478bd9Sstevel@tonic-gate }
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /* Link list of all the stats about rmtcall */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate bool_t
5761961e0fSrobinson xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
587c478bd9Sstevel@tonic-gate {
5961961e0fSrobinson 	rpc_inline_t *buf;
607c478bd9Sstevel@tonic-gate 
6161961e0fSrobinson 	switch (xdrs->x_op) {
6261961e0fSrobinson 	case XDR_ENCODE:
637c478bd9Sstevel@tonic-gate 		buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
647c478bd9Sstevel@tonic-gate 		if (buf == NULL) {
6561961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
667c478bd9Sstevel@tonic-gate 				return (FALSE);
6761961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
687c478bd9Sstevel@tonic-gate 				return (FALSE);
6961961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
707c478bd9Sstevel@tonic-gate 				return (FALSE);
7161961e0fSrobinson 			if (!xdr_int(xdrs, &objp->success))
727c478bd9Sstevel@tonic-gate 				return (FALSE);
7361961e0fSrobinson 			if (!xdr_int(xdrs, &objp->failure))
747c478bd9Sstevel@tonic-gate 				return (FALSE);
7561961e0fSrobinson 			if (!xdr_int(xdrs, &objp->indirect))
767c478bd9Sstevel@tonic-gate 				return (FALSE);
777c478bd9Sstevel@tonic-gate 		} else {
787c478bd9Sstevel@tonic-gate 			IXDR_PUT_U_INT32(buf, objp->prog);
797c478bd9Sstevel@tonic-gate 			IXDR_PUT_U_INT32(buf, objp->vers);
807c478bd9Sstevel@tonic-gate 			IXDR_PUT_U_INT32(buf, objp->proc);
817c478bd9Sstevel@tonic-gate 			IXDR_PUT_INT32(buf, objp->success);
827c478bd9Sstevel@tonic-gate 			IXDR_PUT_INT32(buf, objp->failure);
837c478bd9Sstevel@tonic-gate 			IXDR_PUT_INT32(buf, objp->indirect);
847c478bd9Sstevel@tonic-gate 		}
8561961e0fSrobinson 		if (!xdr_string(xdrs, &objp->netid, ~0))
867c478bd9Sstevel@tonic-gate 			return (FALSE);
8761961e0fSrobinson 		return (xdr_pointer(xdrs, (char **)&objp->next,
887c478bd9Sstevel@tonic-gate 				(uint_t)sizeof (rpcbs_rmtcalllist),
8961961e0fSrobinson 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
9061961e0fSrobinson 	case XDR_DECODE:
917c478bd9Sstevel@tonic-gate 		buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
927c478bd9Sstevel@tonic-gate 		if (buf == NULL) {
9361961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
947c478bd9Sstevel@tonic-gate 				return (FALSE);
9561961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
967c478bd9Sstevel@tonic-gate 				return (FALSE);
9761961e0fSrobinson 			if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
987c478bd9Sstevel@tonic-gate 				return (FALSE);
9961961e0fSrobinson 			if (!xdr_int(xdrs, &objp->success))
1007c478bd9Sstevel@tonic-gate 				return (FALSE);
10161961e0fSrobinson 			if (!xdr_int(xdrs, &objp->failure))
1027c478bd9Sstevel@tonic-gate 				return (FALSE);
10361961e0fSrobinson 			if (!xdr_int(xdrs, &objp->indirect))
1047c478bd9Sstevel@tonic-gate 				return (FALSE);
1057c478bd9Sstevel@tonic-gate 		} else {
1067c478bd9Sstevel@tonic-gate 			objp->prog = IXDR_GET_U_INT32(buf);
1077c478bd9Sstevel@tonic-gate 			objp->vers = IXDR_GET_U_INT32(buf);
1087c478bd9Sstevel@tonic-gate 			objp->proc = IXDR_GET_U_INT32(buf);
1097c478bd9Sstevel@tonic-gate 			objp->success = IXDR_GET_INT32(buf);
1107c478bd9Sstevel@tonic-gate 			objp->failure = IXDR_GET_INT32(buf);
1117c478bd9Sstevel@tonic-gate 			objp->indirect = IXDR_GET_INT32(buf);
1127c478bd9Sstevel@tonic-gate 		}
11361961e0fSrobinson 		if (!xdr_string(xdrs, &objp->netid, ~0))
1147c478bd9Sstevel@tonic-gate 			return (FALSE);
11561961e0fSrobinson 		return (xdr_pointer(xdrs, (char **)&objp->next,
1167c478bd9Sstevel@tonic-gate 				(uint_t)sizeof (rpcbs_rmtcalllist),
11761961e0fSrobinson 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
11861961e0fSrobinson 	case XDR_FREE:
11961961e0fSrobinson 		if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
1207c478bd9Sstevel@tonic-gate 			return (FALSE);
12161961e0fSrobinson 		if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
1227c478bd9Sstevel@tonic-gate 			return (FALSE);
12361961e0fSrobinson 		if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
1247c478bd9Sstevel@tonic-gate 			return (FALSE);
12561961e0fSrobinson 		if (!xdr_int(xdrs, &objp->success))
1267c478bd9Sstevel@tonic-gate 			return (FALSE);
12761961e0fSrobinson 		if (!xdr_int(xdrs, &objp->failure))
1287c478bd9Sstevel@tonic-gate 			return (FALSE);
12961961e0fSrobinson 		if (!xdr_int(xdrs, &objp->indirect))
1307c478bd9Sstevel@tonic-gate 			return (FALSE);
13161961e0fSrobinson 		if (!xdr_string(xdrs, &objp->netid, ~0))
1327c478bd9Sstevel@tonic-gate 			return (FALSE);
13361961e0fSrobinson 		return (xdr_pointer(xdrs, (char **)&objp->next,
1347c478bd9Sstevel@tonic-gate 				(uint_t)sizeof (rpcbs_rmtcalllist),
13561961e0fSrobinson 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
13661961e0fSrobinson 	default:
1377c478bd9Sstevel@tonic-gate 		return (FALSE);
1387c478bd9Sstevel@tonic-gate 	}
1397c478bd9Sstevel@tonic-gate }
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate bool_t
14261961e0fSrobinson xdr_rpcbs_proc(XDR *xdrs, rpcbs_proc objp)
1437c478bd9Sstevel@tonic-gate {
14461961e0fSrobinson 	return (xdr_vector(xdrs, (char *)objp, RPCBSTAT_HIGHPROC, sizeof (int),
14561961e0fSrobinson 			(xdrproc_t)xdr_int));
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate bool_t
14961961e0fSrobinson xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp)
1507c478bd9Sstevel@tonic-gate {
1517c478bd9Sstevel@tonic-gate 	bool_t			more_data;
1527c478bd9Sstevel@tonic-gate 	rpcbs_addrlist_ptr	*nextp;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	for (;;) {
1557c478bd9Sstevel@tonic-gate 		more_data = (*objp != NULL);
1567c478bd9Sstevel@tonic-gate 
15761961e0fSrobinson 		if (!xdr_bool(xdrs, &more_data))
1587c478bd9Sstevel@tonic-gate 			return (FALSE);
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 		if (!more_data)
1617c478bd9Sstevel@tonic-gate 			break;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 		if (xdrs->x_op == XDR_FREE)
1647c478bd9Sstevel@tonic-gate 			nextp = &(*objp)->next;
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 		if (!xdr_reference(xdrs, (char **)objp,
1677c478bd9Sstevel@tonic-gate 			(uint_t)sizeof (rpcbs_addrlist),
16861961e0fSrobinson 			(xdrproc_t)xdr_rpcbs_addrlist))
1697c478bd9Sstevel@tonic-gate 			return (FALSE);
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 		objp = (xdrs->x_op == XDR_FREE) ? nextp : &(*objp)->next;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	}
1747c478bd9Sstevel@tonic-gate 	*objp = NULL;
1757c478bd9Sstevel@tonic-gate 	return (TRUE);
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate bool_t
17961961e0fSrobinson xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
1807c478bd9Sstevel@tonic-gate {
18161961e0fSrobinson 	return (xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
18261961e0fSrobinson 			(xdrproc_t)xdr_rpcbs_rmtcalllist));
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate bool_t
18661961e0fSrobinson xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
1877c478bd9Sstevel@tonic-gate {
18861961e0fSrobinson 	if (!xdr_rpcbs_proc(xdrs, objp->info))
1897c478bd9Sstevel@tonic-gate 		return (FALSE);
19061961e0fSrobinson 	if (!xdr_int(xdrs, &objp->setinfo))
1917c478bd9Sstevel@tonic-gate 		return (FALSE);
19261961e0fSrobinson 	if (!xdr_int(xdrs, &objp->unsetinfo))
1937c478bd9Sstevel@tonic-gate 		return (FALSE);
19461961e0fSrobinson 	if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo))
1957c478bd9Sstevel@tonic-gate 		return (FALSE);
19661961e0fSrobinson 	return (xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo));
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate  * One rpcb_stat structure is returned for each version of rpcbind
2017c478bd9Sstevel@tonic-gate  * being monitored.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate bool_t
20461961e0fSrobinson xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
2057c478bd9Sstevel@tonic-gate {
20661961e0fSrobinson 	return (xdr_vector(xdrs, (char *)objp, RPCBVERS_STAT,
20761961e0fSrobinson 		sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat));
2087c478bd9Sstevel@tonic-gate }
209