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 /* 228670SJose.Borrego@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw /* 278934SJose.Borrego@Sun.COM * SMB requests. 285331Samw * 295331Samw * Request 305331Samw * Header 315331Samw * Magic 0xFF 'S' 'M' 'B' 325331Samw * smb_com a byte, the "first" command 335331Samw * Error a 4-byte union, ignored in a request 345331Samw * smb_flg a one byte set of eight flags 355331Samw * smb_flg2 a two byte set of 16 flags 365331Samw * . twelve reserved bytes, have a role 375331Samw * in connectionless transports (IPX, UDP?) 385331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 395331Samw * 0xFFFF is this command does not have 405331Samw * or require a tree context 415331Samw * smb_pid a 16-bit process ID 425331Samw * smb_uid a 16-bit user ID, specific to this "session" 435331Samw * and mapped to a system (bona-fide) UID 445331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 455331Samw * multiple simultaneous requests from the same 465331Samw * process (pid) (ref RPC "xid") 475331Samw * 485331Samw * Chained (AndX) commands (0 or more) 495331Samw * smb_wct a byte, number of 16-bit words containing 505331Samw * command parameters, min 2 for chained command 515331Samw * andx_com a byte, the "next" command, 0xFF for none 525331Samw * . an unused byte 535331Samw * andx_off a 16-bit offset, byte displacement from &Magic 545331Samw * to the smb_wct field of the "next" command, 555331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 565331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 575331Samw * "this" command (i.e. smb_com if this is the 585331Samw * first parameters, or the andx_com of the just 595331Samw * previous block. 605331Samw * smb_bcc a 16-bit count of smb_data[] bytes 615331Samw * smb_data[] 0 or more bytes, format specific to commands 625331Samw * padding[] Optional padding 635331Samw * 645331Samw * Last command 655331Samw * smb_wct a byte, number of 16-bit words containing 665331Samw * command parameters, min 0 for chained command 675331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 685331Samw * "this" command (i.e. smb_com if this is the 695331Samw * first parameters, or the andx_com of the just 705331Samw * previous block. 715331Samw * smb_bcc a 16-bit count of smb_data[] bytes 725331Samw * smb_data[] 0 or more bytes, format specific to commands 735331Samw * 745331Samw * Reply 755331Samw * Header 765331Samw * Magic 0xFF 'S' 'M' 'B' 775331Samw * smb_com a byte, the "first" command, corresponds 785331Samw * to request 795331Samw * Error a 4-byte union, coding depends on dialect in use 805331Samw * for "DOS" errors 815331Samw * a byte for error class 825331Samw * an unused byte 835331Samw * a 16-bit word for error code 845331Samw * for "NT" errors 855331Samw * a 32-bit error code which 865331Samw * is a packed class and specifier 875331Samw * for "OS/2" errors 885331Samw * I don't know 895331Samw * The error information is specific to the 905331Samw * last command in the reply chain. 915331Samw * smb_flg a one byte set of eight flags, 0x80 bit set 925331Samw * indicating this message is a reply 935331Samw * smb_flg2 a two byte set of 16 flags 945331Samw * . twelve reserved bytes, have a role 955331Samw * in connectionless transports (IPX, UDP?) 965331Samw * smb_tid a 16-bit tree ID, a mount point sorta, 975331Samw * should be the same as the request 985331Samw * smb_pid a 16-bit process ID, MUST BE the same as request 995331Samw * smb_uid a 16-bit user ID, specific to this "session" 1005331Samw * and mapped to a system (bona-fide) UID, 1015331Samw * should be the same as request 1025331Samw * smb_mid a 16-bit multiplex ID, used to differentiate 1035331Samw * multiple simultaneous requests from the same 1045331Samw * process (pid) (ref RPC "xid"), MUST BE the 1055331Samw * same as request 1065331Samw * padding[] Optional padding 1075331Samw * 1085331Samw * Chained (AndX) commands (0 or more) 1095331Samw * smb_wct a byte, number of 16-bit words containing 1105331Samw * command parameters, min 2 for chained command, 1115331Samw * andx_com a byte, the "next" command, 0xFF for none, 1125331Samw * corresponds to request, if this is the chained 1135331Samw * command that had an error set to 0xFF 1145331Samw * . an unused byte 1155331Samw * andx_off a 16-bit offset, byte displacement from &Magic 1165331Samw * to the smb_wct field of the "next" command, 1175331Samw * ignore if andx_com is 0xFF, s/b 0 if no next 1185331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1195331Samw * "this" command (i.e. smb_com if this is the 1205331Samw * first parameters, or the andx_com of the just 1215331Samw * previous block. Empty if an error. 1225331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1235331Samw * smb_data[] 0 or more bytes, format specific to commands 1245331Samw * empty if an error. 1255331Samw * 1265331Samw * Last command 1275331Samw * smb_wct a byte, number of 16-bit words containing 1285331Samw * command parameters, min 0 for chained command 1295331Samw * smb_vwv[] 0 or more 16-bit (sorta) parameters for 1305331Samw * "this" command (i.e. smb_com if this is the 1315331Samw * first parameters, or the andx_com of the just 1325331Samw * previous block, empty if an error. 1335331Samw * smb_bcc a 16-bit count of smb_data[] bytes 1345331Samw * smb_data[] 0 or more bytes, format specific to commands, 1355331Samw * empty if an error. 1365331Samw */ 1375331Samw 1385331Samw #include <smbsrv/smb_incl.h> 1396432Sas200622 #include <smbsrv/smb_kstat.h> 1405331Samw #include <sys/sdt.h> 1415331Samw 1425331Samw #define SMB_ALL_DISPATCH_STAT_INCR(stat) atomic_inc_64(&stat); 1436139Sjb150015 #define SMB_COM_NUM 256 1445331Samw 1455331Samw static kstat_t *smb_dispatch_ksp = NULL; 1466139Sjb150015 static kmutex_t smb_dispatch_ksmtx; 1475331Samw 1486030Sjb150015 static int is_andx_com(unsigned char); 1496030Sjb150015 static int smbsr_check_result(struct smb_request *, int, int); 1505331Samw 1518934SJose.Borrego@Sun.COM static smb_disp_entry_t dispatch[SMB_COM_NUM] = { 1526139Sjb150015 { SMB_SDT_OPS(create_directory), /* 0x00 000 */ 1536139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1545331Samw { "SmbCreateDirectory", KSTAT_DATA_UINT64 } }, 1556139Sjb150015 { SMB_SDT_OPS(delete_directory), /* 0x01 001 */ 1566139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1575331Samw { "SmbDeleteDirectory", KSTAT_DATA_UINT64 } }, 1586139Sjb150015 { SMB_SDT_OPS(open), /* 0x02 002 */ 1596139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1605331Samw { "SmbOpen", KSTAT_DATA_UINT64 } }, 1616139Sjb150015 { SMB_SDT_OPS(create), /* 0x03 003 */ 1626139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1635331Samw { "SmbCreate", KSTAT_DATA_UINT64 } }, 1646139Sjb150015 { SMB_SDT_OPS(close), /* 0x04 004 */ 1656139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1665331Samw { "SmbClose", KSTAT_DATA_UINT64 } }, 1676139Sjb150015 { SMB_SDT_OPS(flush), /* 0x05 005 */ 1686139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1695331Samw { "SmbFlush", KSTAT_DATA_UINT64 } }, 1706139Sjb150015 { SMB_SDT_OPS(delete), /* 0x06 006 */ 1716139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1725331Samw { "SmbDelete", KSTAT_DATA_UINT64 } }, 1736139Sjb150015 { SMB_SDT_OPS(rename), /* 0x07 007 */ 1746139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1755331Samw { "SmbRename", KSTAT_DATA_UINT64 } }, 1766139Sjb150015 { SMB_SDT_OPS(query_information), /* 0x08 008 */ 1776139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1785331Samw { "SmbQueryInformation", KSTAT_DATA_UINT64 } }, 1796139Sjb150015 { SMB_SDT_OPS(set_information), /* 0x09 009 */ 1806139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1815331Samw { "SmbSetInformation", KSTAT_DATA_UINT64 } }, 1826139Sjb150015 { SMB_SDT_OPS(read), /* 0x0A 010 */ 1836139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1845331Samw { "SmbRead", KSTAT_DATA_UINT64 } }, 1856139Sjb150015 { SMB_SDT_OPS(write), /* 0x0B 011 */ 1866139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1875331Samw { "SmbWrite", KSTAT_DATA_UINT64 } }, 1886139Sjb150015 { SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */ 1896139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1905331Samw { "SmbLockByteRange", KSTAT_DATA_UINT64 } }, 1916139Sjb150015 { SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */ 1926139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1935331Samw { "SmbUnlockByteRange", KSTAT_DATA_UINT64 } }, 1946139Sjb150015 { SMB_SDT_OPS(create_temporary), /* 0x0E 014 */ 1956139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1965331Samw { "SmbCreateTemporary", KSTAT_DATA_UINT64 } }, 1976139Sjb150015 { SMB_SDT_OPS(create_new), /* 0x0F 015 */ 1986139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 1995331Samw { "SmbCreateNew", KSTAT_DATA_UINT64 } }, 2006139Sjb150015 { SMB_SDT_OPS(check_directory), /* 0x10 016 */ 2016139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2025331Samw { "SmbCheckDirectory", KSTAT_DATA_UINT64 } }, 2036139Sjb150015 { SMB_SDT_OPS(process_exit), /* 0x11 017 */ 2045331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2055331Samw RW_READER, 2065331Samw { "SmbProcessExit", KSTAT_DATA_UINT64 } }, 2076139Sjb150015 { SMB_SDT_OPS(seek), /* 0x12 018 */ 2086139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 2095331Samw { "SmbSeek", KSTAT_DATA_UINT64 } }, 2106139Sjb150015 { SMB_SDT_OPS(lock_and_read), /* 0x13 019 */ 2116139Sjb150015 LANMAN1_0, 0, RW_READER, 2125331Samw { "SmbLockAndRead", KSTAT_DATA_UINT64 } }, 2136139Sjb150015 { SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */ 2146139Sjb150015 LANMAN1_0, 0, RW_READER, 2155331Samw { "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } }, 2166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x15 021 */ 2176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x16 022 */ 2186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x17 023 */ 2196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x18 024 */ 2206139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x19 025 */ 2216139Sjb150015 { SMB_SDT_OPS(read_raw), /* 0x1A 026 */ 2226139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2235331Samw { "SmbReadRaw", KSTAT_DATA_UINT64 } }, 2246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1B 027 */ 2256139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1C 028 */ 2266139Sjb150015 { SMB_SDT_OPS(write_raw), /* 0x1D 029 */ 2276139Sjb150015 LANMAN1_0, 0, RW_WRITER, 2285331Samw { "SmbWriteRaw", KSTAT_DATA_UINT64 } }, 2296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1E 030 */ 2306139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x1F 031 */ 2316139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x20 032 */ 2326139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x21 033 */ 2336139Sjb150015 { SMB_SDT_OPS(set_information2), /* 0x22 034 */ 2346139Sjb150015 LANMAN1_0, 0, RW_READER, 2355331Samw { "SmbSetInformation2", KSTAT_DATA_UINT64 } }, 2366139Sjb150015 { SMB_SDT_OPS(query_information2), /* 0x23 035 */ 2376139Sjb150015 LANMAN1_0, 0, RW_READER, 2385331Samw { "SmbQueryInformation2", KSTAT_DATA_UINT64 } }, 2396139Sjb150015 { SMB_SDT_OPS(locking_andx), /* 0x24 036 */ 2406139Sjb150015 LANMAN1_0, 0, RW_READER, 2415331Samw { "SmbLockingX", KSTAT_DATA_UINT64 } }, 2426139Sjb150015 { SMB_SDT_OPS(transaction), /* 0x25 037 */ 2436139Sjb150015 LANMAN1_0, 0, RW_READER, 2445331Samw { "SmbTransaction", KSTAT_DATA_UINT64 } }, 2456139Sjb150015 { SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */ 2466139Sjb150015 LANMAN1_0, 0, RW_READER, 2475331Samw { "SmbTransactionSecondary", KSTAT_DATA_UINT64 } }, 2486139Sjb150015 { SMB_SDT_OPS(ioctl), /* 0x27 039 */ 2496139Sjb150015 LANMAN1_0, 0, RW_READER, 2505331Samw { "SmbIoctl", KSTAT_DATA_UINT64 } }, 2516139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x28 040 */ 2526139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x29 041 */ 2536139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x2A 042 */ 2546139Sjb150015 { SMB_SDT_OPS(echo), /* 0x2B 043 */ 2555331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2565331Samw RW_READER, 2575331Samw { "SmbEcho", KSTAT_DATA_UINT64 } }, 2586139Sjb150015 { SMB_SDT_OPS(write_and_close), /* 0x2C 044 */ 2596139Sjb150015 LANMAN1_0, 0, RW_READER, 2605331Samw { "SmbWriteAndClose", KSTAT_DATA_UINT64 } }, 2616139Sjb150015 { SMB_SDT_OPS(open_andx), /* 0x2D 045 */ 2626139Sjb150015 LANMAN1_0, 0, RW_READER, 2635331Samw { "SmbOpenX", KSTAT_DATA_UINT64 } }, 2646139Sjb150015 { SMB_SDT_OPS(read_andx), /* 0x2E 046 */ 2656139Sjb150015 LANMAN1_0, 0, RW_READER, 2665331Samw { "SmbReadX", KSTAT_DATA_UINT64 } }, 2676139Sjb150015 { SMB_SDT_OPS(write_andx), /* 0x2F 047 */ 2686139Sjb150015 LANMAN1_0, 0, RW_READER, 2695331Samw { "SmbWriteX", KSTAT_DATA_UINT64 } }, 2706139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x30 048 */ 2716139Sjb150015 { SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */ 2726139Sjb150015 LANMAN1_0, 0, RW_READER, 2735331Samw { "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } }, 2746139Sjb150015 { SMB_SDT_OPS(transaction2), /* 0x32 050 */ 2756139Sjb150015 LM1_2X002, 0, RW_READER, 2765331Samw { "SmbTransaction2", KSTAT_DATA_UINT64 } }, 2776139Sjb150015 { SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */ 2786139Sjb150015 LM1_2X002, 0, RW_READER, 2795331Samw { "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } }, 2806139Sjb150015 { SMB_SDT_OPS(find_close2), /* 0x34 052 */ 2816139Sjb150015 LM1_2X002, 0, RW_READER, 2825331Samw { "SmbFindClose2", KSTAT_DATA_UINT64 } }, 2836139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x35 053 */ 2846139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x36 054 */ 2856139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x37 055 */ 2866139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x38 056 */ 2876139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x39 057 */ 2886139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3A 058 */ 2896139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3B 059 */ 2906139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3C 060 */ 2916139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3D 061 */ 2926139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3E 062 */ 2936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x3F 063 */ 2946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x40 064 */ 2956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x41 065 */ 2966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x42 066 */ 2976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x43 067 */ 2986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x44 068 */ 2996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x45 069 */ 3006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x46 070 */ 3016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x47 071 */ 3026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x48 072 */ 3036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x49 073 */ 3046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4A 074 */ 3056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4B 075 */ 3066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4C 076 */ 3076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4D 077 */ 3086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4E 078 */ 3096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x4F 079 */ 3106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x50 080 */ 3116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x51 081 */ 3126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x52 082 */ 3136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x53 083 */ 3146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x54 084 */ 3156139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x55 085 */ 3166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x56 086 */ 3176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x57 087 */ 3186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x58 088 */ 3196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x59 089 */ 3206139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5A 090 */ 3216139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5B 091 */ 3226139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5C 092 */ 3236139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5D 093 */ 3246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5E 094 */ 3256139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x5F 095 */ 3266139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x60 096 */ 3276139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x61 097 */ 3286139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x62 098 */ 3296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x63 099 */ 3306139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x64 100 */ 3316139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x65 101 */ 3326139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x66 102 */ 3336139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x67 103 */ 3346139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x68 104 */ 3356139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x69 105 */ 3366139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6A 106 */ 3376139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6B 107 */ 3386139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6C 108 */ 3396139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6D 109 */ 3406139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6E 110 */ 3416139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x6F 111 */ 3426139Sjb150015 { SMB_SDT_OPS(tree_connect), /* 0x70 112 */ 3436139Sjb150015 PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID, RW_READER, 3445331Samw { "SmbTreeConnect", KSTAT_DATA_UINT64 } }, 3456139Sjb150015 { SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */ 3465331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3475331Samw RW_READER, 3485331Samw { "SmbTreeDisconnect", KSTAT_DATA_UINT64 } }, 3496139Sjb150015 { SMB_SDT_OPS(negotiate), /* 0x72 114 */ 3505331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3515331Samw RW_WRITER, 3525331Samw { "SmbNegotiate", KSTAT_DATA_UINT64 } }, 3536139Sjb150015 { SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */ 3545331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3555331Samw RW_READER, 3565331Samw { "SmbSessionSetupX", KSTAT_DATA_UINT64 } }, 3576139Sjb150015 { SMB_SDT_OPS(logoff_andx), /* 0x74 116 */ 3586139Sjb150015 LM1_2X002, SDDF_SUPPRESS_TID, RW_READER, 3595331Samw { "SmbLogoffX", KSTAT_DATA_UINT64 } }, 3606139Sjb150015 { SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */ 3616139Sjb150015 LANMAN1_0, SDDF_SUPPRESS_TID, RW_READER, 3625331Samw { "SmbTreeConnectX", KSTAT_DATA_UINT64 } }, 3636139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x76 118 */ 3646139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x77 119 */ 3656139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x78 120 */ 3666139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x79 121 */ 3676139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7A 122 */ 3686139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7B 123 */ 3696139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7C 124 */ 3706139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7D 125 */ 3716139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7E 126 */ 3726139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x7F 127 */ 3736139Sjb150015 { SMB_SDT_OPS(query_information_disk), /* 0x80 128 */ 3746139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3755331Samw { "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } }, 3766139Sjb150015 { SMB_SDT_OPS(search), /* 0x81 129 */ 3776139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 3785331Samw { "SmbSearch", KSTAT_DATA_UINT64 } }, 3796139Sjb150015 { SMB_SDT_OPS(find), /* 0x82 130 */ 3806139Sjb150015 LANMAN1_0, 0, RW_READER, 3815331Samw { "SmbFind", KSTAT_DATA_UINT64 } }, 3826139Sjb150015 { SMB_SDT_OPS(find_unique), /* 0x83 131 */ 3836139Sjb150015 LANMAN1_0, 0, RW_READER, 3845331Samw { "SmbFindUnique", KSTAT_DATA_UINT64 } }, 3856139Sjb150015 { SMB_SDT_OPS(find_close), /* 0x84 132 */ 3866139Sjb150015 LANMAN1_0, 0, RW_READER, 3875331Samw { "SmbFindClose", KSTAT_DATA_UINT64 } }, 3886139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x85 133 */ 3896139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x86 134 */ 3906139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x87 135 */ 3916139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x88 136 */ 3926139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x89 137 */ 3936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8A 138 */ 3946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8B 139 */ 3956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8C 140 */ 3966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8D 141 */ 3976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8E 142 */ 3986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x8F 143 */ 3996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x90 144 */ 4006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x91 145 */ 4016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x92 146 */ 4026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x93 147 */ 4036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x94 148 */ 4046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x95 149 */ 4056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x96 150 */ 4066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x97 151 */ 4076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x98 152 */ 4086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x99 153 */ 4096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9A 154 */ 4106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9B 155 */ 4116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9C 156 */ 4126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9D 157 */ 4136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9E 158 */ 4146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0x9F 159 */ 4156139Sjb150015 { SMB_SDT_OPS(nt_transact), /* 0xA0 160 */ 4166139Sjb150015 NT_LM_0_12, 0, RW_READER, 4175331Samw { "SmbNtTransact", KSTAT_DATA_UINT64 } }, 4186139Sjb150015 { SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */ 4196139Sjb150015 NT_LM_0_12, 0, RW_READER, 4205331Samw { "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } }, 4216139Sjb150015 { SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */ 4226139Sjb150015 NT_LM_0_12, 0, RW_READER, 4235331Samw { "SmbNtCreateX", KSTAT_DATA_UINT64 } }, 4246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA3 163 */ 4256139Sjb150015 { SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */ 4266139Sjb150015 NT_LM_0_12, 0, RW_READER, 4275331Samw { "SmbNtCancel", KSTAT_DATA_UINT64 } }, 4286139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA5 165 */ 4296139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA6 166 */ 4306139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA7 167 */ 4316139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA8 168 */ 4326139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xA9 169 */ 4336139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAA 170 */ 4346139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAB 171 */ 4356139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAC 172 */ 4366139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAD 173 */ 4376139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAE 174 */ 4386139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xAF 175 */ 4396139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB0 176 */ 4406139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB1 177 */ 4416139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB2 178 */ 4426139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB3 179 */ 4436139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB4 180 */ 4446139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB5 181 */ 4456139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB6 182 */ 4466139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB7 183 */ 4476139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB8 184 */ 4486139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xB9 185 */ 4496139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBA 186 */ 4506139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBB 187 */ 4516139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBC 188 */ 4526139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBD 189 */ 4536139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBE 190 */ 4546139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xBF 191 */ 4556139Sjb150015 { SMB_SDT_OPS(open_print_file), /* 0xC0 192 */ 4566139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4575331Samw { "SmbOpenPrintFile", KSTAT_DATA_UINT64 } }, 4586139Sjb150015 { SMB_SDT_OPS(write_print_file), /* 0xC1 193 */ 4596139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4605331Samw { "SmbWritePrintFile", KSTAT_DATA_UINT64 } }, 4616139Sjb150015 { SMB_SDT_OPS(close_print_file), /* 0xC2 194 */ 4626139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4635331Samw { "SmbClosePrintFile", KSTAT_DATA_UINT64 } }, 4646139Sjb150015 { SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */ 4656139Sjb150015 PC_NETWORK_PROGRAM_1_0, 0, RW_READER, 4665331Samw { "SmbGetPrintQueue", KSTAT_DATA_UINT64 } }, 4676139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC4 196 */ 4686139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC5 197 */ 4696139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC6 198 */ 4706139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC7 199 */ 4716139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC8 200 */ 4726139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xC9 201 */ 4736139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCA 202 */ 4746139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCB 203 */ 4756139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCC 204 */ 4766139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCD 205 */ 4776139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCE 206 */ 4786139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xCF 207 */ 4796139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD0 208 */ 4806139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD1 209 */ 4816139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD2 210 */ 4826139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD3 211 */ 4836139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD4 212 */ 4846139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD5 213 */ 4856139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD6 214 */ 4866139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD7 215 */ 4876139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD8 216 */ 4886139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xD9 217 */ 4896139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDA 218 */ 4906139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDB 219 */ 4916139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDC 220 */ 4926139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDD 221 */ 4936139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDE 222 */ 4946139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xDF 223 */ 4956139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE0 224 */ 4966139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE1 225 */ 4976139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE2 226 */ 4986139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE3 227 */ 4996139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE4 228 */ 5006139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE5 229 */ 5016139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE6 230 */ 5026139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE7 231 */ 5036139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE8 232 */ 5046139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xE9 233 */ 5056139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEA 234 */ 5066139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEB 235 */ 5076139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEC 236 */ 5086139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xED 237 */ 5096139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEE 238 */ 5106139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xEF 239 */ 5116139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF0 240 */ 5126139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF1 241 */ 5136139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF2 242 */ 5146139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF3 243 */ 5156139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF4 244 */ 5166139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF5 245 */ 5176139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF6 246 */ 5186139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF7 247 */ 5196139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF8 248 */ 5206139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xF9 249 */ 5216139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFA 250 */ 5226139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFB 251 */ 5236139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFC 252 */ 5246139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 }, /* 0xFD 253 */ 5256139Sjb150015 { SMB_SDT_OPS(invalid), LANMAN1_0, 0, RW_READER, /* 0xFE 254 */ 5265331Samw { "SmbInvalidCommand", KSTAT_DATA_UINT64 } }, 5276139Sjb150015 { SMB_SDT_OPS(invalid), 0, 0, RW_READER, 0 } /* 0xFF 255 */ 5285331Samw }; 5295331Samw 5305331Samw /* 5315331Samw * smbsr_cleanup 5325331Samw * 5335331Samw * If any user/tree/file is used by given request then 5345331Samw * the reference count for that resource has been incremented. 5355331Samw * This function decrements the reference count and close 5365331Samw * the resource if it's needed. 5375331Samw */ 5385331Samw 5395331Samw void 5406139Sjb150015 smbsr_cleanup(smb_request_t *sr) 5415331Samw { 5425331Samw ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) && 5435331Samw (sr->sr_state != SMB_REQ_STATE_COMPLETED)); 5445331Samw 5455331Samw if (sr->r_xa) { 5465331Samw if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE) 5475331Samw smb_xa_close(sr->r_xa); 5485331Samw smb_xa_rele(sr->session, sr->r_xa); 5495331Samw sr->r_xa = NULL; 5505331Samw } 5515331Samw 5525331Samw /* 5535331Samw * Mark this request so we know that we've already cleaned it up. 5545331Samw * A request should only get cleaned up once so multiple calls to 5555331Samw * smbsr_cleanup for the same request indicate a bug. 5565331Samw */ 5575331Samw mutex_enter(&sr->sr_mutex); 5585331Samw if (sr->sr_state != SMB_REQ_STATE_CANCELED) 5595331Samw sr->sr_state = SMB_REQ_STATE_CLEANED_UP; 5605331Samw mutex_exit(&sr->sr_mutex); 5615331Samw } 5628262SJose.Borrego@Sun.COM /* 5638262SJose.Borrego@Sun.COM * smb_dispatch_request 5648262SJose.Borrego@Sun.COM * 5658262SJose.Borrego@Sun.COM * Returns: 5668262SJose.Borrego@Sun.COM * 5678262SJose.Borrego@Sun.COM * B_TRUE The caller must free the smb request passed in. 5688262SJose.Borrego@Sun.COM * B_FALSE The caller must not access the smb request passed in. It has 5698262SJose.Borrego@Sun.COM * been kept in an internal queue and may have already been freed. 5708262SJose.Borrego@Sun.COM */ 5718262SJose.Borrego@Sun.COM boolean_t 5725331Samw smb_dispatch_request(struct smb_request *sr) 5735331Samw { 5746030Sjb150015 smb_sdrc_t sdrc; 5758934SJose.Borrego@Sun.COM smb_disp_entry_t *sdd; 5766030Sjb150015 boolean_t disconnect = B_FALSE; 5778262SJose.Borrego@Sun.COM smb_session_t *session; 5788934SJose.Borrego@Sun.COM uint32_t capabilities; 5798934SJose.Borrego@Sun.COM uint32_t byte_count; 5808262SJose.Borrego@Sun.COM 5818262SJose.Borrego@Sun.COM session = sr->session; 5828934SJose.Borrego@Sun.COM capabilities = session->capabilities; 5835331Samw 5845331Samw ASSERT(sr->tid_tree == 0); 5855331Samw ASSERT(sr->uid_user == 0); 5865331Samw ASSERT(sr->fid_ofile == 0); 5875331Samw sr->smb_fid = (uint16_t)-1; 5885331Samw 5895331Samw /* temporary until we identify a user */ 5905331Samw sr->user_cr = kcred; 5915331Samw sr->orig_request_hdr = sr->command.chain_offset; 5925331Samw 5935331Samw /* If this connection is shutting down just kill request */ 5947052Samw if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT, 5955331Samw &sr->smb_com, 5965331Samw &sr->smb_rcls, 5975331Samw &sr->smb_reh, 5985331Samw &sr->smb_err, 5995331Samw &sr->smb_flg, 6005331Samw &sr->smb_flg2, 6015331Samw &sr->smb_pid_high, 6025331Samw sr->smb_sig, 6035331Samw &sr->smb_tid, 6045331Samw &sr->smb_pid, 6055331Samw &sr->smb_uid, 6065331Samw &sr->smb_mid) != 0) { 6076030Sjb150015 disconnect = B_TRUE; 6086030Sjb150015 goto drop_connection; 6095331Samw } 6105331Samw 6115331Samw /* 6126030Sjb150015 * The reply "header" is filled in now even though it will, 6136030Sjb150015 * most likely, be rewritten under reply_ready below. We 6146030Sjb150015 * could reserve the space but this is convenient in case 6156030Sjb150015 * the dialect dispatcher has to send a special reply (like 6166030Sjb150015 * TRANSACT). 6175331Samw * 6185331Samw * Ensure that the 32-bit error code flag is turned off. 6195331Samw * Clients seem to set it in transact requests and they may 6205331Samw * get confused if we return success or a 16-bit SMB code. 6215331Samw */ 6225331Samw sr->smb_rcls = 0; 6235331Samw sr->smb_reh = 0; 6245331Samw sr->smb_err = 0; 6255331Samw sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS; 6265331Samw 6277052Samw (void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT, 6285331Samw sr->smb_com, 6295331Samw sr->smb_rcls, 6305331Samw sr->smb_reh, 6315331Samw sr->smb_err, 6325331Samw sr->smb_flg, 6335331Samw sr->smb_flg2, 6345331Samw sr->smb_pid_high, 6355331Samw sr->smb_sig, 6365331Samw sr->smb_tid, 6375331Samw sr->smb_pid, 6385331Samw sr->smb_uid, 6395331Samw sr->smb_mid); 6405331Samw sr->first_smb_com = sr->smb_com; 6415331Samw 6425331Samw /* 6435772Sas200622 * Verify SMB signature if signing is enabled, dialect is NT LM 0.12, 6445331Samw * signing was negotiated and authentication has occurred. 6455331Samw */ 6468262SJose.Borrego@Sun.COM if (session->signing.flags & SMB_SIGNING_ENABLED) { 6475331Samw if (smb_sign_check_request(sr) != 0) { 6486030Sjb150015 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 6496030Sjb150015 ERRDOS, ERROR_ACCESS_DENIED); 6506030Sjb150015 disconnect = B_TRUE; 6518262SJose.Borrego@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_READER); 6526030Sjb150015 goto report_error; 6535331Samw } 6545331Samw } 6555331Samw 6565331Samw andx_more: 6575331Samw sdd = &dispatch[sr->smb_com]; 6586139Sjb150015 ASSERT(sdd->sdt_function); 6595331Samw 6608262SJose.Borrego@Sun.COM smb_rwx_rwenter(&session->s_lock, sdd->sdt_slock_mode); 6615331Samw 6627052Samw if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) { 6636030Sjb150015 disconnect = B_TRUE; 6646030Sjb150015 goto report_error; 6655331Samw } 6665331Samw 6675331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command, 6685331Samw sr->command.chain_offset, sr->smb_wct * 2); 6695331Samw 6707052Samw if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) { 6716030Sjb150015 disconnect = B_TRUE; 6726030Sjb150015 goto report_error; 6735331Samw } 6745331Samw 6758934SJose.Borrego@Sun.COM /* 6768934SJose.Borrego@Sun.COM * Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX 6778934SJose.Borrego@Sun.COM * and this is SmbReadX/SmbWriteX since this enables 6788934SJose.Borrego@Sun.COM * large reads/write and bcc is only 16-bits. 6798934SJose.Borrego@Sun.COM */ 6808934SJose.Borrego@Sun.COM if (((sr->smb_com == SMB_COM_READ_ANDX) && 6818934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_READX)) || 6828934SJose.Borrego@Sun.COM ((sr->smb_com == SMB_COM_WRITE_ANDX) && 6838934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_WRITEX))) { 6848934SJose.Borrego@Sun.COM byte_count = sr->command.max_bytes - sr->command.chain_offset; 6858934SJose.Borrego@Sun.COM } else { 6868934SJose.Borrego@Sun.COM byte_count = (uint32_t)sr->smb_bcc; 6878934SJose.Borrego@Sun.COM } 6888934SJose.Borrego@Sun.COM 6895331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command, 6908934SJose.Borrego@Sun.COM sr->command.chain_offset, byte_count); 6915331Samw 6928934SJose.Borrego@Sun.COM sr->command.chain_offset += byte_count; 6935331Samw if (sr->command.chain_offset > sr->command.max_bytes) { 6946030Sjb150015 disconnect = B_TRUE; 6956030Sjb150015 goto report_error; 6965331Samw } 6975331Samw 6985331Samw /* Store pointers for later */ 6995331Samw sr->cur_reply_offset = sr->reply.chain_offset; 7005331Samw 7015331Samw if (is_andx_com(sr->smb_com)) { 7025331Samw /* Peek ahead and don't disturb vwv */ 7037052Samw if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w", 7045331Samw &sr->andx_com, &sr->andx_off) < 0) { 7056030Sjb150015 disconnect = B_TRUE; 7066030Sjb150015 goto report_error; 7075331Samw } 7085331Samw } else { 7095331Samw sr->andx_com = (unsigned char)-1; 7105331Samw } 7115331Samw 7125331Samw mutex_enter(&sr->sr_mutex); 7135331Samw switch (sr->sr_state) { 7145331Samw case SMB_REQ_STATE_SUBMITTED: 7155331Samw case SMB_REQ_STATE_CLEANED_UP: 7165331Samw sr->sr_state = SMB_REQ_STATE_ACTIVE; 7175331Samw break; 7185331Samw case SMB_REQ_STATE_CANCELED: 7195331Samw break; 7205331Samw default: 7215331Samw ASSERT(0); 7225331Samw break; 7235331Samw } 7245331Samw mutex_exit(&sr->sr_mutex); 7255331Samw 7266030Sjb150015 /* 7276030Sjb150015 * Setup UID and TID information (if required). Both functions 7286030Sjb150015 * will set the sr credentials. In domain mode, the user and 7296030Sjb150015 * tree credentials should be the same. In share mode, the 7306030Sjb150015 * tree credentials (defined in the share definition) should 7316030Sjb150015 * override the user credentials. 7326030Sjb150015 */ 7336139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) { 7348262SJose.Borrego@Sun.COM sr->uid_user = smb_user_lookup_by_uid(session, sr->smb_uid); 7356030Sjb150015 if (sr->uid_user == NULL) { 7366030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRbaduid); 7376139Sjb150015 smbsr_cleanup(sr); 7386030Sjb150015 goto report_error; 7395331Samw } 7405331Samw 7417961SNatalie.Li@Sun.COM sr->user_cr = smb_user_getcred(sr->uid_user); 7427961SNatalie.Li@Sun.COM 7436139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && 7446139Sjb150015 (sr->tid_tree == NULL)) { 7457348SJose.Borrego@Sun.COM sr->tid_tree = smb_user_lookup_tree( 7466030Sjb150015 sr->uid_user, sr->smb_tid); 7476030Sjb150015 if (sr->tid_tree == NULL) { 7486030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRinvnid); 7496139Sjb150015 smbsr_cleanup(sr); 7506030Sjb150015 goto report_error; 7515331Samw } 7525331Samw } 7535331Samw } 7545331Samw 7556030Sjb150015 /* 7566030Sjb150015 * If the command is not a read raw request we can set the 7576030Sjb150015 * state of the session back to SMB_SESSION_STATE_NEGOTIATED 7586030Sjb150015 * (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING). 7596030Sjb150015 * Otherwise we let the read raw handler to deal with it. 7606030Sjb150015 */ 7618262SJose.Borrego@Sun.COM if ((session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) && 7626030Sjb150015 (sr->smb_com != SMB_COM_READ_RAW)) { 7636030Sjb150015 krw_t mode; 7646030Sjb150015 /* 7656030Sjb150015 * The lock may have to be upgraded because, at this 7666030Sjb150015 * point, we don't know how it was entered. We just 7676030Sjb150015 * know that it has to be entered in writer mode here. 7686030Sjb150015 * Whatever mode was used to enter the lock, it will 7696030Sjb150015 * be restored. 7706030Sjb150015 */ 7718262SJose.Borrego@Sun.COM mode = smb_rwx_rwupgrade(&session->s_lock); 7728262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) 7738262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7746030Sjb150015 7758262SJose.Borrego@Sun.COM smb_rwx_rwdowngrade(&session->s_lock, mode); 7766030Sjb150015 } 7776030Sjb150015 7786030Sjb150015 /* 7796030Sjb150015 * Increment method invocation count. This value is exposed 7806030Sjb150015 * via kstats, and it represents a count of all the dispatched 7816030Sjb150015 * requests, including the ones that have a return value, other 7826139Sjb150015 * than SDRC_SUCCESS. 7836030Sjb150015 */ 7846030Sjb150015 SMB_ALL_DISPATCH_STAT_INCR(sdd->sdt_dispatch_stats.value.ui64); 7856030Sjb150015 7866139Sjb150015 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS) 7876139Sjb150015 sdrc = (*sdd->sdt_function)(sr); 7886139Sjb150015 7896139Sjb150015 if (sdrc != SDRC_SUCCESS) { 7906030Sjb150015 /* 7916030Sjb150015 * Handle errors from raw write. 7926030Sjb150015 */ 7938262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_WRITE_RAW_ACTIVE) { 7946030Sjb150015 /* 7956030Sjb150015 * Set state so that the netbios session 7966030Sjb150015 * daemon will start accepting data again. 7976030Sjb150015 */ 7988262SJose.Borrego@Sun.COM session->s_write_raw_status = 0; 7998262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 8006030Sjb150015 } 8016030Sjb150015 } 8028262SJose.Borrego@Sun.COM if (sdrc != SDRC_SR_KEPT) { 8038262SJose.Borrego@Sun.COM (*sdd->sdt_post_op)(sr); 8046030Sjb150015 smbsr_cleanup(sr); 8058262SJose.Borrego@Sun.COM } 8066030Sjb150015 8076030Sjb150015 switch (sdrc) { 8086139Sjb150015 case SDRC_SUCCESS: 8096030Sjb150015 break; 8106030Sjb150015 8116030Sjb150015 case SDRC_DROP_VC: 8126030Sjb150015 disconnect = B_TRUE; 8136030Sjb150015 goto drop_connection; 8146030Sjb150015 8156030Sjb150015 case SDRC_NO_REPLY: 8168262SJose.Borrego@Sun.COM smb_rwx_rwexit(&session->s_lock); 8178262SJose.Borrego@Sun.COM return (B_TRUE); 8188262SJose.Borrego@Sun.COM 8198262SJose.Borrego@Sun.COM case SDRC_SR_KEPT: 8208262SJose.Borrego@Sun.COM smb_rwx_rwexit(&session->s_lock); 8218262SJose.Borrego@Sun.COM return (B_FALSE); 8226030Sjb150015 8236139Sjb150015 case SDRC_ERROR: 8246030Sjb150015 goto report_error; 8256030Sjb150015 8266139Sjb150015 case SDRC_NOT_IMPLEMENTED: 8276030Sjb150015 default: 8286030Sjb150015 smbsr_error(sr, 0, ERRDOS, ERRbadfunc); 8296030Sjb150015 goto report_error; 8306030Sjb150015 } 8316030Sjb150015 8326030Sjb150015 /* 8336030Sjb150015 * If there's no AndX command, we're done. 8346030Sjb150015 */ 8355331Samw if (sr->andx_com == 0xff) 8365331Samw goto reply_ready; 8375331Samw 8386030Sjb150015 /* 8396030Sjb150015 * Otherwise, we have to back-patch the AndXCommand and AndXOffset 8406030Sjb150015 * and continue processing. 8416030Sjb150015 */ 8425331Samw sr->andx_prev_wct = sr->cur_reply_offset; 8437052Samw (void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w", 8445331Samw sr->andx_com, MBC_LENGTH(&sr->reply)); 8455331Samw 8468262SJose.Borrego@Sun.COM smb_rwx_rwexit(&session->s_lock); 8475331Samw 8485331Samw sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off; 8495331Samw sr->smb_com = sr->andx_com; 8505331Samw goto andx_more; 8515331Samw 8526030Sjb150015 report_error: 8535331Samw sr->reply.chain_offset = sr->cur_reply_offset; 8547052Samw (void) smb_mbc_encodef(&sr->reply, "bw", 0, 0); 8555331Samw 8565331Samw sr->smb_wct = 0; 8575331Samw sr->smb_bcc = 0; 8585331Samw 8596139Sjb150015 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0) 8606030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 8616030Sjb150015 8626030Sjb150015 reply_ready: 8636030Sjb150015 smbsr_send_reply(sr); 8646030Sjb150015 8656030Sjb150015 drop_connection: 8666030Sjb150015 if (disconnect) { 8678262SJose.Borrego@Sun.COM switch (session->s_state) { 8686030Sjb150015 case SMB_SESSION_STATE_DISCONNECTED: 8696030Sjb150015 case SMB_SESSION_STATE_TERMINATED: 8706030Sjb150015 break; 8716030Sjb150015 default: 8728262SJose.Borrego@Sun.COM smb_soshutdown(session->sock); 8738262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_DISCONNECTED; 8746030Sjb150015 break; 8756030Sjb150015 } 8765331Samw } 8776030Sjb150015 8788262SJose.Borrego@Sun.COM smb_rwx_rwexit(&session->s_lock); 8798262SJose.Borrego@Sun.COM 8808262SJose.Borrego@Sun.COM return (B_TRUE); 8815331Samw } 8825331Samw 8836030Sjb150015 int 8846030Sjb150015 smbsr_encode_empty_result(struct smb_request *sr) 8856030Sjb150015 { 8866030Sjb150015 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0)); 8876030Sjb150015 } 8885331Samw 8896030Sjb150015 int 8906030Sjb150015 smbsr_encode_result(struct smb_request *sr, int wct, int bcc, char *fmt, ...) 8915331Samw { 8925331Samw va_list ap; 8935331Samw 8946030Sjb150015 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset) 8956030Sjb150015 return (-1); 8965331Samw 8975331Samw va_start(ap, fmt); 8987052Samw (void) smb_mbc_vencodef(&sr->reply, fmt, ap); 8995331Samw va_end(ap); 9005331Samw 9015331Samw sr->smb_wct = (unsigned char)wct; 9025331Samw sr->smb_bcc = (uint16_t)bcc; 9035331Samw 9046030Sjb150015 if (smbsr_check_result(sr, wct, bcc) != 0) 9056030Sjb150015 return (-1); 9066030Sjb150015 9076030Sjb150015 return (0); 9085331Samw } 9095331Samw 9106030Sjb150015 static int 9115331Samw smbsr_check_result(struct smb_request *sr, int wct, int bcc) 9125331Samw { 9135331Samw int offset = sr->cur_reply_offset; 9145331Samw int total_bytes; 9155331Samw unsigned char temp, temp1; 9165331Samw struct mbuf *m; 9175331Samw 9185331Samw total_bytes = 0; 9195331Samw m = sr->reply.chain; 9205331Samw while (m != 0) { 9215331Samw total_bytes += m->m_len; 9225331Samw m = m->m_next; 9235331Samw } 9245331Samw 9256030Sjb150015 if ((offset + 3) > total_bytes) 9266030Sjb150015 return (-1); 9275331Samw 9287052Samw (void) smb_mbc_peek(&sr->reply, offset, "b", &temp); 9296030Sjb150015 if (temp != wct) 9306030Sjb150015 return (-1); 9315331Samw 9326030Sjb150015 if ((offset + (wct * 2 + 1)) > total_bytes) 9336030Sjb150015 return (-1); 9345331Samw 9355331Samw /* reply wct & vwv seem ok, consider data now */ 9365331Samw offset += wct * 2 + 1; 9375331Samw 9386030Sjb150015 if ((offset + 2) > total_bytes) 9396030Sjb150015 return (-1); 9405331Samw 9417052Samw (void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1); 9425331Samw if (bcc == VAR_BCC) { 9435331Samw if ((temp != 0xFF) || (temp1 != 0xFF)) { 9446030Sjb150015 return (-1); 9455331Samw } else { 9465331Samw bcc = (total_bytes - offset) - 2; 9477052Samw (void) smb_mbc_poke(&sr->reply, offset, "bb", 9485331Samw bcc, bcc >> 8); 9495331Samw } 9505331Samw } else { 9516030Sjb150015 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF))) 9526030Sjb150015 return (-1); 9535331Samw } 9545331Samw 9555331Samw offset += bcc + 2; 9565331Samw 9576030Sjb150015 if (offset != total_bytes) 9586030Sjb150015 return (-1); 9595331Samw 9605331Samw sr->smb_wct = (unsigned char)wct; 9615331Samw sr->smb_bcc = (uint16_t)bcc; 9626030Sjb150015 return (0); 9635331Samw } 9645331Samw 9655331Samw int 9665331Samw smbsr_decode_vwv(struct smb_request *sr, char *fmt, ...) 9675331Samw { 9685331Samw int rc; 9695331Samw va_list ap; 9705331Samw 9715331Samw va_start(ap, fmt); 9727052Samw rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap); 9735331Samw va_end(ap); 9745331Samw 9756139Sjb150015 if (rc) 9766139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9775331Samw return (rc); 9785331Samw } 9795331Samw 9805331Samw int 9815331Samw smbsr_decode_data(struct smb_request *sr, char *fmt, ...) 9825331Samw { 9836139Sjb150015 int rc; 9845331Samw va_list ap; 9856139Sjb150015 9865331Samw va_start(ap, fmt); 9877052Samw rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap); 9885331Samw va_end(ap); 9896139Sjb150015 9906139Sjb150015 if (rc) 9916139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9926139Sjb150015 return (rc); 9935331Samw } 9945331Samw 9955331Samw void 9965331Samw smbsr_send_reply(struct smb_request *sr) 9975331Samw { 9987348SJose.Borrego@Sun.COM if (SMB_TREE_IS_CASEINSENSITIVE(sr)) 9996030Sjb150015 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE; 10006030Sjb150015 else 10016030Sjb150015 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE; 10026030Sjb150015 10037052Samw (void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT, 10045331Samw sr->first_smb_com, 10055331Samw sr->smb_rcls, 10065331Samw sr->smb_reh, 10075331Samw sr->smb_err, 10085331Samw sr->smb_flg | SMB_FLAGS_REPLY, 10095331Samw sr->smb_flg2, 10105331Samw sr->smb_pid_high, 10115331Samw sr->smb_sig, 10125331Samw sr->smb_tid, 10135331Samw sr->smb_pid, 10145331Samw sr->smb_uid, 10155331Samw sr->smb_mid); 10165331Samw 10175331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 10185331Samw smb_sign_reply(sr, NULL); 10195331Samw 10206030Sjb150015 if (smb_session_send(sr->session, 0, &sr->reply) == 0) 10216030Sjb150015 sr->reply.chain = 0; 10225331Samw } 10235331Samw 10245331Samw /* 10255772Sas200622 * Map errno values to SMB and NT status values. 10265772Sas200622 * Note: ESRCH is a special case to handle a streams lookup failure. 10275331Samw */ 10285331Samw static struct { 10295772Sas200622 int errnum; 10305772Sas200622 int errcls; 10315772Sas200622 int errcode; 10325772Sas200622 DWORD status32; 10335772Sas200622 } smb_errno_map[] = { 10345331Samw { ENOSPC, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10355331Samw { EDQUOT, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10365331Samw { EPERM, ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED }, 10375331Samw { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, 10385331Samw { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, 10395331Samw { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE }, 10405331Samw { ENOTEMPTY, ERRDOS, ERROR_DIR_NOT_EMPTY, 10415331Samw NT_STATUS_DIRECTORY_NOT_EMPTY }, 1042*9231SAfshin.Ardakani@Sun.COM { EILSEQ, ERRDOS, ERROR_INVALID_NAME, 1043*9231SAfshin.Ardakani@Sun.COM NT_STATUS_OBJECT_NAME_INVALID }, 10445331Samw { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, 10455331Samw { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY }, 10465331Samw { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, 10475331Samw { EXDEV, ERRSRV, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, 10485331Samw { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, 1049*9231SAfshin.Ardakani@Sun.COM { ESTALE, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 1050*9231SAfshin.Ardakani@Sun.COM { EBADF, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 1051*9231SAfshin.Ardakani@Sun.COM { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION }, 1052*9231SAfshin.Ardakani@Sun.COM { ENXIO, ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE }, 10535331Samw { ESRCH, ERRDOS, ERROR_FILE_NOT_FOUND, 10545331Samw NT_STATUS_OBJECT_NAME_NOT_FOUND }, 10555331Samw /* 10565331Samw * It's not clear why smb_read_common effectively returns 10575331Samw * ERRnoaccess if a range lock prevents access and smb_write_common 10585331Samw * effectively returns ERRaccess. This table entry is used by 10595331Samw * smb_read_common and preserves the behavior that was there before. 10605331Samw */ 10615331Samw { ERANGE, ERRDOS, ERRnoaccess, NT_STATUS_FILE_LOCK_CONFLICT } 10625331Samw }; 10635331Samw 10645331Samw void 10655772Sas200622 smbsr_map_errno(int errnum, smb_error_t *err) 10665331Samw { 10675331Samw int i; 10685331Samw 10695772Sas200622 for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) { 10705772Sas200622 if (smb_errno_map[i].errnum == errnum) { 10715772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10725772Sas200622 err->status = smb_errno_map[i].status32; 10735772Sas200622 err->errcls = smb_errno_map[i].errcls; 10745772Sas200622 err->errcode = smb_errno_map[i].errcode; 10755772Sas200622 return; 10765331Samw } 10775331Samw } 10785331Samw 10795772Sas200622 err->severity = ERROR_SEVERITY_ERROR; 10805772Sas200622 err->status = NT_STATUS_INTERNAL_ERROR; 10815772Sas200622 err->errcls = ERRDOS; 10825772Sas200622 err->errcode = ERROR_INTERNAL_ERROR; 10835331Samw } 10845331Samw 10855331Samw void 10865772Sas200622 smbsr_errno(struct smb_request *sr, int errnum) 10875772Sas200622 { 10886030Sjb150015 smbsr_map_errno(errnum, &sr->smb_error); 10896030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 10905772Sas200622 } 10915772Sas200622 10925772Sas200622 /* 10935772Sas200622 * Report a request processing warning. 10945772Sas200622 */ 10955772Sas200622 void 10965772Sas200622 smbsr_warn(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 10975772Sas200622 { 10986030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_WARNING; 10996030Sjb150015 sr->smb_error.status = status; 11006030Sjb150015 sr->smb_error.errcls = errcls; 11016030Sjb150015 sr->smb_error.errcode = errcode; 11025772Sas200622 11036030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 11045772Sas200622 } 11055772Sas200622 11065772Sas200622 /* 11075772Sas200622 * Report a request processing error. This function will not return. 11085772Sas200622 */ 11095772Sas200622 void 11105772Sas200622 smbsr_error(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode) 11115331Samw { 11126030Sjb150015 sr->smb_error.severity = ERROR_SEVERITY_ERROR; 11136030Sjb150015 sr->smb_error.status = status; 11146030Sjb150015 sr->smb_error.errcls = errcls; 11156030Sjb150015 sr->smb_error.errcode = errcode; 11165772Sas200622 11176030Sjb150015 smbsr_set_error(sr, &sr->smb_error); 11185772Sas200622 } 11195772Sas200622 11205772Sas200622 /* 11215772Sas200622 * Setup a request processing error. This function can be used to 11225772Sas200622 * report 32-bit status codes or DOS errors. Set the status code 11235772Sas200622 * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error, 11245772Sas200622 * regardless of the client capabilities. 11255772Sas200622 * 11265772Sas200622 * If status is non-zero and the client supports 32-bit status 11275772Sas200622 * codes, report the status. Otherwise, report the DOS error. 11285772Sas200622 */ 11295772Sas200622 void 11305772Sas200622 smbsr_set_error(smb_request_t *sr, smb_error_t *err) 11315772Sas200622 { 11325772Sas200622 uint32_t status; 11335772Sas200622 uint32_t severity; 11345772Sas200622 uint32_t capabilities; 11355772Sas200622 11365772Sas200622 ASSERT(sr); 11375772Sas200622 ASSERT(err); 11385772Sas200622 11395772Sas200622 status = err->status; 11405772Sas200622 severity = (err->severity == 0) ? ERROR_SEVERITY_ERROR : err->severity; 11415772Sas200622 capabilities = sr->session->capabilities; 11425772Sas200622 11435772Sas200622 if ((err->errcls == 0) && (err->errcode == 0)) { 11445772Sas200622 capabilities |= CAP_STATUS32; 11455772Sas200622 if (status == 0) 11465772Sas200622 status = NT_STATUS_INTERNAL_ERROR; 11475772Sas200622 } 11485772Sas200622 11495772Sas200622 if ((capabilities & CAP_STATUS32) && (status != 0)) { 11505772Sas200622 status |= severity; 11515772Sas200622 sr->smb_rcls = status & 0xff; 11525772Sas200622 sr->smb_reh = (status >> 8) & 0xff; 11535772Sas200622 sr->smb_err = status >> 16; 11545772Sas200622 sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS; 11555772Sas200622 } else { 11565772Sas200622 if ((err->errcls == 0) || (err->errcode == 0)) { 11575772Sas200622 sr->smb_rcls = ERRSRV; 11585772Sas200622 sr->smb_err = ERRerror; 11595772Sas200622 } else { 11605772Sas200622 sr->smb_rcls = (uint8_t)err->errcls; 11615772Sas200622 sr->smb_err = (uint16_t)err->errcode; 11625331Samw } 11635331Samw } 11645331Samw } 11655331Samw 11665331Samw smb_xa_t * 11675331Samw smbsr_lookup_xa(smb_request_t *sr) 11685331Samw { 11695331Samw ASSERT(sr->r_xa == 0); 11705331Samw 11715331Samw sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid); 11725331Samw return (sr->r_xa); 11735331Samw } 11745331Samw 11755331Samw void 11765331Samw smbsr_disconnect_file(smb_request_t *sr) 11775331Samw { 11785331Samw smb_ofile_t *of = sr->fid_ofile; 11795331Samw 11805331Samw sr->fid_ofile = NULL; 11815331Samw (void) smb_ofile_release(of); 11825331Samw } 11835331Samw 11848934SJose.Borrego@Sun.COM void 11858934SJose.Borrego@Sun.COM smbsr_lookup_file(smb_request_t *sr) 11868934SJose.Borrego@Sun.COM { 11878934SJose.Borrego@Sun.COM if (sr->fid_ofile == NULL) 11888934SJose.Borrego@Sun.COM sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree, 11898934SJose.Borrego@Sun.COM sr->smb_fid); 11908934SJose.Borrego@Sun.COM } 11918934SJose.Borrego@Sun.COM 11925331Samw static int 11935331Samw is_andx_com(unsigned char com) 11945331Samw { 11955331Samw switch (com) { 11965331Samw case SMB_COM_LOCKING_ANDX: 11975331Samw case SMB_COM_OPEN_ANDX: 11985331Samw case SMB_COM_READ_ANDX: 11995331Samw case SMB_COM_WRITE_ANDX: 12005331Samw case SMB_COM_SESSION_SETUP_ANDX: 12015331Samw case SMB_COM_LOGOFF_ANDX: 12025331Samw case SMB_COM_TREE_CONNECT_ANDX: 12035331Samw case SMB_COM_NT_CREATE_ANDX: 12045331Samw return (1); 12055331Samw } 12065331Samw return (0); 12075331Samw } 12085331Samw 12095331Samw /* 12106139Sjb150015 * Invalid command stubs. 12116139Sjb150015 * 12126139Sjb150015 * SmbWriteComplete is sent to acknowledge completion of raw write requests. 12136139Sjb150015 * We never send raw write commands to other servers so, if we receive 12146139Sjb150015 * SmbWriteComplete, we treat it as an error. 12156139Sjb150015 * 12166139Sjb150015 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize 12176139Sjb150015 * performance when reading/writing a large block of data: it can be 12186139Sjb150015 * used in parallel with other client/server operations. The mpx sub- 12196139Sjb150015 * protocol is not supported because we support only connection oriented 12206139Sjb150015 * transports and NT supports mpx only over connectionless transports. 12215331Samw */ 12226030Sjb150015 smb_sdrc_t 12236139Sjb150015 smb_pre_invalid(smb_request_t *sr) 12246139Sjb150015 { 12256139Sjb150015 DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr); 12266139Sjb150015 return (SDRC_SUCCESS); 12276139Sjb150015 } 12286139Sjb150015 12296139Sjb150015 void 12306139Sjb150015 smb_post_invalid(smb_request_t *sr) 12316139Sjb150015 { 12326139Sjb150015 DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr); 12336139Sjb150015 } 12346139Sjb150015 12356139Sjb150015 smb_sdrc_t 12366139Sjb150015 smb_com_invalid(smb_request_t *sr) 12375331Samw { 12386139Sjb150015 smb_sdrc_t sdrc; 12396139Sjb150015 12406139Sjb150015 switch (sr->smb_com) { 12416139Sjb150015 case SMB_COM_WRITE_COMPLETE: 12426139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 12436139Sjb150015 sdrc = SDRC_ERROR; 12446139Sjb150015 break; 12456139Sjb150015 12466139Sjb150015 default: 12476139Sjb150015 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED, 12486139Sjb150015 ERRDOS, ERROR_INVALID_FUNCTION); 12496139Sjb150015 sdrc = SDRC_NOT_IMPLEMENTED; 12506139Sjb150015 break; 12516139Sjb150015 } 12526139Sjb150015 12536139Sjb150015 return (sdrc); 12545331Samw } 12555331Samw 12565331Samw /* 12576139Sjb150015 * smb_dispatch_kstat_update 12585331Samw * 12595331Samw * This callback function updates the smb_dispatch_kstat_data when kstat 12605331Samw * command is invoked. 12615331Samw */ 12625331Samw static int 12636139Sjb150015 smb_dispatch_kstat_update(kstat_t *ksp, int rw) 12645331Samw { 12658934SJose.Borrego@Sun.COM smb_disp_entry_t *sdd; 12668934SJose.Borrego@Sun.COM kstat_named_t *ks_named; 12676139Sjb150015 int i; 12685331Samw 12696139Sjb150015 if (rw == KSTAT_WRITE) 12705331Samw return (EACCES); 12716139Sjb150015 12726139Sjb150015 ASSERT(MUTEX_HELD(ksp->ks_lock)); 12736139Sjb150015 12746139Sjb150015 ks_named = ksp->ks_data; 12756139Sjb150015 for (i = 0; i < SMB_COM_NUM; i++) { 12766139Sjb150015 sdd = &dispatch[i]; 12776139Sjb150015 12786139Sjb150015 if (sdd->sdt_function != smb_com_invalid) { 12796139Sjb150015 bcopy(&sdd->sdt_dispatch_stats, ks_named, 12806139Sjb150015 sizeof (kstat_named_t)); 12816139Sjb150015 ++ks_named; 12825331Samw } 12835331Samw } 12846139Sjb150015 12855331Samw return (0); 12865331Samw } 12875331Samw 12885331Samw /* 12896139Sjb150015 * smb_dispatch_kstat_init 12905331Samw * 12915331Samw * Initialize dispatch kstats. 12925331Samw */ 12935331Samw void 12946139Sjb150015 smb_dispatch_kstat_init(void) 12955331Samw { 12966139Sjb150015 int ks_ndata; 12976139Sjb150015 int i; 12985331Samw 12996139Sjb150015 for (i = 0, ks_ndata = 0; i < SMB_COM_NUM; i++) { 13006139Sjb150015 if (dispatch[i].sdt_function != smb_com_invalid) 13016139Sjb150015 ks_ndata++; 13025331Samw } 13035331Samw 13046432Sas200622 smb_dispatch_ksp = kstat_create(SMBSRV_KSTAT_MODULE, 0, 13056432Sas200622 SMBSRV_KSTAT_NAME_CMDS, SMBSRV_KSTAT_CLASS, 13066139Sjb150015 KSTAT_TYPE_NAMED, ks_ndata, 0); 13075331Samw 13085331Samw if (smb_dispatch_ksp) { 13096139Sjb150015 mutex_init(&smb_dispatch_ksmtx, NULL, MUTEX_DEFAULT, NULL); 13106139Sjb150015 smb_dispatch_ksp->ks_update = smb_dispatch_kstat_update; 13116139Sjb150015 smb_dispatch_ksp->ks_lock = &smb_dispatch_ksmtx; 13125331Samw kstat_install(smb_dispatch_ksp); 13135331Samw } 13145331Samw } 13155331Samw 13165331Samw /* 13176139Sjb150015 * smb_dispatch_kstat_fini 13185331Samw * 13195331Samw * Remove dispatch kstats. 13205331Samw */ 13215331Samw void 13226139Sjb150015 smb_dispatch_kstat_fini(void) 13235331Samw { 13245331Samw if (smb_dispatch_ksp != NULL) { 13255331Samw kstat_delete(smb_dispatch_ksp); 13266139Sjb150015 mutex_destroy(&smb_dispatch_ksmtx); 13275331Samw smb_dispatch_ksp = NULL; 13285331Samw } 13295331Samw } 1330