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