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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright (c) 1991, 1998, 2001 by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate  * All rights reserved.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*bbaa8b60SDan Kruchinin /*
28*bbaa8b60SDan Kruchinin  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
29*bbaa8b60SDan Kruchinin  * Copyright (c) 2012 by Delphix. All rights reserved.
30*bbaa8b60SDan Kruchinin  */
31*bbaa8b60SDan Kruchinin 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate #include <setjmp.h>
347c478bd9Sstevel@tonic-gate #include <string.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef notdef
377c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
387c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
397c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
407c478bd9Sstevel@tonic-gate #endif /* notdef */
417c478bd9Sstevel@tonic-gate #include <rpcsvc/nlm_prot.h>
427c478bd9Sstevel@tonic-gate #include "snoop.h"
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate extern char *dlc_header;
457c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate extern void check_retransmit();
487c478bd9Sstevel@tonic-gate static void interpret_nlm_1();
497c478bd9Sstevel@tonic-gate static void interpret_nlm_3();
507c478bd9Sstevel@tonic-gate static void interpret_nlm_4();
517c478bd9Sstevel@tonic-gate static char *nameof_access();
527c478bd9Sstevel@tonic-gate static char *nameof_mode();
537c478bd9Sstevel@tonic-gate static char *nameof_stat();
547c478bd9Sstevel@tonic-gate static char *nameof_stat4();
557c478bd9Sstevel@tonic-gate static void show_cancargs();
567c478bd9Sstevel@tonic-gate static void show_cancargs4();
577c478bd9Sstevel@tonic-gate static void show_lock();
587c478bd9Sstevel@tonic-gate static void show_lock4();
597c478bd9Sstevel@tonic-gate static void show_lockargs();
607c478bd9Sstevel@tonic-gate static void show_lockargs4();
617c478bd9Sstevel@tonic-gate static void show_netobj();
627c478bd9Sstevel@tonic-gate static void show_nlm_access();
637c478bd9Sstevel@tonic-gate static void show_nlm_mode();
647c478bd9Sstevel@tonic-gate static void show_notify();
657c478bd9Sstevel@tonic-gate static void show_res();
667c478bd9Sstevel@tonic-gate static void show_res4();
677c478bd9Sstevel@tonic-gate static void show_share();
687c478bd9Sstevel@tonic-gate static void show_shareargs();
697c478bd9Sstevel@tonic-gate static void show_shareres();
707c478bd9Sstevel@tonic-gate static void show_shareres4();
717c478bd9Sstevel@tonic-gate static enum nlm_stats show_stat();
727c478bd9Sstevel@tonic-gate static enum nlm4_stats show_stat4();
737c478bd9Sstevel@tonic-gate static void show_testargs();
747c478bd9Sstevel@tonic-gate static void show_testargs4();
757c478bd9Sstevel@tonic-gate static void show_testres();
767c478bd9Sstevel@tonic-gate static void show_testres4();
777c478bd9Sstevel@tonic-gate static void show_unlockargs();
787c478bd9Sstevel@tonic-gate static void show_unlockargs4();
797c478bd9Sstevel@tonic-gate static void skip_netobj();
807c478bd9Sstevel@tonic-gate static char *sum_lock();
817c478bd9Sstevel@tonic-gate static char *sum_lock4();
827c478bd9Sstevel@tonic-gate static char *sum_netobj();
837c478bd9Sstevel@tonic-gate static char *sum_notify();
847c478bd9Sstevel@tonic-gate static char *sum_share();
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate void
interpret_nlm(flags,type,xid,vers,proc,data,len)877c478bd9Sstevel@tonic-gate interpret_nlm(flags, type, xid, vers, proc, data, len)
887c478bd9Sstevel@tonic-gate 	int flags, type, xid, vers, proc;
897c478bd9Sstevel@tonic-gate 	char *data;
907c478bd9Sstevel@tonic-gate 	int len;
917c478bd9Sstevel@tonic-gate {
927c478bd9Sstevel@tonic-gate 	switch (vers) {
937c478bd9Sstevel@tonic-gate 	case 1:	interpret_nlm_1(flags, type, xid, vers, proc, data, len);
947c478bd9Sstevel@tonic-gate 		break;
957c478bd9Sstevel@tonic-gate 	case 3:	interpret_nlm_3(flags, type, xid, vers, proc, data, len);
967c478bd9Sstevel@tonic-gate 		break;
977c478bd9Sstevel@tonic-gate 	case 4:	interpret_nlm_4(flags, type, xid, vers, proc, data, len);
987c478bd9Sstevel@tonic-gate 		break;
997c478bd9Sstevel@tonic-gate 	}
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /* ------------  V E R S I O N   1  ---------------------------------- */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate static char *procnames_short_1[] = {
1067c478bd9Sstevel@tonic-gate 	"Null1",	/* 0 */
1077c478bd9Sstevel@tonic-gate 	"TEST1",	/* 1 */
1087c478bd9Sstevel@tonic-gate 	"LOCK1",	/* 2 */
1097c478bd9Sstevel@tonic-gate 	"CANCEL1",	/* 3 */
1107c478bd9Sstevel@tonic-gate 	"UNLOCK1",	/* 4 */
1117c478bd9Sstevel@tonic-gate 	"GRANTED1",	/* 5 */
1127c478bd9Sstevel@tonic-gate 	"TEST MSG1",	/* 6 */
1137c478bd9Sstevel@tonic-gate 	"LOCK MSG1",	/* 7 */
1147c478bd9Sstevel@tonic-gate 	"CANCEL MSG1",	/* 8 */
1157c478bd9Sstevel@tonic-gate 	"UNLOCK MSG1",	/* 9 */
1167c478bd9Sstevel@tonic-gate 	"GRANTED MSG1",	/* 10 */
1177c478bd9Sstevel@tonic-gate 	"TEST RES1",	/* 11 */
1187c478bd9Sstevel@tonic-gate 	"LOCK RES1",	/* 12 */
1197c478bd9Sstevel@tonic-gate 	"CANCEL RES1",	/* 13 */
1207c478bd9Sstevel@tonic-gate 	"UNLOCK RES1",	/* 14 */
1217c478bd9Sstevel@tonic-gate 	"GRANTED RES1",	/* 15 */
1227c478bd9Sstevel@tonic-gate };
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate static char *procnames_long_1[] = {
1257c478bd9Sstevel@tonic-gate 	"Null procedure",	/* 0 */
1267c478bd9Sstevel@tonic-gate 	"Test",			/* 1 */
1277c478bd9Sstevel@tonic-gate 	"Lock",			/* 2 */
1287c478bd9Sstevel@tonic-gate 	"Cancel",		/* 3 */
1297c478bd9Sstevel@tonic-gate 	"Unlock",		/* 4 */
1307c478bd9Sstevel@tonic-gate 	"Granted",		/* 5 */
1317c478bd9Sstevel@tonic-gate 	"Test message",		/* 6 */
1327c478bd9Sstevel@tonic-gate 	"Lock message",		/* 7 */
1337c478bd9Sstevel@tonic-gate 	"Cancel message",	/* 8 */
1347c478bd9Sstevel@tonic-gate 	"Unlock message",	/* 9 */
1357c478bd9Sstevel@tonic-gate 	"Granted message",	/* 10 */
1367c478bd9Sstevel@tonic-gate 	"Test result",		/* 11 */
1377c478bd9Sstevel@tonic-gate 	"Lock result",		/* 12 */
1387c478bd9Sstevel@tonic-gate 	"Cancel result",	/* 13 */
1397c478bd9Sstevel@tonic-gate 	"Unlock result",	/* 14 */
1407c478bd9Sstevel@tonic-gate 	"Granted result",	/* 15 */
1417c478bd9Sstevel@tonic-gate };
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /* Highest procedure number that officially belongs to version 1. */
1447c478bd9Sstevel@tonic-gate #define	MAXPROC_1	15
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /* ARGSUSED */
1477c478bd9Sstevel@tonic-gate static void
interpret_nlm_1(flags,type,xid,vers,proc,data,len)1487c478bd9Sstevel@tonic-gate interpret_nlm_1(flags, type, xid, vers, proc, data, len)
1497c478bd9Sstevel@tonic-gate 	int flags, type, xid, vers, proc;
1507c478bd9Sstevel@tonic-gate 	char *data;
1517c478bd9Sstevel@tonic-gate 	int len;
1527c478bd9Sstevel@tonic-gate {
1537c478bd9Sstevel@tonic-gate 	char *line;
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_1)
1567c478bd9Sstevel@tonic-gate 		return;
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
1597c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
1607c478bd9Sstevel@tonic-gate 			return;
1617c478bd9Sstevel@tonic-gate 		}
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 		line = get_sum_line();
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 		if (type == CALL) {
1667c478bd9Sstevel@tonic-gate 			(void) sprintf(line,
1677c478bd9Sstevel@tonic-gate 				"NLM C %s",
1687c478bd9Sstevel@tonic-gate 				procnames_short_1[proc]);
1697c478bd9Sstevel@tonic-gate 			line += strlen(line);
1707c478bd9Sstevel@tonic-gate 			switch (proc) {
1717c478bd9Sstevel@tonic-gate 			case NLM_TEST:
1727c478bd9Sstevel@tonic-gate 			case NLM_GRANTED:
1737c478bd9Sstevel@tonic-gate 			case NLM_TEST_MSG:
1747c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_MSG:
1757c478bd9Sstevel@tonic-gate 				/* testargs */
1767c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
1777c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
1787c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock());
1797c478bd9Sstevel@tonic-gate 				break;
1807c478bd9Sstevel@tonic-gate 			case NLM_LOCK:
1817c478bd9Sstevel@tonic-gate 			case NLM_LOCK_MSG:
1827c478bd9Sstevel@tonic-gate 				/* lockargs */
1837c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
1847c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Block */
1857c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
1867c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock());
1877c478bd9Sstevel@tonic-gate 				break;
1887c478bd9Sstevel@tonic-gate 			case NLM_CANCEL:
1897c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_MSG:
1907c478bd9Sstevel@tonic-gate 				/* cancargs */
1917c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
1927c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Block */
1937c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
1947c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock());
1957c478bd9Sstevel@tonic-gate 				break;
1967c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK:
1977c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_MSG:
1987c478bd9Sstevel@tonic-gate 				/* unlockargs */
1997c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
2007c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock());
2017c478bd9Sstevel@tonic-gate 				break;
2027c478bd9Sstevel@tonic-gate 			case NLM_TEST_RES:
2037c478bd9Sstevel@tonic-gate 				/* testres */
2047c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
2057c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
2067c478bd9Sstevel@tonic-gate 				(void) strcat(line,
2077c478bd9Sstevel@tonic-gate 				    nameof_stat(getxdr_u_long()));
2087c478bd9Sstevel@tonic-gate 				break;
2097c478bd9Sstevel@tonic-gate 			case NLM_LOCK_RES:
2107c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_RES:
2117c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_RES:
2127c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_RES:
2137c478bd9Sstevel@tonic-gate 				/* res */
2147c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
2157c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
2167c478bd9Sstevel@tonic-gate 				(void) strcat(line,
2177c478bd9Sstevel@tonic-gate 					nameof_stat(getxdr_u_long()));
2187c478bd9Sstevel@tonic-gate 				break;
2197c478bd9Sstevel@tonic-gate 			}
2207c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
2217c478bd9Sstevel@tonic-gate 		} else {
2227c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NLM R %s",
2237c478bd9Sstevel@tonic-gate 				procnames_short_1[proc]);
2247c478bd9Sstevel@tonic-gate 			line += strlen(line);
2257c478bd9Sstevel@tonic-gate 			switch (proc) {
2267c478bd9Sstevel@tonic-gate 			case NLM_TEST:
2277c478bd9Sstevel@tonic-gate 				/* testres */
2287c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
2297c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
2307c478bd9Sstevel@tonic-gate 				(void) strcat(line,
2317c478bd9Sstevel@tonic-gate 				    nameof_stat(getxdr_u_long()));
2327c478bd9Sstevel@tonic-gate 				break;
2337c478bd9Sstevel@tonic-gate 			case NLM_LOCK:
2347c478bd9Sstevel@tonic-gate 			case NLM_CANCEL:
2357c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK:
2367c478bd9Sstevel@tonic-gate 			case NLM_GRANTED:
2377c478bd9Sstevel@tonic-gate 				/* res */
2387c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
2397c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
2407c478bd9Sstevel@tonic-gate 				(void) strcat(line,
2417c478bd9Sstevel@tonic-gate 					nameof_stat(getxdr_u_long()));
2427c478bd9Sstevel@tonic-gate 				break;
2437c478bd9Sstevel@tonic-gate 			}
2447c478bd9Sstevel@tonic-gate 		}
2457c478bd9Sstevel@tonic-gate 	}
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
2487c478bd9Sstevel@tonic-gate 		show_header("NLM:  ", "Network Lock Manager", len);
2497c478bd9Sstevel@tonic-gate 		show_space();
2507c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
2517c478bd9Sstevel@tonic-gate 			return;
2527c478bd9Sstevel@tonic-gate 		}
2537c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
2547c478bd9Sstevel@tonic-gate 			"Proc = %d (%s)",
2557c478bd9Sstevel@tonic-gate 			proc, procnames_long_1[proc]);
2567c478bd9Sstevel@tonic-gate 		if (type == CALL) {
2577c478bd9Sstevel@tonic-gate 			switch (proc) {
2587c478bd9Sstevel@tonic-gate 			case NLM_TEST:
2597c478bd9Sstevel@tonic-gate 			case NLM_GRANTED:
2607c478bd9Sstevel@tonic-gate 			case NLM_TEST_MSG:
2617c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_MSG:
2627c478bd9Sstevel@tonic-gate 				show_testargs();
2637c478bd9Sstevel@tonic-gate 				break;
2647c478bd9Sstevel@tonic-gate 			case NLM_LOCK:
2657c478bd9Sstevel@tonic-gate 			case NLM_LOCK_MSG:
2667c478bd9Sstevel@tonic-gate 				show_lockargs();
2677c478bd9Sstevel@tonic-gate 				break;
2687c478bd9Sstevel@tonic-gate 			case NLM_CANCEL:
2697c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_MSG:
2707c478bd9Sstevel@tonic-gate 				show_cancargs();
2717c478bd9Sstevel@tonic-gate 				break;
2727c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK:
2737c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_MSG:
2747c478bd9Sstevel@tonic-gate 				show_unlockargs();
2757c478bd9Sstevel@tonic-gate 				break;
2767c478bd9Sstevel@tonic-gate 			case NLM_TEST_RES:
2777c478bd9Sstevel@tonic-gate 				show_testres();
2787c478bd9Sstevel@tonic-gate 				break;
2797c478bd9Sstevel@tonic-gate 			case NLM_LOCK_RES:
2807c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_RES:
2817c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_RES:
2827c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_RES:
2837c478bd9Sstevel@tonic-gate 				show_res();
2847c478bd9Sstevel@tonic-gate 				break;
2857c478bd9Sstevel@tonic-gate 			}
2867c478bd9Sstevel@tonic-gate 		} else {
2877c478bd9Sstevel@tonic-gate 			switch (proc) {
2887c478bd9Sstevel@tonic-gate 			case NLM_TEST:
2897c478bd9Sstevel@tonic-gate 				show_testres();
2907c478bd9Sstevel@tonic-gate 				break;
2917c478bd9Sstevel@tonic-gate 			case NLM_LOCK:
2927c478bd9Sstevel@tonic-gate 			case NLM_CANCEL:
2937c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK:
2947c478bd9Sstevel@tonic-gate 			case NLM_GRANTED:
2957c478bd9Sstevel@tonic-gate 				show_res();
2967c478bd9Sstevel@tonic-gate 				break;
2977c478bd9Sstevel@tonic-gate 			case NLM_TEST_MSG:
2987c478bd9Sstevel@tonic-gate 			case NLM_LOCK_MSG:
2997c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_MSG:
3007c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_MSG:
3017c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_MSG:
3027c478bd9Sstevel@tonic-gate 			case NLM_TEST_RES:
3037c478bd9Sstevel@tonic-gate 			case NLM_LOCK_RES:
3047c478bd9Sstevel@tonic-gate 			case NLM_CANCEL_RES:
3057c478bd9Sstevel@tonic-gate 			case NLM_UNLOCK_RES:
3067c478bd9Sstevel@tonic-gate 			case NLM_GRANTED_RES:
3077c478bd9Sstevel@tonic-gate 				break;
3087c478bd9Sstevel@tonic-gate 			}
3097c478bd9Sstevel@tonic-gate 		}
3107c478bd9Sstevel@tonic-gate 		show_trailer();
3117c478bd9Sstevel@tonic-gate 	}
3127c478bd9Sstevel@tonic-gate }
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #define	roundup(sz) ((sz / 4 + (sz % 4 > 0)) * 4)
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Skip a netobj.
3187c478bd9Sstevel@tonic-gate  * Make sure an integral number of words
3197c478bd9Sstevel@tonic-gate  * are skipped.
3207c478bd9Sstevel@tonic-gate  */
3217c478bd9Sstevel@tonic-gate static void
skip_netobj()3227c478bd9Sstevel@tonic-gate skip_netobj()
3237c478bd9Sstevel@tonic-gate {
3247c478bd9Sstevel@tonic-gate 	int sz = getxdr_u_long();
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate 	xdr_skip(roundup(sz));
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate static char *
sum_netobj(handle)3307c478bd9Sstevel@tonic-gate sum_netobj(handle)
3317c478bd9Sstevel@tonic-gate 	char *handle;
3327c478bd9Sstevel@tonic-gate {
3337c478bd9Sstevel@tonic-gate 	int i, l, sz;
3347c478bd9Sstevel@tonic-gate 	int sum = 0;
3357c478bd9Sstevel@tonic-gate 	static char buff[32];
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 	sz = getxdr_u_long();
3387c478bd9Sstevel@tonic-gate 	for (i = 0; i < sz; i += 4) {
3397c478bd9Sstevel@tonic-gate 		l =  getxdr_long();
3407c478bd9Sstevel@tonic-gate 		sum ^= (l >> 16) ^ l;
3417c478bd9Sstevel@tonic-gate 	}
3427c478bd9Sstevel@tonic-gate 	(void) sprintf(buff, " %s=%04X", handle, sum & 0xFFFF);
3437c478bd9Sstevel@tonic-gate 	return (buff);
3447c478bd9Sstevel@tonic-gate }
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate static void
show_netobj(fmt)3477c478bd9Sstevel@tonic-gate show_netobj(fmt)
3487c478bd9Sstevel@tonic-gate 	char *fmt;
3497c478bd9Sstevel@tonic-gate {
3507c478bd9Sstevel@tonic-gate 	int sz, chunk;
3517c478bd9Sstevel@tonic-gate 	char *p;
3527c478bd9Sstevel@tonic-gate 	char buff[64];
3537c478bd9Sstevel@tonic-gate 	int needspace;
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate 	sz = getxdr_u_long();		/* size of the netobj */
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate 	if (sz == 0) {
3587c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), fmt, "<null>");
3597c478bd9Sstevel@tonic-gate 	} else {
3607c478bd9Sstevel@tonic-gate 		needspace = sz > 16;
3617c478bd9Sstevel@tonic-gate 		(void) strcpy(buff, fmt);
3627c478bd9Sstevel@tonic-gate 		while (sz > 0) {
3637c478bd9Sstevel@tonic-gate 			chunk = sz > 16 ? 16 : sz;
3647c478bd9Sstevel@tonic-gate 			sz -= 16;
3657c478bd9Sstevel@tonic-gate 			(void) showxdr_hex(chunk, buff);
3667c478bd9Sstevel@tonic-gate 			/*
3677c478bd9Sstevel@tonic-gate 			 * For every line after the first, blank out
3687c478bd9Sstevel@tonic-gate 			 * everything in the format string before the "%s".
3697c478bd9Sstevel@tonic-gate 			 */
3707c478bd9Sstevel@tonic-gate 			for (p = buff; *p != '%'; p++)
3717c478bd9Sstevel@tonic-gate 				*p = ' ';
3727c478bd9Sstevel@tonic-gate 		}
3737c478bd9Sstevel@tonic-gate 		if (needspace)
3747c478bd9Sstevel@tonic-gate 			show_space();
3757c478bd9Sstevel@tonic-gate 	}
3767c478bd9Sstevel@tonic-gate }
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate static char *
sum_lock()3797c478bd9Sstevel@tonic-gate sum_lock()
3807c478bd9Sstevel@tonic-gate {
3817c478bd9Sstevel@tonic-gate 	static char buff[LM_MAXSTRLEN + 1];
3827c478bd9Sstevel@tonic-gate 	char *cp = buff;
3837c478bd9Sstevel@tonic-gate 	long id;
3847c478bd9Sstevel@tonic-gate 	ulong_t off, len;
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate 	(void) getxdr_string(buff, LM_MAXSTRLEN);	/* Caller */
3877c478bd9Sstevel@tonic-gate 	(void) strcpy(buff, sum_netobj("FH"));		/* Fh */
3887c478bd9Sstevel@tonic-gate 	cp += strlen(buff);
3897c478bd9Sstevel@tonic-gate 	skip_netobj();					/* Owner */
3907c478bd9Sstevel@tonic-gate 	id  = getxdr_long();
3917c478bd9Sstevel@tonic-gate 	off = getxdr_u_long();
3927c478bd9Sstevel@tonic-gate 	len = getxdr_u_long();
3937c478bd9Sstevel@tonic-gate 	(void) sprintf(cp, " PID=%ld Region=%lu:%lu", id, off, len);
3947c478bd9Sstevel@tonic-gate 	return (buff);
3957c478bd9Sstevel@tonic-gate }
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate static void
show_lock()3987c478bd9Sstevel@tonic-gate show_lock()
3997c478bd9Sstevel@tonic-gate {
4007c478bd9Sstevel@tonic-gate 	showxdr_string(LM_MAXSTRLEN, "Caller = %s");
4017c478bd9Sstevel@tonic-gate 	show_netobj("Filehandle = %s");
4027c478bd9Sstevel@tonic-gate 	show_netobj("Lock owner = %s");
4037c478bd9Sstevel@tonic-gate 	showxdr_long("Svid = %ld (process id)");
4047c478bd9Sstevel@tonic-gate 	showxdr_u_long("Offset = %lu bytes");
4057c478bd9Sstevel@tonic-gate 	showxdr_u_long("Length = %lu bytes");
4067c478bd9Sstevel@tonic-gate }
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate static void
show_cancargs()4097c478bd9Sstevel@tonic-gate show_cancargs()
4107c478bd9Sstevel@tonic-gate {
4117c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4127c478bd9Sstevel@tonic-gate 	showxdr_bool("Block = %s");
4137c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
4147c478bd9Sstevel@tonic-gate 	show_lock();
4157c478bd9Sstevel@tonic-gate }
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate static void
show_lockargs()4187c478bd9Sstevel@tonic-gate show_lockargs()
4197c478bd9Sstevel@tonic-gate {
4207c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4217c478bd9Sstevel@tonic-gate 	showxdr_bool("Block = %s");
4227c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
4237c478bd9Sstevel@tonic-gate 	show_lock();
4247c478bd9Sstevel@tonic-gate 	showxdr_bool("Reclaim = %s");
4257c478bd9Sstevel@tonic-gate 	showxdr_long("State = %ld");
4267c478bd9Sstevel@tonic-gate }
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate static void
show_unlockargs()4297c478bd9Sstevel@tonic-gate show_unlockargs()
4307c478bd9Sstevel@tonic-gate {
4317c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4327c478bd9Sstevel@tonic-gate 	show_lock();
4337c478bd9Sstevel@tonic-gate }
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate static void
show_testargs()4367c478bd9Sstevel@tonic-gate show_testargs()
4377c478bd9Sstevel@tonic-gate {
4387c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4397c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
4407c478bd9Sstevel@tonic-gate 	show_lock();
4417c478bd9Sstevel@tonic-gate }
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate static void
show_res()4447c478bd9Sstevel@tonic-gate show_res()
4457c478bd9Sstevel@tonic-gate {
4467c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4477c478bd9Sstevel@tonic-gate 	(void) show_stat();
4487c478bd9Sstevel@tonic-gate }
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate static char *
nameof_stat(s)4517c478bd9Sstevel@tonic-gate nameof_stat(s)
4527c478bd9Sstevel@tonic-gate 	ulong_t s;
4537c478bd9Sstevel@tonic-gate {
4547c478bd9Sstevel@tonic-gate 	switch ((enum nlm_stats) s) {
4557c478bd9Sstevel@tonic-gate 	case nlm_granted:	return ("granted");
4567c478bd9Sstevel@tonic-gate 	case nlm_denied:	return ("denied");
4577c478bd9Sstevel@tonic-gate 	case nlm_denied_nolocks:return ("denied (no locks)");
4587c478bd9Sstevel@tonic-gate 	case nlm_blocked:	return ("blocked");
4597c478bd9Sstevel@tonic-gate 	case nlm_denied_grace_period: return ("denied (grace period)");
4607c478bd9Sstevel@tonic-gate 	case nlm_deadlck:	return ("deadlock");
4617c478bd9Sstevel@tonic-gate 	default:		return ("?");
4627c478bd9Sstevel@tonic-gate 	}
4637c478bd9Sstevel@tonic-gate }
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate static enum nlm_stats
show_stat()4667c478bd9Sstevel@tonic-gate show_stat()
4677c478bd9Sstevel@tonic-gate {
4687c478bd9Sstevel@tonic-gate 	enum nlm_stats s;
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate 	s = (enum nlm_stats) getxdr_u_long();
4717c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0),
4722c2d21e9SRichard Lowe 	    "Status = %d (%s)",
4732c2d21e9SRichard Lowe 	    s, nameof_stat((ulong_t)s));
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate 	return (s);
4767c478bd9Sstevel@tonic-gate }
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate static void
show_testres()4797c478bd9Sstevel@tonic-gate show_testres()
4807c478bd9Sstevel@tonic-gate {
4817c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
4827c478bd9Sstevel@tonic-gate 	if (show_stat() == nlm_denied) {
4837c478bd9Sstevel@tonic-gate 		showxdr_bool("Exclusive = %s");
4847c478bd9Sstevel@tonic-gate 		showxdr_long("Svid = %ld (process id)");
4857c478bd9Sstevel@tonic-gate 		show_netobj("Owner handle = %s");
4867c478bd9Sstevel@tonic-gate 		showxdr_u_long("Offset = %lu bytes");
4877c478bd9Sstevel@tonic-gate 		showxdr_u_long("Length = %lu bytes");
4887c478bd9Sstevel@tonic-gate 	}
4897c478bd9Sstevel@tonic-gate }
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate /* ------------  V E R S I O N   3  ---------------------------------- */
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate static char *procnames_short_3[] = {
4957c478bd9Sstevel@tonic-gate 	"SHARE3",	/* 20 */
4967c478bd9Sstevel@tonic-gate 	"UNSHARE3",	/* 21 */
4977c478bd9Sstevel@tonic-gate 	"NM_LOCK3",	/* 22 */
4987c478bd9Sstevel@tonic-gate 	"FREEALL3",	/* 23 */
4997c478bd9Sstevel@tonic-gate };
5007c478bd9Sstevel@tonic-gate 
5017c478bd9Sstevel@tonic-gate static char *procnames_long_3[] = {
5027c478bd9Sstevel@tonic-gate 	"Share",		/* 20 */
5037c478bd9Sstevel@tonic-gate 	"Unshare",		/* 21 */
5047c478bd9Sstevel@tonic-gate 	"Unmonitored lock",	/* 22 */
5057c478bd9Sstevel@tonic-gate 	"Free all",		/* 23 */
5067c478bd9Sstevel@tonic-gate };
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate /* Maximum procedure number for version 3. */
5097c478bd9Sstevel@tonic-gate #define	MAXPROC_3	23
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate static void
interpret_nlm_3(flags,type,xid,vers,proc,data,len)5127c478bd9Sstevel@tonic-gate interpret_nlm_3(flags, type, xid, vers, proc, data, len)
5137c478bd9Sstevel@tonic-gate 	int flags, type, xid, vers, proc;
5147c478bd9Sstevel@tonic-gate 	char *data;
5157c478bd9Sstevel@tonic-gate 	int len;
5167c478bd9Sstevel@tonic-gate {
5177c478bd9Sstevel@tonic-gate 	char *line, *pl;
5187c478bd9Sstevel@tonic-gate 	ulong_t i;
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_3)
5217c478bd9Sstevel@tonic-gate 		return;
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate 	/*
5247c478bd9Sstevel@tonic-gate 	 * Version 3 is a superset of version 1
5257c478bd9Sstevel@tonic-gate 	 */
5267c478bd9Sstevel@tonic-gate 	if (proc >= 0 && proc <= MAXPROC_1) {
5277c478bd9Sstevel@tonic-gate 		interpret_nlm_1(flags, type, xid, vers, proc, data, len);
5287c478bd9Sstevel@tonic-gate 		return;
5297c478bd9Sstevel@tonic-gate 	}
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
5327c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
5337c478bd9Sstevel@tonic-gate 			return;
5347c478bd9Sstevel@tonic-gate 		}
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate 		line = get_sum_line();
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate 		if (type == CALL) {
5397c478bd9Sstevel@tonic-gate 			(void) sprintf(line,
5407c478bd9Sstevel@tonic-gate 				"NLM C %s",
5417c478bd9Sstevel@tonic-gate 				procnames_short_3[proc-20]);
5427c478bd9Sstevel@tonic-gate 			line += strlen(line);
5437c478bd9Sstevel@tonic-gate 			switch (proc) {
5447c478bd9Sstevel@tonic-gate 			case NLM_SHARE:
5457c478bd9Sstevel@tonic-gate 			case NLM_UNSHARE:
5467c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
5477c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_share());
5487c478bd9Sstevel@tonic-gate 				break;
5497c478bd9Sstevel@tonic-gate 			case NLM_NM_LOCK:
5507c478bd9Sstevel@tonic-gate 				/* lockargs */
5517c478bd9Sstevel@tonic-gate 				skip_netobj();
5527c478bd9Sstevel@tonic-gate 				(void) getxdr_u_long(); /* Block */
5537c478bd9Sstevel@tonic-gate 				(void) getxdr_u_long(); /* Excl */
5547c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock());
5557c478bd9Sstevel@tonic-gate 				break;
5567c478bd9Sstevel@tonic-gate 			case NLM_FREE_ALL:
5577c478bd9Sstevel@tonic-gate 				(void) sprintf(line,
5587c478bd9Sstevel@tonic-gate 					" %s", sum_notify());
5597c478bd9Sstevel@tonic-gate 				break;
5607c478bd9Sstevel@tonic-gate 			}
5617c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
5627c478bd9Sstevel@tonic-gate 		} else {
5637c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NLM R %s",
5647c478bd9Sstevel@tonic-gate 				procnames_short_3[proc-20]);
5657c478bd9Sstevel@tonic-gate 			line += strlen(line);
5667c478bd9Sstevel@tonic-gate 			switch (proc) {
5677c478bd9Sstevel@tonic-gate 			case NLM_SHARE:
5687c478bd9Sstevel@tonic-gate 			case NLM_UNSHARE:
5697c478bd9Sstevel@tonic-gate 				pl = sum_netobj("OH");
5707c478bd9Sstevel@tonic-gate 				i = getxdr_u_long();
5717c478bd9Sstevel@tonic-gate 				sprintf(line, "%s %s %ld",
5727c478bd9Sstevel@tonic-gate 					pl, nameof_stat(i), getxdr_long());
5737c478bd9Sstevel@tonic-gate 				break;
5747c478bd9Sstevel@tonic-gate 			case NLM_NM_LOCK:
5757c478bd9Sstevel@tonic-gate 				/* res */
5767c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
5777c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
5787c478bd9Sstevel@tonic-gate 				(void) strcat(line,
5797c478bd9Sstevel@tonic-gate 					nameof_stat(getxdr_u_long()));
5807c478bd9Sstevel@tonic-gate 				break;
5817c478bd9Sstevel@tonic-gate 			case NLM_FREE_ALL:
5827c478bd9Sstevel@tonic-gate 				break;
5837c478bd9Sstevel@tonic-gate 			}
5847c478bd9Sstevel@tonic-gate 		}
5857c478bd9Sstevel@tonic-gate 	}
5867c478bd9Sstevel@tonic-gate 
5877c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
5887c478bd9Sstevel@tonic-gate 		show_header("NLM:  ", "Network Lock Manager", len);
5897c478bd9Sstevel@tonic-gate 		show_space();
5907c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
5917c478bd9Sstevel@tonic-gate 			return;
5927c478bd9Sstevel@tonic-gate 		}
5937c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
5947c478bd9Sstevel@tonic-gate 			"Proc = %d (%s)",
5957c478bd9Sstevel@tonic-gate 			proc, procnames_long_3[proc-20]);
5967c478bd9Sstevel@tonic-gate 		if (type == CALL) {
5977c478bd9Sstevel@tonic-gate 			switch (proc) {
5987c478bd9Sstevel@tonic-gate 			case NLM_SHARE:
5997c478bd9Sstevel@tonic-gate 			case NLM_UNSHARE:
6007c478bd9Sstevel@tonic-gate 				show_shareargs();
6017c478bd9Sstevel@tonic-gate 				break;
6027c478bd9Sstevel@tonic-gate 			case NLM_NM_LOCK:
6037c478bd9Sstevel@tonic-gate 				show_lockargs();
6047c478bd9Sstevel@tonic-gate 				break;
6057c478bd9Sstevel@tonic-gate 			case NLM_FREE_ALL:
6067c478bd9Sstevel@tonic-gate 				show_notify();
6077c478bd9Sstevel@tonic-gate 				break;
6087c478bd9Sstevel@tonic-gate 			}
6097c478bd9Sstevel@tonic-gate 		} else {
6107c478bd9Sstevel@tonic-gate 			switch (proc) {
6117c478bd9Sstevel@tonic-gate 			case NLM_SHARE:
6127c478bd9Sstevel@tonic-gate 			case NLM_UNSHARE:
6137c478bd9Sstevel@tonic-gate 				show_shareres();
6147c478bd9Sstevel@tonic-gate 				break;
6157c478bd9Sstevel@tonic-gate 			case NLM_NM_LOCK:
6167c478bd9Sstevel@tonic-gate 				show_res();
6177c478bd9Sstevel@tonic-gate 				break;
6187c478bd9Sstevel@tonic-gate 			case NLM_FREE_ALL:
6197c478bd9Sstevel@tonic-gate 				break;
6207c478bd9Sstevel@tonic-gate 			}
6217c478bd9Sstevel@tonic-gate 		}
6227c478bd9Sstevel@tonic-gate 		show_trailer();
6237c478bd9Sstevel@tonic-gate 	}
6247c478bd9Sstevel@tonic-gate }
6257c478bd9Sstevel@tonic-gate 
6267c478bd9Sstevel@tonic-gate static char *
nameof_mode(m)6277c478bd9Sstevel@tonic-gate nameof_mode(m)
6287c478bd9Sstevel@tonic-gate 	uint_t m;
6297c478bd9Sstevel@tonic-gate {
6307c478bd9Sstevel@tonic-gate 	switch ((enum fsh_mode) m) {
6317c478bd9Sstevel@tonic-gate 	case fsm_DN:	return ("deny none");
6327c478bd9Sstevel@tonic-gate 	case fsm_DR:	return ("deny read");
6337c478bd9Sstevel@tonic-gate 	case fsm_DW:	return ("deny write");
6347c478bd9Sstevel@tonic-gate 	case fsm_DRW:	return ("deny read/write");
6357c478bd9Sstevel@tonic-gate 	default:	return ("?");
6367c478bd9Sstevel@tonic-gate 	}
6377c478bd9Sstevel@tonic-gate }
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate static char *
nameof_access(a)6407c478bd9Sstevel@tonic-gate nameof_access(a)
6417c478bd9Sstevel@tonic-gate 	uint_t a;
6427c478bd9Sstevel@tonic-gate {
6437c478bd9Sstevel@tonic-gate 	switch ((enum fsh_access) a) {
6447c478bd9Sstevel@tonic-gate 	case fsa_NONE:	return ("?");
6457c478bd9Sstevel@tonic-gate 	case fsa_R:	return ("read only");
6467c478bd9Sstevel@tonic-gate 	case fsa_W:	return ("write only");
6477c478bd9Sstevel@tonic-gate 	case fsa_RW:	return ("read/write");
6487c478bd9Sstevel@tonic-gate 	default:	return ("?");
6497c478bd9Sstevel@tonic-gate 	}
6507c478bd9Sstevel@tonic-gate }
6517c478bd9Sstevel@tonic-gate 
6527c478bd9Sstevel@tonic-gate static void
show_nlm_mode()6537c478bd9Sstevel@tonic-gate show_nlm_mode()
6547c478bd9Sstevel@tonic-gate {
6557c478bd9Sstevel@tonic-gate 	enum fsh_mode m;
6567c478bd9Sstevel@tonic-gate 
6577c478bd9Sstevel@tonic-gate 	m = (enum fsh_mode) getxdr_u_long();
6587c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0),
6592c2d21e9SRichard Lowe 	    "Mode = %d (%s)",
6602c2d21e9SRichard Lowe 	    m, nameof_mode((uint_t)m));
6617c478bd9Sstevel@tonic-gate }
6627c478bd9Sstevel@tonic-gate 
6637c478bd9Sstevel@tonic-gate static void
show_nlm_access()6647c478bd9Sstevel@tonic-gate show_nlm_access()
6657c478bd9Sstevel@tonic-gate {
6667c478bd9Sstevel@tonic-gate 	enum fsh_access a;
6677c478bd9Sstevel@tonic-gate 
6687c478bd9Sstevel@tonic-gate 	a = (enum fsh_access) getxdr_u_long();
6697c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0),
6702c2d21e9SRichard Lowe 	    "Access = %d (%s)",
6712c2d21e9SRichard Lowe 	    a, nameof_access((uint_t)a));
6727c478bd9Sstevel@tonic-gate }
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate static char *
sum_share()6757c478bd9Sstevel@tonic-gate sum_share()
6767c478bd9Sstevel@tonic-gate {
6777c478bd9Sstevel@tonic-gate 	static char buff[LM_MAXSTRLEN + 1];
6787c478bd9Sstevel@tonic-gate 	char *cp = buff;
6797c478bd9Sstevel@tonic-gate 	ulong_t mode, access;
6807c478bd9Sstevel@tonic-gate 
6817c478bd9Sstevel@tonic-gate 	(void) getxdr_string(buff, LM_MAXSTRLEN);	/* Caller */
6827c478bd9Sstevel@tonic-gate 	(void) strcpy(buff, sum_netobj("FH"));		/* Fh */
6837c478bd9Sstevel@tonic-gate 	cp += strlen(buff);
6847c478bd9Sstevel@tonic-gate 	skip_netobj();					/* Owner */
6857c478bd9Sstevel@tonic-gate 	mode = getxdr_u_long();
6867c478bd9Sstevel@tonic-gate 	access = getxdr_u_long();
6877c478bd9Sstevel@tonic-gate 	(void) sprintf(cp, " Mode=%lu Access=%lu", mode, access);
6887c478bd9Sstevel@tonic-gate 	return (buff);
6897c478bd9Sstevel@tonic-gate }
6907c478bd9Sstevel@tonic-gate 
6917c478bd9Sstevel@tonic-gate static void
show_share()6927c478bd9Sstevel@tonic-gate show_share()
6937c478bd9Sstevel@tonic-gate {
6947c478bd9Sstevel@tonic-gate 	showxdr_string(LM_MAXSTRLEN, "Caller = %s");
6957c478bd9Sstevel@tonic-gate 	show_netobj("Filehandle = %s");
6967c478bd9Sstevel@tonic-gate 	show_netobj("Lock owner = %s");
6977c478bd9Sstevel@tonic-gate 	show_nlm_mode();
6987c478bd9Sstevel@tonic-gate 	show_nlm_access();
6997c478bd9Sstevel@tonic-gate }
7007c478bd9Sstevel@tonic-gate 
7017c478bd9Sstevel@tonic-gate static void
show_shareargs()7027c478bd9Sstevel@tonic-gate show_shareargs()
7037c478bd9Sstevel@tonic-gate {
7047c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
7057c478bd9Sstevel@tonic-gate 	show_share();
7067c478bd9Sstevel@tonic-gate 	showxdr_bool("Reclaim = %s");
7077c478bd9Sstevel@tonic-gate }
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate static void
show_shareres()7107c478bd9Sstevel@tonic-gate show_shareres()
7117c478bd9Sstevel@tonic-gate {
7127c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
7137c478bd9Sstevel@tonic-gate 	(void) show_stat();
7147c478bd9Sstevel@tonic-gate 	showxdr_long("Sequence = %d");
7157c478bd9Sstevel@tonic-gate }
7167c478bd9Sstevel@tonic-gate 
7177c478bd9Sstevel@tonic-gate static void
show_notify()7187c478bd9Sstevel@tonic-gate show_notify()
7197c478bd9Sstevel@tonic-gate {
7207c478bd9Sstevel@tonic-gate 	showxdr_string(LM_MAXNAMELEN, "Name = %s");
7217c478bd9Sstevel@tonic-gate 	showxdr_long("State = %d");
7227c478bd9Sstevel@tonic-gate }
7237c478bd9Sstevel@tonic-gate 
7247c478bd9Sstevel@tonic-gate #define	NOTIFY_PAD	(sizeof (" State=-2147483648") + 1)
7257c478bd9Sstevel@tonic-gate 
7267c478bd9Sstevel@tonic-gate static char *
sum_notify()7277c478bd9Sstevel@tonic-gate sum_notify()
7287c478bd9Sstevel@tonic-gate {
7297c478bd9Sstevel@tonic-gate 	static char buff[LM_MAXNAMELEN + NOTIFY_PAD];
7307c478bd9Sstevel@tonic-gate 	char *cp = buff;
7317c478bd9Sstevel@tonic-gate 	long state;
7327c478bd9Sstevel@tonic-gate 
7337c478bd9Sstevel@tonic-gate 	(void) getxdr_string(buff, LM_MAXNAMELEN);
7347c478bd9Sstevel@tonic-gate 	cp += strlen(buff);
7357c478bd9Sstevel@tonic-gate 	state  = getxdr_long();
7367c478bd9Sstevel@tonic-gate 	(void) sprintf(cp, " State=%ld", state);
7377c478bd9Sstevel@tonic-gate 	return (buff);
7387c478bd9Sstevel@tonic-gate }
7397c478bd9Sstevel@tonic-gate 
7407c478bd9Sstevel@tonic-gate /* ------------  V E R S I O N   4  ---------------------------------- */
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate static char *procnames_short_4[] = {
7437c478bd9Sstevel@tonic-gate 	"Null4",	/* 0 */
7447c478bd9Sstevel@tonic-gate 	"TEST4",	/* 1 */
7457c478bd9Sstevel@tonic-gate 	"LOCK4",	/* 2 */
7467c478bd9Sstevel@tonic-gate 	"CANCEL4",	/* 3 */
7477c478bd9Sstevel@tonic-gate 	"UNLOCK4",	/* 4 */
7487c478bd9Sstevel@tonic-gate 	"GRANTED4",	/* 5 */
7497c478bd9Sstevel@tonic-gate 	"TEST MSG4",	/* 6 */
7507c478bd9Sstevel@tonic-gate 	"LOCK MSG4",	/* 7 */
7517c478bd9Sstevel@tonic-gate 	"CANCEL MSG4",	/* 8 */
7527c478bd9Sstevel@tonic-gate 	"UNLOCK MSG4",	/* 9 */
7537c478bd9Sstevel@tonic-gate 	"GRANTED MSG4",	/* 10 */
7547c478bd9Sstevel@tonic-gate 	"TEST RES4",	/* 11 */
7557c478bd9Sstevel@tonic-gate 	"LOCK RES4",	/* 12 */
7567c478bd9Sstevel@tonic-gate 	"CANCEL RES4",	/* 13 */
7577c478bd9Sstevel@tonic-gate 	"UNLOCK RES4",	/* 14 */
7587c478bd9Sstevel@tonic-gate 	"GRANTED RES4",	/* 15 */
7597c478bd9Sstevel@tonic-gate 	"PROC 16 v4",	/* 16 */
7607c478bd9Sstevel@tonic-gate 	"PROC 17 v4",	/* 17 */
7617c478bd9Sstevel@tonic-gate 	"PROC 18 v4",	/* 18 */
7627c478bd9Sstevel@tonic-gate 	"PROC 19 v4",	/* 19 */
7637c478bd9Sstevel@tonic-gate 	"SHARE4",	/* 20 */
7647c478bd9Sstevel@tonic-gate 	"UNSHARE4",	/* 21 */
7657c478bd9Sstevel@tonic-gate 	"NM_LOCK4",	/* 22 */
7667c478bd9Sstevel@tonic-gate 	"FREEALL4",	/* 23 */
7677c478bd9Sstevel@tonic-gate };
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate static char *procnames_long_4[] = {
7707c478bd9Sstevel@tonic-gate 	"Null procedure",	/* 0 */
7717c478bd9Sstevel@tonic-gate 	"Test",			/* 1 */
7727c478bd9Sstevel@tonic-gate 	"Lock",			/* 2 */
7737c478bd9Sstevel@tonic-gate 	"Cancel",		/* 3 */
7747c478bd9Sstevel@tonic-gate 	"Unlock",		/* 4 */
7757c478bd9Sstevel@tonic-gate 	"Granted",		/* 5 */
7767c478bd9Sstevel@tonic-gate 	"Test message",		/* 6 */
7777c478bd9Sstevel@tonic-gate 	"Lock message",		/* 7 */
7787c478bd9Sstevel@tonic-gate 	"Cancel message",	/* 8 */
7797c478bd9Sstevel@tonic-gate 	"Unlock message",	/* 9 */
7807c478bd9Sstevel@tonic-gate 	"Granted message",	/* 10 */
7817c478bd9Sstevel@tonic-gate 	"Test result",		/* 11 */
7827c478bd9Sstevel@tonic-gate 	"Lock result",		/* 12 */
7837c478bd9Sstevel@tonic-gate 	"Cancel result",	/* 13 */
7847c478bd9Sstevel@tonic-gate 	"Unlock result",	/* 14 */
7857c478bd9Sstevel@tonic-gate 	"Granted result",	/* 15 */
7867c478bd9Sstevel@tonic-gate 	"Procedure 16",		/* 16 */
7877c478bd9Sstevel@tonic-gate 	"Procedure 17",		/* 17 */
7887c478bd9Sstevel@tonic-gate 	"Procedure 18",		/* 18 */
7897c478bd9Sstevel@tonic-gate 	"Procedure 19",		/* 19 */
7907c478bd9Sstevel@tonic-gate 	"Share",		/* 20 */
7917c478bd9Sstevel@tonic-gate 	"Unshare",		/* 21 */
7927c478bd9Sstevel@tonic-gate 	"Unmonitored lock",	/* 22 */
7937c478bd9Sstevel@tonic-gate 	"Free all",		/* 23 */
7947c478bd9Sstevel@tonic-gate };
7957c478bd9Sstevel@tonic-gate 
7967c478bd9Sstevel@tonic-gate /* Maximum procedure number for version 4. */
7977c478bd9Sstevel@tonic-gate #define	MAXPROC_4	23
7987c478bd9Sstevel@tonic-gate 
7997c478bd9Sstevel@tonic-gate /* ARGSUSED */
8007c478bd9Sstevel@tonic-gate static void
interpret_nlm_4(flags,type,xid,vers,proc,data,len)8017c478bd9Sstevel@tonic-gate interpret_nlm_4(flags, type, xid, vers, proc, data, len)
8027c478bd9Sstevel@tonic-gate 	int flags, type, xid, vers, proc;
8037c478bd9Sstevel@tonic-gate 	char *data;
8047c478bd9Sstevel@tonic-gate 	int len;
8057c478bd9Sstevel@tonic-gate {
8067c478bd9Sstevel@tonic-gate 	char *line;
8077c478bd9Sstevel@tonic-gate 	char *pl;
8087c478bd9Sstevel@tonic-gate 	ulong_t i;
8097c478bd9Sstevel@tonic-gate 
8107c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_4)
8117c478bd9Sstevel@tonic-gate 		return;
8127c478bd9Sstevel@tonic-gate 
8137c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
8147c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
8157c478bd9Sstevel@tonic-gate 			return;
8167c478bd9Sstevel@tonic-gate 		}
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate 		line = get_sum_line();
8197c478bd9Sstevel@tonic-gate 
8207c478bd9Sstevel@tonic-gate 		if (type == CALL) {
8217c478bd9Sstevel@tonic-gate 			(void) sprintf(line,
8227c478bd9Sstevel@tonic-gate 				"NLM C %s",
8237c478bd9Sstevel@tonic-gate 				procnames_short_4[proc]);
8247c478bd9Sstevel@tonic-gate 			line += strlen(line);
8257c478bd9Sstevel@tonic-gate 			switch (proc) {
826*bbaa8b60SDan Kruchinin 			case NLM4_TEST:
827*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED:
828*bbaa8b60SDan Kruchinin 			case NLM4_TEST_MSG:
829*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_MSG:
8307c478bd9Sstevel@tonic-gate 				/* testargs */
8317c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8327c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
8337c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock4());
8347c478bd9Sstevel@tonic-gate 				break;
835*bbaa8b60SDan Kruchinin 			case NLM4_LOCK:
836*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_MSG:
8377c478bd9Sstevel@tonic-gate 				/* lockargs */
8387c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8397c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Block */
8407c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
8417c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock4());
8427c478bd9Sstevel@tonic-gate 				/* ignore reclaim, state fields */
8437c478bd9Sstevel@tonic-gate 				break;
844*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL:
845*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_MSG:
8467c478bd9Sstevel@tonic-gate 				/* cancargs */
8477c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8487c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Block */
8497c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
8507c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock4());
8517c478bd9Sstevel@tonic-gate 				break;
852*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK:
853*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_MSG:
8547c478bd9Sstevel@tonic-gate 				/* unlockargs */
8557c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8567c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock4());
8577c478bd9Sstevel@tonic-gate 				break;
858*bbaa8b60SDan Kruchinin 			case NLM4_TEST_RES:
8597c478bd9Sstevel@tonic-gate 				/* testres */
8607c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8617c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
8627c478bd9Sstevel@tonic-gate 				(void) strcat(line,
8637c478bd9Sstevel@tonic-gate 				    nameof_stat4(getxdr_u_long()));
8647c478bd9Sstevel@tonic-gate 				break;
865*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_RES:
866*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_RES:
867*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_RES:
868*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_RES:
8697c478bd9Sstevel@tonic-gate 				/* res */
8707c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8717c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
8727c478bd9Sstevel@tonic-gate 				(void) strcat(line,
8737c478bd9Sstevel@tonic-gate 					nameof_stat4(getxdr_u_long()));
8747c478bd9Sstevel@tonic-gate 				break;
875*bbaa8b60SDan Kruchinin 			case NLM4_SHARE:
876*bbaa8b60SDan Kruchinin 			case NLM4_UNSHARE:
8777c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
8787c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_share());
8797c478bd9Sstevel@tonic-gate 				break;
880*bbaa8b60SDan Kruchinin 			case NLM4_NM_LOCK:
8817c478bd9Sstevel@tonic-gate 				/* lockargs */
8827c478bd9Sstevel@tonic-gate 				skip_netobj();		/* Cookie */
8837c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Block */
8847c478bd9Sstevel@tonic-gate 				(void) getxdr_bool();	/* Excl */
8857c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_lock4());
8867c478bd9Sstevel@tonic-gate 				/* skip reclaim & state fields */
8877c478bd9Sstevel@tonic-gate 				break;
888*bbaa8b60SDan Kruchinin 			case NLM4_FREE_ALL:
8897c478bd9Sstevel@tonic-gate 				(void) sprintf(line,
8907c478bd9Sstevel@tonic-gate 					" %s", sum_notify());
8917c478bd9Sstevel@tonic-gate 				break;
8927c478bd9Sstevel@tonic-gate 			}
8937c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
8947c478bd9Sstevel@tonic-gate 		} else {
8957c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NLM R %s",
8967c478bd9Sstevel@tonic-gate 				procnames_short_4[proc]);
8977c478bd9Sstevel@tonic-gate 			line += strlen(line);
8987c478bd9Sstevel@tonic-gate 			switch (proc) {
899*bbaa8b60SDan Kruchinin 			case NLM4_TEST:
9007c478bd9Sstevel@tonic-gate 				/* testres */
9017c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
9027c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
9037c478bd9Sstevel@tonic-gate 				(void) strcat(line,
9047c478bd9Sstevel@tonic-gate 				    nameof_stat4(getxdr_u_long()));
9057c478bd9Sstevel@tonic-gate 				break;
906*bbaa8b60SDan Kruchinin 			case NLM4_LOCK:
907*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL:
908*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK:
909*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED:
910*bbaa8b60SDan Kruchinin 			case NLM4_NM_LOCK:
9117c478bd9Sstevel@tonic-gate 				/* res */
9127c478bd9Sstevel@tonic-gate 				(void) strcat(line, sum_netobj("OH"));
9137c478bd9Sstevel@tonic-gate 				(void) strcat(line, " ");
9147c478bd9Sstevel@tonic-gate 				(void) strcat(line,
9157c478bd9Sstevel@tonic-gate 					nameof_stat4(getxdr_u_long()));
9167c478bd9Sstevel@tonic-gate 				break;
917*bbaa8b60SDan Kruchinin 			case NLM4_SHARE:
918*bbaa8b60SDan Kruchinin 			case NLM4_UNSHARE:
9197c478bd9Sstevel@tonic-gate 				/* shareres */
9207c478bd9Sstevel@tonic-gate 				pl = sum_netobj("OH");
9217c478bd9Sstevel@tonic-gate 				i = getxdr_u_long();
9227c478bd9Sstevel@tonic-gate 				sprintf(line, "%s %s %ld",
9237c478bd9Sstevel@tonic-gate 					pl, nameof_stat4(i), getxdr_long());
9247c478bd9Sstevel@tonic-gate 				break;
925*bbaa8b60SDan Kruchinin 			case NLM4_FREE_ALL:
9267c478bd9Sstevel@tonic-gate 				break;
9277c478bd9Sstevel@tonic-gate 			}
9287c478bd9Sstevel@tonic-gate 		}
9297c478bd9Sstevel@tonic-gate 	}
9307c478bd9Sstevel@tonic-gate 
9317c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
9327c478bd9Sstevel@tonic-gate 		show_header("NLM:  ", "Network Lock Manager", len);
9337c478bd9Sstevel@tonic-gate 		show_space();
9347c478bd9Sstevel@tonic-gate 		if (setjmp(xdr_err)) {
9357c478bd9Sstevel@tonic-gate 			return;
9367c478bd9Sstevel@tonic-gate 		}
9377c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0),
9387c478bd9Sstevel@tonic-gate 			"Proc = %d (%s)",
9397c478bd9Sstevel@tonic-gate 			proc, procnames_long_4[proc]);
9407c478bd9Sstevel@tonic-gate 		if (type == CALL) {
9417c478bd9Sstevel@tonic-gate 			switch (proc) {
942*bbaa8b60SDan Kruchinin 			case NLM4_TEST:
943*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED:
944*bbaa8b60SDan Kruchinin 			case NLM4_TEST_MSG:
945*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_MSG:
9467c478bd9Sstevel@tonic-gate 				show_testargs4();
9477c478bd9Sstevel@tonic-gate 				break;
948*bbaa8b60SDan Kruchinin 			case NLM4_LOCK:
949*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_MSG:
950*bbaa8b60SDan Kruchinin 			case NLM4_NM_LOCK:
9517c478bd9Sstevel@tonic-gate 				show_lockargs4();
9527c478bd9Sstevel@tonic-gate 				break;
953*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL:
954*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_MSG:
9557c478bd9Sstevel@tonic-gate 				show_cancargs4();
9567c478bd9Sstevel@tonic-gate 				break;
957*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK:
958*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_MSG:
9597c478bd9Sstevel@tonic-gate 				show_unlockargs4();
9607c478bd9Sstevel@tonic-gate 				break;
961*bbaa8b60SDan Kruchinin 			case NLM4_TEST_RES:
9627c478bd9Sstevel@tonic-gate 				show_testres4();
9637c478bd9Sstevel@tonic-gate 				break;
964*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_RES:
965*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_RES:
966*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_RES:
967*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_RES:
9687c478bd9Sstevel@tonic-gate 				show_res4();
9697c478bd9Sstevel@tonic-gate 				break;
970*bbaa8b60SDan Kruchinin 			case NLM4_SHARE:
971*bbaa8b60SDan Kruchinin 			case NLM4_UNSHARE:
9727c478bd9Sstevel@tonic-gate 				show_shareargs();
9737c478bd9Sstevel@tonic-gate 				break;
974*bbaa8b60SDan Kruchinin 			case NLM4_FREE_ALL:
9757c478bd9Sstevel@tonic-gate 				show_notify();
9767c478bd9Sstevel@tonic-gate 				break;
9777c478bd9Sstevel@tonic-gate 			}
9787c478bd9Sstevel@tonic-gate 		} else {
9797c478bd9Sstevel@tonic-gate 			switch (proc) {
980*bbaa8b60SDan Kruchinin 			case NLM4_TEST:
9817c478bd9Sstevel@tonic-gate 				show_testres4();
9827c478bd9Sstevel@tonic-gate 				break;
983*bbaa8b60SDan Kruchinin 			case NLM4_LOCK:
984*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL:
985*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK:
986*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED:
9877c478bd9Sstevel@tonic-gate 			case NLM_NM_LOCK:
9887c478bd9Sstevel@tonic-gate 				show_res4();
9897c478bd9Sstevel@tonic-gate 				break;
990*bbaa8b60SDan Kruchinin 			case NLM4_TEST_MSG:
991*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_MSG:
992*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_MSG:
993*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_MSG:
994*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_MSG:
995*bbaa8b60SDan Kruchinin 			case NLM4_TEST_RES:
996*bbaa8b60SDan Kruchinin 			case NLM4_LOCK_RES:
997*bbaa8b60SDan Kruchinin 			case NLM4_CANCEL_RES:
998*bbaa8b60SDan Kruchinin 			case NLM4_UNLOCK_RES:
999*bbaa8b60SDan Kruchinin 			case NLM4_GRANTED_RES:
10007c478bd9Sstevel@tonic-gate 				break;
10017c478bd9Sstevel@tonic-gate 			case NLM_SHARE:
10027c478bd9Sstevel@tonic-gate 			case NLM_UNSHARE:
10037c478bd9Sstevel@tonic-gate 				show_shareres4();
10047c478bd9Sstevel@tonic-gate 				break;
10057c478bd9Sstevel@tonic-gate 			case NLM_FREE_ALL:
10067c478bd9Sstevel@tonic-gate 				break;
10077c478bd9Sstevel@tonic-gate 			}
10087c478bd9Sstevel@tonic-gate 		}
10097c478bd9Sstevel@tonic-gate 		show_trailer();
10107c478bd9Sstevel@tonic-gate 	}
10117c478bd9Sstevel@tonic-gate }
10127c478bd9Sstevel@tonic-gate 
10137c478bd9Sstevel@tonic-gate static char *
sum_lock4()10147c478bd9Sstevel@tonic-gate sum_lock4()
10157c478bd9Sstevel@tonic-gate {
10167c478bd9Sstevel@tonic-gate 	static char buff[LM_MAXSTRLEN + 1];
10177c478bd9Sstevel@tonic-gate 	char *cp = buff;
10187c478bd9Sstevel@tonic-gate 	long id;
10197c478bd9Sstevel@tonic-gate 	u_longlong_t off, len;
10207c478bd9Sstevel@tonic-gate 
10217c478bd9Sstevel@tonic-gate 	(void) getxdr_string(buff, LM_MAXSTRLEN);	/* Caller */
10227c478bd9Sstevel@tonic-gate 	(void) strcpy(buff, sum_netobj("FH"));		/* Fh */
10237c478bd9Sstevel@tonic-gate 	cp += strlen(buff);
10247c478bd9Sstevel@tonic-gate 	skip_netobj();					/* Owner */
10257c478bd9Sstevel@tonic-gate 	id  = getxdr_long();
10267c478bd9Sstevel@tonic-gate 	off = getxdr_u_longlong();
10277c478bd9Sstevel@tonic-gate 	len = getxdr_u_longlong();
10287c478bd9Sstevel@tonic-gate 	(void) sprintf(cp, " PID=%ld Region=%llu:%llu", id, off, len);
10297c478bd9Sstevel@tonic-gate 	return (buff);
10307c478bd9Sstevel@tonic-gate }
10317c478bd9Sstevel@tonic-gate 
10327c478bd9Sstevel@tonic-gate static void
show_lock4()10337c478bd9Sstevel@tonic-gate show_lock4()
10347c478bd9Sstevel@tonic-gate {
10357c478bd9Sstevel@tonic-gate 	showxdr_string(LM_MAXSTRLEN, "Caller = %s");
10367c478bd9Sstevel@tonic-gate 	show_netobj("Filehandle = %s");
10377c478bd9Sstevel@tonic-gate 	show_netobj("Lock owner = %s");
10387c478bd9Sstevel@tonic-gate 	showxdr_long("Svid = %ld (process id)");
10397c478bd9Sstevel@tonic-gate 	showxdr_u_longlong("Offset = %llu bytes");
10407c478bd9Sstevel@tonic-gate 	showxdr_u_longlong("Length = %llu bytes");
10417c478bd9Sstevel@tonic-gate }
10427c478bd9Sstevel@tonic-gate 
10437c478bd9Sstevel@tonic-gate static void
show_cancargs4()10447c478bd9Sstevel@tonic-gate show_cancargs4()
10457c478bd9Sstevel@tonic-gate {
10467c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
10477c478bd9Sstevel@tonic-gate 	showxdr_bool("Block = %s");
10487c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
10497c478bd9Sstevel@tonic-gate 	show_lock4();
10507c478bd9Sstevel@tonic-gate }
10517c478bd9Sstevel@tonic-gate 
10527c478bd9Sstevel@tonic-gate static void
show_lockargs4()10537c478bd9Sstevel@tonic-gate show_lockargs4()
10547c478bd9Sstevel@tonic-gate {
10557c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
10567c478bd9Sstevel@tonic-gate 	showxdr_bool("Block = %s");
10577c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
10587c478bd9Sstevel@tonic-gate 	show_lock4();
10597c478bd9Sstevel@tonic-gate 	showxdr_bool("Reclaim = %s");
10607c478bd9Sstevel@tonic-gate 	showxdr_long("State = %ld");
10617c478bd9Sstevel@tonic-gate }
10627c478bd9Sstevel@tonic-gate 
10637c478bd9Sstevel@tonic-gate static void
show_unlockargs4()10647c478bd9Sstevel@tonic-gate show_unlockargs4()
10657c478bd9Sstevel@tonic-gate {
10667c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
10677c478bd9Sstevel@tonic-gate 	show_lock4();
10687c478bd9Sstevel@tonic-gate }
10697c478bd9Sstevel@tonic-gate 
10707c478bd9Sstevel@tonic-gate static void
show_testargs4()10717c478bd9Sstevel@tonic-gate show_testargs4()
10727c478bd9Sstevel@tonic-gate {
10737c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
10747c478bd9Sstevel@tonic-gate 	showxdr_bool("Exclusive = %s");
10757c478bd9Sstevel@tonic-gate 	show_lock4();
10767c478bd9Sstevel@tonic-gate }
10777c478bd9Sstevel@tonic-gate 
10787c478bd9Sstevel@tonic-gate static void
show_res4()10797c478bd9Sstevel@tonic-gate show_res4()
10807c478bd9Sstevel@tonic-gate {
10817c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
10827c478bd9Sstevel@tonic-gate 	(void) show_stat4();
10837c478bd9Sstevel@tonic-gate }
10847c478bd9Sstevel@tonic-gate 
10857c478bd9Sstevel@tonic-gate static char *
nameof_stat4(s)10867c478bd9Sstevel@tonic-gate nameof_stat4(s)
10877c478bd9Sstevel@tonic-gate 	ulong_t s;
10887c478bd9Sstevel@tonic-gate {
10897c478bd9Sstevel@tonic-gate 	switch ((enum nlm4_stats) s) {
1090*bbaa8b60SDan Kruchinin 	case nlm4_granted:	return ("granted");
1091*bbaa8b60SDan Kruchinin 	case nlm4_denied:	return ("denied");
1092*bbaa8b60SDan Kruchinin 	case nlm4_denied_nolocks:return ("denied (no locks)");
1093*bbaa8b60SDan Kruchinin 	case nlm4_blocked:	return ("blocked");
1094*bbaa8b60SDan Kruchinin 	case nlm4_denied_grace_period: return ("denied (grace period)");
1095*bbaa8b60SDan Kruchinin 	case nlm4_deadlck:	return ("deadlock");
1096*bbaa8b60SDan Kruchinin 	case nlm4_rofs:		return ("read-only fs");
1097*bbaa8b60SDan Kruchinin 	case nlm4_stale_fh:	return ("stale fh");
1098*bbaa8b60SDan Kruchinin 	case nlm4_fbig:		return ("file too big");
1099*bbaa8b60SDan Kruchinin 	case nlm4_failed:	return ("failed");
11007c478bd9Sstevel@tonic-gate 	default:		return ("?");
11017c478bd9Sstevel@tonic-gate 	}
11027c478bd9Sstevel@tonic-gate }
11037c478bd9Sstevel@tonic-gate 
11047c478bd9Sstevel@tonic-gate static enum nlm4_stats
show_stat4()11057c478bd9Sstevel@tonic-gate show_stat4()
11067c478bd9Sstevel@tonic-gate {
11077c478bd9Sstevel@tonic-gate 	enum nlm4_stats s;
11087c478bd9Sstevel@tonic-gate 
11097c478bd9Sstevel@tonic-gate 	s = (enum nlm4_stats) getxdr_u_long();
11107c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0),
11112c2d21e9SRichard Lowe 	    "Status = %d (%s)",
11122c2d21e9SRichard Lowe 	    s, nameof_stat4((ulong_t)s));
11137c478bd9Sstevel@tonic-gate 
11147c478bd9Sstevel@tonic-gate 	return (s);
11157c478bd9Sstevel@tonic-gate }
11167c478bd9Sstevel@tonic-gate 
11177c478bd9Sstevel@tonic-gate static void
show_testres4()11187c478bd9Sstevel@tonic-gate show_testres4()
11197c478bd9Sstevel@tonic-gate {
11207c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
11212c2d21e9SRichard Lowe 	if (show_stat() == nlm_denied) {
11227c478bd9Sstevel@tonic-gate 		showxdr_bool("Exclusive = %s");
11237c478bd9Sstevel@tonic-gate 		showxdr_long("Svid = %ld (process id)");
11247c478bd9Sstevel@tonic-gate 		show_netobj("Owner handle = %s");
11257c478bd9Sstevel@tonic-gate 		showxdr_u_longlong("Offset = %llu bytes");
11267c478bd9Sstevel@tonic-gate 		showxdr_u_longlong("Length = %llu bytes");
11277c478bd9Sstevel@tonic-gate 	}
11287c478bd9Sstevel@tonic-gate }
11297c478bd9Sstevel@tonic-gate 
11307c478bd9Sstevel@tonic-gate static void
show_shareres4()11317c478bd9Sstevel@tonic-gate show_shareres4()
11327c478bd9Sstevel@tonic-gate {
11337c478bd9Sstevel@tonic-gate 	show_netobj("Cookie = %s");
11347c478bd9Sstevel@tonic-gate 	(void) show_stat4();
11357c478bd9Sstevel@tonic-gate 	showxdr_long("Sequence = %d");
11367c478bd9Sstevel@tonic-gate }
1137