15331Samw /* 25331Samw * CDDL HEADER START 35331Samw * 45331Samw * The contents of this file are subject to the terms of the 55331Samw * Common Development and Distribution License (the "License"). 65331Samw * You may not use this file except in compliance with the License. 75331Samw * 85331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95331Samw * or http://www.opensolaris.org/os/licensing. 105331Samw * See the License for the specific language governing permissions 115331Samw * and limitations under the License. 125331Samw * 135331Samw * When distributing Covered Code, include this CDDL HEADER in each 145331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155331Samw * If applicable, add the following below this CDDL HEADER, with the 165331Samw * fields enclosed by brackets "[]" replaced with your own identifying 175331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 185331Samw * 195331Samw * CDDL HEADER END 205331Samw */ 21*12508Samw@Sun.COM 225331Samw /* 23*12508Samw@Sun.COM * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 245331Samw */ 255331Samw 265331Samw /* 278934SJose.Borrego@Sun.COM * SMB requests. 285331Samw * 295331Samw * Request 305331Samw * Header 315331Samw * Magic 0xFF 'S' 'M' 'B' 325331Samw * smb_com a byte, the "first" command 335331Samw * Error a 4-byte union, ignored in a request 345331Samw * smb_flg a one byte set of eight flags 355331Samw * smb_flg2 a two byte set of 16 flags 365331Samw * . twelve reserved bytes, have a role 375331Samw * in connectionless transports (IPX, UDP?) 385331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 395331Samw * 0xFFFF is this command does not have 405331Samw * or require a tree context 415331Samw * smb_pid a 16-bit process ID 425331Samw * smb_uid a 16-bit user ID, specific to this "session" 435331Samw * and mapped to a system (bona-fide) UID 445331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 455331Samw * multiple simultaneous requests from the same 465331Samw * process (pid) (ref RPC "xid") 475331Samw * 485331Samw * Chained (AndX) commands (0 or more) 495331Samw * smb_wct a byte, number of 16-bit words containing 505331Samw * command parameters, min 2 for chained command 515331Samw * andx_com a byte, the "next" command, 0xFF for none 525331Samw * . an unused byte 535331Samw * andx_off a 16-bit offset, byte displacement from &Magic 545331Samw * to the smb_wct field of the "next" command, 555331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 565331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 575331Samw * "this" command (i.e. smb_com if this is the 585331Samw * first parameters, or the andx_com of the just 595331Samw * previous block. 605331Samw * smb_bcc a 16-bit count of smb_data[] bytes 615331Samw * smb_data[] 0 or more bytes, format specific to commands 625331Samw * padding[] Optional padding 635331Samw * 645331Samw * Last command 655331Samw * smb_wct a byte, number of 16-bit words containing 665331Samw * command parameters, min 0 for chained command 675331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 685331Samw * "this" command (i.e. smb_com if this is the 695331Samw * first parameters, or the andx_com of the just 705331Samw * previous block. 715331Samw * smb_bcc a 16-bit count of smb_data[] bytes 725331Samw * smb_data[] 0 or more bytes, format specific to commands 735331Samw * 745331Samw * Reply 755331Samw * Header 765331Samw * Magic 0xFF 'S' 'M' 'B' 775331Samw * smb_com a byte, the "first" command, corresponds 785331Samw * to request 795331Samw * Error a 4-byte union, coding depends on dialect in use 805331Samw * for "DOS" errors 815331Samw * a byte for error class 825331Samw * an unused byte 835331Samw * a 16-bit word for error code 845331Samw * for "NT" errors 855331Samw * a 32-bit error code which 865331Samw * is a packed class and specifier 875331Samw * for "OS/2" errors 885331Samw * I don't know 895331Samw * The error information is specific to the 905331Samw * last command in the reply chain. 915331Samw * smb_flg a one byte set of eight flags, 0x80 bit set 925331Samw * indicating this message is a reply 935331Samw * smb_flg2 a two byte set of 16 flags 945331Samw * . twelve reserved bytes, have a role 955331Samw * in connectionless transports (IPX, UDP?) 965331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 975331Samw * should be the same as the request 985331Samw * smb_pid a 16-bit process ID, MUST BE the same as request 995331Samw * smb_uid a 16-bit user ID, specific to this "session" 1005331Samw * and mapped to a system (bona-fide) UID, 1015331Samw * should be the same as request 1025331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 1035331Samw * multiple simultaneous requests from the same 1045331Samw * process (pid) (ref RPC "xid"), MUST BE the 1055331Samw * same as request 1065331Samw * padding[] Optional padding 1075331Samw * 1085331Samw * Chained (AndX) commands (0 or more) 1095331Samw * smb_wct a byte, number of 16-bit words containing 1105331Samw * command parameters, min 2 for chained command, 1115331Samw * andx_com a byte, the "next" command, 0xFF for none, 1125331Samw * corresponds to request, if this is the chained 1135331Samw * command that had an error set to 0xFF 1145331Samw * . an unused byte 1155331Samw * andx_off a 16-bit offset, byte displacement from &Magic 1165331Samw * to the smb_wct field of the "next" command, 1175331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 1185331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1195331Samw * "this" command (i.e. smb_com if this is the 1205331Samw * first parameters, or the andx_com of the just 1215331Samw * previous block. Empty if an error. 1225331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1235331Samw * smb_data[] 0 or more bytes, format specific to commands 1245331Samw * empty if an error. 1255331Samw * 1265331Samw * Last command 1275331Samw * smb_wct a byte, number of 16-bit words containing 1285331Samw * command parameters, min 0 for chained command 1295331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1305331Samw * "this" command (i.e. smb_com if this is the 1315331Samw * first parameters, or the andx_com of the just 1325331Samw * previous block, empty if an error. 1335331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1345331Samw * smb_data[] 0 or more bytes, format specific to commands, 1355331Samw * empty if an error. 1365331Samw */ 1375331Samw 13810966SJordan.Brown@Sun.COM #include <smbsrv/smb_kproto.h> 1396432Sas200622 #include <smbsrv/smb_kstat.h> 1405331Samw #include <sys/sdt.h> 141*12508Samw@Sun.COM #include <sys/spl.h> 1425331Samw 1436030Sjb150015 static int is_andx_com(unsigned char); 1446030Sjb150015 static int smbsr_check_result(struct smb_request *, int, int); 1455331Samw 146*12508Samw@Sun.COM static smb_disp_entry_t smb_disp_table[SMB_COM_NUM] = { 147*12508Samw@Sun.COM { "SmbCreateDirectory", SMB_SDT_OPS(create_directory), /* 0x00 000 */ 148*12508Samw@Sun.COM 0x00, PC_NETWORK_PROGRAM_1_0 }, 149*12508Samw@Sun.COM { "SmbDeleteDirectory", SMB_SDT_OPS(delete_directory), /* 0x01 001 */ 150*12508Samw@Sun.COM 0x01, PC_NETWORK_PROGRAM_1_0 }, 151*12508Samw@Sun.COM { "SmbOpen", SMB_SDT_OPS(open), /* 0x02 002 */ 152*12508Samw@Sun.COM 0x02, PC_NETWORK_PROGRAM_1_0 }, 153*12508Samw@Sun.COM { "SmbCreate", SMB_SDT_OPS(create), /* 0x03 003 */ 154*12508Samw@Sun.COM 0x03, PC_NETWORK_PROGRAM_1_0 }, 155*12508Samw@Sun.COM { "SmbClose", SMB_SDT_OPS(close), /* 0x04 004 */ 156*12508Samw@Sun.COM 0x04, PC_NETWORK_PROGRAM_1_0 }, 157*12508Samw@Sun.COM { "SmbFlush", SMB_SDT_OPS(flush), /* 0x05 005 */ 158*12508Samw@Sun.COM 0x05, PC_NETWORK_PROGRAM_1_0 }, 159*12508Samw@Sun.COM { "SmbDelete", SMB_SDT_OPS(delete), /* 0x06 006 */ 160*12508Samw@Sun.COM 0x06, PC_NETWORK_PROGRAM_1_0 }, 161*12508Samw@Sun.COM { "SmbRename", SMB_SDT_OPS(rename), /* 0x07 007 */ 162*12508Samw@Sun.COM 0x07, PC_NETWORK_PROGRAM_1_0 }, 163*12508Samw@Sun.COM { "SmbQueryInformation", SMB_SDT_OPS(query_information), /* 0x08 008 */ 164*12508Samw@Sun.COM 0x08, PC_NETWORK_PROGRAM_1_0 }, 165*12508Samw@Sun.COM { "SmbSetInformation", SMB_SDT_OPS(set_information), /* 0x09 009 */ 166*12508Samw@Sun.COM 0x09, PC_NETWORK_PROGRAM_1_0 }, 167*12508Samw@Sun.COM { "SmbRead", SMB_SDT_OPS(read), /* 0x0A 010 */ 168*12508Samw@Sun.COM 0x0A, PC_NETWORK_PROGRAM_1_0 }, 169*12508Samw@Sun.COM { "SmbWrite", SMB_SDT_OPS(write), /* 0x0B 011 */ 170*12508Samw@Sun.COM 0x0B, PC_NETWORK_PROGRAM_1_0 }, 171*12508Samw@Sun.COM { "SmbLockByteRange", SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */ 172*12508Samw@Sun.COM 0x0C, PC_NETWORK_PROGRAM_1_0 }, 173*12508Samw@Sun.COM { "SmbUnlockByteRange", SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */ 174*12508Samw@Sun.COM 0x0D, PC_NETWORK_PROGRAM_1_0 }, 175*12508Samw@Sun.COM { "SmbCreateTemporary", SMB_SDT_OPS(create_temporary), /* 0x0E 014 */ 176*12508Samw@Sun.COM 0x0E, PC_NETWORK_PROGRAM_1_0 }, 177*12508Samw@Sun.COM { "SmbCreateNew", SMB_SDT_OPS(create_new), /* 0x0F 015 */ 178*12508Samw@Sun.COM 0x0F, PC_NETWORK_PROGRAM_1_0 }, 179*12508Samw@Sun.COM { "SmbCheckDirectory", SMB_SDT_OPS(check_directory), /* 0x10 016 */ 180*12508Samw@Sun.COM 0x10, PC_NETWORK_PROGRAM_1_0 }, 181*12508Samw@Sun.COM { "SmbProcessExit", SMB_SDT_OPS(process_exit), /* 0x11 017 */ 182*12508Samw@Sun.COM 0x11, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 183*12508Samw@Sun.COM 0, 0, { 0 } }, 184*12508Samw@Sun.COM { "SmbSeek", SMB_SDT_OPS(seek), /* 0x12 018 */ 185*12508Samw@Sun.COM 0x12, PC_NETWORK_PROGRAM_1_0 }, 186*12508Samw@Sun.COM { "SmbLockAndRead", SMB_SDT_OPS(lock_and_read), /* 0x13 019 */ 187*12508Samw@Sun.COM 0x13, LANMAN1_0 }, 188*12508Samw@Sun.COM { "SmbWriteAndUnlock", SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */ 189*12508Samw@Sun.COM 0x14, LANMAN1_0 }, 190*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x15, 0 }, /* 0x15 021 */ 191*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x16, 0 }, /* 0x16 022 */ 192*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x17, 0 }, /* 0x17 023 */ 193*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x18, 0 }, /* 0x18 024 */ 194*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x19, 0 }, /* 0x19 025 */ 195*12508Samw@Sun.COM { "SmbReadRaw", SMB_SDT_OPS(read_raw), /* 0x1A 026 */ 196*12508Samw@Sun.COM 0x1A, LANMAN1_0 }, 197*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x1B, 0 }, /* 0x1B 027 */ 198*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x1C, 0 }, /* 0x1C 028 */ 199*12508Samw@Sun.COM { "SmbWriteRaw", SMB_SDT_OPS(write_raw), /* 0x1D 029 */ 200*12508Samw@Sun.COM 0x1D, LANMAN1_0 }, 201*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x1E, 0 }, /* 0x1E 030 */ 202*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x1F, 0 }, /* 0x1F 031 */ 203*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x20, 0 }, /* 0x20 032 */ 204*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x21, 0 }, /* 0x21 033 */ 205*12508Samw@Sun.COM { "SmbSetInformation2", SMB_SDT_OPS(set_information2), /* 0x22 034 */ 206*12508Samw@Sun.COM 0x22, LANMAN1_0 }, 207*12508Samw@Sun.COM { "SmbQueryInformation2", 208*12508Samw@Sun.COM SMB_SDT_OPS(query_information2), /* 0x23 035 */ 209*12508Samw@Sun.COM 0x23, LANMAN1_0 }, 210*12508Samw@Sun.COM { "SmbLockingX", SMB_SDT_OPS(locking_andx), /* 0x24 036 */ 211*12508Samw@Sun.COM 0x24, LANMAN1_0 }, 212*12508Samw@Sun.COM { "SmbTransaction", SMB_SDT_OPS(transaction), /* 0x25 037 */ 213*12508Samw@Sun.COM 0x25, LANMAN1_0 }, 214*12508Samw@Sun.COM { "SmbTransactionSecondary", 215*12508Samw@Sun.COM SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */ 216*12508Samw@Sun.COM 0x26, LANMAN1_0 }, 217*12508Samw@Sun.COM { "SmbIoctl", SMB_SDT_OPS(ioctl), /* 0x27 039 */ 218*12508Samw@Sun.COM 0x27, LANMAN1_0 }, 219*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x28, 0 }, /* 0x28 040 */ 220*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x29, 0 }, /* 0x29 041 */ 221*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x2A, 0 }, /* 0x2A 042 */ 222*12508Samw@Sun.COM { "SmbEcho", SMB_SDT_OPS(echo), /* 0x2B 043 */ 223*12508Samw@Sun.COM 0x2B, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID }, 224*12508Samw@Sun.COM { "SmbWriteAndClose", SMB_SDT_OPS(write_and_close), /* 0x2C 044 */ 225*12508Samw@Sun.COM 0x2C, LANMAN1_0 }, 226*12508Samw@Sun.COM { "SmbOpenX", SMB_SDT_OPS(open_andx), /* 0x2D 045 */ 227*12508Samw@Sun.COM 0x2D, LANMAN1_0 }, 228*12508Samw@Sun.COM { "SmbReadX", SMB_SDT_OPS(read_andx), /* 0x2E 046 */ 229*12508Samw@Sun.COM 0x2E, LANMAN1_0 }, 230*12508Samw@Sun.COM { "SmbWriteX", SMB_SDT_OPS(write_andx), /* 0x2F 047 */ 231*12508Samw@Sun.COM 0x2F, LANMAN1_0 }, 232*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x30, 0 }, /* 0x30 048 */ 233*12508Samw@Sun.COM { "SmbCloseAndTreeDisconnect", 234*12508Samw@Sun.COM SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */ 235*12508Samw@Sun.COM 0x31, LANMAN1_0 }, 236*12508Samw@Sun.COM { "SmbTransaction2", SMB_SDT_OPS(transaction2), /* 0x32 050 */ 237*12508Samw@Sun.COM 0x32, LM1_2X002 }, 238*12508Samw@Sun.COM { "SmbTransaction2Secondary", 239*12508Samw@Sun.COM SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */ 240*12508Samw@Sun.COM 0x33, LM1_2X002 }, 241*12508Samw@Sun.COM { "SmbFindClose2", SMB_SDT_OPS(find_close2), /* 0x34 052 */ 242*12508Samw@Sun.COM 0x34, LM1_2X002 }, 243*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x35, 0 }, /* 0x35 053 */ 244*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x36, 0 }, /* 0x36 054 */ 245*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x37, 0 }, /* 0x37 055 */ 246*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x38, 0 }, /* 0x38 056 */ 247*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x39, 0 }, /* 0x39 057 */ 248*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3A, 0 }, /* 0x3A 058 */ 249*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3B, 0 }, /* 0x3B 059 */ 250*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3C, 0 }, /* 0x3C 060 */ 251*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3D, 0 }, /* 0x3D 061 */ 252*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3E, 0 }, /* 0x3E 062 */ 253*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x3F, 0 }, /* 0x3F 063 */ 254*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x40, 0 }, /* 0x40 064 */ 255*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 065 */ 256*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 066 */ 257*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 067 */ 258*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x44, 0 }, /* 0x44 068 */ 259*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x45, 0 }, /* 0x45 069 */ 260*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x46, 0 }, /* 0x46 070 */ 261*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 071 */ 262*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 072 */ 263*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 073 */ 264*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4A, 0 }, /* 0x4A 074 */ 265*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4B, 0 }, /* 0x4B 075 */ 266*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4C, 0 }, /* 0x4C 076 */ 267*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4D, 0 }, /* 0x4D 077 */ 268*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4E, 0 }, /* 0x4E 078 */ 269*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x4F, 0 }, /* 0x4F 079 */ 270*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x50, 0 }, /* 0x50 080 */ 271*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x51, 0 }, /* 0x51 081 */ 272*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x52, 0 }, /* 0x52 082 */ 273*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x53, 0 }, /* 0x53 083 */ 274*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x54, 0 }, /* 0x54 084 */ 275*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x55, 0 }, /* 0x55 085 */ 276*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x56, 0 }, /* 0x56 086 */ 277*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x57, 0 }, /* 0x57 087 */ 278*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x58, 0 }, /* 0x58 088 */ 279*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x59, 0 }, /* 0x59 089 */ 280*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5A, 0 }, /* 0x5A 090 */ 281*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5B, 0 }, /* 0x5B 091 */ 282*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5C, 0 }, /* 0x5C 092 */ 283*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5D, 0 }, /* 0x5D 093 */ 284*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5E, 0 }, /* 0x5E 094 */ 285*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x5F, 0 }, /* 0x5F 095 */ 286*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x60, 0 }, /* 0x60 096 */ 287*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x61, 0 }, /* 0x61 097 */ 288*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x62, 0 }, /* 0x62 098 */ 289*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x63, 0 }, /* 0x63 099 */ 290*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x64, 0 }, /* 0x64 100 */ 291*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x65, 0 }, /* 0x65 101 */ 292*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x66, 0 }, /* 0x66 102 */ 293*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x67, 0 }, /* 0x67 103 */ 294*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x68, 0 }, /* 0x68 104 */ 295*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x69, 0 }, /* 0x69 105 */ 296*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6A, 0 }, /* 0x6A 106 */ 297*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6B, 0 }, /* 0x6B 107 */ 298*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6C, 0 }, /* 0x6C 108 */ 299*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6D, 0 }, /* 0x6D 109 */ 300*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6E, 0 }, /* 0x6E 110 */ 301*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x6F, 0 }, /* 0x6F 111 */ 302*12508Samw@Sun.COM { "SmbTreeConnect", SMB_SDT_OPS(tree_connect), /* 0x70 112 */ 303*12508Samw@Sun.COM 0x70, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID }, 304*12508Samw@Sun.COM { "SmbTreeDisconnect", SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */ 305*12508Samw@Sun.COM 0x71, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 306*12508Samw@Sun.COM NULL }, 307*12508Samw@Sun.COM { "SmbNegotiate", SMB_SDT_OPS(negotiate), /* 0x72 114 */ 308*12508Samw@Sun.COM 0x72, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 309*12508Samw@Sun.COM NULL }, 310*12508Samw@Sun.COM { "SmbSessionSetupX", SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */ 311*12508Samw@Sun.COM 0x73, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID }, 312*12508Samw@Sun.COM { "SmbLogoffX", SMB_SDT_OPS(logoff_andx), /* 0x74 116 */ 313*12508Samw@Sun.COM 0x74, LM1_2X002, SDDF_SUPPRESS_TID }, 314*12508Samw@Sun.COM { "SmbTreeConnectX", SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */ 315*12508Samw@Sun.COM 0x75, LANMAN1_0, SDDF_SUPPRESS_TID }, 316*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x76, 0, 0 }, /* 0x76 118 */ 317*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x77, 0, 0 }, /* 0x77 119 */ 318*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x78, 0, 0 }, /* 0x78 120 */ 319*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x79, 0, 0 }, /* 0x79 121 */ 320*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7A, 0, 0 }, /* 0x7A 122 */ 321*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7B, 0, 0 }, /* 0x7B 123 */ 322*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7C, 0, 0 }, /* 0x7C 124 */ 323*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7D, 0, 0 }, /* 0x7D 125 */ 324*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7E, 0, 0 }, /* 0x7E 126 */ 325*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x7F, 0, 0 }, /* 0x7F 127 */ 326*12508Samw@Sun.COM { "SmbQueryInformationDisk", 327*12508Samw@Sun.COM SMB_SDT_OPS(query_information_disk), /* 0x80 128 */ 328*12508Samw@Sun.COM 0x80, PC_NETWORK_PROGRAM_1_0, 0 }, 329*12508Samw@Sun.COM { "SmbSearch", SMB_SDT_OPS(search), /* 0x81 129 */ 330*12508Samw@Sun.COM 0x81, PC_NETWORK_PROGRAM_1_0, 0 }, 331*12508Samw@Sun.COM { "SmbFind", SMB_SDT_OPS(find), /* 0x82 130 */ 332*12508Samw@Sun.COM 0x82, LANMAN1_0, 0 }, 333*12508Samw@Sun.COM { "SmbFindUnique", SMB_SDT_OPS(find_unique), /* 0x83 131 */ 334*12508Samw@Sun.COM 0x83, LANMAN1_0, 0 }, 335*12508Samw@Sun.COM { "SmbFindClose", SMB_SDT_OPS(find_close), /* 0x84 132 */ 336*12508Samw@Sun.COM 0x84, LANMAN1_0, 0 }, 337*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x85, 0, 0 }, /* 0x85 133 */ 338*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x86, 0, 0 }, /* 0x86 134 */ 339*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x87, 0, 0 }, /* 0x87 135 */ 340*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x88, 0, 0 }, /* 0x88 136 */ 341*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x89, 0, 0 }, /* 0x89 137 */ 342*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8A, 0, 0 }, /* 0x8A 138 */ 343*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8B, 0, 0 }, /* 0x8B 139 */ 344*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8C, 0, 0 }, /* 0x8C 140 */ 345*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8D, 0, 0 }, /* 0x8D 141 */ 346*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8E, 0, 0 }, /* 0x8E 142 */ 347*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x8F, 0, 0 }, /* 0x8F 143 */ 348*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x90, 0, 0 }, /* 0x90 144 */ 349*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x91, 0, 0 }, /* 0x91 145 */ 350*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x92, 0, 0 }, /* 0x92 146 */ 351*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x93, 0, 0 }, /* 0x93 147 */ 352*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x94, 0, 0 }, /* 0x94 148 */ 353*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x95, 0, 0 }, /* 0x95 149 */ 354*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x96, 0, 0 }, /* 0x96 150 */ 355*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x97, 0, 0 }, /* 0x97 151 */ 356*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x98, 0, 0 }, /* 0x98 152 */ 357*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x99, 0, 0 }, /* 0x99 153 */ 358*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9A, 0, 0 }, /* 0x9A 154 */ 359*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9B, 0, 0 }, /* 0x9B 155 */ 360*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9C, 0, 0 }, /* 0x9C 156 */ 361*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9D, 0, 0 }, /* 0x9D 157 */ 362*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9E, 0, 0 }, /* 0x9E 158 */ 363*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0x9F, 0, 0 }, /* 0x9F 159 */ 364*12508Samw@Sun.COM { "SmbNtTransact", SMB_SDT_OPS(nt_transact), /* 0xA0 160 */ 365*12508Samw@Sun.COM 0xA0, NT_LM_0_12, 0 }, 366*12508Samw@Sun.COM { "SmbNtTransactSecondary", 367*12508Samw@Sun.COM SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */ 368*12508Samw@Sun.COM 0xA1, NT_LM_0_12, 0 }, 369*12508Samw@Sun.COM { "SmbNtCreateX", SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */ 370*12508Samw@Sun.COM 0xA2, NT_LM_0_12, 0 }, 371*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xA3, 0, 0 }, /* 0xA3 163 */ 372*12508Samw@Sun.COM { "SmbNtCancel", SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */ 373*12508Samw@Sun.COM 0xA4, NT_LM_0_12, 0 }, 374*12508Samw@Sun.COM { "SmbNtRename", SMB_SDT_OPS(nt_rename), /* 0xA5 165 */ 375*12508Samw@Sun.COM 0xA5, NT_LM_0_12, 0 }, 376*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xA6, 0, 0 }, /* 0xA6 166 */ 377*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xA7, 0, 0 }, /* 0xA7 167 */ 378*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xA8, 0, 0 }, /* 0xA8 168 */ 379*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xA9, 0, 0 }, /* 0xA9 169 */ 380*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAA, 0, 0 }, /* 0xAA 170 */ 381*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAB, 0, 0 }, /* 0xAB 171 */ 382*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAC, 0, 0 }, /* 0xAC 172 */ 383*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAD, 0, 0 }, /* 0xAD 173 */ 384*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAE, 0, 0 }, /* 0xAE 174 */ 385*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xAF, 0, 0 }, /* 0xAF 175 */ 386*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB0, 0, 0 }, /* 0xB0 176 */ 387*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB1, 0, 0 }, /* 0xB1 177 */ 388*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB2, 0, 0 }, /* 0xB2 178 */ 389*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB3, 0, 0 }, /* 0xB3 179 */ 390*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB4, 0, 0 }, /* 0xB4 180 */ 391*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB5, 0, 0 }, /* 0xB5 181 */ 392*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB6, 0, 0 }, /* 0xB6 182 */ 393*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB7, 0, 0 }, /* 0xB7 183 */ 394*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB8, 0, 0 }, /* 0xB8 184 */ 395*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xB9, 0, 0 }, /* 0xB9 185 */ 396*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBA, 0, 0 }, /* 0xBA 186 */ 397*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBB, 0, 0 }, /* 0xBB 187 */ 398*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBC, 0, 0 }, /* 0xBC 188 */ 399*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBD, 0, 0 }, /* 0xBD 189 */ 400*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBE, 0, 0 }, /* 0xBE 190 */ 401*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xBF, 0, 0 }, /* 0xBF 191 */ 402*12508Samw@Sun.COM { "SmbOpenPrintFile", SMB_SDT_OPS(open_print_file), /* 0xC0 192 */ 403*12508Samw@Sun.COM 0xC0, PC_NETWORK_PROGRAM_1_0, 0 }, 404*12508Samw@Sun.COM { "SmbWritePrintFile", SMB_SDT_OPS(write_print_file), /* 0xC1 193 */ 405*12508Samw@Sun.COM 0xC1, PC_NETWORK_PROGRAM_1_0, 0 }, 406*12508Samw@Sun.COM { "SmbClosePrintFile", SMB_SDT_OPS(close_print_file), /* 0xC2 194 */ 407*12508Samw@Sun.COM 0xC2, PC_NETWORK_PROGRAM_1_0, 0 }, 408*12508Samw@Sun.COM { "SmbGetPrintQueue", SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */ 409*12508Samw@Sun.COM 0xC3, PC_NETWORK_PROGRAM_1_0, 0 }, 410*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC4, 0, 0 }, /* 0xC4 196 */ 411*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC5, 0, 0 }, /* 0xC5 197 */ 412*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC6, 0, 0 }, /* 0xC6 198 */ 413*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC7, 0, 0 }, /* 0xC7 199 */ 414*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC8, 0, 0 }, /* 0xC8 200 */ 415*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xC9, 0, 0 }, /* 0xC9 201 */ 416*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCA, 0, 0 }, /* 0xCA 202 */ 417*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCB, 0, 0 }, /* 0xCB 203 */ 418*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCC, 0, 0 }, /* 0xCC 204 */ 419*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCD, 0, 0 }, /* 0xCD 205 */ 420*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCE, 0, 0 }, /* 0xCE 206 */ 421*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xCF, 0, 0 }, /* 0xCF 207 */ 422*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD0, 0, 0 }, /* 0xD0 208 */ 423*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD1, 0, 0 }, /* 0xD1 209 */ 424*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD2, 0, 0 }, /* 0xD2 210 */ 425*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD3, 0, 0 }, /* 0xD3 211 */ 426*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD4, 0, 0 }, /* 0xD4 212 */ 427*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD5, 0, 0 }, /* 0xD5 213 */ 428*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD6, 0, 0 }, /* 0xD6 214 */ 429*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD7, 0, 0 }, /* 0xD7 215 */ 430*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD8, 0, 0 }, /* 0xD8 216 */ 431*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xD9, 0, 0 }, /* 0xD9 217 */ 432*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDA, 0, 0 }, /* 0xDA 218 */ 433*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDB, 0, 0 }, /* 0xDB 219 */ 434*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDC, 0, 0 }, /* 0xDC 220 */ 435*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDD, 0, 0 }, /* 0xDD 221 */ 436*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDE, 0, 0 }, /* 0xDE 222 */ 437*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xDF, 0, 0 }, /* 0xDF 223 */ 438*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE0, 0, 0 }, /* 0xE0 224 */ 439*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE1, 0, 0 }, /* 0xE1 225 */ 440*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE2, 0, 0 }, /* 0xE2 226 */ 441*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE3, 0, 0 }, /* 0xE3 227 */ 442*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE4, 0, 0 }, /* 0xE4 228 */ 443*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE5, 0, 0 }, /* 0xE5 229 */ 444*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE6, 0, 0 }, /* 0xE6 230 */ 445*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE7, 0, 0 }, /* 0xE7 231 */ 446*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE8, 0, 0 }, /* 0xE8 232 */ 447*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xE9, 0, 0 }, /* 0xE9 233 */ 448*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xEA, 0, 0 }, /* 0xEA 234 */ 449*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xEB, 0, 0 }, /* 0xEB 235 */ 450*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xEC, 0, 0 }, /* 0xEC 236 */ 451*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xED, 0, 0 }, /* 0xED 237 */ 452*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xEE, 0, 0 }, /* 0xEE 238 */ 453*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xEF, 0, 0 }, /* 0xEF 239 */ 454*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF0, 0, 0 }, /* 0xF0 240 */ 455*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF1, 0, 0 }, /* 0xF1 241 */ 456*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF2, 0, 0 }, /* 0xF2 242 */ 457*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF3, 0, 0 }, /* 0xF3 243 */ 458*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF4, 0, 0 }, /* 0xF4 244 */ 459*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF5, 0, 0 }, /* 0xF5 245 */ 460*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF6, 0, 0 }, /* 0xF6 246 */ 461*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF7, 0, 0 }, /* 0xF7 247 */ 462*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF8, 0, 0 }, /* 0xF8 248 */ 463*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xF9, 0, 0 }, /* 0xF9 249 */ 464*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFA, 0, 0 }, /* 0xFA 250 */ 465*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFB, 0, 0 }, /* 0xFB 251 */ 466*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFC, 0, 0 }, /* 0xFC 252 */ 467*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFD, 0, 0 }, /* 0xFD 253 */ 468*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFE, 0, 0 }, /* 0xFE 254 */ 469*12508Samw@Sun.COM { "Invalid", SMB_SDT_OPS(invalid), 0xFF, 0, 0 } /* 0xFF 255 */ 4705331Samw }; 4715331Samw 4725331Samw /* 4735331Samw * smbsr_cleanup 4745331Samw * 4755331Samw * If any user/tree/file is used by given request then 4765331Samw * the reference count for that resource has been incremented. 4775331Samw * This function decrements the reference count and close 4785331Samw * the resource if it's needed. 4795331Samw */ 4805331Samw 4815331Samw void 4826139Sjb150015 smbsr_cleanup(smb_request_t *sr) 4835331Samw { 4845331Samw ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) && 4855331Samw (sr->sr_state != SMB_REQ_STATE_COMPLETED)); 4865331Samw 4875331Samw if (sr->r_xa) { 4885331Samw if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE) 4895331Samw smb_xa_close(sr->r_xa); 4905331Samw smb_xa_rele(sr->session, sr->r_xa); 4915331Samw sr->r_xa = NULL; 4925331Samw } 4935331Samw 4945331Samw /* 4955331Samw * Mark this request so we know that we've already cleaned it up. 4965331Samw * A request should only get cleaned up once so multiple calls to 4975331Samw * smbsr_cleanup for the same request indicate a bug. 4985331Samw */ 4995331Samw mutex_enter(&sr->sr_mutex); 5005331Samw if (sr->sr_state != SMB_REQ_STATE_CANCELED) 5015331Samw sr->sr_state = SMB_REQ_STATE_CLEANED_UP; 5025331Samw mutex_exit(&sr->sr_mutex); 5035331Samw } 5048262SJose.Borrego@Sun.COM /* 5058262SJose.Borrego@Sun.COM * smb_dispatch_request 5068262SJose.Borrego@Sun.COM * 5078262SJose.Borrego@Sun.COM * Returns: 5088262SJose.Borrego@Sun.COM * 5098262SJose.Borrego@Sun.COM * B_TRUE The caller must free the smb request passed in. 5108262SJose.Borrego@Sun.COM * B_FALSE The caller must not access the smb request passed in. It has 5118262SJose.Borrego@Sun.COM * been kept in an internal queue and may have already been freed. 5128262SJose.Borrego@Sun.COM */ 5138262SJose.Borrego@Sun.COM boolean_t 5145331Samw smb_dispatch_request(struct smb_request *sr) 5155331Samw { 5166030Sjb150015 smb_sdrc_t sdrc; 5178934SJose.Borrego@Sun.COM smb_disp_entry_t *sdd; 5186030Sjb150015 boolean_t disconnect = B_FALSE; 5198262SJose.Borrego@Sun.COM smb_session_t *session; 5208934SJose.Borrego@Sun.COM uint32_t capabilities; 5218934SJose.Borrego@Sun.COM uint32_t byte_count; 5228262SJose.Borrego@Sun.COM 5238262SJose.Borrego@Sun.COM session = sr->session; 5248934SJose.Borrego@Sun.COM capabilities = session->capabilities; 5255331Samw 5265331Samw ASSERT(sr->tid_tree == 0); 5275331Samw ASSERT(sr->uid_user == 0); 5285331Samw ASSERT(sr->fid_ofile == 0); 5295331Samw sr->smb_fid = (uint16_t)-1; 5305331Samw 5315331Samw /* temporary until we identify a user */ 5325331Samw sr->user_cr = kcred; 5335331Samw sr->orig_request_hdr = sr->command.chain_offset; 5345331Samw 5355331Samw /* If this connection is shutting down just kill request */ 5367052Samw if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT, 5375331Samw &sr->smb_com, 5385331Samw &sr->smb_rcls, 5395331Samw &sr->smb_reh, 5405331Samw &sr->smb_err, 5415331Samw &sr->smb_flg, 5425331Samw &sr->smb_flg2, 5435331Samw &sr->smb_pid_high, 5445331Samw sr->smb_sig, 5455331Samw &sr->smb_tid, 5465331Samw &sr->smb_pid, 5475331Samw &sr->smb_uid, 5485331Samw &sr->smb_mid) != 0) { 5496030Sjb150015 disconnect = B_TRUE; 5506030Sjb150015 goto drop_connection; 5515331Samw } 5525331Samw 5535331Samw /* 5546030Sjb150015 * The reply "header" is filled in now even though it will, 5556030Sjb150015 * most likely, be rewritten under reply_ready below. We 5566030Sjb150015 * could reserve the space but this is convenient in case 5576030Sjb150015 * the dialect dispatcher has to send a special reply (like 5586030Sjb150015 * TRANSACT). 5595331Samw * 5605331Samw * Ensure that the 32-bit error code flag is turned off. 5615331Samw * Clients seem to set it in transact requests and they may 5625331Samw * get confused if we return success or a 16-bit SMB code. 5635331Samw */ 5645331Samw sr->smb_rcls = 0; 5655331Samw sr->smb_reh = 0; 5665331Samw sr->smb_err = 0; 5675331Samw sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS; 5685331Samw 5697052Samw (void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT, 5705331Samw sr->smb_com, 5715331Samw sr->smb_rcls, 5725331Samw sr->smb_reh, 5735331Samw sr->smb_err, 5745331Samw sr->smb_flg, 5755331Samw sr->smb_flg2, 5765331Samw sr->smb_pid_high, 5775331Samw sr->smb_sig, 5785331Samw sr->smb_tid, 5795331Samw sr->smb_pid, 5805331Samw sr->smb_uid, 5815331Samw sr->smb_mid); 5825331Samw sr->first_smb_com = sr->smb_com; 5835331Samw 5845331Samw /* 5855772Sas200622 * Verify SMB signature if signing is enabled, dialect is NT LM 0.12, 5865331Samw * signing was negotiated and authentication has occurred. 5875331Samw */ 5888262SJose.Borrego@Sun.COM if (session->signing.flags & SMB_SIGNING_ENABLED) { 5895331Samw if (smb_sign_check_request(sr) != 0) { 5906030Sjb150015 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 5916030Sjb150015 ERRDOS, ERROR_ACCESS_DENIED); 5926030Sjb150015 disconnect = B_TRUE; 5936030Sjb150015 goto report_error; 5945331Samw } 5955331Samw } 5965331Samw 5975331Samw andx_more: 598*12508Samw@Sun.COM sdd = &smb_disp_table[sr->smb_com]; 5996139Sjb150015 ASSERT(sdd->sdt_function); 6005331Samw 6017052Samw if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) { 6026030Sjb150015 disconnect = B_TRUE; 6036030Sjb150015 goto report_error; 6045331Samw } 6055331Samw 6065331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command, 6075331Samw sr->command.chain_offset, sr->smb_wct * 2); 6085331Samw 6097052Samw if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) { 6106030Sjb150015 disconnect = B_TRUE; 6116030Sjb150015 goto report_error; 6125331Samw } 6135331Samw 614*12508Samw@Sun.COM atomic_add_64(&sdd->sdt_rxb, 615*12508Samw@Sun.COM (int64_t)(sr->smb_wct * 2 + sr->smb_bcc + 1)); 616*12508Samw@Sun.COM sr->sr_txb = sr->reply.chain_offset; 617*12508Samw@Sun.COM 6188934SJose.Borrego@Sun.COM /* 6198934SJose.Borrego@Sun.COM * Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX 6208934SJose.Borrego@Sun.COM * and this is SmbReadX/SmbWriteX since this enables 6218934SJose.Borrego@Sun.COM * large reads/write and bcc is only 16-bits. 6228934SJose.Borrego@Sun.COM */ 6238934SJose.Borrego@Sun.COM if (((sr->smb_com == SMB_COM_READ_ANDX) && 6248934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_READX)) || 6258934SJose.Borrego@Sun.COM ((sr->smb_com == SMB_COM_WRITE_ANDX) && 6268934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_WRITEX))) { 6278934SJose.Borrego@Sun.COM byte_count = sr->command.max_bytes - sr->command.chain_offset; 6288934SJose.Borrego@Sun.COM } else { 6298934SJose.Borrego@Sun.COM byte_count = (uint32_t)sr->smb_bcc; 6308934SJose.Borrego@Sun.COM } 6318934SJose.Borrego@Sun.COM 6325331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command, 6338934SJose.Borrego@Sun.COM sr->command.chain_offset, byte_count); 6345331Samw 6358934SJose.Borrego@Sun.COM sr->command.chain_offset += byte_count; 6365331Samw if (sr->command.chain_offset > sr->command.max_bytes) { 6376030Sjb150015 disconnect = B_TRUE; 6386030Sjb150015 goto report_error; 6395331Samw } 6405331Samw 6415331Samw /* Store pointers for later */ 6425331Samw sr->cur_reply_offset = sr->reply.chain_offset; 6435331Samw 6445331Samw if (is_andx_com(sr->smb_com)) { 6455331Samw /* Peek ahead and don't disturb vwv */ 6467052Samw if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w", 6475331Samw &sr->andx_com, &sr->andx_off) < 0) { 6486030Sjb150015 disconnect = B_TRUE; 6496030Sjb150015 goto report_error; 6505331Samw } 6515331Samw } else { 6525331Samw sr->andx_com = (unsigned char)-1; 6535331Samw } 6545331Samw 6555331Samw mutex_enter(&sr->sr_mutex); 6565331Samw switch (sr->sr_state) { 6575331Samw case SMB_REQ_STATE_SUBMITTED: 6585331Samw case SMB_REQ_STATE_CLEANED_UP: 6595331Samw sr->sr_state = SMB_REQ_STATE_ACTIVE; 6605331Samw break; 6615331Samw case SMB_REQ_STATE_CANCELED: 6625331Samw break; 6635331Samw default: 6645331Samw ASSERT(0); 6655331Samw break; 6665331Samw } 6675331Samw mutex_exit(&sr->sr_mutex); 6685331Samw 6696030Sjb150015 /* 6706030Sjb150015 * Setup UID and TID information (if required). Both functions 6716030Sjb150015 * will set the sr credentials. In domain mode, the user and 6726030Sjb150015 * tree credentials should be the same. In share mode, the 6736030Sjb150015 * tree credentials (defined in the share definition) should 6746030Sjb150015 * override the user credentials. 6756030Sjb150015 */ 6766139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) { 67711963SAfshin.Ardakani@Sun.COM sr->uid_user = smb_session_lookup_uid(session, sr->smb_uid); 6786030Sjb150015 if (sr->uid_user == NULL) { 6796030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRbaduid); 6806139Sjb150015 smbsr_cleanup(sr); 6816030Sjb150015 goto report_error; 6825331Samw } 6835331Samw 6847961SNatalie.Li@Sun.COM sr->user_cr = smb_user_getcred(sr->uid_user); 6857961SNatalie.Li@Sun.COM 6866139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && 6876139Sjb150015 (sr->tid_tree == NULL)) { 6887348SJose.Borrego@Sun.COM sr->tid_tree = smb_user_lookup_tree( 6896030Sjb150015 sr->uid_user, sr->smb_tid); 6906030Sjb150015 if (sr->tid_tree == NULL) { 6916030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRinvnid); 6926139Sjb150015 smbsr_cleanup(sr); 6936030Sjb150015 goto report_error; 6945331Samw } 6955331Samw } 6965331Samw } 6975331Samw 6986030Sjb150015 /* 6996030Sjb150015 * If the command is not a read raw request we can set the 7006030Sjb150015 * state of the session back to SMB_SESSION_STATE_NEGOTIATED 7016030Sjb150015 * (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING). 7026030Sjb150015 * Otherwise we let the read raw handler to deal with it. 7036030Sjb150015 */ 7049343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_READER); 7058262SJose.Borrego@Sun.COM if ((session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) && 7066030Sjb150015 (sr->smb_com != SMB_COM_READ_RAW)) { 7079343SAfshin.Ardakani@Sun.COM (void) smb_rwx_rwupgrade(&session->s_lock); 7088262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) 7098262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7106030Sjb150015 } 7119343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 7126030Sjb150015 713*12508Samw@Sun.COM sr->sr_time_start = gethrtime(); 7146139Sjb150015 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS) 7156139Sjb150015 sdrc = (*sdd->sdt_function)(sr); 7166139Sjb150015 7179343SAfshin.Ardakani@Sun.COM if (sdrc != SDRC_SR_KEPT) { 7189343SAfshin.Ardakani@Sun.COM (*sdd->sdt_post_op)(sr); 7199343SAfshin.Ardakani@Sun.COM smbsr_cleanup(sr); 7209343SAfshin.Ardakani@Sun.COM } 721*12508Samw@Sun.COM smb_latency_add_sample(&sdd->sdt_lat, gethrtime() - sr->sr_time_start); 722*12508Samw@Sun.COM 723*12508Samw@Sun.COM atomic_add_64(&sdd->sdt_txb, 724*12508Samw@Sun.COM (int64_t)(sr->reply.chain_offset - sr->sr_txb)); 7259343SAfshin.Ardakani@Sun.COM 7266139Sjb150015 if (sdrc != SDRC_SUCCESS) { 7276030Sjb150015 /* 7286030Sjb150015 * Handle errors from raw write. 7296030Sjb150015 */ 7309343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_WRITER); 7318262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_WRITE_RAW_ACTIVE) { 7326030Sjb150015 /* 7336030Sjb150015 * Set state so that the netbios session 7346030Sjb150015 * daemon will start accepting data again. 7356030Sjb150015 */ 7368262SJose.Borrego@Sun.COM session->s_write_raw_status = 0; 7378262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7386030Sjb150015 } 7399343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 7408262SJose.Borrego@Sun.COM } 7416030Sjb150015 7426030Sjb150015 switch (sdrc) { 7436139Sjb150015 case SDRC_SUCCESS: 7446030Sjb150015 break; 7456030Sjb150015 7466030Sjb150015 case SDRC_DROP_VC: 7476030Sjb150015 disconnect = B_TRUE; 7486030Sjb150015 goto drop_connection; 7496030Sjb150015 7506030Sjb150015 case SDRC_NO_REPLY: 7518262SJose.Borrego@Sun.COM return (B_TRUE); 7528262SJose.Borrego@Sun.COM 7538262SJose.Borrego@Sun.COM case SDRC_SR_KEPT: 7548262SJose.Borrego@Sun.COM return (B_FALSE); 7556030Sjb150015 7566139Sjb150015 case SDRC_ERROR: 7576030Sjb150015 goto report_error; 7586030Sjb150015 7596139Sjb150015 case SDRC_NOT_IMPLEMENTED: 7606030Sjb150015 default: 7616030Sjb150015 smbsr_error(sr, 0, ERRDOS, ERRbadfunc); 7626030Sjb150015 goto report_error; 7636030Sjb150015 } 7646030Sjb150015 7656030Sjb150015 /* 7666030Sjb150015 * If there's no AndX command, we're done. 7676030Sjb150015 */ 7685331Samw if (sr->andx_com == 0xff) 7695331Samw goto reply_ready; 7705331Samw 7716030Sjb150015 /* 7726030Sjb150015 * Otherwise, we have to back-patch the AndXCommand and AndXOffset 7736030Sjb150015 * and continue processing. 7746030Sjb150015 */ 7755331Samw sr->andx_prev_wct = sr->cur_reply_offset; 7767052Samw (void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w", 7775331Samw sr->andx_com, MBC_LENGTH(&sr->reply)); 7785331Samw 7795331Samw sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off; 7805331Samw sr->smb_com = sr->andx_com; 7815331Samw goto andx_more; 7825331Samw 7836030Sjb150015 report_error: 7845331Samw sr->reply.chain_offset = sr->cur_reply_offset; 7857052Samw (void) smb_mbc_encodef(&sr->reply, "bw", 0, 0); 7865331Samw 7875331Samw sr->smb_wct = 0; 7885331Samw sr->smb_bcc = 0; 7895331Samw 7906139Sjb150015 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0) 7916030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 7926030Sjb150015 7936030Sjb150015 reply_ready: 7946030Sjb150015 smbsr_send_reply(sr); 7956030Sjb150015 7966030Sjb150015 drop_connection: 7976030Sjb150015 if (disconnect) { 7989343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_WRITER); 7998262SJose.Borrego@Sun.COM switch (session->s_state) { 8006030Sjb150015 case SMB_SESSION_STATE_DISCONNECTED: 8016030Sjb150015 case SMB_SESSION_STATE_TERMINATED: 8026030Sjb150015 break; 8036030Sjb150015 default: 8048262SJose.Borrego@Sun.COM smb_soshutdown(session->sock); 8058262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_DISCONNECTED; 8066030Sjb150015 break; 8076030Sjb150015 } 8089343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 8095331Samw } 8106030Sjb150015 8118262SJose.Borrego@Sun.COM return (B_TRUE); 8125331Samw } 8135331Samw 8146030Sjb150015 int 8156030Sjb150015 smbsr_encode_empty_result(struct smb_request *sr) 8166030Sjb150015 { 8176030Sjb150015 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0)); 8186030Sjb150015 } 8195331Samw 8206030Sjb150015 int 8216030Sjb150015 smbsr_encode_result(struct smb_request *sr, int wct, int bcc, char *fmt, ...) 8225331Samw { 8235331Samw va_list ap; 8245331Samw 8256030Sjb150015 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset) 8266030Sjb150015 return (-1); 8275331Samw 8285331Samw va_start(ap, fmt); 8297052Samw (void) smb_mbc_vencodef(&sr->reply, fmt, ap); 8305331Samw va_end(ap); 8315331Samw 8325331Samw sr->smb_wct = (unsigned char)wct; 8335331Samw sr->smb_bcc = (uint16_t)bcc; 8345331Samw 8356030Sjb150015 if (smbsr_check_result(sr, wct, bcc) != 0) 8366030Sjb150015 return (-1); 8376030Sjb150015 8386030Sjb150015 return (0); 8395331Samw } 8405331Samw 8416030Sjb150015 static int 8425331Samw smbsr_check_result(struct smb_request *sr, int wct, int bcc) 8435331Samw { 8445331Samw int offset = sr->cur_reply_offset; 8455331Samw int total_bytes; 8465331Samw unsigned char temp, temp1; 8475331Samw struct mbuf *m; 8485331Samw 8495331Samw total_bytes = 0; 8505331Samw m = sr->reply.chain; 8515331Samw while (m != 0) { 8525331Samw total_bytes += m->m_len; 8535331Samw m = m->m_next; 8545331Samw } 8555331Samw 8566030Sjb150015 if ((offset + 3) > total_bytes) 8576030Sjb150015 return (-1); 8585331Samw 8597052Samw (void) smb_mbc_peek(&sr->reply, offset, "b", &temp); 8606030Sjb150015 if (temp != wct) 8616030Sjb150015 return (-1); 8625331Samw 8636030Sjb150015 if ((offset + (wct * 2 + 1)) > total_bytes) 8646030Sjb150015 return (-1); 8655331Samw 8665331Samw /* reply wct & vwv seem ok, consider data now */ 8675331Samw offset += wct * 2 + 1; 8685331Samw 8696030Sjb150015 if ((offset + 2) > total_bytes) 8706030Sjb150015 return (-1); 8715331Samw 8727052Samw (void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1); 8735331Samw if (bcc == VAR_BCC) { 8745331Samw if ((temp != 0xFF) || (temp1 != 0xFF)) { 8756030Sjb150015 return (-1); 8765331Samw } else { 8775331Samw bcc = (total_bytes - offset) - 2; 8787052Samw (void) smb_mbc_poke(&sr->reply, offset, "bb", 8795331Samw bcc, bcc >> 8); 8805331Samw } 8815331Samw } else { 8826030Sjb150015 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF))) 8836030Sjb150015 return (-1); 8845331Samw } 8855331Samw 8865331Samw offset += bcc + 2; 8875331Samw 8886030Sjb150015 if (offset != total_bytes) 8896030Sjb150015 return (-1); 8905331Samw 8915331Samw sr->smb_wct = (unsigned char)wct; 8925331Samw sr->smb_bcc = (uint16_t)bcc; 8936030Sjb150015 return (0); 8945331Samw } 8955331Samw 8965331Samw int 8975331Samw smbsr_decode_vwv(struct smb_request *sr, char *fmt, ...) 8985331Samw { 8995331Samw int rc; 9005331Samw va_list ap; 9015331Samw 9025331Samw va_start(ap, fmt); 9037052Samw rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap); 9045331Samw va_end(ap); 9055331Samw 9066139Sjb150015 if (rc) 9076139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9085331Samw return (rc); 9095331Samw } 9105331Samw 9115331Samw int 9125331Samw smbsr_decode_data(struct smb_request *sr, char *fmt, ...) 9135331Samw { 9146139Sjb150015 int rc; 9155331Samw va_list ap; 9166139Sjb150015 9175331Samw va_start(ap, fmt); 9187052Samw rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap); 9195331Samw va_end(ap); 9206139Sjb150015 9216139Sjb150015 if (rc) 9226139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9236139Sjb150015 return (rc); 9245331Samw } 9255331Samw 926*12508Samw@Sun.COM boolean_t 927*12508Samw@Sun.COM smbsr_decode_data_avail(smb_request_t *sr) 928*12508Samw@Sun.COM { 929*12508Samw@Sun.COM return (sr->smb_data.chain_offset < sr->smb_data.max_bytes); 930*12508Samw@Sun.COM } 931*12508Samw@Sun.COM 9325331Samw void 933*12508Samw@Sun.COM smbsr_send_reply(smb_request_t *sr) 9345331Samw { 9357348SJose.Borrego@Sun.COM if (SMB_TREE_IS_CASEINSENSITIVE(sr)) 9366030Sjb150015 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE; 9376030Sjb150015 else 9386030Sjb150015 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE; 9396030Sjb150015 9407052Samw (void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT, 9415331Samw sr->first_smb_com, 9425331Samw sr->smb_rcls, 9435331Samw sr->smb_reh, 9445331Samw sr->smb_err, 9455331Samw sr->smb_flg | SMB_FLAGS_REPLY, 9465331Samw sr->smb_flg2, 9475331Samw sr->smb_pid_high, 9485331Samw sr->smb_sig, 9495331Samw sr->smb_tid, 9505331Samw sr->smb_pid, 9515331Samw sr->smb_uid, 9525331Samw sr->smb_mid); 9535331Samw 9545331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 9555331Samw smb_sign_reply(sr, NULL); 9565331Samw 957*12508Samw@Sun.COM smb_server_inc_req(sr->session->s_server); 9586030Sjb150015 if (smb_session_send(sr->session, 0, &sr->reply) == 0) 9596030Sjb150015 sr->reply.chain = 0; 9605331Samw } 9615331Samw 9625331Samw /* 9635772Sas200622 * Map errno values to SMB and NT status values. 9645772Sas200622 * Note: ESRCH is a special case to handle a streams lookup failure. 9655331Samw */ 9665331Samw static struct { 9675772Sas200622 int errnum; 9685772Sas200622 int errcls; 9695772Sas200622 int errcode; 9705772Sas200622 DWORD status32; 9715772Sas200622 } smb_errno_map[] = { 9725331Samw { ENOSPC, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 9735331Samw { EDQUOT, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 9745331Samw { EPERM, ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED }, 9755331Samw { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, 9765331Samw { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, 9775331Samw { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE }, 9785331Samw { ENOTEMPTY, ERRDOS, ERROR_DIR_NOT_EMPTY, 9795331Samw NT_STATUS_DIRECTORY_NOT_EMPTY }, 9809231SAfshin.Ardakani@Sun.COM { EILSEQ, ERRDOS, ERROR_INVALID_NAME, 9819231SAfshin.Ardakani@Sun.COM NT_STATUS_OBJECT_NAME_INVALID }, 9825331Samw { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, 9835331Samw { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY }, 9845331Samw { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, 9855331Samw { EXDEV, ERRSRV, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, 98611963SAfshin.Ardakani@Sun.COM { EREMOTE, ERRSRV, ERRbadpath, NT_STATUS_PATH_NOT_COVERED}, 9875331Samw { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, 9889231SAfshin.Ardakani@Sun.COM { ESTALE, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 9899231SAfshin.Ardakani@Sun.COM { EBADF, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 9909231SAfshin.Ardakani@Sun.COM { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION }, 9919231SAfshin.Ardakani@Sun.COM { ENXIO, ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE }, 9925331Samw { ESRCH, ERRDOS, ERROR_FILE_NOT_FOUND, 9935331Samw NT_STATUS_OBJECT_NAME_NOT_FOUND }, 9945331Samw /* 9955331Samw * It's not clear why smb_read_common effectively returns 9965331Samw * ERRnoaccess if a range lock prevents access and smb_write_common 9975331Samw * effectively returns ERRaccess. This table entry is used by 9985331Samw * smb_read_common and preserves the behavior that was there before. 9995331Samw */ 10005331Samw { ERANGE, ERRDOS, ERRnoaccess, NT_STATUS_FILE_LOCK_CONFLICT } 10015331Samw }; 10025331Samw 10035331Samw void 10045772Sas200622 smbsr_map_errno(int errnum, smb_error_t *err) 10055331Samw { 10065331Samw int i; 10075331Samw 10085772Sas200622 for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) { 10095772Sas200622 if (smb_errno_map[i].errnum == errnum) { 10105772Sas200622 err->status = smb_errno_map[i].status32; 10115772Sas200622 err->errcls = smb_errno_map[i].errcls; 10125772Sas200622 err->errcode = smb_errno_map[i].errcode; 10135772Sas200622 return; 10145331Samw } 10155331Samw } 10165331Samw 10175772Sas200622 err->status = NT_STATUS_INTERNAL_ERROR; 10185772Sas200622 err->errcls = ERRDOS; 10195772Sas200622 err->errcode = ERROR_INTERNAL_ERROR; 10205331Samw } 10215331Samw 10225331Samw void 10235772Sas200622 smbsr_errno(struct smb_request *sr, int errnum) 10245772Sas200622 { 10256030Sjb150015 smbsr_map_errno(errnum, &sr->smb_error); 10266030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10275772Sas200622 } 10285772Sas200622 10295772Sas200622 /* 1030*12508Samw@Sun.COM * Report a request processing status (error or warning). 10315772Sas200622 */ 10325772Sas200622 void 1033*12508Samw@Sun.COM smbsr_status(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10345772Sas200622 { 10356030Sjb150015 sr->smb_error.status = status; 10366030Sjb150015 sr->smb_error.errcls = errcls; 10376030Sjb150015 sr->smb_error.errcode = errcode; 10385772Sas200622 10396030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10405772Sas200622 } 10415772Sas200622 10425772Sas200622 /* 10435772Sas200622 * Setup a request processing error. This function can be used to 10445772Sas200622 * report 32-bit status codes or DOS errors. Set the status code 10455772Sas200622 * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error, 10465772Sas200622 * regardless of the client capabilities. 10475772Sas200622 * 10485772Sas200622 * If status is non-zero and the client supports 32-bit status 10495772Sas200622 * codes, report the status. Otherwise, report the DOS error. 10505772Sas200622 */ 10515772Sas200622 void 10525772Sas200622 smbsr_set_error(smb_request_t *sr, smb_error_t *err) 10535772Sas200622 { 10545772Sas200622 uint32_t status; 10555772Sas200622 uint32_t capabilities; 10565772Sas200622 10575772Sas200622 ASSERT(sr); 10585772Sas200622 ASSERT(err); 10595772Sas200622 10605772Sas200622 status = err->status; 10615772Sas200622 capabilities = sr->session->capabilities; 10625772Sas200622 10635772Sas200622 if ((err->errcls == 0) && (err->errcode == 0)) { 10645772Sas200622 capabilities |= CAP_STATUS32; 10655772Sas200622 if (status == 0) 10665772Sas200622 status = NT_STATUS_INTERNAL_ERROR; 10675772Sas200622 } 10685772Sas200622 10695772Sas200622 if ((capabilities & CAP_STATUS32) && (status != 0)) { 10705772Sas200622 sr->smb_rcls = status & 0xff; 10715772Sas200622 sr->smb_reh = (status >> 8) & 0xff; 10725772Sas200622 sr->smb_err = status >> 16; 10735772Sas200622 sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS; 10745772Sas200622 } else { 10755772Sas200622 if ((err->errcls == 0) || (err->errcode == 0)) { 10765772Sas200622 sr->smb_rcls = ERRSRV; 10775772Sas200622 sr->smb_err = ERRerror; 10785772Sas200622 } else { 10795772Sas200622 sr->smb_rcls = (uint8_t)err->errcls; 10805772Sas200622 sr->smb_err = (uint16_t)err->errcode; 10815331Samw } 10825331Samw } 10835331Samw } 10845331Samw 10855331Samw smb_xa_t * 10865331Samw smbsr_lookup_xa(smb_request_t *sr) 10875331Samw { 10885331Samw ASSERT(sr->r_xa == 0); 10895331Samw 10905331Samw sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid); 10915331Samw return (sr->r_xa); 10925331Samw } 10935331Samw 10945331Samw void 109510504SKeyur.Desai@Sun.COM smbsr_release_file(smb_request_t *sr) 10965331Samw { 10975331Samw smb_ofile_t *of = sr->fid_ofile; 10985331Samw 10995331Samw sr->fid_ofile = NULL; 11005331Samw (void) smb_ofile_release(of); 11015331Samw } 11025331Samw 11038934SJose.Borrego@Sun.COM void 11048934SJose.Borrego@Sun.COM smbsr_lookup_file(smb_request_t *sr) 11058934SJose.Borrego@Sun.COM { 11068934SJose.Borrego@Sun.COM if (sr->fid_ofile == NULL) 11078934SJose.Borrego@Sun.COM sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree, 11088934SJose.Borrego@Sun.COM sr->smb_fid); 11098934SJose.Borrego@Sun.COM } 11108934SJose.Borrego@Sun.COM 11115331Samw static int 11125331Samw is_andx_com(unsigned char com) 11135331Samw { 11145331Samw switch (com) { 11155331Samw case SMB_COM_LOCKING_ANDX: 11165331Samw case SMB_COM_OPEN_ANDX: 11175331Samw case SMB_COM_READ_ANDX: 11185331Samw case SMB_COM_WRITE_ANDX: 11195331Samw case SMB_COM_SESSION_SETUP_ANDX: 11205331Samw case SMB_COM_LOGOFF_ANDX: 11215331Samw case SMB_COM_TREE_CONNECT_ANDX: 11225331Samw case SMB_COM_NT_CREATE_ANDX: 11235331Samw return (1); 11245331Samw } 11255331Samw return (0); 11265331Samw } 11275331Samw 11285331Samw /* 11296139Sjb150015 * Invalid command stubs. 11306139Sjb150015 * 11316139Sjb150015 * SmbWriteComplete is sent to acknowledge completion of raw write requests. 11326139Sjb150015 * We never send raw write commands to other servers so, if we receive 11336139Sjb150015 * SmbWriteComplete, we treat it as an error. 11346139Sjb150015 * 11356139Sjb150015 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize 11366139Sjb150015 * performance when reading/writing a large block of data: it can be 11376139Sjb150015 * used in parallel with other client/server operations. The mpx sub- 11386139Sjb150015 * protocol is not supported because we support only connection oriented 11396139Sjb150015 * transports and NT supports mpx only over connectionless transports. 11405331Samw */ 11416030Sjb150015 smb_sdrc_t 11426139Sjb150015 smb_pre_invalid(smb_request_t *sr) 11436139Sjb150015 { 11446139Sjb150015 DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr); 11456139Sjb150015 return (SDRC_SUCCESS); 11466139Sjb150015 } 11476139Sjb150015 11486139Sjb150015 void 11496139Sjb150015 smb_post_invalid(smb_request_t *sr) 11506139Sjb150015 { 11516139Sjb150015 DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr); 11526139Sjb150015 } 11536139Sjb150015 11546139Sjb150015 smb_sdrc_t 11556139Sjb150015 smb_com_invalid(smb_request_t *sr) 11565331Samw { 11576139Sjb150015 smb_sdrc_t sdrc; 11586139Sjb150015 11596139Sjb150015 switch (sr->smb_com) { 11606139Sjb150015 case SMB_COM_WRITE_COMPLETE: 11616139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 11626139Sjb150015 sdrc = SDRC_ERROR; 11636139Sjb150015 break; 11646139Sjb150015 11656139Sjb150015 default: 11666139Sjb150015 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED, 11676139Sjb150015 ERRDOS, ERROR_INVALID_FUNCTION); 11686139Sjb150015 sdrc = SDRC_NOT_IMPLEMENTED; 11696139Sjb150015 break; 11706139Sjb150015 } 11716139Sjb150015 11726139Sjb150015 return (sdrc); 11735331Samw } 11745331Samw 11755331Samw /* 1176*12508Samw@Sun.COM * smb_dispatch_stats_init 11775331Samw * 1178*12508Samw@Sun.COM * Initializes dispatch statistics. 11795331Samw */ 11805331Samw void 1181*12508Samw@Sun.COM smb_dispatch_stats_init(smb_kstat_req_t *ksr) 11825331Samw { 1183*12508Samw@Sun.COM int i; 11845331Samw 1185*12508Samw@Sun.COM for (i = 0; i < SMB_COM_NUM; i++, ksr++) { 1186*12508Samw@Sun.COM smb_latency_init(&smb_disp_table[i].sdt_lat); 1187*12508Samw@Sun.COM (void) strlcpy(ksr->kr_name, smb_disp_table[i].sdt_name, 1188*12508Samw@Sun.COM sizeof (ksr->kr_name)); 11895331Samw } 11905331Samw } 11915331Samw 11925331Samw /* 1193*12508Samw@Sun.COM * smb_dispatch_stats_fini 11945331Samw * 1195*12508Samw@Sun.COM * Frees and destroyes the resources used for statistics. 11965331Samw */ 11975331Samw void 1198*12508Samw@Sun.COM smb_dispatch_stats_fini(void) 1199*12508Samw@Sun.COM { 1200*12508Samw@Sun.COM int i; 1201*12508Samw@Sun.COM 1202*12508Samw@Sun.COM for (i = 0; i < SMB_COM_NUM; i++) 1203*12508Samw@Sun.COM smb_latency_destroy(&smb_disp_table[i].sdt_lat); 1204*12508Samw@Sun.COM } 1205*12508Samw@Sun.COM 1206*12508Samw@Sun.COM void 1207*12508Samw@Sun.COM smb_dispatch_stats_update(smb_kstat_req_t *ksr, int first, int nreq) 12085331Samw { 1209*12508Samw@Sun.COM int i; 1210*12508Samw@Sun.COM int last; 1211*12508Samw@Sun.COM 1212*12508Samw@Sun.COM last = first + nreq - 1; 1213*12508Samw@Sun.COM 1214*12508Samw@Sun.COM if ((first < SMB_COM_NUM) && (last < SMB_COM_NUM)) { 1215*12508Samw@Sun.COM for (i = first; i <= last; i++, ksr++) { 1216*12508Samw@Sun.COM ksr->kr_rxb = smb_disp_table[i].sdt_rxb; 1217*12508Samw@Sun.COM ksr->kr_txb = smb_disp_table[i].sdt_txb; 1218*12508Samw@Sun.COM mutex_enter(&smb_disp_table[i].sdt_lat.ly_mutex); 1219*12508Samw@Sun.COM ksr->kr_nreq = smb_disp_table[i].sdt_lat.ly_a_nreq; 1220*12508Samw@Sun.COM ksr->kr_sum = smb_disp_table[i].sdt_lat.ly_a_sum; 1221*12508Samw@Sun.COM ksr->kr_a_mean = smb_disp_table[i].sdt_lat.ly_a_mean; 1222*12508Samw@Sun.COM ksr->kr_a_stddev = 1223*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_a_stddev; 1224*12508Samw@Sun.COM ksr->kr_d_mean = smb_disp_table[i].sdt_lat.ly_d_mean; 1225*12508Samw@Sun.COM ksr->kr_d_stddev = 1226*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_d_stddev; 1227*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_d_mean = 0; 1228*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_d_nreq = 0; 1229*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_d_stddev = 0; 1230*12508Samw@Sun.COM smb_disp_table[i].sdt_lat.ly_d_sum = 0; 1231*12508Samw@Sun.COM mutex_exit(&smb_disp_table[i].sdt_lat.ly_mutex); 1232*12508Samw@Sun.COM } 12335331Samw } 12345331Samw } 1235