17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
52b24ab6bSSebastien Roy * Common Development and Distribution License (the "License").
62b24ab6bSSebastien Roy * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
222b24ab6bSSebastien Roy * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/errno.h>
287c478bd9Sstevel@tonic-gate #include <setjmp.h>
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include <netinet/in.h>
317c478bd9Sstevel@tonic-gate #include <netdb.h>
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
347c478bd9Sstevel@tonic-gate #include <rpc/types.h>
357c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
367c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
377c478bd9Sstevel@tonic-gate #include <rpc/auth_unix.h>
387c478bd9Sstevel@tonic-gate #include <rpc/auth_des.h>
397c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
407c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
417c478bd9Sstevel@tonic-gate #include <rpc/pmap_clnt.h>
427c478bd9Sstevel@tonic-gate #include <rpc/svc.h>
437c478bd9Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
447c478bd9Sstevel@tonic-gate #include <rpc/pmap_prot.h>
457c478bd9Sstevel@tonic-gate #include "snoop.h"
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate #ifndef MIN
487c478bd9Sstevel@tonic-gate #define MIN(a, b) ((a) < (b) ? (a) : (b))
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate int pos;
527c478bd9Sstevel@tonic-gate struct cache_struct *find_xid();
537c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
547c478bd9Sstevel@tonic-gate void protoprint();
557c478bd9Sstevel@tonic-gate void print_rpcsec_gss_cred(int xid, int authlen);
567c478bd9Sstevel@tonic-gate char *nameof_prog();
577c478bd9Sstevel@tonic-gate char *nameof_astat();
587c478bd9Sstevel@tonic-gate char *nameof_why();
592e3b6467Skcpoon static void rpc_detail_call(int, int, int, int, int, int, char *, int);
602e3b6467Skcpoon static void rpc_detail_reply(int, int, struct cache_struct *, char *, int len);
612e3b6467Skcpoon static void print_creds(int);
622e3b6467Skcpoon static void print_verif(int);
632e3b6467Skcpoon static void stash_xid(ulong_t, int, int, int, int);
64*cd93bdd3SToomas Soome struct cache_struct xid_cache[XID_CACHE_SIZE];
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate #define LAST_FRAG ((ulong_t)1 << 31)
677c478bd9Sstevel@tonic-gate
682e3b6467Skcpoon int
interpret_rpc(int flags,char * rpc,int fraglen,int type)692e3b6467Skcpoon interpret_rpc(int flags, char *rpc, int fraglen, int type)
707c478bd9Sstevel@tonic-gate {
717c478bd9Sstevel@tonic-gate ulong_t xid;
727c478bd9Sstevel@tonic-gate int direction;
737c478bd9Sstevel@tonic-gate struct cache_struct *x;
747c478bd9Sstevel@tonic-gate int rpcvers, prog, vers, proc;
757c478bd9Sstevel@tonic-gate int status, astat, rstat, why;
767c478bd9Sstevel@tonic-gate char *lp;
777c478bd9Sstevel@tonic-gate unsigned recmark;
787c478bd9Sstevel@tonic-gate int markpos;
797c478bd9Sstevel@tonic-gate extern int pi_frame;
807c478bd9Sstevel@tonic-gate int lo, hi;
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate xdr_init(rpc, fraglen);
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
857c478bd9Sstevel@tonic-gate if (flags & F_DTAIL)
867c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
872b24ab6bSSebastien Roy "---- short frame ---");
887c478bd9Sstevel@tonic-gate return (fraglen);
897c478bd9Sstevel@tonic-gate }
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate if (type == IPPROTO_TCP) { /* record mark */
927c478bd9Sstevel@tonic-gate markpos = getxdr_pos();
937c478bd9Sstevel@tonic-gate recmark = getxdr_long();
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate xid = getxdr_u_long();
977c478bd9Sstevel@tonic-gate direction = getxdr_long();
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate if (direction == CALL) {
1007c478bd9Sstevel@tonic-gate rpcvers = getxdr_long();
1017c478bd9Sstevel@tonic-gate pos = getxdr_pos();
1027c478bd9Sstevel@tonic-gate prog = getxdr_long();
1037c478bd9Sstevel@tonic-gate vers = getxdr_long();
1047c478bd9Sstevel@tonic-gate proc = getxdr_long();
1057c478bd9Sstevel@tonic-gate stash_xid(xid, pi_frame, prog, vers, proc);
1062b24ab6bSSebastien Roy if (!(flags & (F_SUM | F_DTAIL))) {
1077c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc,
1082b24ab6bSSebastien Roy rpc, fraglen);
1092b24ab6bSSebastien Roy }
1107c478bd9Sstevel@tonic-gate } else {
1117c478bd9Sstevel@tonic-gate x = find_xid(xid);
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate if (flags & F_SUM) {
1157c478bd9Sstevel@tonic-gate switch (direction) {
1167c478bd9Sstevel@tonic-gate case CALL:
1177c478bd9Sstevel@tonic-gate (void) sprintf(get_sum_line(),
1182b24ab6bSSebastien Roy "RPC C XID=%lu PROG=%d (%s) VERS=%d PROC=%d",
1192b24ab6bSSebastien Roy xid,
1202b24ab6bSSebastien Roy prog, nameof_prog(prog),
1212b24ab6bSSebastien Roy vers, proc);
1227c478bd9Sstevel@tonic-gate if (getxdr_long() == RPCSEC_GSS) { /* Cred auth type */
1237c478bd9Sstevel@tonic-gate extract_rpcsec_gss_cred_info(xid);
1247c478bd9Sstevel@tonic-gate /* RPCSEC_GSS cred auth data */
1257c478bd9Sstevel@tonic-gate } else {
1267c478bd9Sstevel@tonic-gate xdr_skip(getxdr_long());
1277c478bd9Sstevel@tonic-gate /* non RPCSEC_GSS cred auth data */
1287c478bd9Sstevel@tonic-gate }
1297c478bd9Sstevel@tonic-gate xdr_skip(4); /* Verf auth type */
1307c478bd9Sstevel@tonic-gate xdr_skip(RNDUP(getxdr_long())); /* Verf auth data */
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc,
1332b24ab6bSSebastien Roy rpc, fraglen);
1347c478bd9Sstevel@tonic-gate break;
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate case REPLY:
1377c478bd9Sstevel@tonic-gate lp = get_sum_line();
1387c478bd9Sstevel@tonic-gate if (x == NULL)
1397c478bd9Sstevel@tonic-gate (void) sprintf(lp, "RPC R XID=%lu", xid);
1407c478bd9Sstevel@tonic-gate else
1417c478bd9Sstevel@tonic-gate (void) sprintf(lp, "RPC R (#%d) XID=%lu",
1422b24ab6bSSebastien Roy x->xid_frame, xid);
1437c478bd9Sstevel@tonic-gate
1447c478bd9Sstevel@tonic-gate lp += strlen(lp);
1457c478bd9Sstevel@tonic-gate status = getxdr_long();
1467c478bd9Sstevel@tonic-gate switch (status) {
1477c478bd9Sstevel@tonic-gate case MSG_ACCEPTED:
1487c478bd9Sstevel@tonic-gate /* eat flavor and verifier */
1497c478bd9Sstevel@tonic-gate (void) getxdr_long();
1507c478bd9Sstevel@tonic-gate xdr_skip(RNDUP(getxdr_long()));
1517c478bd9Sstevel@tonic-gate astat = getxdr_long();
1527c478bd9Sstevel@tonic-gate (void) sprintf(lp, " %s",
1532b24ab6bSSebastien Roy nameof_astat(astat));
1547c478bd9Sstevel@tonic-gate lp += strlen(lp);
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gate switch (astat) {
1577c478bd9Sstevel@tonic-gate case SUCCESS:
1587c478bd9Sstevel@tonic-gate if (x) {
1597c478bd9Sstevel@tonic-gate protoprint(flags, REPLY,
1602b24ab6bSSebastien Roy xid,
1612b24ab6bSSebastien Roy x->xid_prog,
1622b24ab6bSSebastien Roy x->xid_vers,
1632b24ab6bSSebastien Roy x->xid_proc,
1642b24ab6bSSebastien Roy rpc, fraglen);
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate break;
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate case PROG_UNAVAIL :
1697c478bd9Sstevel@tonic-gate case PROG_MISMATCH:
1707c478bd9Sstevel@tonic-gate case PROC_UNAVAIL :
1717c478bd9Sstevel@tonic-gate lo = getxdr_long();
1727c478bd9Sstevel@tonic-gate hi = getxdr_long();
1737c478bd9Sstevel@tonic-gate (void) sprintf(lp,
1742b24ab6bSSebastien Roy " (low=%d, high=%d)",
1752b24ab6bSSebastien Roy lo, hi);
1767c478bd9Sstevel@tonic-gate break;
1777c478bd9Sstevel@tonic-gate
1787c478bd9Sstevel@tonic-gate case GARBAGE_ARGS:
1797c478bd9Sstevel@tonic-gate case SYSTEM_ERR:
1807c478bd9Sstevel@tonic-gate default:
1817c478bd9Sstevel@tonic-gate ;
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate break;
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate case MSG_DENIED:
1867c478bd9Sstevel@tonic-gate rstat = getxdr_long();
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate switch (rstat) {
1897c478bd9Sstevel@tonic-gate case RPC_MISMATCH:
1907c478bd9Sstevel@tonic-gate lo = getxdr_long();
1917c478bd9Sstevel@tonic-gate hi = getxdr_long();
1927c478bd9Sstevel@tonic-gate (void) sprintf(lp,
1937c478bd9Sstevel@tonic-gate " Vers mismatch (low=%d, high=%d)",
1942b24ab6bSSebastien Roy lo, hi);
1957c478bd9Sstevel@tonic-gate break;
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate case AUTH_ERROR:
1987c478bd9Sstevel@tonic-gate why = getxdr_u_long();
1997c478bd9Sstevel@tonic-gate (void) sprintf(lp,
2002b24ab6bSSebastien Roy " Can't authenticate (%s)",
2012b24ab6bSSebastien Roy nameof_why(why));
2027c478bd9Sstevel@tonic-gate break;
2037c478bd9Sstevel@tonic-gate }
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate break;
2067c478bd9Sstevel@tonic-gate }
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) {
2107c478bd9Sstevel@tonic-gate show_header("RPC: ", "SUN RPC Header", fraglen);
2117c478bd9Sstevel@tonic-gate show_space();
2127c478bd9Sstevel@tonic-gate if (type == IPPROTO_TCP) { /* record mark */
2137c478bd9Sstevel@tonic-gate (void) sprintf(get_line(markpos, markpos+4),
2142b24ab6bSSebastien Roy "Record Mark: %s fragment, length = %d",
2152b24ab6bSSebastien Roy recmark & LAST_FRAG ? "last" : "",
2162b24ab6bSSebastien Roy recmark & ~LAST_FRAG);
2177c478bd9Sstevel@tonic-gate }
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
2202b24ab6bSSebastien Roy "Transaction id = %lu",
2212b24ab6bSSebastien Roy xid);
2227c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
2232b24ab6bSSebastien Roy "Type = %d (%s)",
2242b24ab6bSSebastien Roy direction,
2252b24ab6bSSebastien Roy direction == CALL ? "Call":"Reply");
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate switch (direction) {
2287c478bd9Sstevel@tonic-gate case CALL:
2297c478bd9Sstevel@tonic-gate rpc_detail_call(flags, xid, rpcvers,
2302b24ab6bSSebastien Roy prog, vers, proc, rpc, fraglen);
2317c478bd9Sstevel@tonic-gate break;
2327c478bd9Sstevel@tonic-gate case REPLY:
2337c478bd9Sstevel@tonic-gate rpc_detail_reply(flags, xid, x, rpc, fraglen);
2347c478bd9Sstevel@tonic-gate break;
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate }
2377c478bd9Sstevel@tonic-gate
2387c478bd9Sstevel@tonic-gate return (fraglen);
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate
2412e3b6467Skcpoon static void
rpc_detail_call(int flags,int xid,int rpcvers,int prog,int vers,int proc,char * data,int len)2422e3b6467Skcpoon rpc_detail_call(int flags, int xid, int rpcvers, int prog, int vers, int proc,
2432e3b6467Skcpoon char *data, int len)
2447c478bd9Sstevel@tonic-gate {
2457c478bd9Sstevel@tonic-gate char *nameof_flavor();
2467c478bd9Sstevel@tonic-gate char *nameof_prog();
2477c478bd9Sstevel@tonic-gate
2487c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
2492b24ab6bSSebastien Roy "RPC version = %d",
2502b24ab6bSSebastien Roy rpcvers);
2517c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
2522b24ab6bSSebastien Roy "Program = %d (%s), version = %d, procedure = %d",
2532b24ab6bSSebastien Roy prog, nameof_prog(prog), vers, proc);
2547c478bd9Sstevel@tonic-gate print_creds(xid);
2557c478bd9Sstevel@tonic-gate print_verif(CALL);
2567c478bd9Sstevel@tonic-gate show_trailer();
2577c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc, data, len);
2587c478bd9Sstevel@tonic-gate }
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gate char *
nameof_flavor(int flavor)261*cd93bdd3SToomas Soome nameof_flavor(int flavor)
2627c478bd9Sstevel@tonic-gate {
2637c478bd9Sstevel@tonic-gate switch (flavor) {
2647c478bd9Sstevel@tonic-gate case AUTH_NONE : return ("None");
2657c478bd9Sstevel@tonic-gate case AUTH_UNIX : return ("Unix");
2667c478bd9Sstevel@tonic-gate case AUTH_SHORT: return ("Unix short");
2677c478bd9Sstevel@tonic-gate case AUTH_DES : return ("DES");
2687c478bd9Sstevel@tonic-gate case RPCSEC_GSS: return ("RPCSEC_GSS");
2697c478bd9Sstevel@tonic-gate default: return ("unknown");
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate }
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate char *
tohex(char * p,int len)2747c478bd9Sstevel@tonic-gate tohex(char *p, int len)
2757c478bd9Sstevel@tonic-gate {
2767c478bd9Sstevel@tonic-gate int i, j;
2777c478bd9Sstevel@tonic-gate static char hbuff[1024];
2787c478bd9Sstevel@tonic-gate static char *hexstr = "0123456789ABCDEF";
2797c478bd9Sstevel@tonic-gate char toobig = 0;
2807c478bd9Sstevel@tonic-gate
2817c478bd9Sstevel@tonic-gate if (len * 2 > sizeof (hbuff)) {
2827c478bd9Sstevel@tonic-gate toobig++;
2837c478bd9Sstevel@tonic-gate len = sizeof (hbuff) / 2;
2847c478bd9Sstevel@tonic-gate }
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate j = 0;
2877c478bd9Sstevel@tonic-gate for (i = 0; i < len; i++) {
2887c478bd9Sstevel@tonic-gate hbuff[j++] = hexstr[p[i] >> 4 & 0x0f];
2897c478bd9Sstevel@tonic-gate hbuff[j++] = hexstr[p[i] & 0x0f];
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate
2927c478bd9Sstevel@tonic-gate if (toobig) {
2937c478bd9Sstevel@tonic-gate hbuff[len * 2 - strlen("<Too Long>")] = '\0';
2947c478bd9Sstevel@tonic-gate strcat(hbuff, "<Too Long>");
2957c478bd9Sstevel@tonic-gate } else
2967c478bd9Sstevel@tonic-gate hbuff[j] = '\0';
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate return (hbuff);
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate
3012e3b6467Skcpoon static void
print_creds(int xid)3027c478bd9Sstevel@tonic-gate print_creds(int xid)
3037c478bd9Sstevel@tonic-gate {
3047c478bd9Sstevel@tonic-gate int pos, flavor, authlen;
3057c478bd9Sstevel@tonic-gate int uid, gid, len;
3067c478bd9Sstevel@tonic-gate int tlen, idlen;
3077c478bd9Sstevel@tonic-gate int i, namekind;
3087c478bd9Sstevel@tonic-gate char *p, *line;
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate pos = getxdr_pos();
3117c478bd9Sstevel@tonic-gate flavor = getxdr_long();
3127c478bd9Sstevel@tonic-gate authlen = getxdr_long();
3137c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
3142b24ab6bSSebastien Roy "Credentials: Flavor = %d (%s), len = %d bytes",
3152b24ab6bSSebastien Roy flavor, nameof_flavor(flavor), authlen);
3167c478bd9Sstevel@tonic-gate if (authlen <= 0)
3177c478bd9Sstevel@tonic-gate return;
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gate switch (flavor) {
3207c478bd9Sstevel@tonic-gate case AUTH_UNIX:
3217c478bd9Sstevel@tonic-gate (void) showxdr_time(" Time = %s");
3227c478bd9Sstevel@tonic-gate (void) showxdr_string(MAX_MACHINE_NAME, " Hostname = %s");
3237c478bd9Sstevel@tonic-gate pos = getxdr_pos();
3247c478bd9Sstevel@tonic-gate uid = getxdr_u_long();
3257c478bd9Sstevel@tonic-gate gid = getxdr_u_long();
3267c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
3272b24ab6bSSebastien Roy " Uid = %d, Gid = %d",
3282b24ab6bSSebastien Roy uid, gid);
3297c478bd9Sstevel@tonic-gate len = getxdr_u_long();
3307c478bd9Sstevel@tonic-gate line = get_line(pos, len * 4);
3317c478bd9Sstevel@tonic-gate if (len == 0)
3327c478bd9Sstevel@tonic-gate (void) sprintf(line, " Groups = (none)");
3337c478bd9Sstevel@tonic-gate else {
3347c478bd9Sstevel@tonic-gate (void) sprintf(line, " Groups = ");
3357c478bd9Sstevel@tonic-gate line += strlen(line);
3367c478bd9Sstevel@tonic-gate while (len--) {
3377c478bd9Sstevel@tonic-gate gid = getxdr_u_long();
3387c478bd9Sstevel@tonic-gate (void) sprintf(line, "%d ", gid);
3397c478bd9Sstevel@tonic-gate line += strlen(line);
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate break;
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate case AUTH_DES:
3457c478bd9Sstevel@tonic-gate namekind = getxdr_u_long();
3467c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
3472b24ab6bSSebastien Roy " Name kind = %d (%s)",
3482b24ab6bSSebastien Roy namekind,
3492b24ab6bSSebastien Roy namekind == ADN_FULLNAME ?
3502b24ab6bSSebastien Roy "fullname" : "nickname");
3512b24ab6bSSebastien Roy switch (namekind) {
3522b24ab6bSSebastien Roy case ADN_FULLNAME:
3532b24ab6bSSebastien Roy (void) showxdr_string(64,
3542b24ab6bSSebastien Roy " Network name = %s");
3552b24ab6bSSebastien Roy (void) showxdr_hex(8,
3562b24ab6bSSebastien Roy " Conversation key = 0x%s (DES encrypted)");
3572b24ab6bSSebastien Roy (void) showxdr_hex(4,
3582b24ab6bSSebastien Roy " Window = 0x%s (DES encrypted)");
3592b24ab6bSSebastien Roy break;
3607c478bd9Sstevel@tonic-gate
3612b24ab6bSSebastien Roy case ADN_NICKNAME:
3622b24ab6bSSebastien Roy (void) showxdr_hex(4, " Nickname = 0x%s");
3632b24ab6bSSebastien Roy break;
3642b24ab6bSSebastien Roy };
3657c478bd9Sstevel@tonic-gate break;
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gate case RPCSEC_GSS:
3687c478bd9Sstevel@tonic-gate print_rpcsec_gss_cred(xid, authlen);
3697c478bd9Sstevel@tonic-gate break;
3707c478bd9Sstevel@tonic-gate
3717c478bd9Sstevel@tonic-gate default:
3727c478bd9Sstevel@tonic-gate (void) showxdr_hex(authlen, "[%s]");
3737c478bd9Sstevel@tonic-gate break;
3747c478bd9Sstevel@tonic-gate }
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate
3772e3b6467Skcpoon static void
print_verif(int direction)3782e3b6467Skcpoon print_verif(int direction)
3797c478bd9Sstevel@tonic-gate {
3807c478bd9Sstevel@tonic-gate int pos, flavor, verlen;
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate pos = getxdr_pos();
3837c478bd9Sstevel@tonic-gate flavor = getxdr_long();
3847c478bd9Sstevel@tonic-gate verlen = getxdr_long();
3857c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
3862b24ab6bSSebastien Roy "Verifier : Flavor = %d (%s), len = %d bytes",
3872b24ab6bSSebastien Roy flavor, nameof_flavor(flavor), verlen);
3887c478bd9Sstevel@tonic-gate if (verlen == 0)
3897c478bd9Sstevel@tonic-gate return;
3907c478bd9Sstevel@tonic-gate
3917c478bd9Sstevel@tonic-gate switch (flavor) {
3927c478bd9Sstevel@tonic-gate case AUTH_DES:
3937c478bd9Sstevel@tonic-gate (void) showxdr_hex(8, " Timestamp = 0x%s (DES encrypted)");
3947c478bd9Sstevel@tonic-gate if (direction == CALL)
3957c478bd9Sstevel@tonic-gate (void) showxdr_hex(4,
3962b24ab6bSSebastien Roy " Window = 0x%s (DES encrypted)");
3977c478bd9Sstevel@tonic-gate else
3987c478bd9Sstevel@tonic-gate (void) showxdr_hex(4, " Nickname = 0x%s");
3997c478bd9Sstevel@tonic-gate break;
4007c478bd9Sstevel@tonic-gate
4017c478bd9Sstevel@tonic-gate /* For other flavors like AUTH_NONE, AUTH_UNIX, RPCSEC_GSS etc. */
4027c478bd9Sstevel@tonic-gate default:
4037c478bd9Sstevel@tonic-gate (void) showxdr_hex(verlen, "[%s]");
4047c478bd9Sstevel@tonic-gate break;
4057c478bd9Sstevel@tonic-gate }
4067c478bd9Sstevel@tonic-gate }
4077c478bd9Sstevel@tonic-gate
4087c478bd9Sstevel@tonic-gate struct rpcnames {
4097c478bd9Sstevel@tonic-gate int rp_prog;
4107c478bd9Sstevel@tonic-gate char *rp_name;
4117c478bd9Sstevel@tonic-gate } rpcnames[] = {
4127c478bd9Sstevel@tonic-gate 100000, "PMAP", /* Portmapper */
4137c478bd9Sstevel@tonic-gate 100001, "RSTAT", /* Remote stats */
4147c478bd9Sstevel@tonic-gate 100002, "RUSERS", /* Remote users */
4157c478bd9Sstevel@tonic-gate 100003, "NFS", /* Nfs */
4167c478bd9Sstevel@tonic-gate 100004, "NIS", /* Network Information Service */
4177c478bd9Sstevel@tonic-gate 100005, "MOUNT", /* Mount demon */
4187c478bd9Sstevel@tonic-gate 100006, "DBX", /* Remote dbx */
4197c478bd9Sstevel@tonic-gate 100007, "NISBIND", /* NIS binder */
4207c478bd9Sstevel@tonic-gate 100008, "WALL", /* Shutdown msg */
4217c478bd9Sstevel@tonic-gate 100009, "NISPASSWD", /* Yppasswd server */
4227c478bd9Sstevel@tonic-gate 100010, "ETHERSTAT", /* Ether stats */
4237c478bd9Sstevel@tonic-gate 100011, "RQUOTA", /* Disk quotas */
4247c478bd9Sstevel@tonic-gate 100012, "SPRAY", /* Spray packets */
4257c478bd9Sstevel@tonic-gate 100013, "IBM3270", /* 3270 mapper */
4267c478bd9Sstevel@tonic-gate 100014, "IBMRJE", /* RJE mapper */
4277c478bd9Sstevel@tonic-gate 100015, "SELNSVC", /* Selection service */
4287c478bd9Sstevel@tonic-gate 100016, "RDATABASE", /* Remote database access */
4297c478bd9Sstevel@tonic-gate 100017, "REX", /* Remote execution */
4307c478bd9Sstevel@tonic-gate 100018, "ALICE", /* Alice Office Automation */
4317c478bd9Sstevel@tonic-gate 100019, "SCHED", /* Scheduling service */
4327c478bd9Sstevel@tonic-gate 100020, "LLM", /* Local lock manager */
4337c478bd9Sstevel@tonic-gate 100021, "NLM", /* Network lock manager */
4347c478bd9Sstevel@tonic-gate 100022, "X25INR", /* X.25 inr protocol */
4357c478bd9Sstevel@tonic-gate 100023, "STATMON1", /* Status monitor 1 */
4367c478bd9Sstevel@tonic-gate 100024, "STATMON2", /* Status monitor 2 */
4377c478bd9Sstevel@tonic-gate 100025, "SELNLIB", /* Selection library */
4387c478bd9Sstevel@tonic-gate 100026, "BOOTPARAM", /* Boot parameters service */
4397c478bd9Sstevel@tonic-gate 100027, "MAZEPROG", /* Mazewars game */
4407c478bd9Sstevel@tonic-gate 100028, "NISUPDATE", /* NIS update */
4417c478bd9Sstevel@tonic-gate 100029, "KEYSERVE", /* Key server */
4427c478bd9Sstevel@tonic-gate 100030, "SECURECMD", /* Secure login */
4437c478bd9Sstevel@tonic-gate 100031, "NETFWDI", /* NFS net forwarder init */
4447c478bd9Sstevel@tonic-gate 100032, "NETFWDT", /* NFS net forwarder trans */
4457c478bd9Sstevel@tonic-gate 100033, "SUNLINKMAP", /* Sunlink MAP */
4467c478bd9Sstevel@tonic-gate 100034, "NETMON", /* Network monitor */
4477c478bd9Sstevel@tonic-gate 100035, "DBASE", /* Lightweight database */
4487c478bd9Sstevel@tonic-gate 100036, "PWDAUTH", /* Password authorization */
4497c478bd9Sstevel@tonic-gate 100037, "TFS", /* Translucent file svc */
4507c478bd9Sstevel@tonic-gate 100038, "NSE", /* NSE server */
4517c478bd9Sstevel@tonic-gate 100039, "NSE_ACTIVATE", /* NSE activate daemon */
4527c478bd9Sstevel@tonic-gate 100040, "SUNVIEW_HELP", /* Sunview help */
4537c478bd9Sstevel@tonic-gate 100041, "PNP", /* PNP install */
4547c478bd9Sstevel@tonic-gate 100042, "IPADDR_ALLOC", /* IP addr allocator */
4557c478bd9Sstevel@tonic-gate 100043, "FILEHANDLE", /* Show filehandle */
4567c478bd9Sstevel@tonic-gate 100044, "MVSNFS", /* MVS NFS mount */
4577c478bd9Sstevel@tonic-gate 100045, "REM_FILEOP_USER", /* Remote user file operations */
4587c478bd9Sstevel@tonic-gate 100046, "BATCH_NISUPDATE", /* Batched ypupdate */
4597c478bd9Sstevel@tonic-gate 100047, "NEM", /* Network execution mgr */
4607c478bd9Sstevel@tonic-gate 100048, "RAYTRACE_RD", /* Raytrace/mandelbrot remote daemon */
4617c478bd9Sstevel@tonic-gate 100049, "RAYTRACE_LD", /* Raytrace/mandelbrot local daemon */
4627c478bd9Sstevel@tonic-gate 100050, "REM_FILEOP_GROUP", /* Remote group file operations */
4637c478bd9Sstevel@tonic-gate 100051, "REM_FILEOP_SYSTEM", /* Remote system file operations */
4647c478bd9Sstevel@tonic-gate 100052, "REM_SYSTEM_ROLE", /* Remote system role operations */
4657c478bd9Sstevel@tonic-gate 100055, "IOADMD", /* Ioadmd */
4667c478bd9Sstevel@tonic-gate 100056, "FILEMERGE", /* Filemerge */
4677c478bd9Sstevel@tonic-gate 100057, "NAMEBIND", /* Name Binding Program */
4687c478bd9Sstevel@tonic-gate 100058, "NJE", /* Sunlink NJE */
4697c478bd9Sstevel@tonic-gate 100059, "MVSATTR", /* MVSNFS get attribute service */
4707c478bd9Sstevel@tonic-gate 100060, "RMGR", /* SunAccess/SunLink resource manager */
4717c478bd9Sstevel@tonic-gate 100061, "UIDALLOC", /* UID allocation service */
4727c478bd9Sstevel@tonic-gate 100062, "LBSERVER", /* License broker */
4737c478bd9Sstevel@tonic-gate 100063, "LBBINDER", /* NETlicense client binder */
4747c478bd9Sstevel@tonic-gate 100064, "GIDALLOC", /* GID allocation service */
4757c478bd9Sstevel@tonic-gate 100065, "SUNISAM", /* SunIsam */
4767c478bd9Sstevel@tonic-gate 100066, "RDBSRV", /* Remote Debug Server */
4777c478bd9Sstevel@tonic-gate 100067, "NETDIR", /* Network directory daemon */
4787c478bd9Sstevel@tonic-gate 100068, "CMSD", /* Network calendar program */
4797c478bd9Sstevel@tonic-gate 100069, "NISXFR", /* NIS transfer */
4807c478bd9Sstevel@tonic-gate 100070, "TIMED", /* RPC.timed */
4817c478bd9Sstevel@tonic-gate 100071, "BUGTRAQ", /* Bugtraqd */
4827c478bd9Sstevel@tonic-gate 100072, "NeFS", /* Internal use only */
4837c478bd9Sstevel@tonic-gate 100073, "BILLBOARD", /* Connectathon Billboard - NFS */
4847c478bd9Sstevel@tonic-gate 100074, "BILLBOARD", /* Connectathon Billboard - X */
4857c478bd9Sstevel@tonic-gate 100075, "SCHEDROOM", /* Sun meeting room scheduler */
4867c478bd9Sstevel@tonic-gate 100076, "AUTHNEGOTIATE", /* Authentication negotiation */
4877c478bd9Sstevel@tonic-gate 100077, "ATTRPROG", /* Database manipulation */
4887c478bd9Sstevel@tonic-gate 100080, "AUTODUMP", /* Sun consulting special */
4897c478bd9Sstevel@tonic-gate 100081, "EVENT_SVC", /* Event protocol */
4907c478bd9Sstevel@tonic-gate 100085, "ARM_PSD", /* ARM policy */
4917c478bd9Sstevel@tonic-gate 100086, "ARMTOD", /* ARM TOD */
4927c478bd9Sstevel@tonic-gate 100087, "NA.ADMIN", /* Sun (SNAG) administration agent */
4937c478bd9Sstevel@tonic-gate 100099, "PLD", /* Genesil 8.1 hot plot */
4947c478bd9Sstevel@tonic-gate 100101, "NA.EVENT", /* SNM (SunNet Manager) event dispatcher */
4957c478bd9Sstevel@tonic-gate 100102, "NA.LOGGER", /* SNM report logger */
4967c478bd9Sstevel@tonic-gate 100103, "NA.DISCOVER", /* SNM network discovery agent */
4977c478bd9Sstevel@tonic-gate 100104, "NA.SYNC", /* SNM sync interface agent */
4987c478bd9Sstevel@tonic-gate 100105, "NA.DISKINFO", /* SNM disk info agent */
4997c478bd9Sstevel@tonic-gate 100106, "NA.IOSTAT", /* SNM iostat agent */
5007c478bd9Sstevel@tonic-gate 100107, "NA.HOSTPERF", /* SNM rstat proxy agent */
5017c478bd9Sstevel@tonic-gate 100108, "NA.CONFIG", /* SNM host configuration agent */
5027c478bd9Sstevel@tonic-gate 100109, "NA.ACTIVITY", /* SNM activity daemon */
5037c478bd9Sstevel@tonic-gate 100111, "NA.LPSTAT", /* SNM printer agent */
5047c478bd9Sstevel@tonic-gate 100112, "NA.HOSTMEM", /* SNM host network memory agent */
5057c478bd9Sstevel@tonic-gate 100113, "NA.SAMPLE", /* SNM sample agent */
5067c478bd9Sstevel@tonic-gate 100114, "NA.X25", /* SNM X.25 agent */
5077c478bd9Sstevel@tonic-gate 100115, "NA.PING", /* SNM ping proxy agent */
5087c478bd9Sstevel@tonic-gate 100116, "NA.RPCNFS", /* SNM rpc and nfs agent */
5097c478bd9Sstevel@tonic-gate 100117, "NA.HOSTIF", /* SNM host interface agent */
5107c478bd9Sstevel@tonic-gate 100118, "NA.ETHERIF", /* SNM ethernet interface agent */
5117c478bd9Sstevel@tonic-gate 100119, "NA.IPPATH", /* SNM traceroute proxy agent */
5127c478bd9Sstevel@tonic-gate 100120, "NA.IPROUTES", /* SNM routing table agent */
5137c478bd9Sstevel@tonic-gate 100121, "NA.LAYERS", /* SNM protocol layers gent */
5147c478bd9Sstevel@tonic-gate 100122, "NA.SNMP", /* SNM SNMP proxy agent */
5157c478bd9Sstevel@tonic-gate 100123, "NA.TRAFFIC", /* SNM network traffic agent */
5167c478bd9Sstevel@tonic-gate 100124, "NA.DNI", /* DNI (DECnet) proxy agent */
5177c478bd9Sstevel@tonic-gate 100125, "NA.CHAT", /* IBM Channel attach proxy agent */
5187c478bd9Sstevel@tonic-gate 100126, "NA.FDDI", /* FDDI agent */
5197c478bd9Sstevel@tonic-gate 100127, "NA.FDDISMT", /* FDDI SMT proxy agent */
5207c478bd9Sstevel@tonic-gate 100128, "NA.MHS", /* MHS agent */
5217c478bd9Sstevel@tonic-gate 100130, "SNM_GRAPHER", /* SNM 3D grapher */
5227c478bd9Sstevel@tonic-gate 100132, "NA.TR", /* Token Ring agent */
5237c478bd9Sstevel@tonic-gate 100134, "NA.TOKENRING", /* Token Ring agent */
5247c478bd9Sstevel@tonic-gate 100136, "NA.FRAMERELAY", /* Frame Relay agent */
5257c478bd9Sstevel@tonic-gate 100175, "NA.SNMPTRAP", /* SNM SNMP trap daemon */
5267c478bd9Sstevel@tonic-gate 100180, "NA.MIPROUTES", /* SNM multicast routing table agent */
5277c478bd9Sstevel@tonic-gate 100201, "MVSNFSSTAT", /* MVS/NFS Memory usage statistic server */
5287c478bd9Sstevel@tonic-gate 100227, "NFS_ACL", /* NFS ACL support */
5297c478bd9Sstevel@tonic-gate 101002, "NSELINKTOOL", /* NSE link daemon */
5307c478bd9Sstevel@tonic-gate 101003, "NSELINKAPP", /* NSE link application */
5317c478bd9Sstevel@tonic-gate 110001, "GOLABEL", /* SunOS MLS */
5327c478bd9Sstevel@tonic-gate 110002, "PUC", /* SunOS MLS */
5337c478bd9Sstevel@tonic-gate 150001, "PCNFSD", /* PC passwd authorization */
5347c478bd9Sstevel@tonic-gate 150002, "TOPS", /* TOPS name mapping */
5357c478bd9Sstevel@tonic-gate 150003, "TOPS", /* TOPS external attribute storage */
5367c478bd9Sstevel@tonic-gate 150004, "TOPS", /* TOPS hierarchical file system */
5377c478bd9Sstevel@tonic-gate 150005, "TOPS", /* TOPS NFS transparency extensions */
5387c478bd9Sstevel@tonic-gate 150006, "SOLARNET_FW", /* SolarNet Framework protocol */
5397c478bd9Sstevel@tonic-gate 160001, "CM", /* Nihon Sun - Japanese Input system */
5407c478bd9Sstevel@tonic-gate 300004, "FRAME 1", /* Frame program 1 */
5417c478bd9Sstevel@tonic-gate 300009, "FRAME 2", /* Frame program 2 */
5427c478bd9Sstevel@tonic-gate 390101, "RAP", /* Legato RAP protocol */
5437c478bd9Sstevel@tonic-gate 390102, "RAPRD", /* Legato RAP resource dir protocol */
5447c478bd9Sstevel@tonic-gate 500021, "ZNS", /* Zeus Network Service */
5457c478bd9Sstevel@tonic-gate };
5467c478bd9Sstevel@tonic-gate
5472e3b6467Skcpoon int
compare(struct rpcnames * a,struct rpcnames * b)548*cd93bdd3SToomas Soome compare(struct rpcnames *a, struct rpcnames *b)
5497c478bd9Sstevel@tonic-gate {
5507c478bd9Sstevel@tonic-gate return (a->rp_prog - b->rp_prog);
5517c478bd9Sstevel@tonic-gate }
5527c478bd9Sstevel@tonic-gate
5537c478bd9Sstevel@tonic-gate char *
nameof_prog(int prog)554*cd93bdd3SToomas Soome nameof_prog(int prog)
5557c478bd9Sstevel@tonic-gate {
5567c478bd9Sstevel@tonic-gate struct rpcnames *r;
5577c478bd9Sstevel@tonic-gate struct rpcnames *bsearch();
5587c478bd9Sstevel@tonic-gate int elems = sizeof (rpcnames) / sizeof (*r);
5597c478bd9Sstevel@tonic-gate
5607c478bd9Sstevel@tonic-gate r = bsearch(&prog, rpcnames, elems, sizeof (*r), compare);
5617c478bd9Sstevel@tonic-gate if (r)
5627c478bd9Sstevel@tonic-gate return (r->rp_name);
5637c478bd9Sstevel@tonic-gate
5647c478bd9Sstevel@tonic-gate if (prog >= 0x40000000 && prog <= 0x5fffffff)
5657c478bd9Sstevel@tonic-gate return ("transient");
5667c478bd9Sstevel@tonic-gate
5677c478bd9Sstevel@tonic-gate return ("?");
5687c478bd9Sstevel@tonic-gate }
5697c478bd9Sstevel@tonic-gate
5707c478bd9Sstevel@tonic-gate char *
nameof_astat(int status)571*cd93bdd3SToomas Soome nameof_astat(int status)
5727c478bd9Sstevel@tonic-gate {
5737c478bd9Sstevel@tonic-gate switch (status) {
5747c478bd9Sstevel@tonic-gate case SUCCESS : return ("Success");
5757c478bd9Sstevel@tonic-gate case PROG_UNAVAIL : return ("Program unavailable");
5767c478bd9Sstevel@tonic-gate case PROG_MISMATCH: return ("Program number mismatch");
5777c478bd9Sstevel@tonic-gate case PROC_UNAVAIL : return ("Procedure unavailable");
5787c478bd9Sstevel@tonic-gate case GARBAGE_ARGS : return ("Garbage arguments");
5797c478bd9Sstevel@tonic-gate case SYSTEM_ERR : return ("System error");
5807c478bd9Sstevel@tonic-gate default: return ("unknown");
5817c478bd9Sstevel@tonic-gate }
5827c478bd9Sstevel@tonic-gate }
5837c478bd9Sstevel@tonic-gate
5847c478bd9Sstevel@tonic-gate char *
nameof_why(int why)585*cd93bdd3SToomas Soome nameof_why(int why)
5867c478bd9Sstevel@tonic-gate {
5877c478bd9Sstevel@tonic-gate switch (why) {
5887c478bd9Sstevel@tonic-gate case AUTH_BADCRED: return ("bogus credentials (seal broken)");
5897c478bd9Sstevel@tonic-gate case AUTH_REJECTEDCRED: return ("client should begin new session");
5907c478bd9Sstevel@tonic-gate case AUTH_BADVERF: return ("bogus verifier (seal broken)");
5917c478bd9Sstevel@tonic-gate case AUTH_REJECTEDVERF: return ("verifier expired or was replayed");
5927c478bd9Sstevel@tonic-gate case AUTH_TOOWEAK: return ("too weak");
5937c478bd9Sstevel@tonic-gate case AUTH_INVALIDRESP: return ("bogus response verifier");
5947c478bd9Sstevel@tonic-gate case AUTH_TIMEEXPIRE: return ("time of credential expired");
5957c478bd9Sstevel@tonic-gate case AUTH_TKT_FILE: return ("something wrong with ticket file");
5967c478bd9Sstevel@tonic-gate case AUTH_DECODE: return ("can't decode authenticator");
5977c478bd9Sstevel@tonic-gate case AUTH_NET_ADDR: return ("net address in ticket wrong");
5987c478bd9Sstevel@tonic-gate case RPCSEC_GSS_NOCRED: return ("no credentials for user");
5997c478bd9Sstevel@tonic-gate case RPCSEC_GSS_FAILED: return ("GSS failure, credentials deleted");
6007c478bd9Sstevel@tonic-gate case AUTH_FAILED:
6017c478bd9Sstevel@tonic-gate default:
6027c478bd9Sstevel@tonic-gate return ("unknown reason");
6037c478bd9Sstevel@tonic-gate }
6047c478bd9Sstevel@tonic-gate }
6057c478bd9Sstevel@tonic-gate
6062e3b6467Skcpoon static void
rpc_detail_reply(int flags,int xid,struct cache_struct * x,char * data,int len)6072e3b6467Skcpoon rpc_detail_reply(int flags, int xid, struct cache_struct *x, char *data,
6082e3b6467Skcpoon int len)
6097c478bd9Sstevel@tonic-gate {
6107c478bd9Sstevel@tonic-gate int status;
6117c478bd9Sstevel@tonic-gate int astat, rstat, why;
6127c478bd9Sstevel@tonic-gate int pos;
6137c478bd9Sstevel@tonic-gate
6147c478bd9Sstevel@tonic-gate if (x) {
6157c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
6162b24ab6bSSebastien Roy "This is a reply to frame %d",
6172b24ab6bSSebastien Roy x->xid_frame);
6187c478bd9Sstevel@tonic-gate }
6197c478bd9Sstevel@tonic-gate pos = getxdr_pos();
6207c478bd9Sstevel@tonic-gate status = getxdr_long();
6217c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
6222b24ab6bSSebastien Roy "Status = %d (%s)",
6232b24ab6bSSebastien Roy status, status ? "Denied" : "Accepted");
6247c478bd9Sstevel@tonic-gate
6257c478bd9Sstevel@tonic-gate switch (status) {
6267c478bd9Sstevel@tonic-gate case MSG_ACCEPTED:
6277c478bd9Sstevel@tonic-gate print_verif(REPLY);
6287c478bd9Sstevel@tonic-gate pos = getxdr_pos();
6297c478bd9Sstevel@tonic-gate astat = getxdr_long();
6307c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
6312b24ab6bSSebastien Roy "Accept status = %d (%s)",
6322b24ab6bSSebastien Roy astat, nameof_astat(astat));
6337c478bd9Sstevel@tonic-gate
6347c478bd9Sstevel@tonic-gate switch (astat) {
6357c478bd9Sstevel@tonic-gate case SUCCESS:
6367c478bd9Sstevel@tonic-gate if (x) {
6377c478bd9Sstevel@tonic-gate show_trailer();
6387c478bd9Sstevel@tonic-gate protoprint(flags, REPLY, xid,
6392b24ab6bSSebastien Roy x->xid_prog, x->xid_vers, x->xid_proc,
6402b24ab6bSSebastien Roy data, len);
6417c478bd9Sstevel@tonic-gate }
6427c478bd9Sstevel@tonic-gate break;
6437c478bd9Sstevel@tonic-gate case PROG_UNAVAIL :
6447c478bd9Sstevel@tonic-gate break;
6457c478bd9Sstevel@tonic-gate case PROG_MISMATCH:
6467c478bd9Sstevel@tonic-gate case PROC_UNAVAIL :
6477c478bd9Sstevel@tonic-gate showxdr_long(" Low = %d");
6487c478bd9Sstevel@tonic-gate showxdr_long(" High = %d");
6497c478bd9Sstevel@tonic-gate break;
6507c478bd9Sstevel@tonic-gate case GARBAGE_ARGS:
6517c478bd9Sstevel@tonic-gate case SYSTEM_ERR:
6527c478bd9Sstevel@tonic-gate default:
6537c478bd9Sstevel@tonic-gate ;
6547c478bd9Sstevel@tonic-gate }
6557c478bd9Sstevel@tonic-gate
6567c478bd9Sstevel@tonic-gate break;
6577c478bd9Sstevel@tonic-gate
6587c478bd9Sstevel@tonic-gate case MSG_DENIED:
6597c478bd9Sstevel@tonic-gate pos = getxdr_pos();
6607c478bd9Sstevel@tonic-gate rstat = getxdr_long();
6617c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
6622b24ab6bSSebastien Roy "Reject status = %d (%s)",
6632b24ab6bSSebastien Roy rstat,
6642b24ab6bSSebastien Roy rstat ? "can't authenticate"
6652b24ab6bSSebastien Roy : "version mismatch");
6667c478bd9Sstevel@tonic-gate
6677c478bd9Sstevel@tonic-gate switch (rstat) {
6687c478bd9Sstevel@tonic-gate case RPC_MISMATCH:
6697c478bd9Sstevel@tonic-gate showxdr_long(" Low = %d");
6707c478bd9Sstevel@tonic-gate showxdr_long(" High = %d");
6717c478bd9Sstevel@tonic-gate break;
6727c478bd9Sstevel@tonic-gate case AUTH_ERROR:
6737c478bd9Sstevel@tonic-gate why = getxdr_u_long();
6747c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()),
6752b24ab6bSSebastien Roy " Why = %d (%s)",
6762b24ab6bSSebastien Roy why, nameof_why(why));
6777c478bd9Sstevel@tonic-gate break;
6787c478bd9Sstevel@tonic-gate }
6797c478bd9Sstevel@tonic-gate break;
6807c478bd9Sstevel@tonic-gate }
6817c478bd9Sstevel@tonic-gate }
6827c478bd9Sstevel@tonic-gate
6837c478bd9Sstevel@tonic-gate /*
6847c478bd9Sstevel@tonic-gate * Return true if this is a valid RPC packet
6857c478bd9Sstevel@tonic-gate */
6862e3b6467Skcpoon int
valid_rpc(char * rpc,int rpclen)6872e3b6467Skcpoon valid_rpc(char *rpc, int rpclen)
6887c478bd9Sstevel@tonic-gate {
6897c478bd9Sstevel@tonic-gate XDR xdrm;
6907c478bd9Sstevel@tonic-gate struct rpc_msg msg;
6917c478bd9Sstevel@tonic-gate
6927c478bd9Sstevel@tonic-gate if (rpclen < 12)
6937c478bd9Sstevel@tonic-gate return (0);
6947c478bd9Sstevel@tonic-gate
6957c478bd9Sstevel@tonic-gate xdrmem_create(&xdrm, rpc, rpclen, XDR_DECODE);
6967c478bd9Sstevel@tonic-gate if (xdr_u_int(&xdrm, &msg.rm_xid) &&
6977c478bd9Sstevel@tonic-gate xdr_u_int(&xdrm, (uint_t *)&msg.rm_direction)) {
6987c478bd9Sstevel@tonic-gate switch (msg.rm_direction) {
6997c478bd9Sstevel@tonic-gate case CALL:
7007c478bd9Sstevel@tonic-gate if (xdr_rpcvers(&xdrm, &msg.rm_call.cb_rpcvers) &&
7017c478bd9Sstevel@tonic-gate msg.rm_call.cb_rpcvers == 2)
7027c478bd9Sstevel@tonic-gate return (1);
7037c478bd9Sstevel@tonic-gate break;
7047c478bd9Sstevel@tonic-gate case REPLY:
7057c478bd9Sstevel@tonic-gate if (xdr_u_int(&xdrm,
7062b24ab6bSSebastien Roy (uint_t *)&msg.rm_reply.rp_stat) &&
7077c478bd9Sstevel@tonic-gate (msg.rm_reply.rp_stat == MSG_ACCEPTED ||
7087c478bd9Sstevel@tonic-gate msg.rm_reply.rp_stat == MSG_DENIED))
7097c478bd9Sstevel@tonic-gate return (1);
7107c478bd9Sstevel@tonic-gate break;
7117c478bd9Sstevel@tonic-gate }
7127c478bd9Sstevel@tonic-gate }
7137c478bd9Sstevel@tonic-gate
7147c478bd9Sstevel@tonic-gate return (0);
7157c478bd9Sstevel@tonic-gate }
7167c478bd9Sstevel@tonic-gate
7177c478bd9Sstevel@tonic-gate struct cache_struct *xcpfirst = &xid_cache[0];
7187c478bd9Sstevel@tonic-gate struct cache_struct *xcp = &xid_cache[0];
7197c478bd9Sstevel@tonic-gate struct cache_struct *xcplast = &xid_cache[XID_CACHE_SIZE - 1];
7207c478bd9Sstevel@tonic-gate
7217c478bd9Sstevel@tonic-gate struct cache_struct *
find_xid(ulong_t xid)722*cd93bdd3SToomas Soome find_xid(ulong_t xid)
7237c478bd9Sstevel@tonic-gate {
7247c478bd9Sstevel@tonic-gate struct cache_struct *x;
7257c478bd9Sstevel@tonic-gate
7267c478bd9Sstevel@tonic-gate for (x = xcp; x >= xcpfirst; x--)
7277c478bd9Sstevel@tonic-gate if (x->xid_num == xid)
7287c478bd9Sstevel@tonic-gate return (x);
7297c478bd9Sstevel@tonic-gate for (x = xcplast; x > xcp; x--)
7307c478bd9Sstevel@tonic-gate if (x->xid_num == xid)
7317c478bd9Sstevel@tonic-gate return (x);
7327c478bd9Sstevel@tonic-gate return (NULL);
7337c478bd9Sstevel@tonic-gate }
7347c478bd9Sstevel@tonic-gate
7352e3b6467Skcpoon static void
stash_xid(ulong_t xid,int frame,int prog,int vers,int proc)7362e3b6467Skcpoon stash_xid(ulong_t xid, int frame, int prog, int vers, int proc)
7377c478bd9Sstevel@tonic-gate {
7387c478bd9Sstevel@tonic-gate struct cache_struct *x;
7397c478bd9Sstevel@tonic-gate
7407c478bd9Sstevel@tonic-gate x = find_xid(xid);
7417c478bd9Sstevel@tonic-gate if (x == NULL) {
7427c478bd9Sstevel@tonic-gate x = xcp++;
7437c478bd9Sstevel@tonic-gate if (xcp > xcplast)
7447c478bd9Sstevel@tonic-gate xcp = xcpfirst;
7457c478bd9Sstevel@tonic-gate x->xid_num = xid;
7467c478bd9Sstevel@tonic-gate x->xid_frame = frame;
7477c478bd9Sstevel@tonic-gate }
7487c478bd9Sstevel@tonic-gate x->xid_prog = prog;
7497c478bd9Sstevel@tonic-gate x->xid_vers = vers;
7507c478bd9Sstevel@tonic-gate x->xid_proc = proc;
7517c478bd9Sstevel@tonic-gate x->xid_gss_proc = RPCSEC_GSS_DATA;
7527c478bd9Sstevel@tonic-gate x->xid_gss_service = rpc_gss_svc_default;
7537c478bd9Sstevel@tonic-gate }
7547c478bd9Sstevel@tonic-gate
7557c478bd9Sstevel@tonic-gate void
check_retransmit(char * line,ulong_t xid)756*cd93bdd3SToomas Soome check_retransmit(char *line, ulong_t xid)
7577c478bd9Sstevel@tonic-gate {
7587c478bd9Sstevel@tonic-gate struct cache_struct *x;
7597c478bd9Sstevel@tonic-gate extern int pi_frame;
7607c478bd9Sstevel@tonic-gate
7617c478bd9Sstevel@tonic-gate x = find_xid(xid);
7627c478bd9Sstevel@tonic-gate if (x && x->xid_frame != pi_frame)
7637c478bd9Sstevel@tonic-gate (void) strcat(line, " (retransmit)");
7647c478bd9Sstevel@tonic-gate }
765