/*
* 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.
*/
#ifndef _SMBSRV_SMB_H
#define _SMBSRV_SMB_H
/*
* SMB definitions and interfaces, mostly defined in the SMB and CIFS specs.
*/
#include <smb/ntstatus.h>
#include <smb/doserror.h>
#include <smbsrv/ntaccess.h>
/*
* Macintosh Extensions for CIFS
*/
#include <smbsrv/mac_cifs.h>
/*
* NT Installable File System (IFS) interface.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* The msgbuf format and length of an SMB header.
*/
/* There is something wrong with this. Should be 38 bytes. It is 37 bytes */
/*
* CIFS definition for the SMB header (CIFS Section 3.2). Note that the
* pid_high field is not documented in the 1997 CIFS specificaction. This
* is a decoded or memory-based definition, which may be padded to align
* its elements on word boundaries. See smb_hdrbuf_t for the network
* ready structure.
*/
typedef struct smb_hdr {
union {
struct {
} dos_error;
} status;
union {
struct {
} extra;
} extra;
} smb_hdr_t;
/*
* Encoded or packed SMB header in network ready format.
*/
typedef struct smb_hdrbuf {
} smb_hdrbuf_t;
/*
* Protocol magic value as a 32-bit. This will be 0xff 0x53 0x4d 0x42 on
* the wire.
*/
/*
* Time and date encoding (CIFS Section 3.6). The date is encoded such
* that the year has a range of 0-119, which represents 1980-2099. The
* month range is 1-12, and the day range is 1-31.
*/
typedef struct smb_date {
} smb_date_t;
/*
* The hours range is 0-23, the minutes range is 0-59 and the two_sec
* range is 0-29.
*/
typedef struct smb_time {
} smb_time_t;
/*
* This is a 64-bit signed absolute time representing 100ns increments.
* A positive value represents the absolute time since 1601AD. A
* negative value represents a context specific relative time.
*/
typedef struct smb_time2 {
} smb_time2_t;
/*
* The number of seconds since Jan 1, 1970, 00:00:00.0.
*/
/* Share types */
#ifndef _SHARE_TYPES_DEFINED_
#define _SHARE_TYPES_DEFINED_
#endif /* _SHARE_TYPES_DEFINED_ */
/*
* NtCreateAndX and NtTransactCreate creation flags: defined in CIFS
* section 4.2.2
*
* Creation Flag Name Value Description
* ========================== ====== ==================================
* NT_CREATE_REQUEST_OPLOCK 0x02 Level I oplock requested
* NT_CREATE_REQUEST_OPBATCH 0x04 Batch oplock requested
* NT_CREATE_OPEN_TARGET_DIR 0x08 Target for open is a directory
*/
/*
* Define the filter flags for NtNotifyChangeDirectoryFile
*/
/*
* Define the file action type codes for NtNotifyChangeDirectoryFile
*/
/*
* Note: These action values are not from MS-FSCC.
* FILE_ACTION_SUBDIR_CHANGED is used internally for
* "watch tree" support, posted to all parents of a
* directory that had one of the changes above.
* FILE_ACTION_DELETE_PENDING is used internally to tell
* notify change requests when the "delete-on-close" flag
* has been set on the directory being watched.
*/
/* Lock type flags */
/*
* Flags field of the SMB header. The names in parenthesis represent
* alternative names for the flags.
*
* SMB_FLAGS_LOCK_AND_READ_OK If the server supports LockAndRead and
* (SMB_FLAGS_LOCKS_SUBDIALECT) WriteAndUnlock, it sets this bit in the
* Negotiate response.
*
* SMB_FLAGS_SEND_NO_ACK When on, the client guarantees that there
* (SMB_FLAGS_RCV_BUF_POSTED) is a receive buffer posted such that a
* "Send-No-Ack" can be used by the server
* to respond to the client's request.
*
* SMB_FLAGS_CASE_INSENSITIVE This is part of the Flags field of every
* SMB header. If this bit is set, then all
* pathnames in the SMB should be treated as
* case-insensitive. Otherwise pathnames are
* case-sensitive.
*
* SMB_FLAGS_CANONICALIZED_PATHS When on in SessionSetupX, this indicates
* that all paths sent to the server are
* already in OS/2 canonicalized format.
*
* are valid characters, . and .. have been removed and single backslashes
* are used as separators.
*
* SMB_FLAGS_OPLOCK When set in an open file request SMBs
* (Open, Create, OpenX, etc.) this bit
* indicates a request for an oplock on the
* file. When set in the response, this bit
* indicates that the oplock was granted.
*
* SMB_FLAGS_OPLOCK_NOTIFY_ANY When on, this bit indicates that the server
* should notify the client on any request
* that could cause the file to be changed.
* If not set, the server only notifies the
* client on other open requests on the file.
* This bit is only relevant when
* SMB_FLAGS_OPLOCK is set.
*
* SMB_FLAGS_SERVER_TO_REDIR This bit indicates that the SMB is being
* (SMB_FLAGS_REPLY) sent from server to (client) redirector.
*/
/*
* Flags2 field of the SMB header.
*
* SMB_FLAGS2_READ_IF_EXECUTE is also known as SMB_FLAGS2_PAGING_IO
*/
#define DIALECT_UNKNOWN 0
/*
* SMB_TREE_CONNECT_ANDX OptionalSupport flags
*
* SMB_SUPPORT_SEARCH_BITS The server supports SearchAttributes.
* SMB_SHARE_IS_IN_DFS The share is managed by DFS.
* SMB_CSC_MASK Offline-caching mask - see CSC values.
* SMB_UNIQUE_FILE_NAME The server uses long names and does not support
* short names. This indicates to clients that
* they may perform directory name-space caching.
* SMB_EXTENDED_SIGNATURES The server will use signing key protection.
*
* SMB_CSC_CACHE_MANUAL_REINT Clients are allowed to cache files for offline
* use as requested by users but automatic
* file-by-file reintegration is not allowed.
* SMB_CSC_CACHE_AUTO_REINT Clients are allowed to automatically cache
* files for offline use and file-by-file
* reintegration is allowed.
* SMB_CSC_CACHE_VDO Clients are allowed to automatically cache files
* for offline use, file-by-file reintegration is
* allowed and clients are permitted to work from
* their local cache even while offline.
* SMB_CSC_CACHE_NONE Client-side caching is disabled for this share.
*
* SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM
* The server will filter directory entries based
* on the access permissions of the client.
*/
/*
* The subcommand codes, placed in SETUP[0], for named pipe operations are:
* SubCommand Code Value Description
* =================== ===== =========================================
*/
/*
* Setup[0] Transaction2 Value Description
* Subcommand Code
* ========================== ===== =============================
*/
/*
* Access Mode Encoding (CIFS/1.0 1996 Section 3.8).
*
* The desired access mode passed in SmbOpen and SmbOpenAndX has the following
* mapping:
*
* 1111 11
* 5432 1098 7654 3210
* rWrC rLLL rSSS rAAA
*
* where:
*
* W - Write through mode. No read ahead or write behind allowed on
* this file or device. When protocol is returned, data is expected
* to be on the disk or device.
*
* S - Sharing mode:
* 0 - Compatibility mode (as in core open)
* 2 - Deny write
* 4 - Deny none
*
* A - Access mode
* 0 - Open for reading
* 1 - Open for writing
* 2 - Open for reading and writing
* 3 - Open for execute
*
* rSSSrAAA = 11111111 (hex FF) indicates FCB open (as in core protocol)
*
* C - Cache mode
* 0 - Normal file
* 1 - Do not cache this file
*
* L - Locality of reference
* 0 - Locality of reference is unknown
* 1 - Mainly sequential access
* 2 - Mainly random access
* 3 - Random access with some locality
* 4 to 7 - Currently undefined
*/
/*
* Macros used for share reservation rule checking
*/
/*
* The SMB open function determines what action should be taken depending
* on the existence or lack thereof of files used in the operation. It
* has the following mapping:
*
* 1111 1
* 5432 1098 7654 3210
* rrrr rrrr rrrC rrOO
*
* where:
*
* O - Open (action to be taken if the target file exists)
* 0 - Fail
* 1 - Open or Append file
* 2 - Truncate file
*
* C - Create (action to be taken if the target file does not exist)
* 0 - Fail
* 1 - Create file
*/
#define SMB_OFUN_OPEN_FAIL 0
/*
* The Action field of OpenAndX has the following format:
*
* 1111 11
* 5432 1098 7654 3210
* Lrrr rrrr rrrr rrOO
*
* where:
*
* L - Opportunistic lock. 1 if lock granted, else 0.
*
* O - Open action:
* 1 - The file existed and was opened
* 2 - The file did not exist but was created
* 3 - The file existed and was truncated
*/
#define SMB_FTYPE_DISK 0
#define SMB_FTYPE_IS_PIPE(F) \
(((F) == SMB_FTYPE_BYTE_PIPE) || ((F) == SMB_FTYPE_MESG_PIPE))
/*
* TRANS2_FIND
*/
/*
* Flags for TRANS2_FIND_FIRST2 and TRANS2_FIND_NEXT2 (NTDDK).
*
* If SMB_FIND_RETURN_RESUME_KEYS was set in the request parameters,
* each entry is preceded by a four-byte resume key.
*/
/*
* TRANS2_QUERY_FS_INFORMATION
*
* SMB_QUERY_FS_QUOTA_INFO, SMB_QUERY_FS_CONTROL_INFO are not used in Windows
* NT, and are not used in any post NT Windows operating systems. If a server
* receives these information levels from a client, it should handle them as
* invalid information levels.
*/
/*
* Internal use only.
* Define information levels to represent the following requests:
* smb_query_information
* smb_query_information2
* smb_set_information
* smb_set_information2
*/
/* TRANS2_QUERY_{PATH,FILE}_INFORMATION */
/* NT passthrough levels - see ntifs.h FILE_INFORMATION_CLASS */
/* NT passthrough levels - see ntifs.h FILE_FS_INFORMATION_CLASS */
/*
* The following bits may be set in the SecurityMode field of the
* SMB_COM_NEGOTIATE response.
*
* Note: Same as the NTDDK definitions.
*/
/*
* Negotiated Capabilities (CIFS/1.0 section 4.1.1)
*
* Capabilities allow the server to tell the client what it supports.
* Undefined bits MUST be set to zero by servers, and MUST be ignored
* by clients. The bit definitions are:
*
* Capability Name Encoding Meaning
* ==================== ======== ==================================
* CAP_RAW_MODE 0x0001 The server supports SMB_COM_READ_RAW and
* SMB_COM_WRITE_RAW (obsolescent)
* CAP_MPX_MODE 0x0002 The server supports SMB_COM_READ_MPX and
* SMB_COM_WRITE_MPX (obsolescent)
* CAP_UNICODE 0x0004 The server supports Unicode strings
* CAP_LARGE_FILES 0x0008 The server supports large files with 64
* bit offsets
* CAP_NT_SMBS 0x0010 The server supports the SMBs particular
* to the NT LM 0.12 dialect.
* Implies CAP_NT_FIND.
* CAP_RPC_REMOTE_APIS 0x0020 The server supports remote admin API
* requests via DCE RPC
* CAP_STATUS32 0x0040 The server can respond with 32 bit
* status codes in Status.Status
* CAP_LEVEL_II_OPLOCKS 0x0080 The server supports level 2 oplocks
* CAP_LOCK_AND_READ 0x0100 The server supports the
* SMB_COM_LOCK_AND_READ SMB
* CAP_NT_FIND 0x0200
* CAP_BULK_TRANSFER 0x0400
* CAP_COMPRESSED_BULK 0x0800
* CAP_DFS 0x1000 The server is DFS aware
* CAP_INFOLEVEL_PASSTHRU 0x2000 The server supports passthru information
* level processing capability.
* CAP_LARGE_READX 0x4000 The server supports large
* SMB_COM_READ_ANDX
* CAP_LARGE_WRITEX 0x8000 The server supports large
* SMB_COM_WRITE_ANDX
* CAP_RESERVED 0x02000000 Reserved for future use.
* CAP_EXTENDED_SECURITY 0x80000000 The server supports extended security
* exchanges.
*
* Extended security exchanges provides a means of supporting arbitrary
* authentication protocols within CIFS. Security blobs are opaque to the
* CIFS protocol; they are messages in some authentication protocol that
* has been agreed upon by client and server by some out of band mechanism,
* for which CIFS merely functions as a transport. When
* CAP_EXTENDED_SECURITY is negotiated, the server includes a first
* security blob in its response; subsequent security blobs are exchanged
* in SMB_COM_SESSION_SETUP_ANDX requests and responses until the
* authentication protocol terminates.
*/
/*
* Different device types according to NT
*/
/*
* Some of these device types are not currently accessible over the network
* and may never be accessible over the network. Some may change to be
*
* accessible over the network. The values for device types that may never
* be accessible over the network may be redefined to be just reserved at
* some date in the future.
*
* Characteristics is the sum of any of the following:
*/
/*
* File System Control Flags for smb_com_trans2_query|set_fs_information
* level SMB_FILE_FS_CONTROL_INFORMATION
*/
/*
* CREATE_ANDX ShareAccess Flags
*/
/*
* CREATE_ANDX CreateDisposition flags
*
* FILE_SUPERSEDE If the file already exists it should be superseded
* by the specified file. If the file does not already
* exist then it should be created.
*
* FILE_CREATE If the file already exists the operation should fail.
* If the file does not already exist then it should be
* created. (aka CREATE_NEW)
*
* FILE_OPEN If the file already exists then it should be opened.
* If the file does not already exist then the operation
* should fail. (aka OPEN_EXISTING)
*
* FILE_OPEN_IF If the file already exists then it should be opened.
* If the file does not already exist then it should be
* created. (aka OPEN_ALWAYS)
*
* FILE_OVERWRITE If the file already exists, it should be opened and
* overwritten. If the file does not already exist then
* the operation should fail. (aka TRUNCATE_EXISTING)
*
* FILE_OVERWRITE_IF If the file already exists, it should be opened and
* overwritten. If the file does not already exist then
* it should be created. (aka CREATE_ALWAYS)
*/
/*
* CREATE_ANDX Impersonation levels
*/
/*
* CREATE_ANDX SecurityFlags
*/
/*
* Server types
*/
/*
* SMB_COM_NT_TRANSACTION sub-command codes (CIFS/1.0 section 5.3)
*
* SubCommand Code Value Description
* =============================== ===== =================================
* NT_TRANSACT_IOCTL 2 Device IOCTL
* NT_TRANSACT_SET_SECURITY_DESC 3 Set security descriptor
* NT_TRANSACT_NOTIFY_CHANGE 4 Start directory watch
* NT_TRANSACT_RENAME 5 Reserved (handle-based rename)
* NT_TRANSACT_QUERY_SECURITY_DESC 6 Retrieve security descriptor
* NT_TRANSACT_QUERY_QUOTA 7 Retrieve quota information
* NT_TRANSACT_SET_QUOTA 8 Set quota information
*/
/*
* Pipe states
*/
/*
* smb_com_seek request
*/
/*
* API Numbers for Transact based RAP (Remote Administration Protocol) calls
*/
#define API_WshareEnum 0
#ifdef __cplusplus
}
#endif
#endif /* _SMBSRV_SMB_H */