1*93bc28dbSGordon Ross /*
2*93bc28dbSGordon Ross  * This file and its contents are supplied under the terms of the
3*93bc28dbSGordon Ross  * Common Development and Distribution License ("CDDL"), version 1.0.
4*93bc28dbSGordon Ross  * You may only use this file in accordance with the terms of version
5*93bc28dbSGordon Ross  * 1.0 of the CDDL.
6*93bc28dbSGordon Ross  *
7*93bc28dbSGordon Ross  * A full copy of the text of the CDDL should have accompanied this
8*93bc28dbSGordon Ross  * source.  A copy of the CDDL is also available via the Internet at
9*93bc28dbSGordon Ross  * http://www.illumos.org/license/CDDL.
10*93bc28dbSGordon Ross  */
11*93bc28dbSGordon Ross 
12*93bc28dbSGordon Ross /*
13*93bc28dbSGordon Ross  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
14*93bc28dbSGordon Ross  */
15*93bc28dbSGordon Ross 
16*93bc28dbSGordon Ross /*
17*93bc28dbSGordon Ross  * Example using the "fksmb$pid" dtrace provider.
18*93bc28dbSGordon Ross  * Traces all SMB commands using the probes:
19*93bc28dbSGordon Ross  *	start, done
20*93bc28dbSGordon Ross  * all of which have two args:
21*93bc28dbSGordon Ross  *	args[0]: char * (probe-name)
22*93bc28dbSGordon Ross  *	args[1]: ulong (struct smb_request *)
23*93bc28dbSGordon Ross  *
24*93bc28dbSGordon Ross  * Note: the "userland" type classifier causes dtrace to
25*93bc28dbSGordon Ross  * automatically copyin the struct for us.  (Nice!)
26*93bc28dbSGordon Ross  */
27*93bc28dbSGordon Ross 
28*93bc28dbSGordon Ross fksmb$target:::smb_start
29*93bc28dbSGordon Ross {
30*93bc28dbSGordon Ross 	this->pn = copyinstr(arg0);
31*93bc28dbSGordon Ross 	this->sr = (userland pid`smb_request_t *)arg1;
32*93bc28dbSGordon Ross 
33*93bc28dbSGordon Ross 	printf(" %s mid=0x%x uid=0x%x tid=0x%x\n",
34*93bc28dbSGordon Ross 	    this->pn,
35*93bc28dbSGordon Ross 	    this->sr->smb_mid,
36*93bc28dbSGordon Ross 	    this->sr->smb_uid,
37*93bc28dbSGordon Ross 	    this->sr->smb_tid);
38*93bc28dbSGordon Ross }
39*93bc28dbSGordon Ross 
40*93bc28dbSGordon Ross fksmb$target:::smb_done
41*93bc28dbSGordon Ross {
42*93bc28dbSGordon Ross 	this->pn = copyinstr(arg0);
43*93bc28dbSGordon Ross 	this->sr = (userland pid`smb_request_t *)arg1;
44*93bc28dbSGordon Ross 
45*93bc28dbSGordon Ross 	printf(" %s mid=0x%x status=0x%x\n",
46*93bc28dbSGordon Ross 	    this->pn,
47*93bc28dbSGordon Ross 	    this->sr->smb_mid,
48*93bc28dbSGordon Ross 	    this->sr->smb_error.status);
49*93bc28dbSGordon Ross }
50*93bc28dbSGordon Ross 
51*93bc28dbSGordon Ross fksmb$target:::smb2_start
52*93bc28dbSGordon Ross {
53*93bc28dbSGordon Ross 	this->pn = copyinstr(arg0);
54*93bc28dbSGordon Ross 	this->sr = (userland pid`smb_request_t *)arg1;
55*93bc28dbSGordon Ross 
56*93bc28dbSGordon Ross 	printf(" %s mid=0x%x uid=0x%x tid=0x%x\n",
57*93bc28dbSGordon Ross 	    this->pn,
58*93bc28dbSGordon Ross 	    this->sr->smb2_messageid,
59*93bc28dbSGordon Ross 	    this->sr->smb2_ssnid,
60*93bc28dbSGordon Ross 	    this->sr->smb_tid);
61*93bc28dbSGordon Ross }
62*93bc28dbSGordon Ross 
63*93bc28dbSGordon Ross fksmb$target:::smb2_done
64*93bc28dbSGordon Ross {
65*93bc28dbSGordon Ross 	this->pn = copyinstr(arg0);
66*93bc28dbSGordon Ross 	this->sr = (userland pid`smb_request_t *)arg1;
67*93bc28dbSGordon Ross 
68*93bc28dbSGordon Ross 	printf(" %s mid=0x%x status=0x%x\n",
69*93bc28dbSGordon Ross 	    this->pn,
70*93bc28dbSGordon Ross 	    this->sr->smb2_messageid,
71*93bc28dbSGordon Ross 	    this->sr->smb2_status);
72*93bc28dbSGordon Ross }