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