smb_ktypes.h revision 12b65585e720714b31036daaa2b30eb76014048e
/*
* 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 2013 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Structures and type definitions for the SMB module.
*/
#ifndef _SMBSRV_SMB_KTYPES_H
#define _SMBSRV_SMB_KTYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <smbsrv/smb_vops.h>
#include <smbsrv/smb_kstat.h>
struct __door_handle; /* <sys/door.h> */
struct edirent; /* <sys/extdirent.h> */
struct smb_disp_entry;
struct smb_request;
struct smb_server;
struct smb_event;
struct smb_export;
/*
* Accumulated time and queue length statistics.
*
* Accumulated time statistics are kept as a running sum of "active" time.
* Queue length statistics are kept as a running sum of the product of queue
* length and elapsed time at that length -- i.e., a Riemann sum for queue
* length integrated against time. (You can also think of the active time as a
* Riemann sum, for the boolean function (queue_length > 0) integrated against
* time, or you can think of it as the Lebesgue measure of the set on which
* queue_length > 0.)
*
* ^
* | _________
* 8 | i4 |
* | | |
* Queue 6 | |
* Length | _________ | |
* 4 | i2 |_______| |
* | | i3 |
* 2_______| |
* | i1 |
* |_______________________________|
* Time-> t1 t2 t3 t4
*
* At each change of state (entry or exit from the queue), we add the elapsed
* time (since the previous state change) to the active time if the queue length
* was non-zero during that interval; and we add the product of the elapsed time
* times the queue length to the running length*time sum.
*
* This method is generalizable to measuring residency in any defined system:
* instead of queue lengths, think of "outstanding RPC calls to server X".
*
* A large number of I/O subsystems have at least two basic "lists" of
* transactions they manage: one for transactions that have been accepted for
* processing but for which processing has yet to begin, and one for
* transactions which are actively being processed (but not done). For this
* reason, two cumulative time statistics are defined here: wait (pre-service)
* time, and run (service) time.
*
* All times are 64-bit nanoseconds (hrtime_t), as returned by gethrtime().
*
* The units of cumulative busy time are accumulated nanoseconds. The units of
* cumulative length*time products are elapsed time times queue length.
*
* Updates to the fields below are performed implicitly by calls to
* these functions:
*
* smb_srqueue_init()
* smb_srqueue_destroy()
* smb_srqueue_waitq_enter()
* smb_srqueue_runq_exit()
* smb_srqueue_waitq_to_runq()
* smb_srqueue_update()
*
* These fields should never be updated by any other means.
*/
typedef struct smb_srqueue {
/*
* The fields with the prefix 'ly_a' contain the statistics collected since the
* server was last started ('a' for 'aggregated'). The fields with the prefix
* 'ly_d' contain the statistics collected since the last snapshot ('d' for
* 'delta').
*/
typedef struct smb_latency {
typedef struct smb_disp_stats {
#define SMB_AUDIT_STACK_DEPTH 16
#define SMB_AUDIT_BUF_MAX_REC 16
#define SMB_AUDIT_NODE 0x00000001
/*
* Maximum number of records returned in SMBsearch, SMBfind
* and SMBfindunique response. Value set to 10 for compatibility
* with Windows.
*/
#define SMB_MAX_SEARCH 10
#define SMB_SEARCH_ATTRIBUTES \
typedef struct {
int anr_depth;
typedef struct {
int anb_index;
int anb_max_index;
/*
* Thread State Machine
* --------------------
*
* T5 T0
* smb_thread_destroy() <-------+ +------- smb_thread_init()
* | |
* | v
* +-----------------------------+
* | SMB_THREAD_STATE_EXITED |<---+
* +-----------------------------+ |
* | T1 |
* v |
* +-----------------------------+ |
* | SMB_THREAD_STATE_STARTING | |
* +-----------------------------+ |
* | T2 | T4
* v |
* +-----------------------------+ |
* | SMB_THREAD_STATE_RUNNING | |
* +-----------------------------+ |
* | T3 |
* v |
* +-----------------------------+ |
* | SMB_THREAD_STATE_EXITING |----+
* +-----------------------------+
*
* Transition T0
*
* This transition is executed in smb_thread_init().
*
* Transition T1
*
* This transition is executed in smb_thread_start().
*
* Transition T2
*
* This transition is executed by the thread itself when it starts running.
*
* Transition T3
*
* This transition is executed by the thread itself in
* smb_thread_entry_point() just before calling thread_exit().
*
*
* Transition T4
*
* This transition is executed in smb_thread_stop().
*
* Transition T5
*
* This transition is executed in smb_thread_destroy().
*/
typedef enum smb_thread_state {
struct _smb_thread;
typedef struct _smb_thread {
char sth_name[16];
void *sth_ep_arg;
} smb_thread_t;
/*
* Pool of IDs
* -----------
*
* A pool of IDs is a pool of 16 bit numbers. It is implemented as a bitmap.
* A bit set to '1' indicates that that particular value has been allocated.
* The allocation process is done shifting a bit through the whole bitmap.
* The current position of that index bit is kept in the smb_idpool_t
* structure and represented by a byte index (0 to buffer size minus 1) and
* a bit index (0 to 7).
*
* The pools start with a size of 8 bytes or 64 IDs. Each time the pool runs
* out of IDs its current size is doubled until it reaches its maximum size
* (8192 bytes or 65536 IDs). The IDs 0 and 65535 are never given out which
* means that a pool can have a maximum number of 65534 IDs available.
*/
typedef struct smb_idpool {
} smb_idpool_t;
/*
* Maximum size of a Transport Data Unit when CAP_LARGE_READX and
* CAP_LARGE_WRITEX are not set. CAP_LARGE_READX/CAP_LARGE_WRITEX
* allow the payload to exceed the negotiated buffer size.
* 32 --> SMB Header
* 1 --> Word Count byte
* 510 --> Maximum Number of bytes of the Word Table (2 * 255)
* 2 --> Byte count of the data
* 65535 --> Maximum size of the data
* -----
* 66084
*/
typedef struct {
int tr_len;
} smb_txreq_t;
typedef struct {
} smb_txlst_t;
/*
* Maximum buffer size for NT is 37KB. If all clients are Windows 2000, this
* clients because NT loses directory entries when values greater than 37KB are
* used.
*
* Note: NBT_MAXBUF will be subtracted from the specified max buffer size to
* account for the NBT header.
*/
#define NBT_MAXBUF 8
#define SMBHEADERSIZE 32
#define SMBND_HASH_MASK (0xFF)
#define MAX_IOVEC 512
#define SMB_WORKER_MIN 4
#define SMB_WORKER_DEFAULT 64
#define SMB_WORKER_MAX 1024
/*
* Destructor object used in the locked-list delete queue.
*/
#define SMB_DTOR_VALID(d) \
typedef void (*smb_dtorproc_t)(void *);
typedef struct smb_dtor {
void *dt_object;
} smb_dtor_t;
typedef struct smb_llist {
} smb_llist_t;
typedef struct smb_slist {
} smb_slist_t;
/*
* smb_avl_t State Machine
* --------------------
*
* +-----------------------------+
* | SMB_AVL_STATE_START |
* +-----------------------------+
* | T0
* v
* +-----------------------------+
* | SMB_AVL_STATE_READY |
* +-----------------------------+
* | T1
* v
* +-----------------------------+
* | SMB_AVL_STATE_DESTROYING |
* +-----------------------------+
*
* Transition T0
*
* This transition is executed in smb_avl_create().
*
* Transition T1
*
* This transition is executed in smb_avl_destroy().
*
*/
typedef enum {
SMB_AVL_STATE_START = 0,
typedef struct smb_avl_nops {
int (*avln_cmp) (const void *, const void *);
void (*avln_hold)(const void *);
void (*avln_destroy)(void *);
typedef struct smb_avl_cursor {
void *avlc_next;
typedef struct smb_avl {
const smb_avl_nops_t *avl_nops;
} smb_avl_t;
typedef struct {
} smb_rwx_t;
typedef struct smb_export {
} smb_export_t;
/* NOTIFY CHANGE */
typedef struct smb_node_fcn {
typedef struct smb_notify_change_req {
char *nc_fname;
/*
* SMB operates over a NetBIOS-over-TCP transport (NBT) or directly
* over TCP, which is also known as direct hosted NetBIOS-less SMB
* or SMB-over-TCP.
*
* 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.
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | TYPE | LENGTH |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* 8-bit type Must be 0
* 24-bit 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.
*/
typedef struct {
} smb_xprt_t;
int MBC_LENGTH(struct mbuf_chain *);
int MBC_MAXBYTES(struct mbuf_chain *);
void MBC_FLUSH(struct mbuf_chain *);
/*
* Oplock break flags:
* 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
*/
#define SMB_OPLOCK_NO_BREAK 0x00
#define SMB_OPLOCK_BREAK_TO_NONE 0x01
#define SMB_OPLOCK_BREAK_TO_LEVEL_II 0x02
#define SMB_OPLOCK_BREAK_EXCLUSIVE 0x04
#define SMB_OPLOCK_BREAK_BATCH 0x08
#define SMB_OPLOCK_BREAK_NOWAIT 0x10
/*
* Oplocks levels are defined to match the levels in the SMB
* protocol (nt_create_andx / nt_transact_create) and should
* not be changed
*/
#define SMB_OPLOCK_NONE 0
#define SMB_OPLOCK_EXCLUSIVE 1
#define SMB_OPLOCK_BATCH 2
#define SMB_OPLOCK_LEVEL_II 3
typedef struct smb_oplock {
} smb_oplock_t;
#define SMB_OPLOCK_GRANT_VALID(p) \
#define SMB_OFILE_OPLOCK_GRANTED(p) \
typedef struct smb_oplock_grant {
struct smb_session *og_session;
#define SMB_OPLOCK_BREAK_VALID(p) \
typedef struct smb_oplock_break {
typedef struct smb_vfs {
} smb_vfs_t;
typedef enum {
/*
* waiting_event # of clients requesting FCN
* n_timestamps cached timestamps
* n_allocsz cached file allocation size
* n_dnode directory node
* n_unode unnamed stream node
* delete_on_close_cred credentials for delayed delete
*/
typedef struct smb_node {
volatile int flags;
char od_name[MAXNAMELEN];
} smb_node_t;
#define NODE_FLAGS_REPARSE 0x00001000
#define NODE_FLAGS_DFSLINK 0x00002000
#define NODE_FLAGS_VFSROOT 0x00004000
#define NODE_FLAGS_SYSTEM 0x00008000
#define NODE_FLAGS_WRITE_THROUGH 0x00100000
#define NODE_XATTR_DIR 0x01000000
#define NODE_FLAGS_DELETE_ON_CLOSE 0x40000000
#define NODE_FLAGS_EXECUTABLE 0x80000000
/* Maximum buffer size for encryption key */
#define SMB_ENCRYPT_KEY_MAXLEN 32
typedef struct smb_kshare {
char *shr_name;
char *shr_path;
char *shr_cmnt;
char *shr_container;
char *shr_oemname;
char *shr_access_none;
char *shr_access_ro;
char *shr_access_rw;
} smb_kshare_t;
typedef struct smb_arg_negotiate {
char *ni_name;
int ni_dialect;
int ni_index;
typedef enum {
typedef struct smb_arg_sessionsetup {
char *ssi_user;
char *ssi_domain;
/* LM password hash, f.k.a. case-insensitive p/w */
/* NT password hash, f.k.a. case-sensitive p/w */
/* Incoming security blob */
/* Incoming security blob */
/* parameters */
int ssi_native_os;
int ssi_native_lm;
typedef struct tcon {
char *path;
char *service;
int pwdlen;
char *password;
/*
* 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
* closed.
*
* 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
* (see notes in smb_negotiate.c and smb_session_setup_andx.c). For
* 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.
*/
struct smb_sign {
unsigned int flags;
};
#define SMB_SIGNING_ENABLED 1
#define SMB_SIGNING_CHECK 2
/*
* Session State Machine
* ---------------------
*
* +-----------------------------+ +------------------------------+
* | SMB_SESSION_STATE_CONNECTED | | SMB_SESSION_STATE_TERMINATED |
* +-----------------------------+ +------------------------------+
* T0| ^
* +--------------------+ |T13
* v |T14 |
* +-------------------------------+ | +--------------------------------+
* | SMB_SESSION_STATE_ESTABLISHED |---+--->| SMB_SESSION_STATE_DISCONNECTED |
* +-------------------------------+ +--------------------------------+
* T1| ^ ^ ^ ^
* +----------+ |T9 | | |
* v | | | |
* +------------------------------+ | | |
* | SMB_SESSION_STATE_NEGOTIATED | | | |
* +------------------------------+ | | |
* ^| ^| | ^ | | |
* +----------------+| || | | | | |
* |+----------------+ || T7| |T8 | | |
* || || | | | | |
* || +----------------+| | | | | |
* || |+----------------+ | | | | |
* || || v | | | |
* || || +-----------------------------------+ T10| | |
* || || | SMB_SESSION_STATE_OPLOCK_BREAKING |----+ | |
* || || +-----------------------------------+ | |
* || ||T5 | |
* || |+-->+-----------------------------------+ T11| |
* || |T6 | SMB_SESSION_STATE_READ_RAW_ACTIVE |------+ |
* || +----+-----------------------------------+ |
* ||T3 |
* |+------->+------------------------------------+ T12|
* |T4 | SMB_SESSION_STATE_WRITE_RAW_ACTIVE |-------+
* +---------+------------------------------------+
*
* Transition T0
*
*
*
* Transition T1
*
*
*
* Transition T2
*
*
*
* Transition T3
*
*
*
* Transition T4
*
*
*
* Transition T5
*
*
*
* Transition T6
*
*
*
* Transition T7
*
*
*
* Transition T8
*
*
*
* Transition T9
*
*
*
* Transition T10
*
*
*
* Transition T11
*
*
*
* Transition T12
*
*
*
* Transition T13
*
*
*
* Transition T14
*
*
*
*/
#define SMB_SESSION_VALID(p) \
#define SMB_CHALLENGE_SZ 8
typedef enum {
typedef struct smb_session {
struct smb_server *s_server;
int dialect;
int native_os;
int native_lm;
void *sign_mech; /* mechanism info */
void (*sign_fini)(struct smb_session *);
volatile uint32_t s_tree_cnt;
volatile uint32_t s_file_cnt;
unsigned char challenge_key[SMB_CHALLENGE_SZ];
unsigned char MAC_key[44];
/*
* Maximum negotiated buffer size between SMB client and server
* in SMB_SESSION_SETUP_ANDX
*/
int outpipe_datalen;
int outpipe_cookie;
char ip_addr_str[INET6_ADDRSTRLEN];
char workstation[SMB_PI_MAX_HOST];
#define SMB_USER_VALID(u) \
#define SMB_USER_FLAG_GUEST SMB_ATF_GUEST
#define SMB_USER_FLAG_IPC SMB_ATF_ANON
#define SMB_USER_FLAG_ADMIN SMB_ATF_ADMIN
#define SMB_USER_PRIV_TAKE_OWNERSHIP 0x00000001
#define SMB_USER_PRIV_BACKUP 0x00000002
#define SMB_USER_PRIV_RESTORE 0x00000004
#define SMB_USER_PRIV_SECURITY 0x00000008
typedef enum {
typedef struct smb_user {
struct smb_server *u_server;
char *u_name;
char *u_domain;
} smb_user_t;
#define SMB_TREE_VALID(p) \
#define SMB_TYPENAMELEN _ST_FSTYPSZ
#define SMB_VOLNAMELEN 32
#define SMB_TREE_READONLY 0x00000001
#define SMB_TREE_SUPPORTS_ACLS 0x00000002
#define SMB_TREE_STREAMS 0x00000004
#define SMB_TREE_CASEINSENSITIVE 0x00000008
#define SMB_TREE_NO_CASESENSITIVE 0x00000010
#define SMB_TREE_NO_EXPORT 0x00000020
#define SMB_TREE_OPLOCKS 0x00000040
#define SMB_TREE_SHORTNAMES 0x00000080
#define SMB_TREE_XVATTR 0x00000100
#define SMB_TREE_DIRENTFLAGS 0x00000200
#define SMB_TREE_ACLONCREATE 0x00000400
#define SMB_TREE_ACEMASKONACCESS 0x00000800
#define SMB_TREE_NFS_MOUNTED 0x00001000
#define SMB_TREE_UNICODE_ON_DISK 0x00002000
#define SMB_TREE_CATIA 0x00004000
#define SMB_TREE_ABE 0x00008000
#define SMB_TREE_QUOTA 0x00010000
#define SMB_TREE_DFSROOT 0x00020000
#define SMB_TREE_SPARSE 0x00040000
#define SMB_TREE_TRAVERSE_MOUNTS 0x00080000
typedef enum {
typedef struct smb_tree {
struct smb_server *t_server;
/*
* user whose uid was in the tree connect message
* ("owner" in MS-CIFS parlance, see section 2.2.1.6 definition of FID)
*/
char t_sharename[MAXNAMELEN];
char t_resource[MAXPATHLEN];
char t_typename[SMB_TYPENAMELEN];
char t_volume[SMB_VOLNAMELEN];
volatile uint32_t t_open_files;
} smb_tree_t;
#define SMB_TREE_IS_READONLY(sr) \
#define SMB_TREE_IS_CASEINSENSITIVE(sr) \
#define SMB_TREE_SUPPORTS_CATIA(sr) \
#define SMB_TREE_SUPPORTS_ABE(sr) \
#define SMB_TREE_IS_DFSROOT(sr) \
#define SMB_TREE_SUPPORTS_SHORTNAMES(sr) \
/*
* 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
*/
#define SMB_OFILE_IS_READONLY(of) \
/*
* SMB_PATHFILE_IS_READONLY indicates whether or not a file is
* readonly when the caller has a path rather than an ofile.
*/
(SMB_TREE_IS_READONLY((sr)) || \
#define SMB_OPIPE_VALID(p) \
#define SMB_OPIPE_MAXNAME 32
/*
* Data structure for SMB_FTYPE_MESG_PIPE ofiles, which is used
* at the interface between SMB and NDR RPC.
*/
typedef struct smb_opipe {
struct smb_server *p_server;
/* This is the "flat" name, without path prefix */
char p_name[SMB_OPIPE_MAXNAME];
} smb_opipe_t;
/*
* The of_ftype of an open file should contain the SMB_FTYPE value
* 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.
*/
#define SMB_OFLAGS_READONLY 0x0001
#define SMB_OFLAGS_EXECONLY 0x0002
#define SMB_OFLAGS_SET_DELETE_ON_CLOSE 0x0004
#define SMB_OFLAGS_LLF_POS_VALID 0x0008
#define SMB_OFILE_VALID(p) \
typedef enum {
SMB_OFILE_STATE_OPEN = 0,
typedef struct smb_ofile {
struct smb_server *f_server;
int f_mode;
char f_quota_resume[SMB_SID_STRSZ];
} smb_ofile_t;
#define SMB_ODIR_VALID(p) \
#define SMB_ODIR_FLAG_WILDCARDS 0x0001
#define SMB_ODIR_FLAG_IGNORE_CASE 0x0002
#define SMB_ODIR_FLAG_XATTR 0x0004
#define SMB_ODIR_FLAG_EDIRENT 0x0008
#define SMB_ODIR_FLAG_CATIA 0x0010
#define SMB_ODIR_FLAG_ABE 0x0020
#define SMB_ODIR_FLAG_SHORTNAMES 0x0040
typedef enum {
SMB_ODIR_STATE_OPEN = 0,
typedef enum {
typedef struct smb_odir_resume {
int or_idx;
char *or_fname;
/*
* Flags used when opening an odir
*/
#define SMB_ODIR_OPENF_BACKUP_INTENT 0x01
typedef struct smb_odir {
int d_bufsize;
union {
char *u_bufptr;
} d_u;
char d_pattern[MAXNAMELEN];
char d_buf[SMB_ODIR_BUFSIZE];
char d_last_name[MAXNAMELEN];
} smb_odir_t;
typedef struct smb_odirent {
typedef struct smb_fileinfo {
char fi_name[MAXNAMELEN];
char fi_shortname[SMB_SHORTNAMELEN];
typedef struct smb_streaminfo {
char si_name[MAXPATHLEN];
typedef struct smb_lock {
struct smb_request *l_sr;
} smb_lock_t;
#define SMB_LOCK_FLAG_INDEFINITE 0x0004
#define SMB_LOCK_INDEFINITE_WAIT(lock) \
#define SMB_LOCK_TYPE_READWRITE 101
#define SMB_LOCK_TYPE_READONLY 102
typedef struct vardata_block {
} smb_vdb_t;
#define SMB_WRMODE_WRITE_THRU 0x0001
#define SMB_WRMODE_IS_STABLE(M) ((M) & SMB_WRMODE_WRITE_THRU)
typedef struct smb_rw_param {
typedef struct smb_pathname {
char *pn_path;
char *pn_pname;
char *pn_fname;
char *pn_sname;
char *pn_stype;
/*
* fs_query_info
*/
typedef struct smb_fqi {
char fq_last_comp[MAXNAMELEN];
} smb_fqi_t;
typedef struct dirop {
typedef struct {
} smb_error_t;
typedef struct open_param {
/*
* SMB Request State Machine
* -------------------------
*
* T4 +------+ T0
* +--------------------------->| FREE |---------------------------+
* | +------+ |
* +-----------+ |
* | COMPLETED | |
* +-----------+
* ^ |
* | T15 +----------+ v
* +------------+ T6 | | +--------------+
* | CLEANED_UP |<-----------------| CANCELED | | INITIALIZING |
* +------------+ | | +--------------+
* | ^ +----------+ |
* | | ^ ^ ^ ^ |
* | | +-------------+ | | | |
* | | T3 | | | | T13 | T1
* | +-------------------------+ | | +----------------------+ |
* +----------------------------+ | | | | |
* T16 | | | | +-----------+ | |
* | \/ | | T5 | | v
* +-----------------+ | T12 +--------+ | T2 +-----------+
* | EVENT_OCCURRED |------------->| ACTIVE |<--------------------| SUBMITTED |
* +-----------------+ | +--------+ | +-----------+
* ^ | | ^ | |
* | | T8 | | | T7 |
* | T10 T9 | +----------+ | +-------+ | T11
* | | | +-------+ | |
* | | | T14 | | |
* | | v | v |
* +----------------------+ +--------------+
* | WAITING_EVENT | | WAITING_LOCK |
* +----------------------+ +--------------+
*
*
*
*
*
* Transition T0
*
* This transition occurs when the request is allocated and is still under the
* control of the session thread.
*
* Transition T1
*
* This transition occurs when the session thread dispatches a task to treat the
* request.
*
* Transition T2
*
*
*
* Transition T3
*
* 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.
*
* Transition T4
*
*
*
* Transition T5
*
*
*
* Transition T6
*
*
*
* Transition T7
*
*
*
* Transition T8
*
*
*
* Transition T9
*
*
*
* Transition T10
*
*
*
* Transition T11
*
*
*
* Transition T12
*
*
*
* Transition T13
*
*
*
* Transition T14
*
*
*
* Transition T15
*
* Request processing is completed (control returns from smb_dispatch)
*
* Transition T16
*
* Multipart (andx) request was cleaned up with smbsr_cleanup but more "andx"
* sections remain to be processed.
*
*/
typedef enum smb_req_state {
SMB_REQ_STATE_FREE = 0,
typedef struct smb_request {
struct smb_server *sr_server;
/* Info from session service header */
/* Request buffer excluding NBT header */
void *sr_request_buf;
struct mbuf_chain command;
struct mbuf_chain reply;
struct mbuf_chain raw_data;
int andx_prev_wct;
int cur_reply_offset;
int orig_request_hdr;
unsigned int reply_seqnum; /* reply sequence number */
unsigned char first_smb_com; /* command code */
unsigned char smb_com; /* command code */
unsigned char smb_wct; /* count of parameter words */
/* Parameters */
/* Data */
struct mbuf_chain smb_data;
unsigned char andx_com;
union {
} arg;
#define SMB_READ_PROTOCOL(hdr) \
#define SMB_PROTOCOL_MAGIC_INVALID(rd_sr) \
#define SMB_READ_COMMAND(hdr) \
#define SMB_IS_NT_CANCEL(rd_sr) \
#define SMB_IS_SESSION_SETUP_ANDX(rd_sr) \
#define SMB_IS_NT_NEGOTIATE(rd_sr) \
#define SMB_IS_TREE_CONNECT_ANDX(rd_sr) \
#define SMB_XA_FLAG_OPEN 0x0001
#define SMB_XA_FLAG_CLOSE 0x0002
#define SMB_XA_FLAG_COMPLETE 0x0004
typedef struct smb_xa {
struct smb_session *xa_session;
unsigned char smb_com; /* which TRANS type */
unsigned char smb_flg; /* flags */
unsigned int reply_seqnum; /* reply sequence number */
/* bit 0 - if set, disconnect TID in smb_tid */
/* bit 1 - if set, transaction is one way */
/* (no final response) */
char *xa_pipe_name;
/*
* These are the param and data count received so far,
* used to decide if the whole trans is here yet.
*/
int req_disp_param;
int req_disp_data;
struct mbuf_chain req_setup_mb;
struct mbuf_chain req_param_mb;
struct mbuf_chain req_data_mb;
struct mbuf_chain rep_setup_mb;
struct mbuf_chain rep_param_mb;
struct mbuf_chain rep_data_mb;
} smb_xa_t;
#define SDDF_NO_FLAGS 0
#define SDDF_SUPPRESS_TID 0x0001
#define SDDF_SUPPRESS_UID 0x0002
/*
* SMB dispatch return codes.
*/
typedef enum {
SDRC_SUCCESS = 0,
} smb_sdrc_t;
#define VAR_BCC ((short)-1)
#define SMB_SERVER_VALID(s) \
#define SMB_LISTENER_VALID(ld) \
typedef struct {
struct smb_server *ld_sv;
int ld_family;
struct sockaddr_in ld_sin;
struct sockaddr_in6 ld_sin6;
#define SMB_SSETUP_CMD "authentication"
#define SMB_TCON_CMD "share mapping"
#define SMB_OPIPE_CMD "pipe open"
#define SMB_THRESHOLD_REPORT_THROTTLE 50
typedef struct smb_cmd_threshold {
char *ct_cmd;
volatile uint32_t ct_active_cnt;
volatile uint32_t ct_blocked_cnt;
typedef struct {
typedef enum smb_server_state {
typedef struct {
/* protected by sv_mutex */
} smb_spool_t;
#define SMB_SERVER_STATE_VALID(S) \
ASSERT(((S) == SMB_SERVER_STATE_CREATED) || \
((S) == SMB_SERVER_STATE_CONFIGURED) || \
((S) == SMB_SERVER_STATE_RUNNING) || \
((S) == SMB_SERVER_STATE_STOPPING) || \
((S) == SMB_SERVER_STATE_DELETING))
typedef struct smb_server {
struct smb_export sv_export;
struct __door_handle *sv_lmshrd;
/* Internal door for up-calls to smbd */
struct __door_handle *sv_kdoor_hd;
int sv_kdoor_id; /* init -1 */
/* Statistics */
volatile uint32_t sv_nbt_sess;
volatile uint32_t sv_tcp_sess;
} smb_server_t;
#define SMB_EVENT_VALID(e) \
typedef struct smb_event {
int se_waittime;
int se_timeout;
int se_errno;
} smb_event_t;
typedef struct smb_kspooldoc {
char sd_username[MAXNAMELEN];
char sd_path[MAXPATHLEN];
typedef struct smb_spoolfid {
#define SMB_INFO_NETBIOS_SESSION_SVC_RUNNING 0x0001
#define SMB_INFO_NETBIOS_SESSION_SVC_FAILED 0x0002
#define SMB_INFO_USER_LEVEL_SECURITY 0x40000000
#define SMB_INFO_ENCRYPT_PASSWORDS 0x80000000
typedef struct smb_tsd {
void (*proc)();
void *arg;
char name[100];
} smb_tsd_t;
typedef struct smb_disp_entry {
char sdt_name[KSTAT_STRLEN];
void (*sdt_post_op)(smb_request_t *);
char sdt_dialect;
typedef struct smb_xlate {
int code;
char *str;
} smb_xlate_t;
/*
* 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
* in the response buffer
*/
typedef struct smb_enumshare_info {
char *es_buf;
#ifdef __cplusplus
}
#endif
#endif /* _SMBSRV_SMB_KTYPES_H */