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