xref: /netbsd/lib/libc/rpc/rpcb_st_xdr.c (revision bf9ec67e)
1 /*	$NetBSD: rpcb_st_xdr.c,v 1.5 2001/01/04 14:57:17 lukem 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 "namespace.h"
42 #include <rpc/rpc.h>
43 
44 #include <assert.h>
45 
46 /* Link list of all the stats about getport and getaddr */
47 
48 #ifdef __weak_alias
49 __weak_alias(xdr_rpcbs_addrlist,_xdr_rpcbs_addrlist)
50 __weak_alias(xdr_rpcbs_rmtcalllist,_xdr_rpcbs_rmtcalllist)
51 __weak_alias(xdr_rpcbs_proc,_xdr_rpcbs_proc)
52 __weak_alias(xdr_rpcbs_addrlist_ptr,_xdr_rpcbs_addrlist_ptr)
53 __weak_alias(xdr_rpcbs_rmtcalllist_ptr,_xdr_rpcbs_rmtcalllist_ptr)
54 __weak_alias(xdr_rpcb_stat,_xdr_rpcb_stat)
55 __weak_alias(xdr_rpcb_stat_byvers,_xdr_rpcb_stat_byvers)
56 #endif
57 
58 bool_t
59 xdr_rpcbs_addrlist(xdrs, objp)
60 	XDR *xdrs;
61 	rpcbs_addrlist *objp;
62 {
63 
64 	_DIAGASSERT(objp != NULL);
65 
66 	    if (!xdr_u_int32_t(xdrs, &objp->prog)) {
67 		return (FALSE);
68 	    }
69 	    if (!xdr_u_int32_t(xdrs, &objp->vers)) {
70 		return (FALSE);
71 	    }
72 	    if (!xdr_int(xdrs, &objp->success)) {
73 		return (FALSE);
74 	    }
75 	    if (!xdr_int(xdrs, &objp->failure)) {
76 		return (FALSE);
77 	    }
78 	    if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
79 		return (FALSE);
80 	    }
81 
82 	    if (!xdr_pointer(xdrs, (char **)&objp->next,
83 			sizeof (rpcbs_addrlist),
84 			(xdrproc_t)xdr_rpcbs_addrlist)) {
85 		return (FALSE);
86 	    }
87 
88 	return (TRUE);
89 }
90 
91 /* Link list of all the stats about rmtcall */
92 
93 bool_t
94 xdr_rpcbs_rmtcalllist(xdrs, objp)
95 	XDR *xdrs;
96 	rpcbs_rmtcalllist *objp;
97 {
98 	int32_t *buf;
99 
100 	_DIAGASSERT(xdrs != NULL);
101 	_DIAGASSERT(objp != NULL);
102 
103 	if (xdrs->x_op == XDR_ENCODE) {
104 	buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
105 	if (buf == NULL) {
106 		if (!xdr_u_int32_t(xdrs, &objp->prog)) {
107 			return (FALSE);
108 		}
109 		if (!xdr_u_int32_t(xdrs, &objp->vers)) {
110 			return (FALSE);
111 		}
112 		if (!xdr_u_int32_t(xdrs, &objp->proc)) {
113 			return (FALSE);
114 		}
115 		if (!xdr_int(xdrs, &objp->success)) {
116 			return (FALSE);
117 		}
118 		if (!xdr_int(xdrs, &objp->failure)) {
119 			return (FALSE);
120 		}
121 		if (!xdr_int(xdrs, &objp->indirect)) {
122 			return (FALSE);
123 		}
124 	} else {
125 		IXDR_PUT_U_INT32(buf, objp->prog);
126 		IXDR_PUT_U_INT32(buf, objp->vers);
127 		IXDR_PUT_U_INT32(buf, objp->proc);
128 		IXDR_PUT_INT32(buf, objp->success);
129 		IXDR_PUT_INT32(buf, objp->failure);
130 		IXDR_PUT_INT32(buf, objp->indirect);
131 	}
132 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
133 		return (FALSE);
134 	}
135 	if (!xdr_pointer(xdrs, (char **)&objp->next,
136 			sizeof (rpcbs_rmtcalllist),
137 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
138 		return (FALSE);
139 	}
140 	return (TRUE);
141 	} else if (xdrs->x_op == XDR_DECODE) {
142 	buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
143 	if (buf == NULL) {
144 		if (!xdr_u_int32_t(xdrs, &objp->prog)) {
145 			return (FALSE);
146 		}
147 		if (!xdr_u_int32_t(xdrs, &objp->vers)) {
148 			return (FALSE);
149 		}
150 		if (!xdr_u_int32_t(xdrs, &objp->proc)) {
151 			return (FALSE);
152 		}
153 		if (!xdr_int(xdrs, &objp->success)) {
154 			return (FALSE);
155 		}
156 		if (!xdr_int(xdrs, &objp->failure)) {
157 			return (FALSE);
158 		}
159 		if (!xdr_int(xdrs, &objp->indirect)) {
160 			return (FALSE);
161 		}
162 	} else {
163 		objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
164 		objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
165 		objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
166 		objp->success = (int)IXDR_GET_INT32(buf);
167 		objp->failure = (int)IXDR_GET_INT32(buf);
168 		objp->indirect = (int)IXDR_GET_INT32(buf);
169 	}
170 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
171 		return (FALSE);
172 	}
173 	if (!xdr_pointer(xdrs, (char **)&objp->next,
174 			sizeof (rpcbs_rmtcalllist),
175 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
176 		return (FALSE);
177 	}
178 	return (TRUE);
179 	}
180 	if (!xdr_u_int32_t(xdrs, &objp->prog)) {
181 		return (FALSE);
182 	}
183 	if (!xdr_u_int32_t(xdrs, &objp->vers)) {
184 		return (FALSE);
185 	}
186 	if (!xdr_u_int32_t(xdrs, &objp->proc)) {
187 		return (FALSE);
188 	}
189 	if (!xdr_int(xdrs, &objp->success)) {
190 		return (FALSE);
191 	}
192 	if (!xdr_int(xdrs, &objp->failure)) {
193 		return (FALSE);
194 	}
195 	if (!xdr_int(xdrs, &objp->indirect)) {
196 		return (FALSE);
197 	}
198 	if (!xdr_string(xdrs, &objp->netid, (u_int)~0)) {
199 		return (FALSE);
200 	}
201 	if (!xdr_pointer(xdrs, (char **)&objp->next,
202 			sizeof (rpcbs_rmtcalllist),
203 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
204 		return (FALSE);
205 	}
206 	return (TRUE);
207 }
208 
209 bool_t
210 xdr_rpcbs_proc(xdrs, objp)
211 	XDR *xdrs;
212 	rpcbs_proc objp;
213 {
214 	if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC,
215 	    sizeof (int), (xdrproc_t)xdr_int)) {
216 		return (FALSE);
217 	}
218 	return (TRUE);
219 }
220 
221 bool_t
222 xdr_rpcbs_addrlist_ptr(xdrs, objp)
223 	XDR *xdrs;
224 	rpcbs_addrlist_ptr *objp;
225 {
226 	if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist),
227 			(xdrproc_t)xdr_rpcbs_addrlist)) {
228 		return (FALSE);
229 	}
230 	return (TRUE);
231 }
232 
233 bool_t
234 xdr_rpcbs_rmtcalllist_ptr(xdrs, objp)
235 	XDR *xdrs;
236 	rpcbs_rmtcalllist_ptr *objp;
237 {
238 	if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
239 			(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
240 		return (FALSE);
241 	}
242 	return (TRUE);
243 }
244 
245 bool_t
246 xdr_rpcb_stat(xdrs, objp)
247 	XDR *xdrs;
248 	rpcb_stat *objp;
249 {
250 
251 	_DIAGASSERT(objp != NULL);
252 
253 	if (!xdr_rpcbs_proc(xdrs, objp->info)) {
254 		return (FALSE);
255 	}
256 	if (!xdr_int(xdrs, &objp->setinfo)) {
257 		return (FALSE);
258 	}
259 	if (!xdr_int(xdrs, &objp->unsetinfo)) {
260 		return (FALSE);
261 	}
262 	if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) {
263 		return (FALSE);
264 	}
265 	return (TRUE);
266 }
267 
268 /*
269  * One rpcb_stat structure is returned for each version of rpcbind
270  * being monitored.
271  */
272 bool_t
273 xdr_rpcb_stat_byvers(xdrs, objp)
274 	XDR *xdrs;
275 	rpcb_stat_byvers objp;
276 {
277 	if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT,
278 	    sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
279 		return (FALSE);
280 	}
281 	return (TRUE);
282 }
283