xref: /titanic_51/usr/src/uts/common/fs/smbsrv/smb_dispatch.c (revision a90cf9f29973990687fa61de9f1f6ea22e924e40)
1da6c28aaSamw /*
2da6c28aaSamw  * CDDL HEADER START
3da6c28aaSamw  *
4da6c28aaSamw  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
7da6c28aaSamw  *
8da6c28aaSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw  * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw  * See the License for the specific language governing permissions
11da6c28aaSamw  * and limitations under the License.
12da6c28aaSamw  *
13da6c28aaSamw  * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw  * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw  * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw  *
19da6c28aaSamw  * CDDL HEADER END
20da6c28aaSamw  */
21148c5f43SAlan Wright 
22da6c28aaSamw /*
23148c5f43SAlan Wright  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24*a90cf9f2SGordon Ross  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
25da6c28aaSamw  */
26da6c28aaSamw 
27da6c28aaSamw /*
282c2961f8Sjose borrego  * SMB requests.
29da6c28aaSamw  *
30da6c28aaSamw  * Request
31da6c28aaSamw  *   Header
32da6c28aaSamw  *	Magic		0xFF 'S' 'M' 'B'
33da6c28aaSamw  *	smb_com 	a byte, the "first" command
34da6c28aaSamw  *	Error		a 4-byte union, ignored in a request
35da6c28aaSamw  *	smb_flg		a one byte set of eight flags
36da6c28aaSamw  *	smb_flg2	a two byte set of 16 flags
37da6c28aaSamw  *	.		twelve reserved bytes, have a role
38da6c28aaSamw  *			in connectionless transports (IPX, UDP?)
39da6c28aaSamw  *	smb_tid		a 16-bit tree ID, a mount point sorta,
40da6c28aaSamw  *			0xFFFF is this command does not have
41da6c28aaSamw  *			or require a tree context
42da6c28aaSamw  *	smb_pid		a 16-bit process ID
43da6c28aaSamw  *	smb_uid		a 16-bit user ID, specific to this "session"
44da6c28aaSamw  *			and mapped to a system (bona-fide) UID
45da6c28aaSamw  *	smb_mid		a 16-bit multiplex ID, used to differentiate
46da6c28aaSamw  *			multiple simultaneous requests from the same
47da6c28aaSamw  *			process (pid) (ref RPC "xid")
48da6c28aaSamw  *
49da6c28aaSamw  *   Chained (AndX) commands (0 or more)
50da6c28aaSamw  *	smb_wct		a byte, number of 16-bit words containing
51da6c28aaSamw  *			command parameters, min 2 for chained command
52da6c28aaSamw  *	andx_com	a byte, the "next" command, 0xFF for none
53da6c28aaSamw  *	.		an unused byte
54da6c28aaSamw  *	andx_off	a 16-bit offset, byte displacement from &Magic
55da6c28aaSamw  *			to the smb_wct field of the "next" command,
56da6c28aaSamw  *			ignore if andx_com is 0xFF, s/b 0 if no next
57da6c28aaSamw  *	smb_vwv[]	0 or more 16-bit (sorta) parameters for
58da6c28aaSamw  *			"this" command (i.e. smb_com if this is the
59da6c28aaSamw  *			first parameters, or the andx_com of the just
60da6c28aaSamw  *			previous block.
61da6c28aaSamw  *	smb_bcc		a 16-bit count of smb_data[] bytes
62da6c28aaSamw  *	smb_data[]	0 or more bytes, format specific to commands
63da6c28aaSamw  *	padding[]	Optional padding
64da6c28aaSamw  *
65da6c28aaSamw  *   Last command
66da6c28aaSamw  *	smb_wct		a byte, number of 16-bit words containing
67da6c28aaSamw  *			command parameters, min 0 for chained command
68da6c28aaSamw  *	smb_vwv[]	0 or more 16-bit (sorta) parameters for
69da6c28aaSamw  *			"this" command (i.e. smb_com if this is the
70da6c28aaSamw  *			first parameters, or the andx_com of the just
71da6c28aaSamw  *			previous block.
72da6c28aaSamw  *	smb_bcc		a 16-bit count of smb_data[] bytes
73da6c28aaSamw  *	smb_data[]	0 or more bytes, format specific to commands
74da6c28aaSamw  *
75da6c28aaSamw  * Reply
76da6c28aaSamw  *   Header
77da6c28aaSamw  *	Magic		0xFF 'S' 'M' 'B'
78da6c28aaSamw  *	smb_com 	a byte, the "first" command, corresponds
79da6c28aaSamw  *			to request
80da6c28aaSamw  *	Error		a 4-byte union, coding depends on dialect in use
81da6c28aaSamw  *			for "DOS" errors
82da6c28aaSamw  *				a byte for error class
83da6c28aaSamw  *				an unused byte
84da6c28aaSamw  *				a 16-bit word for error code
85da6c28aaSamw  *			for "NT" errors
86da6c28aaSamw  *				a 32-bit error code which
87da6c28aaSamw  *				is a packed class and specifier
88da6c28aaSamw  *			for "OS/2" errors
89da6c28aaSamw  *				I don't know
90da6c28aaSamw  *			The error information is specific to the
91da6c28aaSamw  *			last command in the reply chain.
92da6c28aaSamw  *	smb_flg		a one byte set of eight flags, 0x80 bit set
93da6c28aaSamw  *			indicating this message is a reply
94da6c28aaSamw  *	smb_flg2	a two byte set of 16 flags
95da6c28aaSamw  *	.		twelve reserved bytes, have a role
96da6c28aaSamw  *			in connectionless transports (IPX, UDP?)
97da6c28aaSamw  *	smb_tid		a 16-bit tree ID, a mount point sorta,
98da6c28aaSamw  *			should be the same as the request
99da6c28aaSamw  *	smb_pid		a 16-bit process ID, MUST BE the same as request
100da6c28aaSamw  *	smb_uid		a 16-bit user ID, specific to this "session"
101da6c28aaSamw  *			and mapped to a system (bona-fide) UID,
102da6c28aaSamw  *			should be the same as request
103da6c28aaSamw  *	smb_mid		a 16-bit multiplex ID, used to differentiate
104da6c28aaSamw  *			multiple simultaneous requests from the same
105da6c28aaSamw  *			process (pid) (ref RPC "xid"), MUST BE the
106da6c28aaSamw  *			same as request
107da6c28aaSamw  *	padding[]	Optional padding
108da6c28aaSamw  *
109da6c28aaSamw  *   Chained (AndX) commands (0 or more)
110da6c28aaSamw  *	smb_wct		a byte, number of 16-bit words containing
111da6c28aaSamw  *			command parameters, min 2 for chained command,
112da6c28aaSamw  *	andx_com	a byte, the "next" command, 0xFF for none,
113da6c28aaSamw  *			corresponds to request, if this is the chained
114da6c28aaSamw  *			command that had an error set to 0xFF
115da6c28aaSamw  *	.		an unused byte
116da6c28aaSamw  *	andx_off	a 16-bit offset, byte displacement from &Magic
117da6c28aaSamw  *			to the smb_wct field of the "next" command,
118da6c28aaSamw  *			ignore if andx_com is 0xFF, s/b 0 if no next
119da6c28aaSamw  *	smb_vwv[]	0 or more 16-bit (sorta) parameters for
120da6c28aaSamw  *			"this" command (i.e. smb_com if this is the
121da6c28aaSamw  *			first parameters, or the andx_com of the just
122da6c28aaSamw  *			previous block. Empty if an error.
123da6c28aaSamw  *	smb_bcc		a 16-bit count of smb_data[] bytes
124da6c28aaSamw  *	smb_data[]	0 or more bytes, format specific to commands
125da6c28aaSamw  *			empty if an error.
126da6c28aaSamw  *
127da6c28aaSamw  *   Last command
128da6c28aaSamw  *	smb_wct		a byte, number of 16-bit words containing
129da6c28aaSamw  *			command parameters, min 0 for chained command
130da6c28aaSamw  *	smb_vwv[]	0 or more 16-bit (sorta) parameters for
131da6c28aaSamw  *			"this" command (i.e. smb_com if this is the
132da6c28aaSamw  *			first parameters, or the andx_com of the just
133da6c28aaSamw  *			previous block, empty if an error.
134da6c28aaSamw  *	smb_bcc		a 16-bit count of smb_data[] bytes
135da6c28aaSamw  *	smb_data[]	0 or more bytes, format specific to commands,
136da6c28aaSamw  *			empty if an error.
137da6c28aaSamw  */
138da6c28aaSamw 
139bbf6f00cSJordan Brown #include <smbsrv/smb_kproto.h>
1406537f381Sas200622 #include <smbsrv/smb_kstat.h>
141da6c28aaSamw #include <sys/sdt.h>
142148c5f43SAlan Wright #include <sys/spl.h>
143da6c28aaSamw 
144da6c28aaSamw static int is_andx_com(unsigned char);
1457b59d02dSjb150015 static int smbsr_check_result(struct smb_request *, int, int);
146*a90cf9f2SGordon Ross static void smb1_tq_work(void *);
147da6c28aaSamw 
1488622ec45SGordon Ross static const smb_disp_entry_t const
1498622ec45SGordon Ross smb_disp_table[SMB_COM_NUM] = {
150148c5f43SAlan Wright 	{ "SmbCreateDirectory", SMB_SDT_OPS(create_directory),  /* 0x00 000 */
151148c5f43SAlan Wright 	    0x00, PC_NETWORK_PROGRAM_1_0 },
152148c5f43SAlan Wright 	{ "SmbDeleteDirectory", SMB_SDT_OPS(delete_directory),	/* 0x01 001 */
153148c5f43SAlan Wright 	    0x01, PC_NETWORK_PROGRAM_1_0 },
154148c5f43SAlan Wright 	{ "SmbOpen", SMB_SDT_OPS(open),				/* 0x02 002 */
155148c5f43SAlan Wright 	    0x02, PC_NETWORK_PROGRAM_1_0 },
156148c5f43SAlan Wright 	{ "SmbCreate", SMB_SDT_OPS(create),			/* 0x03 003 */
157148c5f43SAlan Wright 	    0x03, PC_NETWORK_PROGRAM_1_0 },
158148c5f43SAlan Wright 	{ "SmbClose", SMB_SDT_OPS(close),			/* 0x04 004 */
159148c5f43SAlan Wright 	    0x04, PC_NETWORK_PROGRAM_1_0 },
160148c5f43SAlan Wright 	{ "SmbFlush", SMB_SDT_OPS(flush),			/* 0x05 005 */
161148c5f43SAlan Wright 	    0x05, PC_NETWORK_PROGRAM_1_0 },
162148c5f43SAlan Wright 	{ "SmbDelete", SMB_SDT_OPS(delete),			/* 0x06 006 */
163148c5f43SAlan Wright 	    0x06, PC_NETWORK_PROGRAM_1_0 },
164148c5f43SAlan Wright 	{ "SmbRename", SMB_SDT_OPS(rename),			/* 0x07 007 */
165148c5f43SAlan Wright 	    0x07, PC_NETWORK_PROGRAM_1_0 },
166148c5f43SAlan Wright 	{ "SmbQueryInformation", SMB_SDT_OPS(query_information), /* 0x08 008 */
167148c5f43SAlan Wright 	    0x08, PC_NETWORK_PROGRAM_1_0 },
168148c5f43SAlan Wright 	{ "SmbSetInformation", SMB_SDT_OPS(set_information),	/* 0x09 009 */
169148c5f43SAlan Wright 	    0x09, PC_NETWORK_PROGRAM_1_0 },
170148c5f43SAlan Wright 	{ "SmbRead", SMB_SDT_OPS(read),				/* 0x0A 010 */
171148c5f43SAlan Wright 	    0x0A, PC_NETWORK_PROGRAM_1_0 },
172148c5f43SAlan Wright 	{ "SmbWrite", SMB_SDT_OPS(write),			/* 0x0B 011 */
173148c5f43SAlan Wright 	    0x0B, PC_NETWORK_PROGRAM_1_0 },
174148c5f43SAlan Wright 	{ "SmbLockByteRange", SMB_SDT_OPS(lock_byte_range),	/* 0x0C 012 */
175148c5f43SAlan Wright 	    0x0C, PC_NETWORK_PROGRAM_1_0 },
176148c5f43SAlan Wright 	{ "SmbUnlockByteRange", SMB_SDT_OPS(unlock_byte_range),	/* 0x0D 013 */
177148c5f43SAlan Wright 	    0x0D, PC_NETWORK_PROGRAM_1_0 },
178148c5f43SAlan Wright 	{ "SmbCreateTemporary", SMB_SDT_OPS(create_temporary),	/* 0x0E 014 */
179148c5f43SAlan Wright 	    0x0E, PC_NETWORK_PROGRAM_1_0 },
180148c5f43SAlan Wright 	{ "SmbCreateNew", SMB_SDT_OPS(create_new),		/* 0x0F 015 */
181148c5f43SAlan Wright 	    0x0F, PC_NETWORK_PROGRAM_1_0 },
182148c5f43SAlan Wright 	{ "SmbCheckDirectory", SMB_SDT_OPS(check_directory),	/* 0x10 016 */
183148c5f43SAlan Wright 	    0x10, PC_NETWORK_PROGRAM_1_0 },
184148c5f43SAlan Wright 	{ "SmbProcessExit", SMB_SDT_OPS(process_exit),		/* 0x11 017 */
1858622ec45SGordon Ross 	    0x11, PC_NETWORK_PROGRAM_1_0,
1868622ec45SGordon Ross 	    SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
187148c5f43SAlan Wright 	{ "SmbSeek", SMB_SDT_OPS(seek),				/* 0x12 018 */
188148c5f43SAlan Wright 	    0x12, PC_NETWORK_PROGRAM_1_0 },
189148c5f43SAlan Wright 	{ "SmbLockAndRead", SMB_SDT_OPS(lock_and_read),		/* 0x13 019 */
190148c5f43SAlan Wright 	    0x13, LANMAN1_0 },
191148c5f43SAlan Wright 	{ "SmbWriteAndUnlock", SMB_SDT_OPS(write_and_unlock),	/* 0x14 020 */
192148c5f43SAlan Wright 	    0x14, LANMAN1_0 },
193148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x15, 0 },		/* 0x15	021 */
194148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x16, 0 },		/* 0x16 022 */
195148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x17, 0 },		/* 0x17 023 */
196148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x18, 0 },		/* 0x18 024 */
197148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x19, 0 },		/* 0x19 025 */
198380bdfdfSGordon Ross 	{ "SmbReadRaw", SMB_SDT_OPS(invalid), 0x1A, 0 },	/* 0x1A 026 */
199148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x1B, 0 },		/* 0x1B 027 */
200148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x1C, 0 },		/* 0x1C 028 */
201380bdfdfSGordon Ross 	{ "SmbWriteRaw", SMB_SDT_OPS(invalid), 0x1D, 0 },	/* 0x1D 029 */
202148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x1E, 0 },		/* 0x1E 030 */
203148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x1F, 0 },		/* 0x1F 031 */
204148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x20, 0 },		/* 0x20 032 */
205148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x21, 0 },		/* 0x21 033 */
206148c5f43SAlan Wright 	{ "SmbSetInformation2", SMB_SDT_OPS(set_information2),	/* 0x22 034 */
207148c5f43SAlan Wright 	    0x22, LANMAN1_0 },
208148c5f43SAlan Wright 	{ "SmbQueryInformation2",
209148c5f43SAlan Wright 	    SMB_SDT_OPS(query_information2),			/* 0x23 035 */
210148c5f43SAlan Wright 	    0x23, LANMAN1_0 },
211148c5f43SAlan Wright 	{ "SmbLockingX", SMB_SDT_OPS(locking_andx),		/* 0x24 036 */
212148c5f43SAlan Wright 	    0x24, LANMAN1_0 },
213148c5f43SAlan Wright 	{ "SmbTransaction", SMB_SDT_OPS(transaction),		/* 0x25 037 */
214148c5f43SAlan Wright 	    0x25, LANMAN1_0 },
215148c5f43SAlan Wright 	{ "SmbTransactionSecondary",
216148c5f43SAlan Wright 	    SMB_SDT_OPS(transaction_secondary),			/* 0x26 038 */
217148c5f43SAlan Wright 	    0x26, LANMAN1_0 },
218148c5f43SAlan Wright 	{ "SmbIoctl", SMB_SDT_OPS(ioctl),			/* 0x27 039 */
219148c5f43SAlan Wright 	    0x27, LANMAN1_0 },
220148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x28, 0 },	/* 0x28 040 */
221148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x29, 0 },	/* 0x29 041 */
222148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x2A, 0 },	/* 0x2A 042 */
223148c5f43SAlan Wright 	{ "SmbEcho", SMB_SDT_OPS(echo),				/* 0x2B 043 */
224148c5f43SAlan Wright 	    0x2B, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
225148c5f43SAlan Wright 	{ "SmbWriteAndClose", SMB_SDT_OPS(write_and_close),	/* 0x2C 044 */
226148c5f43SAlan Wright 	    0x2C, LANMAN1_0 },
227148c5f43SAlan Wright 	{ "SmbOpenX", SMB_SDT_OPS(open_andx),			/* 0x2D 045 */
228148c5f43SAlan Wright 	    0x2D, LANMAN1_0 },
229148c5f43SAlan Wright 	{ "SmbReadX", SMB_SDT_OPS(read_andx),			/* 0x2E 046 */
230148c5f43SAlan Wright 	    0x2E, LANMAN1_0 },
231148c5f43SAlan Wright 	{ "SmbWriteX", SMB_SDT_OPS(write_andx),			/* 0x2F 047 */
232148c5f43SAlan Wright 	    0x2F, LANMAN1_0 },
233148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x30, 0 },	/* 0x30 048 */
234148c5f43SAlan Wright 	{ "SmbCloseAndTreeDisconnect",
235148c5f43SAlan Wright 	    SMB_SDT_OPS(close_and_tree_disconnect),		/* 0x31 049 */
236148c5f43SAlan Wright 	    0x31, LANMAN1_0 },
237148c5f43SAlan Wright 	{ "SmbTransaction2", SMB_SDT_OPS(transaction2),		/* 0x32 050 */
238148c5f43SAlan Wright 	    0x32, LM1_2X002 },
239148c5f43SAlan Wright 	{ "SmbTransaction2Secondary",
240148c5f43SAlan Wright 	    SMB_SDT_OPS(transaction2_secondary),		/* 0x33 051 */
241148c5f43SAlan Wright 	    0x33, LM1_2X002 },
242148c5f43SAlan Wright 	{ "SmbFindClose2", SMB_SDT_OPS(find_close2),		/* 0x34 052 */
243148c5f43SAlan Wright 	    0x34, LM1_2X002 },
244148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x35, 0 },	/* 0x35 053 */
245148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x36, 0 },	/* 0x36 054 */
246148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x37, 0 },	/* 0x37 055 */
247148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x38, 0 },	/* 0x38 056 */
248148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x39, 0 },	/* 0x39 057 */
249148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3A, 0 },	/* 0x3A 058 */
250148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3B, 0 },	/* 0x3B 059 */
251148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3C, 0 },	/* 0x3C 060 */
252148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3D, 0 },	/* 0x3D 061 */
253148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3E, 0 },	/* 0x3E 062 */
254148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x3F, 0 },	/* 0x3F 063 */
255148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x40, 0 },	/* 0x40 064 */
256148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 },	/* 0x47 065 */
257148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 },	/* 0x48 066 */
258148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 },	/* 0x49 067 */
259148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x44, 0 },	/* 0x44 068 */
260148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x45, 0 },	/* 0x45 069 */
261148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x46, 0 },	/* 0x46 070 */
262148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 },	/* 0x47 071 */
263148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 },	/* 0x48 072 */
264148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 },	/* 0x49 073 */
265148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4A, 0 },	/* 0x4A 074 */
266148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4B, 0 },	/* 0x4B 075 */
267148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4C, 0 },	/* 0x4C 076 */
268148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4D, 0 },	/* 0x4D 077 */
269148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4E, 0 },	/* 0x4E 078 */
270148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x4F, 0 },	/* 0x4F 079 */
271148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x50, 0 },	/* 0x50 080 */
272148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x51, 0 },	/* 0x51 081 */
273148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x52, 0 },	/* 0x52 082 */
274148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x53, 0 },	/* 0x53 083 */
275148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x54, 0 },	/* 0x54 084 */
276148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x55, 0 },	/* 0x55 085 */
277148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x56, 0 },	/* 0x56 086 */
278148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x57, 0 },	/* 0x57 087 */
279148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x58, 0 },	/* 0x58 088 */
280148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x59, 0 },	/* 0x59 089 */
281148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5A, 0 },	/* 0x5A 090 */
282148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5B, 0 },	/* 0x5B 091 */
283148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5C, 0 },	/* 0x5C 092 */
284148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5D, 0 },	/* 0x5D 093 */
285148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5E, 0 },	/* 0x5E 094 */
286148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x5F, 0 },	/* 0x5F 095 */
287148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x60, 0 },	/* 0x60 096 */
288148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x61, 0 },	/* 0x61 097 */
289148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x62, 0 },	/* 0x62 098 */
290148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x63, 0 },	/* 0x63 099 */
291148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x64, 0 },	/* 0x64 100 */
292148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x65, 0 },	/* 0x65 101 */
293148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x66, 0 },	/* 0x66 102 */
294148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x67, 0 },	/* 0x67 103 */
295148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x68, 0 },	/* 0x68 104 */
296148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x69, 0 },	/* 0x69 105 */
297148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6A, 0 },	/* 0x6A 106 */
298148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6B, 0 },	/* 0x6B 107 */
299148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6C, 0 },	/* 0x6C 108 */
300148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6D, 0 },	/* 0x6D 109 */
301148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6E, 0 },	/* 0x6E 110 */
302148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x6F, 0 },	/* 0x6F 111 */
303148c5f43SAlan Wright 	{ "SmbTreeConnect", SMB_SDT_OPS(tree_connect),		/* 0x70 112 */
304148c5f43SAlan Wright 	    0x70, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID },
305148c5f43SAlan Wright 	{ "SmbTreeDisconnect", SMB_SDT_OPS(tree_disconnect),	/* 0x71 113 */
3068622ec45SGordon Ross 	    0x71, PC_NETWORK_PROGRAM_1_0,
3078622ec45SGordon Ross 	    SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
308*a90cf9f2SGordon Ross 	/*
309*a90cf9f2SGordon Ross 	 * NB: Negotiate gets special handling via
310*a90cf9f2SGordon Ross 	 * smb_initial_request_handler.  After that,
311*a90cf9f2SGordon Ross 	 * another Negotiate is an invalid request.
312*a90cf9f2SGordon Ross 	 */
313*a90cf9f2SGordon Ross 	{ "SmbNegotiate", SMB_SDT_OPS(invalid),			/* 0x72 114 */
3148622ec45SGordon Ross 	    0x72, PC_NETWORK_PROGRAM_1_0,
3158622ec45SGordon Ross 	    SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
316148c5f43SAlan Wright 	{ "SmbSessionSetupX", SMB_SDT_OPS(session_setup_andx),	/* 0x73 115 */
317148c5f43SAlan Wright 	    0x73, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
318148c5f43SAlan Wright 	{ "SmbLogoffX", SMB_SDT_OPS(logoff_andx),		/* 0x74 116 */
319148c5f43SAlan Wright 	    0x74, LM1_2X002, SDDF_SUPPRESS_TID },
320148c5f43SAlan Wright 	{ "SmbTreeConnectX", SMB_SDT_OPS(tree_connect_andx),	/* 0x75 117 */
321148c5f43SAlan Wright 	    0x75, LANMAN1_0, SDDF_SUPPRESS_TID },
322148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x76, 0, 0 },	/* 0x76 118 */
323148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x77, 0, 0 },	/* 0x77 119 */
324148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x78, 0, 0 },	/* 0x78 120 */
325148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x79, 0, 0 },	/* 0x79 121 */
326148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7A, 0, 0 },	/* 0x7A 122 */
327148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7B, 0, 0 },	/* 0x7B 123 */
328148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7C, 0, 0 },	/* 0x7C 124 */
329148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7D, 0, 0 },	/* 0x7D 125 */
330148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7E, 0, 0 },	/* 0x7E 126 */
331148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x7F, 0, 0 },	/* 0x7F 127 */
332148c5f43SAlan Wright 	{ "SmbQueryInformationDisk",
333148c5f43SAlan Wright 	    SMB_SDT_OPS(query_information_disk),		/* 0x80 128 */
334148c5f43SAlan Wright 	    0x80, PC_NETWORK_PROGRAM_1_0, 0 },
335148c5f43SAlan Wright 	{ "SmbSearch", SMB_SDT_OPS(search),			/* 0x81 129 */
336148c5f43SAlan Wright 	    0x81, PC_NETWORK_PROGRAM_1_0, 0 },
337148c5f43SAlan Wright 	{ "SmbFind", SMB_SDT_OPS(find),				/* 0x82 130 */
338148c5f43SAlan Wright 	    0x82, LANMAN1_0, 0 },
339148c5f43SAlan Wright 	{ "SmbFindUnique", SMB_SDT_OPS(find_unique),		/* 0x83 131 */
340148c5f43SAlan Wright 	    0x83, LANMAN1_0, 0 },
341148c5f43SAlan Wright 	{ "SmbFindClose", SMB_SDT_OPS(find_close),		/* 0x84 132 */
342148c5f43SAlan Wright 	    0x84, LANMAN1_0, 0 },
343148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x85, 0, 0 },	/* 0x85 133 */
344148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x86, 0, 0 },	/* 0x86 134 */
345148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x87, 0, 0 },	/* 0x87 135 */
346148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x88, 0, 0 },	/* 0x88 136 */
347148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x89, 0, 0 },	/* 0x89 137 */
348148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8A, 0, 0 },	/* 0x8A 138 */
349148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8B, 0, 0 },	/* 0x8B 139 */
350148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8C, 0, 0 },	/* 0x8C 140 */
351148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8D, 0, 0 },	/* 0x8D 141 */
352148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8E, 0, 0 },	/* 0x8E 142 */
353148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x8F, 0, 0 },	/* 0x8F 143 */
354148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x90, 0, 0 },	/* 0x90 144 */
355148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x91, 0, 0 },	/* 0x91 145 */
356148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x92, 0, 0 },	/* 0x92 146 */
357148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x93, 0, 0 },	/* 0x93 147 */
358148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x94, 0, 0 },	/* 0x94 148 */
359148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x95, 0, 0 },	/* 0x95 149 */
360148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x96, 0, 0 },	/* 0x96 150 */
361148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x97, 0, 0 },	/* 0x97 151 */
362148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x98, 0, 0 },	/* 0x98 152 */
363148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x99, 0, 0 },	/* 0x99 153 */
364148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9A, 0, 0 },	/* 0x9A 154 */
365148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9B, 0, 0 },	/* 0x9B 155 */
366148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9C, 0, 0 },	/* 0x9C 156 */
367148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9D, 0, 0 },	/* 0x9D 157 */
368148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9E, 0, 0 },	/* 0x9E 158 */
369148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0x9F, 0, 0 },	/* 0x9F 159 */
370148c5f43SAlan Wright 	{ "SmbNtTransact", SMB_SDT_OPS(nt_transact),	/* 0xA0 160 */
371148c5f43SAlan Wright 	    0xA0, NT_LM_0_12, 0 },
372148c5f43SAlan Wright 	{ "SmbNtTransactSecondary",
373148c5f43SAlan Wright 	    SMB_SDT_OPS(nt_transact_secondary),			/* 0xA1 161 */
374148c5f43SAlan Wright 	    0xA1, NT_LM_0_12, 0 },
375148c5f43SAlan Wright 	{ "SmbNtCreateX", SMB_SDT_OPS(nt_create_andx),		/* 0xA2 162 */
376148c5f43SAlan Wright 	    0xA2, NT_LM_0_12, 0 },
377148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xA3, 0, 0 },	/* 0xA3 163 */
378148c5f43SAlan Wright 	{ "SmbNtCancel", SMB_SDT_OPS(nt_cancel),		/* 0xA4 164 */
379148c5f43SAlan Wright 	    0xA4, NT_LM_0_12, 0 },
380148c5f43SAlan Wright 	{ "SmbNtRename", SMB_SDT_OPS(nt_rename),		/* 0xA5 165 */
381148c5f43SAlan Wright 	    0xA5, NT_LM_0_12, 0 },
382148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xA6, 0, 0 },	/* 0xA6 166 */
383148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xA7, 0, 0 },	/* 0xA7 167 */
384148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xA8, 0, 0 },	/* 0xA8 168 */
385148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xA9, 0, 0 },	/* 0xA9 169 */
386148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAA, 0, 0 },	/* 0xAA 170 */
387148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAB, 0, 0 },	/* 0xAB 171 */
388148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAC, 0, 0 },	/* 0xAC 172 */
389148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAD, 0, 0 },	/* 0xAD 173 */
390148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAE, 0, 0 },	/* 0xAE 174 */
391148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xAF, 0, 0 },	/* 0xAF 175 */
392148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB0, 0, 0 },	/* 0xB0 176 */
393148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB1, 0, 0 },	/* 0xB1 177 */
394148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB2, 0, 0 },	/* 0xB2 178 */
395148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB3, 0, 0 },	/* 0xB3 179 */
396148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB4, 0, 0 },	/* 0xB4 180 */
397148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB5, 0, 0 },	/* 0xB5 181 */
398148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB6, 0, 0 },	/* 0xB6 182 */
399148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB7, 0, 0 },	/* 0xB7 183 */
400148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB8, 0, 0 },	/* 0xB8 184 */
401148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xB9, 0, 0 },	/* 0xB9 185 */
402148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBA, 0, 0 },	/* 0xBA 186 */
403148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBB, 0, 0 },	/* 0xBB 187 */
404148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBC, 0, 0 },	/* 0xBC 188 */
405148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBD, 0, 0 },	/* 0xBD 189 */
406148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBE, 0, 0 },	/* 0xBE 190 */
407148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xBF, 0, 0 },	/* 0xBF 191 */
408148c5f43SAlan Wright 	{ "SmbOpenPrintFile", SMB_SDT_OPS(open_print_file),	/* 0xC0 192 */
409148c5f43SAlan Wright 	    0xC0, PC_NETWORK_PROGRAM_1_0, 0 },
410148c5f43SAlan Wright 	{ "SmbWritePrintFile", SMB_SDT_OPS(write_print_file),	/* 0xC1 193 */
411148c5f43SAlan Wright 	    0xC1, PC_NETWORK_PROGRAM_1_0, 0 },
412148c5f43SAlan Wright 	{ "SmbClosePrintFile", SMB_SDT_OPS(close_print_file),	/* 0xC2 194 */
413148c5f43SAlan Wright 	    0xC2, PC_NETWORK_PROGRAM_1_0, 0 },
414148c5f43SAlan Wright 	{ "SmbGetPrintQueue", SMB_SDT_OPS(get_print_queue),	/* 0xC3 195 */
415148c5f43SAlan Wright 	    0xC3, PC_NETWORK_PROGRAM_1_0, 0 },
416148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC4, 0, 0 },	/* 0xC4 196 */
417148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC5, 0, 0 },	/* 0xC5 197 */
418148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC6, 0, 0 },	/* 0xC6 198 */
419148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC7, 0, 0 },	/* 0xC7 199 */
420148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC8, 0, 0 },	/* 0xC8 200 */
421148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xC9, 0, 0 },	/* 0xC9 201 */
422148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCA, 0, 0 },	/* 0xCA 202 */
423148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCB, 0, 0 },	/* 0xCB 203 */
424148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCC, 0, 0 },	/* 0xCC 204 */
425148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCD, 0, 0 },	/* 0xCD 205 */
426148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCE, 0, 0 },	/* 0xCE 206 */
427148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xCF, 0, 0 },	/* 0xCF 207 */
428148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD0, 0, 0 },	/* 0xD0 208 */
429148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD1, 0, 0 },	/* 0xD1 209 */
430148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD2, 0, 0 },	/* 0xD2 210 */
431148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD3, 0, 0 },	/* 0xD3 211 */
432148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD4, 0, 0 },	/* 0xD4 212 */
433148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD5, 0, 0 },	/* 0xD5 213 */
434148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD6, 0, 0 },	/* 0xD6 214 */
435148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD7, 0, 0 },	/* 0xD7 215 */
436148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD8, 0, 0 },	/* 0xD8 216 */
437148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xD9, 0, 0 },	/* 0xD9 217 */
438148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDA, 0, 0 },	/* 0xDA 218 */
439148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDB, 0, 0 },	/* 0xDB 219 */
440148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDC, 0, 0 },	/* 0xDC 220 */
441148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDD, 0, 0 },	/* 0xDD 221 */
442148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDE, 0, 0 },	/* 0xDE 222 */
443148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xDF, 0, 0 },	/* 0xDF 223 */
444148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE0, 0, 0 },	/* 0xE0 224 */
445148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE1, 0, 0 },	/* 0xE1 225 */
446148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE2, 0, 0 },	/* 0xE2 226 */
447148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE3, 0, 0 },	/* 0xE3 227 */
448148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE4, 0, 0 },	/* 0xE4 228 */
449148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE5, 0, 0 },	/* 0xE5 229 */
450148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE6, 0, 0 },	/* 0xE6 230 */
451148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE7, 0, 0 },	/* 0xE7 231 */
452148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE8, 0, 0 },	/* 0xE8 232 */
453148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xE9, 0, 0 },	/* 0xE9 233 */
454148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xEA, 0, 0 },	/* 0xEA 234 */
455148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xEB, 0, 0 },	/* 0xEB 235 */
456148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xEC, 0, 0 },	/* 0xEC 236 */
457148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xED, 0, 0 },	/* 0xED 237 */
458148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xEE, 0, 0 },	/* 0xEE 238 */
459148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xEF, 0, 0 },	/* 0xEF 239 */
460148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF0, 0, 0 },	/* 0xF0 240 */
461148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF1, 0, 0 },	/* 0xF1 241 */
462148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF2, 0, 0 },	/* 0xF2 242 */
463148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF3, 0, 0 },	/* 0xF3 243 */
464148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF4, 0, 0 },	/* 0xF4 244 */
465148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF5, 0, 0 },	/* 0xF5 245 */
466148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF6, 0, 0 },	/* 0xF6 246 */
467148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF7, 0, 0 },	/* 0xF7 247 */
468148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF8, 0, 0 },	/* 0xF8 248 */
469148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xF9, 0, 0 },	/* 0xF9 249 */
470148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFA, 0, 0 },	/* 0xFA 250 */
471148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFB, 0, 0 },	/* 0xFB 251 */
472148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFC, 0, 0 },	/* 0xFC 252 */
473148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFD, 0, 0 },	/* 0xFD 253 */
474148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFE, 0, 0 },	/* 0xFE 254 */
475148c5f43SAlan Wright 	{ "Invalid", SMB_SDT_OPS(invalid), 0xFF, 0, 0 }	/* 0xFF	255 */
476da6c28aaSamw };
477da6c28aaSamw 
478da6c28aaSamw /*
479da6c28aaSamw  * smbsr_cleanup
480da6c28aaSamw  *
481da6c28aaSamw  * If any user/tree/file is used by given request then
482da6c28aaSamw  * the reference count for that resource has been incremented.
483da6c28aaSamw  * This function decrements the reference count and close
484da6c28aaSamw  * the resource if it's needed.
485da6c28aaSamw  */
486da6c28aaSamw 
487da6c28aaSamw void
488faa1795aSjb150015 smbsr_cleanup(smb_request_t *sr)
489da6c28aaSamw {
490da6c28aaSamw 	ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) &&
491da6c28aaSamw 	    (sr->sr_state != SMB_REQ_STATE_COMPLETED));
492da6c28aaSamw 
493da6c28aaSamw 	if (sr->r_xa) {
494da6c28aaSamw 		if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE)
495da6c28aaSamw 			smb_xa_close(sr->r_xa);
496da6c28aaSamw 		smb_xa_rele(sr->session, sr->r_xa);
497da6c28aaSamw 		sr->r_xa = NULL;
498da6c28aaSamw 	}
499da6c28aaSamw 
500da6c28aaSamw 	/*
501da6c28aaSamw 	 * Mark this request so we know that we've already cleaned it up.
502da6c28aaSamw 	 * A request should only get cleaned up once so multiple calls to
503da6c28aaSamw 	 * smbsr_cleanup for the same request indicate a bug.
504da6c28aaSamw 	 */
505da6c28aaSamw 	mutex_enter(&sr->sr_mutex);
506da6c28aaSamw 	if (sr->sr_state != SMB_REQ_STATE_CANCELED)
507da6c28aaSamw 		sr->sr_state = SMB_REQ_STATE_CLEANED_UP;
508da6c28aaSamw 	mutex_exit(&sr->sr_mutex);
509da6c28aaSamw }
510*a90cf9f2SGordon Ross 
51159229f98Sjose borrego /*
512*a90cf9f2SGordon Ross  * This is the SMB1 handler for new smb requests, called from
513*a90cf9f2SGordon Ross  * smb_session_reader after SMB negotiate is done.  For most SMB
514*a90cf9f2SGordon Ross  * requests, we just enqueue them for the smb_session_worker to
515*a90cf9f2SGordon Ross  * execute via the task queue, so they can block for resources
516*a90cf9f2SGordon Ross  * without stopping the reader thread.  A few protocol messages
517*a90cf9f2SGordon Ross  * are special cases and are handled directly here in the reader
518*a90cf9f2SGordon Ross  * thread so they don't wait for taskq scheduling.  Later, a few
519*a90cf9f2SGordon Ross  * MORE things could be handled here, such as REPLY messages
520*a90cf9f2SGordon Ross  * (oplock break reply) and things like "NT_cancel".
52159229f98Sjose borrego  *
522*a90cf9f2SGordon Ross  * This function must either enqueue the new request for
523*a90cf9f2SGordon Ross  * execution via the task queue, or execute it directly
524*a90cf9f2SGordon Ross  * and then free it.  If this returns non-zero, the caller
525*a90cf9f2SGordon Ross  * will drop the session.
52659229f98Sjose borrego  */
527*a90cf9f2SGordon Ross int
528*a90cf9f2SGordon Ross smb1sr_newrq(smb_request_t *sr)
529*a90cf9f2SGordon Ross {
530*a90cf9f2SGordon Ross 	uint32_t magic;
531*a90cf9f2SGordon Ross 
532*a90cf9f2SGordon Ross 	magic = SMB_READ_PROTOCOL(sr->sr_request_buf);
533*a90cf9f2SGordon Ross 	if (magic != SMB_PROTOCOL_MAGIC) {
534*a90cf9f2SGordon Ross 		smb_request_free(sr);
535*a90cf9f2SGordon Ross 		return (EPROTO);
536*a90cf9f2SGordon Ross 	}
537*a90cf9f2SGordon Ross 
538*a90cf9f2SGordon Ross 	if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
539*a90cf9f2SGordon Ross 		if (SMB_IS_NT_CANCEL(sr)) {
540*a90cf9f2SGordon Ross 			sr->session->signing.seqnum++;
541*a90cf9f2SGordon Ross 			sr->sr_seqnum = sr->session->signing.seqnum + 1;
542*a90cf9f2SGordon Ross 			sr->reply_seqnum = 0;
543*a90cf9f2SGordon Ross 		} else {
544*a90cf9f2SGordon Ross 			sr->session->signing.seqnum += 2;
545*a90cf9f2SGordon Ross 			sr->sr_seqnum = sr->session->signing.seqnum;
546*a90cf9f2SGordon Ross 			sr->reply_seqnum = sr->sr_seqnum + 1;
547*a90cf9f2SGordon Ross 		}
548*a90cf9f2SGordon Ross 	}
549*a90cf9f2SGordon Ross 
550*a90cf9f2SGordon Ross 	/*
551*a90cf9f2SGordon Ross 	 * Submit the request to the task queue, which calls
552*a90cf9f2SGordon Ross 	 * smb1_tq_work when the workload permits.
553*a90cf9f2SGordon Ross 	 */
554*a90cf9f2SGordon Ross 	sr->sr_time_submitted = gethrtime();
555*a90cf9f2SGordon Ross 	sr->sr_state = SMB_REQ_STATE_SUBMITTED;
556*a90cf9f2SGordon Ross 	smb_srqueue_waitq_enter(sr->session->s_srqueue);
557*a90cf9f2SGordon Ross 	(void) taskq_dispatch(sr->sr_server->sv_worker_pool,
558*a90cf9f2SGordon Ross 	    smb1_tq_work, sr, TQ_SLEEP);
559*a90cf9f2SGordon Ross 
560*a90cf9f2SGordon Ross 	return (0);
561*a90cf9f2SGordon Ross }
562*a90cf9f2SGordon Ross 
563*a90cf9f2SGordon Ross static void
564*a90cf9f2SGordon Ross smb1_tq_work(void *arg)
565*a90cf9f2SGordon Ross {
566*a90cf9f2SGordon Ross 	smb_request_t	*sr;
567*a90cf9f2SGordon Ross 	smb_srqueue_t	*srq;
568*a90cf9f2SGordon Ross 
569*a90cf9f2SGordon Ross 	sr = (smb_request_t *)arg;
570*a90cf9f2SGordon Ross 	SMB_REQ_VALID(sr);
571*a90cf9f2SGordon Ross 
572*a90cf9f2SGordon Ross 	srq = sr->session->s_srqueue;
573*a90cf9f2SGordon Ross 	smb_srqueue_waitq_to_runq(srq);
574*a90cf9f2SGordon Ross 	sr->sr_worker = curthread;
575*a90cf9f2SGordon Ross 	sr->sr_time_active = gethrtime();
576*a90cf9f2SGordon Ross 
577*a90cf9f2SGordon Ross 	mutex_enter(&sr->sr_mutex);
578*a90cf9f2SGordon Ross 	switch (sr->sr_state) {
579*a90cf9f2SGordon Ross 	case SMB_REQ_STATE_SUBMITTED:
580*a90cf9f2SGordon Ross 		mutex_exit(&sr->sr_mutex);
581*a90cf9f2SGordon Ross 		smb1sr_work(sr);
582*a90cf9f2SGordon Ross 		sr = NULL;
583*a90cf9f2SGordon Ross 		break;
584*a90cf9f2SGordon Ross 
585*a90cf9f2SGordon Ross 	default:
586*a90cf9f2SGordon Ross 		/*
587*a90cf9f2SGordon Ross 		 * SMB1 requests that have been cancelled
588*a90cf9f2SGordon Ross 		 * have no reply.  Just free it.
589*a90cf9f2SGordon Ross 		 */
590*a90cf9f2SGordon Ross 		sr->sr_state = SMB_REQ_STATE_COMPLETED;
591*a90cf9f2SGordon Ross 		mutex_exit(&sr->sr_mutex);
592*a90cf9f2SGordon Ross 		smb_request_free(sr);
593*a90cf9f2SGordon Ross 		break;
594*a90cf9f2SGordon Ross 	}
595*a90cf9f2SGordon Ross 	smb_srqueue_runq_exit(srq);
596*a90cf9f2SGordon Ross }
597*a90cf9f2SGordon Ross 
598*a90cf9f2SGordon Ross /*
599*a90cf9f2SGordon Ross  * smb1sr_work
600*a90cf9f2SGordon Ross  *
601*a90cf9f2SGordon Ross  * In most cases, this should free the request before return.
602*a90cf9f2SGordon Ross  * Exceptions are when a dispatch function returns SDRC_SR_KEPT.
603*a90cf9f2SGordon Ross  */
604*a90cf9f2SGordon Ross void
605*a90cf9f2SGordon Ross smb1sr_work(struct smb_request *sr)
606da6c28aaSamw {
6077b59d02dSjb150015 	smb_sdrc_t		sdrc;
6088622ec45SGordon Ross 	const smb_disp_entry_t	*sdd;
6098622ec45SGordon Ross 	smb_disp_stats_t	*sds;
6107b59d02dSjb150015 	boolean_t		disconnect = B_FALSE;
61159229f98Sjose borrego 	smb_session_t		*session;
6128622ec45SGordon Ross 	smb_server_t		*server;
6132c2961f8Sjose borrego 	uint32_t		byte_count;
614584e0fceSGordon Ross 	uint32_t		max_bytes;
615*a90cf9f2SGordon Ross 	uint16_t		pid_hi, pid_lo;
61659229f98Sjose borrego 
61759229f98Sjose borrego 	session = sr->session;
6188622ec45SGordon Ross 	server = session->s_server;
619da6c28aaSamw 
620da6c28aaSamw 	ASSERT(sr->tid_tree == 0);
621da6c28aaSamw 	ASSERT(sr->uid_user == 0);
622da6c28aaSamw 	ASSERT(sr->fid_ofile == 0);
623da6c28aaSamw 	sr->smb_fid = (uint16_t)-1;
624da6c28aaSamw 
625da6c28aaSamw 	/* temporary until we identify a user */
6268622ec45SGordon Ross 	sr->user_cr = zone_kcred();
627da6c28aaSamw 	sr->orig_request_hdr = sr->command.chain_offset;
628da6c28aaSamw 
629*a90cf9f2SGordon Ross 	/*
630*a90cf9f2SGordon Ross 	 * Decode the SMB header.
631*a90cf9f2SGordon Ross 	 */
6323db3f65cSamw 	if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT,
633da6c28aaSamw 	    &sr->smb_com,
634da6c28aaSamw 	    &sr->smb_rcls,
635da6c28aaSamw 	    &sr->smb_reh,
636da6c28aaSamw 	    &sr->smb_err,
637da6c28aaSamw 	    &sr->smb_flg,
638da6c28aaSamw 	    &sr->smb_flg2,
639*a90cf9f2SGordon Ross 	    &pid_hi,
640da6c28aaSamw 	    sr->smb_sig,
641da6c28aaSamw 	    &sr->smb_tid,
642*a90cf9f2SGordon Ross 	    &pid_lo,
643da6c28aaSamw 	    &sr->smb_uid,
644da6c28aaSamw 	    &sr->smb_mid) != 0) {
6457b59d02dSjb150015 		disconnect = B_TRUE;
6467b59d02dSjb150015 		goto drop_connection;
647da6c28aaSamw 	}
648*a90cf9f2SGordon Ross 	sr->smb_pid = (pid_hi << 16) | pid_lo;
649da6c28aaSamw 
650da6c28aaSamw 	/*
6517b59d02dSjb150015 	 * The reply "header" is filled in now even though it will,
6527b59d02dSjb150015 	 * most likely, be rewritten under reply_ready below.  We
6537b59d02dSjb150015 	 * could reserve the space but this is convenient in case
6547b59d02dSjb150015 	 * the dialect dispatcher has to send a special reply (like
6557b59d02dSjb150015 	 * TRANSACT).
656da6c28aaSamw 	 *
657da6c28aaSamw 	 * Ensure that the 32-bit error code flag is turned off.
658da6c28aaSamw 	 * Clients seem to set it in transact requests and they may
659da6c28aaSamw 	 * get confused if we return success or a 16-bit SMB code.
660da6c28aaSamw 	 */
661da6c28aaSamw 	sr->smb_rcls = 0;
662da6c28aaSamw 	sr->smb_reh = 0;
663da6c28aaSamw 	sr->smb_err = 0;
664da6c28aaSamw 	sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS;
665da6c28aaSamw 
6663db3f65cSamw 	(void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT,
667da6c28aaSamw 	    sr->smb_com,
668da6c28aaSamw 	    sr->smb_rcls,
669da6c28aaSamw 	    sr->smb_reh,
670da6c28aaSamw 	    sr->smb_err,
671da6c28aaSamw 	    sr->smb_flg,
672da6c28aaSamw 	    sr->smb_flg2,
673*a90cf9f2SGordon Ross 	    pid_hi,
674da6c28aaSamw 	    sr->smb_sig,
675da6c28aaSamw 	    sr->smb_tid,
676*a90cf9f2SGordon Ross 	    pid_lo,
677da6c28aaSamw 	    sr->smb_uid,
678da6c28aaSamw 	    sr->smb_mid);
679da6c28aaSamw 	sr->first_smb_com = sr->smb_com;
680da6c28aaSamw 
681b819cea2SGordon Ross 	if ((session->signing.flags & SMB_SIGNING_CHECK) != 0) {
682b819cea2SGordon Ross 		if ((sr->smb_flg2 & SMB_FLAGS2_SMB_SECURITY_SIGNATURE) == 0 ||
683b819cea2SGordon Ross 		    smb_sign_check_request(sr) != 0) {
6847b59d02dSjb150015 			smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
6857b59d02dSjb150015 			    ERRDOS, ERROR_ACCESS_DENIED);
6867b59d02dSjb150015 			disconnect = B_TRUE;
6877b59d02dSjb150015 			goto report_error;
688da6c28aaSamw 		}
689da6c28aaSamw 	}
690da6c28aaSamw 
691da6c28aaSamw andx_more:
692148c5f43SAlan Wright 	sdd = &smb_disp_table[sr->smb_com];
693faa1795aSjb150015 	ASSERT(sdd->sdt_function);
694*a90cf9f2SGordon Ross 	sds = &server->sv_disp_stats1[sr->smb_com];
695da6c28aaSamw 
6963db3f65cSamw 	if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) {
6977b59d02dSjb150015 		disconnect = B_TRUE;
6987b59d02dSjb150015 		goto report_error;
699da6c28aaSamw 	}
700da6c28aaSamw 
701da6c28aaSamw 	(void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command,
702da6c28aaSamw 	    sr->command.chain_offset, sr->smb_wct * 2);
703da6c28aaSamw 
7043db3f65cSamw 	if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) {
7057b59d02dSjb150015 		disconnect = B_TRUE;
7067b59d02dSjb150015 		goto report_error;
707da6c28aaSamw 	}
708da6c28aaSamw 
7098622ec45SGordon Ross 	atomic_add_64(&sds->sdt_rxb,
710148c5f43SAlan Wright 	    (int64_t)(sr->smb_wct * 2 + sr->smb_bcc + 1));
711148c5f43SAlan Wright 	sr->sr_txb = sr->reply.chain_offset;
712148c5f43SAlan Wright 
7132c2961f8Sjose borrego 	/*
7142c2961f8Sjose borrego 	 * Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX
7152c2961f8Sjose borrego 	 * and this is SmbReadX/SmbWriteX since this enables
7162c2961f8Sjose borrego 	 * large reads/write and bcc is only 16-bits.
7172c2961f8Sjose borrego 	 */
718584e0fceSGordon Ross 	max_bytes = sr->command.max_bytes - sr->command.chain_offset;
7191fb4a876SGordon Ross 	if (sr->smb_com == SMB_COM_WRITE_ANDX) {
7201fb4a876SGordon Ross 		/* Allow > BCC */
721584e0fceSGordon Ross 		byte_count = max_bytes;
722584e0fceSGordon Ross 	} else if (max_bytes < (uint32_t)sr->smb_bcc) {
723584e0fceSGordon Ross 		/* BCC is bogus.  Will fail later. */
724584e0fceSGordon Ross 		byte_count = max_bytes;
7252c2961f8Sjose borrego 	} else {
726584e0fceSGordon Ross 		/* ordinary case */
7272c2961f8Sjose borrego 		byte_count = (uint32_t)sr->smb_bcc;
7282c2961f8Sjose borrego 	}
729da6c28aaSamw 
7302c2961f8Sjose borrego 	(void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command,
7312c2961f8Sjose borrego 	    sr->command.chain_offset, byte_count);
7322c2961f8Sjose borrego 
7332c2961f8Sjose borrego 	sr->command.chain_offset += byte_count;
734da6c28aaSamw 	if (sr->command.chain_offset > sr->command.max_bytes) {
7357b59d02dSjb150015 		disconnect = B_TRUE;
7367b59d02dSjb150015 		goto report_error;
737da6c28aaSamw 	}
738da6c28aaSamw 
739da6c28aaSamw 	/* Store pointers for later */
740da6c28aaSamw 	sr->cur_reply_offset = sr->reply.chain_offset;
741da6c28aaSamw 
742da6c28aaSamw 	if (is_andx_com(sr->smb_com)) {
743da6c28aaSamw 		/* Peek ahead and don't disturb vwv */
7443db3f65cSamw 		if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w",
745da6c28aaSamw 		    &sr->andx_com, &sr->andx_off) < 0) {
7467b59d02dSjb150015 			disconnect = B_TRUE;
7477b59d02dSjb150015 			goto report_error;
748da6c28aaSamw 		}
749da6c28aaSamw 	} else {
750da6c28aaSamw 		sr->andx_com = (unsigned char)-1;
751da6c28aaSamw 	}
752da6c28aaSamw 
753da6c28aaSamw 	mutex_enter(&sr->sr_mutex);
754da6c28aaSamw 	switch (sr->sr_state) {
755da6c28aaSamw 	case SMB_REQ_STATE_SUBMITTED:
756da6c28aaSamw 	case SMB_REQ_STATE_CLEANED_UP:
757da6c28aaSamw 		sr->sr_state = SMB_REQ_STATE_ACTIVE;
758da6c28aaSamw 		break;
759da6c28aaSamw 	case SMB_REQ_STATE_CANCELED:
760da6c28aaSamw 		break;
761da6c28aaSamw 	default:
762da6c28aaSamw 		ASSERT(0);
763da6c28aaSamw 		break;
764da6c28aaSamw 	}
765da6c28aaSamw 	mutex_exit(&sr->sr_mutex);
766da6c28aaSamw 
767da6c28aaSamw 	/*
768da6c28aaSamw 	 * Setup UID and TID information (if required). Both functions
769da6c28aaSamw 	 * will set the sr credentials. In domain mode, the user and
770da6c28aaSamw 	 * tree credentials should be the same. In share mode, the
771da6c28aaSamw 	 * tree credentials (defined in the share definition) should
772da6c28aaSamw 	 * override the user credentials.
773da6c28aaSamw 	 */
774faa1795aSjb150015 	if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) {
7759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		sr->uid_user = smb_session_lookup_uid(session, sr->smb_uid);
776da6c28aaSamw 		if (sr->uid_user == NULL) {
777dc20a302Sas200622 			smbsr_error(sr, 0, ERRSRV, ERRbaduid);
778faa1795aSjb150015 			smbsr_cleanup(sr);
7797b59d02dSjb150015 			goto report_error;
780da6c28aaSamw 		}
7817b59d02dSjb150015 
782b89a8333Snatalie li - Sun Microsystems - Irvine United States 		sr->user_cr = smb_user_getcred(sr->uid_user);
7833b13a1efSThomas Keiser 	}
7843b13a1efSThomas Keiser 	if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && (sr->tid_tree == NULL)) {
7853b13a1efSThomas Keiser 		sr->tid_tree = smb_session_lookup_tree(session, sr->smb_tid);
786da6c28aaSamw 		if (sr->tid_tree == NULL) {
787dc20a302Sas200622 			smbsr_error(sr, 0, ERRSRV, ERRinvnid);
788faa1795aSjb150015 			smbsr_cleanup(sr);
7897b59d02dSjb150015 			goto report_error;
790da6c28aaSamw 		}
791da6c28aaSamw 	}
792da6c28aaSamw 
793148c5f43SAlan Wright 	sr->sr_time_start = gethrtime();
794faa1795aSjb150015 	if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS)
795faa1795aSjb150015 		sdrc = (*sdd->sdt_function)(sr);
796faa1795aSjb150015 
797eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 	if (sdrc != SDRC_SR_KEPT) {
798eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 		(*sdd->sdt_post_op)(sr);
799eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 		smbsr_cleanup(sr);
800eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 	}
8018622ec45SGordon Ross 	smb_latency_add_sample(&sds->sdt_lat, gethrtime() - sr->sr_time_start);
802148c5f43SAlan Wright 
8038622ec45SGordon Ross 	atomic_add_64(&sds->sdt_txb,
804148c5f43SAlan Wright 	    (int64_t)(sr->reply.chain_offset - sr->sr_txb));
805eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 
8067b59d02dSjb150015 	switch (sdrc) {
807faa1795aSjb150015 	case SDRC_SUCCESS:
808da6c28aaSamw 		break;
809da6c28aaSamw 
810da6c28aaSamw 	case SDRC_DROP_VC:
8117b59d02dSjb150015 		disconnect = B_TRUE;
8127b59d02dSjb150015 		goto drop_connection;
813da6c28aaSamw 
814da6c28aaSamw 	case SDRC_NO_REPLY:
815*a90cf9f2SGordon Ross 		/* will free sr */
816*a90cf9f2SGordon Ross 		goto out;
81759229f98Sjose borrego 
81859229f98Sjose borrego 	case SDRC_SR_KEPT:
819*a90cf9f2SGordon Ross 		/* Do NOT free sr */
820*a90cf9f2SGordon Ross 		sr = NULL;
821*a90cf9f2SGordon Ross 		goto out;
8227b59d02dSjb150015 
823faa1795aSjb150015 	case SDRC_ERROR:
8247b59d02dSjb150015 		goto report_error;
825da6c28aaSamw 
826faa1795aSjb150015 	case SDRC_NOT_IMPLEMENTED:
827da6c28aaSamw 	default:
8287b59d02dSjb150015 		smbsr_error(sr, 0, ERRDOS, ERRbadfunc);
8297b59d02dSjb150015 		goto report_error;
830da6c28aaSamw 	}
831da6c28aaSamw 
8327b59d02dSjb150015 	/*
8337b59d02dSjb150015 	 * If there's no AndX command, we're done.
8347b59d02dSjb150015 	 */
835da6c28aaSamw 	if (sr->andx_com == 0xff)
836da6c28aaSamw 		goto reply_ready;
837da6c28aaSamw 
8387b59d02dSjb150015 	/*
8397b59d02dSjb150015 	 * Otherwise, we have to back-patch the AndXCommand and AndXOffset
8407b59d02dSjb150015 	 * and continue processing.
8417b59d02dSjb150015 	 */
842da6c28aaSamw 	sr->andx_prev_wct = sr->cur_reply_offset;
8433db3f65cSamw 	(void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w",
844da6c28aaSamw 	    sr->andx_com, MBC_LENGTH(&sr->reply));
845da6c28aaSamw 
846da6c28aaSamw 	sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off;
847da6c28aaSamw 	sr->smb_com = sr->andx_com;
848da6c28aaSamw 	goto andx_more;
849da6c28aaSamw 
8507b59d02dSjb150015 report_error:
851da6c28aaSamw 	sr->reply.chain_offset = sr->cur_reply_offset;
8523db3f65cSamw 	(void) smb_mbc_encodef(&sr->reply, "bw", 0, 0);
853da6c28aaSamw 
854da6c28aaSamw 	sr->smb_wct = 0;
855da6c28aaSamw 	sr->smb_bcc = 0;
856da6c28aaSamw 
857faa1795aSjb150015 	if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0)
8587b59d02dSjb150015 		smbsr_error(sr, 0, ERRSRV, ERRerror);
8597b59d02dSjb150015 
8607b59d02dSjb150015 reply_ready:
8617b59d02dSjb150015 	smbsr_send_reply(sr);
8627b59d02dSjb150015 
8637b59d02dSjb150015 drop_connection:
8647b59d02dSjb150015 	if (disconnect) {
865eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 		smb_rwx_rwenter(&session->s_lock, RW_WRITER);
86659229f98Sjose borrego 		switch (session->s_state) {
8677b59d02dSjb150015 		case SMB_SESSION_STATE_DISCONNECTED:
8687b59d02dSjb150015 		case SMB_SESSION_STATE_TERMINATED:
8697b59d02dSjb150015 			break;
8707b59d02dSjb150015 		default:
87159229f98Sjose borrego 			smb_soshutdown(session->sock);
87259229f98Sjose borrego 			session->s_state = SMB_SESSION_STATE_DISCONNECTED;
8737b59d02dSjb150015 			break;
874da6c28aaSamw 		}
87559229f98Sjose borrego 		smb_rwx_rwexit(&session->s_lock);
876eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 	}
87759229f98Sjose borrego 
878*a90cf9f2SGordon Ross out:
879*a90cf9f2SGordon Ross 	if (sr != NULL) {
880*a90cf9f2SGordon Ross 		mutex_enter(&sr->sr_mutex);
881*a90cf9f2SGordon Ross 		sr->sr_state = SMB_REQ_STATE_COMPLETED;
882*a90cf9f2SGordon Ross 		mutex_exit(&sr->sr_mutex);
883*a90cf9f2SGordon Ross 		smb_request_free(sr);
884*a90cf9f2SGordon Ross 	}
8857b59d02dSjb150015 }
886da6c28aaSamw 
8877b59d02dSjb150015 int
8887b59d02dSjb150015 smbsr_encode_empty_result(struct smb_request *sr)
8897b59d02dSjb150015 {
8907b59d02dSjb150015 	return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0));
8917b59d02dSjb150015 }
8927b59d02dSjb150015 
8937b59d02dSjb150015 int
894*a90cf9f2SGordon Ross smbsr_encode_result(struct smb_request *sr, int wct, int bcc,
895*a90cf9f2SGordon Ross     const char *fmt, ...)
896da6c28aaSamw {
897da6c28aaSamw 	va_list ap;
898da6c28aaSamw 
8997b59d02dSjb150015 	if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset)
9007b59d02dSjb150015 		return (-1);
901da6c28aaSamw 
902da6c28aaSamw 	va_start(ap, fmt);
9033db3f65cSamw 	(void) smb_mbc_vencodef(&sr->reply, fmt, ap);
904da6c28aaSamw 	va_end(ap);
905da6c28aaSamw 
906da6c28aaSamw 	sr->smb_wct = (unsigned char)wct;
907da6c28aaSamw 	sr->smb_bcc = (uint16_t)bcc;
908da6c28aaSamw 
9097b59d02dSjb150015 	if (smbsr_check_result(sr, wct, bcc) != 0)
9107b59d02dSjb150015 		return (-1);
9117b59d02dSjb150015 
9127b59d02dSjb150015 	return (0);
913da6c28aaSamw }
914da6c28aaSamw 
9157b59d02dSjb150015 static int
916da6c28aaSamw smbsr_check_result(struct smb_request *sr, int wct, int bcc)
917da6c28aaSamw {
918da6c28aaSamw 	int		offset = sr->cur_reply_offset;
919da6c28aaSamw 	int		total_bytes;
920da6c28aaSamw 	unsigned char	temp, temp1;
921da6c28aaSamw 	struct mbuf	*m;
922da6c28aaSamw 
923da6c28aaSamw 	total_bytes = 0;
924da6c28aaSamw 	m = sr->reply.chain;
925da6c28aaSamw 	while (m != 0) {
926da6c28aaSamw 		total_bytes += m->m_len;
927da6c28aaSamw 		m = m->m_next;
928da6c28aaSamw 	}
929da6c28aaSamw 
9307b59d02dSjb150015 	if ((offset + 3) > total_bytes)
9317b59d02dSjb150015 		return (-1);
932da6c28aaSamw 
9333db3f65cSamw 	(void) smb_mbc_peek(&sr->reply, offset, "b", &temp);
9347b59d02dSjb150015 	if (temp != wct)
9357b59d02dSjb150015 		return (-1);
936da6c28aaSamw 
9377b59d02dSjb150015 	if ((offset + (wct * 2 + 1)) > total_bytes)
9387b59d02dSjb150015 		return (-1);
939da6c28aaSamw 
940da6c28aaSamw 	/* reply wct & vwv seem ok, consider data now */
941da6c28aaSamw 	offset += wct * 2 + 1;
942da6c28aaSamw 
9437b59d02dSjb150015 	if ((offset + 2) > total_bytes)
9447b59d02dSjb150015 		return (-1);
945da6c28aaSamw 
9463db3f65cSamw 	(void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1);
947da6c28aaSamw 	if (bcc == VAR_BCC) {
948da6c28aaSamw 		if ((temp != 0xFF) || (temp1 != 0xFF)) {
9497b59d02dSjb150015 			return (-1);
950da6c28aaSamw 		} else {
951da6c28aaSamw 			bcc = (total_bytes - offset) - 2;
9523db3f65cSamw 			(void) smb_mbc_poke(&sr->reply, offset, "bb",
953da6c28aaSamw 			    bcc, bcc >> 8);
954da6c28aaSamw 		}
955da6c28aaSamw 	} else {
9567b59d02dSjb150015 		if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF)))
9577b59d02dSjb150015 			return (-1);
958da6c28aaSamw 	}
959da6c28aaSamw 
960da6c28aaSamw 	offset += bcc + 2;
961da6c28aaSamw 
9627b59d02dSjb150015 	if (offset != total_bytes)
9637b59d02dSjb150015 		return (-1);
964da6c28aaSamw 
965da6c28aaSamw 	sr->smb_wct = (unsigned char)wct;
966da6c28aaSamw 	sr->smb_bcc = (uint16_t)bcc;
9677b59d02dSjb150015 	return (0);
968da6c28aaSamw }
969da6c28aaSamw 
970da6c28aaSamw int
971*a90cf9f2SGordon Ross smbsr_decode_vwv(struct smb_request *sr, const char *fmt, ...)
972da6c28aaSamw {
973da6c28aaSamw 	int rc;
974da6c28aaSamw 	va_list ap;
975da6c28aaSamw 
976da6c28aaSamw 	va_start(ap, fmt);
9773db3f65cSamw 	rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap);
978da6c28aaSamw 	va_end(ap);
979da6c28aaSamw 
980faa1795aSjb150015 	if (rc)
981faa1795aSjb150015 		smbsr_error(sr, 0, ERRSRV, ERRerror);
982da6c28aaSamw 	return (rc);
983da6c28aaSamw }
984da6c28aaSamw 
985da6c28aaSamw int
986*a90cf9f2SGordon Ross smbsr_decode_data(struct smb_request *sr, const char *fmt, ...)
987da6c28aaSamw {
988faa1795aSjb150015 	int rc;
989da6c28aaSamw 	va_list ap;
990faa1795aSjb150015 
991da6c28aaSamw 	va_start(ap, fmt);
9923db3f65cSamw 	rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap);
993da6c28aaSamw 	va_end(ap);
994faa1795aSjb150015 
995faa1795aSjb150015 	if (rc)
996faa1795aSjb150015 		smbsr_error(sr, 0, ERRSRV, ERRerror);
997faa1795aSjb150015 	return (rc);
998da6c28aaSamw }
999da6c28aaSamw 
1000148c5f43SAlan Wright boolean_t
1001148c5f43SAlan Wright smbsr_decode_data_avail(smb_request_t *sr)
1002148c5f43SAlan Wright {
1003148c5f43SAlan Wright 	return (sr->smb_data.chain_offset < sr->smb_data.max_bytes);
1004148c5f43SAlan Wright }
1005148c5f43SAlan Wright 
1006da6c28aaSamw void
1007148c5f43SAlan Wright smbsr_send_reply(smb_request_t *sr)
1008da6c28aaSamw {
1009*a90cf9f2SGordon Ross 	uint16_t	pid_hi, pid_lo;
1010*a90cf9f2SGordon Ross 
1011c8ec8eeaSjose borrego 	if (SMB_TREE_IS_CASEINSENSITIVE(sr))
10127b59d02dSjb150015 		sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE;
10137b59d02dSjb150015 	else
10147b59d02dSjb150015 		sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE;
1015*a90cf9f2SGordon Ross 	pid_hi = sr->smb_pid >> 16;
1016*a90cf9f2SGordon Ross 	pid_lo = (uint16_t)sr->smb_pid;
10177b59d02dSjb150015 
10183db3f65cSamw 	(void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT,
1019da6c28aaSamw 	    sr->first_smb_com,
1020da6c28aaSamw 	    sr->smb_rcls,
1021da6c28aaSamw 	    sr->smb_reh,
1022da6c28aaSamw 	    sr->smb_err,
1023da6c28aaSamw 	    sr->smb_flg | SMB_FLAGS_REPLY,
1024da6c28aaSamw 	    sr->smb_flg2,
1025*a90cf9f2SGordon Ross 	    pid_hi,
1026da6c28aaSamw 	    sr->smb_sig,
1027da6c28aaSamw 	    sr->smb_tid,
1028*a90cf9f2SGordon Ross 	    pid_lo,
1029da6c28aaSamw 	    sr->smb_uid,
1030da6c28aaSamw 	    sr->smb_mid);
1031da6c28aaSamw 
1032da6c28aaSamw 	if (sr->session->signing.flags & SMB_SIGNING_ENABLED)
1033da6c28aaSamw 		smb_sign_reply(sr, NULL);
1034da6c28aaSamw 
10357b59d02dSjb150015 	if (smb_session_send(sr->session, 0, &sr->reply) == 0)
10367b59d02dSjb150015 		sr->reply.chain = 0;
1037da6c28aaSamw }
1038da6c28aaSamw 
1039da6c28aaSamw void
1040dc20a302Sas200622 smbsr_map_errno(int errnum, smb_error_t *err)
1041da6c28aaSamw {
1042*a90cf9f2SGordon Ross 	uint32_t status;
1043*a90cf9f2SGordon Ross 	uint16_t doserr;
1044da6c28aaSamw 
1045*a90cf9f2SGordon Ross 	status = smb_errno2status(errnum);
1046*a90cf9f2SGordon Ross 	doserr = smb_status2doserr(status);
1047da6c28aaSamw 
1048*a90cf9f2SGordon Ross 	err->status  = status;
1049dc20a302Sas200622 	err->errcls  = ERRDOS;
1050*a90cf9f2SGordon Ross 	err->errcode = doserr;
1051da6c28aaSamw }
1052da6c28aaSamw 
1053da6c28aaSamw void
1054dc20a302Sas200622 smbsr_errno(struct smb_request *sr, int errnum)
1055da6c28aaSamw {
10567b59d02dSjb150015 	smbsr_map_errno(errnum, &sr->smb_error);
10577b59d02dSjb150015 	smbsr_set_error(sr, &sr->smb_error);
1058da6c28aaSamw }
1059da6c28aaSamw 
1060dc20a302Sas200622 /*
1061148c5f43SAlan Wright  * Report a request processing status (error or warning).
1062dc20a302Sas200622  */
1063dc20a302Sas200622 void
1064148c5f43SAlan Wright smbsr_status(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode)
1065dc20a302Sas200622 {
1066*a90cf9f2SGordon Ross 
10677b59d02dSjb150015 	sr->smb_error.status   = status;
1068*a90cf9f2SGordon Ross 
1069*a90cf9f2SGordon Ross 	/*
1070*a90cf9f2SGordon Ross 	 * This function is SMB1 specific.  While adding SMB2 support,
1071*a90cf9f2SGordon Ross 	 * calls to this function have been removed from common code.
1072*a90cf9f2SGordon Ross 	 * In case we missed any, check for SMB2 callers here, and
1073*a90cf9f2SGordon Ross 	 * vector into a wrapper function that we can watch for...
1074*a90cf9f2SGordon Ross 	 * (and track down with dtrace:)
1075*a90cf9f2SGordon Ross 	 */
1076*a90cf9f2SGordon Ross 	if (sr->session->dialect >= SMB_VERS_2_BASE) {
1077*a90cf9f2SGordon Ross 		smbsr_status_smb2(sr, status);
1078*a90cf9f2SGordon Ross 		return;
1079*a90cf9f2SGordon Ross 	}
1080*a90cf9f2SGordon Ross 
1081*a90cf9f2SGordon Ross 	if (status != 0 && errcls == 0 && errcode == 0) {
1082*a90cf9f2SGordon Ross 		errcls = ERRDOS;
1083*a90cf9f2SGordon Ross 		errcode = smb_status2doserr(status);
1084*a90cf9f2SGordon Ross 	}
1085*a90cf9f2SGordon Ross 
10867b59d02dSjb150015 	sr->smb_error.errcls   = errcls;
10877b59d02dSjb150015 	sr->smb_error.errcode  = errcode;
1088dc20a302Sas200622 
10897b59d02dSjb150015 	smbsr_set_error(sr, &sr->smb_error);
1090dc20a302Sas200622 }
1091dc20a302Sas200622 
1092dc20a302Sas200622 /*
1093dc20a302Sas200622  * Setup a request processing error.  This function can be used to
1094dc20a302Sas200622  * report 32-bit status codes or DOS errors.  Set the status code
1095dc20a302Sas200622  * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error,
1096dc20a302Sas200622  * regardless of the client capabilities.
1097dc20a302Sas200622  *
1098dc20a302Sas200622  * If status is non-zero and the client supports 32-bit status
1099dc20a302Sas200622  * codes, report the status.  Otherwise, report the DOS error.
1100dc20a302Sas200622  */
1101dc20a302Sas200622 void
1102dc20a302Sas200622 smbsr_set_error(smb_request_t *sr, smb_error_t *err)
1103dc20a302Sas200622 {
1104dc20a302Sas200622 	uint32_t status;
1105dc20a302Sas200622 	uint32_t capabilities;
1106dc20a302Sas200622 
1107dc20a302Sas200622 	ASSERT(sr);
1108dc20a302Sas200622 	ASSERT(err);
1109dc20a302Sas200622 
1110dc20a302Sas200622 	status = err->status;
1111dc20a302Sas200622 	capabilities = sr->session->capabilities;
1112dc20a302Sas200622 
1113dc20a302Sas200622 	if ((err->errcls == 0) && (err->errcode == 0)) {
1114dc20a302Sas200622 		capabilities |= CAP_STATUS32;
1115dc20a302Sas200622 		if (status == 0)
1116dc20a302Sas200622 			status = NT_STATUS_INTERNAL_ERROR;
1117dc20a302Sas200622 	}
1118dc20a302Sas200622 
1119dc20a302Sas200622 	if ((capabilities & CAP_STATUS32) && (status != 0)) {
1120dc20a302Sas200622 		sr->smb_rcls = status & 0xff;
1121dc20a302Sas200622 		sr->smb_reh = (status >> 8) & 0xff;
1122dc20a302Sas200622 		sr->smb_err  = status >> 16;
1123dc20a302Sas200622 		sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS;
1124dc20a302Sas200622 	} else {
1125dc20a302Sas200622 		if ((err->errcls == 0) || (err->errcode == 0)) {
1126dc20a302Sas200622 			sr->smb_rcls = ERRSRV;
1127dc20a302Sas200622 			sr->smb_err  = ERRerror;
1128dc20a302Sas200622 		} else {
1129dc20a302Sas200622 			sr->smb_rcls = (uint8_t)err->errcls;
1130dc20a302Sas200622 			sr->smb_err  = (uint16_t)err->errcode;
1131dc20a302Sas200622 		}
1132dc20a302Sas200622 	}
1133da6c28aaSamw }
1134da6c28aaSamw 
1135da6c28aaSamw smb_xa_t *
1136da6c28aaSamw smbsr_lookup_xa(smb_request_t *sr)
1137da6c28aaSamw {
1138da6c28aaSamw 	ASSERT(sr->r_xa == 0);
1139da6c28aaSamw 
1140da6c28aaSamw 	sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid);
1141da6c28aaSamw 	return (sr->r_xa);
1142da6c28aaSamw }
1143da6c28aaSamw 
1144da6c28aaSamw void
1145e3f2c991SKeyur Desai smbsr_release_file(smb_request_t *sr)
1146da6c28aaSamw {
1147da6c28aaSamw 	smb_ofile_t	*of = sr->fid_ofile;
1148da6c28aaSamw 
1149da6c28aaSamw 	sr->fid_ofile = NULL;
1150da6c28aaSamw 	(void) smb_ofile_release(of);
1151da6c28aaSamw }
1152da6c28aaSamw 
11532c2961f8Sjose borrego void
11542c2961f8Sjose borrego smbsr_lookup_file(smb_request_t *sr)
11552c2961f8Sjose borrego {
11562c2961f8Sjose borrego 	if (sr->fid_ofile == NULL)
11573b13a1efSThomas Keiser 		sr->fid_ofile = smb_ofile_lookup_by_fid(sr, sr->smb_fid);
11582c2961f8Sjose borrego }
11592c2961f8Sjose borrego 
1160da6c28aaSamw static int
1161da6c28aaSamw is_andx_com(unsigned char com)
1162da6c28aaSamw {
1163da6c28aaSamw 	switch (com) {
1164da6c28aaSamw 	case SMB_COM_LOCKING_ANDX:
1165da6c28aaSamw 	case SMB_COM_OPEN_ANDX:
1166da6c28aaSamw 	case SMB_COM_READ_ANDX:
1167da6c28aaSamw 	case SMB_COM_WRITE_ANDX:
1168da6c28aaSamw 	case SMB_COM_SESSION_SETUP_ANDX:
1169da6c28aaSamw 	case SMB_COM_LOGOFF_ANDX:
1170da6c28aaSamw 	case SMB_COM_TREE_CONNECT_ANDX:
1171da6c28aaSamw 	case SMB_COM_NT_CREATE_ANDX:
1172da6c28aaSamw 		return (1);
1173da6c28aaSamw 	}
1174da6c28aaSamw 	return (0);
1175da6c28aaSamw }
1176da6c28aaSamw 
1177da6c28aaSamw /*
1178faa1795aSjb150015  * Invalid command stubs.
1179faa1795aSjb150015  *
1180faa1795aSjb150015  * The Read/Write Block Multiplexed (mpx) protocol is used to maximize
1181faa1795aSjb150015  * performance when reading/writing a large block of data: it can be
1182faa1795aSjb150015  * used in parallel with other client/server operations.  The mpx sub-
1183faa1795aSjb150015  * protocol is not supported because we support only connection oriented
1184faa1795aSjb150015  * transports and NT supports mpx only over connectionless transports.
1185da6c28aaSamw  */
11867b59d02dSjb150015 smb_sdrc_t
1187faa1795aSjb150015 smb_pre_invalid(smb_request_t *sr)
1188da6c28aaSamw {
1189faa1795aSjb150015 	DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr);
1190faa1795aSjb150015 	return (SDRC_SUCCESS);
1191faa1795aSjb150015 }
1192faa1795aSjb150015 
1193faa1795aSjb150015 void
1194faa1795aSjb150015 smb_post_invalid(smb_request_t *sr)
1195faa1795aSjb150015 {
1196faa1795aSjb150015 	DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr);
1197faa1795aSjb150015 }
1198faa1795aSjb150015 
1199faa1795aSjb150015 smb_sdrc_t
1200faa1795aSjb150015 smb_com_invalid(smb_request_t *sr)
1201faa1795aSjb150015 {
1202faa1795aSjb150015 	smb_sdrc_t sdrc;
1203faa1795aSjb150015 
1204faa1795aSjb150015 	switch (sr->smb_com) {
1205faa1795aSjb150015 	case SMB_COM_WRITE_COMPLETE:
1206faa1795aSjb150015 		smbsr_error(sr, 0, ERRSRV, ERRerror);
1207faa1795aSjb150015 		sdrc = SDRC_ERROR;
1208faa1795aSjb150015 		break;
1209faa1795aSjb150015 
1210faa1795aSjb150015 	default:
1211faa1795aSjb150015 		smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED,
1212faa1795aSjb150015 		    ERRDOS, ERROR_INVALID_FUNCTION);
1213faa1795aSjb150015 		sdrc = SDRC_NOT_IMPLEMENTED;
1214faa1795aSjb150015 		break;
1215faa1795aSjb150015 	}
1216faa1795aSjb150015 
1217faa1795aSjb150015 	return (sdrc);
1218da6c28aaSamw }
1219da6c28aaSamw 
1220da6c28aaSamw /*
1221148c5f43SAlan Wright  * smb_dispatch_stats_init
1222da6c28aaSamw  *
1223148c5f43SAlan Wright  * Initializes dispatch statistics.
1224da6c28aaSamw  */
1225da6c28aaSamw void
12268622ec45SGordon Ross smb_dispatch_stats_init(smb_server_t *sv)
1227da6c28aaSamw {
1228*a90cf9f2SGordon Ross 	smb_disp_stats_t *sds = sv->sv_disp_stats1;
12298622ec45SGordon Ross 	smb_kstat_req_t *ksr;
1230faa1795aSjb150015 	int		i;
1231da6c28aaSamw 
1232*a90cf9f2SGordon Ross 	ksr = ((smbsrv_kstats_t *)sv->sv_ksp->ks_data)->ks_reqs1;
12338622ec45SGordon Ross 
1234148c5f43SAlan Wright 	for (i = 0; i < SMB_COM_NUM; i++, ksr++) {
12358622ec45SGordon Ross 		smb_latency_init(&sds[i].sdt_lat);
1236148c5f43SAlan Wright 		(void) strlcpy(ksr->kr_name, smb_disp_table[i].sdt_name,
1237148c5f43SAlan Wright 		    sizeof (ksr->kr_name));
1238da6c28aaSamw 	}
1239da6c28aaSamw }
1240da6c28aaSamw 
1241da6c28aaSamw /*
1242148c5f43SAlan Wright  * smb_dispatch_stats_fini
1243da6c28aaSamw  *
1244148c5f43SAlan Wright  * Frees and destroyes the resources used for statistics.
1245da6c28aaSamw  */
1246da6c28aaSamw void
12478622ec45SGordon Ross smb_dispatch_stats_fini(smb_server_t *sv)
1248da6c28aaSamw {
1249*a90cf9f2SGordon Ross 	smb_disp_stats_t *sds = sv->sv_disp_stats1;
1250148c5f43SAlan Wright 	int	i;
1251148c5f43SAlan Wright 
1252148c5f43SAlan Wright 	for (i = 0; i < SMB_COM_NUM; i++)
12538622ec45SGordon Ross 		smb_latency_destroy(&sds[i].sdt_lat);
1254148c5f43SAlan Wright }
1255148c5f43SAlan Wright 
1256148c5f43SAlan Wright void
12578622ec45SGordon Ross smb_dispatch_stats_update(smb_server_t *sv,
12588622ec45SGordon Ross     smb_kstat_req_t *ksr, int first, int nreq)
1259148c5f43SAlan Wright {
1260*a90cf9f2SGordon Ross 	smb_disp_stats_t *sds = sv->sv_disp_stats1;
1261148c5f43SAlan Wright 	int	i;
1262148c5f43SAlan Wright 	int	last;
1263148c5f43SAlan Wright 
1264148c5f43SAlan Wright 	last = first + nreq - 1;
1265148c5f43SAlan Wright 
1266148c5f43SAlan Wright 	if ((first < SMB_COM_NUM) && (last < SMB_COM_NUM))  {
1267148c5f43SAlan Wright 		for (i = first; i <= last; i++, ksr++) {
12688622ec45SGordon Ross 			ksr->kr_rxb = sds[i].sdt_rxb;
12698622ec45SGordon Ross 			ksr->kr_txb = sds[i].sdt_txb;
12708622ec45SGordon Ross 			mutex_enter(&sds[i].sdt_lat.ly_mutex);
12718622ec45SGordon Ross 			ksr->kr_nreq = sds[i].sdt_lat.ly_a_nreq;
12728622ec45SGordon Ross 			ksr->kr_sum = sds[i].sdt_lat.ly_a_sum;
12738622ec45SGordon Ross 			ksr->kr_a_mean = sds[i].sdt_lat.ly_a_mean;
1274148c5f43SAlan Wright 			ksr->kr_a_stddev =
12758622ec45SGordon Ross 			    sds[i].sdt_lat.ly_a_stddev;
12768622ec45SGordon Ross 			ksr->kr_d_mean = sds[i].sdt_lat.ly_d_mean;
1277148c5f43SAlan Wright 			ksr->kr_d_stddev =
12788622ec45SGordon Ross 			    sds[i].sdt_lat.ly_d_stddev;
12798622ec45SGordon Ross 			sds[i].sdt_lat.ly_d_mean = 0;
12808622ec45SGordon Ross 			sds[i].sdt_lat.ly_d_nreq = 0;
12818622ec45SGordon Ross 			sds[i].sdt_lat.ly_d_stddev = 0;
12828622ec45SGordon Ross 			sds[i].sdt_lat.ly_d_sum = 0;
12838622ec45SGordon Ross 			mutex_exit(&sds[i].sdt_lat.ly_mutex);
1284148c5f43SAlan Wright 		}
1285da6c28aaSamw 	}
1286da6c28aaSamw }
1287