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