xref: /illumos-gate/usr/src/cmd/fs.d/nfs/mountd/nfsauth_xdr.c (revision 5cb0d67909d9970a3e7adbea9422ca3fc88000bf)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
27  */
28 
29 #include <stdlib.h>
30 #include <nfs/auth.h>
31 
32 bool_t
33 xdr_varg(XDR *xdrs, varg_t *vap)
34 {
35 	if (!xdr_u_int(xdrs, &vap->vers))
36 		return (FALSE);
37 
38 	switch (vap->vers) {
39 	case V_PROTO:
40 		if (!xdr_nfsauth_arg(xdrs, &vap->arg_u.arg))
41 			return (FALSE);
42 		break;
43 
44 	/* Additional versions of the args go here */
45 
46 	default:
47 		vap->vers = V_ERROR;
48 		return (FALSE);
49 		/* NOTREACHED */
50 	}
51 	return (TRUE);
52 }
53 
54 bool_t
55 xdr_nfsauth_arg(XDR *xdrs, nfsauth_arg_t *argp)
56 {
57 	if (!xdr_u_int(xdrs, &argp->cmd))
58 		return (FALSE);
59 	if (!xdr_netobj(xdrs, &argp->areq.req_client))
60 		return (FALSE);
61 	if (!xdr_string(xdrs, &argp->areq.req_netid, ~0))
62 		return (FALSE);
63 	if (!xdr_string(xdrs, &argp->areq.req_path, A_MAXPATH))
64 		return (FALSE);
65 	if (!xdr_int(xdrs, &argp->areq.req_flavor))
66 		return (FALSE);
67 	if (!xdr_u_int(xdrs, &argp->areq.req_clnt_uid))
68 		return (FALSE);
69 	if (!xdr_u_int(xdrs, &argp->areq.req_clnt_gid))
70 		return (FALSE);
71 	return (TRUE);
72 }
73 
74 bool_t
75 xdr_nfsauth_res(XDR *xdrs, nfsauth_res_t *argp)
76 {
77 	if (!xdr_u_int(xdrs, &argp->stat))
78 		return (FALSE);
79 	if (!xdr_int(xdrs, &argp->ares.auth_perm))
80 		return (FALSE);
81 	if (!xdr_u_int(xdrs, &argp->ares.auth_srv_uid))
82 		return (FALSE);
83 	if (!xdr_u_int(xdrs, &argp->ares.auth_srv_gid))
84 		return (FALSE);
85 	return (TRUE);
86 }
87