1*f14fb602SLionel Sambuc /* $NetBSD: xdryp.c,v 1.32 2012/03/20 16:30:26 matt Exp $ */
22fe8fb19SBen Gras
32fe8fb19SBen Gras /*
42fe8fb19SBen Gras * Copyright (c) 1996 Jason R. Thorpe <thorpej@NetBSD.org>.
52fe8fb19SBen Gras * All rights reserved.
62fe8fb19SBen Gras *
72fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without
82fe8fb19SBen Gras * modification, are permitted provided that the following conditions
92fe8fb19SBen Gras * are met:
102fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright
112fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer.
122fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
132fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the
142fe8fb19SBen Gras * documentation and/or other materials provided with the distribution.
152fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software
162fe8fb19SBen Gras * must display the following acknowledgement:
172fe8fb19SBen Gras * This product includes software developed for the NetBSD Project
182fe8fb19SBen Gras * by Jason R. Thorpe.
192fe8fb19SBen Gras * 4. The name of the author may not be used to endorse or promote products
202fe8fb19SBen Gras * derived from this software without specific prior written permission.
212fe8fb19SBen Gras *
222fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
232fe8fb19SBen Gras * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
242fe8fb19SBen Gras * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
252fe8fb19SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
262fe8fb19SBen Gras * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
272fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
282fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
292fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
302fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
312fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
322fe8fb19SBen Gras * SUCH DAMAGE.
332fe8fb19SBen Gras */
342fe8fb19SBen Gras
352fe8fb19SBen Gras /*
362fe8fb19SBen Gras * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
372fe8fb19SBen Gras * All rights reserved.
382fe8fb19SBen Gras *
392fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without
402fe8fb19SBen Gras * modification, are permitted provided that the following conditions
412fe8fb19SBen Gras * are met:
422fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright
432fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer.
442fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
452fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the
462fe8fb19SBen Gras * documentation and/or other materials provided with the distribution.
472fe8fb19SBen Gras *
482fe8fb19SBen Gras *
492fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
502fe8fb19SBen Gras * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
512fe8fb19SBen Gras * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
522fe8fb19SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
532fe8fb19SBen Gras * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
542fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
552fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
562fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
572fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
582fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
592fe8fb19SBen Gras * SUCH DAMAGE.
602fe8fb19SBen Gras */
612fe8fb19SBen Gras
622fe8fb19SBen Gras #include <sys/cdefs.h>
632fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint)
64*f14fb602SLionel Sambuc __RCSID("$NetBSD: xdryp.c,v 1.32 2012/03/20 16:30:26 matt Exp $");
652fe8fb19SBen Gras #endif
662fe8fb19SBen Gras
672fe8fb19SBen Gras /*
682fe8fb19SBen Gras * XDR routines used by the YP protocol. Note that these routines do
692fe8fb19SBen Gras * not strictly conform to the RPC definition in yp.x. This file
702fe8fb19SBen Gras * replicates the functions exported by the Sun YP API; reality is
712fe8fb19SBen Gras * often inaccurate.
722fe8fb19SBen Gras */
732fe8fb19SBen Gras
742fe8fb19SBen Gras #include "namespace.h"
752fe8fb19SBen Gras
762fe8fb19SBen Gras #include <sys/param.h>
772fe8fb19SBen Gras #include <sys/socket.h>
782fe8fb19SBen Gras
792fe8fb19SBen Gras #include <assert.h>
802fe8fb19SBen Gras #include <ctype.h>
812fe8fb19SBen Gras #include <stdio.h>
822fe8fb19SBen Gras #include <stdlib.h>
832fe8fb19SBen Gras #include <string.h>
842fe8fb19SBen Gras
852fe8fb19SBen Gras #include <rpc/rpc.h>
862fe8fb19SBen Gras #include <rpc/xdr.h>
872fe8fb19SBen Gras #include <rpcsvc/yp_prot.h>
882fe8fb19SBen Gras #include <rpcsvc/ypclnt.h>
892fe8fb19SBen Gras
902fe8fb19SBen Gras #ifdef __weak_alias
912fe8fb19SBen Gras __weak_alias(xdr_datum,_xdr_datum)
922fe8fb19SBen Gras __weak_alias(xdr_domainname,_xdr_domainname)
932fe8fb19SBen Gras __weak_alias(xdr_mapname,_xdr_mapname)
942fe8fb19SBen Gras __weak_alias(xdr_peername,_xdr_peername)
952fe8fb19SBen Gras __weak_alias(xdr_yp_inaddr,_xdr_yp_inaddr)
962fe8fb19SBen Gras __weak_alias(xdr_ypall,_xdr_ypall)
972fe8fb19SBen Gras __weak_alias(xdr_ypbind_resp,_xdr_ypbind_resp)
982fe8fb19SBen Gras __weak_alias(xdr_ypbind_setdom,_xdr_ypbind_setdom)
992fe8fb19SBen Gras __weak_alias(xdr_ypdomain_wrap_string,_xdr_ypdomain_wrap_string)
1002fe8fb19SBen Gras __weak_alias(xdr_ypmap_parms,_xdr_ypmap_parms)
1012fe8fb19SBen Gras __weak_alias(xdr_ypmap_wrap_string,_xdr_ypmap_wrap_string)
1022fe8fb19SBen Gras __weak_alias(xdr_ypmaplist,_xdr_ypmaplist)
1032fe8fb19SBen Gras __weak_alias(xdr_ypowner_wrap_string,_xdr_ypowner_wrap_string)
1042fe8fb19SBen Gras __weak_alias(xdr_yppushresp_xfr,_xdr_yppushresp_xfr)
1052fe8fb19SBen Gras __weak_alias(xdr_ypreq_key,_xdr_ypreq_key)
1062fe8fb19SBen Gras __weak_alias(xdr_ypreq_nokey,_xdr_ypreq_nokey)
1072fe8fb19SBen Gras __weak_alias(xdr_ypreq_xfr,_xdr_ypreq_xfr)
1082fe8fb19SBen Gras __weak_alias(xdr_ypresp_key_val,_xdr_ypresp_key_val)
1092fe8fb19SBen Gras __weak_alias(xdr_ypresp_maplist,_xdr_ypresp_maplist)
1102fe8fb19SBen Gras __weak_alias(xdr_ypresp_master,_xdr_ypresp_master)
1112fe8fb19SBen Gras __weak_alias(xdr_ypresp_order,_xdr_ypresp_order)
1122fe8fb19SBen Gras __weak_alias(xdr_ypresp_val,_xdr_ypresp_val)
1132fe8fb19SBen Gras #endif
1142fe8fb19SBen Gras
1152fe8fb19SBen Gras /*
1162fe8fb19SBen Gras * Functions used only within this file.
1172fe8fb19SBen Gras */
118*f14fb602SLionel Sambuc static bool_t xdr_ypbind_binding(XDR *, struct ypbind_binding *);
119*f14fb602SLionel Sambuc static bool_t xdr_ypbind_resptype(XDR *, enum ypbind_resptype *);
120*f14fb602SLionel Sambuc static bool_t xdr_ypstat(XDR *, enum ypbind_resptype *);
121*f14fb602SLionel Sambuc static bool_t xdr_ypmaplist_str(XDR *, char *);
1222fe8fb19SBen Gras
1232fe8fb19SBen Gras __warn_references(xdr_domainname,
1242fe8fb19SBen Gras "warning: this program uses xdr_domainname(), which is deprecated and buggy.")
1252fe8fb19SBen Gras
1262fe8fb19SBen Gras bool_t
xdr_domainname(XDR * xdrs,char * objp)127*f14fb602SLionel Sambuc xdr_domainname(XDR *xdrs, char *objp)
1282fe8fb19SBen Gras {
1292fe8fb19SBen Gras
1302fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1312fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1322fe8fb19SBen Gras
1332fe8fb19SBen Gras return xdr_string(xdrs, &objp, YPMAXDOMAIN);
1342fe8fb19SBen Gras }
1352fe8fb19SBen Gras
1362fe8fb19SBen Gras __warn_references(xdr_peername,
1372fe8fb19SBen Gras "warning: this program uses xdr_peername(), which is deprecated and buggy.")
1382fe8fb19SBen Gras
1392fe8fb19SBen Gras bool_t
xdr_peername(XDR * xdrs,char * objp)140*f14fb602SLionel Sambuc xdr_peername(XDR *xdrs, char *objp)
1412fe8fb19SBen Gras {
1422fe8fb19SBen Gras
1432fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1442fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1452fe8fb19SBen Gras
1462fe8fb19SBen Gras return xdr_string(xdrs, &objp, YPMAXPEER);
1472fe8fb19SBen Gras }
1482fe8fb19SBen Gras
1492fe8fb19SBen Gras __warn_references(xdr_mapname,
1502fe8fb19SBen Gras "warning: this program uses xdr_mapname(), which is deprecated and buggy.")
1512fe8fb19SBen Gras
1522fe8fb19SBen Gras bool_t
xdr_mapname(XDR * xdrs,char * objp)153*f14fb602SLionel Sambuc xdr_mapname(XDR *xdrs, char *objp)
1542fe8fb19SBen Gras {
1552fe8fb19SBen Gras
1562fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1572fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1582fe8fb19SBen Gras
1592fe8fb19SBen Gras return xdr_string(xdrs, &objp, YPMAXMAP);
1602fe8fb19SBen Gras }
1612fe8fb19SBen Gras
1622fe8fb19SBen Gras bool_t
xdr_ypdomain_wrap_string(XDR * xdrs,char ** objp)163*f14fb602SLionel Sambuc xdr_ypdomain_wrap_string(XDR *xdrs, char **objp)
1642fe8fb19SBen Gras {
1652fe8fb19SBen Gras
1662fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1672fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1682fe8fb19SBen Gras
1692fe8fb19SBen Gras return xdr_string(xdrs, objp, YPMAXDOMAIN);
1702fe8fb19SBen Gras }
1712fe8fb19SBen Gras
1722fe8fb19SBen Gras bool_t
xdr_ypmap_wrap_string(XDR * xdrs,char ** objp)173*f14fb602SLionel Sambuc xdr_ypmap_wrap_string(XDR *xdrs, char **objp)
1742fe8fb19SBen Gras {
1752fe8fb19SBen Gras
1762fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1772fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1782fe8fb19SBen Gras
1792fe8fb19SBen Gras return xdr_string(xdrs, objp, YPMAXMAP);
1802fe8fb19SBen Gras }
1812fe8fb19SBen Gras
1822fe8fb19SBen Gras bool_t
xdr_ypowner_wrap_string(XDR * xdrs,char ** objp)183*f14fb602SLionel Sambuc xdr_ypowner_wrap_string(XDR *xdrs, char **objp)
1842fe8fb19SBen Gras {
1852fe8fb19SBen Gras
1862fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1872fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1882fe8fb19SBen Gras
1892fe8fb19SBen Gras return xdr_string(xdrs, objp, YPMAXPEER);
1902fe8fb19SBen Gras }
1912fe8fb19SBen Gras
1922fe8fb19SBen Gras bool_t
xdr_datum(XDR * xdrs,datum * objp)193*f14fb602SLionel Sambuc xdr_datum(XDR *xdrs, datum *objp)
1942fe8fb19SBen Gras {
1952fe8fb19SBen Gras
1962fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
1972fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
1982fe8fb19SBen Gras
1992fe8fb19SBen Gras return xdr_bytes(xdrs, __UNCONST(&objp->dptr),
2002fe8fb19SBen Gras (u_int *)&objp->dsize, YPMAXRECORD);
2012fe8fb19SBen Gras }
2022fe8fb19SBen Gras
2032fe8fb19SBen Gras bool_t
xdr_ypreq_key(XDR * xdrs,struct ypreq_key * objp)204*f14fb602SLionel Sambuc xdr_ypreq_key(XDR *xdrs, struct ypreq_key *objp)
2052fe8fb19SBen Gras {
2062fe8fb19SBen Gras
2072fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2082fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2092fe8fb19SBen Gras
2102fe8fb19SBen Gras if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
2112fe8fb19SBen Gras return FALSE;
2122fe8fb19SBen Gras
2132fe8fb19SBen Gras if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
2142fe8fb19SBen Gras return FALSE;
2152fe8fb19SBen Gras
2162fe8fb19SBen Gras if (!xdr_datum(xdrs, &objp->keydat))
2172fe8fb19SBen Gras return FALSE;
2182fe8fb19SBen Gras
2192fe8fb19SBen Gras return TRUE;
2202fe8fb19SBen Gras }
2212fe8fb19SBen Gras
2222fe8fb19SBen Gras bool_t
xdr_ypreq_nokey(XDR * xdrs,struct ypreq_nokey * objp)223*f14fb602SLionel Sambuc xdr_ypreq_nokey(XDR *xdrs, struct ypreq_nokey *objp)
2242fe8fb19SBen Gras {
2252fe8fb19SBen Gras
2262fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2272fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2282fe8fb19SBen Gras
2292fe8fb19SBen Gras if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
2302fe8fb19SBen Gras return FALSE;
2312fe8fb19SBen Gras
2322fe8fb19SBen Gras if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
2332fe8fb19SBen Gras return FALSE;
2342fe8fb19SBen Gras
2352fe8fb19SBen Gras return TRUE;
2362fe8fb19SBen Gras }
2372fe8fb19SBen Gras
2382fe8fb19SBen Gras bool_t
xdr_yp_inaddr(XDR * xdrs,struct in_addr * objp)239*f14fb602SLionel Sambuc xdr_yp_inaddr(XDR *xdrs, struct in_addr *objp)
2402fe8fb19SBen Gras {
2412fe8fb19SBen Gras
2422fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2432fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2442fe8fb19SBen Gras
2452fe8fb19SBen Gras return xdr_opaque(xdrs, (caddr_t)(void *)&objp->s_addr,
246*f14fb602SLionel Sambuc (u_int)sizeof objp->s_addr);
2472fe8fb19SBen Gras }
2482fe8fb19SBen Gras
2492fe8fb19SBen Gras static bool_t
xdr_ypbind_binding(XDR * xdrs,struct ypbind_binding * objp)250*f14fb602SLionel Sambuc xdr_ypbind_binding(XDR *xdrs, struct ypbind_binding *objp)
2512fe8fb19SBen Gras {
2522fe8fb19SBen Gras
2532fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2542fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2552fe8fb19SBen Gras
2562fe8fb19SBen Gras if (!xdr_yp_inaddr(xdrs, &objp->ypbind_binding_addr))
2572fe8fb19SBen Gras return FALSE;
2582fe8fb19SBen Gras
2592fe8fb19SBen Gras if (!xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
260*f14fb602SLionel Sambuc (u_int)sizeof objp->ypbind_binding_port))
2612fe8fb19SBen Gras return FALSE;
2622fe8fb19SBen Gras
2632fe8fb19SBen Gras return TRUE;
2642fe8fb19SBen Gras }
2652fe8fb19SBen Gras
2662fe8fb19SBen Gras static bool_t
xdr_ypbind_resptype(XDR * xdrs,enum ypbind_resptype * objp)267*f14fb602SLionel Sambuc xdr_ypbind_resptype(XDR *xdrs, enum ypbind_resptype *objp)
2682fe8fb19SBen Gras {
2692fe8fb19SBen Gras
2702fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2712fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2722fe8fb19SBen Gras
2732fe8fb19SBen Gras return xdr_enum(xdrs, (enum_t *)(void *)objp);
2742fe8fb19SBen Gras }
2752fe8fb19SBen Gras
2762fe8fb19SBen Gras static bool_t
xdr_ypstat(XDR * xdrs,enum ypbind_resptype * objp)277*f14fb602SLionel Sambuc xdr_ypstat(XDR *xdrs, enum ypbind_resptype *objp)
2782fe8fb19SBen Gras {
2792fe8fb19SBen Gras
2802fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2812fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2822fe8fb19SBen Gras
2832fe8fb19SBen Gras return xdr_enum(xdrs, (enum_t *)(void *)objp);
2842fe8fb19SBen Gras }
2852fe8fb19SBen Gras
2862fe8fb19SBen Gras bool_t
xdr_ypbind_resp(XDR * xdrs,struct ypbind_resp * objp)287*f14fb602SLionel Sambuc xdr_ypbind_resp(XDR *xdrs, struct ypbind_resp *objp)
2882fe8fb19SBen Gras {
2892fe8fb19SBen Gras
2902fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
2912fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
2922fe8fb19SBen Gras
2932fe8fb19SBen Gras if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status))
2942fe8fb19SBen Gras return FALSE;
2952fe8fb19SBen Gras
2962fe8fb19SBen Gras switch (objp->ypbind_status) {
2972fe8fb19SBen Gras case YPBIND_FAIL_VAL:
2982fe8fb19SBen Gras return xdr_u_int(xdrs,
2992fe8fb19SBen Gras (u_int *)&objp->ypbind_respbody.ypbind_error);
3002fe8fb19SBen Gras
3012fe8fb19SBen Gras case YPBIND_SUCC_VAL:
3022fe8fb19SBen Gras return xdr_ypbind_binding(xdrs,
3032fe8fb19SBen Gras &objp->ypbind_respbody.ypbind_bindinfo);
3042fe8fb19SBen Gras
3052fe8fb19SBen Gras default:
3062fe8fb19SBen Gras return FALSE;
3072fe8fb19SBen Gras }
3082fe8fb19SBen Gras /* NOTREACHED */
3092fe8fb19SBen Gras }
3102fe8fb19SBen Gras
3112fe8fb19SBen Gras bool_t
xdr_ypresp_val(XDR * xdrs,struct ypresp_val * objp)312*f14fb602SLionel Sambuc xdr_ypresp_val(XDR *xdrs, struct ypresp_val *objp)
3132fe8fb19SBen Gras {
3142fe8fb19SBen Gras
3152fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
3162fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
3172fe8fb19SBen Gras
3182fe8fb19SBen Gras if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
3192fe8fb19SBen Gras return FALSE;
3202fe8fb19SBen Gras
3212fe8fb19SBen Gras if (!xdr_datum(xdrs, &objp->valdat))
3222fe8fb19SBen Gras return FALSE;
3232fe8fb19SBen Gras
3242fe8fb19SBen Gras return TRUE;
3252fe8fb19SBen Gras }
3262fe8fb19SBen Gras
3272fe8fb19SBen Gras bool_t
xdr_ypbind_setdom(XDR * xdrs,struct ypbind_setdom * objp)328*f14fb602SLionel Sambuc xdr_ypbind_setdom(XDR *xdrs, struct ypbind_setdom *objp)
3292fe8fb19SBen Gras {
3302fe8fb19SBen Gras char *cp;
3312fe8fb19SBen Gras
3322fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
3332fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
3342fe8fb19SBen Gras
3352fe8fb19SBen Gras cp = objp->ypsetdom_domain;
3362fe8fb19SBen Gras
3372fe8fb19SBen Gras if (!xdr_ypdomain_wrap_string(xdrs, &cp))
3382fe8fb19SBen Gras return FALSE;
3392fe8fb19SBen Gras
3402fe8fb19SBen Gras if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding))
3412fe8fb19SBen Gras return FALSE;
3422fe8fb19SBen Gras
3432fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->ypsetdom_vers))
3442fe8fb19SBen Gras return FALSE;
3452fe8fb19SBen Gras
3462fe8fb19SBen Gras return TRUE;
3472fe8fb19SBen Gras }
3482fe8fb19SBen Gras
3492fe8fb19SBen Gras bool_t
xdr_ypresp_key_val(XDR * xdrs,struct ypresp_key_val * objp)350*f14fb602SLionel Sambuc xdr_ypresp_key_val(XDR *xdrs, struct ypresp_key_val *objp)
3512fe8fb19SBen Gras {
3522fe8fb19SBen Gras
3532fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
3542fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
3552fe8fb19SBen Gras
3562fe8fb19SBen Gras if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
3572fe8fb19SBen Gras return FALSE;
3582fe8fb19SBen Gras
3592fe8fb19SBen Gras if (!xdr_datum(xdrs, &objp->valdat))
3602fe8fb19SBen Gras return FALSE;
3612fe8fb19SBen Gras
3622fe8fb19SBen Gras if (!xdr_datum(xdrs, &objp->keydat))
3632fe8fb19SBen Gras return FALSE;
3642fe8fb19SBen Gras
3652fe8fb19SBen Gras return TRUE;
3662fe8fb19SBen Gras }
3672fe8fb19SBen Gras
3682fe8fb19SBen Gras bool_t
xdr_ypall(XDR * xdrs,struct ypall_callback * incallback)369*f14fb602SLionel Sambuc xdr_ypall(XDR *xdrs, struct ypall_callback *incallback)
3702fe8fb19SBen Gras {
3712fe8fb19SBen Gras struct ypresp_key_val out;
3722fe8fb19SBen Gras char key[YPMAXRECORD], val[YPMAXRECORD];
3732fe8fb19SBen Gras bool_t more, status;
3742fe8fb19SBen Gras
3752fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
3762fe8fb19SBen Gras _DIAGASSERT(incallback != NULL);
3772fe8fb19SBen Gras
3782fe8fb19SBen Gras /*
3792fe8fb19SBen Gras * Set up key/val struct to be used during the transaction.
3802fe8fb19SBen Gras */
3812fe8fb19SBen Gras memset(&out, 0, sizeof out);
3822fe8fb19SBen Gras out.keydat.dptr = key;
3832fe8fb19SBen Gras out.keydat.dsize = sizeof(key);
3842fe8fb19SBen Gras out.valdat.dptr = val;
3852fe8fb19SBen Gras out.valdat.dsize = sizeof(val);
3862fe8fb19SBen Gras
3872fe8fb19SBen Gras for (;;) {
3882fe8fb19SBen Gras /* Values pending? */
3892fe8fb19SBen Gras if (!xdr_bool(xdrs, &more))
3902fe8fb19SBen Gras return FALSE; /* can't tell! */
3912fe8fb19SBen Gras if (!more)
3922fe8fb19SBen Gras return TRUE; /* no more */
3932fe8fb19SBen Gras
3942fe8fb19SBen Gras /* Transfer key/value pair. */
3952fe8fb19SBen Gras status = xdr_ypresp_key_val(xdrs, &out);
3962fe8fb19SBen Gras
3972fe8fb19SBen Gras /*
3982fe8fb19SBen Gras * If we succeeded, call the callback function.
3992fe8fb19SBen Gras * The callback will return TRUE when it wants
4002fe8fb19SBen Gras * no more values. If we fail, indicate the
4012fe8fb19SBen Gras * error.
4022fe8fb19SBen Gras */
4032fe8fb19SBen Gras if (status) {
4042fe8fb19SBen Gras if ((*incallback->foreach)((int)out.status,
4052fe8fb19SBen Gras __UNCONST(out.keydat.dptr), out.keydat.dsize,
4062fe8fb19SBen Gras __UNCONST(out.valdat.dptr), out.valdat.dsize,
4072fe8fb19SBen Gras incallback->data))
4082fe8fb19SBen Gras return TRUE;
4092fe8fb19SBen Gras } else
4102fe8fb19SBen Gras return FALSE;
4112fe8fb19SBen Gras }
4122fe8fb19SBen Gras }
4132fe8fb19SBen Gras
4142fe8fb19SBen Gras bool_t
xdr_ypresp_master(XDR * xdrs,struct ypresp_master * objp)415*f14fb602SLionel Sambuc xdr_ypresp_master(XDR *xdrs, struct ypresp_master *objp)
4162fe8fb19SBen Gras {
4172fe8fb19SBen Gras
4182fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4192fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4202fe8fb19SBen Gras
4212fe8fb19SBen Gras if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
4222fe8fb19SBen Gras return FALSE;
4232fe8fb19SBen Gras
4242fe8fb19SBen Gras if (!xdr_string(xdrs, &objp->master, YPMAXPEER))
4252fe8fb19SBen Gras return FALSE;
4262fe8fb19SBen Gras
4272fe8fb19SBen Gras return TRUE;
4282fe8fb19SBen Gras }
4292fe8fb19SBen Gras
4302fe8fb19SBen Gras static bool_t
xdr_ypmaplist_str(XDR * xdrs,char * objp)431*f14fb602SLionel Sambuc xdr_ypmaplist_str(XDR *xdrs, char *objp)
4322fe8fb19SBen Gras {
4332fe8fb19SBen Gras
4342fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4352fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4362fe8fb19SBen Gras
4372fe8fb19SBen Gras return xdr_string(xdrs, &objp, YPMAXMAP+1);
4382fe8fb19SBen Gras }
4392fe8fb19SBen Gras
4402fe8fb19SBen Gras bool_t
xdr_ypmaplist(XDR * xdrs,struct ypmaplist * objp)441*f14fb602SLionel Sambuc xdr_ypmaplist(XDR *xdrs, struct ypmaplist *objp)
4422fe8fb19SBen Gras {
4432fe8fb19SBen Gras
4442fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4452fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4462fe8fb19SBen Gras
4472fe8fb19SBen Gras if (!xdr_ypmaplist_str(xdrs, objp->ypml_name))
4482fe8fb19SBen Gras return FALSE;
4492fe8fb19SBen Gras
4502fe8fb19SBen Gras if (!xdr_pointer(xdrs, (char **)(void *)&objp->ypml_next,
451*f14fb602SLionel Sambuc (u_int)sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
4522fe8fb19SBen Gras return FALSE;
4532fe8fb19SBen Gras
4542fe8fb19SBen Gras return TRUE;
4552fe8fb19SBen Gras }
4562fe8fb19SBen Gras
4572fe8fb19SBen Gras bool_t
xdr_ypresp_maplist(XDR * xdrs,struct ypresp_maplist * objp)458*f14fb602SLionel Sambuc xdr_ypresp_maplist(XDR *xdrs, struct ypresp_maplist *objp)
4592fe8fb19SBen Gras {
4602fe8fb19SBen Gras
4612fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4622fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4632fe8fb19SBen Gras
4642fe8fb19SBen Gras if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
4652fe8fb19SBen Gras return FALSE;
4662fe8fb19SBen Gras
4672fe8fb19SBen Gras if (!xdr_pointer(xdrs, (char **)(void *)&objp->list,
468*f14fb602SLionel Sambuc (u_int)sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
4692fe8fb19SBen Gras return FALSE;
4702fe8fb19SBen Gras
4712fe8fb19SBen Gras return TRUE;
4722fe8fb19SBen Gras }
4732fe8fb19SBen Gras
4742fe8fb19SBen Gras bool_t
xdr_ypresp_order(XDR * xdrs,struct ypresp_order * objp)475*f14fb602SLionel Sambuc xdr_ypresp_order(XDR *xdrs, struct ypresp_order *objp)
4762fe8fb19SBen Gras {
4772fe8fb19SBen Gras
4782fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4792fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4802fe8fb19SBen Gras
4812fe8fb19SBen Gras if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)(void *)&objp->status))
4822fe8fb19SBen Gras return FALSE;
4832fe8fb19SBen Gras
4842fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->ordernum))
4852fe8fb19SBen Gras return FALSE;
4862fe8fb19SBen Gras
4872fe8fb19SBen Gras return TRUE;
4882fe8fb19SBen Gras }
4892fe8fb19SBen Gras
4902fe8fb19SBen Gras bool_t
xdr_ypreq_xfr(XDR * xdrs,struct ypreq_xfr * objp)491*f14fb602SLionel Sambuc xdr_ypreq_xfr(XDR *xdrs, struct ypreq_xfr *objp)
4922fe8fb19SBen Gras {
4932fe8fb19SBen Gras
4942fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
4952fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
4962fe8fb19SBen Gras
4972fe8fb19SBen Gras if (!xdr_ypmap_parms(xdrs, &objp->map_parms))
4982fe8fb19SBen Gras return FALSE;
4992fe8fb19SBen Gras
5002fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->transid))
5012fe8fb19SBen Gras return FALSE;
5022fe8fb19SBen Gras
5032fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->proto))
5042fe8fb19SBen Gras return FALSE;
5052fe8fb19SBen Gras
5062fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->port))
5072fe8fb19SBen Gras return FALSE;
5082fe8fb19SBen Gras
5092fe8fb19SBen Gras return TRUE;
5102fe8fb19SBen Gras }
5112fe8fb19SBen Gras
5122fe8fb19SBen Gras bool_t
xdr_ypmap_parms(XDR * xdrs,struct ypmap_parms * objp)513*f14fb602SLionel Sambuc xdr_ypmap_parms(XDR *xdrs, struct ypmap_parms *objp)
5142fe8fb19SBen Gras {
5152fe8fb19SBen Gras
5162fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
5172fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
5182fe8fb19SBen Gras
5192fe8fb19SBen Gras if (!xdr_ypdomain_wrap_string(xdrs, __UNCONST(&objp->domain)))
5202fe8fb19SBen Gras return FALSE;
5212fe8fb19SBen Gras
5222fe8fb19SBen Gras if (!xdr_ypmap_wrap_string(xdrs, __UNCONST(&objp->map)))
5232fe8fb19SBen Gras return FALSE;
5242fe8fb19SBen Gras
5252fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->ordernum))
5262fe8fb19SBen Gras return FALSE;
5272fe8fb19SBen Gras
5282fe8fb19SBen Gras if (!xdr_ypowner_wrap_string(xdrs, &objp->owner))
5292fe8fb19SBen Gras return FALSE;
5302fe8fb19SBen Gras
5312fe8fb19SBen Gras return TRUE;
5322fe8fb19SBen Gras }
5332fe8fb19SBen Gras
5342fe8fb19SBen Gras bool_t
xdr_yppushresp_xfr(XDR * xdrs,struct yppushresp_xfr * objp)535*f14fb602SLionel Sambuc xdr_yppushresp_xfr(XDR *xdrs, struct yppushresp_xfr *objp)
5362fe8fb19SBen Gras {
5372fe8fb19SBen Gras
5382fe8fb19SBen Gras _DIAGASSERT(xdrs != NULL);
5392fe8fb19SBen Gras _DIAGASSERT(objp != NULL);
5402fe8fb19SBen Gras
5412fe8fb19SBen Gras if (!xdr_u_int(xdrs, &objp->transid))
5422fe8fb19SBen Gras return FALSE;
5432fe8fb19SBen Gras
5442fe8fb19SBen Gras if (!xdr_enum(xdrs, (enum_t *)&objp->status))
5452fe8fb19SBen Gras return FALSE;
5462fe8fb19SBen Gras
5472fe8fb19SBen Gras return TRUE;
5482fe8fb19SBen Gras }
549