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 */ 1539343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1545331Samw { "SmbCreateDirectory", KSTAT_DATA_UINT64 } }, 1556139Sjb150015 { SMB_SDT_OPS(delete_directory), /* 0x01 001 */ 1569343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1575331Samw { "SmbDeleteDirectory", KSTAT_DATA_UINT64 } }, 1586139Sjb150015 { SMB_SDT_OPS(open), /* 0x02 002 */ 1599343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1605331Samw { "SmbOpen", KSTAT_DATA_UINT64 } }, 1616139Sjb150015 { SMB_SDT_OPS(create), /* 0x03 003 */ 1629343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1635331Samw { "SmbCreate", KSTAT_DATA_UINT64 } }, 1646139Sjb150015 { SMB_SDT_OPS(close), /* 0x04 004 */ 1659343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1665331Samw { "SmbClose", KSTAT_DATA_UINT64 } }, 1676139Sjb150015 { SMB_SDT_OPS(flush), /* 0x05 005 */ 1689343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1695331Samw { "SmbFlush", KSTAT_DATA_UINT64 } }, 1706139Sjb150015 { SMB_SDT_OPS(delete), /* 0x06 006 */ 1719343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1725331Samw { "SmbDelete", KSTAT_DATA_UINT64 } }, 1736139Sjb150015 { SMB_SDT_OPS(rename), /* 0x07 007 */ 1749343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1755331Samw { "SmbRename", KSTAT_DATA_UINT64 } }, 1766139Sjb150015 { SMB_SDT_OPS(query_information), /* 0x08 008 */ 1779343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1785331Samw { "SmbQueryInformation", KSTAT_DATA_UINT64 } }, 1796139Sjb150015 { SMB_SDT_OPS(set_information), /* 0x09 009 */ 1809343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1815331Samw { "SmbSetInformation", KSTAT_DATA_UINT64 } }, 1826139Sjb150015 { SMB_SDT_OPS(read), /* 0x0A 010 */ 1839343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1845331Samw { "SmbRead", KSTAT_DATA_UINT64 } }, 1856139Sjb150015 { SMB_SDT_OPS(write), /* 0x0B 011 */ 1869343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1875331Samw { "SmbWrite", KSTAT_DATA_UINT64 } }, 1886139Sjb150015 { SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */ 1899343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1905331Samw { "SmbLockByteRange", KSTAT_DATA_UINT64 } }, 1916139Sjb150015 { SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */ 1929343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1935331Samw { "SmbUnlockByteRange", KSTAT_DATA_UINT64 } }, 1946139Sjb150015 { SMB_SDT_OPS(create_temporary), /* 0x0E 014 */ 1959343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1965331Samw { "SmbCreateTemporary", KSTAT_DATA_UINT64 } }, 1976139Sjb150015 { SMB_SDT_OPS(create_new), /* 0x0F 015 */ 1989343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 1995331Samw { "SmbCreateNew", KSTAT_DATA_UINT64 } }, 2006139Sjb150015 { SMB_SDT_OPS(check_directory), /* 0x10 016 */ 2019343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 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 { "SmbProcessExit", KSTAT_DATA_UINT64 } }, 2066139Sjb150015 { SMB_SDT_OPS(seek), /* 0x12 018 */ 2079343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 2085331Samw { "SmbSeek", KSTAT_DATA_UINT64 } }, 2096139Sjb150015 { SMB_SDT_OPS(lock_and_read), /* 0x13 019 */ 2109343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2115331Samw { "SmbLockAndRead", KSTAT_DATA_UINT64 } }, 2126139Sjb150015 { SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */ 2139343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2145331Samw { "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } }, 2159343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x15 021 */ 2169343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x16 022 */ 2179343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x17 023 */ 2189343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x18 024 */ 2199343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x19 025 */ 2206139Sjb150015 { SMB_SDT_OPS(read_raw), /* 0x1A 026 */ 2219343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2225331Samw { "SmbReadRaw", KSTAT_DATA_UINT64 } }, 2239343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1B 027 */ 2249343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1C 028 */ 2256139Sjb150015 { SMB_SDT_OPS(write_raw), /* 0x1D 029 */ 2269343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2275331Samw { "SmbWriteRaw", KSTAT_DATA_UINT64 } }, 2289343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1E 030 */ 2299343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1F 031 */ 2309343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x20 032 */ 2319343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x21 033 */ 2326139Sjb150015 { SMB_SDT_OPS(set_information2), /* 0x22 034 */ 2339343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2345331Samw { "SmbSetInformation2", KSTAT_DATA_UINT64 } }, 2356139Sjb150015 { SMB_SDT_OPS(query_information2), /* 0x23 035 */ 2369343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2375331Samw { "SmbQueryInformation2", KSTAT_DATA_UINT64 } }, 2386139Sjb150015 { SMB_SDT_OPS(locking_andx), /* 0x24 036 */ 2399343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2405331Samw { "SmbLockingX", KSTAT_DATA_UINT64 } }, 2416139Sjb150015 { SMB_SDT_OPS(transaction), /* 0x25 037 */ 2429343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2435331Samw { "SmbTransaction", KSTAT_DATA_UINT64 } }, 2446139Sjb150015 { SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */ 2459343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2465331Samw { "SmbTransactionSecondary", KSTAT_DATA_UINT64 } }, 2476139Sjb150015 { SMB_SDT_OPS(ioctl), /* 0x27 039 */ 2489343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2495331Samw { "SmbIoctl", KSTAT_DATA_UINT64 } }, 2509343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x28 040 */ 2519343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x29 041 */ 2529343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x2A 042 */ 2536139Sjb150015 { SMB_SDT_OPS(echo), /* 0x2B 043 */ 2545331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 2555331Samw { "SmbEcho", KSTAT_DATA_UINT64 } }, 2566139Sjb150015 { SMB_SDT_OPS(write_and_close), /* 0x2C 044 */ 2579343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2585331Samw { "SmbWriteAndClose", KSTAT_DATA_UINT64 } }, 2596139Sjb150015 { SMB_SDT_OPS(open_andx), /* 0x2D 045 */ 2609343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2615331Samw { "SmbOpenX", KSTAT_DATA_UINT64 } }, 2626139Sjb150015 { SMB_SDT_OPS(read_andx), /* 0x2E 046 */ 2639343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2645331Samw { "SmbReadX", KSTAT_DATA_UINT64 } }, 2656139Sjb150015 { SMB_SDT_OPS(write_andx), /* 0x2F 047 */ 2669343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2675331Samw { "SmbWriteX", KSTAT_DATA_UINT64 } }, 2689343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x30 048 */ 2696139Sjb150015 { SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */ 2709343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 2715331Samw { "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } }, 2726139Sjb150015 { SMB_SDT_OPS(transaction2), /* 0x32 050 */ 2739343SAfshin.Ardakani@Sun.COM LM1_2X002, 0, 2745331Samw { "SmbTransaction2", KSTAT_DATA_UINT64 } }, 2756139Sjb150015 { SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */ 2769343SAfshin.Ardakani@Sun.COM LM1_2X002, 0, 2775331Samw { "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } }, 2786139Sjb150015 { SMB_SDT_OPS(find_close2), /* 0x34 052 */ 2799343SAfshin.Ardakani@Sun.COM LM1_2X002, 0, 2805331Samw { "SmbFindClose2", KSTAT_DATA_UINT64 } }, 2819343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x35 053 */ 2829343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x36 054 */ 2839343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x37 055 */ 2849343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x38 056 */ 2859343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x39 057 */ 2869343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3A 058 */ 2879343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3B 059 */ 2889343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3C 060 */ 2899343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3D 061 */ 2909343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3E 062 */ 2919343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3F 063 */ 2929343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x40 064 */ 2939343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x41 065 */ 2949343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x42 066 */ 2959343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x43 067 */ 2969343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x44 068 */ 2979343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x45 069 */ 2989343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x46 070 */ 2999343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x47 071 */ 3009343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x48 072 */ 3019343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x49 073 */ 3029343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4A 074 */ 3039343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4B 075 */ 3049343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4C 076 */ 3059343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4D 077 */ 3069343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4E 078 */ 3079343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4F 079 */ 3089343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x50 080 */ 3099343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x51 081 */ 3109343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x52 082 */ 3119343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x53 083 */ 3129343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x54 084 */ 3139343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x55 085 */ 3149343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x56 086 */ 3159343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x57 087 */ 3169343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x58 088 */ 3179343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x59 089 */ 3189343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5A 090 */ 3199343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5B 091 */ 3209343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5C 092 */ 3219343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5D 093 */ 3229343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5E 094 */ 3239343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5F 095 */ 3249343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x60 096 */ 3259343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x61 097 */ 3269343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x62 098 */ 3279343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x63 099 */ 3289343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x64 100 */ 3299343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x65 101 */ 3309343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x66 102 */ 3319343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x67 103 */ 3329343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x68 104 */ 3339343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x69 105 */ 3349343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6A 106 */ 3359343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6B 107 */ 3369343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6C 108 */ 3379343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6D 109 */ 3389343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6E 110 */ 3399343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6F 111 */ 3406139Sjb150015 { SMB_SDT_OPS(tree_connect), /* 0x70 112 */ 3419343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID, 3425331Samw { "SmbTreeConnect", KSTAT_DATA_UINT64 } }, 3436139Sjb150015 { SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */ 3445331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3455331Samw { "SmbTreeDisconnect", KSTAT_DATA_UINT64 } }, 3466139Sjb150015 { SMB_SDT_OPS(negotiate), /* 0x72 114 */ 3475331Samw PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3485331Samw { "SmbNegotiate", KSTAT_DATA_UINT64 } }, 3496139Sjb150015 { SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */ 3505331Samw LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID, 3515331Samw { "SmbSessionSetupX", KSTAT_DATA_UINT64 } }, 3526139Sjb150015 { SMB_SDT_OPS(logoff_andx), /* 0x74 116 */ 3539343SAfshin.Ardakani@Sun.COM LM1_2X002, SDDF_SUPPRESS_TID, 3545331Samw { "SmbLogoffX", KSTAT_DATA_UINT64 } }, 3556139Sjb150015 { SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */ 3569343SAfshin.Ardakani@Sun.COM LANMAN1_0, SDDF_SUPPRESS_TID, 3575331Samw { "SmbTreeConnectX", KSTAT_DATA_UINT64 } }, 3589343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x76 118 */ 3599343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x77 119 */ 3609343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x78 120 */ 3619343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x79 121 */ 3629343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7A 122 */ 3639343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7B 123 */ 3649343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7C 124 */ 3659343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7D 125 */ 3669343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7E 126 */ 3679343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7F 127 */ 3686139Sjb150015 { SMB_SDT_OPS(query_information_disk), /* 0x80 128 */ 3699343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 3705331Samw { "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } }, 3716139Sjb150015 { SMB_SDT_OPS(search), /* 0x81 129 */ 3729343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 3735331Samw { "SmbSearch", KSTAT_DATA_UINT64 } }, 3746139Sjb150015 { SMB_SDT_OPS(find), /* 0x82 130 */ 3759343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 3765331Samw { "SmbFind", KSTAT_DATA_UINT64 } }, 3776139Sjb150015 { SMB_SDT_OPS(find_unique), /* 0x83 131 */ 3789343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 3795331Samw { "SmbFindUnique", KSTAT_DATA_UINT64 } }, 3806139Sjb150015 { SMB_SDT_OPS(find_close), /* 0x84 132 */ 3819343SAfshin.Ardakani@Sun.COM LANMAN1_0, 0, 3825331Samw { "SmbFindClose", KSTAT_DATA_UINT64 } }, 3839343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x85 133 */ 3849343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x86 134 */ 3859343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x87 135 */ 3869343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x88 136 */ 3879343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x89 137 */ 3889343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8A 138 */ 3899343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8B 139 */ 3909343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8C 140 */ 3919343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8D 141 */ 3929343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8E 142 */ 3939343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8F 143 */ 3949343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x90 144 */ 3959343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x91 145 */ 3969343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x92 146 */ 3979343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x93 147 */ 3989343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x94 148 */ 3999343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x95 149 */ 4009343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x96 150 */ 4019343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x97 151 */ 4029343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x98 152 */ 4039343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x99 153 */ 4049343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9A 154 */ 4059343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9B 155 */ 4069343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9C 156 */ 4079343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9D 157 */ 4089343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9E 158 */ 4099343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9F 159 */ 4106139Sjb150015 { SMB_SDT_OPS(nt_transact), /* 0xA0 160 */ 4119343SAfshin.Ardakani@Sun.COM NT_LM_0_12, 0, 4125331Samw { "SmbNtTransact", KSTAT_DATA_UINT64 } }, 4136139Sjb150015 { SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */ 4149343SAfshin.Ardakani@Sun.COM NT_LM_0_12, 0, 4155331Samw { "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } }, 4166139Sjb150015 { SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */ 4179343SAfshin.Ardakani@Sun.COM NT_LM_0_12, 0, 4185331Samw { "SmbNtCreateX", KSTAT_DATA_UINT64 } }, 4199343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA3 163 */ 4206139Sjb150015 { SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */ 4219343SAfshin.Ardakani@Sun.COM NT_LM_0_12, 0, 4225331Samw { "SmbNtCancel", KSTAT_DATA_UINT64 } }, 4239914Samw@Sun.COM { SMB_SDT_OPS(nt_rename), /* 0xA5 165 */ 4249914Samw@Sun.COM NT_LM_0_12, 0, 4259914Samw@Sun.COM { "SmbNtRename", KSTAT_DATA_UINT64 } }, 4269343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA6 166 */ 4279343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA7 167 */ 4289343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA8 168 */ 4299343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA9 169 */ 4309343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAA 170 */ 4319343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAB 171 */ 4329343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAC 172 */ 4339343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAD 173 */ 4349343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAE 174 */ 4359343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAF 175 */ 4369343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB0 176 */ 4379343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB1 177 */ 4389343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB2 178 */ 4399343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB3 179 */ 4409343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB4 180 */ 4419343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB5 181 */ 4429343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB6 182 */ 4439343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB7 183 */ 4449343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB8 184 */ 4459343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB9 185 */ 4469343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBA 186 */ 4479343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBB 187 */ 4489343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBC 188 */ 4499343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBD 189 */ 4509343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBE 190 */ 4519343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBF 191 */ 4526139Sjb150015 { SMB_SDT_OPS(open_print_file), /* 0xC0 192 */ 4539343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 4545331Samw { "SmbOpenPrintFile", KSTAT_DATA_UINT64 } }, 4556139Sjb150015 { SMB_SDT_OPS(write_print_file), /* 0xC1 193 */ 4569343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 4575331Samw { "SmbWritePrintFile", KSTAT_DATA_UINT64 } }, 4586139Sjb150015 { SMB_SDT_OPS(close_print_file), /* 0xC2 194 */ 4599343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 4605331Samw { "SmbClosePrintFile", KSTAT_DATA_UINT64 } }, 4616139Sjb150015 { SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */ 4629343SAfshin.Ardakani@Sun.COM PC_NETWORK_PROGRAM_1_0, 0, 4635331Samw { "SmbGetPrintQueue", KSTAT_DATA_UINT64 } }, 4649343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC4 196 */ 4659343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC5 197 */ 4669343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC6 198 */ 4679343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC7 199 */ 4689343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC8 200 */ 4699343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC9 201 */ 4709343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCA 202 */ 4719343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCB 203 */ 4729343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCC 204 */ 4739343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCD 205 */ 4749343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCE 206 */ 4759343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCF 207 */ 4769343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD0 208 */ 4779343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD1 209 */ 4789343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD2 210 */ 4799343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD3 211 */ 4809343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD4 212 */ 4819343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD5 213 */ 4829343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD6 214 */ 4839343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD7 215 */ 4849343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD8 216 */ 4859343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD9 217 */ 4869343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDA 218 */ 4879343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDB 219 */ 4889343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDC 220 */ 4899343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDD 221 */ 4909343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDE 222 */ 4919343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDF 223 */ 4929343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE0 224 */ 4939343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE1 225 */ 4949343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE2 226 */ 4959343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE3 227 */ 4969343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE4 228 */ 4979343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE5 229 */ 4989343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE6 230 */ 4999343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE7 231 */ 5009343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE8 232 */ 5019343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE9 233 */ 5029343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEA 234 */ 5039343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEB 235 */ 5049343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEC 236 */ 5059343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xED 237 */ 5069343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEE 238 */ 5079343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEF 239 */ 5089343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF0 240 */ 5099343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF1 241 */ 5109343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF2 242 */ 5119343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF3 243 */ 5129343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF4 244 */ 5139343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF5 245 */ 5149343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF6 246 */ 5159343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF7 247 */ 5169343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF8 248 */ 5179343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF9 249 */ 5189343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFA 250 */ 5199343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFB 251 */ 5209343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFC 252 */ 5219343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFD 253 */ 5229343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), LANMAN1_0, 0, /* 0xFE 254 */ 5235331Samw { "SmbInvalidCommand", KSTAT_DATA_UINT64 } }, 5249343SAfshin.Ardakani@Sun.COM { SMB_SDT_OPS(invalid), 0, 0, 0 } /* 0xFF 255 */ 5255331Samw }; 5265331Samw 5275331Samw /* 5285331Samw * smbsr_cleanup 5295331Samw * 5305331Samw * If any user/tree/file is used by given request then 5315331Samw * the reference count for that resource has been incremented. 5325331Samw * This function decrements the reference count and close 5335331Samw * the resource if it's needed. 5345331Samw */ 5355331Samw 5365331Samw void 5376139Sjb150015 smbsr_cleanup(smb_request_t *sr) 5385331Samw { 5395331Samw ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) && 5405331Samw (sr->sr_state != SMB_REQ_STATE_COMPLETED)); 5415331Samw 5425331Samw if (sr->r_xa) { 5435331Samw if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE) 5445331Samw smb_xa_close(sr->r_xa); 5455331Samw smb_xa_rele(sr->session, sr->r_xa); 5465331Samw sr->r_xa = NULL; 5475331Samw } 5485331Samw 5495331Samw /* 5505331Samw * Mark this request so we know that we've already cleaned it up. 5515331Samw * A request should only get cleaned up once so multiple calls to 5525331Samw * smbsr_cleanup for the same request indicate a bug. 5535331Samw */ 5545331Samw mutex_enter(&sr->sr_mutex); 5555331Samw if (sr->sr_state != SMB_REQ_STATE_CANCELED) 5565331Samw sr->sr_state = SMB_REQ_STATE_CLEANED_UP; 5575331Samw mutex_exit(&sr->sr_mutex); 5585331Samw } 5598262SJose.Borrego@Sun.COM /* 5608262SJose.Borrego@Sun.COM * smb_dispatch_request 5618262SJose.Borrego@Sun.COM * 5628262SJose.Borrego@Sun.COM * Returns: 5638262SJose.Borrego@Sun.COM * 5648262SJose.Borrego@Sun.COM * B_TRUE The caller must free the smb request passed in. 5658262SJose.Borrego@Sun.COM * B_FALSE The caller must not access the smb request passed in. It has 5668262SJose.Borrego@Sun.COM * been kept in an internal queue and may have already been freed. 5678262SJose.Borrego@Sun.COM */ 5688262SJose.Borrego@Sun.COM boolean_t 5695331Samw smb_dispatch_request(struct smb_request *sr) 5705331Samw { 5716030Sjb150015 smb_sdrc_t sdrc; 5728934SJose.Borrego@Sun.COM smb_disp_entry_t *sdd; 5736030Sjb150015 boolean_t disconnect = B_FALSE; 5748262SJose.Borrego@Sun.COM smb_session_t *session; 5758934SJose.Borrego@Sun.COM uint32_t capabilities; 5768934SJose.Borrego@Sun.COM uint32_t byte_count; 5778262SJose.Borrego@Sun.COM 5788262SJose.Borrego@Sun.COM session = sr->session; 5798934SJose.Borrego@Sun.COM capabilities = session->capabilities; 5805331Samw 5815331Samw ASSERT(sr->tid_tree == 0); 5825331Samw ASSERT(sr->uid_user == 0); 5835331Samw ASSERT(sr->fid_ofile == 0); 5845331Samw sr->smb_fid = (uint16_t)-1; 5855331Samw 5865331Samw /* temporary until we identify a user */ 5875331Samw sr->user_cr = kcred; 5885331Samw sr->orig_request_hdr = sr->command.chain_offset; 5895331Samw 5905331Samw /* If this connection is shutting down just kill request */ 5917052Samw if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT, 5925331Samw &sr->smb_com, 5935331Samw &sr->smb_rcls, 5945331Samw &sr->smb_reh, 5955331Samw &sr->smb_err, 5965331Samw &sr->smb_flg, 5975331Samw &sr->smb_flg2, 5985331Samw &sr->smb_pid_high, 5995331Samw sr->smb_sig, 6005331Samw &sr->smb_tid, 6015331Samw &sr->smb_pid, 6025331Samw &sr->smb_uid, 6035331Samw &sr->smb_mid) != 0) { 6046030Sjb150015 disconnect = B_TRUE; 6056030Sjb150015 goto drop_connection; 6065331Samw } 6075331Samw 6085331Samw /* 6096030Sjb150015 * The reply "header" is filled in now even though it will, 6106030Sjb150015 * most likely, be rewritten under reply_ready below. We 6116030Sjb150015 * could reserve the space but this is convenient in case 6126030Sjb150015 * the dialect dispatcher has to send a special reply (like 6136030Sjb150015 * TRANSACT). 6145331Samw * 6155331Samw * Ensure that the 32-bit error code flag is turned off. 6165331Samw * Clients seem to set it in transact requests and they may 6175331Samw * get confused if we return success or a 16-bit SMB code. 6185331Samw */ 6195331Samw sr->smb_rcls = 0; 6205331Samw sr->smb_reh = 0; 6215331Samw sr->smb_err = 0; 6225331Samw sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS; 6235331Samw 6247052Samw (void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT, 6255331Samw sr->smb_com, 6265331Samw sr->smb_rcls, 6275331Samw sr->smb_reh, 6285331Samw sr->smb_err, 6295331Samw sr->smb_flg, 6305331Samw sr->smb_flg2, 6315331Samw sr->smb_pid_high, 6325331Samw sr->smb_sig, 6335331Samw sr->smb_tid, 6345331Samw sr->smb_pid, 6355331Samw sr->smb_uid, 6365331Samw sr->smb_mid); 6375331Samw sr->first_smb_com = sr->smb_com; 6385331Samw 6395331Samw /* 6405772Sas200622 * Verify SMB signature if signing is enabled, dialect is NT LM 0.12, 6415331Samw * signing was negotiated and authentication has occurred. 6425331Samw */ 6438262SJose.Borrego@Sun.COM if (session->signing.flags & SMB_SIGNING_ENABLED) { 6445331Samw if (smb_sign_check_request(sr) != 0) { 6456030Sjb150015 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 6466030Sjb150015 ERRDOS, ERROR_ACCESS_DENIED); 6476030Sjb150015 disconnect = B_TRUE; 6486030Sjb150015 goto report_error; 6495331Samw } 6505331Samw } 6515331Samw 6525331Samw andx_more: 6535331Samw sdd = &dispatch[sr->smb_com]; 6546139Sjb150015 ASSERT(sdd->sdt_function); 6555331Samw 6567052Samw if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) { 6576030Sjb150015 disconnect = B_TRUE; 6586030Sjb150015 goto report_error; 6595331Samw } 6605331Samw 6615331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command, 6625331Samw sr->command.chain_offset, sr->smb_wct * 2); 6635331Samw 6647052Samw if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) { 6656030Sjb150015 disconnect = B_TRUE; 6666030Sjb150015 goto report_error; 6675331Samw } 6685331Samw 6698934SJose.Borrego@Sun.COM /* 6708934SJose.Borrego@Sun.COM * Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX 6718934SJose.Borrego@Sun.COM * and this is SmbReadX/SmbWriteX since this enables 6728934SJose.Borrego@Sun.COM * large reads/write and bcc is only 16-bits. 6738934SJose.Borrego@Sun.COM */ 6748934SJose.Borrego@Sun.COM if (((sr->smb_com == SMB_COM_READ_ANDX) && 6758934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_READX)) || 6768934SJose.Borrego@Sun.COM ((sr->smb_com == SMB_COM_WRITE_ANDX) && 6778934SJose.Borrego@Sun.COM (capabilities & CAP_LARGE_WRITEX))) { 6788934SJose.Borrego@Sun.COM byte_count = sr->command.max_bytes - sr->command.chain_offset; 6798934SJose.Borrego@Sun.COM } else { 6808934SJose.Borrego@Sun.COM byte_count = (uint32_t)sr->smb_bcc; 6818934SJose.Borrego@Sun.COM } 6828934SJose.Borrego@Sun.COM 6835331Samw (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command, 6848934SJose.Borrego@Sun.COM sr->command.chain_offset, byte_count); 6855331Samw 6868934SJose.Borrego@Sun.COM sr->command.chain_offset += byte_count; 6875331Samw if (sr->command.chain_offset > sr->command.max_bytes) { 6886030Sjb150015 disconnect = B_TRUE; 6896030Sjb150015 goto report_error; 6905331Samw } 6915331Samw 6925331Samw /* Store pointers for later */ 6935331Samw sr->cur_reply_offset = sr->reply.chain_offset; 6945331Samw 6955331Samw if (is_andx_com(sr->smb_com)) { 6965331Samw /* Peek ahead and don't disturb vwv */ 6977052Samw if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w", 6985331Samw &sr->andx_com, &sr->andx_off) < 0) { 6996030Sjb150015 disconnect = B_TRUE; 7006030Sjb150015 goto report_error; 7015331Samw } 7025331Samw } else { 7035331Samw sr->andx_com = (unsigned char)-1; 7045331Samw } 7055331Samw 7065331Samw mutex_enter(&sr->sr_mutex); 7075331Samw switch (sr->sr_state) { 7085331Samw case SMB_REQ_STATE_SUBMITTED: 7095331Samw case SMB_REQ_STATE_CLEANED_UP: 7105331Samw sr->sr_state = SMB_REQ_STATE_ACTIVE; 7115331Samw break; 7125331Samw case SMB_REQ_STATE_CANCELED: 7135331Samw break; 7145331Samw default: 7155331Samw ASSERT(0); 7165331Samw break; 7175331Samw } 7185331Samw mutex_exit(&sr->sr_mutex); 7195331Samw 7206030Sjb150015 /* 7216030Sjb150015 * Setup UID and TID information (if required). Both functions 7226030Sjb150015 * will set the sr credentials. In domain mode, the user and 7236030Sjb150015 * tree credentials should be the same. In share mode, the 7246030Sjb150015 * tree credentials (defined in the share definition) should 7256030Sjb150015 * override the user credentials. 7266030Sjb150015 */ 7276139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) { 7288262SJose.Borrego@Sun.COM sr->uid_user = smb_user_lookup_by_uid(session, sr->smb_uid); 7296030Sjb150015 if (sr->uid_user == NULL) { 7306030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRbaduid); 7316139Sjb150015 smbsr_cleanup(sr); 7326030Sjb150015 goto report_error; 7335331Samw } 7345331Samw 7357961SNatalie.Li@Sun.COM sr->user_cr = smb_user_getcred(sr->uid_user); 7367961SNatalie.Li@Sun.COM 7376139Sjb150015 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && 7386139Sjb150015 (sr->tid_tree == NULL)) { 7397348SJose.Borrego@Sun.COM sr->tid_tree = smb_user_lookup_tree( 7406030Sjb150015 sr->uid_user, sr->smb_tid); 7416030Sjb150015 if (sr->tid_tree == NULL) { 7426030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRinvnid); 7436139Sjb150015 smbsr_cleanup(sr); 7446030Sjb150015 goto report_error; 7455331Samw } 7465331Samw } 7475331Samw } 7485331Samw 7496030Sjb150015 /* 7506030Sjb150015 * If the command is not a read raw request we can set the 7516030Sjb150015 * state of the session back to SMB_SESSION_STATE_NEGOTIATED 7526030Sjb150015 * (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING). 7536030Sjb150015 * Otherwise we let the read raw handler to deal with it. 7546030Sjb150015 */ 7559343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_READER); 7568262SJose.Borrego@Sun.COM if ((session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) && 7576030Sjb150015 (sr->smb_com != SMB_COM_READ_RAW)) { 7589343SAfshin.Ardakani@Sun.COM (void) smb_rwx_rwupgrade(&session->s_lock); 7598262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_OPLOCK_BREAKING) 7608262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7616030Sjb150015 } 7629343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 7636030Sjb150015 7646030Sjb150015 /* 7656030Sjb150015 * Increment method invocation count. This value is exposed 7666030Sjb150015 * via kstats, and it represents a count of all the dispatched 7676030Sjb150015 * requests, including the ones that have a return value, other 7686139Sjb150015 * than SDRC_SUCCESS. 7696030Sjb150015 */ 7706030Sjb150015 SMB_ALL_DISPATCH_STAT_INCR(sdd->sdt_dispatch_stats.value.ui64); 7716030Sjb150015 7726139Sjb150015 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS) 7736139Sjb150015 sdrc = (*sdd->sdt_function)(sr); 7746139Sjb150015 7759343SAfshin.Ardakani@Sun.COM if (sdrc != SDRC_SR_KEPT) { 7769343SAfshin.Ardakani@Sun.COM (*sdd->sdt_post_op)(sr); 7779343SAfshin.Ardakani@Sun.COM smbsr_cleanup(sr); 7789343SAfshin.Ardakani@Sun.COM } 7799343SAfshin.Ardakani@Sun.COM 7806139Sjb150015 if (sdrc != SDRC_SUCCESS) { 7816030Sjb150015 /* 7826030Sjb150015 * Handle errors from raw write. 7836030Sjb150015 */ 7849343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_WRITER); 7858262SJose.Borrego@Sun.COM if (session->s_state == SMB_SESSION_STATE_WRITE_RAW_ACTIVE) { 7866030Sjb150015 /* 7876030Sjb150015 * Set state so that the netbios session 7886030Sjb150015 * daemon will start accepting data again. 7896030Sjb150015 */ 7908262SJose.Borrego@Sun.COM session->s_write_raw_status = 0; 7918262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_NEGOTIATED; 7926030Sjb150015 } 7939343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 7948262SJose.Borrego@Sun.COM } 7956030Sjb150015 7966030Sjb150015 switch (sdrc) { 7976139Sjb150015 case SDRC_SUCCESS: 7986030Sjb150015 break; 7996030Sjb150015 8006030Sjb150015 case SDRC_DROP_VC: 8016030Sjb150015 disconnect = B_TRUE; 8026030Sjb150015 goto drop_connection; 8036030Sjb150015 8046030Sjb150015 case SDRC_NO_REPLY: 8058262SJose.Borrego@Sun.COM return (B_TRUE); 8068262SJose.Borrego@Sun.COM 8078262SJose.Borrego@Sun.COM case SDRC_SR_KEPT: 8088262SJose.Borrego@Sun.COM return (B_FALSE); 8096030Sjb150015 8106139Sjb150015 case SDRC_ERROR: 8116030Sjb150015 goto report_error; 8126030Sjb150015 8136139Sjb150015 case SDRC_NOT_IMPLEMENTED: 8146030Sjb150015 default: 8156030Sjb150015 smbsr_error(sr, 0, ERRDOS, ERRbadfunc); 8166030Sjb150015 goto report_error; 8176030Sjb150015 } 8186030Sjb150015 8196030Sjb150015 /* 8206030Sjb150015 * If there's no AndX command, we're done. 8216030Sjb150015 */ 8225331Samw if (sr->andx_com == 0xff) 8235331Samw goto reply_ready; 8245331Samw 8256030Sjb150015 /* 8266030Sjb150015 * Otherwise, we have to back-patch the AndXCommand and AndXOffset 8276030Sjb150015 * and continue processing. 8286030Sjb150015 */ 8295331Samw sr->andx_prev_wct = sr->cur_reply_offset; 8307052Samw (void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w", 8315331Samw sr->andx_com, MBC_LENGTH(&sr->reply)); 8325331Samw 8335331Samw sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off; 8345331Samw sr->smb_com = sr->andx_com; 8355331Samw goto andx_more; 8365331Samw 8376030Sjb150015 report_error: 8385331Samw sr->reply.chain_offset = sr->cur_reply_offset; 8397052Samw (void) smb_mbc_encodef(&sr->reply, "bw", 0, 0); 8405331Samw 8415331Samw sr->smb_wct = 0; 8425331Samw sr->smb_bcc = 0; 8435331Samw 8446139Sjb150015 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0) 8456030Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 8466030Sjb150015 8476030Sjb150015 reply_ready: 8486030Sjb150015 smbsr_send_reply(sr); 8496030Sjb150015 8506030Sjb150015 drop_connection: 8516030Sjb150015 if (disconnect) { 8529343SAfshin.Ardakani@Sun.COM smb_rwx_rwenter(&session->s_lock, RW_WRITER); 8538262SJose.Borrego@Sun.COM switch (session->s_state) { 8546030Sjb150015 case SMB_SESSION_STATE_DISCONNECTED: 8556030Sjb150015 case SMB_SESSION_STATE_TERMINATED: 8566030Sjb150015 break; 8576030Sjb150015 default: 8588262SJose.Borrego@Sun.COM smb_soshutdown(session->sock); 8598262SJose.Borrego@Sun.COM session->s_state = SMB_SESSION_STATE_DISCONNECTED; 8606030Sjb150015 break; 8616030Sjb150015 } 8629343SAfshin.Ardakani@Sun.COM smb_rwx_rwexit(&session->s_lock); 8635331Samw } 8646030Sjb150015 8658262SJose.Borrego@Sun.COM return (B_TRUE); 8665331Samw } 8675331Samw 8686030Sjb150015 int 8696030Sjb150015 smbsr_encode_empty_result(struct smb_request *sr) 8706030Sjb150015 { 8716030Sjb150015 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0)); 8726030Sjb150015 } 8735331Samw 8746030Sjb150015 int 8756030Sjb150015 smbsr_encode_result(struct smb_request *sr, int wct, int bcc, char *fmt, ...) 8765331Samw { 8775331Samw va_list ap; 8785331Samw 8796030Sjb150015 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset) 8806030Sjb150015 return (-1); 8815331Samw 8825331Samw va_start(ap, fmt); 8837052Samw (void) smb_mbc_vencodef(&sr->reply, fmt, ap); 8845331Samw va_end(ap); 8855331Samw 8865331Samw sr->smb_wct = (unsigned char)wct; 8875331Samw sr->smb_bcc = (uint16_t)bcc; 8885331Samw 8896030Sjb150015 if (smbsr_check_result(sr, wct, bcc) != 0) 8906030Sjb150015 return (-1); 8916030Sjb150015 8926030Sjb150015 return (0); 8935331Samw } 8945331Samw 8956030Sjb150015 static int 8965331Samw smbsr_check_result(struct smb_request *sr, int wct, int bcc) 8975331Samw { 8985331Samw int offset = sr->cur_reply_offset; 8995331Samw int total_bytes; 9005331Samw unsigned char temp, temp1; 9015331Samw struct mbuf *m; 9025331Samw 9035331Samw total_bytes = 0; 9045331Samw m = sr->reply.chain; 9055331Samw while (m != 0) { 9065331Samw total_bytes += m->m_len; 9075331Samw m = m->m_next; 9085331Samw } 9095331Samw 9106030Sjb150015 if ((offset + 3) > total_bytes) 9116030Sjb150015 return (-1); 9125331Samw 9137052Samw (void) smb_mbc_peek(&sr->reply, offset, "b", &temp); 9146030Sjb150015 if (temp != wct) 9156030Sjb150015 return (-1); 9165331Samw 9176030Sjb150015 if ((offset + (wct * 2 + 1)) > total_bytes) 9186030Sjb150015 return (-1); 9195331Samw 9205331Samw /* reply wct & vwv seem ok, consider data now */ 9215331Samw offset += wct * 2 + 1; 9225331Samw 9236030Sjb150015 if ((offset + 2) > total_bytes) 9246030Sjb150015 return (-1); 9255331Samw 9267052Samw (void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1); 9275331Samw if (bcc == VAR_BCC) { 9285331Samw if ((temp != 0xFF) || (temp1 != 0xFF)) { 9296030Sjb150015 return (-1); 9305331Samw } else { 9315331Samw bcc = (total_bytes - offset) - 2; 9327052Samw (void) smb_mbc_poke(&sr->reply, offset, "bb", 9335331Samw bcc, bcc >> 8); 9345331Samw } 9355331Samw } else { 9366030Sjb150015 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF))) 9376030Sjb150015 return (-1); 9385331Samw } 9395331Samw 9405331Samw offset += bcc + 2; 9415331Samw 9426030Sjb150015 if (offset != total_bytes) 9436030Sjb150015 return (-1); 9445331Samw 9455331Samw sr->smb_wct = (unsigned char)wct; 9465331Samw sr->smb_bcc = (uint16_t)bcc; 9476030Sjb150015 return (0); 9485331Samw } 9495331Samw 9505331Samw int 9515331Samw smbsr_decode_vwv(struct smb_request *sr, char *fmt, ...) 9525331Samw { 9535331Samw int rc; 9545331Samw va_list ap; 9555331Samw 9565331Samw va_start(ap, fmt); 9577052Samw rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap); 9585331Samw va_end(ap); 9595331Samw 9606139Sjb150015 if (rc) 9616139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9625331Samw return (rc); 9635331Samw } 9645331Samw 9655331Samw int 9665331Samw smbsr_decode_data(struct smb_request *sr, char *fmt, ...) 9675331Samw { 9686139Sjb150015 int rc; 9695331Samw va_list ap; 9706139Sjb150015 9715331Samw va_start(ap, fmt); 9727052Samw rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap); 9735331Samw va_end(ap); 9746139Sjb150015 9756139Sjb150015 if (rc) 9766139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 9776139Sjb150015 return (rc); 9785331Samw } 9795331Samw 9805331Samw void 9815331Samw smbsr_send_reply(struct smb_request *sr) 9825331Samw { 9837348SJose.Borrego@Sun.COM if (SMB_TREE_IS_CASEINSENSITIVE(sr)) 9846030Sjb150015 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE; 9856030Sjb150015 else 9866030Sjb150015 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE; 9876030Sjb150015 9887052Samw (void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT, 9895331Samw sr->first_smb_com, 9905331Samw sr->smb_rcls, 9915331Samw sr->smb_reh, 9925331Samw sr->smb_err, 9935331Samw sr->smb_flg | SMB_FLAGS_REPLY, 9945331Samw sr->smb_flg2, 9955331Samw sr->smb_pid_high, 9965331Samw sr->smb_sig, 9975331Samw sr->smb_tid, 9985331Samw sr->smb_pid, 9995331Samw sr->smb_uid, 10005331Samw sr->smb_mid); 10015331Samw 10025331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 10035331Samw smb_sign_reply(sr, NULL); 10045331Samw 10056030Sjb150015 if (smb_session_send(sr->session, 0, &sr->reply) == 0) 10066030Sjb150015 sr->reply.chain = 0; 10075331Samw } 10085331Samw 10095331Samw /* 10105772Sas200622 * Map errno values to SMB and NT status values. 10115772Sas200622 * Note: ESRCH is a special case to handle a streams lookup failure. 10125331Samw */ 10135331Samw static struct { 10145772Sas200622 int errnum; 10155772Sas200622 int errcls; 10165772Sas200622 int errcode; 10175772Sas200622 DWORD status32; 10185772Sas200622 } smb_errno_map[] = { 10195331Samw { ENOSPC, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10205331Samw { EDQUOT, ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL }, 10215331Samw { EPERM, ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED }, 10225331Samw { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, 10235331Samw { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, 10245331Samw { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE }, 10255331Samw { ENOTEMPTY, ERRDOS, ERROR_DIR_NOT_EMPTY, 10265331Samw NT_STATUS_DIRECTORY_NOT_EMPTY }, 10279231SAfshin.Ardakani@Sun.COM { EILSEQ, ERRDOS, ERROR_INVALID_NAME, 10289231SAfshin.Ardakani@Sun.COM NT_STATUS_OBJECT_NAME_INVALID }, 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 }, 10349231SAfshin.Ardakani@Sun.COM { ESTALE, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 10359231SAfshin.Ardakani@Sun.COM { EBADF, ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE }, 10369231SAfshin.Ardakani@Sun.COM { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION }, 10379231SAfshin.Ardakani@Sun.COM { 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 1161*10504SKeyur.Desai@Sun.COM smbsr_release_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 11698934SJose.Borrego@Sun.COM void 11708934SJose.Borrego@Sun.COM smbsr_lookup_file(smb_request_t *sr) 11718934SJose.Borrego@Sun.COM { 11728934SJose.Borrego@Sun.COM if (sr->fid_ofile == NULL) 11738934SJose.Borrego@Sun.COM sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree, 11748934SJose.Borrego@Sun.COM sr->smb_fid); 11758934SJose.Borrego@Sun.COM } 11768934SJose.Borrego@Sun.COM 11775331Samw static int 11785331Samw is_andx_com(unsigned char com) 11795331Samw { 11805331Samw switch (com) { 11815331Samw case SMB_COM_LOCKING_ANDX: 11825331Samw case SMB_COM_OPEN_ANDX: 11835331Samw case SMB_COM_READ_ANDX: 11845331Samw case SMB_COM_WRITE_ANDX: 11855331Samw case SMB_COM_SESSION_SETUP_ANDX: 11865331Samw case SMB_COM_LOGOFF_ANDX: 11875331Samw case SMB_COM_TREE_CONNECT_ANDX: 11885331Samw case SMB_COM_NT_CREATE_ANDX: 11895331Samw return (1); 11905331Samw } 11915331Samw return (0); 11925331Samw } 11935331Samw 11945331Samw /* 11956139Sjb150015 * Invalid command stubs. 11966139Sjb150015 * 11976139Sjb150015 * SmbWriteComplete is sent to acknowledge completion of raw write requests. 11986139Sjb150015 * We never send raw write commands to other servers so, if we receive 11996139Sjb150015 * SmbWriteComplete, we treat it as an error. 12006139Sjb150015 * 12016139Sjb150015 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize 12026139Sjb150015 * performance when reading/writing a large block of data: it can be 12036139Sjb150015 * used in parallel with other client/server operations. The mpx sub- 12046139Sjb150015 * protocol is not supported because we support only connection oriented 12056139Sjb150015 * transports and NT supports mpx only over connectionless transports. 12065331Samw */ 12076030Sjb150015 smb_sdrc_t 12086139Sjb150015 smb_pre_invalid(smb_request_t *sr) 12096139Sjb150015 { 12106139Sjb150015 DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr); 12116139Sjb150015 return (SDRC_SUCCESS); 12126139Sjb150015 } 12136139Sjb150015 12146139Sjb150015 void 12156139Sjb150015 smb_post_invalid(smb_request_t *sr) 12166139Sjb150015 { 12176139Sjb150015 DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr); 12186139Sjb150015 } 12196139Sjb150015 12206139Sjb150015 smb_sdrc_t 12216139Sjb150015 smb_com_invalid(smb_request_t *sr) 12225331Samw { 12236139Sjb150015 smb_sdrc_t sdrc; 12246139Sjb150015 12256139Sjb150015 switch (sr->smb_com) { 12266139Sjb150015 case SMB_COM_WRITE_COMPLETE: 12276139Sjb150015 smbsr_error(sr, 0, ERRSRV, ERRerror); 12286139Sjb150015 sdrc = SDRC_ERROR; 12296139Sjb150015 break; 12306139Sjb150015 12316139Sjb150015 default: 12326139Sjb150015 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED, 12336139Sjb150015 ERRDOS, ERROR_INVALID_FUNCTION); 12346139Sjb150015 sdrc = SDRC_NOT_IMPLEMENTED; 12356139Sjb150015 break; 12366139Sjb150015 } 12376139Sjb150015 12386139Sjb150015 return (sdrc); 12395331Samw } 12405331Samw 12415331Samw /* 12426139Sjb150015 * smb_dispatch_kstat_update 12435331Samw * 12445331Samw * This callback function updates the smb_dispatch_kstat_data when kstat 12455331Samw * command is invoked. 12465331Samw */ 12475331Samw static int 12486139Sjb150015 smb_dispatch_kstat_update(kstat_t *ksp, int rw) 12495331Samw { 12508934SJose.Borrego@Sun.COM smb_disp_entry_t *sdd; 12518934SJose.Borrego@Sun.COM kstat_named_t *ks_named; 12526139Sjb150015 int i; 12535331Samw 12546139Sjb150015 if (rw == KSTAT_WRITE) 12555331Samw return (EACCES); 12566139Sjb150015 12576139Sjb150015 ASSERT(MUTEX_HELD(ksp->ks_lock)); 12586139Sjb150015 12596139Sjb150015 ks_named = ksp->ks_data; 12606139Sjb150015 for (i = 0; i < SMB_COM_NUM; i++) { 12616139Sjb150015 sdd = &dispatch[i]; 12626139Sjb150015 12636139Sjb150015 if (sdd->sdt_function != smb_com_invalid) { 12646139Sjb150015 bcopy(&sdd->sdt_dispatch_stats, ks_named, 12656139Sjb150015 sizeof (kstat_named_t)); 12666139Sjb150015 ++ks_named; 12675331Samw } 12685331Samw } 12696139Sjb150015 12705331Samw return (0); 12715331Samw } 12725331Samw 12735331Samw /* 12746139Sjb150015 * smb_dispatch_kstat_init 12755331Samw * 12765331Samw * Initialize dispatch kstats. 12775331Samw */ 12785331Samw void 12796139Sjb150015 smb_dispatch_kstat_init(void) 12805331Samw { 12816139Sjb150015 int ks_ndata; 12826139Sjb150015 int i; 12835331Samw 12846139Sjb150015 for (i = 0, ks_ndata = 0; i < SMB_COM_NUM; i++) { 12856139Sjb150015 if (dispatch[i].sdt_function != smb_com_invalid) 12866139Sjb150015 ks_ndata++; 12875331Samw } 12885331Samw 12896432Sas200622 smb_dispatch_ksp = kstat_create(SMBSRV_KSTAT_MODULE, 0, 12906432Sas200622 SMBSRV_KSTAT_NAME_CMDS, SMBSRV_KSTAT_CLASS, 12916139Sjb150015 KSTAT_TYPE_NAMED, ks_ndata, 0); 12925331Samw 12935331Samw if (smb_dispatch_ksp) { 12946139Sjb150015 mutex_init(&smb_dispatch_ksmtx, NULL, MUTEX_DEFAULT, NULL); 12956139Sjb150015 smb_dispatch_ksp->ks_update = smb_dispatch_kstat_update; 12966139Sjb150015 smb_dispatch_ksp->ks_lock = &smb_dispatch_ksmtx; 12975331Samw kstat_install(smb_dispatch_ksp); 12985331Samw } 12995331Samw } 13005331Samw 13015331Samw /* 13026139Sjb150015 * smb_dispatch_kstat_fini 13035331Samw * 13045331Samw * Remove dispatch kstats. 13055331Samw */ 13065331Samw void 13076139Sjb150015 smb_dispatch_kstat_fini(void) 13085331Samw { 13095331Samw if (smb_dispatch_ksp != NULL) { 13105331Samw kstat_delete(smb_dispatch_ksp); 13116139Sjb150015 mutex_destroy(&smb_dispatch_ksmtx); 13125331Samw smb_dispatch_ksp = NULL; 13135331Samw } 13145331Samw } 1315