smb_ktypes.h revision 8622ec4569457733001d4982ef7f5b44427069be
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 2N/A * Structures and type definitions for the SMB module. 2N/A * Accumulated time and queue length statistics. 2N/A * Accumulated time statistics are kept as a running sum of "active" time. 2N/A * Queue length statistics are kept as a running sum of the product of queue 2N/A * length and elapsed time at that length -- i.e., a Riemann sum for queue 2N/A * length integrated against time. (You can also think of the active time as a 2N/A * Riemann sum, for the boolean function (queue_length > 0) integrated against 2N/A * time, or you can think of it as the Lebesgue measure of the set on which 2N/A * queue_length > 0.) 2N/A * Length | _________ | | 2N/A * 4 | i2 |_______| | 2N/A * |_______________________________| 2N/A * Time-> t1 t2 t3 t4 2N/A * At each change of state (entry or exit from the queue), we add the elapsed 2N/A * time (since the previous state change) to the active time if the queue length 2N/A * was non-zero during that interval; and we add the product of the elapsed time 2N/A * times the queue length to the running length*time sum. 2N/A * This method is generalizable to measuring residency in any defined system: 2N/A * instead of queue lengths, think of "outstanding RPC calls to server X". 2N/A * A large number of I/O subsystems have at least two basic "lists" of 2N/A * transactions they manage: one for transactions that have been accepted for 2N/A * processing but for which processing has yet to begin, and one for 2N/A * transactions which are actively being processed (but not done). For this 2N/A * reason, two cumulative time statistics are defined here: wait (pre-service) 2N/A * time, and run (service) time. 2N/A * All times are 64-bit nanoseconds (hrtime_t), as returned by gethrtime(). 2N/A * The units of cumulative busy time are accumulated nanoseconds. The units of 2N/A * cumulative length*time products are elapsed time times queue length. 2N/A * Updates to the fields below are performed implicitly by calls to 2N/A * smb_srqueue_init() 2N/A * smb_srqueue_destroy() 2N/A * smb_srqueue_waitq_enter() 2N/A * smb_srqueue_runq_exit() 2N/A * smb_srqueue_waitq_to_runq() 2N/A * smb_srqueue_update() 2N/A * These fields should never be updated by any other means. 2N/A * The fields with the prefix 'ly_a' contain the statistics collected since the 2N/A * server was last started ('a' for 'aggregated'). The fields with the prefix 2N/A * 'ly_d' contain the statistics collected since the last snapshot ('d' for 2N/A * Maximum number of records returned in SMBsearch, SMBfind 2N/A * and SMBfindunique response. Value set to 10 for compatibility 2N/A * Thread State Machine 2N/A * -------------------- 2N/A * smb_thread_destroy() <-------+ +------- smb_thread_init() 2N/A * +-----------------------------+ 2N/A * | SMB_THREAD_STATE_EXITED |<---+ 2N/A * +-----------------------------+ | 2N/A * +-----------------------------+ | 2N/A * | SMB_THREAD_STATE_STARTING | | 2N/A * +-----------------------------+ | 2N/A * +-----------------------------+ | 2N/A * | SMB_THREAD_STATE_RUNNING | | 2N/A * +-----------------------------+ | 2N/A * +-----------------------------+ | 2N/A * | SMB_THREAD_STATE_EXITING |----+ 2N/A * +-----------------------------+ 2N/A * This transition is executed in smb_thread_init(). 2N/A * This transition is executed in smb_thread_start(). 2N/A * This transition is executed by the thread itself when it starts running. 2N/A * This transition is executed by the thread itself in 2N/A * smb_thread_entry_point() just before calling thread_exit(). 2N/A * This transition is executed in smb_thread_stop(). 2N/A * This transition is executed in smb_thread_destroy(). 2N/A * A pool of IDs is a pool of 16 bit numbers. It is implemented as a bitmap. 2N/A * A bit set to '1' indicates that that particular value has been allocated. 2N/A * The allocation process is done shifting a bit through the whole bitmap. 2N/A * The current position of that index bit is kept in the smb_idpool_t 2N/A * structure and represented by a byte index (0 to buffer size minus 1) and 2N/A * a bit index (0 to 7). 2N/A * The pools start with a size of 8 bytes or 64 IDs. Each time the pool runs 2N/A * out of IDs its current size is doubled until it reaches its maximum size 2N/A * (8192 bytes or 65536 IDs). The IDs 0 and 65535 are never given out which 2N/A * means that a pool can have a maximum number of 65534 IDs available. 2N/A * Maximum size of a Transport Data Unit when CAP_LARGE_READX and 2N/A * allow the payload to exceed the negotiated buffer size. 2N/A * 1 --> Word Count byte 2N/A * 510 --> Maximum Number of bytes of the Word Table (2 * 255) 2N/A * 2 --> Byte count of the data 2N/A * 65535 --> Maximum size of the data 2N/A * Maximum buffer size for NT is 37KB. If all clients are Windows 2000, this 2N/A * can be changed to 64KB. 37KB must be used with a mix of NT/Windows 2000 2N/A * clients because NT loses directory entries when values greater than 37KB are 2N/A * Note: NBT_MAXBUF will be subtracted from the specified max buffer size to 2N/A * account for the NBT header. 2N/A * Destructor object used in the locked-list delete queue. 2N/A * smb_avl_t State Machine 2N/A * -------------------- 2N/A * +-----------------------------+ 2N/A * | SMB_AVL_STATE_START | 2N/A * +-----------------------------+ 2N/A * +-----------------------------+ 2N/A * | SMB_AVL_STATE_READY | 2N/A * +-----------------------------+ 2N/A * +-----------------------------+ 2N/A * | SMB_AVL_STATE_DESTROYING | 2N/A * +-----------------------------+ 2N/A * This transition is executed in smb_avl_create(). 2N/A * This transition is executed in smb_avl_destroy(). 2N/A * SMB operates over a NetBIOS-over-TCP transport (NBT) or directly * over TCP, which is also known as direct hosted NetBIOS-less SMB * NBT messages have a 4-byte header that defines the message type * (8-bits), a 7-bit flags field and a 17-bit length. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | TYPE | FLAGS |E| LENGTH | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 8-bit type Defined in RFC 1002 * 7-bit flags Bits 0-6 reserved (must be 0) * Bit 7: Length extension bit (E) * 17-bit length Includes bit 7 of the flags byte * SMB-over-TCP is defined to use a modified version of the NBT header * containing an 8-bit message type and 24-bit message length. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * The following structure is used to represent a generic, in-memory * SMB transport header; it is not intended to map directly to either * of the over-the-wire formats. * SMB_OPLOCK_BREAK_EXCLUSIVE - only break exclusive oplock * (type SMB_OPLOCK_EXCLUSIVE or SMB_OPLOCK_BATCH) * SMB_OPLOCK_BREAK_BATCH - only break exclusive BATCH oplock * SMB_OPLOCK_BREAK_NOWAIT - do not wait for oplock break ack * Oplocks levels are defined to match the levels in the SMB * protocol (nt_create_andx / nt_transact_create) and should * waiting_event # of clients requesting FCN * n_timestamps cached timestamps * n_allocsz cached file allocation size * n_unode unnamed stream node * delete_on_close_cred credentials for delayed delete /* Maximum buffer size for encryption key */ * Based on section 2.6.1.2 (Connection Management) of the June 13, * 1996 CIFS spec, a server may terminate the transport connection * due to inactivity. The client software is expected to be able to * automatically reconnect to the server if this happens. Like much * of the useful background information, this section appears to * have been dropped from later revisions of the document. * Each session has an activity timestamp that's updated whenever a * request is dispatched. If the session is idle, i.e. receives no * requests, for SMB_SESSION_INACTIVITY_TIMEOUT minutes it will be * Each session has an I/O semaphore to serialize communication with * the client. For example, after receiving a raw-read request, the * server is not allowed to send an oplock break to the client until * after it has sent the raw-read data. * When a connection is set up we need to remember both the client * (peer) IP address and the local IP address used to establish the * connection. When a client connects with a vc number of zero, we * are supposed to abort any existing connections with that client * servers with multiple network interfaces or IP aliases, however, * each interface has to be managed independently since the client * is not aware of the server configuration. We have to allow the * client to establish a connection on each interface with a vc * number of zero without aborting the other connections. * ipaddr: the client (peer) IP address for the session. * local_ipaddr: the local IP address used to connect to the server. * +-----------------------------+ +------------------------------+ * | SMB_SESSION_STATE_CONNECTED | | SMB_SESSION_STATE_TERMINATED | * +-----------------------------+ +------------------------------+ * +--------------------+ |T13 * +-------------------------------+ | +--------------------------------+ * | SMB_SESSION_STATE_ESTABLISHED |---+--->| SMB_SESSION_STATE_DISCONNECTED | * +-------------------------------+ +--------------------------------+ * +------------------------------+ | | | * | SMB_SESSION_STATE_NEGOTIATED | | | | * +------------------------------+ | | | * +----------------+| || | | | | | * |+----------------+ || T7| |T8 | | | * || +----------------+| | | | | | * || |+----------------+ | | | | | * || || +-----------------------------------+ T10| | | * || || | SMB_SESSION_STATE_OPLOCK_BREAKING |----+ | | * || || +-----------------------------------+ | | * || |+-->+-----------------------------------+ T11| | * || |T6 | SMB_SESSION_STATE_READ_RAW_ACTIVE |------+ | * || +----+-----------------------------------+ | * |+------->+------------------------------------+ T12| * |T4 | SMB_SESSION_STATE_WRITE_RAW_ACTIVE |-------+ * +---------+------------------------------------+ * Maximum negotiated buffer size between SMB client and server * in SMB_SESSION_SETUP_ANDX * user whose uid was in the tree connect message * ("owner" in MS-CIFS parlance, see section 2.2.1.6 definition of FID) * SMB_TREE_CONTAINS_NODE is used to check if a node is on the same * file system as the tree's root filesystem, or if mount point traversal * should be allowed. Note that this is also called in some cases with * sr=NULL, where it is expected to evaluate to TRUE. * SMB_OFILE_IS_READONLY reflects whether an ofile is readonly or not. * The macro takes into account read-only settings in any of: * the tree, the node (pending) and the file-system object. * all of this is evaluated in smb_ofile_open() and after that * we can just test the f_flags & SMB_OFLAGS_READONLY * SMB_PATHFILE_IS_READONLY indicates whether or not a file is * readonly when the caller has a path rather than an ofile. * Data structure for SMB_FTYPE_MESG_PIPE ofiles, which is used * at the interface between SMB and NDR RPC. * The of_ftype of an open file should contain the SMB_FTYPE value * returned when the file/pipe was opened. The following * assumptions are currently made: * File Type Node PipeInfo * --------- -------- -------- * SMB_FTYPE_DISK Valid Null * SMB_FTYPE_BYTE_PIPE Undefined Undefined * SMB_FTYPE_MESG_PIPE Null Valid * SMB_FTYPE_PRINTER Undefined Undefined * SMB_FTYPE_UNKNOWN Undefined Undefined * Some flags for ofile structure * SMB_OFLAGS_SET_DELETE_ON_CLOSE * Set this flag when the corresponding open operation whose * DELETE_ON_CLOSE bit of the CreateOptions is set. If any * open file instance has this bit set, the NODE_FLAGS_DELETE_ON_CLOSE * will be set for the file node upon close. * Flags used when opening an odir /* This is only set by NTTransactCreate */ * SMB Request State Machine * ------------------------- * +--------------------------->| FREE |---------------------------+ * +------------+ T6 | | +--------------+ * | CLEANED_UP |<-----------------| CANCELED | | INITIALIZING | * +------------+ | | +--------------+ * | | +-------------+ | | | | * | | T3 | | | | T13 | T1 * | +-------------------------+ | | +----------------------+ | * +----------------------------+ | | | | | * T16 | | | | +-----------+ | | * +-----------------+ | T12 +--------+ | T2 +-----------+ * | EVENT_OCCURRED |------------->| ACTIVE |<--------------------| SUBMITTED | * +-----------------+ | +--------+ | +-----------+ * | T10 T9 | +----------+ | +-------+ | T11 * +----------------------+ +--------------+ * | WAITING_EVENT | | WAITING_LOCK | * +----------------------+ +--------------+ * This transition occurs when the request is allocated and is still under the * control of the session thread. * This transition occurs when the session thread dispatches a task to treat the * A request completes and smbsr_cleanup is called to release resources * associated with the request (but not the smb_request_t itself). This * includes references on smb_ofile_t, smb_node_t, and other structures. * CLEANED_UP state exists to detect if we attempt to cleanup a request * multiple times and to allow us to detect that we are accessing a * request that has already been cleaned up. * Request processing is completed (control returns from smb_dispatch) * Multipart (andx) request was cleaned up with smbsr_cleanup but more "andx" * sections remain to be processed. /* Info from session service header */ /* Request buffer excluding NBT header */ unsigned char smb_com;
/* command code */ unsigned char smb_sig[
8];
/* signiture */ unsigned char smb_wct;
/* count of parameter words */ unsigned char smb_com;
/* which TRANS type */ /* bit 0 - if set, disconnect TID in smb_tid */ /* bit 1 - if set, transaction is one way */ /* (no final response) */ * These are the param and data count received so far, * used to decide if the whole trans is here yet. * SMB dispatch return codes. /* protected by sv_mutex */ /* Internal door for up-calls to smbd */ /* RPC pipes (client side) */ * This structure is a helper for building RAP NetShareEnum response * es_posix_uid UID of the user requesting the shares list which * is used to detect if the user has any autohome * es_bufsize size of the response buffer * es_buf pointer to the response buffer * es_ntotal total number of shares exported by server which * their OEM names is less then 13 chars * es_nsent number of shares that can fit in the specified buffer * es_datasize actual data size (share's data) which was encoded #
endif /* _SMBSRV_SMB_KTYPES_H */