xref: /illumos-gate/usr/src/cmd/ypcmd/ypv1_xdr.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"
23*7c478bd9Sstevel@tonic-gate /*
24*7c478bd9Sstevel@tonic-gate  *    Copyright (c) 1995  Sun Microsystems, Inc
25*7c478bd9Sstevel@tonic-gate  *      All rights reserved.
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * This contains the xdr functions needed by ypserv and the NIS
30*7c478bd9Sstevel@tonic-gate  * administrative tools to support the previous version of the NIS protocol.
31*7c478bd9Sstevel@tonic-gate  * Note that many "old" xdr functions are called, with the assumption that
32*7c478bd9Sstevel@tonic-gate  * they have not changed between the v1 protocol (which this module exists
33*7c478bd9Sstevel@tonic-gate  * to support) and the current v2 protocol.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #define	NULL 0
37*7c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
38*7c478bd9Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
39*7c478bd9Sstevel@tonic-gate #include "ypv1_prot.h"
40*7c478bd9Sstevel@tonic-gate #include <rpcsvc/ypclnt.h>
41*7c478bd9Sstevel@tonic-gate typedef struct xdr_discrim XDR_DISCRIM;
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate extern bool xdr_ypreq_key();
44*7c478bd9Sstevel@tonic-gate extern bool xdr_ypreq_nokey();
45*7c478bd9Sstevel@tonic-gate extern bool xdr_ypresp_val();
46*7c478bd9Sstevel@tonic-gate extern bool xdr_ypresp_key_val();
47*7c478bd9Sstevel@tonic-gate extern bool xdr_ypmap_parms();
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate /*
51*7c478bd9Sstevel@tonic-gate  * Serializes/deserializes a yprequest structure.
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate bool
_xdr_yprequest(XDR * xdrs,struct yprequest * ps)54*7c478bd9Sstevel@tonic-gate _xdr_yprequest(XDR *xdrs, struct yprequest *ps)
55*7c478bd9Sstevel@tonic-gate {
56*7c478bd9Sstevel@tonic-gate 	XDR_DISCRIM yprequest_arms[4];
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate 	yprequest_arms[0].value = (int)YPREQ_KEY;
59*7c478bd9Sstevel@tonic-gate 	yprequest_arms[1].value = (int)YPREQ_NOKEY;
60*7c478bd9Sstevel@tonic-gate 	yprequest_arms[2].value = (int)YPREQ_KEY;
61*7c478bd9Sstevel@tonic-gate 	yprequest_arms[3].value = __dontcare__;
62*7c478bd9Sstevel@tonic-gate 	yprequest_arms[0].proc = (xdrproc_t)xdr_ypreq_key;
63*7c478bd9Sstevel@tonic-gate 	yprequest_arms[1].proc = (xdrproc_t)xdr_ypreq_nokey;
64*7c478bd9Sstevel@tonic-gate 	yprequest_arms[2].proc = (xdrproc_t)xdr_ypmap_parms;
65*7c478bd9Sstevel@tonic-gate 	yprequest_arms[3].proc = (xdrproc_t)NULL;
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate 	return (xdr_union(xdrs,
68*7c478bd9Sstevel@tonic-gate 				(int *) &ps->yp_reqtype,
69*7c478bd9Sstevel@tonic-gate 				(char *) &ps->yp_reqbody,
70*7c478bd9Sstevel@tonic-gate 				yprequest_arms, NULL));
71*7c478bd9Sstevel@tonic-gate }
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypresponse structure.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate bool
_xdr_ypresponse(XDR * xdrs,struct ypresponse * ps)77*7c478bd9Sstevel@tonic-gate _xdr_ypresponse(XDR *xdrs, struct ypresponse *ps)
78*7c478bd9Sstevel@tonic-gate {
79*7c478bd9Sstevel@tonic-gate 	XDR_DISCRIM ypresponse_arms[4];
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[0].value = (int)YPRESP_VAL;
82*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[1].value = (int)YPRESP_KEY_VAL;
83*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[2].value = (int)YPRESP_MAP_PARMS;
84*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[3].value = __dontcare__;
85*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[0].proc = (xdrproc_t)xdr_ypresp_val;
86*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[1].proc = (xdrproc_t)xdr_ypresp_key_val;
87*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[2].proc = (xdrproc_t)xdr_ypmap_parms;
88*7c478bd9Sstevel@tonic-gate 	ypresponse_arms[3].proc = (xdrproc_t)NULL;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate 	return (xdr_union(xdrs,
91*7c478bd9Sstevel@tonic-gate 				(int *) &ps->yp_resptype,
92*7c478bd9Sstevel@tonic-gate 				(char *) &ps->yp_respbody,
93*7c478bd9Sstevel@tonic-gate 				ypresponse_arms, NULL));
94*7c478bd9Sstevel@tonic-gate }
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /* XXX - Excess baggage? - georgn */
97*7c478bd9Sstevel@tonic-gate #if	0
98*7c478bd9Sstevel@tonic-gate /*
99*7c478bd9Sstevel@tonic-gate  * Serializes/deserializes a ypbind_oldsetdom structure.
100*7c478bd9Sstevel@tonic-gate  */
101*7c478bd9Sstevel@tonic-gate bool
102*7c478bd9Sstevel@tonic-gate _xdr_ypbind_oldsetdom(XDR *xdrs, struct ypbind_setdom *ps)
103*7c478bd9Sstevel@tonic-gate {
104*7c478bd9Sstevel@tonic-gate 	char *domain = ps->ypsetdom_domain;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 	return (xdr_ypdomain_wrap_string(xdrs, &domain) &&
107*7c478bd9Sstevel@tonic-gate 		xdr_yp_binding(xdrs, &ps->ypsetdom_binding));
108*7c478bd9Sstevel@tonic-gate }
109*7c478bd9Sstevel@tonic-gate #endif
110