xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_xdr.c (revision e8031f0a)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
2161961e0fSrobinson  */
2261961e0fSrobinson 
2361961e0fSrobinson /*
24*e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved   */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
337c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of
347c478bd9Sstevel@tonic-gate  * California.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * This contains ALL xdr routines used by the YP rpc interface.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
43*e8031f0aSraf #include "mt.h"
4461961e0fSrobinson #include <unistd.h>
4561961e0fSrobinson #include <stdlib.h>
467c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
477c478bd9Sstevel@tonic-gate #include "yp_b.h"
487c478bd9Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
497c478bd9Sstevel@tonic-gate #include <rpcsvc/ypclnt.h>
507c478bd9Sstevel@tonic-gate #include <sys/types.h>
517c478bd9Sstevel@tonic-gate #include <limits.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate static bool xdr_ypmaplist(XDR *, struct ypmaplist **);
547c478bd9Sstevel@tonic-gate static bool xdr_ypmaplist_wrap_string(XDR *, char *);
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate typedef struct xdr_discrim XDR_DISCRIM;
5761961e0fSrobinson extern bool xdr_ypreq_key(XDR *, struct ypreq_key *);
5861961e0fSrobinson extern bool xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
5961961e0fSrobinson extern bool xdr_ypresp_val(XDR *, struct ypresp_val *);
6061961e0fSrobinson extern bool xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
6161961e0fSrobinson extern bool xdr_ypmap_parms(XDR *, struct ypmap_parms *);
6261961e0fSrobinson extern bool xdr_ypowner_wrap_string(XDR *, char **);
6361961e0fSrobinson extern bool xdr_ypreq_newname_string(XDR *, char **);
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * Serializes/deserializes a dbm datum data structure.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate bool
xdr_datum(XDR * xdrs,datum * pdatum)7061961e0fSrobinson xdr_datum(XDR *xdrs, datum *pdatum)
717c478bd9Sstevel@tonic-gate {
7261961e0fSrobinson 	bool res;
737c478bd9Sstevel@tonic-gate 	uint_t dsize;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 	/*
767c478bd9Sstevel@tonic-gate 	 * LP64 case :
777c478bd9Sstevel@tonic-gate 	 * xdr_bytes() expects a uint_t for the 3rd argument. Since
787c478bd9Sstevel@tonic-gate 	 * datum.dsize is a long, we need a new temporary to pass to
797c478bd9Sstevel@tonic-gate 	 * xdr_bytes()
807c478bd9Sstevel@tonic-gate 	 */
817c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE) {
827c478bd9Sstevel@tonic-gate 		if (pdatum->dsize > UINT_MAX)
837c478bd9Sstevel@tonic-gate 			return (FALSE);
847c478bd9Sstevel@tonic-gate 	}
857c478bd9Sstevel@tonic-gate 	dsize = (uint_t)pdatum->dsize;
8661961e0fSrobinson 	res = (bool)xdr_bytes(xdrs, (char **)&(pdatum->dptr), &dsize,
8761961e0fSrobinson 								YPMAXRECORD);
887c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_DECODE) {
897c478bd9Sstevel@tonic-gate 		pdatum->dsize = dsize;
907c478bd9Sstevel@tonic-gate 	}
917c478bd9Sstevel@tonic-gate 
9261961e0fSrobinson 	return (res);
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*
977c478bd9Sstevel@tonic-gate  * Serializes/deserializes a domain name string.  This is a "wrapper" for
987c478bd9Sstevel@tonic-gate  * xdr_string which knows about the maximum domain name size.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate bool
xdr_ypdomain_wrap_string(XDR * xdrs,char ** ppstring)10161961e0fSrobinson xdr_ypdomain_wrap_string(XDR *xdrs, char **ppstring)
1027c478bd9Sstevel@tonic-gate {
10361961e0fSrobinson 	return ((bool)xdr_string(xdrs, ppstring, YPMAXDOMAIN));
1047c478bd9Sstevel@tonic-gate }
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * Serializes/deserializes a map name string.  This is a "wrapper" for
1087c478bd9Sstevel@tonic-gate  * xdr_string which knows about the maximum map name size.
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate bool
xdr_ypmap_wrap_string(XDR * xdrs,char ** ppstring)11161961e0fSrobinson xdr_ypmap_wrap_string(XDR *xdrs, char **ppstring)
1127c478bd9Sstevel@tonic-gate {
11361961e0fSrobinson 	return ((bool)xdr_string(xdrs, ppstring, YPMAXMAP));
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypreq_key structure.
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate bool
xdr_ypreq_key(XDR * xdrs,struct ypreq_key * ps)12061961e0fSrobinson xdr_ypreq_key(XDR *xdrs, struct ypreq_key *ps)
1217c478bd9Sstevel@tonic-gate {
12261961e0fSrobinson 	return ((bool)(xdr_ypdomain_wrap_string(xdrs, &ps->domain) &&
1237c478bd9Sstevel@tonic-gate 		    xdr_ypmap_wrap_string(xdrs, &ps->map) &&
12461961e0fSrobinson 		    xdr_datum(xdrs, &ps->keydat)));
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypreq_nokey structure.
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate bool
xdr_ypreq_nokey(XDR * xdrs,struct ypreq_nokey * ps)13161961e0fSrobinson xdr_ypreq_nokey(XDR *xdrs, struct ypreq_nokey *ps)
1327c478bd9Sstevel@tonic-gate {
13361961e0fSrobinson 	return ((bool)(xdr_ypdomain_wrap_string(xdrs, &ps->domain) &&
13461961e0fSrobinson 		    xdr_ypmap_wrap_string(xdrs, &ps->map)));
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate /*
1387c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresp_val structure.
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate bool
xdr_ypresp_val(XDR * xdrs,struct ypresp_val * ps)14161961e0fSrobinson xdr_ypresp_val(XDR *xdrs, struct ypresp_val *ps)
1427c478bd9Sstevel@tonic-gate {
14361961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
14461961e0fSrobinson 		    xdr_datum(xdrs, &ps->valdat)));
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresp_key_val structure.
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate bool
xdr_ypresp_key_val(XDR * xdrs,struct ypresp_key_val * ps)15161961e0fSrobinson xdr_ypresp_key_val(XDR *xdrs, struct ypresp_key_val *ps)
1527c478bd9Sstevel@tonic-gate {
15361961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
1547c478bd9Sstevel@tonic-gate 	    xdr_datum(xdrs, &ps->valdat) &&
15561961e0fSrobinson 	    xdr_datum(xdrs, &ps->keydat)));
1567c478bd9Sstevel@tonic-gate }
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * Serializes/deserializes a peer server's node name
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate bool
xdr_ypowner_wrap_string(XDR * xdrs,char ** ppstring)16261961e0fSrobinson xdr_ypowner_wrap_string(XDR *xdrs, char **ppstring)
1637c478bd9Sstevel@tonic-gate {
16461961e0fSrobinson 	return ((bool)xdr_string(xdrs, ppstring, YPMAXPEER));
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate /*
1687c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypmap_parms structure.
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate bool
xdr_ypmap_parms(XDR * xdrs,struct ypmap_parms * ps)17161961e0fSrobinson xdr_ypmap_parms(XDR *xdrs, struct ypmap_parms *ps)
1727c478bd9Sstevel@tonic-gate {
17361961e0fSrobinson 	return ((bool)(xdr_ypdomain_wrap_string(xdrs, &ps->domain) &&
1747c478bd9Sstevel@tonic-gate 	    xdr_ypmap_wrap_string(xdrs, &ps->map) &&
1757c478bd9Sstevel@tonic-gate 	    xdr_u_int(xdrs, &ps->ordernum) &&
17661961e0fSrobinson 	    xdr_ypowner_wrap_string(xdrs, &ps->owner)));
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypreq_newxfr name
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate bool
xdr_ypreq_newname_string(XDR * xdrs,char ** ppstring)18361961e0fSrobinson xdr_ypreq_newname_string(XDR *xdrs, char **ppstring)
1847c478bd9Sstevel@tonic-gate {
18561961e0fSrobinson 	return ((bool)xdr_string(xdrs, ppstring, 256));
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresp_master structure.
1907c478bd9Sstevel@tonic-gate  */
1917c478bd9Sstevel@tonic-gate bool
xdr_ypresp_master(XDR * xdrs,struct ypresp_master * ps)19261961e0fSrobinson xdr_ypresp_master(XDR *xdrs, struct ypresp_master *ps)
1937c478bd9Sstevel@tonic-gate {
19461961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
19561961e0fSrobinson 	    xdr_ypowner_wrap_string(xdrs, &ps->master)));
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresp_order structure.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate bool
xdr_ypresp_order(XDR * xdrs,struct ypresp_order * ps)20261961e0fSrobinson xdr_ypresp_order(XDR *xdrs, struct ypresp_order *ps)
2037c478bd9Sstevel@tonic-gate {
20461961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
20561961e0fSrobinson 	    xdr_u_int(xdrs, &ps->ordernum)));
2067c478bd9Sstevel@tonic-gate }
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * This is like xdr_ypmap_wrap_string except that it serializes/deserializes
2107c478bd9Sstevel@tonic-gate  * an array, instead of a pointer, so xdr_reference can work on the structure
2117c478bd9Sstevel@tonic-gate  * containing the char array itself.
2127c478bd9Sstevel@tonic-gate  */
2137c478bd9Sstevel@tonic-gate static bool
xdr_ypmaplist_wrap_string(XDR * xdrs,char * pstring)21461961e0fSrobinson xdr_ypmaplist_wrap_string(XDR *xdrs, char *pstring)
2157c478bd9Sstevel@tonic-gate {
2167c478bd9Sstevel@tonic-gate 	char *s;
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 	s = pstring;
21961961e0fSrobinson 	return ((bool)xdr_string(xdrs, &s, YPMAXMAP));
2207c478bd9Sstevel@tonic-gate }
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypmaplist.
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate static bool
xdr_ypmaplist(XDR * xdrs,struct ypmaplist ** lst)22661961e0fSrobinson xdr_ypmaplist(XDR *xdrs, struct ypmaplist **lst)
2277c478bd9Sstevel@tonic-gate {
2287c478bd9Sstevel@tonic-gate 	bool_t more_elements;
2297c478bd9Sstevel@tonic-gate 	int freeing = (xdrs->x_op == XDR_FREE);
2307c478bd9Sstevel@tonic-gate 	struct ypmaplist **next;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	for (;;) {
23361961e0fSrobinson 		more_elements = (*lst != NULL);
2347c478bd9Sstevel@tonic-gate 
23561961e0fSrobinson 		if (!xdr_bool(xdrs, &more_elements))
2367c478bd9Sstevel@tonic-gate 			return (FALSE);
2377c478bd9Sstevel@tonic-gate 
23861961e0fSrobinson 		if (!more_elements)
2397c478bd9Sstevel@tonic-gate 			return (TRUE);  /* All done */
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate 		if (freeing)
2427c478bd9Sstevel@tonic-gate 			next = &((*lst)->ypml_next);
2437c478bd9Sstevel@tonic-gate 
24461961e0fSrobinson 		if (!xdr_reference(xdrs, (caddr_t *)lst,
24561961e0fSrobinson 			(uint_t)sizeof (struct ypmaplist),
24661961e0fSrobinson 		    (xdrproc_t)xdr_ypmaplist_wrap_string))
2477c478bd9Sstevel@tonic-gate 			return (FALSE);
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate 		lst = (freeing) ? next : &((*lst)->ypml_next);
2507c478bd9Sstevel@tonic-gate 	}
2517c478bd9Sstevel@tonic-gate 	/*NOTREACHED*/
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresp_maplist.
2567c478bd9Sstevel@tonic-gate  */
2577c478bd9Sstevel@tonic-gate bool
xdr_ypresp_maplist(XDR * xdrs,struct ypresp_maplist * ps)25861961e0fSrobinson xdr_ypresp_maplist(XDR *xdrs, struct ypresp_maplist *ps)
2597c478bd9Sstevel@tonic-gate {
26061961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
26161961e0fSrobinson 		xdr_ypmaplist(xdrs, &ps->list)));
2627c478bd9Sstevel@tonic-gate }
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  * Serializes/deserializes a yppushresp_xfr structure.
2667c478bd9Sstevel@tonic-gate  */
2677c478bd9Sstevel@tonic-gate bool
xdr_yppushresp_xfr(XDR * xdrs,struct yppushresp_xfr * ps)26861961e0fSrobinson xdr_yppushresp_xfr(XDR *xdrs, struct yppushresp_xfr *ps)
2697c478bd9Sstevel@tonic-gate {
27061961e0fSrobinson 	return ((bool)(xdr_u_int(xdrs, &ps->transid) &&
27161961e0fSrobinson 	    xdr_u_int(xdrs, &ps->status)));
2727c478bd9Sstevel@tonic-gate }
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate /*
2767c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypreq_xfr structure.
2777c478bd9Sstevel@tonic-gate  */
2787c478bd9Sstevel@tonic-gate bool
xdr_ypreq_newxfr(XDR * xdrs,struct ypreq_newxfr * ps)27961961e0fSrobinson xdr_ypreq_newxfr(XDR *xdrs, struct ypreq_newxfr *ps)
2807c478bd9Sstevel@tonic-gate {
28161961e0fSrobinson 	return ((bool)(xdr_ypmap_parms(xdrs, &ps->map_parms) &&
2827c478bd9Sstevel@tonic-gate 	    xdr_u_int(xdrs, &ps->transid) &&
2837c478bd9Sstevel@tonic-gate 	    xdr_u_int(xdrs, &ps->proto) &&
28461961e0fSrobinson 	    xdr_string(xdrs, &ps->name, 256)));
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate /*
2887c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypreq_xfr structure.
2897c478bd9Sstevel@tonic-gate  */
2907c478bd9Sstevel@tonic-gate bool
xdr_ypreq_xfr(XDR * xdrs,struct ypreq_xfr * ps)29161961e0fSrobinson xdr_ypreq_xfr(XDR *xdrs, struct ypreq_xfr *ps)
2927c478bd9Sstevel@tonic-gate {
29361961e0fSrobinson 	return ((bool)(xdr_ypmap_parms(xdrs, &ps->map_parms) &&
2947c478bd9Sstevel@tonic-gate 	    xdr_u_int(xdrs, &ps->transid) &&
2957c478bd9Sstevel@tonic-gate 	    xdr_u_int(xdrs, &ps->proto) &&
29661961e0fSrobinson 	    xdr_u_short(xdrs, &ps->port)));
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate /*
3017c478bd9Sstevel@tonic-gate  * Serializes/deserializes a stream of struct ypresp_key_val's.  This is used
3027c478bd9Sstevel@tonic-gate  * only by the client side of the batch enumerate operation.
3037c478bd9Sstevel@tonic-gate  */
3047c478bd9Sstevel@tonic-gate bool
xdr_ypall(XDR * xdrs,struct ypall_callback * callback)30561961e0fSrobinson xdr_ypall(XDR *xdrs, struct ypall_callback *callback)
3067c478bd9Sstevel@tonic-gate {
3077c478bd9Sstevel@tonic-gate 	bool_t more;
3087c478bd9Sstevel@tonic-gate 	struct ypresp_key_val kv;
3097c478bd9Sstevel@tonic-gate 	char keybuf[YPMAXRECORD];
3107c478bd9Sstevel@tonic-gate 	char valbuf[YPMAXRECORD];
3117c478bd9Sstevel@tonic-gate 
31261961e0fSrobinson 	if (xdrs->x_op == XDR_ENCODE)
3137c478bd9Sstevel@tonic-gate 		return (FALSE);
3147c478bd9Sstevel@tonic-gate 
31561961e0fSrobinson 	if (xdrs->x_op == XDR_FREE)
3167c478bd9Sstevel@tonic-gate 		return (TRUE);
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 	kv.keydat.dptr = keybuf;
3197c478bd9Sstevel@tonic-gate 	kv.valdat.dptr = valbuf;
3207c478bd9Sstevel@tonic-gate 	kv.keydat.dsize = YPMAXRECORD;
3217c478bd9Sstevel@tonic-gate 	kv.valdat.dsize = YPMAXRECORD;
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate 	for (;;) {
32461961e0fSrobinson 		if (!xdr_bool(xdrs, &more))
3257c478bd9Sstevel@tonic-gate 			return (FALSE);
3267c478bd9Sstevel@tonic-gate 
32761961e0fSrobinson 		if (!more)
3287c478bd9Sstevel@tonic-gate 			return (TRUE);
3297c478bd9Sstevel@tonic-gate 
33061961e0fSrobinson 		if (!xdr_ypresp_key_val(xdrs, &kv))
3317c478bd9Sstevel@tonic-gate 			return (FALSE);
33261961e0fSrobinson 		if ((*callback->foreach)(kv.status, kv.keydat.dptr,
33361961e0fSrobinson 			    kv.keydat.dsize, kv.valdat.dptr, kv.valdat.dsize,
33461961e0fSrobinson 			    callback->data))
33561961e0fSrobinson 			return (TRUE);
3367c478bd9Sstevel@tonic-gate 	}
3377c478bd9Sstevel@tonic-gate }
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate bool_t
xdr_netconfig(XDR * xdrs,struct netconfig * objp)34061961e0fSrobinson xdr_netconfig(XDR *xdrs, struct netconfig *objp)
3417c478bd9Sstevel@tonic-gate {
34261961e0fSrobinson 	if (!xdr_string(xdrs, &objp->nc_netid, ~0))
3437c478bd9Sstevel@tonic-gate 		return (FALSE);
34461961e0fSrobinson 	if (!xdr_u_int(xdrs, &objp->nc_semantics))
3457c478bd9Sstevel@tonic-gate 		return (FALSE);
34661961e0fSrobinson 	if (!xdr_u_int(xdrs, &objp->nc_flag))
3477c478bd9Sstevel@tonic-gate 		return (FALSE);
34861961e0fSrobinson 	if (!xdr_string(xdrs, &objp->nc_protofmly, ~0))
3497c478bd9Sstevel@tonic-gate 		return (FALSE);
35061961e0fSrobinson 	if (!xdr_string(xdrs, &objp->nc_proto, ~0))
3517c478bd9Sstevel@tonic-gate 		return (FALSE);
35261961e0fSrobinson 	if (!xdr_string(xdrs, &objp->nc_device, ~0))
3537c478bd9Sstevel@tonic-gate 		return (FALSE);
35461961e0fSrobinson 	if (!xdr_array(xdrs, (char **)&objp->nc_lookups,
35561961e0fSrobinson 		(uint_t *)&objp->nc_nlookups, 100, sizeof (char *),
35661961e0fSrobinson 		xdr_wrapstring))
3577c478bd9Sstevel@tonic-gate 		return (FALSE);
35861961e0fSrobinson 	return ((bool)xdr_vector(xdrs, (char *)objp->nc_unused,
35961961e0fSrobinson 		8, sizeof (uint_t), xdr_u_int));
3607c478bd9Sstevel@tonic-gate }
361