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 5*2b24ab6bSSebastien Roy * Common Development and Distribution License (the "License"). 6*2b24ab6bSSebastien 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 /* 22*2b24ab6bSSebastien 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); 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #define LAST_FRAG ((ulong_t)1 << 31) 667c478bd9Sstevel@tonic-gate 672e3b6467Skcpoon int 682e3b6467Skcpoon interpret_rpc(int flags, char *rpc, int fraglen, int type) 697c478bd9Sstevel@tonic-gate { 707c478bd9Sstevel@tonic-gate ulong_t xid; 717c478bd9Sstevel@tonic-gate int direction; 727c478bd9Sstevel@tonic-gate struct cache_struct *x; 737c478bd9Sstevel@tonic-gate int rpcvers, prog, vers, proc; 747c478bd9Sstevel@tonic-gate int status, astat, rstat, why; 757c478bd9Sstevel@tonic-gate char *lp; 767c478bd9Sstevel@tonic-gate unsigned recmark; 777c478bd9Sstevel@tonic-gate int markpos; 787c478bd9Sstevel@tonic-gate extern int pi_frame; 797c478bd9Sstevel@tonic-gate int lo, hi; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate xdr_init(rpc, fraglen); 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) { 847c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) 857c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), 867c478bd9Sstevel@tonic-gate "---- short frame ---"); 877c478bd9Sstevel@tonic-gate return (fraglen); 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate if (type == IPPROTO_TCP) { /* record mark */ 917c478bd9Sstevel@tonic-gate markpos = getxdr_pos(); 927c478bd9Sstevel@tonic-gate recmark = getxdr_long(); 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate xid = getxdr_u_long(); 967c478bd9Sstevel@tonic-gate direction = getxdr_long(); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate if (direction == CALL) { 997c478bd9Sstevel@tonic-gate rpcvers = getxdr_long(); 1007c478bd9Sstevel@tonic-gate pos = getxdr_pos(); 1017c478bd9Sstevel@tonic-gate prog = getxdr_long(); 1027c478bd9Sstevel@tonic-gate vers = getxdr_long(); 1037c478bd9Sstevel@tonic-gate proc = getxdr_long(); 1047c478bd9Sstevel@tonic-gate stash_xid(xid, pi_frame, prog, vers, proc); 105*2b24ab6bSSebastien Roy if (!(flags & (F_SUM | F_DTAIL))) { 1067c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc, 1077c478bd9Sstevel@tonic-gate rpc, fraglen); 108*2b24ab6bSSebastien Roy } 1097c478bd9Sstevel@tonic-gate } else { 1107c478bd9Sstevel@tonic-gate x = find_xid(xid); 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate if (flags & F_SUM) { 1147c478bd9Sstevel@tonic-gate switch (direction) { 1157c478bd9Sstevel@tonic-gate case CALL: 1167c478bd9Sstevel@tonic-gate (void) sprintf(get_sum_line(), 1177c478bd9Sstevel@tonic-gate "RPC C XID=%lu PROG=%d (%s) VERS=%d PROC=%d", 1187c478bd9Sstevel@tonic-gate xid, 1197c478bd9Sstevel@tonic-gate prog, nameof_prog(prog), 1207c478bd9Sstevel@tonic-gate vers, proc); 1217c478bd9Sstevel@tonic-gate if (getxdr_long() == RPCSEC_GSS) { /* Cred auth type */ 1227c478bd9Sstevel@tonic-gate extract_rpcsec_gss_cred_info(xid); 1237c478bd9Sstevel@tonic-gate /* RPCSEC_GSS cred auth data */ 1247c478bd9Sstevel@tonic-gate } else { 1257c478bd9Sstevel@tonic-gate xdr_skip(getxdr_long()); 1267c478bd9Sstevel@tonic-gate /* non RPCSEC_GSS cred auth data */ 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate xdr_skip(4); /* Verf auth type */ 1297c478bd9Sstevel@tonic-gate xdr_skip(RNDUP(getxdr_long())); /* Verf auth data */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc, 1327c478bd9Sstevel@tonic-gate rpc, fraglen); 1337c478bd9Sstevel@tonic-gate break; 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate case REPLY: 1367c478bd9Sstevel@tonic-gate lp = get_sum_line(); 1377c478bd9Sstevel@tonic-gate if (x == NULL) 1387c478bd9Sstevel@tonic-gate (void) sprintf(lp, "RPC R XID=%lu", xid); 1397c478bd9Sstevel@tonic-gate else 1407c478bd9Sstevel@tonic-gate (void) sprintf(lp, "RPC R (#%d) XID=%lu", 1417c478bd9Sstevel@tonic-gate x->xid_frame, xid); 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate lp += strlen(lp); 1447c478bd9Sstevel@tonic-gate status = getxdr_long(); 1457c478bd9Sstevel@tonic-gate switch (status) { 1467c478bd9Sstevel@tonic-gate case MSG_ACCEPTED: 1477c478bd9Sstevel@tonic-gate /* eat flavor and verifier */ 1487c478bd9Sstevel@tonic-gate (void) getxdr_long(); 1497c478bd9Sstevel@tonic-gate xdr_skip(RNDUP(getxdr_long())); 1507c478bd9Sstevel@tonic-gate astat = getxdr_long(); 1517c478bd9Sstevel@tonic-gate (void) sprintf(lp, " %s", 1527c478bd9Sstevel@tonic-gate nameof_astat(astat)); 1537c478bd9Sstevel@tonic-gate lp += strlen(lp); 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate switch (astat) { 1567c478bd9Sstevel@tonic-gate case SUCCESS: 1577c478bd9Sstevel@tonic-gate if (x) { 1587c478bd9Sstevel@tonic-gate protoprint(flags, REPLY, 1597c478bd9Sstevel@tonic-gate xid, 1607c478bd9Sstevel@tonic-gate x->xid_prog, 1617c478bd9Sstevel@tonic-gate x->xid_vers, 1627c478bd9Sstevel@tonic-gate x->xid_proc, 1637c478bd9Sstevel@tonic-gate rpc, fraglen); 1647c478bd9Sstevel@tonic-gate } 1657c478bd9Sstevel@tonic-gate break; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate case PROG_UNAVAIL : 1687c478bd9Sstevel@tonic-gate case PROG_MISMATCH: 1697c478bd9Sstevel@tonic-gate case PROC_UNAVAIL : 1707c478bd9Sstevel@tonic-gate lo = getxdr_long(); 1717c478bd9Sstevel@tonic-gate hi = getxdr_long(); 1727c478bd9Sstevel@tonic-gate (void) sprintf(lp, 1737c478bd9Sstevel@tonic-gate " (low=%d, high=%d)", 1747c478bd9Sstevel@tonic-gate lo, hi); 1757c478bd9Sstevel@tonic-gate break; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate case GARBAGE_ARGS: 1787c478bd9Sstevel@tonic-gate case SYSTEM_ERR: 1797c478bd9Sstevel@tonic-gate default: 1807c478bd9Sstevel@tonic-gate ; 1817c478bd9Sstevel@tonic-gate } 1827c478bd9Sstevel@tonic-gate break; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate case MSG_DENIED: 1857c478bd9Sstevel@tonic-gate rstat = getxdr_long(); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate switch (rstat) { 1887c478bd9Sstevel@tonic-gate case RPC_MISMATCH: 1897c478bd9Sstevel@tonic-gate lo = getxdr_long(); 1907c478bd9Sstevel@tonic-gate hi = getxdr_long(); 1917c478bd9Sstevel@tonic-gate (void) sprintf(lp, 1927c478bd9Sstevel@tonic-gate " Vers mismatch (low=%d, high=%d)", 1937c478bd9Sstevel@tonic-gate lo, hi); 1947c478bd9Sstevel@tonic-gate break; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate case AUTH_ERROR: 1977c478bd9Sstevel@tonic-gate why = getxdr_u_long(); 1987c478bd9Sstevel@tonic-gate (void) sprintf(lp, 1997c478bd9Sstevel@tonic-gate " Can't authenticate (%s)", 2007c478bd9Sstevel@tonic-gate nameof_why(why)); 2017c478bd9Sstevel@tonic-gate break; 2027c478bd9Sstevel@tonic-gate } 2037c478bd9Sstevel@tonic-gate } 2047c478bd9Sstevel@tonic-gate break; 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) { 2097c478bd9Sstevel@tonic-gate show_header("RPC: ", "SUN RPC Header", fraglen); 2107c478bd9Sstevel@tonic-gate show_space(); 2117c478bd9Sstevel@tonic-gate if (type == IPPROTO_TCP) { /* record mark */ 2127c478bd9Sstevel@tonic-gate (void) sprintf(get_line(markpos, markpos+4), 2137c478bd9Sstevel@tonic-gate "Record Mark: %s fragment, length = %d", 2147c478bd9Sstevel@tonic-gate recmark & LAST_FRAG ? "last" : "", 2157c478bd9Sstevel@tonic-gate recmark & ~LAST_FRAG); 2167c478bd9Sstevel@tonic-gate } 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), 2197c478bd9Sstevel@tonic-gate "Transaction id = %lu", 2207c478bd9Sstevel@tonic-gate xid); 2217c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), 2227c478bd9Sstevel@tonic-gate "Type = %d (%s)", 2237c478bd9Sstevel@tonic-gate direction, 2247c478bd9Sstevel@tonic-gate direction == CALL ? "Call":"Reply"); 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate switch (direction) { 2277c478bd9Sstevel@tonic-gate case CALL: 2287c478bd9Sstevel@tonic-gate rpc_detail_call(flags, xid, rpcvers, 2297c478bd9Sstevel@tonic-gate prog, vers, proc, rpc, fraglen); 2307c478bd9Sstevel@tonic-gate break; 2317c478bd9Sstevel@tonic-gate case REPLY: 2327c478bd9Sstevel@tonic-gate rpc_detail_reply(flags, xid, x, rpc, fraglen); 2337c478bd9Sstevel@tonic-gate break; 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate } 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate return (fraglen); 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate 2402e3b6467Skcpoon static void 2412e3b6467Skcpoon rpc_detail_call(int flags, int xid, int rpcvers, int prog, int vers, int proc, 2422e3b6467Skcpoon char *data, int len) 2437c478bd9Sstevel@tonic-gate { 2447c478bd9Sstevel@tonic-gate char *nameof_flavor(); 2457c478bd9Sstevel@tonic-gate char *nameof_prog(); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 2487c478bd9Sstevel@tonic-gate "RPC version = %d", 2497c478bd9Sstevel@tonic-gate rpcvers); 2507c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 2517c478bd9Sstevel@tonic-gate "Program = %d (%s), version = %d, procedure = %d", 2527c478bd9Sstevel@tonic-gate prog, nameof_prog(prog), vers, proc); 2537c478bd9Sstevel@tonic-gate print_creds(xid); 2547c478bd9Sstevel@tonic-gate print_verif(CALL); 2557c478bd9Sstevel@tonic-gate show_trailer(); 2567c478bd9Sstevel@tonic-gate protoprint(flags, CALL, xid, prog, vers, proc, data, len); 2577c478bd9Sstevel@tonic-gate } 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate char * 2607c478bd9Sstevel@tonic-gate nameof_flavor(flavor) 2617c478bd9Sstevel@tonic-gate 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 * 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 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()), 3147c478bd9Sstevel@tonic-gate "Credentials: Flavor = %d (%s), len = %d bytes", 3157c478bd9Sstevel@tonic-gate 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()), 3277c478bd9Sstevel@tonic-gate " Uid = %d, Gid = %d", 3287c478bd9Sstevel@tonic-gate 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()), 3477c478bd9Sstevel@tonic-gate " Name kind = %d (%s)", 3487c478bd9Sstevel@tonic-gate namekind, 3497c478bd9Sstevel@tonic-gate namekind == ADN_FULLNAME ? 3507c478bd9Sstevel@tonic-gate "fullname" : "nickname"); 3517c478bd9Sstevel@tonic-gate switch (namekind) { 3527c478bd9Sstevel@tonic-gate case ADN_FULLNAME: 3537c478bd9Sstevel@tonic-gate (void) showxdr_string(64, 3547c478bd9Sstevel@tonic-gate " Network name = %s"); 3557c478bd9Sstevel@tonic-gate (void) showxdr_hex(8, 3567c478bd9Sstevel@tonic-gate " Conversation key = 0x%s (DES encrypted)"); 3577c478bd9Sstevel@tonic-gate (void) showxdr_hex(4, 3587c478bd9Sstevel@tonic-gate " Window = 0x%s (DES encrypted)"); 3597c478bd9Sstevel@tonic-gate break; 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate case ADN_NICKNAME: 3627c478bd9Sstevel@tonic-gate (void) showxdr_hex(4, " Nickname = 0x%s"); 3637c478bd9Sstevel@tonic-gate break; 3647c478bd9Sstevel@tonic-gate }; 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 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()), 3867c478bd9Sstevel@tonic-gate "Verifier : Flavor = %d (%s), len = %d bytes", 3877c478bd9Sstevel@tonic-gate 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, 3967c478bd9Sstevel@tonic-gate " 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 5487c478bd9Sstevel@tonic-gate compare(a, b) 5497c478bd9Sstevel@tonic-gate register struct rpcnames *a, *b; 5507c478bd9Sstevel@tonic-gate { 5517c478bd9Sstevel@tonic-gate return (a->rp_prog - b->rp_prog); 5527c478bd9Sstevel@tonic-gate } 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate char * 5557c478bd9Sstevel@tonic-gate nameof_prog(prog) 5567c478bd9Sstevel@tonic-gate int prog; 5577c478bd9Sstevel@tonic-gate { 5587c478bd9Sstevel@tonic-gate struct rpcnames *r; 5597c478bd9Sstevel@tonic-gate struct rpcnames *bsearch(); 5607c478bd9Sstevel@tonic-gate int elems = sizeof (rpcnames) / sizeof (*r); 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate r = bsearch(&prog, rpcnames, elems, sizeof (*r), compare); 5637c478bd9Sstevel@tonic-gate if (r) 5647c478bd9Sstevel@tonic-gate return (r->rp_name); 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate if (prog >= 0x40000000 && prog <= 0x5fffffff) 5677c478bd9Sstevel@tonic-gate return ("transient"); 5687c478bd9Sstevel@tonic-gate 5697c478bd9Sstevel@tonic-gate return ("?"); 5707c478bd9Sstevel@tonic-gate } 5717c478bd9Sstevel@tonic-gate 5727c478bd9Sstevel@tonic-gate char * 5737c478bd9Sstevel@tonic-gate nameof_astat(status) 5747c478bd9Sstevel@tonic-gate int status; 5757c478bd9Sstevel@tonic-gate { 5767c478bd9Sstevel@tonic-gate switch (status) { 5777c478bd9Sstevel@tonic-gate case SUCCESS : return ("Success"); 5787c478bd9Sstevel@tonic-gate case PROG_UNAVAIL : return ("Program unavailable"); 5797c478bd9Sstevel@tonic-gate case PROG_MISMATCH: return ("Program number mismatch"); 5807c478bd9Sstevel@tonic-gate case PROC_UNAVAIL : return ("Procedure unavailable"); 5817c478bd9Sstevel@tonic-gate case GARBAGE_ARGS : return ("Garbage arguments"); 5827c478bd9Sstevel@tonic-gate case SYSTEM_ERR : return ("System error"); 5837c478bd9Sstevel@tonic-gate default: return ("unknown"); 5847c478bd9Sstevel@tonic-gate } 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate char * 5887c478bd9Sstevel@tonic-gate nameof_why(why) 5897c478bd9Sstevel@tonic-gate int why; 5907c478bd9Sstevel@tonic-gate { 5917c478bd9Sstevel@tonic-gate switch (why) { 5927c478bd9Sstevel@tonic-gate case AUTH_BADCRED: return ("bogus credentials (seal broken)"); 5937c478bd9Sstevel@tonic-gate case AUTH_REJECTEDCRED: return ("client should begin new session"); 5947c478bd9Sstevel@tonic-gate case AUTH_BADVERF: return ("bogus verifier (seal broken)"); 5957c478bd9Sstevel@tonic-gate case AUTH_REJECTEDVERF: return ("verifier expired or was replayed"); 5967c478bd9Sstevel@tonic-gate case AUTH_TOOWEAK: return ("too weak"); 5977c478bd9Sstevel@tonic-gate case AUTH_INVALIDRESP: return ("bogus response verifier"); 5987c478bd9Sstevel@tonic-gate case AUTH_TIMEEXPIRE: return ("time of credential expired"); 5997c478bd9Sstevel@tonic-gate case AUTH_TKT_FILE: return ("something wrong with ticket file"); 6007c478bd9Sstevel@tonic-gate case AUTH_DECODE: return ("can't decode authenticator"); 6017c478bd9Sstevel@tonic-gate case AUTH_NET_ADDR: return ("net address in ticket wrong"); 6027c478bd9Sstevel@tonic-gate case RPCSEC_GSS_NOCRED: return ("no credentials for user"); 6037c478bd9Sstevel@tonic-gate case RPCSEC_GSS_FAILED: return ("GSS failure, credentials deleted"); 6047c478bd9Sstevel@tonic-gate case AUTH_FAILED: 6057c478bd9Sstevel@tonic-gate default: 6067c478bd9Sstevel@tonic-gate return ("unknown reason"); 6077c478bd9Sstevel@tonic-gate } 6087c478bd9Sstevel@tonic-gate } 6097c478bd9Sstevel@tonic-gate 6102e3b6467Skcpoon static void 6112e3b6467Skcpoon rpc_detail_reply(int flags, int xid, struct cache_struct *x, char *data, 6122e3b6467Skcpoon int len) 6137c478bd9Sstevel@tonic-gate { 6147c478bd9Sstevel@tonic-gate int status; 6157c478bd9Sstevel@tonic-gate int astat, rstat, why; 6167c478bd9Sstevel@tonic-gate int pos; 6177c478bd9Sstevel@tonic-gate 6187c478bd9Sstevel@tonic-gate if (x) { 6197c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), 6207c478bd9Sstevel@tonic-gate "This is a reply to frame %d", 6217c478bd9Sstevel@tonic-gate x->xid_frame); 6227c478bd9Sstevel@tonic-gate } 6237c478bd9Sstevel@tonic-gate pos = getxdr_pos(); 6247c478bd9Sstevel@tonic-gate status = getxdr_long(); 6257c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 6267c478bd9Sstevel@tonic-gate "Status = %d (%s)", 6277c478bd9Sstevel@tonic-gate status, status ? "Denied" : "Accepted"); 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate switch (status) { 6307c478bd9Sstevel@tonic-gate case MSG_ACCEPTED: 6317c478bd9Sstevel@tonic-gate print_verif(REPLY); 6327c478bd9Sstevel@tonic-gate pos = getxdr_pos(); 6337c478bd9Sstevel@tonic-gate astat = getxdr_long(); 6347c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 6357c478bd9Sstevel@tonic-gate "Accept status = %d (%s)", 6367c478bd9Sstevel@tonic-gate astat, nameof_astat(astat)); 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate switch (astat) { 6397c478bd9Sstevel@tonic-gate case SUCCESS: 6407c478bd9Sstevel@tonic-gate if (x) { 6417c478bd9Sstevel@tonic-gate show_trailer(); 6427c478bd9Sstevel@tonic-gate protoprint(flags, REPLY, xid, 6437c478bd9Sstevel@tonic-gate x->xid_prog, x->xid_vers, x->xid_proc, 6447c478bd9Sstevel@tonic-gate data, len); 6457c478bd9Sstevel@tonic-gate } 6467c478bd9Sstevel@tonic-gate break; 6477c478bd9Sstevel@tonic-gate case PROG_UNAVAIL : 6487c478bd9Sstevel@tonic-gate break; 6497c478bd9Sstevel@tonic-gate case PROG_MISMATCH: 6507c478bd9Sstevel@tonic-gate case PROC_UNAVAIL : 6517c478bd9Sstevel@tonic-gate showxdr_long(" Low = %d"); 6527c478bd9Sstevel@tonic-gate showxdr_long(" High = %d"); 6537c478bd9Sstevel@tonic-gate break; 6547c478bd9Sstevel@tonic-gate case GARBAGE_ARGS: 6557c478bd9Sstevel@tonic-gate case SYSTEM_ERR: 6567c478bd9Sstevel@tonic-gate default: 6577c478bd9Sstevel@tonic-gate ; 6587c478bd9Sstevel@tonic-gate } 6597c478bd9Sstevel@tonic-gate 6607c478bd9Sstevel@tonic-gate break; 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate case MSG_DENIED: 6637c478bd9Sstevel@tonic-gate pos = getxdr_pos(); 6647c478bd9Sstevel@tonic-gate rstat = getxdr_long(); 6657c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 6667c478bd9Sstevel@tonic-gate "Reject status = %d (%s)", 6677c478bd9Sstevel@tonic-gate rstat, 6687c478bd9Sstevel@tonic-gate rstat ? "can't authenticate" 6697c478bd9Sstevel@tonic-gate : "version mismatch"); 6707c478bd9Sstevel@tonic-gate 6717c478bd9Sstevel@tonic-gate switch (rstat) { 6727c478bd9Sstevel@tonic-gate case RPC_MISMATCH: 6737c478bd9Sstevel@tonic-gate showxdr_long(" Low = %d"); 6747c478bd9Sstevel@tonic-gate showxdr_long(" High = %d"); 6757c478bd9Sstevel@tonic-gate break; 6767c478bd9Sstevel@tonic-gate case AUTH_ERROR: 6777c478bd9Sstevel@tonic-gate why = getxdr_u_long(); 6787c478bd9Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), 6797c478bd9Sstevel@tonic-gate " Why = %d (%s)", 6807c478bd9Sstevel@tonic-gate why, nameof_why(why)); 6817c478bd9Sstevel@tonic-gate break; 6827c478bd9Sstevel@tonic-gate } 6837c478bd9Sstevel@tonic-gate break; 6847c478bd9Sstevel@tonic-gate } 6857c478bd9Sstevel@tonic-gate } 6867c478bd9Sstevel@tonic-gate 6877c478bd9Sstevel@tonic-gate /* 6887c478bd9Sstevel@tonic-gate * Return true if this is a valid RPC packet 6897c478bd9Sstevel@tonic-gate */ 6902e3b6467Skcpoon int 6912e3b6467Skcpoon valid_rpc(char *rpc, int rpclen) 6927c478bd9Sstevel@tonic-gate { 6937c478bd9Sstevel@tonic-gate XDR xdrm; 6947c478bd9Sstevel@tonic-gate struct rpc_msg msg; 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate if (rpclen < 12) 6977c478bd9Sstevel@tonic-gate return (0); 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate xdrmem_create(&xdrm, rpc, rpclen, XDR_DECODE); 7007c478bd9Sstevel@tonic-gate if (xdr_u_int(&xdrm, &msg.rm_xid) && 7017c478bd9Sstevel@tonic-gate xdr_u_int(&xdrm, (uint_t *)&msg.rm_direction)) { 7027c478bd9Sstevel@tonic-gate switch (msg.rm_direction) { 7037c478bd9Sstevel@tonic-gate case CALL: 7047c478bd9Sstevel@tonic-gate if (xdr_rpcvers(&xdrm, &msg.rm_call.cb_rpcvers) && 7057c478bd9Sstevel@tonic-gate msg.rm_call.cb_rpcvers == 2) 7067c478bd9Sstevel@tonic-gate return (1); 7077c478bd9Sstevel@tonic-gate break; 7087c478bd9Sstevel@tonic-gate case REPLY: 7097c478bd9Sstevel@tonic-gate if (xdr_u_int(&xdrm, 7107c478bd9Sstevel@tonic-gate (uint_t *)&msg.rm_reply.rp_stat) && 7117c478bd9Sstevel@tonic-gate (msg.rm_reply.rp_stat == MSG_ACCEPTED || 7127c478bd9Sstevel@tonic-gate msg.rm_reply.rp_stat == MSG_DENIED)) 7137c478bd9Sstevel@tonic-gate return (1); 7147c478bd9Sstevel@tonic-gate break; 7157c478bd9Sstevel@tonic-gate } 7167c478bd9Sstevel@tonic-gate } 7177c478bd9Sstevel@tonic-gate 7187c478bd9Sstevel@tonic-gate return (0); 7197c478bd9Sstevel@tonic-gate } 7207c478bd9Sstevel@tonic-gate 7217c478bd9Sstevel@tonic-gate struct cache_struct *xcpfirst = &xid_cache[0]; 7227c478bd9Sstevel@tonic-gate struct cache_struct *xcp = &xid_cache[0]; 7237c478bd9Sstevel@tonic-gate struct cache_struct *xcplast = &xid_cache[XID_CACHE_SIZE - 1]; 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate struct cache_struct * 7267c478bd9Sstevel@tonic-gate find_xid(xid) 7277c478bd9Sstevel@tonic-gate ulong_t xid; 7287c478bd9Sstevel@tonic-gate { 7297c478bd9Sstevel@tonic-gate struct cache_struct *x; 7307c478bd9Sstevel@tonic-gate 7317c478bd9Sstevel@tonic-gate for (x = xcp; x >= xcpfirst; x--) 7327c478bd9Sstevel@tonic-gate if (x->xid_num == xid) 7337c478bd9Sstevel@tonic-gate return (x); 7347c478bd9Sstevel@tonic-gate for (x = xcplast; x > xcp; x--) 7357c478bd9Sstevel@tonic-gate if (x->xid_num == xid) 7367c478bd9Sstevel@tonic-gate return (x); 7377c478bd9Sstevel@tonic-gate return (NULL); 7387c478bd9Sstevel@tonic-gate } 7397c478bd9Sstevel@tonic-gate 7402e3b6467Skcpoon static void 7412e3b6467Skcpoon stash_xid(ulong_t xid, int frame, int prog, int vers, int proc) 7427c478bd9Sstevel@tonic-gate { 7437c478bd9Sstevel@tonic-gate struct cache_struct *x; 7447c478bd9Sstevel@tonic-gate 7457c478bd9Sstevel@tonic-gate x = find_xid(xid); 7467c478bd9Sstevel@tonic-gate if (x == NULL) { 7477c478bd9Sstevel@tonic-gate x = xcp++; 7487c478bd9Sstevel@tonic-gate if (xcp > xcplast) 7497c478bd9Sstevel@tonic-gate xcp = xcpfirst; 7507c478bd9Sstevel@tonic-gate x->xid_num = xid; 7517c478bd9Sstevel@tonic-gate x->xid_frame = frame; 7527c478bd9Sstevel@tonic-gate } 7537c478bd9Sstevel@tonic-gate x->xid_prog = prog; 7547c478bd9Sstevel@tonic-gate x->xid_vers = vers; 7557c478bd9Sstevel@tonic-gate x->xid_proc = proc; 7567c478bd9Sstevel@tonic-gate x->xid_gss_proc = RPCSEC_GSS_DATA; 7577c478bd9Sstevel@tonic-gate x->xid_gss_service = rpc_gss_svc_default; 7587c478bd9Sstevel@tonic-gate } 7597c478bd9Sstevel@tonic-gate 7607c478bd9Sstevel@tonic-gate void 7617c478bd9Sstevel@tonic-gate check_retransmit(line, xid) 7627c478bd9Sstevel@tonic-gate char *line; 7637c478bd9Sstevel@tonic-gate ulong_t xid; 7647c478bd9Sstevel@tonic-gate { 7657c478bd9Sstevel@tonic-gate struct cache_struct *x; 7667c478bd9Sstevel@tonic-gate extern int pi_frame; 7677c478bd9Sstevel@tonic-gate 7687c478bd9Sstevel@tonic-gate x = find_xid(xid); 7697c478bd9Sstevel@tonic-gate if (x && x->xid_frame != pi_frame) 7707c478bd9Sstevel@tonic-gate (void) strcat(line, " (retransmit)"); 7717c478bd9Sstevel@tonic-gate } 772