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