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