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> 1446432Sas200622 #include <smbsrv/smb_kstat.h> 1455331Samw #include <sys/sdt.h> 1465331Samw 1475331Samw #define SMB_ALL_DISPATCH_STAT_INCR(stat) atomic_inc_64(&stat); 1486139Sjb150015 #define SMB_COM_NUM 256 1495331Samw 1505331Samw static kstat_t *smb_dispatch_ksp = NULL; 1516139Sjb150015 static kmutex_t smb_dispatch_ksmtx; 1525331Samw 1536030Sjb150015 static int is_andx_com(unsigned char); 1546030Sjb150015 static int smbsr_check_result(struct smb_request *, int, int); 1555331Samw 1566139Sjb150015 static smb_dispatch_table_t dispatch[SMB_COM_NUM] = { 1576139Sjb150015 { SMB_SDT_OPS(create_directory), /* 0x00 000 */ 1586139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1595331Samw { "SmbCreateDirectory", KSTAT_DATA_UINT64 } }, 1606139Sjb150015 { SMB_SDT_OPS(delete_directory), /* 0x01 001 */ 1616139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1625331Samw { "SmbDeleteDirectory", KSTAT_DATA_UINT64 } }, 1636139Sjb150015 { SMB_SDT_OPS(open), /* 0x02 002 */ 1646139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1655331Samw { "SmbOpen", KSTAT_DATA_UINT64 } }, 1666139Sjb150015 { SMB_SDT_OPS(create), /* 0x03 003 */ 1676139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1685331Samw { "SmbCreate", KSTAT_DATA_UINT64 } }, 1696139Sjb150015 { SMB_SDT_OPS(close), /* 0x04 004 */ 1706139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1715331Samw { "SmbClose", KSTAT_DATA_UINT64 } }, 1726139Sjb150015 { SMB_SDT_OPS(flush), /* 0x05 005 */ 1736139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1745331Samw { "SmbFlush", KSTAT_DATA_UINT64 } }, 1756139Sjb150015 { SMB_SDT_OPS(delete), /* 0x06 006 */ 1766139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1775331Samw { "SmbDelete", KSTAT_DATA_UINT64 } }, 1786139Sjb150015 { SMB_SDT_OPS(rename), /* 0x07 007 */ 1796139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1805331Samw { "SmbRename", KSTAT_DATA_UINT64 } }, 1816139Sjb150015 { SMB_SDT_OPS(query_information), /* 0x08 008 */ 1826139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1835331Samw { "SmbQueryInformation", KSTAT_DATA_UINT64 } }, 1846139Sjb150015 { SMB_SDT_OPS(set_information), /* 0x09 009 */ 1856139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1865331Samw { "SmbSetInformation", KSTAT_DATA_UINT64 } }, 1876139Sjb150015 { SMB_SDT_OPS(read), /* 0x0A 010 */ 1886139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1895331Samw { "SmbRead", KSTAT_DATA_UINT64 } }, 1906139Sjb150015 { SMB_SDT_OPS(write), /* 0x0B 011 */ 1916139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1925331Samw { "SmbWrite", KSTAT_DATA_UINT64 } }, 1936139Sjb150015 { SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */ 1946139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1955331Samw { "SmbLockByteRange", KSTAT_DATA_UINT64 } }, 1966139Sjb150015 { SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */ 1976139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1985331Samw { "SmbUnlockByteRange", KSTAT_DATA_UINT64 } }, 1996139Sjb150015 { SMB_SDT_OPS(create_temporary), /* 0x0E 014 */ 2006139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2015331Samw { "SmbCreateTemporary", KSTAT_DATA_UINT64 } }, 2026139Sjb150015 { SMB_SDT_OPS(create_new), /* 0x0F 015 */ 2036139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2045331Samw { "SmbCreateNew", KSTAT_DATA_UINT64 } }, 2056139Sjb150015 { SMB_SDT_OPS(check_directory), /* 0x10 016 */ 2066139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2075331Samw { "SmbCheckDirectory", KSTAT_DATA_UINT64 } }, 2086139Sjb150015 { SMB_SDT_OPS(process_exit), /* 0x11 017 */ 2095331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2105331Samw RW_READER, 2115331Samw { "SmbProcessExit", KSTAT_DATA_UINT64 } }, 2126139Sjb150015 { SMB_SDT_OPS(seek), /* 0x12 018 */ 2136139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2145331Samw { "SmbSeek", KSTAT_DATA_UINT64 } }, 2156139Sjb150015 { SMB_SDT_OPS(lock_and_read), /* 0x13 019 */ 2166139Sjb150015 LANMAN1_0, 0, RW_READER, 2175331Samw { "SmbLockAndRead", KSTAT_DATA_UINT64 } }, 2186139Sjb150015 { SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */ 2196139Sjb150015 LANMAN1_0, 0, RW_READER, 2205331Samw { "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } }, 2216139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x15 021 */ 2226139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x16 022 */ 2236139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x17 023 */ 2246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x18 024 */ 2256139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x19 025 */ 2266139Sjb150015 { SMB_SDT_OPS(read_raw), /* 0x1A 026 */ 2276139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2285331Samw { "SmbReadRaw", KSTAT_DATA_UINT64 } }, 2296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1B 027 */ 2306139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1C 028 */ 2316139Sjb150015 { SMB_SDT_OPS(write_raw), /* 0x1D 029 */ 2326139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2335331Samw { "SmbWriteRaw", KSTAT_DATA_UINT64 } }, 2346139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1E 030 */ 2356139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1F 031 */ 2366139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x20 032 */ 2376139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x21 033 */ 2386139Sjb150015 { SMB_SDT_OPS(set_information2), /* 0x22 034 */ 2396139Sjb150015 LANMAN1_0, 0, RW_READER, 2405331Samw { "SmbSetInformation2", KSTAT_DATA_UINT64 } }, 2416139Sjb150015 { SMB_SDT_OPS(query_information2), /* 0x23 035 */ 2426139Sjb150015 LANMAN1_0, 0, RW_READER, 2435331Samw { "SmbQueryInformation2", KSTAT_DATA_UINT64 } }, 2446139Sjb150015 { SMB_SDT_OPS(locking_andx), /* 0x24 036 */ 2456139Sjb150015 LANMAN1_0, 0, RW_READER, 2465331Samw { "SmbLockingX", KSTAT_DATA_UINT64 } }, 2476139Sjb150015 { SMB_SDT_OPS(transaction), /* 0x25 037 */ 2486139Sjb150015 LANMAN1_0, 0, RW_READER, 2495331Samw { "SmbTransaction", KSTAT_DATA_UINT64 } }, 2506139Sjb150015 { SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */ 2516139Sjb150015 LANMAN1_0, 0, RW_READER, 2525331Samw { "SmbTransactionSecondary", KSTAT_DATA_UINT64 } }, 2536139Sjb150015 { SMB_SDT_OPS(ioctl), /* 0x27 039 */ 2546139Sjb150015 LANMAN1_0, 0, RW_READER, 2555331Samw { "SmbIoctl", KSTAT_DATA_UINT64 } }, 2566139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x28 040 */ 2576139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x29 041 */ 2586139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x2A 042 */ 2596139Sjb150015 { SMB_SDT_OPS(echo), /* 0x2B 043 */ 2605331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2615331Samw RW_READER, 2625331Samw { "SmbEcho", KSTAT_DATA_UINT64 } }, 2636139Sjb150015 { SMB_SDT_OPS(write_and_close), /* 0x2C 044 */ 2646139Sjb150015 LANMAN1_0, 0, RW_READER, 2655331Samw { "SmbWriteAndClose", KSTAT_DATA_UINT64 } }, 2666139Sjb150015 { SMB_SDT_OPS(open_andx), /* 0x2D 045 */ 2676139Sjb150015 LANMAN1_0, 0, RW_READER, 2685331Samw { "SmbOpenX", KSTAT_DATA_UINT64 } }, 2696139Sjb150015 { SMB_SDT_OPS(read_andx), /* 0x2E 046 */ 2706139Sjb150015 LANMAN1_0, 0, RW_READER, 2715331Samw { "SmbReadX", KSTAT_DATA_UINT64 } }, 2726139Sjb150015 { SMB_SDT_OPS(write_andx), /* 0x2F 047 */ 2736139Sjb150015 LANMAN1_0, 0, RW_READER, 2745331Samw { "SmbWriteX", KSTAT_DATA_UINT64 } }, 2756139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x30 048 */ 2766139Sjb150015 { SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */ 2776139Sjb150015 LANMAN1_0, 0, RW_READER, 2785331Samw { "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } }, 2796139Sjb150015 { SMB_SDT_OPS(transaction2), /* 0x32 050 */ 2806139Sjb150015 LM1_2X002, 0, RW_READER, 2815331Samw { "SmbTransaction2", KSTAT_DATA_UINT64 } }, 2826139Sjb150015 { SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */ 2836139Sjb150015 LM1_2X002, 0, RW_READER, 2845331Samw { "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } }, 2856139Sjb150015 { SMB_SDT_OPS(find_close2), /* 0x34 052 */ 2866139Sjb150015 LM1_2X002, 0, RW_READER, 2875331Samw { "SmbFindClose2", KSTAT_DATA_UINT64 } }, 2886139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x35 053 */ 2896139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x36 054 */ 2906139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x37 055 */ 2916139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x38 056 */ 2926139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x39 057 */ 2936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3A 058 */ 2946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3B 059 */ 2956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3C 060 */ 2966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3D 061 */ 2976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3E 062 */ 2986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3F 063 */ 2996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x40 064 */ 3006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x41 065 */ 3016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x42 066 */ 3026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x43 067 */ 3036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x44 068 */ 3046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x45 069 */ 3056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x46 070 */ 3066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x47 071 */ 3076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x48 072 */ 3086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x49 073 */ 3096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4A 074 */ 3106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4B 075 */ 3116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4C 076 */ 3126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4D 077 */ 3136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4E 078 */ 3146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4F 079 */ 3156139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x50 080 */ 3166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x51 081 */ 3176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x52 082 */ 3186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x53 083 */ 3196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x54 084 */ 3206139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x55 085 */ 3216139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x56 086 */ 3226139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x57 087 */ 3236139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x58 088 */ 3246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x59 089 */ 3256139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5A 090 */ 3266139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5B 091 */ 3276139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5C 092 */ 3286139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5D 093 */ 3296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5E 094 */ 3306139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5F 095 */ 3316139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x60 096 */ 3326139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x61 097 */ 3336139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x62 098 */ 3346139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x63 099 */ 3356139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x64 100 */ 3366139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x65 101 */ 3376139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x66 102 */ 3386139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x67 103 */ 3396139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x68 104 */ 3406139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x69 105 */ 3416139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6A 106 */ 3426139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6B 107 */ 3436139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6C 108 */ 3446139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6D 109 */ 3456139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6E 110 */ 3466139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6F 111 */ 3476139Sjb150015 { SMB_SDT_OPS(tree_connect), /* 0x70 112 */ 3486139Sjb150015 PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID, RW_READER, 3495331Samw { "SmbTreeConnect", KSTAT_DATA_UINT64 } }, 3506139Sjb150015 { SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */ 3515331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3525331Samw RW_READER, 3535331Samw { "SmbTreeDisconnect", KSTAT_DATA_UINT64 } }, 3546139Sjb150015 { SMB_SDT_OPS(negotiate), /* 0x72 114 */ 3555331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3565331Samw RW_WRITER, 3575331Samw { "SmbNegotiate", KSTAT_DATA_UINT64 } }, 3586139Sjb150015 { SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */ 3595331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3605331Samw RW_READER, 3615331Samw { "SmbSessionSetupX", KSTAT_DATA_UINT64 } }, 3626139Sjb150015 { SMB_SDT_OPS(logoff_andx), /* 0x74 116 */ 3636139Sjb150015 LM1_2X002, SDDF_SUPPRESS_TID, RW_READER, 3645331Samw { "SmbLogoffX", KSTAT_DATA_UINT64 } }, 3656139Sjb150015 { SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */ 3666139Sjb150015 LANMAN1_0, SDDF_SUPPRESS_TID, RW_READER, 3675331Samw { "SmbTreeConnectX", KSTAT_DATA_UINT64 } }, 3686139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x76 118 */ 3696139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x77 119 */ 3706139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x78 120 */ 3716139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x79 121 */ 3726139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7A 122 */ 3736139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7B 123 */ 3746139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7C 124 */ 3756139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7D 125 */ 3766139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7E 126 */ 3776139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7F 127 */ 3786139Sjb150015 { SMB_SDT_OPS(query_information_disk), /* 0x80 128 */ 3796139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3805331Samw { "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } }, 3816139Sjb150015 { SMB_SDT_OPS(search), /* 0x81 129 */ 3826139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3835331Samw { "SmbSearch", KSTAT_DATA_UINT64 } }, 3846139Sjb150015 { SMB_SDT_OPS(find), /* 0x82 130 */ 3856139Sjb150015 LANMAN1_0, 0, RW_READER, 3865331Samw { "SmbFind", KSTAT_DATA_UINT64 } }, 3876139Sjb150015 { SMB_SDT_OPS(find_unique), /* 0x83 131 */ 3886139Sjb150015 LANMAN1_0, 0, RW_READER, 3895331Samw { "SmbFindUnique", KSTAT_DATA_UINT64 } }, 3906139Sjb150015 { SMB_SDT_OPS(find_close), /* 0x84 132 */ 3916139Sjb150015 LANMAN1_0, 0, RW_READER, 3925331Samw { "SmbFindClose", KSTAT_DATA_UINT64 } }, 3936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x85 133 */ 3946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x86 134 */ 3956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x87 135 */ 3966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x88 136 */ 3976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x89 137 */ 3986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8A 138 */ 3996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8B 139 */ 4006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8C 140 */ 4016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8D 141 */ 4026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8E 142 */ 4036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8F 143 */ 4046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x90 144 */ 4056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x91 145 */ 4066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x92 146 */ 4076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x93 147 */ 4086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x94 148 */ 4096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x95 149 */ 4106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x96 150 */ 4116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x97 151 */ 4126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x98 152 */ 4136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x99 153 */ 4146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9A 154 */ 4156139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9B 155 */ 4166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9C 156 */ 4176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9D 157 */ 4186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9E 158 */ 4196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9F 159 */ 4206139Sjb150015 { SMB_SDT_OPS(nt_transact), /* 0xA0 160 */ 4216139Sjb150015 NT_LM_0_12, 0, RW_READER, 4225331Samw { "SmbNtTransact", KSTAT_DATA_UINT64 } }, 4236139Sjb150015 { SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */ 4246139Sjb150015 NT_LM_0_12, 0, RW_READER, 4255331Samw { "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } }, 4266139Sjb150015 { SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */ 4276139Sjb150015 NT_LM_0_12, 0, RW_READER, 4285331Samw { "SmbNtCreateX", KSTAT_DATA_UINT64 } }, 4296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA3 163 */ 4306139Sjb150015 { SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */ 4316139Sjb150015 NT_LM_0_12, 0, RW_READER, 4325331Samw { "SmbNtCancel", KSTAT_DATA_UINT64 } }, 4336139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA5 165 */ 4346139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA6 166 */ 4356139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA7 167 */ 4366139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA8 168 */ 4376139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA9 169 */ 4386139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAA 170 */ 4396139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAB 171 */ 4406139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAC 172 */ 4416139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAD 173 */ 4426139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAE 174 */ 4436139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAF 175 */ 4446139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB0 176 */ 4456139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB1 177 */ 4466139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB2 178 */ 4476139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB3 179 */ 4486139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB4 180 */ 4496139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB5 181 */ 4506139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB6 182 */ 4516139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB7 183 */ 4526139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB8 184 */ 4536139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB9 185 */ 4546139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBA 186 */ 4556139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBB 187 */ 4566139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBC 188 */ 4576139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBD 189 */ 4586139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBE 190 */ 4596139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBF 191 */ 4606139Sjb150015 { SMB_SDT_OPS(open_print_file), /* 0xC0 192 */ 4616139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4625331Samw { "SmbOpenPrintFile", KSTAT_DATA_UINT64 } }, 4636139Sjb150015 { SMB_SDT_OPS(write_print_file), /* 0xC1 193 */ 4646139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4655331Samw { "SmbWritePrintFile", KSTAT_DATA_UINT64 } }, 4666139Sjb150015 { SMB_SDT_OPS(close_print_file), /* 0xC2 194 */ 4676139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4685331Samw { "SmbClosePrintFile", KSTAT_DATA_UINT64 } }, 4696139Sjb150015 { SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */ 4706139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4715331Samw { "SmbGetPrintQueue", KSTAT_DATA_UINT64 } }, 4726139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC4 196 */ 4736139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC5 197 */ 4746139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC6 198 */ 4756139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC7 199 */ 4766139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC8 200 */ 4776139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC9 201 */ 4786139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCA 202 */ 4796139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCB 203 */ 4806139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCC 204 */ 4816139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCD 205 */ 4826139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCE 206 */ 4836139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCF 207 */ 4846139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD0 208 */ 4856139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD1 209 */ 4866139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD2 210 */ 4876139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD3 211 */ 4886139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD4 212 */ 4896139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD5 213 */ 4906139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD6 214 */ 4916139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD7 215 */ 4926139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD8 216 */ 4936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD9 217 */ 4946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDA 218 */ 4956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDB 219 */ 4966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDC 220 */ 4976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDD 221 */ 4986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDE 222 */ 4996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDF 223 */ 5006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE0 224 */ 5016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE1 225 */ 5026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE2 226 */ 5036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE3 227 */ 5046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE4 228 */ 5056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE5 229 */ 5066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE6 230 */ 5076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE7 231 */ 5086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE8 232 */ 5096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE9 233 */ 5106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEA 234 */ 5116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEB 235 */ 5126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEC 236 */ 5136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xED 237 */ 5146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEE 238 */ 5156139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEF 239 */ 5166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF0 240 */ 5176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF1 241 */ 5186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF2 242 */ 5196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF3 243 */ 5206139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF4 244 */ 5216139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF5 245 */ 5226139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF6 246 */ 5236139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF7 247 */ 5246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF8 248 */ 5256139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF9 249 */ 5266139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFA 250 */ 5276139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFB 251 */ 5286139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFC 252 */ 5296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFD 253 */ 5306139Sjb150015 { SMB_SDT_OPS(invalid), LANMAN1_0, 0, RW_READER, /* 0xFE 254 */ 5315331Samw { "SmbInvalidCommand", KSTAT_DATA_UINT64 } }, 5326139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 } /* 0xFF 255 */ 5335331Samw }; 5345331Samw 5355331Samw /* 5365331Samw * smbsr_cleanup 5375331Samw * 5385331Samw * If any user/tree/file is used by given request then 5395331Samw * the reference count for that resource has been incremented. 5405331Samw * This function decrements the reference count and close 5415331Samw * the resource if it's needed. 5425331Samw */ 5435331Samw 5445331Samw void 5456139Sjb150015 smbsr_cleanup(smb_request_t *sr) 5465331Samw { 5475331Samw ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) && 5485331Samw (sr->sr_state != SMB_REQ_STATE_COMPLETED)); 5495331Samw 5505331Samw if (sr->fid_ofile) 5515331Samw smbsr_disconnect_file(sr); 5525331Samw 5535331Samw if (sr->sid_odir) 5545331Samw smbsr_disconnect_dir(sr); 5555331Samw 5565331Samw if (sr->r_xa) { 5575331Samw if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE) 5585331Samw smb_xa_close(sr->r_xa); 5595331Samw smb_xa_rele(sr->session, sr->r_xa); 5605331Samw sr->r_xa = NULL; 5615331Samw } 5625331Samw 5635331Samw /* 5645331Samw * Mark this request so we know that we've already cleaned it up. 5655331Samw * A request should only get cleaned up once so multiple calls to 5665331Samw * smbsr_cleanup for the same request indicate a bug. 5675331Samw */ 5685331Samw mutex_enter(&sr->sr_mutex); 5695331Samw if (sr->sr_state != SMB_REQ_STATE_CANCELED) 5705331Samw sr->sr_state = SMB_REQ_STATE_CLEANED_UP; 5715331Samw mutex_exit(&sr->sr_mutex); 5725331Samw } 5735331Samw 5746030Sjb150015 void 5755331Samw smb_dispatch_request(struct smb_request *sr) 5765331Samw { 5776030Sjb150015 smb_sdrc_t sdrc; 5785331Samw smb_dispatch_table_t *sdd; 5796030Sjb150015 boolean_t disconnect = B_FALSE; 5805331Samw 5815331Samw ASSERT(sr->tid_tree == 0); 5825331Samw ASSERT(sr->uid_user == 0); 5835331Samw ASSERT(sr->fid_ofile == 0); 5845331Samw ASSERT(sr->sid_odir == 0); 5855331Samw sr->smb_fid = (uint16_t)-1; 5865331Samw sr->smb_sid = (uint16_t)-1; 5875331Samw 5885331Samw /* temporary until we identify a user */ 5895331Samw sr->user_cr = kcred; 5905331Samw sr->orig_request_hdr = sr->command.chain_offset; 5915331Samw 5925331Samw /* If this connection is shutting down just kill request */ 593*7052Samw if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT, 5945331Samw &sr->smb_com, 5955331Samw &sr->smb_rcls, 5965331Samw &sr->smb_reh, 5975331Samw &sr->smb_err, 5985331Samw &sr->smb_flg, 5995331Samw &sr->smb_flg2, 6005331Samw &sr->smb_pid_high, 6015331Samw sr->smb_sig, 6025331Samw &sr->smb_tid, 6035331Samw &sr->smb_pid, 6045331Samw &sr->smb_uid, 6055331Samw &sr->smb_mid) != 0) { 6066030Sjb150015 disconnect = B_TRUE; 6076030Sjb150015 goto drop_connection; 6085331Samw } 6095331Samw 6105331Samw /* 6116030Sjb150015 * The reply "header" is filled in now even though it will, 6126030Sjb150015 * most likely, be rewritten under reply_ready below. We 6136030Sjb150015 * could reserve the space but this is convenient in case 6146030Sjb150015 * the dialect dispatcher has to send a special reply (like 6156030Sjb150015 * TRANSACT). 6165331Samw * 6175331Samw * Ensure that the 32-bit error code flag is turned off. 6185331Samw * Clients seem to set it in transact requests and they may 6195331Samw * get confused if we return success or a 16-bit SMB code. 6205331Samw */ 6215331Samw sr->smb_rcls = 0; 6225331Samw sr->smb_reh = 0; 6235331Samw sr->smb_err = 0; 6245331Samw sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS; 6255331Samw 626*7052Samw (void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT, 6275331Samw sr->smb_com, 6285331Samw sr->smb_rcls, 6295331Samw sr->smb_reh, 6305331Samw sr->smb_err, 6315331Samw sr->smb_flg, 6325331Samw sr->smb_flg2, 6335331Samw sr->smb_pid_high, 6345331Samw sr->smb_sig, 6355331Samw sr->smb_tid, 6365331Samw sr->smb_pid, 6375331Samw sr->smb_uid, 6385331Samw sr->smb_mid); 6395331Samw sr->first_smb_com = sr->smb_com; 6405331Samw 6415331Samw /* 6425772Sas200622 * Verify SMB signature if signing is enabled, dialect is NT LM 0.12, 6435331Samw * signing was negotiated and authentication has occurred. 6445331Samw */ 6455331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) { 6465331Samw if (smb_sign_check_request(sr) != 0) { 6476030Sjb150015 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 6486030Sjb150015 ERRDOS, ERROR_ACCESS_DENIED); 6496030Sjb150015 disconnect = B_TRUE; 6505331Samw smb_rwx_rwenter(&sr->session->s_lock, RW_READER); 6516030Sjb150015 goto report_error; 6525331Samw } 6535331Samw } 6545331Samw 6555331Samw andx_more: 6565331Samw sdd = &dispatch[sr->smb_com]; 6576139Sjb150015 ASSERT(sdd->sdt_function); 6585331Samw 6595331Samw smb_rwx_rwenter(&sr->session->s_lock, sdd->sdt_slock_mode); 6605331Samw 661*7052Samw if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) { 6626030Sjb150015 disconnect = B_TRUE; 6636030Sjb150015 goto report_error; 6645331Samw } 6655331Samw 6665331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command, 6675331Samw sr->command.chain_offset, sr->smb_wct * 2); 6685331Samw 669*7052Samw if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) { 6706030Sjb150015 disconnect = B_TRUE; 6716030Sjb150015 goto report_error; 6725331Samw } 6735331Samw 6745331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command, 6755331Samw sr->command.chain_offset, sr->smb_bcc); 6765331Samw 6775331Samw sr->command.chain_offset += sr->smb_bcc; 6785331Samw if (sr->command.chain_offset > sr->command.max_bytes) { 6796030Sjb150015 disconnect = B_TRUE; 6806030Sjb150015 goto report_error; 6815331Samw } 6825331Samw 6835331Samw /* Store pointers for later */ 6845331Samw sr->cur_reply_offset = sr->reply.chain_offset; 6855331Samw 6865331Samw if (is_andx_com(sr->smb_com)) { 6875331Samw /* Peek ahead and don't disturb vwv */ 688*7052Samw if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w", 6895331Samw &sr->andx_com, &sr->andx_off) < 0) { 6906030Sjb150015 disconnect = B_TRUE; 6916030Sjb150015 goto report_error; 6925331Samw } 6935331Samw } else { 6945331Samw sr->andx_com = (unsigned char)-1; 6955331Samw } 6965331Samw 6975331Samw mutex_enter(&sr->sr_mutex); 6985331Samw switch (sr->sr_state) { 6995331Samw case SMB_REQ_STATE_SUBMITTED: 7005331Samw case SMB_REQ_STATE_CLEANED_UP: 7015331Samw sr->sr_state = SMB_REQ_STATE_ACTIVE; 7025331Samw break; 7035331Samw case SMB_REQ_STATE_CANCELED: 7045331Samw break; 7055331Samw default: 7065331Samw ASSERT(0); 7075331Samw break; 7085331Samw } 7095331Samw mutex_exit(&sr->sr_mutex); 7105331Samw 7116030Sjb150015 /* 7126030Sjb150015 * Setup UID and TID information (if required). Both functions 7136030Sjb150015 * will set the sr credentials. In domain mode, the user and 7146030Sjb150015 * tree credentials should be the same. In share mode, the 7156030Sjb150015 * tree credentials (defined in the share definition) should 7166030Sjb150015 * override the user credentials. 7176030Sjb150015 */ 7186139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) { 7196030Sjb150015 sr->uid_user = smb_user_lookup_by_uid(sr->session, 7206030Sjb150015 &sr->user_cr, sr->smb_uid); 7216030Sjb150015 if (sr->uid_user == NULL) { 7226030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRbaduid); 7236139Sjb150015 smbsr_cleanup(sr); 7246030Sjb150015 goto report_error; 7255331Samw } 7265331Samw 7276139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && 7286139Sjb150015 (sr->tid_tree == NULL)) { 7296030Sjb150015 sr->tid_tree = smb_tree_lookup_by_tid( 7306030Sjb150015 sr->uid_user, sr->smb_tid); 7316030Sjb150015 if (sr->tid_tree == NULL) { 7326030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRinvnid); 7336139Sjb150015 smbsr_cleanup(sr); 7346030Sjb150015 goto report_error; 7355331Samw } 7365331Samw } 7375331Samw } 7385331Samw 7396030Sjb150015 /* 7406030Sjb150015 * If the command is not a read raw request we can set the 7416030Sjb150015 * state of the session back to SMB_SESSION_STATE_NEGOTIATED 7426030Sjb150015 * (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING). 7436030Sjb150015 * Otherwise we let the read raw handler to deal with it. 7446030Sjb150015 */ 7456030Sjb150015 if ((sr->session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) && 7466030Sjb150015 (sr->smb_com != SMB_COM_READ_RAW)) { 7476030Sjb150015 krw_t mode; 7486030Sjb150015 /* 7496030Sjb150015 * The lock may have to be upgraded because, at this 7506030Sjb150015 * point, we don't know how it was entered. We just 7516030Sjb150015 * know that it has to be entered in writer mode here. 7526030Sjb150015 * Whatever mode was used to enter the lock, it will 7536030Sjb150015 * be restored. 7546030Sjb150015 */ 7556030Sjb150015 mode = smb_rwx_rwupgrade(&sr->session->s_lock); 7566030Sjb150015 if (sr->session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) 7576030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7586030Sjb150015 7596030Sjb150015 smb_rwx_rwdowngrade(&sr->session->s_lock, mode); 7606030Sjb150015 } 7616030Sjb150015 7626030Sjb150015 /* 7636030Sjb150015 * Increment method invocation count. This value is exposed 7646030Sjb150015 * via kstats, and it represents a count of all the dispatched 7656030Sjb150015 * requests, including the ones that have a return value, other 7666139Sjb150015 * than SDRC_SUCCESS. 7676030Sjb150015 */ 7686030Sjb150015 SMB_ALL_DISPATCH_STAT_INCR(sdd->sdt_dispatch_stats.value.ui64); 7696030Sjb150015 7706139Sjb150015 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS) 7716139Sjb150015 sdrc = (*sdd->sdt_function)(sr); 7726139Sjb150015 7736139Sjb150015 if (sdrc != SDRC_SUCCESS) { 7746030Sjb150015 /* 7756030Sjb150015 * Handle errors from raw write. 7766030Sjb150015 */ 7776030Sjb150015 if (sr->session->s_state == 7786030Sjb150015 SMB_SESSION_STATE_WRITE_RAW_ACTIVE) { 7796030Sjb150015 /* 7806030Sjb150015 * Set state so that the netbios session 7816030Sjb150015 * daemon will start accepting data again. 7826030Sjb150015 */ 7836030Sjb150015 sr->session->s_write_raw_status = 0; 7846030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7856030Sjb150015 } 7866030Sjb150015 } 7876030Sjb150015 7886139Sjb150015 (*sdd->sdt_post_op)(sr); 7896139Sjb150015 7906030Sjb150015 /* 7916030Sjb150015 * Only call smbsr_cleanup if smb->sr_keep is not set. 7926030Sjb150015 * smb_nt_transact_notify_change will set smb->sr_keep if it 7936030Sjb150015 * retains control of the request when it returns. In that 7946030Sjb150015 * case the notify change code will call smbsr_cleanup later 7956030Sjb150015 * when the request has completed. 7966030Sjb150015 */ 7976030Sjb150015 if (sr->sr_keep == 0) 7986030Sjb150015 smbsr_cleanup(sr); 7996030Sjb150015 8006030Sjb150015 switch (sdrc) { 8016139Sjb150015 case SDRC_SUCCESS: 8026030Sjb150015 break; 8036030Sjb150015 8046030Sjb150015 case SDRC_DROP_VC: 8056030Sjb150015 disconnect = B_TRUE; 8066030Sjb150015 goto drop_connection; 8076030Sjb150015 8086030Sjb150015 case SDRC_NO_REPLY: 8096030Sjb150015 smb_rwx_rwexit(&sr->session->s_lock); 8106030Sjb150015 return; 8116030Sjb150015 8126139Sjb150015 case SDRC_ERROR: 8136030Sjb150015 goto report_error; 8146030Sjb150015 8156139Sjb150015 case SDRC_NOT_IMPLEMENTED: 8166030Sjb150015 default: 8176030Sjb150015 smbsr_error(sr, 0, ERRDOS, ERRbadfunc); 8186030Sjb150015 goto report_error; 8196030Sjb150015 } 8206030Sjb150015 8216030Sjb150015 /* 8226030Sjb150015 * If there's no AndX command, we're done. 8236030Sjb150015 */ 8245331Samw if (sr->andx_com == 0xff) 8255331Samw goto reply_ready; 8265331Samw 8276030Sjb150015 /* 8286030Sjb150015 * Otherwise, we have to back-patch the AndXCommand and AndXOffset 8296030Sjb150015 * and continue processing. 8306030Sjb150015 */ 8315331Samw sr->andx_prev_wct = sr->cur_reply_offset; 832*7052Samw (void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w", 8335331Samw sr->andx_com, MBC_LENGTH(&sr->reply)); 8345331Samw 8355331Samw smb_rwx_rwexit(&sr->session->s_lock); 8365331Samw 8375331Samw sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off; 8385331Samw sr->smb_com = sr->andx_com; 8395331Samw goto andx_more; 8405331Samw 8416030Sjb150015 report_error: 8425331Samw sr->reply.chain_offset = sr->cur_reply_offset; 843*7052Samw (void) smb_mbc_encodef(&sr->reply, "bw", 0, 0); 8445331Samw 8455331Samw sr->smb_wct = 0; 8465331Samw sr->smb_bcc = 0; 8475331Samw 8486139Sjb150015 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0) 8496030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 8506030Sjb150015 8516030Sjb150015 reply_ready: 8526030Sjb150015 smbsr_send_reply(sr); 8536030Sjb150015 8546030Sjb150015 drop_connection: 8556030Sjb150015 if (disconnect) { 8566030Sjb150015 switch (sr->session->s_state) { 8576030Sjb150015 case SMB_SESSION_STATE_DISCONNECTED: 8586030Sjb150015 case SMB_SESSION_STATE_TERMINATED: 8596030Sjb150015 break; 8606030Sjb150015 default: 8616030Sjb150015 smb_soshutdown(sr->session->sock); 8626030Sjb150015 sr->session->s_state = SMB_SESSION_STATE_DISCONNECTED; 8636030Sjb150015 break; 8646030Sjb150015 } 8655331Samw } 8666030Sjb150015 8676030Sjb150015 smb_rwx_rwexit(&sr->session->s_lock); 8685331Samw } 8695331Samw 8706030Sjb150015 int 8716030Sjb150015 smbsr_encode_empty_result(struct smb_request *sr) 8726030Sjb150015 { 8736030Sjb150015 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0)); 8746030Sjb150015 } 8755331Samw 8766030Sjb150015 int 8776030Sjb150015 smbsr_encode_result(struct smb_request *sr, int wct, int bcc, char *fmt, ...) 8785331Samw { 8795331Samw va_list ap; 8805331Samw 8816030Sjb150015 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset) 8826030Sjb150015 return (-1); 8835331Samw 8845331Samw va_start(ap, fmt); 885*7052Samw (void) smb_mbc_vencodef(&sr->reply, fmt, ap); 8865331Samw va_end(ap); 8875331Samw 8885331Samw sr->smb_wct = (unsigned char)wct; 8895331Samw sr->smb_bcc = (uint16_t)bcc; 8905331Samw 8916030Sjb150015 if (smbsr_check_result(sr, wct, bcc) != 0) 8926030Sjb150015 return (-1); 8936030Sjb150015 8946030Sjb150015 return (0); 8955331Samw } 8965331Samw 8976030Sjb150015 static int 8985331Samw smbsr_check_result(struct smb_request *sr, int wct, int bcc) 8995331Samw { 9005331Samw int offset = sr->cur_reply_offset; 9015331Samw int total_bytes; 9025331Samw unsigned char temp, temp1; 9035331Samw struct mbuf *m; 9045331Samw 9055331Samw total_bytes = 0; 9065331Samw m = sr->reply.chain; 9075331Samw while (m != 0) { 9085331Samw total_bytes += m->m_len; 9095331Samw m = m->m_next; 9105331Samw } 9115331Samw 9126030Sjb150015 if ((offset + 3) > total_bytes) 9136030Sjb150015 return (-1); 9145331Samw 915*7052Samw (void) smb_mbc_peek(&sr->reply, offset, "b", &temp); 9166030Sjb150015 if (temp != wct) 9176030Sjb150015 return (-1); 9185331Samw 9196030Sjb150015 if ((offset + (wct * 2 + 1)) > total_bytes) 9206030Sjb150015 return (-1); 9215331Samw 9225331Samw /* reply wct & vwv seem ok, consider data now */ 9235331Samw offset += wct * 2 + 1; 9245331Samw 9256030Sjb150015 if ((offset + 2) > total_bytes) 9266030Sjb150015 return (-1); 9275331Samw 928*7052Samw (void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1); 9295331Samw if (bcc == VAR_BCC) { 9305331Samw if ((temp != 0xFF) || (temp1 != 0xFF)) { 9316030Sjb150015 return (-1); 9325331Samw } else { 9335331Samw bcc = (total_bytes - offset) - 2; 934*7052Samw (void) smb_mbc_poke(&sr->reply, offset, "bb", 9355331Samw bcc, bcc >> 8); 9365331Samw } 9375331Samw } else { 9386030Sjb150015 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF))) 9396030Sjb150015 return (-1); 9405331Samw } 9415331Samw 9425331Samw offset += bcc + 2; 9435331Samw 9446030Sjb150015 if (offset != total_bytes) 9456030Sjb150015 return (-1); 9465331Samw 9475331Samw sr->smb_wct = (unsigned char)wct; 9485331Samw sr->smb_bcc = (uint16_t)bcc; 9496030Sjb150015 return (0); 9505331Samw } 9515331Samw 9525331Samw int 9535331Samw smbsr_decode_vwv(struct smb_request *sr, char *fmt, ...) 9545331Samw { 9555331Samw int rc; 9565331Samw va_list ap; 9575331Samw 9585331Samw va_start(ap, fmt); 959*7052Samw rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap); 9605331Samw va_end(ap); 9615331Samw 9626139Sjb150015 if (rc) 9636139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9645331Samw return (rc); 9655331Samw } 9665331Samw 9675331Samw int 9685331Samw smbsr_decode_data(struct smb_request *sr, char *fmt, ...) 9695331Samw { 9706139Sjb150015 int rc; 9715331Samw va_list ap; 9726139Sjb150015 9735331Samw va_start(ap, fmt); 974*7052Samw rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap); 9755331Samw va_end(ap); 9766139Sjb150015 9776139Sjb150015 if (rc) 9786139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9796139Sjb150015 return (rc); 9805331Samw } 9815331Samw 9825331Samw void 9835331Samw smbsr_send_reply(struct smb_request *sr) 9845331Samw { 9856030Sjb150015 if (SMB_TREE_CASE_INSENSITIVE(sr)) 9866030Sjb150015 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE; 9876030Sjb150015 else 9886030Sjb150015 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE; 9896030Sjb150015 990*7052Samw (void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT, 9915331Samw sr->first_smb_com, 9925331Samw sr->smb_rcls, 9935331Samw sr->smb_reh, 9945331Samw sr->smb_err, 9955331Samw sr->smb_flg | SMB_FLAGS_REPLY, 9965331Samw sr->smb_flg2, 9975331Samw sr->smb_pid_high, 9985331Samw sr->smb_sig, 9995331Samw sr->smb_tid, 10005331Samw sr->smb_pid, 10015331Samw sr->smb_uid, 10025331Samw sr->smb_mid); 10035331Samw 10045331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 10055331Samw smb_sign_reply(sr, NULL); 10065331Samw 10076030Sjb150015 if (smb_session_send(sr->session, 0, &sr->reply) == 0) 10086030Sjb150015 sr->reply.chain = 0; 10095331Samw } 10105331Samw 10115331Samw /* 10125772Sas200622 * Map errno values to SMB and NT status values. 10135772Sas200622 * Note: ESRCH is a special case to handle a streams lookup failure. 10145331Samw */ 10155331Samw static struct { 10165772Sas200622 int errnum; 10175772Sas200622 int errcls; 10185772Sas200622 int errcode; 10195772Sas200622 DWORD status32; 10205772Sas200622 } smb_errno_map[] = { 10215331Samw { ENOSPC, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10225331Samw { EDQUOT, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10235331Samw { EPERM, ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED }, 10245331Samw { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, 10255331Samw { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, 10265331Samw { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE }, 10275331Samw { ENOTEMPTY, ERRDOS, ERROR_DIR_NOT_EMPTY, 10285331Samw NT_STATUS_DIRECTORY_NOT_EMPTY }, 10295331Samw { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, 10305331Samw { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY }, 10315331Samw { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, 10325331Samw { EXDEV, ERRSRV, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, 10335331Samw { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, 10345331Samw { ESTALE, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, 10355331Samw { EBADF, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, 10365331Samw { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, 10375331Samw { ENXIO, ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE}, 10385331Samw { ESRCH, ERRDOS, ERROR_FILE_NOT_FOUND, 10395331Samw NT_STATUS_OBJECT_NAME_NOT_FOUND }, 10405331Samw /* 10415331Samw * It's not clear why smb_read_common effectively returns 10425331Samw * ERRnoaccess if a range lock prevents access and smb_write_common 10435331Samw * effectively returns ERRaccess. This table entry is used by 10445331Samw * smb_read_common and preserves the behavior that was there before. 10455331Samw */ 10465331Samw { ERANGE, ERRDOS, ERRnoaccess, NT_STATUS_FILE_LOCK_CONFLICT } 10475331Samw }; 10485331Samw 10495331Samw void 10505772Sas200622 smbsr_map_errno(int errnum, smb_error_t *err) 10515331Samw { 10525331Samw int i; 10535331Samw 10545772Sas200622 for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) { 10555772Sas200622 if (smb_errno_map[i].errnum == errnum) { 10565772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10575772Sas200622 err->status = smb_errno_map[i].status32; 10585772Sas200622 err->errcls = smb_errno_map[i].errcls; 10595772Sas200622 err->errcode = smb_errno_map[i].errcode; 10605772Sas200622 return; 10615331Samw } 10625331Samw } 10635331Samw 10645772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10655772Sas200622 err->status = NT_STATUS_INTERNAL_ERROR; 10665772Sas200622 err->errcls = ERRDOS; 10675772Sas200622 err->errcode = ERROR_INTERNAL_ERROR; 10685331Samw } 10695331Samw 10705331Samw void 10715772Sas200622 smbsr_errno(struct smb_request *sr, int errnum) 10725772Sas200622 { 10736030Sjb150015 smbsr_map_errno(errnum, &sr->smb_error); 10746030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10755772Sas200622 } 10765772Sas200622 10775772Sas200622 /* 10785772Sas200622 * Report a request processing warning. 10795772Sas200622 */ 10805772Sas200622 void 10815772Sas200622 smbsr_warn(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10825772Sas200622 { 10836030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_WARNING; 10846030Sjb150015 sr->smb_error.status = status; 10856030Sjb150015 sr->smb_error.errcls = errcls; 10866030Sjb150015 sr->smb_error.errcode = errcode; 10875772Sas200622 10886030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10895772Sas200622 } 10905772Sas200622 10915772Sas200622 /* 10925772Sas200622 * Report a request processing error. This function will not return. 10935772Sas200622 */ 10945772Sas200622 void 10955772Sas200622 smbsr_error(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10965331Samw { 10976030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_ERROR; 10986030Sjb150015 sr->smb_error.status = status; 10996030Sjb150015 sr->smb_error.errcls = errcls; 11006030Sjb150015 sr->smb_error.errcode = errcode; 11015772Sas200622 11026030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 11035772Sas200622 } 11045772Sas200622 11055772Sas200622 /* 11065772Sas200622 * Setup a request processing error. This function can be used to 11075772Sas200622 * report 32-bit status codes or DOS errors. Set the status code 11085772Sas200622 * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error, 11095772Sas200622 * regardless of the client capabilities. 11105772Sas200622 * 11115772Sas200622 * If status is non-zero and the client supports 32-bit status 11125772Sas200622 * codes, report the status. Otherwise, report the DOS error. 11135772Sas200622 */ 11145772Sas200622 void 11155772Sas200622 smbsr_set_error(smb_request_t *sr, smb_error_t *err) 11165772Sas200622 { 11175772Sas200622 uint32_t status; 11185772Sas200622 uint32_t severity; 11195772Sas200622 uint32_t capabilities; 11205772Sas200622 11215772Sas200622 ASSERT(sr); 11225772Sas200622 ASSERT(err); 11235772Sas200622 11245772Sas200622 status = err->status; 11255772Sas200622 severity = (err->severity == 0) ? ERROR_SEVERITY_ERROR : err->severity; 11265772Sas200622 capabilities = sr->session->capabilities; 11275772Sas200622 11285772Sas200622 if ((err->errcls == 0) && (err->errcode == 0)) { 11295772Sas200622 capabilities |= CAP_STATUS32; 11305772Sas200622 if (status == 0) 11315772Sas200622 status = NT_STATUS_INTERNAL_ERROR; 11325772Sas200622 } 11335772Sas200622 11345772Sas200622 if ((capabilities & CAP_STATUS32) && (status != 0)) { 11355772Sas200622 status |= severity; 11365772Sas200622 sr->smb_rcls = status & 0xff; 11375772Sas200622 sr->smb_reh = (status >> 8) & 0xff; 11385772Sas200622 sr->smb_err = status >> 16; 11395772Sas200622 sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS; 11405772Sas200622 } else { 11415772Sas200622 if ((err->errcls == 0) || (err->errcode == 0)) { 11425772Sas200622 sr->smb_rcls = ERRSRV; 11435772Sas200622 sr->smb_err = ERRerror; 11445772Sas200622 } else { 11455772Sas200622 sr->smb_rcls = (uint8_t)err->errcls; 11465772Sas200622 sr->smb_err = (uint16_t)err->errcode; 11475331Samw } 11485331Samw } 11495331Samw } 11505331Samw 11515331Samw smb_xa_t * 11525331Samw smbsr_lookup_xa(smb_request_t *sr) 11535331Samw { 11545331Samw ASSERT(sr->r_xa == 0); 11555331Samw 11565331Samw sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid); 11575331Samw return (sr->r_xa); 11585331Samw } 11595331Samw 11605331Samw void 11615331Samw smbsr_disconnect_file(smb_request_t *sr) 11625331Samw { 11635331Samw smb_ofile_t *of = sr->fid_ofile; 11645331Samw 11655331Samw sr->fid_ofile = NULL; 11665331Samw (void) smb_ofile_release(of); 11675331Samw } 11685331Samw 11695331Samw void 11705331Samw smbsr_disconnect_dir(smb_request_t *sr) 11715331Samw { 11725331Samw smb_odir_t *od = sr->sid_odir; 11735331Samw 11745331Samw sr->sid_odir = NULL; 11755331Samw smb_odir_release(od); 11765331Samw } 11775331Samw 11785331Samw static int 11795331Samw is_andx_com(unsigned char com) 11805331Samw { 11815331Samw switch (com) { 11825331Samw case SMB_COM_LOCKING_ANDX: 11835331Samw case SMB_COM_OPEN_ANDX: 11845331Samw case SMB_COM_READ_ANDX: 11855331Samw case SMB_COM_WRITE_ANDX: 11865331Samw case SMB_COM_SESSION_SETUP_ANDX: 11875331Samw case SMB_COM_LOGOFF_ANDX: 11885331Samw case SMB_COM_TREE_CONNECT_ANDX: 11895331Samw case SMB_COM_NT_CREATE_ANDX: 11905331Samw return (1); 11915331Samw } 11925331Samw return (0); 11935331Samw } 11945331Samw 11955331Samw /* 11966139Sjb150015 * Invalid command stubs. 11976139Sjb150015 * 11986139Sjb150015 * SmbWriteComplete is sent to acknowledge completion of raw write requests. 11996139Sjb150015 * We never send raw write commands to other servers so, if we receive 12006139Sjb150015 * SmbWriteComplete, we treat it as an error. 12016139Sjb150015 * 12026139Sjb150015 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize 12036139Sjb150015 * performance when reading/writing a large block of data: it can be 12046139Sjb150015 * used in parallel with other client/server operations. The mpx sub- 12056139Sjb150015 * protocol is not supported because we support only connection oriented 12066139Sjb150015 * transports and NT supports mpx only over connectionless transports. 12075331Samw */ 12086030Sjb150015 smb_sdrc_t 12096139Sjb150015 smb_pre_invalid(smb_request_t *sr) 12106139Sjb150015 { 12116139Sjb150015 DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr); 12126139Sjb150015 return (SDRC_SUCCESS); 12136139Sjb150015 } 12146139Sjb150015 12156139Sjb150015 void 12166139Sjb150015 smb_post_invalid(smb_request_t *sr) 12176139Sjb150015 { 12186139Sjb150015 DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr); 12196139Sjb150015 } 12206139Sjb150015 12216139Sjb150015 smb_sdrc_t 12226139Sjb150015 smb_com_invalid(smb_request_t *sr) 12235331Samw { 12246139Sjb150015 smb_sdrc_t sdrc; 12256139Sjb150015 12266139Sjb150015 switch (sr->smb_com) { 12276139Sjb150015 case SMB_COM_WRITE_COMPLETE: 12286139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 12296139Sjb150015 sdrc = SDRC_ERROR; 12306139Sjb150015 break; 12316139Sjb150015 12326139Sjb150015 default: 12336139Sjb150015 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED, 12346139Sjb150015 ERRDOS, ERROR_INVALID_FUNCTION); 12356139Sjb150015 sdrc = SDRC_NOT_IMPLEMENTED; 12366139Sjb150015 break; 12376139Sjb150015 } 12386139Sjb150015 12396139Sjb150015 return (sdrc); 12405331Samw } 12415331Samw 12425331Samw /* 12436139Sjb150015 * smb_dispatch_kstat_update 12445331Samw * 12455331Samw * This callback function updates the smb_dispatch_kstat_data when kstat 12465331Samw * command is invoked. 12475331Samw */ 12485331Samw static int 12496139Sjb150015 smb_dispatch_kstat_update(kstat_t *ksp, int rw) 12505331Samw { 12516139Sjb150015 smb_dispatch_table_t *sdd; 12526139Sjb150015 kstat_named_t *ks_named; 12536139Sjb150015 int i; 12545331Samw 12556139Sjb150015 if (rw == KSTAT_WRITE) 12565331Samw return (EACCES); 12576139Sjb150015 12586139Sjb150015 ASSERT(MUTEX_HELD(ksp->ks_lock)); 12596139Sjb150015 12606139Sjb150015 ks_named = ksp->ks_data; 12616139Sjb150015 for (i = 0; i < SMB_COM_NUM; i++) { 12626139Sjb150015 sdd = &dispatch[i]; 12636139Sjb150015 12646139Sjb150015 if (sdd->sdt_function != smb_com_invalid) { 12656139Sjb150015 bcopy(&sdd->sdt_dispatch_stats, ks_named, 12666139Sjb150015 sizeof (kstat_named_t)); 12676139Sjb150015 ++ks_named; 12685331Samw } 12695331Samw } 12706139Sjb150015 12715331Samw return (0); 12725331Samw } 12735331Samw 12745331Samw /* 12756139Sjb150015 * smb_dispatch_kstat_init 12765331Samw * 12775331Samw * Initialize dispatch kstats. 12785331Samw */ 12795331Samw void 12806139Sjb150015 smb_dispatch_kstat_init(void) 12815331Samw { 12826139Sjb150015 int ks_ndata; 12836139Sjb150015 int i; 12845331Samw 12856139Sjb150015 for (i = 0, ks_ndata = 0; i < SMB_COM_NUM; i++) { 12866139Sjb150015 if (dispatch[i].sdt_function != smb_com_invalid) 12876139Sjb150015 ks_ndata++; 12885331Samw } 12895331Samw 12906432Sas200622 smb_dispatch_ksp = kstat_create(SMBSRV_KSTAT_MODULE, 0, 12916432Sas200622 SMBSRV_KSTAT_NAME_CMDS, SMBSRV_KSTAT_CLASS, 12926139Sjb150015 KSTAT_TYPE_NAMED, ks_ndata, 0); 12935331Samw 12945331Samw if (smb_dispatch_ksp) { 12956139Sjb150015 mutex_init(&smb_dispatch_ksmtx, NULL, MUTEX_DEFAULT, NULL); 12966139Sjb150015 smb_dispatch_ksp->ks_update = smb_dispatch_kstat_update; 12976139Sjb150015 smb_dispatch_ksp->ks_lock = &smb_dispatch_ksmtx; 12985331Samw kstat_install(smb_dispatch_ksp); 12995331Samw } 13005331Samw } 13015331Samw 13025331Samw /* 13036139Sjb150015 * smb_dispatch_kstat_fini 13045331Samw * 13055331Samw * Remove dispatch kstats. 13065331Samw */ 13075331Samw void 13086139Sjb150015 smb_dispatch_kstat_fini(void) 13095331Samw { 13105331Samw if (smb_dispatch_ksp != NULL) { 13115331Samw kstat_delete(smb_dispatch_ksp); 13126139Sjb150015 mutex_destroy(&smb_dispatch_ksmtx); 13135331Samw smb_dispatch_ksp = NULL; 13145331Samw } 13155331Samw } 1316