11cc55349Srmesta /*
21cc55349Srmesta  * CDDL HEADER START
31cc55349Srmesta  *
41cc55349Srmesta  * The contents of this file are subject to the terms of the
51cc55349Srmesta  * Common Development and Distribution License (the "License").
61cc55349Srmesta  * You may not use this file except in compliance with the License.
71cc55349Srmesta  *
81cc55349Srmesta  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91cc55349Srmesta  * or http://www.opensolaris.org/os/licensing.
101cc55349Srmesta  * See the License for the specific language governing permissions
111cc55349Srmesta  * and limitations under the License.
121cc55349Srmesta  *
131cc55349Srmesta  * When distributing Covered Code, include this CDDL HEADER in each
141cc55349Srmesta  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151cc55349Srmesta  * If applicable, add the following below this CDDL HEADER, with the
161cc55349Srmesta  * fields enclosed by brackets "[]" replaced with your own identifying
171cc55349Srmesta  * information: Portions Copyright [yyyy] [name of copyright owner]
181cc55349Srmesta  *
191cc55349Srmesta  * CDDL HEADER END
201cc55349Srmesta  */
21a05fd0c9SMarcel Telka 
221cc55349Srmesta /*
23a05fd0c9SMarcel Telka  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
241cc55349Srmesta  */
25a05fd0c9SMarcel Telka 
265cb0d679SMarcel Telka /*
27a05fd0c9SMarcel Telka  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
28a05fd0c9SMarcel Telka  * Use is subject to license terms.
295cb0d679SMarcel Telka  */
301cc55349Srmesta 
311cc55349Srmesta #include <nfs/auth.h>
32a05fd0c9SMarcel Telka #include <rpc/auth_sys.h>
331cc55349Srmesta 
341cc55349Srmesta bool_t
xdr_varg(XDR * xdrs,varg_t * vap)351cc55349Srmesta xdr_varg(XDR *xdrs, varg_t *vap)
361cc55349Srmesta {
371cc55349Srmesta 	if (!xdr_u_int(xdrs, &vap->vers))
381cc55349Srmesta 		return (FALSE);
391cc55349Srmesta 
401cc55349Srmesta 	switch (vap->vers) {
411cc55349Srmesta 	case V_PROTO:
421cc55349Srmesta 		if (!xdr_nfsauth_arg(xdrs, &vap->arg_u.arg))
431cc55349Srmesta 			return (FALSE);
441cc55349Srmesta 		break;
451cc55349Srmesta 
461cc55349Srmesta 		/* Additional versions of the args go here */
471cc55349Srmesta 
481cc55349Srmesta 	default:
491cc55349Srmesta 		vap->vers = V_ERROR;
501cc55349Srmesta 		return (FALSE);
511cc55349Srmesta 		/* NOTREACHED */
521cc55349Srmesta 	}
531cc55349Srmesta 	return (TRUE);
541cc55349Srmesta }
551cc55349Srmesta 
561cc55349Srmesta bool_t
xdr_nfsauth_arg(XDR * xdrs,nfsauth_arg_t * argp)571cc55349Srmesta xdr_nfsauth_arg(XDR *xdrs, nfsauth_arg_t *argp)
581cc55349Srmesta {
591cc55349Srmesta 	if (!xdr_u_int(xdrs, &argp->cmd))
601cc55349Srmesta 		return (FALSE);
611cc55349Srmesta 	if (!xdr_netobj(xdrs, &argp->areq.req_client))
621cc55349Srmesta 		return (FALSE);
631cc55349Srmesta 	if (!xdr_string(xdrs, &argp->areq.req_netid, ~0))
641cc55349Srmesta 		return (FALSE);
651cc55349Srmesta 	if (!xdr_string(xdrs, &argp->areq.req_path, A_MAXPATH))
661cc55349Srmesta 		return (FALSE);
671cc55349Srmesta 	if (!xdr_int(xdrs, &argp->areq.req_flavor))
681cc55349Srmesta 		return (FALSE);
69a05fd0c9SMarcel Telka 	if (!xdr_uid_t(xdrs, &argp->areq.req_clnt_uid))
705cb0d679SMarcel Telka 		return (FALSE);
71a05fd0c9SMarcel Telka 	if (!xdr_gid_t(xdrs, &argp->areq.req_clnt_gid))
725cb0d679SMarcel Telka 		return (FALSE);
73*89621fe1SMarcel Telka 	if (!xdr_array(xdrs, (caddr_t *)&argp->areq.req_clnt_gids.val,
74*89621fe1SMarcel Telka 	    &argp->areq.req_clnt_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
75*89621fe1SMarcel Telka 	    xdr_gid_t))
76*89621fe1SMarcel Telka 		return (FALSE);
771cc55349Srmesta 	return (TRUE);
781cc55349Srmesta }
791cc55349Srmesta 
801cc55349Srmesta bool_t
xdr_nfsauth_res(XDR * xdrs,nfsauth_res_t * argp)811cc55349Srmesta xdr_nfsauth_res(XDR *xdrs, nfsauth_res_t *argp)
821cc55349Srmesta {
831cc55349Srmesta 	if (!xdr_u_int(xdrs, &argp->stat))
841cc55349Srmesta 		return (FALSE);
851cc55349Srmesta 	if (!xdr_int(xdrs, &argp->ares.auth_perm))
861cc55349Srmesta 		return (FALSE);
87a05fd0c9SMarcel Telka 	if (!xdr_uid_t(xdrs, &argp->ares.auth_srv_uid))
885cb0d679SMarcel Telka 		return (FALSE);
89a05fd0c9SMarcel Telka 	if (!xdr_gid_t(xdrs, &argp->ares.auth_srv_gid))
905cb0d679SMarcel Telka 		return (FALSE);
91*89621fe1SMarcel Telka 	if (!xdr_array(xdrs, (caddr_t *)&argp->ares.auth_srv_gids.val,
92*89621fe1SMarcel Telka 	    &argp->ares.auth_srv_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
93*89621fe1SMarcel Telka 	    xdr_gid_t))
94*89621fe1SMarcel Telka 		return (FALSE);
951cc55349Srmesta 	return (TRUE);
961cc55349Srmesta }
97