xdryp.c revision 1.29 1 1.29 christos /* $NetBSD: xdryp.c,v 1.29 2005/11/29 03:12:01 christos Exp $ */
2 1.8 cgd
3 1.3 deraadt /*
4 1.27 keihan * Copyright (c) 1996 Jason R. Thorpe <thorpej (at) NetBSD.org>.
5 1.12 thorpej * All rights reserved.
6 1.12 thorpej *
7 1.3 deraadt * Redistribution and use in source and binary forms, with or without
8 1.3 deraadt * modification, are permitted provided that the following conditions
9 1.3 deraadt * are met:
10 1.3 deraadt * 1. Redistributions of source code must retain the above copyright
11 1.3 deraadt * notice, this list of conditions and the following disclaimer.
12 1.3 deraadt * 2. Redistributions in binary form must reproduce the above copyright
13 1.3 deraadt * notice, this list of conditions and the following disclaimer in the
14 1.3 deraadt * documentation and/or other materials provided with the distribution.
15 1.6 deraadt * 3. All advertising materials mentioning features or use of this software
16 1.6 deraadt * must display the following acknowledgement:
17 1.12 thorpej * This product includes software developed for the NetBSD Project
18 1.12 thorpej * by Jason R. Thorpe.
19 1.6 deraadt * 4. The name of the author may not be used to endorse or promote products
20 1.6 deraadt * derived from this software without specific prior written permission.
21 1.3 deraadt *
22 1.3 deraadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23 1.3 deraadt * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 1.3 deraadt * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.3 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26 1.3 deraadt * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.3 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.3 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.3 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.3 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.3 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.3 deraadt * SUCH DAMAGE.
33 1.3 deraadt */
34 1.3 deraadt
35 1.28 agc /*
36 1.28 agc * Copyright (c) 1992, 1993 Theo de Raadt <deraadt (at) fsa.ca>
37 1.28 agc * All rights reserved.
38 1.28 agc *
39 1.28 agc * Redistribution and use in source and binary forms, with or without
40 1.28 agc * modification, are permitted provided that the following conditions
41 1.28 agc * are met:
42 1.28 agc * 1. Redistributions of source code must retain the above copyright
43 1.28 agc * notice, this list of conditions and the following disclaimer.
44 1.28 agc * 2. Redistributions in binary form must reproduce the above copyright
45 1.28 agc * notice, this list of conditions and the following disclaimer in the
46 1.28 agc * documentation and/or other materials provided with the distribution.
47 1.28 agc *
48 1.28 agc *
49 1.28 agc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
50 1.28 agc * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
51 1.28 agc * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 1.28 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
53 1.28 agc * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 1.28 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 1.28 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 1.28 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 1.28 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 1.28 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 1.28 agc * SUCH DAMAGE.
60 1.28 agc */
61 1.28 agc
62 1.16 christos #include <sys/cdefs.h>
63 1.10 jtc #if defined(LIBC_SCCS) && !defined(lint)
64 1.29 christos __RCSID("$NetBSD: xdryp.c,v 1.29 2005/11/29 03:12:01 christos Exp $");
65 1.3 deraadt #endif
66 1.3 deraadt
67 1.12 thorpej /*
68 1.12 thorpej * XDR routines used by the YP protocol. Note that these routines do
69 1.12 thorpej * not strictly conform to the RPC definition in yp.x. This file
70 1.12 thorpej * replicates the functions exported by the Sun YP API; reality is
71 1.12 thorpej * often inaccurate.
72 1.12 thorpej */
73 1.12 thorpej
74 1.17 jtc #include "namespace.h"
75 1.23 lukem
76 1.1 deraadt #include <sys/param.h>
77 1.1 deraadt #include <sys/socket.h>
78 1.23 lukem
79 1.23 lukem #include <assert.h>
80 1.23 lukem #include <ctype.h>
81 1.1 deraadt #include <stdio.h>
82 1.7 jtc #include <stdlib.h>
83 1.7 jtc #include <string.h>
84 1.23 lukem
85 1.1 deraadt #include <rpc/rpc.h>
86 1.1 deraadt #include <rpc/xdr.h>
87 1.1 deraadt #include <rpcsvc/yp_prot.h>
88 1.1 deraadt #include <rpcsvc/ypclnt.h>
89 1.17 jtc
90 1.17 jtc #ifdef __weak_alias
91 1.25 mycroft __weak_alias(xdr_datum,_xdr_datum)
92 1.25 mycroft __weak_alias(xdr_domainname,_xdr_domainname)
93 1.25 mycroft __weak_alias(xdr_mapname,_xdr_mapname)
94 1.25 mycroft __weak_alias(xdr_peername,_xdr_peername)
95 1.25 mycroft __weak_alias(xdr_yp_inaddr,_xdr_yp_inaddr)
96 1.25 mycroft __weak_alias(xdr_ypall,_xdr_ypall)
97 1.25 mycroft __weak_alias(xdr_ypbind_resp,_xdr_ypbind_resp)
98 1.25 mycroft __weak_alias(xdr_ypbind_setdom,_xdr_ypbind_setdom)
99 1.25 mycroft __weak_alias(xdr_ypdomain_wrap_string,_xdr_ypdomain_wrap_string)
100 1.25 mycroft __weak_alias(xdr_ypmap_parms,_xdr_ypmap_parms)
101 1.25 mycroft __weak_alias(xdr_ypmap_wrap_string,_xdr_ypmap_wrap_string)
102 1.25 mycroft __weak_alias(xdr_ypmaplist,_xdr_ypmaplist)
103 1.25 mycroft __weak_alias(xdr_ypowner_wrap_string,_xdr_ypowner_wrap_string)
104 1.25 mycroft __weak_alias(xdr_yppushresp_xfr,_xdr_yppushresp_xfr)
105 1.25 mycroft __weak_alias(xdr_ypreq_key,_xdr_ypreq_key)
106 1.25 mycroft __weak_alias(xdr_ypreq_nokey,_xdr_ypreq_nokey)
107 1.25 mycroft __weak_alias(xdr_ypreq_xfr,_xdr_ypreq_xfr)
108 1.25 mycroft __weak_alias(xdr_ypresp_key_val,_xdr_ypresp_key_val)
109 1.25 mycroft __weak_alias(xdr_ypresp_maplist,_xdr_ypresp_maplist)
110 1.25 mycroft __weak_alias(xdr_ypresp_master,_xdr_ypresp_master)
111 1.25 mycroft __weak_alias(xdr_ypresp_order,_xdr_ypresp_order)
112 1.25 mycroft __weak_alias(xdr_ypresp_val,_xdr_ypresp_val)
113 1.17 jtc #endif
114 1.1 deraadt
115 1.12 thorpej /*
116 1.12 thorpej * Functions used only within this file.
117 1.12 thorpej */
118 1.12 thorpej static bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
119 1.12 thorpej static bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
120 1.12 thorpej static bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
121 1.12 thorpej static bool_t xdr_ypmaplist_str __P((XDR *, char *));
122 1.12 thorpej
123 1.19 thorpej __warn_references(xdr_domainname,
124 1.20 thorpej "warning: this program uses xdr_domainname(), which is deprecated and buggy.")
125 1.19 thorpej
126 1.19 thorpej bool_t
127 1.19 thorpej xdr_domainname(xdrs, objp)
128 1.19 thorpej XDR *xdrs;
129 1.19 thorpej char *objp;
130 1.19 thorpej {
131 1.23 lukem
132 1.23 lukem _DIAGASSERT(xdrs != NULL);
133 1.23 lukem _DIAGASSERT(objp != NULL);
134 1.23 lukem
135 1.19 thorpej return xdr_string(xdrs, &objp, YPMAXDOMAIN);
136 1.19 thorpej }
137 1.19 thorpej
138 1.19 thorpej __warn_references(xdr_peername,
139 1.20 thorpej "warning: this program uses xdr_peername(), which is deprecated and buggy.")
140 1.19 thorpej
141 1.19 thorpej bool_t
142 1.19 thorpej xdr_peername(xdrs, objp)
143 1.19 thorpej XDR *xdrs;
144 1.19 thorpej char *objp;
145 1.19 thorpej {
146 1.23 lukem
147 1.23 lukem _DIAGASSERT(xdrs != NULL);
148 1.23 lukem _DIAGASSERT(objp != NULL);
149 1.23 lukem
150 1.19 thorpej return xdr_string(xdrs, &objp, YPMAXPEER);
151 1.19 thorpej }
152 1.19 thorpej
153 1.19 thorpej __warn_references(xdr_mapname,
154 1.20 thorpej "warning: this program uses xdr_mapname(), which is deprecated and buggy.")
155 1.19 thorpej
156 1.19 thorpej bool_t
157 1.19 thorpej xdr_mapname(xdrs, objp)
158 1.19 thorpej XDR *xdrs;
159 1.19 thorpej char *objp;
160 1.19 thorpej {
161 1.23 lukem
162 1.23 lukem _DIAGASSERT(xdrs != NULL);
163 1.23 lukem _DIAGASSERT(objp != NULL);
164 1.23 lukem
165 1.19 thorpej return xdr_string(xdrs, &objp, YPMAXMAP);
166 1.19 thorpej }
167 1.19 thorpej
168 1.12 thorpej bool_t
169 1.12 thorpej xdr_ypdomain_wrap_string(xdrs, objp)
170 1.12 thorpej XDR *xdrs;
171 1.12 thorpej char **objp;
172 1.12 thorpej {
173 1.23 lukem
174 1.23 lukem _DIAGASSERT(xdrs != NULL);
175 1.23 lukem _DIAGASSERT(objp != NULL);
176 1.23 lukem
177 1.12 thorpej return xdr_string(xdrs, objp, YPMAXDOMAIN);
178 1.12 thorpej }
179 1.12 thorpej
180 1.12 thorpej bool_t
181 1.12 thorpej xdr_ypmap_wrap_string(xdrs, objp)
182 1.12 thorpej XDR *xdrs;
183 1.12 thorpej char **objp;
184 1.12 thorpej {
185 1.23 lukem
186 1.23 lukem _DIAGASSERT(xdrs != NULL);
187 1.23 lukem _DIAGASSERT(objp != NULL);
188 1.23 lukem
189 1.12 thorpej return xdr_string(xdrs, objp, YPMAXMAP);
190 1.12 thorpej }
191 1.12 thorpej
192 1.1 deraadt bool_t
193 1.12 thorpej xdr_ypowner_wrap_string(xdrs, objp)
194 1.12 thorpej XDR *xdrs;
195 1.12 thorpej char **objp;
196 1.1 deraadt {
197 1.23 lukem
198 1.23 lukem _DIAGASSERT(xdrs != NULL);
199 1.23 lukem _DIAGASSERT(objp != NULL);
200 1.23 lukem
201 1.12 thorpej return xdr_string(xdrs, objp, YPMAXPEER);
202 1.1 deraadt }
203 1.1 deraadt
204 1.1 deraadt bool_t
205 1.12 thorpej xdr_datum(xdrs, objp)
206 1.12 thorpej XDR *xdrs;
207 1.12 thorpej datum *objp;
208 1.1 deraadt {
209 1.23 lukem
210 1.23 lukem _DIAGASSERT(xdrs != NULL);
211 1.23 lukem _DIAGASSERT(objp != NULL);
212 1.23 lukem
213 1.29 christos return xdr_bytes(xdrs, __UNCONST(&objp->dptr),
214 1.12 thorpej (u_int *)&objp->dsize, YPMAXRECORD);
215 1.1 deraadt }
216 1.1 deraadt
217 1.1 deraadt bool_t
218 1.1 deraadt xdr_ypreq_key(xdrs, objp)
219 1.12 thorpej XDR *xdrs;
220 1.12 thorpej struct ypreq_key *objp;
221 1.1 deraadt {
222 1.23 lukem
223 1.23 lukem _DIAGASSERT(xdrs != NULL);
224 1.23 lukem _DIAGASSERT(objp != NULL);
225 1.23 lukem
226 1.29 christos if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
227 1.9 christos return FALSE;
228 1.12 thorpej
229 1.29 christos if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
230 1.9 christos return FALSE;
231 1.12 thorpej
232 1.13 christos if (!xdr_datum(xdrs, &objp->keydat))
233 1.13 christos return FALSE;
234 1.13 christos
235 1.13 christos return TRUE;
236 1.1 deraadt }
237 1.1 deraadt
238 1.1 deraadt bool_t
239 1.1 deraadt xdr_ypreq_nokey(xdrs, objp)
240 1.12 thorpej XDR *xdrs;
241 1.12 thorpej struct ypreq_nokey *objp;
242 1.1 deraadt {
243 1.23 lukem
244 1.23 lukem _DIAGASSERT(xdrs != NULL);
245 1.23 lukem _DIAGASSERT(objp != NULL);
246 1.23 lukem
247 1.29 christos if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
248 1.13 christos return FALSE;
249 1.13 christos
250 1.29 christos if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
251 1.9 christos return FALSE;
252 1.12 thorpej
253 1.13 christos return TRUE;
254 1.1 deraadt }
255 1.1 deraadt
256 1.1 deraadt bool_t
257 1.1 deraadt xdr_yp_inaddr(xdrs, objp)
258 1.12 thorpej XDR *xdrs;
259 1.12 thorpej struct in_addr *objp;
260 1.1 deraadt {
261 1.23 lukem
262 1.23 lukem _DIAGASSERT(xdrs != NULL);
263 1.23 lukem _DIAGASSERT(objp != NULL);
264 1.23 lukem
265 1.21 christos return xdr_opaque(xdrs, (caddr_t)(void *)&objp->s_addr,
266 1.21 christos sizeof objp->s_addr);
267 1.1 deraadt }
268 1.1 deraadt
269 1.12 thorpej static bool_t
270 1.1 deraadt xdr_ypbind_binding(xdrs, objp)
271 1.12 thorpej XDR *xdrs;
272 1.12 thorpej struct ypbind_binding *objp;
273 1.1 deraadt {
274 1.23 lukem
275 1.23 lukem _DIAGASSERT(xdrs != NULL);
276 1.23 lukem _DIAGASSERT(objp != NULL);
277 1.23 lukem
278 1.12 thorpej if (!xdr_yp_inaddr(xdrs, &objp->ypbind_binding_addr))
279 1.9 christos return FALSE;
280 1.12 thorpej
281 1.13 christos if (!xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
282 1.13 christos sizeof objp->ypbind_binding_port))
283 1.13 christos return FALSE;
284 1.13 christos
285 1.13 christos return TRUE;
286 1.1 deraadt }
287 1.1 deraadt
288 1.12 thorpej static bool_t
289 1.1 deraadt xdr_ypbind_resptype(xdrs, objp)
290 1.12 thorpej XDR *xdrs;
291 1.12 thorpej enum ypbind_resptype *objp;
292 1.1 deraadt {
293 1.23 lukem
294 1.23 lukem _DIAGASSERT(xdrs != NULL);
295 1.23 lukem _DIAGASSERT(objp != NULL);
296 1.23 lukem
297 1.26 christos return xdr_enum(xdrs, (enum_t *)(void *)objp);
298 1.1 deraadt }
299 1.1 deraadt
300 1.12 thorpej static bool_t
301 1.1 deraadt xdr_ypstat(xdrs, objp)
302 1.12 thorpej XDR *xdrs;
303 1.12 thorpej enum ypbind_resptype *objp;
304 1.1 deraadt {
305 1.23 lukem
306 1.23 lukem _DIAGASSERT(xdrs != NULL);
307 1.23 lukem _DIAGASSERT(objp != NULL);
308 1.23 lukem
309 1.26 christos return xdr_enum(xdrs, (enum_t *)(void *)objp);
310 1.1 deraadt }
311 1.1 deraadt
312 1.1 deraadt bool_t
313 1.1 deraadt xdr_ypbind_resp(xdrs, objp)
314 1.12 thorpej XDR *xdrs;
315 1.12 thorpej struct ypbind_resp *objp;
316 1.1 deraadt {
317 1.23 lukem
318 1.23 lukem _DIAGASSERT(xdrs != NULL);
319 1.23 lukem _DIAGASSERT(objp != NULL);
320 1.23 lukem
321 1.12 thorpej if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status))
322 1.9 christos return FALSE;
323 1.9 christos
324 1.1 deraadt switch (objp->ypbind_status) {
325 1.1 deraadt case YPBIND_FAIL_VAL:
326 1.9 christos return xdr_u_int(xdrs,
327 1.12 thorpej (u_int *)&objp->ypbind_respbody.ypbind_error);
328 1.12 thorpej
329 1.1 deraadt case YPBIND_SUCC_VAL:
330 1.12 thorpej return xdr_ypbind_binding(xdrs,
331 1.12 thorpej &objp->ypbind_respbody.ypbind_bindinfo);
332 1.12 thorpej
333 1.1 deraadt default:
334 1.9 christos return FALSE;
335 1.1 deraadt }
336 1.7 jtc /* NOTREACHED */
337 1.1 deraadt }
338 1.1 deraadt
339 1.1 deraadt bool_t
340 1.1 deraadt xdr_ypresp_val(xdrs, objp)
341 1.12 thorpej XDR *xdrs;
342 1.12 thorpej struct ypresp_val *objp;
343 1.1 deraadt {
344 1.23 lukem
345 1.23 lukem _DIAGASSERT(xdrs != NULL);
346 1.23 lukem _DIAGASSERT(objp != NULL);
347 1.23 lukem
348 1.26 christos if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
349 1.9 christos return FALSE;
350 1.12 thorpej
351 1.13 christos if (!xdr_datum(xdrs, &objp->valdat))
352 1.13 christos return FALSE;
353 1.13 christos
354 1.13 christos return TRUE;
355 1.1 deraadt }
356 1.1 deraadt
357 1.1 deraadt bool_t
358 1.1 deraadt xdr_ypbind_setdom(xdrs, objp)
359 1.12 thorpej XDR *xdrs;
360 1.12 thorpej struct ypbind_setdom *objp;
361 1.1 deraadt {
362 1.23 lukem char *cp;
363 1.23 lukem
364 1.23 lukem _DIAGASSERT(xdrs != NULL);
365 1.23 lukem _DIAGASSERT(objp != NULL);
366 1.23 lukem
367 1.23 lukem cp = objp->ypsetdom_domain;
368 1.12 thorpej
369 1.13 christos if (!xdr_ypdomain_wrap_string(xdrs, &cp))
370 1.9 christos return FALSE;
371 1.12 thorpej
372 1.12 thorpej if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding))
373 1.9 christos return FALSE;
374 1.12 thorpej
375 1.14 thorpej if (!xdr_u_int(xdrs, &objp->ypsetdom_vers))
376 1.13 christos return FALSE;
377 1.13 christos
378 1.13 christos return TRUE;
379 1.1 deraadt }
380 1.1 deraadt
381 1.1 deraadt bool_t
382 1.1 deraadt xdr_ypresp_key_val(xdrs, objp)
383 1.12 thorpej XDR *xdrs;
384 1.12 thorpej struct ypresp_key_val *objp;
385 1.1 deraadt {
386 1.23 lukem
387 1.23 lukem _DIAGASSERT(xdrs != NULL);
388 1.23 lukem _DIAGASSERT(objp != NULL);
389 1.23 lukem
390 1.26 christos if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
391 1.9 christos return FALSE;
392 1.12 thorpej
393 1.12 thorpej if (!xdr_datum(xdrs, &objp->valdat))
394 1.9 christos return FALSE;
395 1.12 thorpej
396 1.13 christos if (!xdr_datum(xdrs, &objp->keydat))
397 1.13 christos return FALSE;
398 1.13 christos
399 1.13 christos return TRUE;
400 1.1 deraadt }
401 1.1 deraadt
402 1.1 deraadt bool_t
403 1.12 thorpej xdr_ypall(xdrs, incallback)
404 1.12 thorpej XDR *xdrs;
405 1.12 thorpej struct ypall_callback *incallback;
406 1.12 thorpej {
407 1.12 thorpej struct ypresp_key_val out;
408 1.12 thorpej char key[YPMAXRECORD], val[YPMAXRECORD];
409 1.12 thorpej bool_t more, status;
410 1.1 deraadt
411 1.23 lukem _DIAGASSERT(xdrs != NULL);
412 1.23 lukem _DIAGASSERT(incallback != NULL);
413 1.23 lukem
414 1.12 thorpej /*
415 1.12 thorpej * Set up key/val struct to be used during the transaction.
416 1.12 thorpej */
417 1.7 jtc memset(&out, 0, sizeof out);
418 1.12 thorpej out.keydat.dptr = key;
419 1.12 thorpej out.keydat.dsize = sizeof(key);
420 1.12 thorpej out.valdat.dptr = val;
421 1.12 thorpej out.valdat.dsize = sizeof(val);
422 1.12 thorpej
423 1.12 thorpej for (;;) {
424 1.12 thorpej /* Values pending? */
425 1.12 thorpej if (!xdr_bool(xdrs, &more))
426 1.12 thorpej return FALSE; /* can't tell! */
427 1.13 christos if (!more)
428 1.12 thorpej return TRUE; /* no more */
429 1.12 thorpej
430 1.12 thorpej /* Transfer key/value pair. */
431 1.12 thorpej status = xdr_ypresp_key_val(xdrs, &out);
432 1.12 thorpej
433 1.12 thorpej /*
434 1.12 thorpej * If we succeeded, call the callback function.
435 1.12 thorpej * The callback will return TRUE when it wants
436 1.12 thorpej * no more values. If we fail, indicate the
437 1.12 thorpej * error.
438 1.12 thorpej */
439 1.13 christos if (status) {
440 1.21 christos if ((*incallback->foreach)((int)out.status,
441 1.29 christos __UNCONST(out.keydat.dptr), out.keydat.dsize,
442 1.29 christos __UNCONST(out.valdat.dptr), out.valdat.dsize,
443 1.12 thorpej incallback->data))
444 1.12 thorpej return TRUE;
445 1.12 thorpej } else
446 1.1 deraadt return FALSE;
447 1.1 deraadt }
448 1.1 deraadt }
449 1.1 deraadt
450 1.1 deraadt bool_t
451 1.1 deraadt xdr_ypresp_master(xdrs, objp)
452 1.12 thorpej XDR *xdrs;
453 1.12 thorpej struct ypresp_master *objp;
454 1.1 deraadt {
455 1.23 lukem
456 1.23 lukem _DIAGASSERT(xdrs != NULL);
457 1.23 lukem _DIAGASSERT(objp != NULL);
458 1.23 lukem
459 1.26 christos if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
460 1.9 christos return FALSE;
461 1.12 thorpej
462 1.13 christos if (!xdr_string(xdrs, &objp->master, YPMAXPEER))
463 1.13 christos return FALSE;
464 1.13 christos
465 1.13 christos return TRUE;
466 1.1 deraadt }
467 1.1 deraadt
468 1.12 thorpej static bool_t
469 1.1 deraadt xdr_ypmaplist_str(xdrs, objp)
470 1.12 thorpej XDR *xdrs;
471 1.12 thorpej char *objp;
472 1.1 deraadt {
473 1.23 lukem
474 1.23 lukem _DIAGASSERT(xdrs != NULL);
475 1.23 lukem _DIAGASSERT(objp != NULL);
476 1.23 lukem
477 1.7 jtc return xdr_string(xdrs, &objp, YPMAXMAP+1);
478 1.1 deraadt }
479 1.1 deraadt
480 1.1 deraadt bool_t
481 1.1 deraadt xdr_ypmaplist(xdrs, objp)
482 1.12 thorpej XDR *xdrs;
483 1.12 thorpej struct ypmaplist *objp;
484 1.1 deraadt {
485 1.23 lukem
486 1.23 lukem _DIAGASSERT(xdrs != NULL);
487 1.23 lukem _DIAGASSERT(objp != NULL);
488 1.23 lukem
489 1.12 thorpej if (!xdr_ypmaplist_str(xdrs, objp->ypml_name))
490 1.9 christos return FALSE;
491 1.12 thorpej
492 1.13 christos if (!xdr_pointer(xdrs, (caddr_t *)&objp->ypml_next,
493 1.22 christos sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
494 1.13 christos return FALSE;
495 1.13 christos
496 1.13 christos return TRUE;
497 1.1 deraadt }
498 1.1 deraadt
499 1.1 deraadt bool_t
500 1.1 deraadt xdr_ypresp_maplist(xdrs, objp)
501 1.12 thorpej XDR *xdrs;
502 1.12 thorpej struct ypresp_maplist *objp;
503 1.1 deraadt {
504 1.23 lukem
505 1.23 lukem _DIAGASSERT(xdrs != NULL);
506 1.23 lukem _DIAGASSERT(objp != NULL);
507 1.23 lukem
508 1.26 christos if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
509 1.9 christos return FALSE;
510 1.12 thorpej
511 1.13 christos if (!xdr_pointer(xdrs, (caddr_t *)&objp->list,
512 1.22 christos sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
513 1.13 christos return FALSE;
514 1.13 christos
515 1.13 christos return TRUE;
516 1.1 deraadt }
517 1.1 deraadt
518 1.1 deraadt bool_t
519 1.1 deraadt xdr_ypresp_order(xdrs, objp)
520 1.12 thorpej XDR *xdrs;
521 1.12 thorpej struct ypresp_order *objp;
522 1.1 deraadt {
523 1.23 lukem
524 1.23 lukem _DIAGASSERT(xdrs != NULL);
525 1.23 lukem _DIAGASSERT(objp != NULL);
526 1.23 lukem
527 1.26 christos if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
528 1.9 christos return FALSE;
529 1.12 thorpej
530 1.14 thorpej if (!xdr_u_int(xdrs, &objp->ordernum))
531 1.13 christos return FALSE;
532 1.13 christos
533 1.13 christos return TRUE;
534 1.12 thorpej }
535 1.12 thorpej
536 1.12 thorpej bool_t
537 1.12 thorpej xdr_ypreq_xfr(xdrs, objp)
538 1.12 thorpej XDR *xdrs;
539 1.12 thorpej struct ypreq_xfr *objp;
540 1.12 thorpej {
541 1.23 lukem
542 1.23 lukem _DIAGASSERT(xdrs != NULL);
543 1.23 lukem _DIAGASSERT(objp != NULL);
544 1.23 lukem
545 1.13 christos if (!xdr_ypmap_parms(xdrs, &objp->map_parms))
546 1.12 thorpej return FALSE;
547 1.12 thorpej
548 1.14 thorpej if (!xdr_u_int(xdrs, &objp->transid))
549 1.12 thorpej return FALSE;
550 1.12 thorpej
551 1.14 thorpej if (!xdr_u_int(xdrs, &objp->proto))
552 1.12 thorpej return FALSE;
553 1.12 thorpej
554 1.14 thorpej if (!xdr_u_int(xdrs, &objp->port))
555 1.12 thorpej return FALSE;
556 1.12 thorpej
557 1.12 thorpej return TRUE;
558 1.12 thorpej }
559 1.12 thorpej
560 1.12 thorpej bool_t
561 1.12 thorpej xdr_ypmap_parms(xdrs, objp)
562 1.12 thorpej XDR *xdrs;
563 1.12 thorpej struct ypmap_parms *objp;
564 1.12 thorpej {
565 1.23 lukem
566 1.23 lukem _DIAGASSERT(xdrs != NULL);
567 1.23 lukem _DIAGASSERT(objp != NULL);
568 1.23 lukem
569 1.29 christos if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
570 1.12 thorpej return FALSE;
571 1.12 thorpej
572 1.29 christos if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
573 1.12 thorpej return FALSE;
574 1.12 thorpej
575 1.14 thorpej if (!xdr_u_int(xdrs, &objp->ordernum))
576 1.12 thorpej return FALSE;
577 1.12 thorpej
578 1.13 christos if (!xdr_ypowner_wrap_string(xdrs, &objp->owner))
579 1.12 thorpej return FALSE;
580 1.12 thorpej
581 1.12 thorpej return TRUE;
582 1.12 thorpej }
583 1.12 thorpej
584 1.12 thorpej bool_t
585 1.12 thorpej xdr_yppushresp_xfr(xdrs, objp)
586 1.12 thorpej XDR *xdrs;
587 1.12 thorpej struct yppushresp_xfr *objp;
588 1.12 thorpej {
589 1.23 lukem
590 1.23 lukem _DIAGASSERT(xdrs != NULL);
591 1.23 lukem _DIAGASSERT(objp != NULL);
592 1.23 lukem
593 1.14 thorpej if (!xdr_u_int(xdrs, &objp->transid))
594 1.12 thorpej return FALSE;
595 1.12 thorpej
596 1.14 thorpej if (!xdr_enum(xdrs, (enum_t *)&objp->status))
597 1.12 thorpej return FALSE;
598 1.12 thorpej
599 1.12 thorpej return TRUE;
600 1.1 deraadt }
601