1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 /*
31  * This file was generated from rpcb_prot.x, but includes only those
32  * routines used with the rpcbind stats facility.
33  */
34 
35 #include <rpc/rpc.h>
36 
37 /* Link list of all the stats about getport and getaddr */
38 
39 bool_t
40 xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
41 {
42 	if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
43 		return (FALSE);
44 	if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
45 		return (FALSE);
46 	if (!xdr_int(xdrs, &objp->success))
47 		return (FALSE);
48 	if (!xdr_int(xdrs, &objp->failure))
49 		return (FALSE);
50 	return (xdr_string(xdrs, &objp->netid, ~0));
51 }
52 
53 /* Link list of all the stats about rmtcall */
54 
55 bool_t
56 xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
57 {
58 	rpc_inline_t *buf;
59 
60 	switch (xdrs->x_op) {
61 	case XDR_ENCODE:
62 		buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
63 		if (buf == NULL) {
64 			if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
65 				return (FALSE);
66 			if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
67 				return (FALSE);
68 			if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
69 				return (FALSE);
70 			if (!xdr_int(xdrs, &objp->success))
71 				return (FALSE);
72 			if (!xdr_int(xdrs, &objp->failure))
73 				return (FALSE);
74 			if (!xdr_int(xdrs, &objp->indirect))
75 				return (FALSE);
76 		} else {
77 			IXDR_PUT_U_INT32(buf, objp->prog);
78 			IXDR_PUT_U_INT32(buf, objp->vers);
79 			IXDR_PUT_U_INT32(buf, objp->proc);
80 			IXDR_PUT_INT32(buf, objp->success);
81 			IXDR_PUT_INT32(buf, objp->failure);
82 			IXDR_PUT_INT32(buf, objp->indirect);
83 		}
84 		if (!xdr_string(xdrs, &objp->netid, ~0))
85 			return (FALSE);
86 		return (xdr_pointer(xdrs, (char **)&objp->next,
87 				(uint_t)sizeof (rpcbs_rmtcalllist),
88 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
89 	case XDR_DECODE:
90 		buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
91 		if (buf == NULL) {
92 			if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
93 				return (FALSE);
94 			if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
95 				return (FALSE);
96 			if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
97 				return (FALSE);
98 			if (!xdr_int(xdrs, &objp->success))
99 				return (FALSE);
100 			if (!xdr_int(xdrs, &objp->failure))
101 				return (FALSE);
102 			if (!xdr_int(xdrs, &objp->indirect))
103 				return (FALSE);
104 		} else {
105 			objp->prog = IXDR_GET_U_INT32(buf);
106 			objp->vers = IXDR_GET_U_INT32(buf);
107 			objp->proc = IXDR_GET_U_INT32(buf);
108 			objp->success = IXDR_GET_INT32(buf);
109 			objp->failure = IXDR_GET_INT32(buf);
110 			objp->indirect = IXDR_GET_INT32(buf);
111 		}
112 		if (!xdr_string(xdrs, &objp->netid, ~0))
113 			return (FALSE);
114 		return (xdr_pointer(xdrs, (char **)&objp->next,
115 				(uint_t)sizeof (rpcbs_rmtcalllist),
116 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
117 	case XDR_FREE:
118 		if (!xdr_u_int(xdrs, (uint_t *)&objp->prog))
119 			return (FALSE);
120 		if (!xdr_u_int(xdrs, (uint_t *)&objp->vers))
121 			return (FALSE);
122 		if (!xdr_u_int(xdrs, (uint_t *)&objp->proc))
123 			return (FALSE);
124 		if (!xdr_int(xdrs, &objp->success))
125 			return (FALSE);
126 		if (!xdr_int(xdrs, &objp->failure))
127 			return (FALSE);
128 		if (!xdr_int(xdrs, &objp->indirect))
129 			return (FALSE);
130 		if (!xdr_string(xdrs, &objp->netid, ~0))
131 			return (FALSE);
132 		return (xdr_pointer(xdrs, (char **)&objp->next,
133 				(uint_t)sizeof (rpcbs_rmtcalllist),
134 				(xdrproc_t)xdr_rpcbs_rmtcalllist));
135 	default:
136 		return (FALSE);
137 	}
138 }
139 
140 bool_t
141 xdr_rpcbs_proc(XDR *xdrs, rpcbs_proc objp)
142 {
143 	return (xdr_vector(xdrs, (char *)objp, RPCBSTAT_HIGHPROC, sizeof (int),
144 			(xdrproc_t)xdr_int));
145 }
146 
147 bool_t
148 xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp)
149 {
150 	bool_t			more_data;
151 	rpcbs_addrlist_ptr	*nextp;
152 
153 	for (;;) {
154 		more_data = (*objp != NULL);
155 
156 		if (!xdr_bool(xdrs, &more_data))
157 			return (FALSE);
158 
159 		if (!more_data)
160 			break;
161 
162 		if (xdrs->x_op == XDR_FREE)
163 			nextp = &(*objp)->next;
164 
165 		if (!xdr_reference(xdrs, (char **)objp,
166 			(uint_t)sizeof (rpcbs_addrlist),
167 			(xdrproc_t)xdr_rpcbs_addrlist))
168 			return (FALSE);
169 
170 		objp = (xdrs->x_op == XDR_FREE) ? nextp : &(*objp)->next;
171 
172 	}
173 	*objp = NULL;
174 	return (TRUE);
175 }
176 
177 bool_t
178 xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
179 {
180 	return (xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
181 			(xdrproc_t)xdr_rpcbs_rmtcalllist));
182 }
183 
184 bool_t
185 xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
186 {
187 	if (!xdr_rpcbs_proc(xdrs, objp->info))
188 		return (FALSE);
189 	if (!xdr_int(xdrs, &objp->setinfo))
190 		return (FALSE);
191 	if (!xdr_int(xdrs, &objp->unsetinfo))
192 		return (FALSE);
193 	if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo))
194 		return (FALSE);
195 	return (xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo));
196 }
197 
198 /*
199  * One rpcb_stat structure is returned for each version of rpcbind
200  * being monitored.
201  */
202 bool_t
203 xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
204 {
205 	return (xdr_vector(xdrs, (char *)objp, RPCBVERS_STAT,
206 		sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat));
207 }
208