Bring in a transport-independent RPC (TI-RPC).
[dragonfly.git] / lib / libc / rpc / rpcb_st_xdr.c
blob52ef33340e4e3e8909a356dbb9090d17d746e3a3
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.
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.
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.
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.
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.
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California 94043
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 * $DragonFly$
34 * Copyright 1991 Sun Microsystems, Inc.
35 * rpcb_stat_xdr.c
39 * This file was generated from rpcb_prot.x, but includes only those
40 * routines used with the rpcbind stats facility.
43 #include "namespace.h"
44 #include <rpc/rpc.h>
45 #include "un-namespace.h"
47 /* Link list of all the stats about getport and getaddr */
49 bool_t
50 xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
52 struct rpcbs_addrlist **pnext;
54 if (!xdr_u_int32_t(xdrs, &objp->prog)) {
55 return (FALSE);
57 if (!xdr_u_int32_t(xdrs, &objp->vers)) {
58 return (FALSE);
60 if (!xdr_int(xdrs, &objp->success)) {
61 return (FALSE);
63 if (!xdr_int(xdrs, &objp->failure)) {
64 return (FALSE);
66 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
67 return (FALSE);
70 pnext = &objp->next;
72 if (!xdr_pointer(xdrs, (char **) pnext,
73 sizeof (rpcbs_addrlist),
74 (xdrproc_t)xdr_rpcbs_addrlist)) {
75 return (FALSE);
78 return (TRUE);
81 /* Link list of all the stats about rmtcall */
83 bool_t
84 xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
86 int32_t *buf;
87 struct rpcbs_rmtcalllist **pnext;
89 if (xdrs->x_op == XDR_ENCODE) {
90 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
91 if (buf == NULL) {
92 if (!xdr_u_int32_t(xdrs, &objp->prog)) {
93 return (FALSE);
95 if (!xdr_u_int32_t(xdrs, &objp->vers)) {
96 return (FALSE);
98 if (!xdr_u_int32_t(xdrs, &objp->proc)) {
99 return (FALSE);
101 if (!xdr_int(xdrs, &objp->success)) {
102 return (FALSE);
104 if (!xdr_int(xdrs, &objp->failure)) {
105 return (FALSE);
107 if (!xdr_int(xdrs, &objp->indirect)) {
108 return (FALSE);
110 } else {
111 IXDR_PUT_U_INT32(buf, objp->prog);
112 IXDR_PUT_U_INT32(buf, objp->vers);
113 IXDR_PUT_U_INT32(buf, objp->proc);
114 IXDR_PUT_INT32(buf, objp->success);
115 IXDR_PUT_INT32(buf, objp->failure);
116 IXDR_PUT_INT32(buf, objp->indirect);
118 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
119 return (FALSE);
121 pnext = &objp->next;
122 if (!xdr_pointer(xdrs, (char **) pnext,
123 sizeof (rpcbs_rmtcalllist),
124 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
125 return (FALSE);
127 return (TRUE);
128 } else if (xdrs->x_op == XDR_DECODE) {
129 buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
130 if (buf == NULL) {
131 if (!xdr_u_int32_t(xdrs, &objp->prog)) {
132 return (FALSE);
134 if (!xdr_u_int32_t(xdrs, &objp->vers)) {
135 return (FALSE);
137 if (!xdr_u_int32_t(xdrs, &objp->proc)) {
138 return (FALSE);
140 if (!xdr_int(xdrs, &objp->success)) {
141 return (FALSE);
143 if (!xdr_int(xdrs, &objp->failure)) {
144 return (FALSE);
146 if (!xdr_int(xdrs, &objp->indirect)) {
147 return (FALSE);
149 } else {
150 objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
151 objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
152 objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
153 objp->success = (int)IXDR_GET_INT32(buf);
154 objp->failure = (int)IXDR_GET_INT32(buf);
155 objp->indirect = (int)IXDR_GET_INT32(buf);
157 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
158 return (FALSE);
160 if (!xdr_pointer(xdrs, (char **) pnext,
161 sizeof (rpcbs_rmtcalllist),
162 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
163 return (FALSE);
165 return (TRUE);
167 if (!xdr_u_int32_t(xdrs, &objp->prog)) {
168 return (FALSE);
170 if (!xdr_u_int32_t(xdrs, &objp->vers)) {
171 return (FALSE);
173 if (!xdr_u_int32_t(xdrs, &objp->proc)) {
174 return (FALSE);
176 if (!xdr_int(xdrs, &objp->success)) {
177 return (FALSE);
179 if (!xdr_int(xdrs, &objp->failure)) {
180 return (FALSE);
182 if (!xdr_int(xdrs, &objp->indirect)) {
183 return (FALSE);
185 if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
186 return (FALSE);
188 if (!xdr_pointer(xdrs, (char **) pnext,
189 sizeof (rpcbs_rmtcalllist),
190 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
191 return (FALSE);
193 return (TRUE);
196 bool_t
197 xdr_rpcbs_proc(XDR *xdrs, rpcbs_proc objp)
199 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC,
200 sizeof (int), (xdrproc_t)xdr_int)) {
201 return (FALSE);
203 return (TRUE);
206 bool_t
207 xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp)
209 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist),
210 (xdrproc_t)xdr_rpcbs_addrlist)) {
211 return (FALSE);
213 return (TRUE);
216 bool_t
217 xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
219 if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
220 (xdrproc_t)xdr_rpcbs_rmtcalllist)) {
221 return (FALSE);
223 return (TRUE);
226 bool_t
227 xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
230 if (!xdr_rpcbs_proc(xdrs, objp->info)) {
231 return (FALSE);
233 if (!xdr_int(xdrs, &objp->setinfo)) {
234 return (FALSE);
236 if (!xdr_int(xdrs, &objp->unsetinfo)) {
237 return (FALSE);
239 if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) {
240 return (FALSE);
242 if (!xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo)) {
243 return (FALSE);
245 return (TRUE);
249 * One rpcb_stat structure is returned for each version of rpcbind
250 * being monitored.
252 bool_t
253 xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
255 if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT,
256 sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
257 return (FALSE);
259 return (TRUE);