e477e4e4533199dbcc1275a9e7580d09bb27e11f
[dragonfly.git] / lib / libc / rpc / rpcb_st_xdr.c
1 /*
2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3  * unrestricted use provided that this legend is included on all tape
4  * media and as a part of the software program in whole or part.  Users
5  * may copy or modify Sun RPC without charge, but are not authorized
6  * to license or distribute it to anyone else except as part of a product or
7  * program developed by the user.
8  *
9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12  *
13  * Sun RPC is provided with no support and without any obligation on the
14  * part of Sun Microsystems, Inc. to assist in its use, correction,
15  * modification or enhancement.
16  *
17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19  * OR ANY PART THEREOF.
20  *
21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22  * or profits or other special, indirect and consequential damages, even if
23  * Sun has been advised of the possibility of such damages.
24  *
25  * Sun Microsystems, Inc.
26  * 2550 Garcia Avenue
27  * Mountain View, California  94043
28  *
29  * $NetBSD: rpcb_st_xdr.c,v 1.3 2000/07/14 08:40:42 fvdl Exp $
30  * $FreeBSD: src/lib/libc/rpc/rpcb_st_xdr.c,v 1.4 2007/11/20 01:51:20 jb Exp $
31  */
32 /*
33  * Copyright 1991 Sun Microsystems, Inc.
34  * rpcb_stat_xdr.c
35  */
36
37 /*
38  * This file was generated from rpcb_prot.x, but includes only those
39  * routines used with the rpcbind stats facility.
40  */
41
42 #include "namespace.h"
43 #include <rpc/rpc.h>
44 #include "un-namespace.h"
45
46 /* Link list of all the stats about getport and getaddr */
47
48 bool_t
49 xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
50 {
51         struct rpcbs_addrlist **pnext;
52
53         if (!xdr_u_int32_t(xdrs, &objp->prog)) {
54                 return (FALSE);
55         }
56         if (!xdr_u_int32_t(xdrs, &objp->vers)) {
57                 return (FALSE);
58         }
59         if (!xdr_int(xdrs, &objp->success)) {
60                 return (FALSE);
61         }
62         if (!xdr_int(xdrs, &objp->failure)) {
63                 return (FALSE);
64         }
65         if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
66                 return (FALSE);
67         }
68
69         pnext = &objp->next;
70
71         if (!xdr_pointer(xdrs, (char **) pnext,
72                         sizeof (rpcbs_addrlist),
73                         (xdrproc_t)xdr_rpcbs_addrlist)) {
74                 return (FALSE);
75         }
76
77         return (TRUE);
78 }
79
80 /* Link list of all the stats about rmtcall */
81
82 bool_t
83 xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
84 {
85         int32_t *buf;
86
87         if (xdrs->x_op == XDR_ENCODE) {
88                 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
89                 if (buf == NULL) {
90                         if (!xdr_u_int32_t(xdrs, &objp->prog)) {
91                                 return (FALSE);
92                         }
93                         if (!xdr_u_int32_t(xdrs, &objp->vers)) {
94                                 return (FALSE);
95                         }
96                         if (!xdr_u_int32_t(xdrs, &objp->proc)) {
97                                 return (FALSE);
98                         }
99                         if (!xdr_int(xdrs, &objp->success)) {
100                                 return (FALSE);
101                         }
102                         if (!xdr_int(xdrs, &objp->failure)) {
103                                 return (FALSE);
104                         }
105                         if (!xdr_int(xdrs, &objp->indirect)) {
106                                 return (FALSE);
107                         }
108                 } else {
109                         IXDR_PUT_U_INT32(buf, objp->prog);
110                         IXDR_PUT_U_INT32(buf, objp->vers);
111                         IXDR_PUT_U_INT32(buf, objp->proc);
112                         IXDR_PUT_INT32(buf, objp->success);
113                         IXDR_PUT_INT32(buf, objp->failure);
114                         IXDR_PUT_INT32(buf, objp->indirect);
115                 }
116                 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
117                         return (FALSE);
118                 }
119                 if (!xdr_pointer(xdrs, (char **)&objp->next,
120                                 sizeof (rpcbs_rmtcalllist),
121                                 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
122                         return (FALSE);
123                 }
124                 return (TRUE);
125         } else if (xdrs->x_op == XDR_DECODE) {
126                 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
127                 if (buf == NULL) {
128                         if (!xdr_u_int32_t(xdrs, &objp->prog)) {
129                                 return (FALSE);
130                         }
131                         if (!xdr_u_int32_t(xdrs, &objp->vers)) {
132                                 return (FALSE);
133                         }
134                         if (!xdr_u_int32_t(xdrs, &objp->proc)) {
135                                 return (FALSE);
136                         }
137                         if (!xdr_int(xdrs, &objp->success)) {
138                                 return (FALSE);
139                         }
140                         if (!xdr_int(xdrs, &objp->failure)) {
141                                 return (FALSE);
142                         }
143                         if (!xdr_int(xdrs, &objp->indirect)) {
144                                 return (FALSE);
145                         }
146                 } else {
147                         objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
148                         objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
149                         objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
150                         objp->success = (int)IXDR_GET_INT32(buf);
151                         objp->failure = (int)IXDR_GET_INT32(buf);
152                         objp->indirect = (int)IXDR_GET_INT32(buf);
153                 }
154                 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
155                         return (FALSE);
156                 }
157                 if (!xdr_pointer(xdrs, (char **)&objp->next,
158                                 sizeof (rpcbs_rmtcalllist),
159                                 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
160                         return (FALSE);
161                 }
162                 return (TRUE);
163         }
164         if (!xdr_u_int32_t(xdrs, &objp->prog)) {
165                 return (FALSE);
166         }
167         if (!xdr_u_int32_t(xdrs, &objp->vers)) {
168                 return (FALSE);
169         }
170         if (!xdr_u_int32_t(xdrs, &objp->proc)) {
171                 return (FALSE);
172         }
173         if (!xdr_int(xdrs, &objp->success)) {
174                 return (FALSE);
175         }
176         if (!xdr_int(xdrs, &objp->failure)) {
177                 return (FALSE);
178         }
179         if (!xdr_int(xdrs, &objp->indirect)) {
180                 return (FALSE);
181         }
182         if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
183                 return (FALSE);
184         }
185         if (!xdr_pointer(xdrs, (char **)&objp->next,
186                         sizeof (rpcbs_rmtcalllist),
187                         (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
188                 return (FALSE);
189         }
190         return (TRUE);
191 }
192
193 bool_t
194 xdr_rpcbs_proc(XDR *xdrs, 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(XDR *xdrs, rpcbs_addrlist_ptr *objp)
205 {
206         if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist),
207                         (xdrproc_t)xdr_rpcbs_addrlist)) {
208                 return (FALSE);
209         }
210         return (TRUE);
211 }
212
213 bool_t
214 xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
215 {
216         if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
217                         (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
218                 return (FALSE);
219         }
220         return (TRUE);
221 }
222
223 bool_t
224 xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
225 {
226
227         if (!xdr_rpcbs_proc(xdrs, objp->info)) {
228                 return (FALSE);
229         }
230         if (!xdr_int(xdrs, &objp->setinfo)) {
231                 return (FALSE);
232         }
233         if (!xdr_int(xdrs, &objp->unsetinfo)) {
234                 return (FALSE);
235         }
236         if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) {
237                 return (FALSE);
238         }
239         if (!xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo)) {
240                 return (FALSE);
241         }
242         return (TRUE);
243 }
244
245 /*
246  * One rpcb_stat structure is returned for each version of rpcbind
247  * being monitored.
248  */
249 bool_t
250 xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
251 {
252         if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT,
253             sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
254                 return (FALSE);
255         }
256         return (TRUE);
257 }