smb_dispatch.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*
* Dispatching SMB requests.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ALMOST EVERYTHING YOU NEED TO KNOW ABOUT A SERVER MESSAGE BLOCK
*
* Request
* Header
* Magic 0xFF 'S' 'M' 'B'
* smb_com a byte, the "first" command
* Error a 4-byte union, ignored in a request
* smb_flg a one byte set of eight flags
* smb_flg2 a two byte set of 16 flags
* . twelve reserved bytes, have a role
* in connectionless transports (IPX, UDP?)
* smb_tid a 16-bit tree ID, a mount point sorta,
* 0xFFFF is this command does not have
* or require a tree context
* smb_pid a 16-bit process ID
* smb_uid a 16-bit user ID, specific to this "session"
* and mapped to a system (bona-fide) UID
* smb_mid a 16-bit multiplex ID, used to differentiate
* multiple simultaneous requests from the same
* process (pid) (ref RPC "xid")
*
* Chained (AndX) commands (0 or more)
* smb_wct a byte, number of 16-bit words containing
* command parameters, min 2 for chained command
* andx_com a byte, the "next" command, 0xFF for none
* . an unused byte
* andx_off a 16-bit offset, byte displacement from &Magic
* to the smb_wct field of the "next" command,
* ignore if andx_com is 0xFF, s/b 0 if no next
* smb_vwv[] 0 or more 16-bit (sorta) parameters for
* "this" command (i.e. smb_com if this is the
* first parameters, or the andx_com of the just
* previous block.
* smb_bcc a 16-bit count of smb_data[] bytes
* smb_data[] 0 or more bytes, format specific to commands
* padding[] Optional padding
*
* Last command
* smb_wct a byte, number of 16-bit words containing
* command parameters, min 0 for chained command
* smb_vwv[] 0 or more 16-bit (sorta) parameters for
* "this" command (i.e. smb_com if this is the
* first parameters, or the andx_com of the just
* previous block.
* smb_bcc a 16-bit count of smb_data[] bytes
* smb_data[] 0 or more bytes, format specific to commands
*
* Reply
* Header
* Magic 0xFF 'S' 'M' 'B'
* smb_com a byte, the "first" command, corresponds
* to request
* Error a 4-byte union, coding depends on dialect in use
* for "DOS" errors
* a byte for error class
* an unused byte
* a 16-bit word for error code
* for "NT" errors
* a 32-bit error code which
* is a packed class and specifier
* for "OS/2" errors
* I don't know
* The error information is specific to the
* last command in the reply chain.
* smb_flg a one byte set of eight flags, 0x80 bit set
* indicating this message is a reply
* smb_flg2 a two byte set of 16 flags
* . twelve reserved bytes, have a role
* in connectionless transports (IPX, UDP?)
* smb_tid a 16-bit tree ID, a mount point sorta,
* should be the same as the request
* smb_pid a 16-bit process ID, MUST BE the same as request
* smb_uid a 16-bit user ID, specific to this "session"
* and mapped to a system (bona-fide) UID,
* should be the same as request
* smb_mid a 16-bit multiplex ID, used to differentiate
* multiple simultaneous requests from the same
* process (pid) (ref RPC "xid"), MUST BE the
* same as request
* padding[] Optional padding
*
* Chained (AndX) commands (0 or more)
* smb_wct a byte, number of 16-bit words containing
* command parameters, min 2 for chained command,
* andx_com a byte, the "next" command, 0xFF for none,
* corresponds to request, if this is the chained
* command that had an error set to 0xFF
* . an unused byte
* andx_off a 16-bit offset, byte displacement from &Magic
* to the smb_wct field of the "next" command,
* ignore if andx_com is 0xFF, s/b 0 if no next
* smb_vwv[] 0 or more 16-bit (sorta) parameters for
* "this" command (i.e. smb_com if this is the
* first parameters, or the andx_com of the just
* previous block. Empty if an error.
* smb_bcc a 16-bit count of smb_data[] bytes
* smb_data[] 0 or more bytes, format specific to commands
* empty if an error.
*
* Last command
* smb_wct a byte, number of 16-bit words containing
* command parameters, min 0 for chained command
* smb_vwv[] 0 or more 16-bit (sorta) parameters for
* "this" command (i.e. smb_com if this is the
* first parameters, or the andx_com of the just
* previous block, empty if an error.
* smb_bcc a 16-bit count of smb_data[] bytes
* smb_data[] 0 or more bytes, format specific to commands,
* empty if an error.
*/
#include <smbsrv/smb_incl.h>
int smb_dispatch_diags = 0;
static int smb_dispatch_kstat_size = 0;
static int is_andx_com(unsigned char);
extern int smb_com_cancel_forward(struct smb_request *);
extern int smb_com_check_directory(struct smb_request *);
extern int smb_com_close(struct smb_request *);
extern int smb_com_close_and_tree_disconnect(struct smb_request *);
extern int smb_com_close_print_file(struct smb_request *);
extern int smb_com_copy(struct smb_request *);
extern int smb_com_create(struct smb_request *);
extern int smb_com_create_directory(struct smb_request *);
extern int smb_com_create_new(struct smb_request *);
extern int smb_com_create_temporary(struct smb_request *);
extern int smb_com_delete(struct smb_request *);
extern int smb_com_delete_directory(struct smb_request *);
extern int smb_com_echo(struct smb_request *);
extern int smb_com_find(struct smb_request *);
extern int smb_com_find_close(struct smb_request *);
extern int smb_com_find_close2(struct smb_request *);
extern int smb_com_find_notify_close(struct smb_request *);
extern int smb_com_find_unique(struct smb_request *);
extern int smb_com_flush(struct smb_request *);
extern int smb_com_forward_user_name(struct smb_request *);
extern int smb_com_get_machine_name(struct smb_request *);
extern int smb_com_get_print_queue(struct smb_request *);
extern int smb_com_invalid_command(struct smb_request *);
extern int smb_com_ioctl(struct smb_request *);
extern int smb_com_ioctl_secondary(struct smb_request *);
extern int smb_com_lock_and_read(struct smb_request *);
extern int smb_com_lock_byte_range(struct smb_request *);
extern int smb_com_locking_andx(struct smb_request *);
extern int smb_com_logoff_andx(struct smb_request *);
extern int smb_com_move(struct smb_request *);
extern int smb_com_negotiate(struct smb_request *);
extern int smb_com_nt_cancel(struct smb_request *);
extern int smb_com_nt_create_andx(struct smb_request *);
extern int smb_com_nt_transact(struct smb_request *);
extern int smb_com_nt_transact_secondary(struct smb_request *);
extern int smb_com_open(struct smb_request *);
extern int smb_com_open_andx(struct smb_request *);
extern int smb_com_open_print_file(struct smb_request *);
extern int smb_com_process_exit(struct smb_request *);
extern int smb_com_query_information(struct smb_request *);
extern int smb_com_query_information2(struct smb_request *);
extern int smb_com_query_information_disk(struct smb_request *);
extern int smb_com_read(struct smb_request *);
extern int smb_com_read_andx(struct smb_request *);
extern int smb_com_read_mpx(struct smb_request *);
extern int smb_com_read_mpx_secondary(struct smb_request *);
extern int smb_com_read_raw(struct smb_request *);
extern int smb_com_rename(struct smb_request *);
extern int smb_com_search(struct smb_request *);
extern int smb_com_seek(struct smb_request *);
extern int smb_com_send_broadcast_message(struct smb_request *);
extern int smb_com_send_end_mb_message(struct smb_request *);
extern int smb_com_send_single_message(struct smb_request *);
extern int smb_com_send_start_mb_message(struct smb_request *);
extern int smb_com_send_text_mb_message(struct smb_request *);
extern int smb_com_session_setup_andx(struct smb_request *);
extern int smb_com_set_information(struct smb_request *);
extern int smb_com_set_information2(struct smb_request *);
extern int smb_com_transaction(struct smb_request *);
extern int smb_com_transaction2(struct smb_request *);
extern int smb_com_transaction2_secondary(struct smb_request *);
extern int smb_com_transaction_secondary(struct smb_request *);
extern int smb_com_tree_connect(struct smb_request *);
extern int smb_com_tree_connect_andx(struct smb_request *);
extern int smb_com_tree_disconnect(struct smb_request *);
extern int smb_com_unlock_byte_range(struct smb_request *);
extern int smb_com_write(struct smb_request *);
extern int smb_com_write_and_close(struct smb_request *);
extern int smb_com_write_and_unlock(struct smb_request *);
extern int smb_com_write_andx(struct smb_request *);
extern int smb_com_write_complete(struct smb_request *);
extern int smb_com_write_mpx(struct smb_request *);
extern int smb_com_write_mpx_secondary(struct smb_request *);
extern int smb_com_write_print_file(struct smb_request *);
extern int smb_com_write_raw(struct smb_request *);
{ smb_com_create_directory, /* 0x00 000 */
{ "SmbCreateDirectory", KSTAT_DATA_UINT64 } },
{ smb_com_delete_directory, /* 0x01 001 */
{ "SmbDeleteDirectory", KSTAT_DATA_UINT64 } },
{ smb_com_open, /* 0x02 002 */
{ "SmbOpen", KSTAT_DATA_UINT64 } },
{ smb_com_create, /* 0x03 003 */
{ "SmbCreate", KSTAT_DATA_UINT64 } },
{ smb_com_close, /* 0x04 004 */
{ "SmbClose", KSTAT_DATA_UINT64 } },
{ smb_com_flush, /* 0x05 005 */
{ "SmbFlush", KSTAT_DATA_UINT64 } },
{ smb_com_delete, /* 0x06 006 */
{ "SmbDelete", KSTAT_DATA_UINT64 } },
{ smb_com_rename, /* 0x07 007 */
{ "SmbRename", KSTAT_DATA_UINT64 } },
{ smb_com_query_information, /* 0x08 008 */
{ "SmbQueryInformation", KSTAT_DATA_UINT64 } },
{ smb_com_set_information, /* 0x09 009 */
{ "SmbSetInformation", KSTAT_DATA_UINT64 } },
{ smb_com_read, /* 0x0A 010 */
{ "SmbRead", KSTAT_DATA_UINT64 } },
{ smb_com_write, /* 0x0B 011 */
{ "SmbWrite", KSTAT_DATA_UINT64 } },
{ smb_com_lock_byte_range, /* 0x0C 012 */
{ "SmbLockByteRange", KSTAT_DATA_UINT64 } },
{ smb_com_unlock_byte_range, /* 0x0D 013 */
{ "SmbUnlockByteRange", KSTAT_DATA_UINT64 } },
{ smb_com_create_temporary, /* 0x0E 014 */
{ "SmbCreateTemporary", KSTAT_DATA_UINT64 } },
{ smb_com_create_new, /* 0x0F 015 */
{ "SmbCreateNew", KSTAT_DATA_UINT64 } },
{ smb_com_check_directory, /* 0x10 016 */
{ "SmbCheckDirectory", KSTAT_DATA_UINT64 } },
{ smb_com_process_exit, /* 0x11 017 */
{ "SmbProcessExit", KSTAT_DATA_UINT64 } },
{ smb_com_seek, /* 0x12 018 */
{ "SmbSeek", KSTAT_DATA_UINT64 } },
{ smb_com_lock_and_read, /* 0x13 019 */
{ "SmbLockAndRead", KSTAT_DATA_UINT64 } },
{ smb_com_write_and_unlock, /* 0x14 020 */
{ "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0x15 021 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x16 022 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x17 023 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x18 024 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x19 025 */
{ smb_com_read_raw, /* 0x1A 026 */
{ "SmbReadRaw", KSTAT_DATA_UINT64 } },
{ smb_com_read_mpx, /* 0x1B 027 */
{ "SmbReadMpx", KSTAT_DATA_UINT64 } },
{ smb_com_read_mpx_secondary, /* 0x1C 028 */
{ "SmbReadMpxSecondary", KSTAT_DATA_UINT64 } },
{ smb_com_write_raw, /* 0x1D 029 */
{ "SmbWriteRaw", KSTAT_DATA_UINT64 } },
{ smb_com_write_mpx, /* 0x1E 030 */
{ "SmbWriteMpx", KSTAT_DATA_UINT64 } },
{ smb_com_write_mpx_secondary, /* 0x1F 031 */
{ "SmbWriteMpxSecondary", KSTAT_DATA_UINT64 } },
{ smb_com_write_complete, /* 0x20 032 */
{ "SmbWriteComplete", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, 0, 0 }, /* 0x21 033 */
{ smb_com_set_information2, /* 0x22 034 */
{ "SmbSetInformation2", KSTAT_DATA_UINT64 } },
{ smb_com_query_information2, /* 0x23 035 */
{ "SmbQueryInformation2", KSTAT_DATA_UINT64 } },
{ smb_com_locking_andx, /* 0x24 036 */
{ "SmbLockingX", KSTAT_DATA_UINT64 } },
{ smb_com_transaction, /* 0x25 037 */
{ "SmbTransaction", KSTAT_DATA_UINT64 } },
{ smb_com_transaction_secondary, /* 0x26 038 */
{ "SmbTransactionSecondary", KSTAT_DATA_UINT64 } },
{ smb_com_ioctl, /* 0x27 039 */
{ "SmbIoctl", KSTAT_DATA_UINT64 } },
{ smb_com_ioctl_secondary, /* 0x28 040 */
{ "SmbIoctlSecondary", KSTAT_DATA_UINT64 } },
{ smb_com_copy, /* 0x29 041 */
{ "SmbCopy", KSTAT_DATA_UINT64 } },
{ smb_com_move, /* 0x2A 042 */
{ "SmbMove", KSTAT_DATA_UINT64 } },
{ smb_com_echo, /* 0x2B 043 */
{ "SmbEcho", KSTAT_DATA_UINT64 } },
{ smb_com_write_and_close, /* 0x2C 044 */
{ "SmbWriteAndClose", KSTAT_DATA_UINT64 } },
{ smb_com_open_andx, /* 0x2D 045 */
{ "SmbOpenX", KSTAT_DATA_UINT64 } },
{ smb_com_read_andx, /* 0x2E 046 */
{ "SmbReadX", KSTAT_DATA_UINT64 } },
{ smb_com_write_andx, /* 0x2F 047 */
{ "SmbWriteX", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, 0, 0 }, /* 0x30 048 */
{ smb_com_close_and_tree_disconnect, /* 0x31 049 */
{ "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } },
{ smb_com_transaction2, /* 0x32 050 */
{ "SmbTransaction2", KSTAT_DATA_UINT64 } },
{ smb_com_transaction2_secondary, /* 0x33 051 */
{ "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } },
{ smb_com_find_close2, /* 0x34 052 */
{ "SmbFindClose2", KSTAT_DATA_UINT64 } },
{ smb_com_find_notify_close, /* 0x35 053 */
{ "SmbFindNotifyClose", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0x36 054 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x37 055 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x38 056 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x39 057 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3A 058 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3B 059 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3C 060 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3D 061 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3E 062 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x3F 063 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x40 064 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x41 065 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x42 066 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x43 067 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x44 068 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x45 069 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x46 070 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x47 071 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x48 072 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x49 073 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4A 074 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4B 075 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4C 076 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4D 077 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4E 078 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x4F 079 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x50 080 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x51 081 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x52 082 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x53 083 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x54 084 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x55 085 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x56 086 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x57 087 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x58 088 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x59 089 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5A 090 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5B 091 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5C 092 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5D 093 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5E 094 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x5F 095 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x60 096 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x61 097 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x62 098 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x63 099 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x64 100 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x65 101 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x66 102 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x67 103 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x68 104 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x69 105 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6A 106 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6B 107 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6C 108 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6D 109 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6E 110 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x6F 111 */
{ smb_com_tree_connect, /* 0x70 112 */
{ "SmbTreeConnect", KSTAT_DATA_UINT64 } },
{ smb_com_tree_disconnect, /* 0x71 113 */
{ "SmbTreeDisconnect", KSTAT_DATA_UINT64 } },
{ smb_com_negotiate, /* 0x72 114 */
{ "SmbNegotiate", KSTAT_DATA_UINT64 } },
{ smb_com_session_setup_andx, /* 0x73 115 */
{ "SmbSessionSetupX", KSTAT_DATA_UINT64 } },
{ smb_com_logoff_andx, /* 0x74 116 */
{ "SmbLogoffX", KSTAT_DATA_UINT64 } },
{ smb_com_tree_connect_andx, /* 0x75 117 */
{ "SmbTreeConnectX", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0x76 118 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x77 119 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x78 120 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x79 121 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7A 122 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7B 123 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7C 124 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7D 125 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7E 126 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x7F 127 */
{ smb_com_query_information_disk, /* 0x80 128 */
{ "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } },
{ smb_com_search, /* 0x81 129 */
{ "SmbSearch", KSTAT_DATA_UINT64 } },
{ smb_com_find, /* 0x82 130 */
{ "SmbFind", KSTAT_DATA_UINT64 } },
{ smb_com_find_unique, /* 0x83 131 */
{ "SmbFindUnique", KSTAT_DATA_UINT64 } },
{ smb_com_find_close, /* 0x84 132 */
{ "SmbFindClose", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0x85 133 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x86 134 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x87 135 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x88 136 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x89 137 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8A 138 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8B 139 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8C 140 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8D 141 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8E 142 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x8F 143 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x90 144 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x91 145 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x92 146 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x93 147 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x94 148 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x95 149 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x96 150 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x97 151 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x98 152 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x99 153 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9A 154 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9B 155 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9C 156 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9D 157 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9E 158 */
{ 0, 0, 0, RW_READER, 0 }, /* 0x9F 159 */
{ smb_com_nt_transact, /* 0xA0 160 */
{ "SmbNtTransact", KSTAT_DATA_UINT64 } },
{ smb_com_nt_transact_secondary, /* 0xA1 161 */
{ "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } },
{ smb_com_nt_create_andx, /* 0xA2 162 */
{ "SmbNtCreateX", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, 0, 0 }, /* 0xA3 163 */
{ smb_com_nt_cancel, /* 0xA4 164 */
{ "SmbNtCancel", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0xA5 165 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xA6 166 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xA7 167 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xA8 168 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xA9 169 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAA 170 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAB 171 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAC 172 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAD 173 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAE 174 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xAF 175 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB0 176 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB1 177 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB2 178 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB3 179 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB4 180 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB5 181 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB6 182 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB7 183 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB8 184 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xB9 185 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBA 186 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBB 187 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBC 188 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBD 189 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBE 190 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xBF 191 */
{ smb_com_open_print_file, /* 0xC0 192 */
{ "SmbOpenPrintFile", KSTAT_DATA_UINT64 } },
{ smb_com_write_print_file, /* 0xC1 193 */
{ "SmbWritePrintFile", KSTAT_DATA_UINT64 } },
{ smb_com_close_print_file, /* 0xC2 194 */
{ "SmbClosePrintFile", KSTAT_DATA_UINT64 } },
{ smb_com_get_print_queue, /* 0xC3 195 */
{ "SmbGetPrintQueue", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0xC4 196 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xC5 197 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xC6 198 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xC7 199 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xC8 200 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xC9 201 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCA 202 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCB 203 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCC 204 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCD 205 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCE 206 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xCF 207 */
{ smb_com_send_single_message, /* 0xD0 208 */
{ "SmbSendSingleMessage", KSTAT_DATA_UINT64 } },
{ smb_com_send_broadcast_message, /* 0xD1 209 */
{ "SmbSendBroadcastMessage", KSTAT_DATA_UINT64 } },
{ smb_com_forward_user_name, /* 0xD2 210 */
{ "SmbForwardUserName", KSTAT_DATA_UINT64 } },
{ smb_com_cancel_forward, /* 0xD3 211 */
{ "SmbCancelForward", KSTAT_DATA_UINT64 } },
{ smb_com_get_machine_name, /* 0xD4 212 */
{ "SmbGetMachineName", KSTAT_DATA_UINT64 } },
{ smb_com_send_start_mb_message, /* 0xD5 213 */
{ "SmbSendStartMbMessage", KSTAT_DATA_UINT64 } },
{ smb_com_send_end_mb_message, /* 0xD6 214 */
{ "SmbSendEndMbMessage", KSTAT_DATA_UINT64 } },
{ smb_com_send_text_mb_message, /* 0xD7 215 */
{ "SmbSendTextMbMessage", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 }, /* 0xD8 216 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xD9 217 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDA 218 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDB 219 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDC 220 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDD 221 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDE 222 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xDF 223 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE0 224 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE1 225 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE2 226 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE3 227 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE4 228 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE5 229 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE6 230 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE7 231 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE8 232 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xE9 233 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xEA 234 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xEB 235 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xEC 236 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xED 237 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xEE 238 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xEF 239 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF0 240 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF1 241 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF2 242 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF3 243 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF4 244 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF5 245 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF6 246 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF7 247 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF8 248 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xF9 249 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xFA 250 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xFB 251 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xFC 252 */
{ 0, 0, 0, RW_READER, 0 }, /* 0xFD 253 */
{ smb_com_invalid_command, /* 0xFE 254 */
{ "SmbInvalidCommand", KSTAT_DATA_UINT64 } },
{ 0, 0, 0, RW_READER, 0 } /* 0xFF 255 */
};
int smb_watch = -1;
int smb_emit_sending = 0;
/*
* smbsr_cleanup
*
* the reference count for that resource has been incremented.
* This function decrements the reference count and close
* the resource if it's needed.
*/
void
{
}
}
}
/*
* Mark this request so we know that we've already cleaned it up.
* A request should only get cleaned up once so multiple calls to
* smbsr_cleanup for the same request indicate a bug.
*/
}
int
{
int rc;
/* temporary until we identify a user */
/* If this connection is shutting down just kill request */
&sr->smb_pid_high,
return (-1);
}
/*
* The reply "header" is filled in now even though
* it most likely will be rewritten under reply_ready:
* below. Could just reserve the space. But this
* (for now) is convenient incase the dialect dispatcher
* has to send a special reply (like TRANSACT).
*
* Ensure that the 32-bit error code flag is turned off.
* Clients seem to set it in transact requests and they may
* get confused if we return success or a 16-bit SMB code.
*/
/*
* Verify SMB signature if signing is enabled,
* dialiect is NT LM 0.12,
* signing was negotiated and authentication has occurred.
*/
if (smb_sign_check_request(sr) != 0) {
/* Reply with ACCESS_DENIED */
else {
}
rc = -1;
goto reply_error;
}
}
rc = -3;
goto cant_decode;
}
rc = -5;
goto cant_decode;
}
rc = -6;
goto cant_decode;
}
/* Store pointers for later */
/* Peek ahead and don't disturb vwv */
rc = -7;
goto cant_decode;
}
} else {
}
case SMB_REQ_STATE_SUBMITTED:
case SMB_REQ_STATE_CLEANED_UP:
break;
case SMB_REQ_STATE_CANCELED:
break;
default:
ASSERT(0);
break;
}
if (sdd->sdt_function) {
/*
* Handle any errors from raw write.
*/
/*
* Set state so that the netbios session
* daemon will start accepting data again.
*/
}
/*
* We should never have sr->sr_keep set here
* since this is the error path.
*/
smb_emit_sending = 1;
}
if (rc < 0) {
rc -= 1000;
goto cant_decode;
}
goto reply_error;
}
/*
* Setup UID and TID information (if required). Both functions
* will set the sr credentials. In domain mode, the user and
* tree credentials should be the same. In share mode, the
* tree credentials (defined in the share definition) should
* override the user credentials.
*/
/* NOTREACHED */
}
/* NOTREACHED */
}
}
}
/*
* If the command is not a read raw request we can set the
* state of the session back to SMB_SESSION_STATE_NEGOTIATED
* (if the current state is SMB_SESSION_STATE_OPLOCK_BREAKING).
* Otherwise we let the read raw handler to deal with it.
*/
/*
* The lock may have to be upgraded because, at this
* point, we don't know how it was entered. We just
* know that it has to be entered in writer mode here.
* Whatever mode was used to enter the lock, it will
* be restored.
*/
}
}
/*
* Increment method invocation count. This value is exposed
* via kstats, and it represents a count of all the dispatched
* requests, including the ones that have a return value, other
* than SDRC_NORMAL_REPLY.
*/
/*
* Only call smbsr_cleanup if smb->sr_keep is not set. The
* smb_nt_transact_notify_change function will set
* smb->sr_keep if it retains control of the request when
* it returns. In that case the notify change code
* will call smbsr_cleanup later when the request is finally
* completed.
*/
} else {
}
switch (rc) {
case SDRC_NORMAL_REPLY:
break;
case SDRC_ERROR_REPLY:
goto reply_error;
case SDRC_DROP_VC:
break;
default:
break;
}
goto reply_error;
case SDRC_NO_REPLY:
/* tricky. */
return (0);
case SDRC_UNIMPLEMENTED:
goto reply_error;
default:
goto reply_error;
}
}
goto reply_ready;
/* have to back-patch the AndXCommand and AndXOffset */
/* now it gets interesting */
goto andx_more;
if (SMB_TREE_CASE_INSENSITIVE(sr)) {
} else {
}
return (rc);
}
goto reply_ready;
}
void
{
}
}
void
{
int total_bytes;
struct mbuf *m;
total_bytes = 0;
while (m != 0) {
total_bytes += m->m_len;
m = m->m_next;
}
/* NOTREACHED */
}
/* NOTREACHED */
}
/* NOTREACHED */
}
/* reply wct & vwv seem ok, consider data now */
}
/* NOTREACHED */
} else {
}
} else {
}
}
if (offset != total_bytes) {
}
}
int
{
int rc;
return (rc);
}
int
{
int r;
return (r);
}
void
{
}
void
{
}
void
{
}
void
{
}
/*
* cifs_raise_error
*
* decision: just report them both here.
*/
void
int error_class,
int error_code)
{
else
/* NOTREACHED */
}
void
{
}
/*
* smbsr_setup_nt_status
*
* Set up an NT status in the smb_request but don't long jump or try
* to do any error handling. There are times when we need a status set
* up in the response to indicate that the request has either failed
* or, at least, is only partially complete (possibly indicated by the
* severity) but we also need to return some information to the client.
*/
void
{
}
void
{
errcod |= 0xc0000000;
}
/*
* Attempt to map errno values to SMB and NT status values.
* Note: ESRCH is used as special case to handle a lookup
* failure on streams.
*/
static struct {
int unix_errno;
int smb_error_class;
int smb_error_value;
}
smb_errno_map[] = {
/*
* It's not clear why smb_read_common effectively returns
* ERRnoaccess if a range lock prevents access and smb_write_common
* effectively returns ERRaccess. This table entry is used by
* smb_read_common and preserves the behavior that was there before.
*/
};
void
{
int i;
for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) {
return;
}
}
}
int
{
int i;
/*
* If the client supports 32-bit NT status values, check for
* an appropriate mapping and raise an NT error, control won't
* return here due to the longjmp in smbsr_raise_nt_error.
*/
for (i = 0;
i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]);
++i) {
smb_errno_map[i].nt_status);
/* NOTREACHED */
}
}
} else {
for (i = 0;
i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]);
++i) {
return (0);
}
}
}
return (-1);
}
void
{
if (smb_dispatch_diags) {
}
}
/* no return */
}
smb_xa_t *
{
}
void
{
(void) smb_ofile_release(of);
}
void
{
}
static int
is_andx_com(unsigned char com)
{
switch (com) {
case SMB_COM_LOCKING_ANDX:
case SMB_COM_OPEN_ANDX:
case SMB_COM_READ_ANDX:
case SMB_COM_WRITE_ANDX:
case SMB_COM_LOGOFF_ANDX:
case SMB_COM_NT_CREATE_ANDX:
return (1);
}
return (0);
}
/*
* Invalid command stub.
*/
/*ARGSUSED*/
int
{
return (SDRC_UNIMPLEMENTED);
}
/*
* smb_kstat_update_dispatch
*
* This callback function updates the smb_dispatch_kstat_data when kstat
* command is invoked.
*/
/*ARGSUSED*/
static int
{
int i = 0, j = 0;
if (rw == KSTAT_WRITE) {
return (EACCES);
} else {
for (i = 0; i < 256; i++) {
if (dispatch[i].sdt_function) {
(void) memcpy(&smb_dispatch_kstat_data[j],
&(dispatch[i].sdt_dispatch_stats),
sizeof (kstat_named_t));
j++;
}
}
}
return (0);
}
/*
* smb_initialize_dispatch_kstat
*
* Initialize dispatch kstats.
*/
void
{
int i = 0, alloc_size = 0;
for (i = 0; i < 256; i++) {
if (dispatch[i].sdt_function)
}
if (smb_dispatch_ksp) {
}
}
/*
* smb_remove_dispatch_kstat
*
* Remove dispatch kstats.
*/
void
{
if (smb_dispatch_kstat_data != NULL)
smb_dispatch_kstat_size * sizeof (kstat_named_t));
if (smb_dispatch_ksp != NULL) {
}
}