xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c (revision 410:51e39f6c6311)
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
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*410Skcpoon  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/errno.h>
310Sstevel@tonic-gate #include <setjmp.h>
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <netinet/in.h>
340Sstevel@tonic-gate #include <netdb.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/tiuser.h>
370Sstevel@tonic-gate #include <rpc/types.h>
380Sstevel@tonic-gate #include <rpc/xdr.h>
390Sstevel@tonic-gate #include <rpc/auth.h>
400Sstevel@tonic-gate #include <rpc/auth_unix.h>
410Sstevel@tonic-gate #include <rpc/auth_des.h>
420Sstevel@tonic-gate #include <rpc/clnt.h>
430Sstevel@tonic-gate #include <rpc/rpc_msg.h>
440Sstevel@tonic-gate #include <rpc/pmap_clnt.h>
450Sstevel@tonic-gate #include <rpc/svc.h>
460Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
470Sstevel@tonic-gate #include <rpc/pmap_prot.h>
480Sstevel@tonic-gate #include "snoop.h"
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #ifndef MIN
510Sstevel@tonic-gate #define	MIN(a, b) ((a) < (b) ? (a) : (b))
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate int pos;
550Sstevel@tonic-gate struct cache_struct *find_xid();
560Sstevel@tonic-gate extern jmp_buf xdr_err;
570Sstevel@tonic-gate void protoprint();
580Sstevel@tonic-gate void print_rpcsec_gss_cred(int xid, int authlen);
590Sstevel@tonic-gate char *nameof_prog();
600Sstevel@tonic-gate char *nameof_astat();
610Sstevel@tonic-gate char *nameof_why();
62*410Skcpoon static void rpc_detail_call(int, int, int, int, int, int, char *, int);
63*410Skcpoon static void rpc_detail_reply(int, int, struct cache_struct *, char *, int len);
64*410Skcpoon static void print_creds(int);
65*410Skcpoon static void print_verif(int);
66*410Skcpoon static void stash_xid(ulong_t, int, int, int, int);
67*410Skcpoon int valid_rpc(char *, int);
680Sstevel@tonic-gate 
690Sstevel@tonic-gate #define	LAST_FRAG ((ulong_t)1 << 31)
700Sstevel@tonic-gate 
71*410Skcpoon int
72*410Skcpoon interpret_rpc(int flags, char *rpc, int fraglen, int type)
730Sstevel@tonic-gate {
740Sstevel@tonic-gate 	ulong_t xid;
750Sstevel@tonic-gate 	int direction;
760Sstevel@tonic-gate 	struct cache_struct *x;
770Sstevel@tonic-gate 	int rpcvers, prog, vers, proc;
780Sstevel@tonic-gate 	int status, astat, rstat, why;
790Sstevel@tonic-gate 	char *lp;
800Sstevel@tonic-gate 	unsigned recmark;
810Sstevel@tonic-gate 	int markpos;
820Sstevel@tonic-gate 	extern int pi_frame;
830Sstevel@tonic-gate 	int lo, hi;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	xdr_init(rpc, fraglen);
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	if (setjmp(xdr_err)) {
880Sstevel@tonic-gate 		if (flags & F_DTAIL)
890Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0),
900Sstevel@tonic-gate 				"----  short frame ---");
910Sstevel@tonic-gate 		return (fraglen);
920Sstevel@tonic-gate 	}
930Sstevel@tonic-gate 
940Sstevel@tonic-gate 	if (type == IPPROTO_TCP) {	/* record mark */
950Sstevel@tonic-gate 		markpos = getxdr_pos();
960Sstevel@tonic-gate 		recmark = getxdr_long();
970Sstevel@tonic-gate 	}
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	xid	  = getxdr_u_long();
1000Sstevel@tonic-gate 	direction = getxdr_long();
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	if (direction == CALL) {
1030Sstevel@tonic-gate 		rpcvers = getxdr_long();
1040Sstevel@tonic-gate 		pos = getxdr_pos();
1050Sstevel@tonic-gate 		prog = getxdr_long();
1060Sstevel@tonic-gate 		vers = getxdr_long();
1070Sstevel@tonic-gate 		proc = getxdr_long();
1080Sstevel@tonic-gate 		stash_xid(xid, pi_frame, prog, vers, proc);
1090Sstevel@tonic-gate 		if (!(flags & (F_SUM | F_DTAIL)))
1100Sstevel@tonic-gate 			protoprint(flags, CALL, xid, prog, vers, proc,
1110Sstevel@tonic-gate 				rpc, fraglen);
1120Sstevel@tonic-gate 	} else {
1130Sstevel@tonic-gate 		x = find_xid(xid);
1140Sstevel@tonic-gate 	}
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate 	if (flags & F_SUM) {
1170Sstevel@tonic-gate 		switch (direction) {
1180Sstevel@tonic-gate 		case CALL:
1190Sstevel@tonic-gate 			(void) sprintf(get_sum_line(),
1200Sstevel@tonic-gate 				"RPC C XID=%lu PROG=%d (%s) VERS=%d PROC=%d",
1210Sstevel@tonic-gate 				xid,
1220Sstevel@tonic-gate 				prog, nameof_prog(prog),
1230Sstevel@tonic-gate 				vers, proc);
1240Sstevel@tonic-gate 			if (getxdr_long() == RPCSEC_GSS) { /* Cred auth type */
1250Sstevel@tonic-gate 				extract_rpcsec_gss_cred_info(xid);
1260Sstevel@tonic-gate 				/* RPCSEC_GSS cred auth data */
1270Sstevel@tonic-gate 			} else {
1280Sstevel@tonic-gate 				xdr_skip(getxdr_long());
1290Sstevel@tonic-gate 				/* non RPCSEC_GSS cred auth data */
1300Sstevel@tonic-gate 			}
1310Sstevel@tonic-gate 			xdr_skip(4);			/* Verf auth type */
1320Sstevel@tonic-gate 			xdr_skip(RNDUP(getxdr_long()));	/* Verf auth data */
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 			protoprint(flags, CALL, xid, prog, vers, proc,
1350Sstevel@tonic-gate 				rpc, fraglen);
1360Sstevel@tonic-gate 			break;
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate 		case REPLY:
1390Sstevel@tonic-gate 			lp = get_sum_line();
1400Sstevel@tonic-gate 			if (x == NULL)
1410Sstevel@tonic-gate 				(void) sprintf(lp, "RPC R XID=%lu", xid);
1420Sstevel@tonic-gate 			else
1430Sstevel@tonic-gate 				(void) sprintf(lp, "RPC R (#%d) XID=%lu",
1440Sstevel@tonic-gate 					x->xid_frame, xid);
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate 			lp += strlen(lp);
1470Sstevel@tonic-gate 			status = getxdr_long();
1480Sstevel@tonic-gate 			switch (status) {
1490Sstevel@tonic-gate 			case MSG_ACCEPTED:
1500Sstevel@tonic-gate 				/* eat flavor and verifier */
1510Sstevel@tonic-gate 				(void) getxdr_long();
1520Sstevel@tonic-gate 				xdr_skip(RNDUP(getxdr_long()));
1530Sstevel@tonic-gate 				astat = getxdr_long();
1540Sstevel@tonic-gate 				(void) sprintf(lp, " %s",
1550Sstevel@tonic-gate 					nameof_astat(astat));
1560Sstevel@tonic-gate 				lp += strlen(lp);
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate 				switch (astat) {
1590Sstevel@tonic-gate 				case SUCCESS:
1600Sstevel@tonic-gate 					if (x) {
1610Sstevel@tonic-gate 						protoprint(flags, REPLY,
1620Sstevel@tonic-gate 							xid,
1630Sstevel@tonic-gate 							x->xid_prog,
1640Sstevel@tonic-gate 							x->xid_vers,
1650Sstevel@tonic-gate 							x->xid_proc,
1660Sstevel@tonic-gate 							rpc, fraglen);
1670Sstevel@tonic-gate 					}
1680Sstevel@tonic-gate 					break;
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate 				case PROG_UNAVAIL :
1710Sstevel@tonic-gate 				case PROG_MISMATCH:
1720Sstevel@tonic-gate 				case PROC_UNAVAIL :
1730Sstevel@tonic-gate 					lo = getxdr_long();
1740Sstevel@tonic-gate 					hi = getxdr_long();
1750Sstevel@tonic-gate 					(void) sprintf(lp,
1760Sstevel@tonic-gate 						" (low=%d, high=%d)",
1770Sstevel@tonic-gate 						lo, hi);
1780Sstevel@tonic-gate 					break;
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 				case GARBAGE_ARGS:
1810Sstevel@tonic-gate 				case SYSTEM_ERR:
1820Sstevel@tonic-gate 				default:
1830Sstevel@tonic-gate 					;
1840Sstevel@tonic-gate 				}
1850Sstevel@tonic-gate 				break;
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate 			case MSG_DENIED:
1880Sstevel@tonic-gate 				rstat = getxdr_long();
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 				switch (rstat) {
1910Sstevel@tonic-gate 				case RPC_MISMATCH:
1920Sstevel@tonic-gate 					lo = getxdr_long();
1930Sstevel@tonic-gate 					hi = getxdr_long();
1940Sstevel@tonic-gate 					(void) sprintf(lp,
1950Sstevel@tonic-gate 					" Vers mismatch (low=%d, high=%d)",
1960Sstevel@tonic-gate 						lo, hi);
1970Sstevel@tonic-gate 					break;
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 				case AUTH_ERROR:
2000Sstevel@tonic-gate 					why = getxdr_u_long();
2010Sstevel@tonic-gate 					(void) sprintf(lp,
2020Sstevel@tonic-gate 						" Can't authenticate (%s)",
2030Sstevel@tonic-gate 						nameof_why(why));
2040Sstevel@tonic-gate 					break;
2050Sstevel@tonic-gate 				}
2060Sstevel@tonic-gate 			}
2070Sstevel@tonic-gate 			break;
2080Sstevel@tonic-gate 		}
2090Sstevel@tonic-gate 	}
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 	if (flags & F_DTAIL) {
2120Sstevel@tonic-gate 		show_header("RPC:  ", "SUN RPC Header", fraglen);
2130Sstevel@tonic-gate 		show_space();
2140Sstevel@tonic-gate 		if (type == IPPROTO_TCP) {	/* record mark */
2150Sstevel@tonic-gate 			(void) sprintf(get_line(markpos, markpos+4),
2160Sstevel@tonic-gate 				"Record Mark: %s fragment, length = %d",
2170Sstevel@tonic-gate 				recmark & LAST_FRAG ? "last" : "",
2180Sstevel@tonic-gate 				recmark & ~LAST_FRAG);
2190Sstevel@tonic-gate 		}
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
2220Sstevel@tonic-gate 			"Transaction id = %lu",
2230Sstevel@tonic-gate 			xid);
2240Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
2250Sstevel@tonic-gate 			"Type = %d (%s)",
2260Sstevel@tonic-gate 			direction,
2270Sstevel@tonic-gate 			direction == CALL ? "Call":"Reply");
2280Sstevel@tonic-gate 
2290Sstevel@tonic-gate 		switch (direction) {
2300Sstevel@tonic-gate 		case CALL:
2310Sstevel@tonic-gate 			rpc_detail_call(flags, xid, rpcvers,
2320Sstevel@tonic-gate 				prog, vers, proc, rpc, fraglen);
2330Sstevel@tonic-gate 			break;
2340Sstevel@tonic-gate 		case REPLY:
2350Sstevel@tonic-gate 			rpc_detail_reply(flags, xid, x, rpc, fraglen);
2360Sstevel@tonic-gate 			break;
2370Sstevel@tonic-gate 		}
2380Sstevel@tonic-gate 	}
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate 	return (fraglen);
2410Sstevel@tonic-gate }
2420Sstevel@tonic-gate 
243*410Skcpoon static void
244*410Skcpoon rpc_detail_call(int flags, int xid, int rpcvers, int prog, int vers, int proc,
245*410Skcpoon     char *data, int len)
2460Sstevel@tonic-gate {
2470Sstevel@tonic-gate 	char *nameof_flavor();
2480Sstevel@tonic-gate 	char *nameof_prog();
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
2510Sstevel@tonic-gate 		"RPC version = %d",
2520Sstevel@tonic-gate 		rpcvers);
2530Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
2540Sstevel@tonic-gate 		"Program = %d (%s), version = %d, procedure = %d",
2550Sstevel@tonic-gate 		prog, nameof_prog(prog), vers, proc);
2560Sstevel@tonic-gate 	print_creds(xid);
2570Sstevel@tonic-gate 	print_verif(CALL);
2580Sstevel@tonic-gate 	show_trailer();
2590Sstevel@tonic-gate 	protoprint(flags, CALL, xid, prog, vers, proc, data, len);
2600Sstevel@tonic-gate }
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate char *
2630Sstevel@tonic-gate nameof_flavor(flavor)
2640Sstevel@tonic-gate 	int flavor;
2650Sstevel@tonic-gate {
2660Sstevel@tonic-gate 	switch (flavor) {
2670Sstevel@tonic-gate 	case AUTH_NONE : return ("None");
2680Sstevel@tonic-gate 	case AUTH_UNIX : return ("Unix");
2690Sstevel@tonic-gate 	case AUTH_SHORT: return ("Unix short");
2700Sstevel@tonic-gate 	case AUTH_DES  : return ("DES");
2710Sstevel@tonic-gate 	case RPCSEC_GSS: return ("RPCSEC_GSS");
2720Sstevel@tonic-gate 	default: return ("unknown");
2730Sstevel@tonic-gate 	}
2740Sstevel@tonic-gate }
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate char *
2770Sstevel@tonic-gate tohex(char *p, int len)
2780Sstevel@tonic-gate {
2790Sstevel@tonic-gate 	int i, j;
2800Sstevel@tonic-gate 	static char hbuff[1024];
2810Sstevel@tonic-gate 	static char *hexstr = "0123456789ABCDEF";
2820Sstevel@tonic-gate 	char toobig = 0;
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	if (len * 2 > sizeof (hbuff)) {
2850Sstevel@tonic-gate 		toobig++;
2860Sstevel@tonic-gate 		len = sizeof (hbuff) / 2;
2870Sstevel@tonic-gate 	}
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate 	j = 0;
2900Sstevel@tonic-gate 	for (i = 0; i < len; i++) {
2910Sstevel@tonic-gate 		hbuff[j++] = hexstr[p[i] >> 4	& 0x0f];
2920Sstevel@tonic-gate 		hbuff[j++] = hexstr[p[i]	& 0x0f];
2930Sstevel@tonic-gate 	}
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 	if (toobig) {
2960Sstevel@tonic-gate 		hbuff[len * 2 - strlen("<Too Long>")] = '\0';
2970Sstevel@tonic-gate 		strcat(hbuff, "<Too Long>");
2980Sstevel@tonic-gate 	} else
2990Sstevel@tonic-gate 		hbuff[j] = '\0';
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate 	return (hbuff);
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate 
304*410Skcpoon static void
3050Sstevel@tonic-gate print_creds(int xid)
3060Sstevel@tonic-gate {
3070Sstevel@tonic-gate 	int pos, flavor, authlen;
3080Sstevel@tonic-gate 	int uid, gid, len;
3090Sstevel@tonic-gate 	int tlen, idlen;
3100Sstevel@tonic-gate 	int i, namekind;
3110Sstevel@tonic-gate 	char *p, *line;
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate 	pos = getxdr_pos();
3140Sstevel@tonic-gate 	flavor  = getxdr_long();
3150Sstevel@tonic-gate 	authlen = getxdr_long();
3160Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3170Sstevel@tonic-gate 		"Credentials: Flavor = %d (%s), len = %d bytes",
3180Sstevel@tonic-gate 		flavor, nameof_flavor(flavor), authlen);
3190Sstevel@tonic-gate 	if (authlen <= 0)
3200Sstevel@tonic-gate 		return;
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 	switch (flavor) {
3230Sstevel@tonic-gate 	case AUTH_UNIX:
3240Sstevel@tonic-gate 		(void) showxdr_time("   Time = %s");
3250Sstevel@tonic-gate 		(void) showxdr_string(MAX_MACHINE_NAME, "   Hostname = %s");
3260Sstevel@tonic-gate 		pos = getxdr_pos();
3270Sstevel@tonic-gate 		uid = getxdr_u_long();
3280Sstevel@tonic-gate 		gid = getxdr_u_long();
3290Sstevel@tonic-gate 		(void) sprintf(get_line(pos, getxdr_pos()),
3300Sstevel@tonic-gate 			"   Uid = %d, Gid = %d",
3310Sstevel@tonic-gate 			uid, gid);
3320Sstevel@tonic-gate 		len = getxdr_u_long();
3330Sstevel@tonic-gate 		line = get_line(pos, len * 4);
3340Sstevel@tonic-gate 		if (len == 0)
3350Sstevel@tonic-gate 			(void) sprintf(line, "   Groups = (none)");
3360Sstevel@tonic-gate 		else {
3370Sstevel@tonic-gate 			(void) sprintf(line, "   Groups = ");
3380Sstevel@tonic-gate 			line += strlen(line);
3390Sstevel@tonic-gate 			while (len--) {
3400Sstevel@tonic-gate 				gid = getxdr_u_long();
3410Sstevel@tonic-gate 				(void) sprintf(line, "%d ", gid);
3420Sstevel@tonic-gate 				line += strlen(line);
3430Sstevel@tonic-gate 			}
3440Sstevel@tonic-gate 		}
3450Sstevel@tonic-gate 		break;
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	case AUTH_DES:
3480Sstevel@tonic-gate 		namekind = getxdr_u_long();
3490Sstevel@tonic-gate 		(void) sprintf(get_line(pos, getxdr_pos()),
3500Sstevel@tonic-gate 			"   Name kind = %d (%s)",
3510Sstevel@tonic-gate 			namekind,
3520Sstevel@tonic-gate 			namekind == ADN_FULLNAME ?
3530Sstevel@tonic-gate 				"fullname" : "nickname");
3540Sstevel@tonic-gate 			switch (namekind) {
3550Sstevel@tonic-gate 			case ADN_FULLNAME:
3560Sstevel@tonic-gate 				(void) showxdr_string(64,
3570Sstevel@tonic-gate 					"   Network name = %s");
3580Sstevel@tonic-gate 				(void) showxdr_hex(8,
3590Sstevel@tonic-gate 				"   Conversation key = 0x%s (DES encrypted)");
3600Sstevel@tonic-gate 				(void) showxdr_hex(4,
3610Sstevel@tonic-gate 				"   Window = 0x%s (DES encrypted)");
3620Sstevel@tonic-gate 				break;
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 			case ADN_NICKNAME:
3650Sstevel@tonic-gate 				(void) showxdr_hex(4, "   Nickname = 0x%s");
3660Sstevel@tonic-gate 				break;
3670Sstevel@tonic-gate 			};
3680Sstevel@tonic-gate 		break;
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate 	case RPCSEC_GSS:
3710Sstevel@tonic-gate 		print_rpcsec_gss_cred(xid, authlen);
3720Sstevel@tonic-gate 		break;
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate 	default:
3750Sstevel@tonic-gate 		(void) showxdr_hex(authlen, "[%s]");
3760Sstevel@tonic-gate 		break;
3770Sstevel@tonic-gate 	}
3780Sstevel@tonic-gate }
3790Sstevel@tonic-gate 
380*410Skcpoon static void
381*410Skcpoon print_verif(int direction)
3820Sstevel@tonic-gate {
3830Sstevel@tonic-gate 	int pos, flavor, verlen;
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 	pos = getxdr_pos();
3860Sstevel@tonic-gate 	flavor = getxdr_long();
3870Sstevel@tonic-gate 	verlen = getxdr_long();
3880Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3890Sstevel@tonic-gate 		"Verifier   : Flavor = %d (%s), len = %d bytes",
3900Sstevel@tonic-gate 		flavor, nameof_flavor(flavor), verlen);
3910Sstevel@tonic-gate 	if (verlen == 0)
3920Sstevel@tonic-gate 		return;
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate 	switch (flavor) {
3950Sstevel@tonic-gate 	case AUTH_DES:
3960Sstevel@tonic-gate 		(void) showxdr_hex(8, "   Timestamp = 0x%s (DES encrypted)");
3970Sstevel@tonic-gate 		if (direction == CALL)
3980Sstevel@tonic-gate 			(void) showxdr_hex(4,
3990Sstevel@tonic-gate 				"   Window    = 0x%s (DES encrypted)");
4000Sstevel@tonic-gate 		else
4010Sstevel@tonic-gate 			(void) showxdr_hex(4, "   Nickname  = 0x%s");
4020Sstevel@tonic-gate 		break;
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate 	/* For other flavors like AUTH_NONE, AUTH_UNIX, RPCSEC_GSS etc. */
4050Sstevel@tonic-gate 	default:
4060Sstevel@tonic-gate 		(void) showxdr_hex(verlen, "[%s]");
4070Sstevel@tonic-gate 		break;
4080Sstevel@tonic-gate 	}
4090Sstevel@tonic-gate }
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate struct rpcnames {
4120Sstevel@tonic-gate 	int   rp_prog;
4130Sstevel@tonic-gate 	char *rp_name;
4140Sstevel@tonic-gate } rpcnames[] = {
4150Sstevel@tonic-gate 100000, "PMAP",			/* Portmapper */
4160Sstevel@tonic-gate 100001, "RSTAT",		/* Remote stats */
4170Sstevel@tonic-gate 100002, "RUSERS",		/* Remote users */
4180Sstevel@tonic-gate 100003, "NFS",			/* Nfs */
4190Sstevel@tonic-gate 100004, "NIS",			/* Network Information Service */
4200Sstevel@tonic-gate 100005, "MOUNT",		/* Mount demon */
4210Sstevel@tonic-gate 100006, "DBX",			/* Remote dbx */
4220Sstevel@tonic-gate 100007, "NISBIND",		/* NIS binder */
4230Sstevel@tonic-gate 100008, "WALL",			/* Shutdown msg */
4240Sstevel@tonic-gate 100009, "NISPASSWD",		/* Yppasswd server */
4250Sstevel@tonic-gate 100010, "ETHERSTAT",		/* Ether stats */
4260Sstevel@tonic-gate 100011, "RQUOTA",		/* Disk quotas */
4270Sstevel@tonic-gate 100012, "SPRAY",		/* Spray packets */
4280Sstevel@tonic-gate 100013, "IBM3270",		/* 3270 mapper */
4290Sstevel@tonic-gate 100014, "IBMRJE",		/* RJE mapper */
4300Sstevel@tonic-gate 100015, "SELNSVC",		/* Selection service */
4310Sstevel@tonic-gate 100016, "RDATABASE",		/* Remote database access */
4320Sstevel@tonic-gate 100017, "REX",			/* Remote execution */
4330Sstevel@tonic-gate 100018, "ALICE",		/* Alice Office Automation */
4340Sstevel@tonic-gate 100019, "SCHED",		/* Scheduling service */
4350Sstevel@tonic-gate 100020, "LLM",			/* Local lock manager */
4360Sstevel@tonic-gate 100021, "NLM",			/* Network lock manager */
4370Sstevel@tonic-gate 100022, "X25INR",		/* X.25 inr protocol */
4380Sstevel@tonic-gate 100023, "STATMON1",		/* Status monitor 1 */
4390Sstevel@tonic-gate 100024, "STATMON2",		/* Status monitor 2 */
4400Sstevel@tonic-gate 100025, "SELNLIB",		/* Selection library */
4410Sstevel@tonic-gate 100026, "BOOTPARAM",		/* Boot parameters service */
4420Sstevel@tonic-gate 100027, "MAZEPROG",		/* Mazewars game */
4430Sstevel@tonic-gate 100028, "NISUPDATE",		/* NIS update */
4440Sstevel@tonic-gate 100029, "KEYSERVE",		/* Key server */
4450Sstevel@tonic-gate 100030, "SECURECMD",		/* Secure login */
4460Sstevel@tonic-gate 100031, "NETFWDI",		/* NFS net forwarder init */
4470Sstevel@tonic-gate 100032, "NETFWDT",		/* NFS net forwarder trans */
4480Sstevel@tonic-gate 100033, "SUNLINKMAP",		/* Sunlink MAP */
4490Sstevel@tonic-gate 100034, "NETMON",		/* Network monitor */
4500Sstevel@tonic-gate 100035, "DBASE",		/* Lightweight database */
4510Sstevel@tonic-gate 100036, "PWDAUTH",		/* Password authorization */
4520Sstevel@tonic-gate 100037, "TFS",			/* Translucent file svc */
4530Sstevel@tonic-gate 100038, "NSE",			/* NSE server */
4540Sstevel@tonic-gate 100039, "NSE_ACTIVATE",		/* NSE activate daemon */
4550Sstevel@tonic-gate 100040, "SUNVIEW_HELP",		/* Sunview help */
4560Sstevel@tonic-gate 100041, "PNP",			/* PNP install */
4570Sstevel@tonic-gate 100042, "IPADDR_ALLOC",		/* IP addr allocator */
4580Sstevel@tonic-gate 100043, "FILEHANDLE",		/* Show filehandle */
4590Sstevel@tonic-gate 100044, "MVSNFS",		/* MVS NFS mount  */
4600Sstevel@tonic-gate 100045, "REM_FILEOP_USER",	/* Remote user file operations */
4610Sstevel@tonic-gate 100046, "BATCH_NISUPDATE",	/* Batched ypupdate */
4620Sstevel@tonic-gate 100047, "NEM",			/* Network execution mgr */
4630Sstevel@tonic-gate 100048, "RAYTRACE_RD",		/* Raytrace/mandelbrot remote daemon */
4640Sstevel@tonic-gate 100049, "RAYTRACE_LD",		/* Raytrace/mandelbrot local daemon */
4650Sstevel@tonic-gate 100050, "REM_FILEOP_GROUP",	/* Remote group file operations */
4660Sstevel@tonic-gate 100051, "REM_FILEOP_SYSTEM",	/* Remote system file operations */
4670Sstevel@tonic-gate 100052, "REM_SYSTEM_ROLE",	/* Remote system role operations */
4680Sstevel@tonic-gate 100055, "IOADMD",		/* Ioadmd */
4690Sstevel@tonic-gate 100056, "FILEMERGE",		/* Filemerge */
4700Sstevel@tonic-gate 100057, "NAMEBIND",		/* Name Binding Program */
4710Sstevel@tonic-gate 100058, "NJE",			/* Sunlink NJE */
4720Sstevel@tonic-gate 100059, "MVSATTR",		/* MVSNFS get attribute service */
4730Sstevel@tonic-gate 100060, "RMGR",			/* SunAccess/SunLink resource manager */
4740Sstevel@tonic-gate 100061, "UIDALLOC",		/* UID allocation service */
4750Sstevel@tonic-gate 100062, "LBSERVER",		/* License broker */
4760Sstevel@tonic-gate 100063, "LBBINDER",		/* NETlicense client binder */
4770Sstevel@tonic-gate 100064, "GIDALLOC",		/* GID allocation service */
4780Sstevel@tonic-gate 100065, "SUNISAM",		/* SunIsam */
4790Sstevel@tonic-gate 100066, "RDBSRV",		/* Remote Debug Server */
4800Sstevel@tonic-gate 100067, "NETDIR",		/* Network directory daemon */
4810Sstevel@tonic-gate 100068, "CMSD",			/* Network calendar program */
4820Sstevel@tonic-gate 100069, "NISXFR",		/* NIS transfer */
4830Sstevel@tonic-gate 100070, "TIMED",		/* RPC.timed */
4840Sstevel@tonic-gate 100071, "BUGTRAQ",		/* Bugtraqd */
4850Sstevel@tonic-gate 100072, "NeFS",			/* Internal use only */
4860Sstevel@tonic-gate 100073, "BILLBOARD",		/* Connectathon Billboard - NFS */
4870Sstevel@tonic-gate 100074, "BILLBOARD",		/* Connectathon Billboard - X */
4880Sstevel@tonic-gate 100075, "SCHEDROOM",		/* Sun meeting room scheduler */
4890Sstevel@tonic-gate 100076, "AUTHNEGOTIATE",	/* Authentication negotiation */
4900Sstevel@tonic-gate 100077, "ATTRPROG",		/* Database manipulation */
4910Sstevel@tonic-gate 100080, "AUTODUMP",		/* Sun consulting special */
4920Sstevel@tonic-gate 100081, "EVENT_SVC",		/* Event protocol */
4930Sstevel@tonic-gate 100085,	"ARM_PSD",		/* ARM policy */
4940Sstevel@tonic-gate 100086,	"ARMTOD",		/* ARM TOD */
4950Sstevel@tonic-gate 100087, "NA.ADMIN",		/* Sun (SNAG) administration agent */
4960Sstevel@tonic-gate 100099, "PLD",			/* Genesil 8.1 hot plot */
4970Sstevel@tonic-gate 100101, "NA.EVENT",		/* SNM (SunNet Manager) event dispatcher */
4980Sstevel@tonic-gate 100102, "NA.LOGGER",		/* SNM report logger */
4990Sstevel@tonic-gate 100103, "NA.DISCOVER",		/* SNM network discovery agent */
5000Sstevel@tonic-gate 100104, "NA.SYNC",		/* SNM sync interface agent */
5010Sstevel@tonic-gate 100105, "NA.DISKINFO",		/* SNM disk info agent */
5020Sstevel@tonic-gate 100106, "NA.IOSTAT",		/* SNM iostat agent */
5030Sstevel@tonic-gate 100107, "NA.HOSTPERF",		/* SNM rstat proxy agent */
5040Sstevel@tonic-gate 100108, "NA.CONFIG",		/* SNM host configuration agent */
5050Sstevel@tonic-gate 100109, "NA.ACTIVITY",		/* SNM activity daemon */
5060Sstevel@tonic-gate 100111, "NA.LPSTAT",		/* SNM printer agent */
5070Sstevel@tonic-gate 100112, "NA.HOSTMEM",		/* SNM host network memory agent */
5080Sstevel@tonic-gate 100113, "NA.SAMPLE",		/* SNM sample agent */
5090Sstevel@tonic-gate 100114, "NA.X25",		/* SNM X.25 agent */
5100Sstevel@tonic-gate 100115,	"NA.PING",		/* SNM ping proxy agent */
5110Sstevel@tonic-gate 100116,	"NA.RPCNFS",		/* SNM rpc and nfs agent */
5120Sstevel@tonic-gate 100117,	"NA.HOSTIF",		/* SNM host interface agent */
5130Sstevel@tonic-gate 100118,	"NA.ETHERIF",		/* SNM ethernet interface agent */
5140Sstevel@tonic-gate 100119,	"NA.IPPATH",		/* SNM traceroute proxy agent */
5150Sstevel@tonic-gate 100120,	"NA.IPROUTES",		/* SNM routing table agent */
5160Sstevel@tonic-gate 100121,	"NA.LAYERS",		/* SNM protocol layers gent */
5170Sstevel@tonic-gate 100122,	"NA.SNMP",		/* SNM SNMP proxy agent */
5180Sstevel@tonic-gate 100123,	"NA.TRAFFIC",		/* SNM network traffic agent */
5190Sstevel@tonic-gate 100124, "NA.DNI",		/* DNI (DECnet) proxy agent */
5200Sstevel@tonic-gate 100125, "NA.CHAT",		/* IBM Channel attach proxy agent */
5210Sstevel@tonic-gate 100126, "NA.FDDI",		/* FDDI agent */
5220Sstevel@tonic-gate 100127, "NA.FDDISMT",		/* FDDI SMT proxy agent */
5230Sstevel@tonic-gate 100128, "NA.MHS",		/* MHS agent */
5240Sstevel@tonic-gate 100130, "SNM_GRAPHER",		/* SNM 3D grapher */
5250Sstevel@tonic-gate 100132, "NA.TR",		/* Token Ring agent */
5260Sstevel@tonic-gate 100134, "NA.TOKENRING",		/* Token Ring agent */
5270Sstevel@tonic-gate 100136, "NA.FRAMERELAY",	/* Frame Relay agent */
5280Sstevel@tonic-gate 100175, "NA.SNMPTRAP",		/* SNM SNMP trap daemon */
5290Sstevel@tonic-gate 100180, "NA.MIPROUTES",		/* SNM multicast routing table agent */
5300Sstevel@tonic-gate 100201, "MVSNFSSTAT",		/* MVS/NFS Memory usage statistic server */
5310Sstevel@tonic-gate 100227, "NFS_ACL",		/* NFS ACL support */
5320Sstevel@tonic-gate 100300, "NIS+",			/* NIS+ name service */
5330Sstevel@tonic-gate 100302, "NIS+ CB",		/* NIS+ callbacks */
5340Sstevel@tonic-gate 101002, "NSELINKTOOL",		/* NSE link daemon */
5350Sstevel@tonic-gate 101003, "NSELINKAPP",		/* NSE link application */
5360Sstevel@tonic-gate 110001, "GOLABEL",		/* SunOS MLS  */
5370Sstevel@tonic-gate 110002, "PUC",			/* SunOS MLS  */
5380Sstevel@tonic-gate 150001, "PCNFSD",		/* PC passwd authorization */
5390Sstevel@tonic-gate 150002, "TOPS",			/* TOPS name mapping */
5400Sstevel@tonic-gate 150003, "TOPS",			/* TOPS external attribute storage */
5410Sstevel@tonic-gate 150004, "TOPS",			/* TOPS hierarchical file system */
5420Sstevel@tonic-gate 150005, "TOPS",			/* TOPS NFS transparency extensions */
5430Sstevel@tonic-gate 150006, "SOLARNET_FW",		/* SolarNet Framework protocol */
5440Sstevel@tonic-gate 160001, "CM",			/* Nihon Sun - Japanese Input system */
5450Sstevel@tonic-gate 300004, "FRAME 1",		/* Frame program 1 */
5460Sstevel@tonic-gate 300009, "FRAME 2",		/* Frame program 2 */
5470Sstevel@tonic-gate 390101, "RAP",			/* Legato RAP protocol */
5480Sstevel@tonic-gate 390102, "RAPRD",		/* Legato RAP resource dir protocol */
5490Sstevel@tonic-gate 500021, "ZNS",			/* Zeus Network Service */
5500Sstevel@tonic-gate };
5510Sstevel@tonic-gate 
552*410Skcpoon int
5530Sstevel@tonic-gate compare(a, b)
5540Sstevel@tonic-gate 	register struct rpcnames *a, *b;
5550Sstevel@tonic-gate {
5560Sstevel@tonic-gate 	return (a->rp_prog - b->rp_prog);
5570Sstevel@tonic-gate }
5580Sstevel@tonic-gate 
5590Sstevel@tonic-gate char *
5600Sstevel@tonic-gate nameof_prog(prog)
5610Sstevel@tonic-gate 	int prog;
5620Sstevel@tonic-gate {
5630Sstevel@tonic-gate 	struct rpcnames *r;
5640Sstevel@tonic-gate 	struct rpcnames *bsearch();
5650Sstevel@tonic-gate 	int elems = sizeof (rpcnames) / sizeof (*r);
5660Sstevel@tonic-gate 
5670Sstevel@tonic-gate 	r = bsearch(&prog, rpcnames, elems, sizeof (*r), compare);
5680Sstevel@tonic-gate 	if (r)
5690Sstevel@tonic-gate 		return (r->rp_name);
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate 	if (prog >= 0x40000000 && prog <= 0x5fffffff)
5720Sstevel@tonic-gate 		return ("transient");
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate 	return ("?");
5750Sstevel@tonic-gate }
5760Sstevel@tonic-gate 
5770Sstevel@tonic-gate char *
5780Sstevel@tonic-gate nameof_astat(status)
5790Sstevel@tonic-gate 	int status;
5800Sstevel@tonic-gate {
5810Sstevel@tonic-gate 	switch (status) {
5820Sstevel@tonic-gate 	case SUCCESS	  : return ("Success");
5830Sstevel@tonic-gate 	case PROG_UNAVAIL : return ("Program unavailable");
5840Sstevel@tonic-gate 	case PROG_MISMATCH: return ("Program number mismatch");
5850Sstevel@tonic-gate 	case PROC_UNAVAIL : return ("Procedure unavailable");
5860Sstevel@tonic-gate 	case GARBAGE_ARGS : return ("Garbage arguments");
5870Sstevel@tonic-gate 	case SYSTEM_ERR   : return ("System error");
5880Sstevel@tonic-gate 	default: return ("unknown");
5890Sstevel@tonic-gate 	}
5900Sstevel@tonic-gate }
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate char *
5930Sstevel@tonic-gate nameof_why(why)
5940Sstevel@tonic-gate 	int why;
5950Sstevel@tonic-gate {
5960Sstevel@tonic-gate 	switch (why) {
5970Sstevel@tonic-gate 	case AUTH_BADCRED:	return ("bogus credentials (seal broken)");
5980Sstevel@tonic-gate 	case AUTH_REJECTEDCRED:	return ("client should begin new session");
5990Sstevel@tonic-gate 	case AUTH_BADVERF:	return ("bogus verifier (seal broken)");
6000Sstevel@tonic-gate 	case AUTH_REJECTEDVERF:	return ("verifier expired or was replayed");
6010Sstevel@tonic-gate 	case AUTH_TOOWEAK:	return ("too weak");
6020Sstevel@tonic-gate 	case AUTH_INVALIDRESP:	return ("bogus response verifier");
6030Sstevel@tonic-gate 	case AUTH_TIMEEXPIRE:	return ("time of credential expired");
6040Sstevel@tonic-gate 	case AUTH_TKT_FILE:	return ("something wrong with ticket file");
6050Sstevel@tonic-gate 	case AUTH_DECODE:	return ("can't decode authenticator");
6060Sstevel@tonic-gate 	case AUTH_NET_ADDR:	return ("net address in ticket wrong");
6070Sstevel@tonic-gate 	case RPCSEC_GSS_NOCRED:	return ("no credentials for user");
6080Sstevel@tonic-gate 	case RPCSEC_GSS_FAILED:	return ("GSS failure, credentials deleted");
6090Sstevel@tonic-gate 	case AUTH_FAILED:
6100Sstevel@tonic-gate 	default:
6110Sstevel@tonic-gate 		return ("unknown reason");
6120Sstevel@tonic-gate 	}
6130Sstevel@tonic-gate }
6140Sstevel@tonic-gate 
615*410Skcpoon static void
616*410Skcpoon rpc_detail_reply(int flags, int xid, struct cache_struct *x, char *data,
617*410Skcpoon     int len)
6180Sstevel@tonic-gate {
6190Sstevel@tonic-gate 	int status;
6200Sstevel@tonic-gate 	int astat, rstat, why;
6210Sstevel@tonic-gate 	int pos;
6220Sstevel@tonic-gate 
6230Sstevel@tonic-gate 	if (x) {
6240Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
6250Sstevel@tonic-gate 			"This is a reply to frame %d",
6260Sstevel@tonic-gate 			x->xid_frame);
6270Sstevel@tonic-gate 	}
6280Sstevel@tonic-gate 	pos = getxdr_pos();
6290Sstevel@tonic-gate 	status = getxdr_long();
6300Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
6310Sstevel@tonic-gate 		"Status = %d (%s)",
6320Sstevel@tonic-gate 		status, status ? "Denied" : "Accepted");
6330Sstevel@tonic-gate 
6340Sstevel@tonic-gate 	switch (status) {
6350Sstevel@tonic-gate 	case MSG_ACCEPTED:
6360Sstevel@tonic-gate 		print_verif(REPLY);
6370Sstevel@tonic-gate 		pos = getxdr_pos();
6380Sstevel@tonic-gate 		astat = getxdr_long();
6390Sstevel@tonic-gate 		(void) sprintf(get_line(pos, getxdr_pos()),
6400Sstevel@tonic-gate 			"Accept status = %d (%s)",
6410Sstevel@tonic-gate 			astat, nameof_astat(astat));
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 		switch (astat) {
6440Sstevel@tonic-gate 		case SUCCESS:
6450Sstevel@tonic-gate 			if (x) {
6460Sstevel@tonic-gate 				show_trailer();
6470Sstevel@tonic-gate 				protoprint(flags, REPLY, xid,
6480Sstevel@tonic-gate 					x->xid_prog, x->xid_vers, x->xid_proc,
6490Sstevel@tonic-gate 					data, len);
6500Sstevel@tonic-gate 			}
6510Sstevel@tonic-gate 			break;
6520Sstevel@tonic-gate 		case PROG_UNAVAIL :
6530Sstevel@tonic-gate 			break;
6540Sstevel@tonic-gate 		case PROG_MISMATCH:
6550Sstevel@tonic-gate 		case PROC_UNAVAIL :
6560Sstevel@tonic-gate 			showxdr_long("   Low  = %d");
6570Sstevel@tonic-gate 			showxdr_long("   High = %d");
6580Sstevel@tonic-gate 			break;
6590Sstevel@tonic-gate 		case GARBAGE_ARGS:
6600Sstevel@tonic-gate 		case SYSTEM_ERR:
6610Sstevel@tonic-gate 		default:
6620Sstevel@tonic-gate 			;
6630Sstevel@tonic-gate 		}
6640Sstevel@tonic-gate 
6650Sstevel@tonic-gate 		break;
6660Sstevel@tonic-gate 
6670Sstevel@tonic-gate 	case MSG_DENIED:
6680Sstevel@tonic-gate 		pos = getxdr_pos();
6690Sstevel@tonic-gate 		rstat = getxdr_long();
6700Sstevel@tonic-gate 		(void) sprintf(get_line(pos, getxdr_pos()),
6710Sstevel@tonic-gate 			"Reject status = %d (%s)",
6720Sstevel@tonic-gate 			rstat,
6730Sstevel@tonic-gate 			rstat ? "can't authenticate"
6740Sstevel@tonic-gate 				: "version mismatch");
6750Sstevel@tonic-gate 
6760Sstevel@tonic-gate 		switch (rstat) {
6770Sstevel@tonic-gate 		case RPC_MISMATCH:
6780Sstevel@tonic-gate 			showxdr_long("   Low  = %d");
6790Sstevel@tonic-gate 			showxdr_long("   High = %d");
6800Sstevel@tonic-gate 			break;
6810Sstevel@tonic-gate 		case AUTH_ERROR:
6820Sstevel@tonic-gate 			why = getxdr_u_long();
6830Sstevel@tonic-gate 			(void) sprintf(get_line(pos, getxdr_pos()),
6840Sstevel@tonic-gate 				"   Why = %d (%s)",
6850Sstevel@tonic-gate 				why, nameof_why(why));
6860Sstevel@tonic-gate 			break;
6870Sstevel@tonic-gate 		}
6880Sstevel@tonic-gate 		break;
6890Sstevel@tonic-gate 	}
6900Sstevel@tonic-gate }
6910Sstevel@tonic-gate 
6920Sstevel@tonic-gate /*
6930Sstevel@tonic-gate  * Return true if this is a valid RPC packet
6940Sstevel@tonic-gate  */
695*410Skcpoon int
696*410Skcpoon valid_rpc(char *rpc, int rpclen)
6970Sstevel@tonic-gate {
6980Sstevel@tonic-gate 	XDR	xdrm;
6990Sstevel@tonic-gate 	struct rpc_msg msg;
7000Sstevel@tonic-gate 
7010Sstevel@tonic-gate 	if (rpclen < 12)
7020Sstevel@tonic-gate 		return (0);
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate 	xdrmem_create(&xdrm, rpc, rpclen, XDR_DECODE);
7050Sstevel@tonic-gate 	if (xdr_u_int(&xdrm, &msg.rm_xid) &&
7060Sstevel@tonic-gate 	    xdr_u_int(&xdrm, (uint_t *)&msg.rm_direction)) {
7070Sstevel@tonic-gate 		switch (msg.rm_direction) {
7080Sstevel@tonic-gate 		case CALL:
7090Sstevel@tonic-gate 			if (xdr_rpcvers(&xdrm, &msg.rm_call.cb_rpcvers) &&
7100Sstevel@tonic-gate 			    msg.rm_call.cb_rpcvers == 2)
7110Sstevel@tonic-gate 				return (1);
7120Sstevel@tonic-gate 			break;
7130Sstevel@tonic-gate 		case REPLY:
7140Sstevel@tonic-gate 			if (xdr_u_int(&xdrm,
7150Sstevel@tonic-gate 					(uint_t *)&msg.rm_reply.rp_stat) &&
7160Sstevel@tonic-gate 			    (msg.rm_reply.rp_stat == MSG_ACCEPTED ||
7170Sstevel@tonic-gate 			    msg.rm_reply.rp_stat == MSG_DENIED))
7180Sstevel@tonic-gate 				return (1);
7190Sstevel@tonic-gate 			break;
7200Sstevel@tonic-gate 		}
7210Sstevel@tonic-gate 	}
7220Sstevel@tonic-gate 
7230Sstevel@tonic-gate 	return (0);
7240Sstevel@tonic-gate }
7250Sstevel@tonic-gate 
7260Sstevel@tonic-gate struct cache_struct *xcpfirst	= &xid_cache[0];
7270Sstevel@tonic-gate struct cache_struct *xcp	= &xid_cache[0];
7280Sstevel@tonic-gate struct cache_struct *xcplast	= &xid_cache[XID_CACHE_SIZE - 1];
7290Sstevel@tonic-gate 
7300Sstevel@tonic-gate struct cache_struct *
7310Sstevel@tonic-gate find_xid(xid)
7320Sstevel@tonic-gate 	ulong_t xid;
7330Sstevel@tonic-gate {
7340Sstevel@tonic-gate 	struct cache_struct *x;
7350Sstevel@tonic-gate 
7360Sstevel@tonic-gate 	for (x = xcp; x >= xcpfirst; x--)
7370Sstevel@tonic-gate 		if (x->xid_num == xid)
7380Sstevel@tonic-gate 			return (x);
7390Sstevel@tonic-gate 	for (x = xcplast; x > xcp; x--)
7400Sstevel@tonic-gate 		if (x->xid_num == xid)
7410Sstevel@tonic-gate 			return (x);
7420Sstevel@tonic-gate 	return (NULL);
7430Sstevel@tonic-gate }
7440Sstevel@tonic-gate 
745*410Skcpoon static void
746*410Skcpoon stash_xid(ulong_t xid, int frame, int prog, int vers, int proc)
7470Sstevel@tonic-gate {
7480Sstevel@tonic-gate 	struct cache_struct *x;
7490Sstevel@tonic-gate 
7500Sstevel@tonic-gate 	x = find_xid(xid);
7510Sstevel@tonic-gate 	if (x == NULL) {
7520Sstevel@tonic-gate 		x = xcp++;
7530Sstevel@tonic-gate 		if (xcp > xcplast)
7540Sstevel@tonic-gate 			xcp = xcpfirst;
7550Sstevel@tonic-gate 		x->xid_num = xid;
7560Sstevel@tonic-gate 		x->xid_frame = frame;
7570Sstevel@tonic-gate 	}
7580Sstevel@tonic-gate 	x->xid_prog = prog;
7590Sstevel@tonic-gate 	x->xid_vers = vers;
7600Sstevel@tonic-gate 	x->xid_proc = proc;
7610Sstevel@tonic-gate 	x->xid_gss_proc = RPCSEC_GSS_DATA;
7620Sstevel@tonic-gate 	x->xid_gss_service = rpc_gss_svc_default;
7630Sstevel@tonic-gate }
7640Sstevel@tonic-gate 
7650Sstevel@tonic-gate void
7660Sstevel@tonic-gate check_retransmit(line, xid)
7670Sstevel@tonic-gate 	char *line;
7680Sstevel@tonic-gate 	ulong_t xid;
7690Sstevel@tonic-gate {
7700Sstevel@tonic-gate 	struct cache_struct *x;
7710Sstevel@tonic-gate 	extern int pi_frame;
7720Sstevel@tonic-gate 
7730Sstevel@tonic-gate 	x = find_xid(xid);
7740Sstevel@tonic-gate 	if (x && x->xid_frame != pi_frame)
7750Sstevel@tonic-gate 		(void) strcat(line, " (retransmit)");
7760Sstevel@tonic-gate }
777