xref: /onnv-gate/usr/src/lib/libnsl/rpc/rpc_prot.c (revision 1219:f89f56c2d9ac)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
21132Srobinson  */
22132Srobinson 
23132Srobinson /*
24*1219Sraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate  * Use is subject to license terms.
260Sstevel@tonic-gate  */
27*1219Sraf 
280Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
290Sstevel@tonic-gate /* All Rights Reserved */
300Sstevel@tonic-gate /*
310Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
320Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
330Sstevel@tonic-gate  * California.
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * This set of routines implements the rpc message definition,
400Sstevel@tonic-gate  * its serializer and some common rpc utility routines.
410Sstevel@tonic-gate  * The routines are meant for various implementations of rpc -
420Sstevel@tonic-gate  * they are NOT for the rpc client or rpc service implementations!
430Sstevel@tonic-gate  * Because authentication stuff is easy and is part of rpc, the opaque
440Sstevel@tonic-gate  * routines are also in this program.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate 
47*1219Sraf #include "mt.h"
480Sstevel@tonic-gate #include <sys/param.h>
490Sstevel@tonic-gate #include <syslog.h>
500Sstevel@tonic-gate #include <rpc/rpc.h>
510Sstevel@tonic-gate #include <malloc.h>
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
540Sstevel@tonic-gate 
550Sstevel@tonic-gate struct opaque_auth _null_auth;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /*
580Sstevel@tonic-gate  * XDR an opaque authentication struct
590Sstevel@tonic-gate  * (see auth.h)
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate bool_t
xdr_opaque_auth(XDR * xdrs,struct opaque_auth * ap)62132Srobinson xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
630Sstevel@tonic-gate {
64132Srobinson 	if (xdr_enum(xdrs, &(ap->oa_flavor)))
65132Srobinson 		return (xdr_bytes(xdrs, &ap->oa_base,
66132Srobinson 			&ap->oa_length, MAX_AUTH_BYTES));
670Sstevel@tonic-gate 	return (FALSE);
680Sstevel@tonic-gate }
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * XDR a DES block
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate bool_t
xdr_des_block(XDR * xdrs,des_block * blkp)74132Srobinson xdr_des_block(XDR *xdrs, des_block *blkp)
750Sstevel@tonic-gate {
76132Srobinson 	return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof (des_block)));
770Sstevel@tonic-gate }
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
800Sstevel@tonic-gate 
810Sstevel@tonic-gate /*
820Sstevel@tonic-gate  * XDR the MSG_ACCEPTED part of a reply message union
830Sstevel@tonic-gate  */
840Sstevel@tonic-gate bool_t
xdr_accepted_reply(XDR * xdrs,struct accepted_reply * ar)85132Srobinson xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
860Sstevel@tonic-gate {
870Sstevel@tonic-gate 	/* personalized union, rather than calling xdr_union */
88132Srobinson 	if (!xdr_opaque_auth(xdrs, &(ar->ar_verf)))
890Sstevel@tonic-gate 		return (FALSE);
90132Srobinson 	if (!xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
910Sstevel@tonic-gate 		return (FALSE);
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 	switch (ar->ar_stat) {
940Sstevel@tonic-gate 	case SUCCESS:
95132Srobinson 		return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
960Sstevel@tonic-gate 	case PROG_MISMATCH:
97132Srobinson 		if (!xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.low)))
980Sstevel@tonic-gate 			return (FALSE);
99132Srobinson 		return (xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.high)));
1000Sstevel@tonic-gate 	}
1010Sstevel@tonic-gate 	return (TRUE);  /* TRUE => open ended set of problems */
1020Sstevel@tonic-gate }
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * XDR the MSG_DENIED part of a reply message union
1060Sstevel@tonic-gate  */
1070Sstevel@tonic-gate bool_t
xdr_rejected_reply(XDR * xdrs,struct rejected_reply * rr)108132Srobinson xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
1090Sstevel@tonic-gate {
1100Sstevel@tonic-gate 	/* personalized union, rather than calling xdr_union */
111132Srobinson 	if (!xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
1120Sstevel@tonic-gate 		return (FALSE);
1130Sstevel@tonic-gate 	switch (rr->rj_stat) {
1140Sstevel@tonic-gate 	case RPC_MISMATCH:
115132Srobinson 		if (!xdr_u_int(xdrs, (uint_t *)&(rr->rj_vers.low)))
1160Sstevel@tonic-gate 			return (FALSE);
117132Srobinson 		return (xdr_u_int(xdrs, (uint_t *)&(rr->rj_vers.high)));
1180Sstevel@tonic-gate 	case AUTH_ERROR:
119132Srobinson 		return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
1200Sstevel@tonic-gate 	}
1210Sstevel@tonic-gate 	return (FALSE);
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * XDR a reply message
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate bool_t
xdr_replymsg(XDR * xdrs,struct rpc_msg * rmsg)128132Srobinson xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
1290Sstevel@tonic-gate {
1300Sstevel@tonic-gate 	struct xdr_discrim reply_dscrm[3];
131132Srobinson 	rpc_inline_t *buf;
132132Srobinson 	struct accepted_reply *ar;
133132Srobinson 	struct opaque_auth *oa;
134132Srobinson 	uint_t rndup;
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE &&
1370Sstevel@tonic-gate 	    rmsg->rm_reply.rp_stat == MSG_ACCEPTED &&
1380Sstevel@tonic-gate 	    rmsg->rm_direction == REPLY &&
1390Sstevel@tonic-gate 	    (buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT + (rndup =
1400Sstevel@tonic-gate 		RNDUP(rmsg->rm_reply.rp_acpt.ar_verf.oa_length)))) != NULL) {
1410Sstevel@tonic-gate 		IXDR_PUT_INT32(buf, rmsg->rm_xid);
1420Sstevel@tonic-gate 		IXDR_PUT_ENUM(buf, rmsg->rm_direction);
1430Sstevel@tonic-gate 		IXDR_PUT_ENUM(buf, rmsg->rm_reply.rp_stat);
1440Sstevel@tonic-gate 		ar = &rmsg->rm_reply.rp_acpt;
1450Sstevel@tonic-gate 		oa = &ar->ar_verf;
1460Sstevel@tonic-gate 		IXDR_PUT_ENUM(buf, oa->oa_flavor);
1470Sstevel@tonic-gate 		IXDR_PUT_INT32(buf, oa->oa_length);
1480Sstevel@tonic-gate 		if (oa->oa_length) {
149132Srobinson 			(void) memcpy(buf, oa->oa_base, oa->oa_length);
1500Sstevel@tonic-gate /* LINTED pointer alignment */
1510Sstevel@tonic-gate 			buf = (rpc_inline_t *)(((caddr_t)buf) + oa->oa_length);
1520Sstevel@tonic-gate 		}
1530Sstevel@tonic-gate 		if ((rndup = (rndup - oa->oa_length)) > 0) {
1540Sstevel@tonic-gate 			(void) memset((caddr_t)buf, 0, rndup);
1550Sstevel@tonic-gate /* LINTED pointer alignment */
1560Sstevel@tonic-gate 			buf = (rpc_inline_t *)(((caddr_t)buf) + rndup);
1570Sstevel@tonic-gate 		}
1580Sstevel@tonic-gate 		/*
1590Sstevel@tonic-gate 		 * stat and rest of reply, copied from xdr_accepted_reply
1600Sstevel@tonic-gate 		 */
1610Sstevel@tonic-gate 		IXDR_PUT_ENUM(buf, ar->ar_stat);
1620Sstevel@tonic-gate 		switch (ar->ar_stat) {
1630Sstevel@tonic-gate 		case SUCCESS:
164132Srobinson 			return ((*(ar->ar_results.proc))
165132Srobinson 				(xdrs, ar->ar_results.where));
1660Sstevel@tonic-gate 		case PROG_MISMATCH:
167132Srobinson 			if (!xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.low)))
1680Sstevel@tonic-gate 				return (FALSE);
169132Srobinson 			return (xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.high)));
1700Sstevel@tonic-gate 		}
1710Sstevel@tonic-gate 		return (TRUE);
1720Sstevel@tonic-gate 	}
1730Sstevel@tonic-gate 	if (xdrs->x_op == XDR_DECODE &&
1740Sstevel@tonic-gate 	    (buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT)) != NULL) {
1750Sstevel@tonic-gate 		rmsg->rm_xid = IXDR_GET_INT32(buf);
1760Sstevel@tonic-gate 		rmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
177132Srobinson 		if (rmsg->rm_direction != REPLY)
1780Sstevel@tonic-gate 			return (FALSE);
1790Sstevel@tonic-gate 		rmsg->rm_reply.rp_stat = IXDR_GET_ENUM(buf, enum reply_stat);
1800Sstevel@tonic-gate 		if (rmsg->rm_reply.rp_stat != MSG_ACCEPTED) {
181132Srobinson 			if (rmsg->rm_reply.rp_stat == MSG_DENIED)
182132Srobinson 				return (xdr_rejected_reply(xdrs,
183132Srobinson 					&rmsg->rm_reply.rp_rjct));
1840Sstevel@tonic-gate 			return (FALSE);
1850Sstevel@tonic-gate 		}
1860Sstevel@tonic-gate 		ar = &rmsg->rm_reply.rp_acpt;
1870Sstevel@tonic-gate 		oa = &ar->ar_verf;
1880Sstevel@tonic-gate 		buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
1890Sstevel@tonic-gate 		if (buf != NULL) {
1900Sstevel@tonic-gate 			oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
1910Sstevel@tonic-gate 			oa->oa_length = IXDR_GET_INT32(buf);
1920Sstevel@tonic-gate 		} else {
1930Sstevel@tonic-gate 			if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
194132Srobinson 			    xdr_u_int(xdrs, &oa->oa_length) == FALSE)
1950Sstevel@tonic-gate 				return (FALSE);
1960Sstevel@tonic-gate 		}
1970Sstevel@tonic-gate 		if (oa->oa_length) {
198132Srobinson 			if (oa->oa_length > MAX_AUTH_BYTES)
1990Sstevel@tonic-gate 				return (FALSE);
2000Sstevel@tonic-gate 			if (oa->oa_base == NULL) {
201132Srobinson 				oa->oa_base = malloc(oa->oa_length);
2020Sstevel@tonic-gate 				if (oa->oa_base == NULL) {
2030Sstevel@tonic-gate 					syslog(LOG_ERR,
2040Sstevel@tonic-gate 						"xdr_replymsg : "
2050Sstevel@tonic-gate 						"out of memory.");
2060Sstevel@tonic-gate 					rpc_callerr.re_status = RPC_SYSTEMERROR;
2070Sstevel@tonic-gate 					return (FALSE);
2080Sstevel@tonic-gate 				}
2090Sstevel@tonic-gate 			}
2100Sstevel@tonic-gate 			buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
2110Sstevel@tonic-gate 			if (buf == NULL) {
2120Sstevel@tonic-gate 				if (xdr_opaque(xdrs, oa->oa_base,
213132Srobinson 				    oa->oa_length) == FALSE)
2140Sstevel@tonic-gate 					return (FALSE);
2150Sstevel@tonic-gate 			} else {
216132Srobinson 				(void) memcpy(oa->oa_base, buf, oa->oa_length);
2170Sstevel@tonic-gate 			}
2180Sstevel@tonic-gate 		}
2190Sstevel@tonic-gate 		/*
2200Sstevel@tonic-gate 		 * stat and rest of reply, copied from
2210Sstevel@tonic-gate 		 * xdr_accepted_reply
2220Sstevel@tonic-gate 		 */
223132Srobinson 		if (!xdr_enum(xdrs, (enum_t *)&ar->ar_stat))
2240Sstevel@tonic-gate 			return (FALSE);
2250Sstevel@tonic-gate 		switch (ar->ar_stat) {
2260Sstevel@tonic-gate 		case SUCCESS:
227132Srobinson 			return ((*(ar->ar_results.proc))
228132Srobinson 				(xdrs, ar->ar_results.where));
2290Sstevel@tonic-gate 		case PROG_MISMATCH:
230132Srobinson 			if (!xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.low)))
2310Sstevel@tonic-gate 				return (FALSE);
232132Srobinson 			return (xdr_u_int(xdrs, (uint_t *)&(ar->ar_vers.high)));
2330Sstevel@tonic-gate 		}
2340Sstevel@tonic-gate 		return (TRUE);
2350Sstevel@tonic-gate 	}
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate 	reply_dscrm[0].value = (int)MSG_ACCEPTED;
238132Srobinson 	reply_dscrm[0].proc = (xdrproc_t)xdr_accepted_reply;
2390Sstevel@tonic-gate 	reply_dscrm[1].value = (int)MSG_DENIED;
240132Srobinson 	reply_dscrm[1].proc =  (xdrproc_t)xdr_rejected_reply;
2410Sstevel@tonic-gate 	reply_dscrm[2].value = __dontcare__;
2420Sstevel@tonic-gate 	reply_dscrm[2].proc = NULL_xdrproc_t;
2430Sstevel@tonic-gate 	if (xdr_u_int(xdrs, &(rmsg->rm_xid)) &&
2440Sstevel@tonic-gate 	    xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
245132Srobinson 	    (rmsg->rm_direction == REPLY))
246132Srobinson 		return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
2470Sstevel@tonic-gate 				(caddr_t)&(rmsg->rm_reply.ru),
248132Srobinson 				reply_dscrm, NULL_xdrproc_t));
2490Sstevel@tonic-gate 	return (FALSE);
2500Sstevel@tonic-gate }
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate /*
2530Sstevel@tonic-gate  * Serializes the "static part" of a call message header.
2540Sstevel@tonic-gate  * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
2550Sstevel@tonic-gate  * The rm_xid is not really static, but the user can easily munge on the fly.
2560Sstevel@tonic-gate  */
2570Sstevel@tonic-gate bool_t
xdr_callhdr(XDR * xdrs,struct rpc_msg * cmsg)258132Srobinson xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
2590Sstevel@tonic-gate {
2600Sstevel@tonic-gate 	cmsg->rm_direction = CALL;
2610Sstevel@tonic-gate 	cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
2620Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE &&
2630Sstevel@tonic-gate 	    xdr_u_int(xdrs, &(cmsg->rm_xid)) &&
2640Sstevel@tonic-gate 	    xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
265132Srobinson 	    xdr_u_int(xdrs, (uint_t *)&(cmsg->rm_call.cb_rpcvers)) &&
266132Srobinson 	    xdr_u_int(xdrs, (uint_t *)&(cmsg->rm_call.cb_prog))) {
267132Srobinson 	    return (xdr_u_int(xdrs, (uint_t *)&(cmsg->rm_call.cb_vers)));
2680Sstevel@tonic-gate 	}
2690Sstevel@tonic-gate 	return (FALSE);
2700Sstevel@tonic-gate }
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate /* ************************** Client utility routine ************* */
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate static void
accepted(enum accept_stat acpt_stat,struct rpc_err * error)275132Srobinson accepted(enum accept_stat acpt_stat, struct rpc_err *error)
2760Sstevel@tonic-gate {
2770Sstevel@tonic-gate 	switch (acpt_stat) {
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 	case PROG_UNAVAIL:
2800Sstevel@tonic-gate 		error->re_status = RPC_PROGUNAVAIL;
2810Sstevel@tonic-gate 		return;
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate 	case PROG_MISMATCH:
2840Sstevel@tonic-gate 		error->re_status = RPC_PROGVERSMISMATCH;
2850Sstevel@tonic-gate 		return;
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate 	case PROC_UNAVAIL:
2880Sstevel@tonic-gate 		error->re_status = RPC_PROCUNAVAIL;
2890Sstevel@tonic-gate 		return;
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate 	case GARBAGE_ARGS:
2920Sstevel@tonic-gate 		error->re_status = RPC_CANTDECODEARGS;
2930Sstevel@tonic-gate 		return;
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 	case SYSTEM_ERR:
2960Sstevel@tonic-gate 		error->re_status = RPC_SYSTEMERROR;
2970Sstevel@tonic-gate 		return;
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate 	case SUCCESS:
3000Sstevel@tonic-gate 		error->re_status = RPC_SUCCESS;
3010Sstevel@tonic-gate 		return;
3020Sstevel@tonic-gate 	}
3030Sstevel@tonic-gate 	/* something's wrong, but we don't know what ... */
3040Sstevel@tonic-gate 	error->re_status = RPC_FAILED;
3050Sstevel@tonic-gate 	error->re_lb.s1 = (int32_t)MSG_ACCEPTED;
3060Sstevel@tonic-gate 	error->re_lb.s2 = (int32_t)acpt_stat;
3070Sstevel@tonic-gate }
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate static void
rejected(enum reject_stat rjct_stat,struct rpc_err * error)310132Srobinson rejected(enum reject_stat rjct_stat, struct rpc_err *error)
3110Sstevel@tonic-gate {
3120Sstevel@tonic-gate 	switch (rjct_stat) {
3130Sstevel@tonic-gate 	case RPC_MISMATCH:
3140Sstevel@tonic-gate 		error->re_status = RPC_VERSMISMATCH;
3150Sstevel@tonic-gate 		return;
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate 	case AUTH_ERROR:
3180Sstevel@tonic-gate 		error->re_status = RPC_AUTHERROR;
3190Sstevel@tonic-gate 		return;
3200Sstevel@tonic-gate 	}
3210Sstevel@tonic-gate 	/* something's wrong, but we don't know what ... */
3220Sstevel@tonic-gate 	error->re_status = RPC_FAILED;
3230Sstevel@tonic-gate 	error->re_lb.s1 = (int32_t)MSG_DENIED;
3240Sstevel@tonic-gate 	error->re_lb.s2 = (int32_t)rjct_stat;
3250Sstevel@tonic-gate }
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate /*
3280Sstevel@tonic-gate  * given a reply message, fills in the error
3290Sstevel@tonic-gate  */
3300Sstevel@tonic-gate void
__seterr_reply(struct rpc_msg * msg,struct rpc_err * error)331132Srobinson __seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
3320Sstevel@tonic-gate {
3330Sstevel@tonic-gate 	/* optimized for normal, SUCCESSful case */
3340Sstevel@tonic-gate 	switch (msg->rm_reply.rp_stat) {
3350Sstevel@tonic-gate 	case MSG_ACCEPTED:
3360Sstevel@tonic-gate 		if (msg->acpted_rply.ar_stat == SUCCESS) {
3370Sstevel@tonic-gate 			error->re_status = RPC_SUCCESS;
3380Sstevel@tonic-gate 			return;
3390Sstevel@tonic-gate 		};
3400Sstevel@tonic-gate 		accepted(msg->acpted_rply.ar_stat, error);
3410Sstevel@tonic-gate 		break;
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate 	case MSG_DENIED:
3440Sstevel@tonic-gate 		rejected(msg->rjcted_rply.rj_stat, error);
3450Sstevel@tonic-gate 		break;
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	default:
3480Sstevel@tonic-gate 		error->re_status = RPC_FAILED;
3490Sstevel@tonic-gate 		error->re_lb.s1 = (int32_t)(msg->rm_reply.rp_stat);
3500Sstevel@tonic-gate 		break;
3510Sstevel@tonic-gate 	}
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate 	switch (error->re_status) {
3540Sstevel@tonic-gate 	case RPC_VERSMISMATCH:
3550Sstevel@tonic-gate 		error->re_vers.low = msg->rjcted_rply.rj_vers.low;
3560Sstevel@tonic-gate 		error->re_vers.high = msg->rjcted_rply.rj_vers.high;
3570Sstevel@tonic-gate 		break;
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate 	case RPC_AUTHERROR:
3600Sstevel@tonic-gate 		error->re_why = msg->rjcted_rply.rj_why;
3610Sstevel@tonic-gate 		break;
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate 	case RPC_PROGVERSMISMATCH:
3640Sstevel@tonic-gate 		error->re_vers.low = msg->acpted_rply.ar_vers.low;
3650Sstevel@tonic-gate 		error->re_vers.high = msg->acpted_rply.ar_vers.high;
3660Sstevel@tonic-gate 		break;
3670Sstevel@tonic-gate 	}
3680Sstevel@tonic-gate }
369