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 */ 215331Samw /* 225772Sas200622 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw * 255331Samw * 265331Samw * Dispatching SMB requests. 275331Samw */ 285331Samw 295331Samw #pragma ident "%Z%%M% %I% %E% SMI" 305331Samw 315331Samw /* 325331Samw * ALMOST EVERYTHING YOU NEED TO KNOW ABOUT A SERVER MESSAGE BLOCK 335331Samw * 345331Samw * Request 355331Samw * Header 365331Samw * Magic 0xFF 'S' 'M' 'B' 375331Samw * smb_com a byte, the "first" command 385331Samw * Error a 4-byte union, ignored in a request 395331Samw * smb_flg a one byte set of eight flags 405331Samw * smb_flg2 a two byte set of 16 flags 415331Samw * . twelve reserved bytes, have a role 425331Samw * in connectionless transports (IPX, UDP?) 435331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 445331Samw * 0xFFFF is this command does not have 455331Samw * or require a tree context 465331Samw * smb_pid a 16-bit process ID 475331Samw * smb_uid a 16-bit user ID, specific to this "session" 485331Samw * and mapped to a system (bona-fide) UID 495331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 505331Samw * multiple simultaneous requests from the same 515331Samw * process (pid) (ref RPC "xid") 525331Samw * 535331Samw * Chained (AndX) commands (0 or more) 545331Samw * smb_wct a byte, number of 16-bit words containing 555331Samw * command parameters, min 2 for chained command 565331Samw * andx_com a byte, the "next" command, 0xFF for none 575331Samw * . an unused byte 585331Samw * andx_off a 16-bit offset, byte displacement from &Magic 595331Samw * to the smb_wct field of the "next" command, 605331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 615331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 625331Samw * "this" command (i.e. smb_com if this is the 635331Samw * first parameters, or the andx_com of the just 645331Samw * previous block. 655331Samw * smb_bcc a 16-bit count of smb_data[] bytes 665331Samw * smb_data[] 0 or more bytes, format specific to commands 675331Samw * padding[] Optional padding 685331Samw * 695331Samw * Last command 705331Samw * smb_wct a byte, number of 16-bit words containing 715331Samw * command parameters, min 0 for chained command 725331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 735331Samw * "this" command (i.e. smb_com if this is the 745331Samw * first parameters, or the andx_com of the just 755331Samw * previous block. 765331Samw * smb_bcc a 16-bit count of smb_data[] bytes 775331Samw * smb_data[] 0 or more bytes, format specific to commands 785331Samw * 795331Samw * Reply 805331Samw * Header 815331Samw * Magic 0xFF 'S' 'M' 'B' 825331Samw * smb_com a byte, the "first" command, corresponds 835331Samw * to request 845331Samw * Error a 4-byte union, coding depends on dialect in use 855331Samw * for "DOS" errors 865331Samw * a byte for error class 875331Samw * an unused byte 885331Samw * a 16-bit word for error code 895331Samw * for "NT" errors 905331Samw * a 32-bit error code which 915331Samw * is a packed class and specifier 925331Samw * for "OS/2" errors 935331Samw * I don't know 945331Samw * The error information is specific to the 955331Samw * last command in the reply chain. 965331Samw * smb_flg a one byte set of eight flags, 0x80 bit set 975331Samw * indicating this message is a reply 985331Samw * smb_flg2 a two byte set of 16 flags 995331Samw * . twelve reserved bytes, have a role 1005331Samw * in connectionless transports (IPX, UDP?) 1015331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 1025331Samw * should be the same as the request 1035331Samw * smb_pid a 16-bit process ID, MUST BE the same as request 1045331Samw * smb_uid a 16-bit user ID, specific to this "session" 1055331Samw * and mapped to a system (bona-fide) UID, 1065331Samw * should be the same as request 1075331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 1085331Samw * multiple simultaneous requests from the same 1095331Samw * process (pid) (ref RPC "xid"), MUST BE the 1105331Samw * same as request 1115331Samw * padding[] Optional padding 1125331Samw * 1135331Samw * Chained (AndX) commands (0 or more) 1145331Samw * smb_wct a byte, number of 16-bit words containing 1155331Samw * command parameters, min 2 for chained command, 1165331Samw * andx_com a byte, the "next" command, 0xFF for none, 1175331Samw * corresponds to request, if this is the chained 1185331Samw * command that had an error set to 0xFF 1195331Samw * . an unused byte 1205331Samw * andx_off a 16-bit offset, byte displacement from &Magic 1215331Samw * to the smb_wct field of the "next" command, 1225331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 1235331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1245331Samw * "this" command (i.e. smb_com if this is the 1255331Samw * first parameters, or the andx_com of the just 1265331Samw * previous block. Empty if an error. 1275331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1285331Samw * smb_data[] 0 or more bytes, format specific to commands 1295331Samw * empty if an error. 1305331Samw * 1315331Samw * Last command 1325331Samw * smb_wct a byte, number of 16-bit words containing 1335331Samw * command parameters, min 0 for chained command 1345331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1355331Samw * "this" command (i.e. smb_com if this is the 1365331Samw * first parameters, or the andx_com of the just 1375331Samw * previous block, empty if an error. 1385331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1395331Samw * smb_data[] 0 or more bytes, format specific to commands, 1405331Samw * empty if an error. 1415331Samw */ 1425331Samw 1435331Samw #include <smbsrv/smb_incl.h> 1445331Samw #include <sys/sdt.h> 1455331Samw 1465331Samw #define SMB_ALL_DISPATCH_STAT_INCR(stat) atomic_inc_64(&stat); 147*6139Sjb150015 #define SMB_COM_NUM 256 1485331Samw 1495331Samw static kstat_t *smb_dispatch_ksp = NULL; 150*6139Sjb150015 static kmutex_t smb_dispatch_ksmtx; 1515331Samw 1526030Sjb150015 static int is_andx_com(unsigned char); 1536030Sjb150015 static int smbsr_check_result(struct smb_request *, int, int); 1545331Samw 155*6139Sjb150015 static smb_dispatch_table_t dispatch[SMB_COM_NUM] = { 156*6139Sjb150015 { SMB_SDT_OPS(create_directory), /* 0x00 000 */ 157*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1585331Samw { "SmbCreateDirectory", KSTAT_DATA_UINT64 } }, 159*6139Sjb150015 { SMB_SDT_OPS(delete_directory), /* 0x01 001 */ 160*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1615331Samw { "SmbDeleteDirectory", KSTAT_DATA_UINT64 } }, 162*6139Sjb150015 { SMB_SDT_OPS(open), /* 0x02 002 */ 163*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1645331Samw { "SmbOpen", KSTAT_DATA_UINT64 } }, 165*6139Sjb150015 { SMB_SDT_OPS(create), /* 0x03 003 */ 166*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1675331Samw { "SmbCreate", KSTAT_DATA_UINT64 } }, 168*6139Sjb150015 { SMB_SDT_OPS(close), /* 0x04 004 */ 169*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1705331Samw { "SmbClose", KSTAT_DATA_UINT64 } }, 171*6139Sjb150015 { SMB_SDT_OPS(flush), /* 0x05 005 */ 172*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1735331Samw { "SmbFlush", KSTAT_DATA_UINT64 } }, 174*6139Sjb150015 { SMB_SDT_OPS(delete), /* 0x06 006 */ 175*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1765331Samw { "SmbDelete", KSTAT_DATA_UINT64 } }, 177*6139Sjb150015 { SMB_SDT_OPS(rename), /* 0x07 007 */ 178*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1795331Samw { "SmbRename", KSTAT_DATA_UINT64 } }, 180*6139Sjb150015 { SMB_SDT_OPS(query_information), /* 0x08 008 */ 181*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1825331Samw { "SmbQueryInformation", KSTAT_DATA_UINT64 } }, 183*6139Sjb150015 { SMB_SDT_OPS(set_information), /* 0x09 009 */ 184*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1855331Samw { "SmbSetInformation", KSTAT_DATA_UINT64 } }, 186*6139Sjb150015 { SMB_SDT_OPS(read), /* 0x0A 010 */ 187*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1885331Samw { "SmbRead", KSTAT_DATA_UINT64 } }, 189*6139Sjb150015 { SMB_SDT_OPS(write), /* 0x0B 011 */ 190*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1915331Samw { "SmbWrite", KSTAT_DATA_UINT64 } }, 192*6139Sjb150015 { SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */ 193*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1945331Samw { "SmbLockByteRange", KSTAT_DATA_UINT64 } }, 195*6139Sjb150015 { SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */ 196*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1975331Samw { "SmbUnlockByteRange", KSTAT_DATA_UINT64 } }, 198*6139Sjb150015 { SMB_SDT_OPS(create_temporary), /* 0x0E 014 */ 199*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2005331Samw { "SmbCreateTemporary", KSTAT_DATA_UINT64 } }, 201*6139Sjb150015 { SMB_SDT_OPS(create_new), /* 0x0F 015 */ 202*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2035331Samw { "SmbCreateNew", KSTAT_DATA_UINT64 } }, 204*6139Sjb150015 { SMB_SDT_OPS(check_directory), /* 0x10 016 */ 205*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2065331Samw { "SmbCheckDirectory", KSTAT_DATA_UINT64 } }, 207*6139Sjb150015 { SMB_SDT_OPS(process_exit), /* 0x11 017 */ 2085331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2095331Samw RW_READER, 2105331Samw { "SmbProcessExit", KSTAT_DATA_UINT64 } }, 211*6139Sjb150015 { SMB_SDT_OPS(seek), /* 0x12 018 */ 212*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2135331Samw { "SmbSeek", KSTAT_DATA_UINT64 } }, 214*6139Sjb150015 { SMB_SDT_OPS(lock_and_read), /* 0x13 019 */ 215*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2165331Samw { "SmbLockAndRead", KSTAT_DATA_UINT64 } }, 217*6139Sjb150015 { SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */ 218*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2195331Samw { "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } }, 220*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x15 021 */ 221*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x16 022 */ 222*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x17 023 */ 223*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x18 024 */ 224*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x19 025 */ 225*6139Sjb150015 { SMB_SDT_OPS(read_raw), /* 0x1A 026 */ 226*6139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2275331Samw { "SmbReadRaw", KSTAT_DATA_UINT64 } }, 228*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1B 027 */ 229*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1C 028 */ 230*6139Sjb150015 { SMB_SDT_OPS(write_raw), /* 0x1D 029 */ 231*6139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2325331Samw { "SmbWriteRaw", KSTAT_DATA_UINT64 } }, 233*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1E 030 */ 234*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1F 031 */ 235*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x20 032 */ 236*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x21 033 */ 237*6139Sjb150015 { SMB_SDT_OPS(set_information2), /* 0x22 034 */ 238*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2395331Samw { "SmbSetInformation2", KSTAT_DATA_UINT64 } }, 240*6139Sjb150015 { SMB_SDT_OPS(query_information2), /* 0x23 035 */ 241*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2425331Samw { "SmbQueryInformation2", KSTAT_DATA_UINT64 } }, 243*6139Sjb150015 { SMB_SDT_OPS(locking_andx), /* 0x24 036 */ 244*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2455331Samw { "SmbLockingX", KSTAT_DATA_UINT64 } }, 246*6139Sjb150015 { SMB_SDT_OPS(transaction), /* 0x25 037 */ 247*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2485331Samw { "SmbTransaction", KSTAT_DATA_UINT64 } }, 249*6139Sjb150015 { SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */ 250*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2515331Samw { "SmbTransactionSecondary", KSTAT_DATA_UINT64 } }, 252*6139Sjb150015 { SMB_SDT_OPS(ioctl), /* 0x27 039 */ 253*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2545331Samw { "SmbIoctl", KSTAT_DATA_UINT64 } }, 255*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x28 040 */ 256*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x29 041 */ 257*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x2A 042 */ 258*6139Sjb150015 { SMB_SDT_OPS(echo), /* 0x2B 043 */ 2595331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2605331Samw RW_READER, 2615331Samw { "SmbEcho", KSTAT_DATA_UINT64 } }, 262*6139Sjb150015 { SMB_SDT_OPS(write_and_close), /* 0x2C 044 */ 263*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2645331Samw { "SmbWriteAndClose", KSTAT_DATA_UINT64 } }, 265*6139Sjb150015 { SMB_SDT_OPS(open_andx), /* 0x2D 045 */ 266*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2675331Samw { "SmbOpenX", KSTAT_DATA_UINT64 } }, 268*6139Sjb150015 { SMB_SDT_OPS(read_andx), /* 0x2E 046 */ 269*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2705331Samw { "SmbReadX", KSTAT_DATA_UINT64 } }, 271*6139Sjb150015 { SMB_SDT_OPS(write_andx), /* 0x2F 047 */ 272*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2735331Samw { "SmbWriteX", KSTAT_DATA_UINT64 } }, 274*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x30 048 */ 275*6139Sjb150015 { SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */ 276*6139Sjb150015 LANMAN1_0, 0, RW_READER, 2775331Samw { "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } }, 278*6139Sjb150015 { SMB_SDT_OPS(transaction2), /* 0x32 050 */ 279*6139Sjb150015 LM1_2X002, 0, RW_READER, 2805331Samw { "SmbTransaction2", KSTAT_DATA_UINT64 } }, 281*6139Sjb150015 { SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */ 282*6139Sjb150015 LM1_2X002, 0, RW_READER, 2835331Samw { "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } }, 284*6139Sjb150015 { SMB_SDT_OPS(find_close2), /* 0x34 052 */ 285*6139Sjb150015 LM1_2X002, 0, RW_READER, 2865331Samw { "SmbFindClose2", KSTAT_DATA_UINT64 } }, 287*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x35 053 */ 288*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x36 054 */ 289*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x37 055 */ 290*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x38 056 */ 291*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x39 057 */ 292*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3A 058 */ 293*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3B 059 */ 294*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3C 060 */ 295*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3D 061 */ 296*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3E 062 */ 297*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3F 063 */ 298*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x40 064 */ 299*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x41 065 */ 300*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x42 066 */ 301*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x43 067 */ 302*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x44 068 */ 303*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x45 069 */ 304*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x46 070 */ 305*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x47 071 */ 306*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x48 072 */ 307*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x49 073 */ 308*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4A 074 */ 309*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4B 075 */ 310*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4C 076 */ 311*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4D 077 */ 312*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4E 078 */ 313*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4F 079 */ 314*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x50 080 */ 315*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x51 081 */ 316*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x52 082 */ 317*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x53 083 */ 318*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x54 084 */ 319*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x55 085 */ 320*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x56 086 */ 321*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x57 087 */ 322*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x58 088 */ 323*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x59 089 */ 324*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5A 090 */ 325*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5B 091 */ 326*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5C 092 */ 327*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5D 093 */ 328*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5E 094 */ 329*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5F 095 */ 330*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x60 096 */ 331*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x61 097 */ 332*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x62 098 */ 333*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x63 099 */ 334*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x64 100 */ 335*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x65 101 */ 336*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x66 102 */ 337*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x67 103 */ 338*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x68 104 */ 339*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x69 105 */ 340*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6A 106 */ 341*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6B 107 */ 342*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6C 108 */ 343*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6D 109 */ 344*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6E 110 */ 345*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6F 111 */ 346*6139Sjb150015 { SMB_SDT_OPS(tree_connect), /* 0x70 112 */ 347*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID, RW_READER, 3485331Samw { "SmbTreeConnect", KSTAT_DATA_UINT64 } }, 349*6139Sjb150015 { SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */ 3505331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3515331Samw RW_READER, 3525331Samw { "SmbTreeDisconnect", KSTAT_DATA_UINT64 } }, 353*6139Sjb150015 { SMB_SDT_OPS(negotiate), /* 0x72 114 */ 3545331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3555331Samw RW_WRITER, 3565331Samw { "SmbNegotiate", KSTAT_DATA_UINT64 } }, 357*6139Sjb150015 { SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */ 3585331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3595331Samw RW_READER, 3605331Samw { "SmbSessionSetupX", KSTAT_DATA_UINT64 } }, 361*6139Sjb150015 { SMB_SDT_OPS(logoff_andx), /* 0x74 116 */ 362*6139Sjb150015 LM1_2X002, SDDF_SUPPRESS_TID, RW_READER, 3635331Samw { "SmbLogoffX", KSTAT_DATA_UINT64 } }, 364*6139Sjb150015 { SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */ 365*6139Sjb150015 LANMAN1_0, SDDF_SUPPRESS_TID, RW_READER, 3665331Samw { "SmbTreeConnectX", KSTAT_DATA_UINT64 } }, 367*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x76 118 */ 368*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x77 119 */ 369*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x78 120 */ 370*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x79 121 */ 371*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7A 122 */ 372*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7B 123 */ 373*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7C 124 */ 374*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7D 125 */ 375*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7E 126 */ 376*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7F 127 */ 377*6139Sjb150015 { SMB_SDT_OPS(query_information_disk), /* 0x80 128 */ 378*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3795331Samw { "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } }, 380*6139Sjb150015 { SMB_SDT_OPS(search), /* 0x81 129 */ 381*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3825331Samw { "SmbSearch", KSTAT_DATA_UINT64 } }, 383*6139Sjb150015 { SMB_SDT_OPS(find), /* 0x82 130 */ 384*6139Sjb150015 LANMAN1_0, 0, RW_READER, 3855331Samw { "SmbFind", KSTAT_DATA_UINT64 } }, 386*6139Sjb150015 { SMB_SDT_OPS(find_unique), /* 0x83 131 */ 387*6139Sjb150015 LANMAN1_0, 0, RW_READER, 3885331Samw { "SmbFindUnique", KSTAT_DATA_UINT64 } }, 389*6139Sjb150015 { SMB_SDT_OPS(find_close), /* 0x84 132 */ 390*6139Sjb150015 LANMAN1_0, 0, RW_READER, 3915331Samw { "SmbFindClose", KSTAT_DATA_UINT64 } }, 392*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x85 133 */ 393*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x86 134 */ 394*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x87 135 */ 395*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x88 136 */ 396*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x89 137 */ 397*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8A 138 */ 398*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8B 139 */ 399*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8C 140 */ 400*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8D 141 */ 401*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8E 142 */ 402*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8F 143 */ 403*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x90 144 */ 404*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x91 145 */ 405*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x92 146 */ 406*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x93 147 */ 407*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x94 148 */ 408*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x95 149 */ 409*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x96 150 */ 410*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x97 151 */ 411*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x98 152 */ 412*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x99 153 */ 413*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9A 154 */ 414*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9B 155 */ 415*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9C 156 */ 416*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9D 157 */ 417*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9E 158 */ 418*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9F 159 */ 419*6139Sjb150015 { SMB_SDT_OPS(nt_transact), /* 0xA0 160 */ 420*6139Sjb150015 NT_LM_0_12, 0, RW_READER, 4215331Samw { "SmbNtTransact", KSTAT_DATA_UINT64 } }, 422*6139Sjb150015 { SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */ 423*6139Sjb150015 NT_LM_0_12, 0, RW_READER, 4245331Samw { "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } }, 425*6139Sjb150015 { SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */ 426*6139Sjb150015 NT_LM_0_12, 0, RW_READER, 4275331Samw { "SmbNtCreateX", KSTAT_DATA_UINT64 } }, 428*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA3 163 */ 429*6139Sjb150015 { SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */ 430*6139Sjb150015 NT_LM_0_12, 0, RW_READER, 4315331Samw { "SmbNtCancel", KSTAT_DATA_UINT64 } }, 432*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA5 165 */ 433*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA6 166 */ 434*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA7 167 */ 435*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA8 168 */ 436*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA9 169 */ 437*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAA 170 */ 438*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAB 171 */ 439*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAC 172 */ 440*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAD 173 */ 441*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAE 174 */ 442*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAF 175 */ 443*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB0 176 */ 444*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB1 177 */ 445*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB2 178 */ 446*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB3 179 */ 447*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB4 180 */ 448*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB5 181 */ 449*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB6 182 */ 450*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB7 183 */ 451*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB8 184 */ 452*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB9 185 */ 453*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBA 186 */ 454*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBB 187 */ 455*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBC 188 */ 456*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBD 189 */ 457*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBE 190 */ 458*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBF 191 */ 459*6139Sjb150015 { SMB_SDT_OPS(open_print_file), /* 0xC0 192 */ 460*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4615331Samw { "SmbOpenPrintFile", KSTAT_DATA_UINT64 } }, 462*6139Sjb150015 { SMB_SDT_OPS(write_print_file), /* 0xC1 193 */ 463*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4645331Samw { "SmbWritePrintFile", KSTAT_DATA_UINT64 } }, 465*6139Sjb150015 { SMB_SDT_OPS(close_print_file), /* 0xC2 194 */ 466*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4675331Samw { "SmbClosePrintFile", KSTAT_DATA_UINT64 } }, 468*6139Sjb150015 { SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */ 469*6139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4705331Samw { "SmbGetPrintQueue", KSTAT_DATA_UINT64 } }, 471*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC4 196 */ 472*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC5 197 */ 473*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC6 198 */ 474*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC7 199 */ 475*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC8 200 */ 476*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC9 201 */ 477*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCA 202 */ 478*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCB 203 */ 479*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCC 204 */ 480*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCD 205 */ 481*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCE 206 */ 482*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCF 207 */ 483*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD0 208 */ 484*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD1 209 */ 485*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD2 210 */ 486*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD3 211 */ 487*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD4 212 */ 488*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD5 213 */ 489*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD6 214 */ 490*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD7 215 */ 491*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD8 216 */ 492*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD9 217 */ 493*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDA 218 */ 494*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDB 219 */ 495*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDC 220 */ 496*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDD 221 */ 497*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDE 222 */ 498*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDF 223 */ 499*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE0 224 */ 500*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE1 225 */ 501*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE2 226 */ 502*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE3 227 */ 503*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE4 228 */ 504*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE5 229 */ 505*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE6 230 */ 506*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE7 231 */ 507*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE8 232 */ 508*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE9 233 */ 509*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEA 234 */ 510*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEB 235 */ 511*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEC 236 */ 512*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xED 237 */ 513*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEE 238 */ 514*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEF 239 */ 515*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF0 240 */ 516*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF1 241 */ 517*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF2 242 */ 518*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF3 243 */ 519*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF4 244 */ 520*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF5 245 */ 521*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF6 246 */ 522*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF7 247 */ 523*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF8 248 */ 524*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF9 249 */ 525*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFA 250 */ 526*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFB 251 */ 527*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFC 252 */ 528*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFD 253 */ 529*6139Sjb150015 { SMB_SDT_OPS(invalid), LANMAN1_0, 0, RW_READER, /* 0xFE 254 */ 5305331Samw { "SmbInvalidCommand", KSTAT_DATA_UINT64 } }, 531*6139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 } /* 0xFF 255 */ 5325331Samw }; 5335331Samw 5345331Samw /* 5355331Samw * smbsr_cleanup 5365331Samw * 5375331Samw * If any user/tree/file is used by given request then 5385331Samw * the reference count for that resource has been incremented. 5395331Samw * This function decrements the reference count and close 5405331Samw * the resource if it's needed. 5415331Samw */ 5425331Samw 5435331Samw void 544*6139Sjb150015 smbsr_cleanup(smb_request_t *sr) 5455331Samw { 5465331Samw ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) && 5475331Samw (sr->sr_state != SMB_REQ_STATE_COMPLETED)); 5485331Samw 5495331Samw if (sr->fid_ofile) 5505331Samw smbsr_disconnect_file(sr); 5515331Samw 5525331Samw if (sr->sid_odir) 5535331Samw smbsr_disconnect_dir(sr); 5545331Samw 5555331Samw if (sr->r_xa) { 5565331Samw if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE) 5575331Samw smb_xa_close(sr->r_xa); 5585331Samw smb_xa_rele(sr->session, sr->r_xa); 5595331Samw sr->r_xa = NULL; 5605331Samw } 5615331Samw 5625331Samw /* 5635331Samw * Mark this request so we know that we've already cleaned it up. 5645331Samw * A request should only get cleaned up once so multiple calls to 5655331Samw * smbsr_cleanup for the same request indicate a bug. 5665331Samw */ 5675331Samw mutex_enter(&sr->sr_mutex); 5685331Samw if (sr->sr_state != SMB_REQ_STATE_CANCELED) 5695331Samw sr->sr_state = SMB_REQ_STATE_CLEANED_UP; 5705331Samw mutex_exit(&sr->sr_mutex); 5715331Samw } 5725331Samw 5736030Sjb150015 void 5745331Samw smb_dispatch_request(struct smb_request *sr) 5755331Samw { 5766030Sjb150015 smb_sdrc_t sdrc; 5775331Samw smb_dispatch_table_t *sdd; 5786030Sjb150015 boolean_t disconnect = B_FALSE; 5795331Samw 5805331Samw ASSERT(sr->tid_tree == 0); 5815331Samw ASSERT(sr->uid_user == 0); 5825331Samw ASSERT(sr->fid_ofile == 0); 5835331Samw ASSERT(sr->sid_odir == 0); 5845331Samw sr->smb_fid = (uint16_t)-1; 5855331Samw sr->smb_sid = (uint16_t)-1; 5865331Samw 5875331Samw /* temporary until we identify a user */ 5885331Samw sr->user_cr = kcred; 5895331Samw sr->orig_request_hdr = sr->command.chain_offset; 5905331Samw 5915331Samw /* If this connection is shutting down just kill request */ 5925331Samw if (smb_decode_mbc(&sr->command, SMB_HEADER_ED_FMT, 5935331Samw &sr->smb_com, 5945331Samw &sr->smb_rcls, 5955331Samw &sr->smb_reh, 5965331Samw &sr->smb_err, 5975331Samw &sr->smb_flg, 5985331Samw &sr->smb_flg2, 5995331Samw &sr->smb_pid_high, 6005331Samw sr->smb_sig, 6015331Samw &sr->smb_tid, 6025331Samw &sr->smb_pid, 6035331Samw &sr->smb_uid, 6045331Samw &sr->smb_mid) != 0) { 6056030Sjb150015 disconnect = B_TRUE; 6066030Sjb150015 goto drop_connection; 6075331Samw } 6085331Samw 6095331Samw /* 6106030Sjb150015 * The reply "header" is filled in now even though it will, 6116030Sjb150015 * most likely, be rewritten under reply_ready below. We 6126030Sjb150015 * could reserve the space but this is convenient in case 6136030Sjb150015 * the dialect dispatcher has to send a special reply (like 6146030Sjb150015 * TRANSACT). 6155331Samw * 6165331Samw * Ensure that the 32-bit error code flag is turned off. 6175331Samw * Clients seem to set it in transact requests and they may 6185331Samw * get confused if we return success or a 16-bit SMB code. 6195331Samw */ 6205331Samw sr->smb_rcls = 0; 6215331Samw sr->smb_reh = 0; 6225331Samw sr->smb_err = 0; 6235331Samw sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS; 6245331Samw 6255331Samw (void) smb_encode_mbc(&sr->reply, SMB_HEADER_ED_FMT, 6265331Samw sr->smb_com, 6275331Samw sr->smb_rcls, 6285331Samw sr->smb_reh, 6295331Samw sr->smb_err, 6305331Samw sr->smb_flg, 6315331Samw sr->smb_flg2, 6325331Samw sr->smb_pid_high, 6335331Samw sr->smb_sig, 6345331Samw sr->smb_tid, 6355331Samw sr->smb_pid, 6365331Samw sr->smb_uid, 6375331Samw sr->smb_mid); 6385331Samw sr->first_smb_com = sr->smb_com; 6395331Samw 6405331Samw /* 6415772Sas200622 * Verify SMB signature if signing is enabled, dialect is NT LM 0.12, 6425331Samw * signing was negotiated and authentication has occurred. 6435331Samw */ 6445331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) { 6455331Samw if (smb_sign_check_request(sr) != 0) { 6466030Sjb150015 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 6476030Sjb150015 ERRDOS, ERROR_ACCESS_DENIED); 6486030Sjb150015 disconnect = B_TRUE; 6495331Samw smb_rwx_rwenter(&sr->session->s_lock, RW_READER); 6506030Sjb150015 goto report_error; 6515331Samw } 6525331Samw } 6535331Samw 6545331Samw andx_more: 6555331Samw sdd = &dispatch[sr->smb_com]; 656*6139Sjb150015 ASSERT(sdd->sdt_function); 6575331Samw 6585331Samw smb_rwx_rwenter(&sr->session->s_lock, sdd->sdt_slock_mode); 6595331Samw 6605331Samw if (smb_decode_mbc(&sr->command, "b", &sr->smb_wct) != 0) { 6616030Sjb150015 disconnect = B_TRUE; 6626030Sjb150015 goto report_error; 6635331Samw } 6645331Samw 6655331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command, 6665331Samw sr->command.chain_offset, sr->smb_wct * 2); 6675331Samw 6686030Sjb150015 if (smb_decode_mbc(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) { 6696030Sjb150015 disconnect = B_TRUE; 6706030Sjb150015 goto report_error; 6715331Samw } 6725331Samw 6735331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command, 6745331Samw sr->command.chain_offset, sr->smb_bcc); 6755331Samw 6765331Samw sr->command.chain_offset += sr->smb_bcc; 6775331Samw if (sr->command.chain_offset > sr->command.max_bytes) { 6786030Sjb150015 disconnect = B_TRUE; 6796030Sjb150015 goto report_error; 6805331Samw } 6815331Samw 6825331Samw /* Store pointers for later */ 6835331Samw sr->cur_reply_offset = sr->reply.chain_offset; 6845331Samw 6855331Samw if (is_andx_com(sr->smb_com)) { 6865331Samw /* Peek ahead and don't disturb vwv */ 6875331Samw if (smb_peek_mbc(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w", 6885331Samw &sr->andx_com, &sr->andx_off) < 0) { 6896030Sjb150015 disconnect = B_TRUE; 6906030Sjb150015 goto report_error; 6915331Samw } 6925331Samw } else { 6935331Samw sr->andx_com = (unsigned char)-1; 6945331Samw } 6955331Samw 6965331Samw mutex_enter(&sr->sr_mutex); 6975331Samw switch (sr->sr_state) { 6985331Samw case SMB_REQ_STATE_SUBMITTED: 6995331Samw case SMB_REQ_STATE_CLEANED_UP: 7005331Samw sr->sr_state = SMB_REQ_STATE_ACTIVE; 7015331Samw break; 7025331Samw case SMB_REQ_STATE_CANCELED: 7035331Samw break; 7045331Samw default: 7055331Samw ASSERT(0); 7065331Samw break; 7075331Samw } 7085331Samw mutex_exit(&sr->sr_mutex); 7095331Samw 7106030Sjb150015 /* 7116030Sjb150015 * Setup UID and TID information (if required). Both functions 7126030Sjb150015 * will set the sr credentials. In domain mode, the user and 7136030Sjb150015 * tree credentials should be the same. In share mode, the 7146030Sjb150015 * tree credentials (defined in the share definition) should 7156030Sjb150015 * override the user credentials. 7166030Sjb150015 */ 717*6139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) { 7186030Sjb150015 sr->uid_user = smb_user_lookup_by_uid(sr->session, 7196030Sjb150015 &sr->user_cr, sr->smb_uid); 7206030Sjb150015 if (sr->uid_user == NULL) { 7216030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRbaduid); 722*6139Sjb150015 smbsr_cleanup(sr); 7236030Sjb150015 goto report_error; 7245331Samw } 7255331Samw 726*6139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && 727*6139Sjb150015 (sr->tid_tree == NULL)) { 7286030Sjb150015 sr->tid_tree = smb_tree_lookup_by_tid( 7296030Sjb150015 sr->uid_user, sr->smb_tid); 7306030Sjb150015 if (sr->tid_tree == NULL) { 7316030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRinvnid); 732*6139Sjb150015 smbsr_cleanup(sr); 7336030Sjb150015 goto report_error; 7345331Samw } 7355331Samw } 7365331Samw } 7375331Samw 7386030Sjb150015 /* 7396030Sjb150015 * If the command is not a read raw request we can set the 7406030Sjb150015 * state of the session back to SMB_SESSION_STATE_NEGOTIATED 7416030Sjb150015 * (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING). 7426030Sjb150015 * Otherwise we let the read raw handler to deal with it. 7436030Sjb150015 */ 7446030Sjb150015 if ((sr->session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) && 7456030Sjb150015 (sr->smb_com != SMB_COM_READ_RAW)) { 7466030Sjb150015 krw_t mode; 7476030Sjb150015 /* 7486030Sjb150015 * The lock may have to be upgraded because, at this 7496030Sjb150015 * point, we don't know how it was entered. We just 7506030Sjb150015 * know that it has to be entered in writer mode here. 7516030Sjb150015 * Whatever mode was used to enter the lock, it will 7526030Sjb150015 * be restored. 7536030Sjb150015 */ 7546030Sjb150015 mode = smb_rwx_rwupgrade(&sr->session->s_lock); 7556030Sjb150015 if (sr->session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) 7566030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7576030Sjb150015 7586030Sjb150015 smb_rwx_rwdowngrade(&sr->session->s_lock, mode); 7596030Sjb150015 } 7606030Sjb150015 7616030Sjb150015 /* 7626030Sjb150015 * Increment method invocation count. This value is exposed 7636030Sjb150015 * via kstats, and it represents a count of all the dispatched 7646030Sjb150015 * requests, including the ones that have a return value, other 765*6139Sjb150015 * than SDRC_SUCCESS. 7666030Sjb150015 */ 7676030Sjb150015 SMB_ALL_DISPATCH_STAT_INCR(sdd->sdt_dispatch_stats.value.ui64); 7686030Sjb150015 769*6139Sjb150015 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS) 770*6139Sjb150015 sdrc = (*sdd->sdt_function)(sr); 771*6139Sjb150015 772*6139Sjb150015 if (sdrc != SDRC_SUCCESS) { 7736030Sjb150015 /* 7746030Sjb150015 * Handle errors from raw write. 7756030Sjb150015 */ 7766030Sjb150015 if (sr->session->s_state == 7776030Sjb150015 SMB_SESSION_STATE_WRITE_RAW_ACTIVE) { 7786030Sjb150015 /* 7796030Sjb150015 * Set state so that the netbios session 7806030Sjb150015 * daemon will start accepting data again. 7816030Sjb150015 */ 7826030Sjb150015 sr->session->s_write_raw_status = 0; 7836030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7846030Sjb150015 } 7856030Sjb150015 } 7866030Sjb150015 787*6139Sjb150015 (*sdd->sdt_post_op)(sr); 788*6139Sjb150015 7896030Sjb150015 /* 7906030Sjb150015 * Only call smbsr_cleanup if smb->sr_keep is not set. 7916030Sjb150015 * smb_nt_transact_notify_change will set smb->sr_keep if it 7926030Sjb150015 * retains control of the request when it returns. In that 7936030Sjb150015 * case the notify change code will call smbsr_cleanup later 7946030Sjb150015 * when the request has completed. 7956030Sjb150015 */ 7966030Sjb150015 if (sr->sr_keep == 0) 7976030Sjb150015 smbsr_cleanup(sr); 7986030Sjb150015 7996030Sjb150015 switch (sdrc) { 800*6139Sjb150015 case SDRC_SUCCESS: 8016030Sjb150015 break; 8026030Sjb150015 8036030Sjb150015 case SDRC_DROP_VC: 8046030Sjb150015 disconnect = B_TRUE; 8056030Sjb150015 goto drop_connection; 8066030Sjb150015 8076030Sjb150015 case SDRC_NO_REPLY: 8086030Sjb150015 smb_rwx_rwexit(&sr->session->s_lock); 8096030Sjb150015 return; 8106030Sjb150015 811*6139Sjb150015 case SDRC_ERROR: 8126030Sjb150015 goto report_error; 8136030Sjb150015 814*6139Sjb150015 case SDRC_NOT_IMPLEMENTED: 8156030Sjb150015 default: 8166030Sjb150015 smbsr_error(sr, 0, ERRDOS, ERRbadfunc); 8176030Sjb150015 goto report_error; 8186030Sjb150015 } 8196030Sjb150015 8206030Sjb150015 /* 8216030Sjb150015 * If there's no AndX command, we're done. 8226030Sjb150015 */ 8235331Samw if (sr->andx_com == 0xff) 8245331Samw goto reply_ready; 8255331Samw 8266030Sjb150015 /* 8276030Sjb150015 * Otherwise, we have to back-patch the AndXCommand and AndXOffset 8286030Sjb150015 * and continue processing. 8296030Sjb150015 */ 8305331Samw sr->andx_prev_wct = sr->cur_reply_offset; 8315331Samw (void) smb_poke_mbc(&sr->reply, sr->andx_prev_wct + 1, "b.w", 8325331Samw sr->andx_com, MBC_LENGTH(&sr->reply)); 8335331Samw 8345331Samw smb_rwx_rwexit(&sr->session->s_lock); 8355331Samw 8365331Samw sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off; 8375331Samw sr->smb_com = sr->andx_com; 8385331Samw goto andx_more; 8395331Samw 8406030Sjb150015 report_error: 8415331Samw sr->reply.chain_offset = sr->cur_reply_offset; 8425331Samw (void) smb_encode_mbc(&sr->reply, "bw", 0, 0); 8435331Samw 8445331Samw sr->smb_wct = 0; 8455331Samw sr->smb_bcc = 0; 8465331Samw 847*6139Sjb150015 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0) 8486030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 8496030Sjb150015 8506030Sjb150015 reply_ready: 8516030Sjb150015 smbsr_send_reply(sr); 8526030Sjb150015 8536030Sjb150015 drop_connection: 8546030Sjb150015 if (disconnect) { 8556030Sjb150015 switch (sr->session->s_state) { 8566030Sjb150015 case SMB_SESSION_STATE_DISCONNECTED: 8576030Sjb150015 case SMB_SESSION_STATE_TERMINATED: 8586030Sjb150015 break; 8596030Sjb150015 default: 8606030Sjb150015 smb_soshutdown(sr->session->sock); 8616030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_DISCONNECTED; 8626030Sjb150015 break; 8636030Sjb150015 } 8645331Samw } 8656030Sjb150015 8666030Sjb150015 smb_rwx_rwexit(&sr->session->s_lock); 8675331Samw } 8685331Samw 8696030Sjb150015 int 8706030Sjb150015 smbsr_encode_empty_result(struct smb_request *sr) 8716030Sjb150015 { 8726030Sjb150015 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0)); 8736030Sjb150015 } 8745331Samw 8756030Sjb150015 int 8766030Sjb150015 smbsr_encode_result(struct smb_request *sr, int wct, int bcc, char *fmt, ...) 8775331Samw { 8785331Samw va_list ap; 8795331Samw 8806030Sjb150015 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset) 8816030Sjb150015 return (-1); 8825331Samw 8835331Samw va_start(ap, fmt); 8845331Samw (void) smb_mbc_encode(&sr->reply, fmt, ap); 8855331Samw va_end(ap); 8865331Samw 8875331Samw sr->smb_wct = (unsigned char)wct; 8885331Samw sr->smb_bcc = (uint16_t)bcc; 8895331Samw 8906030Sjb150015 if (smbsr_check_result(sr, wct, bcc) != 0) 8916030Sjb150015 return (-1); 8926030Sjb150015 8936030Sjb150015 return (0); 8945331Samw } 8955331Samw 8966030Sjb150015 static int 8975331Samw smbsr_check_result(struct smb_request *sr, int wct, int bcc) 8985331Samw { 8995331Samw int offset = sr->cur_reply_offset; 9005331Samw int total_bytes; 9015331Samw unsigned char temp, temp1; 9025331Samw struct mbuf *m; 9035331Samw 9045331Samw total_bytes = 0; 9055331Samw m = sr->reply.chain; 9065331Samw while (m != 0) { 9075331Samw total_bytes += m->m_len; 9085331Samw m = m->m_next; 9095331Samw } 9105331Samw 9116030Sjb150015 if ((offset + 3) > total_bytes) 9126030Sjb150015 return (-1); 9135331Samw 9145331Samw (void) smb_peek_mbc(&sr->reply, offset, "b", &temp); 9156030Sjb150015 if (temp != wct) 9166030Sjb150015 return (-1); 9175331Samw 9186030Sjb150015 if ((offset + (wct * 2 + 1)) > total_bytes) 9196030Sjb150015 return (-1); 9205331Samw 9215331Samw /* reply wct & vwv seem ok, consider data now */ 9225331Samw offset += wct * 2 + 1; 9235331Samw 9246030Sjb150015 if ((offset + 2) > total_bytes) 9256030Sjb150015 return (-1); 9265331Samw 9275331Samw (void) smb_peek_mbc(&sr->reply, offset, "bb", &temp, &temp1); 9285331Samw if (bcc == VAR_BCC) { 9295331Samw if ((temp != 0xFF) || (temp1 != 0xFF)) { 9306030Sjb150015 return (-1); 9315331Samw } else { 9325331Samw bcc = (total_bytes - offset) - 2; 9335331Samw (void) smb_poke_mbc(&sr->reply, offset, "bb", 9345331Samw bcc, bcc >> 8); 9355331Samw } 9365331Samw } else { 9376030Sjb150015 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF))) 9386030Sjb150015 return (-1); 9395331Samw } 9405331Samw 9415331Samw offset += bcc + 2; 9425331Samw 9436030Sjb150015 if (offset != total_bytes) 9446030Sjb150015 return (-1); 9455331Samw 9465331Samw sr->smb_wct = (unsigned char)wct; 9475331Samw sr->smb_bcc = (uint16_t)bcc; 9486030Sjb150015 return (0); 9495331Samw } 9505331Samw 9515331Samw int 9525331Samw smbsr_decode_vwv(struct smb_request *sr, char *fmt, ...) 9535331Samw { 9545331Samw int rc; 9555331Samw va_list ap; 9565331Samw 9575331Samw va_start(ap, fmt); 9585331Samw rc = smb_mbc_decode(&sr->smb_vwv, fmt, ap); 9595331Samw va_end(ap); 9605331Samw 961*6139Sjb150015 if (rc) 962*6139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9635331Samw return (rc); 9645331Samw } 9655331Samw 9665331Samw int 9675331Samw smbsr_decode_data(struct smb_request *sr, char *fmt, ...) 9685331Samw { 969*6139Sjb150015 int rc; 9705331Samw va_list ap; 971*6139Sjb150015 9725331Samw va_start(ap, fmt); 973*6139Sjb150015 rc = smb_mbc_decode(&sr->smb_data, fmt, ap); 9745331Samw va_end(ap); 975*6139Sjb150015 976*6139Sjb150015 if (rc) 977*6139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 978*6139Sjb150015 return (rc); 9795331Samw } 9805331Samw 9815331Samw void 9825331Samw smbsr_send_reply(struct smb_request *sr) 9835331Samw { 9846030Sjb150015 if (SMB_TREE_CASE_INSENSITIVE(sr)) 9856030Sjb150015 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE; 9866030Sjb150015 else 9876030Sjb150015 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE; 9886030Sjb150015 9895331Samw (void) smb_poke_mbc(&sr->reply, 0, SMB_HEADER_ED_FMT, 9905331Samw sr->first_smb_com, 9915331Samw sr->smb_rcls, 9925331Samw sr->smb_reh, 9935331Samw sr->smb_err, 9945331Samw sr->smb_flg | SMB_FLAGS_REPLY, 9955331Samw sr->smb_flg2, 9965331Samw sr->smb_pid_high, 9975331Samw sr->smb_sig, 9985331Samw sr->smb_tid, 9995331Samw sr->smb_pid, 10005331Samw sr->smb_uid, 10015331Samw sr->smb_mid); 10025331Samw 10035331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 10045331Samw smb_sign_reply(sr, NULL); 10055331Samw 10066030Sjb150015 if (smb_session_send(sr->session, 0, &sr->reply) == 0) 10076030Sjb150015 sr->reply.chain = 0; 10085331Samw } 10095331Samw 10105331Samw /* 10115772Sas200622 * Map errno values to SMB and NT status values. 10125772Sas200622 * Note: ESRCH is a special case to handle a streams lookup failure. 10135331Samw */ 10145331Samw static struct { 10155772Sas200622 int errnum; 10165772Sas200622 int errcls; 10175772Sas200622 int errcode; 10185772Sas200622 DWORD status32; 10195772Sas200622 } smb_errno_map[] = { 10205331Samw { ENOSPC, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10215331Samw { EDQUOT, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10225331Samw { EPERM, ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED }, 10235331Samw { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, 10245331Samw { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, 10255331Samw { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE }, 10265331Samw { ENOTEMPTY, ERRDOS, ERROR_DIR_NOT_EMPTY, 10275331Samw NT_STATUS_DIRECTORY_NOT_EMPTY }, 10285331Samw { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, 10295331Samw { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY }, 10305331Samw { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, 10315331Samw { EXDEV, ERRSRV, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, 10325331Samw { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, 10335331Samw { ESTALE, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, 10345331Samw { EBADF, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, 10355331Samw { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, 10365331Samw { ENXIO, ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE}, 10375331Samw { ESRCH, ERRDOS, ERROR_FILE_NOT_FOUND, 10385331Samw NT_STATUS_OBJECT_NAME_NOT_FOUND }, 10395331Samw /* 10405331Samw * It's not clear why smb_read_common effectively returns 10415331Samw * ERRnoaccess if a range lock prevents access and smb_write_common 10425331Samw * effectively returns ERRaccess. This table entry is used by 10435331Samw * smb_read_common and preserves the behavior that was there before. 10445331Samw */ 10455331Samw { ERANGE, ERRDOS, ERRnoaccess, NT_STATUS_FILE_LOCK_CONFLICT } 10465331Samw }; 10475331Samw 10485331Samw void 10495772Sas200622 smbsr_map_errno(int errnum, smb_error_t *err) 10505331Samw { 10515331Samw int i; 10525331Samw 10535772Sas200622 for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) { 10545772Sas200622 if (smb_errno_map[i].errnum == errnum) { 10555772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10565772Sas200622 err->status = smb_errno_map[i].status32; 10575772Sas200622 err->errcls = smb_errno_map[i].errcls; 10585772Sas200622 err->errcode = smb_errno_map[i].errcode; 10595772Sas200622 return; 10605331Samw } 10615331Samw } 10625331Samw 10635772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10645772Sas200622 err->status = NT_STATUS_INTERNAL_ERROR; 10655772Sas200622 err->errcls = ERRDOS; 10665772Sas200622 err->errcode = ERROR_INTERNAL_ERROR; 10675331Samw } 10685331Samw 10695331Samw void 10705772Sas200622 smbsr_errno(struct smb_request *sr, int errnum) 10715772Sas200622 { 10726030Sjb150015 smbsr_map_errno(errnum, &sr->smb_error); 10736030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10745772Sas200622 } 10755772Sas200622 10765772Sas200622 /* 10775772Sas200622 * Report a request processing warning. 10785772Sas200622 */ 10795772Sas200622 void 10805772Sas200622 smbsr_warn(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10815772Sas200622 { 10826030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_WARNING; 10836030Sjb150015 sr->smb_error.status = status; 10846030Sjb150015 sr->smb_error.errcls = errcls; 10856030Sjb150015 sr->smb_error.errcode = errcode; 10865772Sas200622 10876030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10885772Sas200622 } 10895772Sas200622 10905772Sas200622 /* 10915772Sas200622 * Report a request processing error. This function will not return. 10925772Sas200622 */ 10935772Sas200622 void 10945772Sas200622 smbsr_error(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10955331Samw { 10966030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_ERROR; 10976030Sjb150015 sr->smb_error.status = status; 10986030Sjb150015 sr->smb_error.errcls = errcls; 10996030Sjb150015 sr->smb_error.errcode = errcode; 11005772Sas200622 11016030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 11025772Sas200622 } 11035772Sas200622 11045772Sas200622 /* 11055772Sas200622 * Setup a request processing error. This function can be used to 11065772Sas200622 * report 32-bit status codes or DOS errors. Set the status code 11075772Sas200622 * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error, 11085772Sas200622 * regardless of the client capabilities. 11095772Sas200622 * 11105772Sas200622 * If status is non-zero and the client supports 32-bit status 11115772Sas200622 * codes, report the status. Otherwise, report the DOS error. 11125772Sas200622 */ 11135772Sas200622 void 11145772Sas200622 smbsr_set_error(smb_request_t *sr, smb_error_t *err) 11155772Sas200622 { 11165772Sas200622 uint32_t status; 11175772Sas200622 uint32_t severity; 11185772Sas200622 uint32_t capabilities; 11195772Sas200622 11205772Sas200622 ASSERT(sr); 11215772Sas200622 ASSERT(err); 11225772Sas200622 11235772Sas200622 status = err->status; 11245772Sas200622 severity = (err->severity == 0) ? ERROR_SEVERITY_ERROR : err->severity; 11255772Sas200622 capabilities = sr->session->capabilities; 11265772Sas200622 11275772Sas200622 if ((err->errcls == 0) && (err->errcode == 0)) { 11285772Sas200622 capabilities |= CAP_STATUS32; 11295772Sas200622 if (status == 0) 11305772Sas200622 status = NT_STATUS_INTERNAL_ERROR; 11315772Sas200622 } 11325772Sas200622 11335772Sas200622 if ((capabilities & CAP_STATUS32) && (status != 0)) { 11345772Sas200622 status |= severity; 11355772Sas200622 sr->smb_rcls = status & 0xff; 11365772Sas200622 sr->smb_reh = (status >> 8) & 0xff; 11375772Sas200622 sr->smb_err = status >> 16; 11385772Sas200622 sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS; 11395772Sas200622 } else { 11405772Sas200622 if ((err->errcls == 0) || (err->errcode == 0)) { 11415772Sas200622 sr->smb_rcls = ERRSRV; 11425772Sas200622 sr->smb_err = ERRerror; 11435772Sas200622 } else { 11445772Sas200622 sr->smb_rcls = (uint8_t)err->errcls; 11455772Sas200622 sr->smb_err = (uint16_t)err->errcode; 11465331Samw } 11475331Samw } 11485331Samw } 11495331Samw 11505331Samw smb_xa_t * 11515331Samw smbsr_lookup_xa(smb_request_t *sr) 11525331Samw { 11535331Samw ASSERT(sr->r_xa == 0); 11545331Samw 11555331Samw sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid); 11565331Samw return (sr->r_xa); 11575331Samw } 11585331Samw 11595331Samw void 11605331Samw smbsr_disconnect_file(smb_request_t *sr) 11615331Samw { 11625331Samw smb_ofile_t *of = sr->fid_ofile; 11635331Samw 11645331Samw sr->fid_ofile = NULL; 11655331Samw (void) smb_ofile_release(of); 11665331Samw } 11675331Samw 11685331Samw void 11695331Samw smbsr_disconnect_dir(smb_request_t *sr) 11705331Samw { 11715331Samw smb_odir_t *od = sr->sid_odir; 11725331Samw 11735331Samw sr->sid_odir = NULL; 11745331Samw smb_odir_release(od); 11755331Samw } 11765331Samw 11775331Samw static int 11785331Samw is_andx_com(unsigned char com) 11795331Samw { 11805331Samw switch (com) { 11815331Samw case SMB_COM_LOCKING_ANDX: 11825331Samw case SMB_COM_OPEN_ANDX: 11835331Samw case SMB_COM_READ_ANDX: 11845331Samw case SMB_COM_WRITE_ANDX: 11855331Samw case SMB_COM_SESSION_SETUP_ANDX: 11865331Samw case SMB_COM_LOGOFF_ANDX: 11875331Samw case SMB_COM_TREE_CONNECT_ANDX: 11885331Samw case SMB_COM_NT_CREATE_ANDX: 11895331Samw return (1); 11905331Samw } 11915331Samw return (0); 11925331Samw } 11935331Samw 11945331Samw /* 1195*6139Sjb150015 * Invalid command stubs. 1196*6139Sjb150015 * 1197*6139Sjb150015 * SmbWriteComplete is sent to acknowledge completion of raw write requests. 1198*6139Sjb150015 * We never send raw write commands to other servers so, if we receive 1199*6139Sjb150015 * SmbWriteComplete, we treat it as an error. 1200*6139Sjb150015 * 1201*6139Sjb150015 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize 1202*6139Sjb150015 * performance when reading/writing a large block of data: it can be 1203*6139Sjb150015 * used in parallel with other client/server operations. The mpx sub- 1204*6139Sjb150015 * protocol is not supported because we support only connection oriented 1205*6139Sjb150015 * transports and NT supports mpx only over connectionless transports. 12065331Samw */ 12076030Sjb150015 smb_sdrc_t 1208*6139Sjb150015 smb_pre_invalid(smb_request_t *sr) 1209*6139Sjb150015 { 1210*6139Sjb150015 DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr); 1211*6139Sjb150015 return (SDRC_SUCCESS); 1212*6139Sjb150015 } 1213*6139Sjb150015 1214*6139Sjb150015 void 1215*6139Sjb150015 smb_post_invalid(smb_request_t *sr) 1216*6139Sjb150015 { 1217*6139Sjb150015 DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr); 1218*6139Sjb150015 } 1219*6139Sjb150015 1220*6139Sjb150015 smb_sdrc_t 1221*6139Sjb150015 smb_com_invalid(smb_request_t *sr) 12225331Samw { 1223*6139Sjb150015 smb_sdrc_t sdrc; 1224*6139Sjb150015 1225*6139Sjb150015 switch (sr->smb_com) { 1226*6139Sjb150015 case SMB_COM_WRITE_COMPLETE: 1227*6139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 1228*6139Sjb150015 sdrc = SDRC_ERROR; 1229*6139Sjb150015 break; 1230*6139Sjb150015 1231*6139Sjb150015 default: 1232*6139Sjb150015 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED, 1233*6139Sjb150015 ERRDOS, ERROR_INVALID_FUNCTION); 1234*6139Sjb150015 sdrc = SDRC_NOT_IMPLEMENTED; 1235*6139Sjb150015 break; 1236*6139Sjb150015 } 1237*6139Sjb150015 1238*6139Sjb150015 return (sdrc); 12395331Samw } 12405331Samw 12415331Samw /* 1242*6139Sjb150015 * smb_dispatch_kstat_update 12435331Samw * 12445331Samw * This callback function updates the smb_dispatch_kstat_data when kstat 12455331Samw * command is invoked. 12465331Samw */ 12475331Samw static int 1248*6139Sjb150015 smb_dispatch_kstat_update(kstat_t *ksp, int rw) 12495331Samw { 1250*6139Sjb150015 smb_dispatch_table_t *sdd; 1251*6139Sjb150015 kstat_named_t *ks_named; 1252*6139Sjb150015 int i; 12535331Samw 1254*6139Sjb150015 if (rw == KSTAT_WRITE) 12555331Samw return (EACCES); 1256*6139Sjb150015 1257*6139Sjb150015 ASSERT(MUTEX_HELD(ksp->ks_lock)); 1258*6139Sjb150015 1259*6139Sjb150015 ks_named = ksp->ks_data; 1260*6139Sjb150015 for (i = 0; i < SMB_COM_NUM; i++) { 1261*6139Sjb150015 sdd = &dispatch[i]; 1262*6139Sjb150015 1263*6139Sjb150015 if (sdd->sdt_function != smb_com_invalid) { 1264*6139Sjb150015 bcopy(&sdd->sdt_dispatch_stats, ks_named, 1265*6139Sjb150015 sizeof (kstat_named_t)); 1266*6139Sjb150015 ++ks_named; 12675331Samw } 12685331Samw } 1269*6139Sjb150015 12705331Samw return (0); 12715331Samw } 12725331Samw 12735331Samw /* 1274*6139Sjb150015 * smb_dispatch_kstat_init 12755331Samw * 12765331Samw * Initialize dispatch kstats. 12775331Samw */ 12785331Samw void 1279*6139Sjb150015 smb_dispatch_kstat_init(void) 12805331Samw { 1281*6139Sjb150015 int ks_ndata; 1282*6139Sjb150015 int i; 12835331Samw 1284*6139Sjb150015 for (i = 0, ks_ndata = 0; i < SMB_COM_NUM; i++) { 1285*6139Sjb150015 if (dispatch[i].sdt_function != smb_com_invalid) 1286*6139Sjb150015 ks_ndata++; 12875331Samw } 12885331Samw 1289*6139Sjb150015 smb_dispatch_ksp = kstat_create("smb", 0, "smb_dispatch_all", "misc", 1290*6139Sjb150015 KSTAT_TYPE_NAMED, ks_ndata, 0); 12915331Samw 12925331Samw if (smb_dispatch_ksp) { 1293*6139Sjb150015 mutex_init(&smb_dispatch_ksmtx, NULL, MUTEX_DEFAULT, NULL); 1294*6139Sjb150015 smb_dispatch_ksp->ks_update = smb_dispatch_kstat_update; 1295*6139Sjb150015 smb_dispatch_ksp->ks_lock = &smb_dispatch_ksmtx; 12965331Samw kstat_install(smb_dispatch_ksp); 12975331Samw } 12985331Samw } 12995331Samw 13005331Samw /* 1301*6139Sjb150015 * smb_dispatch_kstat_fini 13025331Samw * 13035331Samw * Remove dispatch kstats. 13045331Samw */ 13055331Samw void 1306*6139Sjb150015 smb_dispatch_kstat_fini(void) 13075331Samw { 13085331Samw if (smb_dispatch_ksp != NULL) { 13095331Samw kstat_delete(smb_dispatch_ksp); 1310*6139Sjb150015 mutex_destroy(&smb_dispatch_ksmtx); 13115331Samw smb_dispatch_ksp = NULL; 13125331Samw } 13135331Samw } 1314