1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright (c) 1991, 1998, 2001 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate * All rights reserved.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <sys/types.h>
30*0Sstevel@tonic-gate #include <setjmp.h>
31*0Sstevel@tonic-gate #include <string.h>
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate #ifdef notdef
34*0Sstevel@tonic-gate #include <rpc/xdr.h>
35*0Sstevel@tonic-gate #include <rpc/auth.h>
36*0Sstevel@tonic-gate #include <rpc/rpc_msg.h>
37*0Sstevel@tonic-gate #endif /* notdef */
38*0Sstevel@tonic-gate #include <rpcsvc/nlm_prot.h>
39*0Sstevel@tonic-gate #include "snoop.h"
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate extern char *dlc_header;
42*0Sstevel@tonic-gate extern jmp_buf xdr_err;
43*0Sstevel@tonic-gate
44*0Sstevel@tonic-gate extern void check_retransmit();
45*0Sstevel@tonic-gate static void interpret_nlm_1();
46*0Sstevel@tonic-gate static void interpret_nlm_3();
47*0Sstevel@tonic-gate static void interpret_nlm_4();
48*0Sstevel@tonic-gate static char *nameof_access();
49*0Sstevel@tonic-gate static char *nameof_mode();
50*0Sstevel@tonic-gate static char *nameof_stat();
51*0Sstevel@tonic-gate static char *nameof_stat4();
52*0Sstevel@tonic-gate static void show_cancargs();
53*0Sstevel@tonic-gate static void show_cancargs4();
54*0Sstevel@tonic-gate static void show_lock();
55*0Sstevel@tonic-gate static void show_lock4();
56*0Sstevel@tonic-gate static void show_lockargs();
57*0Sstevel@tonic-gate static void show_lockargs4();
58*0Sstevel@tonic-gate static void show_netobj();
59*0Sstevel@tonic-gate static void show_nlm_access();
60*0Sstevel@tonic-gate static void show_nlm_mode();
61*0Sstevel@tonic-gate static void show_notify();
62*0Sstevel@tonic-gate static void show_res();
63*0Sstevel@tonic-gate static void show_res4();
64*0Sstevel@tonic-gate static void show_share();
65*0Sstevel@tonic-gate static void show_shareargs();
66*0Sstevel@tonic-gate static void show_shareres();
67*0Sstevel@tonic-gate static void show_shareres4();
68*0Sstevel@tonic-gate static enum nlm_stats show_stat();
69*0Sstevel@tonic-gate static enum nlm4_stats show_stat4();
70*0Sstevel@tonic-gate static void show_testargs();
71*0Sstevel@tonic-gate static void show_testargs4();
72*0Sstevel@tonic-gate static void show_testres();
73*0Sstevel@tonic-gate static void show_testres4();
74*0Sstevel@tonic-gate static void show_unlockargs();
75*0Sstevel@tonic-gate static void show_unlockargs4();
76*0Sstevel@tonic-gate static void skip_netobj();
77*0Sstevel@tonic-gate static char *sum_lock();
78*0Sstevel@tonic-gate static char *sum_lock4();
79*0Sstevel@tonic-gate static char *sum_netobj();
80*0Sstevel@tonic-gate static char *sum_notify();
81*0Sstevel@tonic-gate static char *sum_share();
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate void
interpret_nlm(flags,type,xid,vers,proc,data,len)84*0Sstevel@tonic-gate interpret_nlm(flags, type, xid, vers, proc, data, len)
85*0Sstevel@tonic-gate int flags, type, xid, vers, proc;
86*0Sstevel@tonic-gate char *data;
87*0Sstevel@tonic-gate int len;
88*0Sstevel@tonic-gate {
89*0Sstevel@tonic-gate switch (vers) {
90*0Sstevel@tonic-gate case 1: interpret_nlm_1(flags, type, xid, vers, proc, data, len);
91*0Sstevel@tonic-gate break;
92*0Sstevel@tonic-gate case 3: interpret_nlm_3(flags, type, xid, vers, proc, data, len);
93*0Sstevel@tonic-gate break;
94*0Sstevel@tonic-gate case 4: interpret_nlm_4(flags, type, xid, vers, proc, data, len);
95*0Sstevel@tonic-gate break;
96*0Sstevel@tonic-gate }
97*0Sstevel@tonic-gate }
98*0Sstevel@tonic-gate
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gate /* ------------ V E R S I O N 1 ---------------------------------- */
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate static char *procnames_short_1[] = {
103*0Sstevel@tonic-gate "Null1", /* 0 */
104*0Sstevel@tonic-gate "TEST1", /* 1 */
105*0Sstevel@tonic-gate "LOCK1", /* 2 */
106*0Sstevel@tonic-gate "CANCEL1", /* 3 */
107*0Sstevel@tonic-gate "UNLOCK1", /* 4 */
108*0Sstevel@tonic-gate "GRANTED1", /* 5 */
109*0Sstevel@tonic-gate "TEST MSG1", /* 6 */
110*0Sstevel@tonic-gate "LOCK MSG1", /* 7 */
111*0Sstevel@tonic-gate "CANCEL MSG1", /* 8 */
112*0Sstevel@tonic-gate "UNLOCK MSG1", /* 9 */
113*0Sstevel@tonic-gate "GRANTED MSG1", /* 10 */
114*0Sstevel@tonic-gate "TEST RES1", /* 11 */
115*0Sstevel@tonic-gate "LOCK RES1", /* 12 */
116*0Sstevel@tonic-gate "CANCEL RES1", /* 13 */
117*0Sstevel@tonic-gate "UNLOCK RES1", /* 14 */
118*0Sstevel@tonic-gate "GRANTED RES1", /* 15 */
119*0Sstevel@tonic-gate };
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate static char *procnames_long_1[] = {
122*0Sstevel@tonic-gate "Null procedure", /* 0 */
123*0Sstevel@tonic-gate "Test", /* 1 */
124*0Sstevel@tonic-gate "Lock", /* 2 */
125*0Sstevel@tonic-gate "Cancel", /* 3 */
126*0Sstevel@tonic-gate "Unlock", /* 4 */
127*0Sstevel@tonic-gate "Granted", /* 5 */
128*0Sstevel@tonic-gate "Test message", /* 6 */
129*0Sstevel@tonic-gate "Lock message", /* 7 */
130*0Sstevel@tonic-gate "Cancel message", /* 8 */
131*0Sstevel@tonic-gate "Unlock message", /* 9 */
132*0Sstevel@tonic-gate "Granted message", /* 10 */
133*0Sstevel@tonic-gate "Test result", /* 11 */
134*0Sstevel@tonic-gate "Lock result", /* 12 */
135*0Sstevel@tonic-gate "Cancel result", /* 13 */
136*0Sstevel@tonic-gate "Unlock result", /* 14 */
137*0Sstevel@tonic-gate "Granted result", /* 15 */
138*0Sstevel@tonic-gate };
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate /* Highest procedure number that officially belongs to version 1. */
141*0Sstevel@tonic-gate #define MAXPROC_1 15
142*0Sstevel@tonic-gate
143*0Sstevel@tonic-gate /* ARGSUSED */
144*0Sstevel@tonic-gate static void
interpret_nlm_1(flags,type,xid,vers,proc,data,len)145*0Sstevel@tonic-gate interpret_nlm_1(flags, type, xid, vers, proc, data, len)
146*0Sstevel@tonic-gate int flags, type, xid, vers, proc;
147*0Sstevel@tonic-gate char *data;
148*0Sstevel@tonic-gate int len;
149*0Sstevel@tonic-gate {
150*0Sstevel@tonic-gate char *line;
151*0Sstevel@tonic-gate
152*0Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_1)
153*0Sstevel@tonic-gate return;
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate if (flags & F_SUM) {
156*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
157*0Sstevel@tonic-gate return;
158*0Sstevel@tonic-gate }
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate line = get_sum_line();
161*0Sstevel@tonic-gate
162*0Sstevel@tonic-gate if (type == CALL) {
163*0Sstevel@tonic-gate (void) sprintf(line,
164*0Sstevel@tonic-gate "NLM C %s",
165*0Sstevel@tonic-gate procnames_short_1[proc]);
166*0Sstevel@tonic-gate line += strlen(line);
167*0Sstevel@tonic-gate switch (proc) {
168*0Sstevel@tonic-gate case NLM_TEST:
169*0Sstevel@tonic-gate case NLM_GRANTED:
170*0Sstevel@tonic-gate case NLM_TEST_MSG:
171*0Sstevel@tonic-gate case NLM_GRANTED_MSG:
172*0Sstevel@tonic-gate /* testargs */
173*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
174*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
175*0Sstevel@tonic-gate (void) strcat(line, sum_lock());
176*0Sstevel@tonic-gate break;
177*0Sstevel@tonic-gate case NLM_LOCK:
178*0Sstevel@tonic-gate case NLM_LOCK_MSG:
179*0Sstevel@tonic-gate /* lockargs */
180*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
181*0Sstevel@tonic-gate (void) getxdr_bool(); /* Block */
182*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
183*0Sstevel@tonic-gate (void) strcat(line, sum_lock());
184*0Sstevel@tonic-gate break;
185*0Sstevel@tonic-gate case NLM_CANCEL:
186*0Sstevel@tonic-gate case NLM_CANCEL_MSG:
187*0Sstevel@tonic-gate /* cancargs */
188*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
189*0Sstevel@tonic-gate (void) getxdr_bool(); /* Block */
190*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
191*0Sstevel@tonic-gate (void) strcat(line, sum_lock());
192*0Sstevel@tonic-gate break;
193*0Sstevel@tonic-gate case NLM_UNLOCK:
194*0Sstevel@tonic-gate case NLM_UNLOCK_MSG:
195*0Sstevel@tonic-gate /* unlockargs */
196*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
197*0Sstevel@tonic-gate (void) strcat(line, sum_lock());
198*0Sstevel@tonic-gate break;
199*0Sstevel@tonic-gate case NLM_TEST_RES:
200*0Sstevel@tonic-gate /* testres */
201*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
202*0Sstevel@tonic-gate (void) strcat(line, " ");
203*0Sstevel@tonic-gate (void) strcat(line,
204*0Sstevel@tonic-gate nameof_stat(getxdr_u_long()));
205*0Sstevel@tonic-gate break;
206*0Sstevel@tonic-gate case NLM_LOCK_RES:
207*0Sstevel@tonic-gate case NLM_CANCEL_RES:
208*0Sstevel@tonic-gate case NLM_UNLOCK_RES:
209*0Sstevel@tonic-gate case NLM_GRANTED_RES:
210*0Sstevel@tonic-gate /* res */
211*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
212*0Sstevel@tonic-gate (void) strcat(line, " ");
213*0Sstevel@tonic-gate (void) strcat(line,
214*0Sstevel@tonic-gate nameof_stat(getxdr_u_long()));
215*0Sstevel@tonic-gate break;
216*0Sstevel@tonic-gate }
217*0Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
218*0Sstevel@tonic-gate } else {
219*0Sstevel@tonic-gate (void) sprintf(line, "NLM R %s",
220*0Sstevel@tonic-gate procnames_short_1[proc]);
221*0Sstevel@tonic-gate line += strlen(line);
222*0Sstevel@tonic-gate switch (proc) {
223*0Sstevel@tonic-gate case NLM_TEST:
224*0Sstevel@tonic-gate /* testres */
225*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
226*0Sstevel@tonic-gate (void) strcat(line, " ");
227*0Sstevel@tonic-gate (void) strcat(line,
228*0Sstevel@tonic-gate nameof_stat(getxdr_u_long()));
229*0Sstevel@tonic-gate break;
230*0Sstevel@tonic-gate case NLM_LOCK:
231*0Sstevel@tonic-gate case NLM_CANCEL:
232*0Sstevel@tonic-gate case NLM_UNLOCK:
233*0Sstevel@tonic-gate case NLM_GRANTED:
234*0Sstevel@tonic-gate /* res */
235*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
236*0Sstevel@tonic-gate (void) strcat(line, " ");
237*0Sstevel@tonic-gate (void) strcat(line,
238*0Sstevel@tonic-gate nameof_stat(getxdr_u_long()));
239*0Sstevel@tonic-gate break;
240*0Sstevel@tonic-gate }
241*0Sstevel@tonic-gate }
242*0Sstevel@tonic-gate }
243*0Sstevel@tonic-gate
244*0Sstevel@tonic-gate if (flags & F_DTAIL) {
245*0Sstevel@tonic-gate show_header("NLM: ", "Network Lock Manager", len);
246*0Sstevel@tonic-gate show_space();
247*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
248*0Sstevel@tonic-gate return;
249*0Sstevel@tonic-gate }
250*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
251*0Sstevel@tonic-gate "Proc = %d (%s)",
252*0Sstevel@tonic-gate proc, procnames_long_1[proc]);
253*0Sstevel@tonic-gate if (type == CALL) {
254*0Sstevel@tonic-gate switch (proc) {
255*0Sstevel@tonic-gate case NLM_TEST:
256*0Sstevel@tonic-gate case NLM_GRANTED:
257*0Sstevel@tonic-gate case NLM_TEST_MSG:
258*0Sstevel@tonic-gate case NLM_GRANTED_MSG:
259*0Sstevel@tonic-gate show_testargs();
260*0Sstevel@tonic-gate break;
261*0Sstevel@tonic-gate case NLM_LOCK:
262*0Sstevel@tonic-gate case NLM_LOCK_MSG:
263*0Sstevel@tonic-gate show_lockargs();
264*0Sstevel@tonic-gate break;
265*0Sstevel@tonic-gate case NLM_CANCEL:
266*0Sstevel@tonic-gate case NLM_CANCEL_MSG:
267*0Sstevel@tonic-gate show_cancargs();
268*0Sstevel@tonic-gate break;
269*0Sstevel@tonic-gate case NLM_UNLOCK:
270*0Sstevel@tonic-gate case NLM_UNLOCK_MSG:
271*0Sstevel@tonic-gate show_unlockargs();
272*0Sstevel@tonic-gate break;
273*0Sstevel@tonic-gate case NLM_TEST_RES:
274*0Sstevel@tonic-gate show_testres();
275*0Sstevel@tonic-gate break;
276*0Sstevel@tonic-gate case NLM_LOCK_RES:
277*0Sstevel@tonic-gate case NLM_CANCEL_RES:
278*0Sstevel@tonic-gate case NLM_UNLOCK_RES:
279*0Sstevel@tonic-gate case NLM_GRANTED_RES:
280*0Sstevel@tonic-gate show_res();
281*0Sstevel@tonic-gate break;
282*0Sstevel@tonic-gate }
283*0Sstevel@tonic-gate } else {
284*0Sstevel@tonic-gate switch (proc) {
285*0Sstevel@tonic-gate case NLM_TEST:
286*0Sstevel@tonic-gate show_testres();
287*0Sstevel@tonic-gate break;
288*0Sstevel@tonic-gate case NLM_LOCK:
289*0Sstevel@tonic-gate case NLM_CANCEL:
290*0Sstevel@tonic-gate case NLM_UNLOCK:
291*0Sstevel@tonic-gate case NLM_GRANTED:
292*0Sstevel@tonic-gate show_res();
293*0Sstevel@tonic-gate break;
294*0Sstevel@tonic-gate case NLM_TEST_MSG:
295*0Sstevel@tonic-gate case NLM_LOCK_MSG:
296*0Sstevel@tonic-gate case NLM_CANCEL_MSG:
297*0Sstevel@tonic-gate case NLM_UNLOCK_MSG:
298*0Sstevel@tonic-gate case NLM_GRANTED_MSG:
299*0Sstevel@tonic-gate case NLM_TEST_RES:
300*0Sstevel@tonic-gate case NLM_LOCK_RES:
301*0Sstevel@tonic-gate case NLM_CANCEL_RES:
302*0Sstevel@tonic-gate case NLM_UNLOCK_RES:
303*0Sstevel@tonic-gate case NLM_GRANTED_RES:
304*0Sstevel@tonic-gate break;
305*0Sstevel@tonic-gate }
306*0Sstevel@tonic-gate }
307*0Sstevel@tonic-gate show_trailer();
308*0Sstevel@tonic-gate }
309*0Sstevel@tonic-gate }
310*0Sstevel@tonic-gate
311*0Sstevel@tonic-gate #define roundup(sz) ((sz / 4 + (sz % 4 > 0)) * 4)
312*0Sstevel@tonic-gate
313*0Sstevel@tonic-gate /*
314*0Sstevel@tonic-gate * Skip a netobj.
315*0Sstevel@tonic-gate * Make sure an integral number of words
316*0Sstevel@tonic-gate * are skipped.
317*0Sstevel@tonic-gate */
318*0Sstevel@tonic-gate static void
skip_netobj()319*0Sstevel@tonic-gate skip_netobj()
320*0Sstevel@tonic-gate {
321*0Sstevel@tonic-gate int sz = getxdr_u_long();
322*0Sstevel@tonic-gate
323*0Sstevel@tonic-gate xdr_skip(roundup(sz));
324*0Sstevel@tonic-gate }
325*0Sstevel@tonic-gate
326*0Sstevel@tonic-gate static char *
sum_netobj(handle)327*0Sstevel@tonic-gate sum_netobj(handle)
328*0Sstevel@tonic-gate char *handle;
329*0Sstevel@tonic-gate {
330*0Sstevel@tonic-gate int i, l, sz;
331*0Sstevel@tonic-gate int sum = 0;
332*0Sstevel@tonic-gate static char buff[32];
333*0Sstevel@tonic-gate
334*0Sstevel@tonic-gate sz = getxdr_u_long();
335*0Sstevel@tonic-gate for (i = 0; i < sz; i += 4) {
336*0Sstevel@tonic-gate l = getxdr_long();
337*0Sstevel@tonic-gate sum ^= (l >> 16) ^ l;
338*0Sstevel@tonic-gate }
339*0Sstevel@tonic-gate (void) sprintf(buff, " %s=%04X", handle, sum & 0xFFFF);
340*0Sstevel@tonic-gate return (buff);
341*0Sstevel@tonic-gate }
342*0Sstevel@tonic-gate
343*0Sstevel@tonic-gate static void
show_netobj(fmt)344*0Sstevel@tonic-gate show_netobj(fmt)
345*0Sstevel@tonic-gate char *fmt;
346*0Sstevel@tonic-gate {
347*0Sstevel@tonic-gate int sz, chunk;
348*0Sstevel@tonic-gate char *p;
349*0Sstevel@tonic-gate char buff[64];
350*0Sstevel@tonic-gate int needspace;
351*0Sstevel@tonic-gate
352*0Sstevel@tonic-gate sz = getxdr_u_long(); /* size of the netobj */
353*0Sstevel@tonic-gate
354*0Sstevel@tonic-gate if (sz == 0) {
355*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0), fmt, "<null>");
356*0Sstevel@tonic-gate } else {
357*0Sstevel@tonic-gate needspace = sz > 16;
358*0Sstevel@tonic-gate (void) strcpy(buff, fmt);
359*0Sstevel@tonic-gate while (sz > 0) {
360*0Sstevel@tonic-gate chunk = sz > 16 ? 16 : sz;
361*0Sstevel@tonic-gate sz -= 16;
362*0Sstevel@tonic-gate (void) showxdr_hex(chunk, buff);
363*0Sstevel@tonic-gate /*
364*0Sstevel@tonic-gate * For every line after the first, blank out
365*0Sstevel@tonic-gate * everything in the format string before the "%s".
366*0Sstevel@tonic-gate */
367*0Sstevel@tonic-gate for (p = buff; *p != '%'; p++)
368*0Sstevel@tonic-gate *p = ' ';
369*0Sstevel@tonic-gate }
370*0Sstevel@tonic-gate if (needspace)
371*0Sstevel@tonic-gate show_space();
372*0Sstevel@tonic-gate }
373*0Sstevel@tonic-gate }
374*0Sstevel@tonic-gate
375*0Sstevel@tonic-gate static char *
sum_lock()376*0Sstevel@tonic-gate sum_lock()
377*0Sstevel@tonic-gate {
378*0Sstevel@tonic-gate static char buff[LM_MAXSTRLEN + 1];
379*0Sstevel@tonic-gate char *cp = buff;
380*0Sstevel@tonic-gate long id;
381*0Sstevel@tonic-gate ulong_t off, len;
382*0Sstevel@tonic-gate
383*0Sstevel@tonic-gate (void) getxdr_string(buff, LM_MAXSTRLEN); /* Caller */
384*0Sstevel@tonic-gate (void) strcpy(buff, sum_netobj("FH")); /* Fh */
385*0Sstevel@tonic-gate cp += strlen(buff);
386*0Sstevel@tonic-gate skip_netobj(); /* Owner */
387*0Sstevel@tonic-gate id = getxdr_long();
388*0Sstevel@tonic-gate off = getxdr_u_long();
389*0Sstevel@tonic-gate len = getxdr_u_long();
390*0Sstevel@tonic-gate (void) sprintf(cp, " PID=%ld Region=%lu:%lu", id, off, len);
391*0Sstevel@tonic-gate return (buff);
392*0Sstevel@tonic-gate }
393*0Sstevel@tonic-gate
394*0Sstevel@tonic-gate static void
show_lock()395*0Sstevel@tonic-gate show_lock()
396*0Sstevel@tonic-gate {
397*0Sstevel@tonic-gate showxdr_string(LM_MAXSTRLEN, "Caller = %s");
398*0Sstevel@tonic-gate show_netobj("Filehandle = %s");
399*0Sstevel@tonic-gate show_netobj("Lock owner = %s");
400*0Sstevel@tonic-gate showxdr_long("Svid = %ld (process id)");
401*0Sstevel@tonic-gate showxdr_u_long("Offset = %lu bytes");
402*0Sstevel@tonic-gate showxdr_u_long("Length = %lu bytes");
403*0Sstevel@tonic-gate }
404*0Sstevel@tonic-gate
405*0Sstevel@tonic-gate static void
show_cancargs()406*0Sstevel@tonic-gate show_cancargs()
407*0Sstevel@tonic-gate {
408*0Sstevel@tonic-gate show_netobj("Cookie = %s");
409*0Sstevel@tonic-gate showxdr_bool("Block = %s");
410*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
411*0Sstevel@tonic-gate show_lock();
412*0Sstevel@tonic-gate }
413*0Sstevel@tonic-gate
414*0Sstevel@tonic-gate static void
show_lockargs()415*0Sstevel@tonic-gate show_lockargs()
416*0Sstevel@tonic-gate {
417*0Sstevel@tonic-gate show_netobj("Cookie = %s");
418*0Sstevel@tonic-gate showxdr_bool("Block = %s");
419*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
420*0Sstevel@tonic-gate show_lock();
421*0Sstevel@tonic-gate showxdr_bool("Reclaim = %s");
422*0Sstevel@tonic-gate showxdr_long("State = %ld");
423*0Sstevel@tonic-gate }
424*0Sstevel@tonic-gate
425*0Sstevel@tonic-gate static void
show_unlockargs()426*0Sstevel@tonic-gate show_unlockargs()
427*0Sstevel@tonic-gate {
428*0Sstevel@tonic-gate show_netobj("Cookie = %s");
429*0Sstevel@tonic-gate show_lock();
430*0Sstevel@tonic-gate }
431*0Sstevel@tonic-gate
432*0Sstevel@tonic-gate static void
show_testargs()433*0Sstevel@tonic-gate show_testargs()
434*0Sstevel@tonic-gate {
435*0Sstevel@tonic-gate show_netobj("Cookie = %s");
436*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
437*0Sstevel@tonic-gate show_lock();
438*0Sstevel@tonic-gate }
439*0Sstevel@tonic-gate
440*0Sstevel@tonic-gate static void
show_res()441*0Sstevel@tonic-gate show_res()
442*0Sstevel@tonic-gate {
443*0Sstevel@tonic-gate show_netobj("Cookie = %s");
444*0Sstevel@tonic-gate (void) show_stat();
445*0Sstevel@tonic-gate }
446*0Sstevel@tonic-gate
447*0Sstevel@tonic-gate static char *
nameof_stat(s)448*0Sstevel@tonic-gate nameof_stat(s)
449*0Sstevel@tonic-gate ulong_t s;
450*0Sstevel@tonic-gate {
451*0Sstevel@tonic-gate switch ((enum nlm_stats) s) {
452*0Sstevel@tonic-gate case nlm_granted: return ("granted");
453*0Sstevel@tonic-gate case nlm_denied: return ("denied");
454*0Sstevel@tonic-gate case nlm_denied_nolocks:return ("denied (no locks)");
455*0Sstevel@tonic-gate case nlm_blocked: return ("blocked");
456*0Sstevel@tonic-gate case nlm_denied_grace_period: return ("denied (grace period)");
457*0Sstevel@tonic-gate case nlm_deadlck: return ("deadlock");
458*0Sstevel@tonic-gate default: return ("?");
459*0Sstevel@tonic-gate }
460*0Sstevel@tonic-gate }
461*0Sstevel@tonic-gate
462*0Sstevel@tonic-gate static enum nlm_stats
show_stat()463*0Sstevel@tonic-gate show_stat()
464*0Sstevel@tonic-gate {
465*0Sstevel@tonic-gate enum nlm_stats s;
466*0Sstevel@tonic-gate
467*0Sstevel@tonic-gate s = (enum nlm_stats) getxdr_u_long();
468*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
469*0Sstevel@tonic-gate "Status = %d (%s)",
470*0Sstevel@tonic-gate s, nameof_stat((ulong_t)s));
471*0Sstevel@tonic-gate
472*0Sstevel@tonic-gate return (s);
473*0Sstevel@tonic-gate }
474*0Sstevel@tonic-gate
475*0Sstevel@tonic-gate static void
show_testres()476*0Sstevel@tonic-gate show_testres()
477*0Sstevel@tonic-gate {
478*0Sstevel@tonic-gate show_netobj("Cookie = %s");
479*0Sstevel@tonic-gate if (show_stat() == nlm_denied) {
480*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
481*0Sstevel@tonic-gate showxdr_long("Svid = %ld (process id)");
482*0Sstevel@tonic-gate show_netobj("Owner handle = %s");
483*0Sstevel@tonic-gate showxdr_u_long("Offset = %lu bytes");
484*0Sstevel@tonic-gate showxdr_u_long("Length = %lu bytes");
485*0Sstevel@tonic-gate }
486*0Sstevel@tonic-gate }
487*0Sstevel@tonic-gate
488*0Sstevel@tonic-gate
489*0Sstevel@tonic-gate /* ------------ V E R S I O N 3 ---------------------------------- */
490*0Sstevel@tonic-gate
491*0Sstevel@tonic-gate static char *procnames_short_3[] = {
492*0Sstevel@tonic-gate "SHARE3", /* 20 */
493*0Sstevel@tonic-gate "UNSHARE3", /* 21 */
494*0Sstevel@tonic-gate "NM_LOCK3", /* 22 */
495*0Sstevel@tonic-gate "FREEALL3", /* 23 */
496*0Sstevel@tonic-gate };
497*0Sstevel@tonic-gate
498*0Sstevel@tonic-gate static char *procnames_long_3[] = {
499*0Sstevel@tonic-gate "Share", /* 20 */
500*0Sstevel@tonic-gate "Unshare", /* 21 */
501*0Sstevel@tonic-gate "Unmonitored lock", /* 22 */
502*0Sstevel@tonic-gate "Free all", /* 23 */
503*0Sstevel@tonic-gate };
504*0Sstevel@tonic-gate
505*0Sstevel@tonic-gate /* Maximum procedure number for version 3. */
506*0Sstevel@tonic-gate #define MAXPROC_3 23
507*0Sstevel@tonic-gate
508*0Sstevel@tonic-gate static void
interpret_nlm_3(flags,type,xid,vers,proc,data,len)509*0Sstevel@tonic-gate interpret_nlm_3(flags, type, xid, vers, proc, data, len)
510*0Sstevel@tonic-gate int flags, type, xid, vers, proc;
511*0Sstevel@tonic-gate char *data;
512*0Sstevel@tonic-gate int len;
513*0Sstevel@tonic-gate {
514*0Sstevel@tonic-gate char *line, *pl;
515*0Sstevel@tonic-gate ulong_t i;
516*0Sstevel@tonic-gate
517*0Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_3)
518*0Sstevel@tonic-gate return;
519*0Sstevel@tonic-gate
520*0Sstevel@tonic-gate /*
521*0Sstevel@tonic-gate * Version 3 is a superset of version 1
522*0Sstevel@tonic-gate */
523*0Sstevel@tonic-gate if (proc >= 0 && proc <= MAXPROC_1) {
524*0Sstevel@tonic-gate interpret_nlm_1(flags, type, xid, vers, proc, data, len);
525*0Sstevel@tonic-gate return;
526*0Sstevel@tonic-gate }
527*0Sstevel@tonic-gate
528*0Sstevel@tonic-gate if (flags & F_SUM) {
529*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
530*0Sstevel@tonic-gate return;
531*0Sstevel@tonic-gate }
532*0Sstevel@tonic-gate
533*0Sstevel@tonic-gate line = get_sum_line();
534*0Sstevel@tonic-gate
535*0Sstevel@tonic-gate if (type == CALL) {
536*0Sstevel@tonic-gate (void) sprintf(line,
537*0Sstevel@tonic-gate "NLM C %s",
538*0Sstevel@tonic-gate procnames_short_3[proc-20]);
539*0Sstevel@tonic-gate line += strlen(line);
540*0Sstevel@tonic-gate switch (proc) {
541*0Sstevel@tonic-gate case NLM_SHARE:
542*0Sstevel@tonic-gate case NLM_UNSHARE:
543*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
544*0Sstevel@tonic-gate (void) strcat(line, sum_share());
545*0Sstevel@tonic-gate break;
546*0Sstevel@tonic-gate case NLM_NM_LOCK:
547*0Sstevel@tonic-gate /* lockargs */
548*0Sstevel@tonic-gate skip_netobj();
549*0Sstevel@tonic-gate (void) getxdr_u_long(); /* Block */
550*0Sstevel@tonic-gate (void) getxdr_u_long(); /* Excl */
551*0Sstevel@tonic-gate (void) strcat(line, sum_lock());
552*0Sstevel@tonic-gate break;
553*0Sstevel@tonic-gate case NLM_FREE_ALL:
554*0Sstevel@tonic-gate (void) sprintf(line,
555*0Sstevel@tonic-gate " %s", sum_notify());
556*0Sstevel@tonic-gate break;
557*0Sstevel@tonic-gate }
558*0Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
559*0Sstevel@tonic-gate } else {
560*0Sstevel@tonic-gate (void) sprintf(line, "NLM R %s",
561*0Sstevel@tonic-gate procnames_short_3[proc-20]);
562*0Sstevel@tonic-gate line += strlen(line);
563*0Sstevel@tonic-gate switch (proc) {
564*0Sstevel@tonic-gate case NLM_SHARE:
565*0Sstevel@tonic-gate case NLM_UNSHARE:
566*0Sstevel@tonic-gate pl = sum_netobj("OH");
567*0Sstevel@tonic-gate i = getxdr_u_long();
568*0Sstevel@tonic-gate sprintf(line, "%s %s %ld",
569*0Sstevel@tonic-gate pl, nameof_stat(i), getxdr_long());
570*0Sstevel@tonic-gate break;
571*0Sstevel@tonic-gate case NLM_NM_LOCK:
572*0Sstevel@tonic-gate /* res */
573*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
574*0Sstevel@tonic-gate (void) strcat(line, " ");
575*0Sstevel@tonic-gate (void) strcat(line,
576*0Sstevel@tonic-gate nameof_stat(getxdr_u_long()));
577*0Sstevel@tonic-gate break;
578*0Sstevel@tonic-gate case NLM_FREE_ALL:
579*0Sstevel@tonic-gate break;
580*0Sstevel@tonic-gate }
581*0Sstevel@tonic-gate }
582*0Sstevel@tonic-gate }
583*0Sstevel@tonic-gate
584*0Sstevel@tonic-gate if (flags & F_DTAIL) {
585*0Sstevel@tonic-gate show_header("NLM: ", "Network Lock Manager", len);
586*0Sstevel@tonic-gate show_space();
587*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
588*0Sstevel@tonic-gate return;
589*0Sstevel@tonic-gate }
590*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
591*0Sstevel@tonic-gate "Proc = %d (%s)",
592*0Sstevel@tonic-gate proc, procnames_long_3[proc-20]);
593*0Sstevel@tonic-gate if (type == CALL) {
594*0Sstevel@tonic-gate switch (proc) {
595*0Sstevel@tonic-gate case NLM_SHARE:
596*0Sstevel@tonic-gate case NLM_UNSHARE:
597*0Sstevel@tonic-gate show_shareargs();
598*0Sstevel@tonic-gate break;
599*0Sstevel@tonic-gate case NLM_NM_LOCK:
600*0Sstevel@tonic-gate show_lockargs();
601*0Sstevel@tonic-gate break;
602*0Sstevel@tonic-gate case NLM_FREE_ALL:
603*0Sstevel@tonic-gate show_notify();
604*0Sstevel@tonic-gate break;
605*0Sstevel@tonic-gate }
606*0Sstevel@tonic-gate } else {
607*0Sstevel@tonic-gate switch (proc) {
608*0Sstevel@tonic-gate case NLM_SHARE:
609*0Sstevel@tonic-gate case NLM_UNSHARE:
610*0Sstevel@tonic-gate show_shareres();
611*0Sstevel@tonic-gate break;
612*0Sstevel@tonic-gate case NLM_NM_LOCK:
613*0Sstevel@tonic-gate show_res();
614*0Sstevel@tonic-gate break;
615*0Sstevel@tonic-gate case NLM_FREE_ALL:
616*0Sstevel@tonic-gate break;
617*0Sstevel@tonic-gate }
618*0Sstevel@tonic-gate }
619*0Sstevel@tonic-gate show_trailer();
620*0Sstevel@tonic-gate }
621*0Sstevel@tonic-gate }
622*0Sstevel@tonic-gate
623*0Sstevel@tonic-gate static char *
nameof_mode(m)624*0Sstevel@tonic-gate nameof_mode(m)
625*0Sstevel@tonic-gate uint_t m;
626*0Sstevel@tonic-gate {
627*0Sstevel@tonic-gate switch ((enum fsh_mode) m) {
628*0Sstevel@tonic-gate case fsm_DN: return ("deny none");
629*0Sstevel@tonic-gate case fsm_DR: return ("deny read");
630*0Sstevel@tonic-gate case fsm_DW: return ("deny write");
631*0Sstevel@tonic-gate case fsm_DRW: return ("deny read/write");
632*0Sstevel@tonic-gate default: return ("?");
633*0Sstevel@tonic-gate }
634*0Sstevel@tonic-gate }
635*0Sstevel@tonic-gate
636*0Sstevel@tonic-gate static char *
nameof_access(a)637*0Sstevel@tonic-gate nameof_access(a)
638*0Sstevel@tonic-gate uint_t a;
639*0Sstevel@tonic-gate {
640*0Sstevel@tonic-gate switch ((enum fsh_access) a) {
641*0Sstevel@tonic-gate case fsa_NONE: return ("?");
642*0Sstevel@tonic-gate case fsa_R: return ("read only");
643*0Sstevel@tonic-gate case fsa_W: return ("write only");
644*0Sstevel@tonic-gate case fsa_RW: return ("read/write");
645*0Sstevel@tonic-gate default: return ("?");
646*0Sstevel@tonic-gate }
647*0Sstevel@tonic-gate }
648*0Sstevel@tonic-gate
649*0Sstevel@tonic-gate static void
show_nlm_mode()650*0Sstevel@tonic-gate show_nlm_mode()
651*0Sstevel@tonic-gate {
652*0Sstevel@tonic-gate enum fsh_mode m;
653*0Sstevel@tonic-gate
654*0Sstevel@tonic-gate m = (enum fsh_mode) getxdr_u_long();
655*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
656*0Sstevel@tonic-gate "Mode = %d (%s)",
657*0Sstevel@tonic-gate m, nameof_mode((uint_t)m));
658*0Sstevel@tonic-gate }
659*0Sstevel@tonic-gate
660*0Sstevel@tonic-gate static void
show_nlm_access()661*0Sstevel@tonic-gate show_nlm_access()
662*0Sstevel@tonic-gate {
663*0Sstevel@tonic-gate enum fsh_access a;
664*0Sstevel@tonic-gate
665*0Sstevel@tonic-gate a = (enum fsh_access) getxdr_u_long();
666*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
667*0Sstevel@tonic-gate "Access = %d (%s)",
668*0Sstevel@tonic-gate a, nameof_access((uint_t)a));
669*0Sstevel@tonic-gate }
670*0Sstevel@tonic-gate
671*0Sstevel@tonic-gate static char *
sum_share()672*0Sstevel@tonic-gate sum_share()
673*0Sstevel@tonic-gate {
674*0Sstevel@tonic-gate static char buff[LM_MAXSTRLEN + 1];
675*0Sstevel@tonic-gate char *cp = buff;
676*0Sstevel@tonic-gate ulong_t mode, access;
677*0Sstevel@tonic-gate
678*0Sstevel@tonic-gate (void) getxdr_string(buff, LM_MAXSTRLEN); /* Caller */
679*0Sstevel@tonic-gate (void) strcpy(buff, sum_netobj("FH")); /* Fh */
680*0Sstevel@tonic-gate cp += strlen(buff);
681*0Sstevel@tonic-gate skip_netobj(); /* Owner */
682*0Sstevel@tonic-gate mode = getxdr_u_long();
683*0Sstevel@tonic-gate access = getxdr_u_long();
684*0Sstevel@tonic-gate (void) sprintf(cp, " Mode=%lu Access=%lu", mode, access);
685*0Sstevel@tonic-gate return (buff);
686*0Sstevel@tonic-gate }
687*0Sstevel@tonic-gate
688*0Sstevel@tonic-gate static void
show_share()689*0Sstevel@tonic-gate show_share()
690*0Sstevel@tonic-gate {
691*0Sstevel@tonic-gate showxdr_string(LM_MAXSTRLEN, "Caller = %s");
692*0Sstevel@tonic-gate show_netobj("Filehandle = %s");
693*0Sstevel@tonic-gate show_netobj("Lock owner = %s");
694*0Sstevel@tonic-gate show_nlm_mode();
695*0Sstevel@tonic-gate show_nlm_access();
696*0Sstevel@tonic-gate }
697*0Sstevel@tonic-gate
698*0Sstevel@tonic-gate static void
show_shareargs()699*0Sstevel@tonic-gate show_shareargs()
700*0Sstevel@tonic-gate {
701*0Sstevel@tonic-gate show_netobj("Cookie = %s");
702*0Sstevel@tonic-gate show_share();
703*0Sstevel@tonic-gate showxdr_bool("Reclaim = %s");
704*0Sstevel@tonic-gate }
705*0Sstevel@tonic-gate
706*0Sstevel@tonic-gate static void
show_shareres()707*0Sstevel@tonic-gate show_shareres()
708*0Sstevel@tonic-gate {
709*0Sstevel@tonic-gate show_netobj("Cookie = %s");
710*0Sstevel@tonic-gate (void) show_stat();
711*0Sstevel@tonic-gate showxdr_long("Sequence = %d");
712*0Sstevel@tonic-gate }
713*0Sstevel@tonic-gate
714*0Sstevel@tonic-gate static void
show_notify()715*0Sstevel@tonic-gate show_notify()
716*0Sstevel@tonic-gate {
717*0Sstevel@tonic-gate showxdr_string(LM_MAXNAMELEN, "Name = %s");
718*0Sstevel@tonic-gate showxdr_long("State = %d");
719*0Sstevel@tonic-gate }
720*0Sstevel@tonic-gate
721*0Sstevel@tonic-gate #define NOTIFY_PAD (sizeof (" State=-2147483648") + 1)
722*0Sstevel@tonic-gate
723*0Sstevel@tonic-gate static char *
sum_notify()724*0Sstevel@tonic-gate sum_notify()
725*0Sstevel@tonic-gate {
726*0Sstevel@tonic-gate static char buff[LM_MAXNAMELEN + NOTIFY_PAD];
727*0Sstevel@tonic-gate char *cp = buff;
728*0Sstevel@tonic-gate long state;
729*0Sstevel@tonic-gate
730*0Sstevel@tonic-gate (void) getxdr_string(buff, LM_MAXNAMELEN);
731*0Sstevel@tonic-gate cp += strlen(buff);
732*0Sstevel@tonic-gate state = getxdr_long();
733*0Sstevel@tonic-gate (void) sprintf(cp, " State=%ld", state);
734*0Sstevel@tonic-gate return (buff);
735*0Sstevel@tonic-gate }
736*0Sstevel@tonic-gate
737*0Sstevel@tonic-gate /* ------------ V E R S I O N 4 ---------------------------------- */
738*0Sstevel@tonic-gate
739*0Sstevel@tonic-gate static char *procnames_short_4[] = {
740*0Sstevel@tonic-gate "Null4", /* 0 */
741*0Sstevel@tonic-gate "TEST4", /* 1 */
742*0Sstevel@tonic-gate "LOCK4", /* 2 */
743*0Sstevel@tonic-gate "CANCEL4", /* 3 */
744*0Sstevel@tonic-gate "UNLOCK4", /* 4 */
745*0Sstevel@tonic-gate "GRANTED4", /* 5 */
746*0Sstevel@tonic-gate "TEST MSG4", /* 6 */
747*0Sstevel@tonic-gate "LOCK MSG4", /* 7 */
748*0Sstevel@tonic-gate "CANCEL MSG4", /* 8 */
749*0Sstevel@tonic-gate "UNLOCK MSG4", /* 9 */
750*0Sstevel@tonic-gate "GRANTED MSG4", /* 10 */
751*0Sstevel@tonic-gate "TEST RES4", /* 11 */
752*0Sstevel@tonic-gate "LOCK RES4", /* 12 */
753*0Sstevel@tonic-gate "CANCEL RES4", /* 13 */
754*0Sstevel@tonic-gate "UNLOCK RES4", /* 14 */
755*0Sstevel@tonic-gate "GRANTED RES4", /* 15 */
756*0Sstevel@tonic-gate "PROC 16 v4", /* 16 */
757*0Sstevel@tonic-gate "PROC 17 v4", /* 17 */
758*0Sstevel@tonic-gate "PROC 18 v4", /* 18 */
759*0Sstevel@tonic-gate "PROC 19 v4", /* 19 */
760*0Sstevel@tonic-gate "SHARE4", /* 20 */
761*0Sstevel@tonic-gate "UNSHARE4", /* 21 */
762*0Sstevel@tonic-gate "NM_LOCK4", /* 22 */
763*0Sstevel@tonic-gate "FREEALL4", /* 23 */
764*0Sstevel@tonic-gate };
765*0Sstevel@tonic-gate
766*0Sstevel@tonic-gate static char *procnames_long_4[] = {
767*0Sstevel@tonic-gate "Null procedure", /* 0 */
768*0Sstevel@tonic-gate "Test", /* 1 */
769*0Sstevel@tonic-gate "Lock", /* 2 */
770*0Sstevel@tonic-gate "Cancel", /* 3 */
771*0Sstevel@tonic-gate "Unlock", /* 4 */
772*0Sstevel@tonic-gate "Granted", /* 5 */
773*0Sstevel@tonic-gate "Test message", /* 6 */
774*0Sstevel@tonic-gate "Lock message", /* 7 */
775*0Sstevel@tonic-gate "Cancel message", /* 8 */
776*0Sstevel@tonic-gate "Unlock message", /* 9 */
777*0Sstevel@tonic-gate "Granted message", /* 10 */
778*0Sstevel@tonic-gate "Test result", /* 11 */
779*0Sstevel@tonic-gate "Lock result", /* 12 */
780*0Sstevel@tonic-gate "Cancel result", /* 13 */
781*0Sstevel@tonic-gate "Unlock result", /* 14 */
782*0Sstevel@tonic-gate "Granted result", /* 15 */
783*0Sstevel@tonic-gate "Procedure 16", /* 16 */
784*0Sstevel@tonic-gate "Procedure 17", /* 17 */
785*0Sstevel@tonic-gate "Procedure 18", /* 18 */
786*0Sstevel@tonic-gate "Procedure 19", /* 19 */
787*0Sstevel@tonic-gate "Share", /* 20 */
788*0Sstevel@tonic-gate "Unshare", /* 21 */
789*0Sstevel@tonic-gate "Unmonitored lock", /* 22 */
790*0Sstevel@tonic-gate "Free all", /* 23 */
791*0Sstevel@tonic-gate };
792*0Sstevel@tonic-gate
793*0Sstevel@tonic-gate /* Maximum procedure number for version 4. */
794*0Sstevel@tonic-gate #define MAXPROC_4 23
795*0Sstevel@tonic-gate
796*0Sstevel@tonic-gate /* ARGSUSED */
797*0Sstevel@tonic-gate static void
interpret_nlm_4(flags,type,xid,vers,proc,data,len)798*0Sstevel@tonic-gate interpret_nlm_4(flags, type, xid, vers, proc, data, len)
799*0Sstevel@tonic-gate int flags, type, xid, vers, proc;
800*0Sstevel@tonic-gate char *data;
801*0Sstevel@tonic-gate int len;
802*0Sstevel@tonic-gate {
803*0Sstevel@tonic-gate char *line;
804*0Sstevel@tonic-gate char *pl;
805*0Sstevel@tonic-gate ulong_t i;
806*0Sstevel@tonic-gate
807*0Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_4)
808*0Sstevel@tonic-gate return;
809*0Sstevel@tonic-gate
810*0Sstevel@tonic-gate if (flags & F_SUM) {
811*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
812*0Sstevel@tonic-gate return;
813*0Sstevel@tonic-gate }
814*0Sstevel@tonic-gate
815*0Sstevel@tonic-gate line = get_sum_line();
816*0Sstevel@tonic-gate
817*0Sstevel@tonic-gate if (type == CALL) {
818*0Sstevel@tonic-gate (void) sprintf(line,
819*0Sstevel@tonic-gate "NLM C %s",
820*0Sstevel@tonic-gate procnames_short_4[proc]);
821*0Sstevel@tonic-gate line += strlen(line);
822*0Sstevel@tonic-gate switch (proc) {
823*0Sstevel@tonic-gate case NLMPROC4_TEST:
824*0Sstevel@tonic-gate case NLMPROC4_GRANTED:
825*0Sstevel@tonic-gate case NLMPROC4_TEST_MSG:
826*0Sstevel@tonic-gate case NLMPROC4_GRANTED_MSG:
827*0Sstevel@tonic-gate /* testargs */
828*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
829*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
830*0Sstevel@tonic-gate (void) strcat(line, sum_lock4());
831*0Sstevel@tonic-gate break;
832*0Sstevel@tonic-gate case NLMPROC4_LOCK:
833*0Sstevel@tonic-gate case NLMPROC4_LOCK_MSG:
834*0Sstevel@tonic-gate /* lockargs */
835*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
836*0Sstevel@tonic-gate (void) getxdr_bool(); /* Block */
837*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
838*0Sstevel@tonic-gate (void) strcat(line, sum_lock4());
839*0Sstevel@tonic-gate /* ignore reclaim, state fields */
840*0Sstevel@tonic-gate break;
841*0Sstevel@tonic-gate case NLMPROC4_CANCEL:
842*0Sstevel@tonic-gate case NLMPROC4_CANCEL_MSG:
843*0Sstevel@tonic-gate /* cancargs */
844*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
845*0Sstevel@tonic-gate (void) getxdr_bool(); /* Block */
846*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
847*0Sstevel@tonic-gate (void) strcat(line, sum_lock4());
848*0Sstevel@tonic-gate break;
849*0Sstevel@tonic-gate case NLMPROC4_UNLOCK:
850*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_MSG:
851*0Sstevel@tonic-gate /* unlockargs */
852*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
853*0Sstevel@tonic-gate (void) strcat(line, sum_lock4());
854*0Sstevel@tonic-gate break;
855*0Sstevel@tonic-gate case NLMPROC4_TEST_RES:
856*0Sstevel@tonic-gate /* testres */
857*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
858*0Sstevel@tonic-gate (void) strcat(line, " ");
859*0Sstevel@tonic-gate (void) strcat(line,
860*0Sstevel@tonic-gate nameof_stat4(getxdr_u_long()));
861*0Sstevel@tonic-gate break;
862*0Sstevel@tonic-gate case NLMPROC4_LOCK_RES:
863*0Sstevel@tonic-gate case NLMPROC4_CANCEL_RES:
864*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_RES:
865*0Sstevel@tonic-gate case NLMPROC4_GRANTED_RES:
866*0Sstevel@tonic-gate /* res */
867*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
868*0Sstevel@tonic-gate (void) strcat(line, " ");
869*0Sstevel@tonic-gate (void) strcat(line,
870*0Sstevel@tonic-gate nameof_stat4(getxdr_u_long()));
871*0Sstevel@tonic-gate break;
872*0Sstevel@tonic-gate case NLMPROC4_SHARE:
873*0Sstevel@tonic-gate case NLMPROC4_UNSHARE:
874*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
875*0Sstevel@tonic-gate (void) strcat(line, sum_share());
876*0Sstevel@tonic-gate break;
877*0Sstevel@tonic-gate case NLMPROC4_NM_LOCK:
878*0Sstevel@tonic-gate /* lockargs */
879*0Sstevel@tonic-gate skip_netobj(); /* Cookie */
880*0Sstevel@tonic-gate (void) getxdr_bool(); /* Block */
881*0Sstevel@tonic-gate (void) getxdr_bool(); /* Excl */
882*0Sstevel@tonic-gate (void) strcat(line, sum_lock4());
883*0Sstevel@tonic-gate /* skip reclaim & state fields */
884*0Sstevel@tonic-gate break;
885*0Sstevel@tonic-gate case NLMPROC4_FREE_ALL:
886*0Sstevel@tonic-gate (void) sprintf(line,
887*0Sstevel@tonic-gate " %s", sum_notify());
888*0Sstevel@tonic-gate break;
889*0Sstevel@tonic-gate }
890*0Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
891*0Sstevel@tonic-gate } else {
892*0Sstevel@tonic-gate (void) sprintf(line, "NLM R %s",
893*0Sstevel@tonic-gate procnames_short_4[proc]);
894*0Sstevel@tonic-gate line += strlen(line);
895*0Sstevel@tonic-gate switch (proc) {
896*0Sstevel@tonic-gate case NLMPROC4_TEST:
897*0Sstevel@tonic-gate /* testres */
898*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
899*0Sstevel@tonic-gate (void) strcat(line, " ");
900*0Sstevel@tonic-gate (void) strcat(line,
901*0Sstevel@tonic-gate nameof_stat4(getxdr_u_long()));
902*0Sstevel@tonic-gate break;
903*0Sstevel@tonic-gate case NLMPROC4_LOCK:
904*0Sstevel@tonic-gate case NLMPROC4_CANCEL:
905*0Sstevel@tonic-gate case NLMPROC4_UNLOCK:
906*0Sstevel@tonic-gate case NLMPROC4_GRANTED:
907*0Sstevel@tonic-gate case NLMPROC4_NM_LOCK:
908*0Sstevel@tonic-gate /* res */
909*0Sstevel@tonic-gate (void) strcat(line, sum_netobj("OH"));
910*0Sstevel@tonic-gate (void) strcat(line, " ");
911*0Sstevel@tonic-gate (void) strcat(line,
912*0Sstevel@tonic-gate nameof_stat4(getxdr_u_long()));
913*0Sstevel@tonic-gate break;
914*0Sstevel@tonic-gate case NLMPROC4_SHARE:
915*0Sstevel@tonic-gate case NLMPROC4_UNSHARE:
916*0Sstevel@tonic-gate /* shareres */
917*0Sstevel@tonic-gate pl = sum_netobj("OH");
918*0Sstevel@tonic-gate i = getxdr_u_long();
919*0Sstevel@tonic-gate sprintf(line, "%s %s %ld",
920*0Sstevel@tonic-gate pl, nameof_stat4(i), getxdr_long());
921*0Sstevel@tonic-gate break;
922*0Sstevel@tonic-gate case NLMPROC4_FREE_ALL:
923*0Sstevel@tonic-gate break;
924*0Sstevel@tonic-gate }
925*0Sstevel@tonic-gate }
926*0Sstevel@tonic-gate }
927*0Sstevel@tonic-gate
928*0Sstevel@tonic-gate if (flags & F_DTAIL) {
929*0Sstevel@tonic-gate show_header("NLM: ", "Network Lock Manager", len);
930*0Sstevel@tonic-gate show_space();
931*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
932*0Sstevel@tonic-gate return;
933*0Sstevel@tonic-gate }
934*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
935*0Sstevel@tonic-gate "Proc = %d (%s)",
936*0Sstevel@tonic-gate proc, procnames_long_4[proc]);
937*0Sstevel@tonic-gate if (type == CALL) {
938*0Sstevel@tonic-gate switch (proc) {
939*0Sstevel@tonic-gate case NLMPROC4_TEST:
940*0Sstevel@tonic-gate case NLMPROC4_GRANTED:
941*0Sstevel@tonic-gate case NLMPROC4_TEST_MSG:
942*0Sstevel@tonic-gate case NLMPROC4_GRANTED_MSG:
943*0Sstevel@tonic-gate show_testargs4();
944*0Sstevel@tonic-gate break;
945*0Sstevel@tonic-gate case NLMPROC4_LOCK:
946*0Sstevel@tonic-gate case NLMPROC4_LOCK_MSG:
947*0Sstevel@tonic-gate case NLMPROC4_NM_LOCK:
948*0Sstevel@tonic-gate show_lockargs4();
949*0Sstevel@tonic-gate break;
950*0Sstevel@tonic-gate case NLMPROC4_CANCEL:
951*0Sstevel@tonic-gate case NLMPROC4_CANCEL_MSG:
952*0Sstevel@tonic-gate show_cancargs4();
953*0Sstevel@tonic-gate break;
954*0Sstevel@tonic-gate case NLMPROC4_UNLOCK:
955*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_MSG:
956*0Sstevel@tonic-gate show_unlockargs4();
957*0Sstevel@tonic-gate break;
958*0Sstevel@tonic-gate case NLMPROC4_TEST_RES:
959*0Sstevel@tonic-gate show_testres4();
960*0Sstevel@tonic-gate break;
961*0Sstevel@tonic-gate case NLMPROC4_LOCK_RES:
962*0Sstevel@tonic-gate case NLMPROC4_CANCEL_RES:
963*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_RES:
964*0Sstevel@tonic-gate case NLMPROC4_GRANTED_RES:
965*0Sstevel@tonic-gate show_res4();
966*0Sstevel@tonic-gate break;
967*0Sstevel@tonic-gate case NLMPROC4_SHARE:
968*0Sstevel@tonic-gate case NLMPROC4_UNSHARE:
969*0Sstevel@tonic-gate show_shareargs();
970*0Sstevel@tonic-gate break;
971*0Sstevel@tonic-gate case NLMPROC4_FREE_ALL:
972*0Sstevel@tonic-gate show_notify();
973*0Sstevel@tonic-gate break;
974*0Sstevel@tonic-gate }
975*0Sstevel@tonic-gate } else {
976*0Sstevel@tonic-gate switch (proc) {
977*0Sstevel@tonic-gate case NLMPROC4_TEST:
978*0Sstevel@tonic-gate show_testres4();
979*0Sstevel@tonic-gate break;
980*0Sstevel@tonic-gate case NLMPROC4_LOCK:
981*0Sstevel@tonic-gate case NLMPROC4_CANCEL:
982*0Sstevel@tonic-gate case NLMPROC4_UNLOCK:
983*0Sstevel@tonic-gate case NLMPROC4_GRANTED:
984*0Sstevel@tonic-gate case NLM_NM_LOCK:
985*0Sstevel@tonic-gate show_res4();
986*0Sstevel@tonic-gate break;
987*0Sstevel@tonic-gate case NLMPROC4_TEST_MSG:
988*0Sstevel@tonic-gate case NLMPROC4_LOCK_MSG:
989*0Sstevel@tonic-gate case NLMPROC4_CANCEL_MSG:
990*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_MSG:
991*0Sstevel@tonic-gate case NLMPROC4_GRANTED_MSG:
992*0Sstevel@tonic-gate case NLMPROC4_TEST_RES:
993*0Sstevel@tonic-gate case NLMPROC4_LOCK_RES:
994*0Sstevel@tonic-gate case NLMPROC4_CANCEL_RES:
995*0Sstevel@tonic-gate case NLMPROC4_UNLOCK_RES:
996*0Sstevel@tonic-gate case NLMPROC4_GRANTED_RES:
997*0Sstevel@tonic-gate break;
998*0Sstevel@tonic-gate case NLM_SHARE:
999*0Sstevel@tonic-gate case NLM_UNSHARE:
1000*0Sstevel@tonic-gate show_shareres4();
1001*0Sstevel@tonic-gate break;
1002*0Sstevel@tonic-gate case NLM_FREE_ALL:
1003*0Sstevel@tonic-gate break;
1004*0Sstevel@tonic-gate }
1005*0Sstevel@tonic-gate }
1006*0Sstevel@tonic-gate show_trailer();
1007*0Sstevel@tonic-gate }
1008*0Sstevel@tonic-gate }
1009*0Sstevel@tonic-gate
1010*0Sstevel@tonic-gate static char *
sum_lock4()1011*0Sstevel@tonic-gate sum_lock4()
1012*0Sstevel@tonic-gate {
1013*0Sstevel@tonic-gate static char buff[LM_MAXSTRLEN + 1];
1014*0Sstevel@tonic-gate char *cp = buff;
1015*0Sstevel@tonic-gate long id;
1016*0Sstevel@tonic-gate u_longlong_t off, len;
1017*0Sstevel@tonic-gate
1018*0Sstevel@tonic-gate (void) getxdr_string(buff, LM_MAXSTRLEN); /* Caller */
1019*0Sstevel@tonic-gate (void) strcpy(buff, sum_netobj("FH")); /* Fh */
1020*0Sstevel@tonic-gate cp += strlen(buff);
1021*0Sstevel@tonic-gate skip_netobj(); /* Owner */
1022*0Sstevel@tonic-gate id = getxdr_long();
1023*0Sstevel@tonic-gate off = getxdr_u_longlong();
1024*0Sstevel@tonic-gate len = getxdr_u_longlong();
1025*0Sstevel@tonic-gate (void) sprintf(cp, " PID=%ld Region=%llu:%llu", id, off, len);
1026*0Sstevel@tonic-gate return (buff);
1027*0Sstevel@tonic-gate }
1028*0Sstevel@tonic-gate
1029*0Sstevel@tonic-gate static void
show_lock4()1030*0Sstevel@tonic-gate show_lock4()
1031*0Sstevel@tonic-gate {
1032*0Sstevel@tonic-gate showxdr_string(LM_MAXSTRLEN, "Caller = %s");
1033*0Sstevel@tonic-gate show_netobj("Filehandle = %s");
1034*0Sstevel@tonic-gate show_netobj("Lock owner = %s");
1035*0Sstevel@tonic-gate showxdr_long("Svid = %ld (process id)");
1036*0Sstevel@tonic-gate showxdr_u_longlong("Offset = %llu bytes");
1037*0Sstevel@tonic-gate showxdr_u_longlong("Length = %llu bytes");
1038*0Sstevel@tonic-gate }
1039*0Sstevel@tonic-gate
1040*0Sstevel@tonic-gate static void
show_cancargs4()1041*0Sstevel@tonic-gate show_cancargs4()
1042*0Sstevel@tonic-gate {
1043*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1044*0Sstevel@tonic-gate showxdr_bool("Block = %s");
1045*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
1046*0Sstevel@tonic-gate show_lock4();
1047*0Sstevel@tonic-gate }
1048*0Sstevel@tonic-gate
1049*0Sstevel@tonic-gate static void
show_lockargs4()1050*0Sstevel@tonic-gate show_lockargs4()
1051*0Sstevel@tonic-gate {
1052*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1053*0Sstevel@tonic-gate showxdr_bool("Block = %s");
1054*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
1055*0Sstevel@tonic-gate show_lock4();
1056*0Sstevel@tonic-gate showxdr_bool("Reclaim = %s");
1057*0Sstevel@tonic-gate showxdr_long("State = %ld");
1058*0Sstevel@tonic-gate }
1059*0Sstevel@tonic-gate
1060*0Sstevel@tonic-gate static void
show_unlockargs4()1061*0Sstevel@tonic-gate show_unlockargs4()
1062*0Sstevel@tonic-gate {
1063*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1064*0Sstevel@tonic-gate show_lock4();
1065*0Sstevel@tonic-gate }
1066*0Sstevel@tonic-gate
1067*0Sstevel@tonic-gate static void
show_testargs4()1068*0Sstevel@tonic-gate show_testargs4()
1069*0Sstevel@tonic-gate {
1070*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1071*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
1072*0Sstevel@tonic-gate show_lock4();
1073*0Sstevel@tonic-gate }
1074*0Sstevel@tonic-gate
1075*0Sstevel@tonic-gate static void
show_res4()1076*0Sstevel@tonic-gate show_res4()
1077*0Sstevel@tonic-gate {
1078*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1079*0Sstevel@tonic-gate (void) show_stat4();
1080*0Sstevel@tonic-gate }
1081*0Sstevel@tonic-gate
1082*0Sstevel@tonic-gate static char *
nameof_stat4(s)1083*0Sstevel@tonic-gate nameof_stat4(s)
1084*0Sstevel@tonic-gate ulong_t s;
1085*0Sstevel@tonic-gate {
1086*0Sstevel@tonic-gate switch ((enum nlm4_stats) s) {
1087*0Sstevel@tonic-gate case NLM4_GRANTED: return ("granted");
1088*0Sstevel@tonic-gate case NLM4_DENIED: return ("denied");
1089*0Sstevel@tonic-gate case NLM4_DENIED_NOLOCKS:return ("denied (no locks)");
1090*0Sstevel@tonic-gate case NLM4_BLOCKED: return ("blocked");
1091*0Sstevel@tonic-gate case NLM4_DENIED_GRACE_PERIOD: return ("denied (grace period)");
1092*0Sstevel@tonic-gate case NLM4_DEADLCK: return ("deadlock");
1093*0Sstevel@tonic-gate case NLM4_ROFS: return ("read-only fs");
1094*0Sstevel@tonic-gate case NLM4_STALE_FH: return ("stale fh");
1095*0Sstevel@tonic-gate case NLM4_FBIG: return ("file too big");
1096*0Sstevel@tonic-gate case NLM4_FAILED: return ("failed");
1097*0Sstevel@tonic-gate default: return ("?");
1098*0Sstevel@tonic-gate }
1099*0Sstevel@tonic-gate }
1100*0Sstevel@tonic-gate
1101*0Sstevel@tonic-gate static enum nlm4_stats
show_stat4()1102*0Sstevel@tonic-gate show_stat4()
1103*0Sstevel@tonic-gate {
1104*0Sstevel@tonic-gate enum nlm4_stats s;
1105*0Sstevel@tonic-gate
1106*0Sstevel@tonic-gate s = (enum nlm4_stats) getxdr_u_long();
1107*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
1108*0Sstevel@tonic-gate "Status = %d (%s)",
1109*0Sstevel@tonic-gate s, nameof_stat4((ulong_t)s));
1110*0Sstevel@tonic-gate
1111*0Sstevel@tonic-gate return (s);
1112*0Sstevel@tonic-gate }
1113*0Sstevel@tonic-gate
1114*0Sstevel@tonic-gate static void
show_testres4()1115*0Sstevel@tonic-gate show_testres4()
1116*0Sstevel@tonic-gate {
1117*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1118*0Sstevel@tonic-gate if (show_stat() == NLM4_DENIED) {
1119*0Sstevel@tonic-gate showxdr_bool("Exclusive = %s");
1120*0Sstevel@tonic-gate showxdr_long("Svid = %ld (process id)");
1121*0Sstevel@tonic-gate show_netobj("Owner handle = %s");
1122*0Sstevel@tonic-gate showxdr_u_longlong("Offset = %llu bytes");
1123*0Sstevel@tonic-gate showxdr_u_longlong("Length = %llu bytes");
1124*0Sstevel@tonic-gate }
1125*0Sstevel@tonic-gate }
1126*0Sstevel@tonic-gate
1127*0Sstevel@tonic-gate static void
show_shareres4()1128*0Sstevel@tonic-gate show_shareres4()
1129*0Sstevel@tonic-gate {
1130*0Sstevel@tonic-gate show_netobj("Cookie = %s");
1131*0Sstevel@tonic-gate (void) show_stat4();
1132*0Sstevel@tonic-gate showxdr_long("Sequence = %d");
1133*0Sstevel@tonic-gate }
1134