📄 smb.h
字号:
/* Flag for NT transact rename call. */#define RENAME_REPLACE_IF_EXISTS 1/* Filesystem Attributes. */#define FILE_CASE_SENSITIVE_SEARCH 0x1#define FILE_CASE_PRESERVED_NAMES 0x2#define FILE_UNICODE_ON_DISK 0x4#define FILE_PERSISTENT_ACLS 0x8/* ChangeNotify flags. */#define FILE_NOTIFY_CHANGE_FILE_NAME 0x001#define FILE_NOTIFY_CHANGE_DIR_NAME 0x002#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004#define FILE_NOTIFY_CHANGE_SIZE 0x008#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020#define FILE_NOTIFY_CHANGE_CREATION 0x040#define FILE_NOTIFY_CHANGE_EA 0x080#define FILE_NOTIFY_CHANGE_SECURITY 0x100/* where to find the base of the SMB packet proper */#define smb_base(buf) (((char *)(buf))+4)#define SMB_SUCCESS 0 /* The request was successful. */#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/#define ERRHRD 0x03 /* Error is an hardware error. */#define ERRCMD 0xFF /* Command was not in the "SMB" format. */#ifdef HAVE_STDARG_Hint slprintf(char *str, int n, char *format, ...)#ifdef __GNUC__ __attribute__ ((format (printf, 3, 4)))#endif;#elseint slprintf();#endif#ifdef WITH_DFSvoid dfs_unlogin(void);extern int dcelogin_atmost_once;#endif#ifdef NOSTRDUPchar *strdup(char *s);#endif#ifndef MIN#define MIN(a,b) ((a)<(b)?(a):(b))#endif#ifndef MAX#define MAX(a,b) ((a)>(b)?(a):(b))#endif#ifndef ABS#define ABS(a) ((a)>0?(a):(-(a)))#endif#ifndef SIGNAL_CAST#define SIGNAL_CAST (RETSIGTYPE (*)(int))#endif#ifndef SELECT_CAST#define SELECT_CAST#endif/* Some POSIX definitions for those without */ #ifndef S_IFDIR#define S_IFDIR 0x4000#endif#ifndef S_ISDIR#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)#endif#ifndef S_IRWXU#define S_IRWXU 00700 /* read, write, execute: owner */#endif#ifndef S_IRUSR#define S_IRUSR 00400 /* read permission: owner */#endif#ifndef S_IWUSR#define S_IWUSR 00200 /* write permission: owner */#endif#ifndef S_IXUSR#define S_IXUSR 00100 /* execute permission: owner */#endif#ifndef S_IRWXG#define S_IRWXG 00070 /* read, write, execute: group */#endif#ifndef S_IRGRP#define S_IRGRP 00040 /* read permission: group */#endif#ifndef S_IWGRP#define S_IWGRP 00020 /* write permission: group */#endif#ifndef S_IXGRP#define S_IXGRP 00010 /* execute permission: group */#endif#ifndef S_IRWXO#define S_IRWXO 00007 /* read, write, execute: other */#endif#ifndef S_IROTH#define S_IROTH 00004 /* read permission: other */#endif#ifndef S_IWOTH#define S_IWOTH 00002 /* write permission: other */#endif#ifndef S_IXOTH#define S_IXOTH 00001 /* execute permission: other */#endif/* these are used in NetServerEnum to choose what to receive */#define SV_TYPE_WORKSTATION 0x00000001#define SV_TYPE_SERVER 0x00000002#define SV_TYPE_SQLSERVER 0x00000004#define SV_TYPE_DOMAIN_CTRL 0x00000008#define SV_TYPE_DOMAIN_BAKCTRL 0x00000010#define SV_TYPE_TIME_SOURCE 0x00000020#define SV_TYPE_AFP 0x00000040#define SV_TYPE_NOVELL 0x00000080#define SV_TYPE_DOMAIN_MEMBER 0x00000100#define SV_TYPE_PRINTQ_SERVER 0x00000200#define SV_TYPE_DIALIN_SERVER 0x00000400#define SV_TYPE_SERVER_UNIX 0x00000800#define SV_TYPE_NT 0x00001000#define SV_TYPE_WFW 0x00002000#define SV_TYPE_SERVER_MFPN 0x00004000#define SV_TYPE_SERVER_NT 0x00008000#define SV_TYPE_POTENTIAL_BROWSER 0x00010000#define SV_TYPE_BACKUP_BROWSER 0x00020000#define SV_TYPE_MASTER_BROWSER 0x00040000#define SV_TYPE_DOMAIN_MASTER 0x00080000#define SV_TYPE_SERVER_OSF 0x00100000#define SV_TYPE_SERVER_VMS 0x00200000#define SV_TYPE_WIN95_PLUS 0x00400000#define SV_TYPE_ALTERNATE_XPORT 0x20000000 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000 #define SV_TYPE_DOMAIN_ENUM 0x80000000#define SV_TYPE_ALL 0xFFFFFFFF /* what server type are we currently - JHT Says we ARE 4.20 *//* this was set by JHT in liaison with Jeremy Allison early 1997 *//* setting to 4.20 at same time as announcing ourselves as NT Server *//* History: *//* Version 4.0 - never made public *//* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 *//* - Reappeared in 1.9.16p11 with fixed smbd services *//* Version 4.20 - To indicate that nmbd and browsing now works better */#define DEFAULT_MAJOR_VERSION 0x04#define DEFAULT_MINOR_VERSION 0x02/* Browser Election Values */#define BROWSER_ELECTION_VERSION 0x010f#define BROWSER_CONSTANT 0xaa55/* NT Flags2 bits - cifs6.txt section 3.1.2 */ #define FLAGS2_LONG_PATH_COMPONENTS 0x0001#define FLAGS2_EXTENDED_ATTRIBUTES 0x0002#define FLAGS2_DFS_PATHNAMES 0x1000#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000#define FLAGS2_32_BIT_ERROR_CODES 0x4000 #define FLAGS2_UNICODE_STRINGS 0x8000/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */#define CAP_RAW_MODE 0x0001#define CAP_MPX_MODE 0x0002#define CAP_UNICODE 0x0004#define CAP_LARGE_FILES 0x0008#define CAP_NT_SMBS 0x0010#define CAP_RPC_REMOTE_APIS 0x0020#define CAP_STATUS32 0x0040#define CAP_LEVEL_II_OPLOCKS 0x0080#define CAP_LOCK_AND_READ 0x0100#define CAP_NT_FIND 0x0200#define CAP_DFS 0x1000#define CAP_LARGE_READX 0x4000/* protocol types. It assumes that higher protocols include lower protocols as subsets */enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};/* security levels */enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};/* printing types */enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX, PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ};/* Remote architectures we know about. */enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};/* case handling */enum case_handling {CASE_LOWER,CASE_UPPER};#ifdef WITH_SSL/* SSL version options */enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};#endif /* WITH_SSL *//* Macros to get at offsets within smb_lkrng and smb_unlkrng structures. We cannot define these as actual structures due to possible differences in structure packing on different machines/compilers. */#define SMB_LPID_OFFSET(indx) (10 * (indx))#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx)))#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx)))#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))/* Macro to cache an error in a write_bmpx_struct */#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ w->wr_discard = True, -1)/* Macro to test if an error has been cached for this fnum */#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ (fsp)->wbmpx_ptr->wr_discard)/* Macro to turn the cached error into an error packet */#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__)/* these are the datagram types */#define DGRAM_DIRECT_UNIQUE 0x10#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)/* this is how errors are generated */#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))/* * Global value meaing that the smb_uid field should be * ingored (in share level security and protocol level == CORE) */#define UID_FIELD_INVALID 0#define VUID_OFFSET 100 /* Amount to bias returned vuid numbers *//* Defines needed for multi-codepage support. */#define MSDOS_LATIN_1_CODEPAGE 850#define KANJI_CODEPAGE 932#define HANGUL_CODEPAGE 949#define BIG5_CODEPAGE 950#define SIMPLIFIED_CHINESE_CODEPAGE 936#ifdef KANJI/* * Default client code page - Japanese */#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE#else /* KANJI *//* * Default client code page - 850 - Western European */#define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE#endif /* KANJI *//* * Size of buffer to use when moving files across filesystems. */#define COPYBUF_SIZE (8*1024)/* * Integers used to override error codes. */extern int unix_ERR_class;extern int unix_ERR_code;/* * Map the Core and Extended Oplock requesst bits down * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK). *//* * Core protocol. */#define CORE_OPLOCK_REQUEST(inbuf) \ ((CVAL(inbuf,smb_flg)&(FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK))>>5)/* * Extended protocol. */#define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)/* Lock types. */#define LOCKING_ANDX_SHARED_LOCK 0x1#define LOCKING_ANDX_OPLOCK_RELEASE 0x2#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4#define LOCKING_ANDX_CANCEL_LOCK 0x8#define LOCKING_ANDX_LARGE_FILES 0x10/* Oplock levels */#define OPLOCKLEVEL_NONE 0#define OPLOCKLEVEL_II 1/* * Bits we test with. */#define EXCLUSIVE_OPLOCK 1#define BATCH_OPLOCK 2#define CORE_OPLOCK_GRANTED (1<<5)#define EXTENDED_OPLOCK_GRANTED (1<<15)/* * Loopback command offsets. */#define OPBRK_CMD_LEN_OFFSET 0#define OPBRK_CMD_PORT_OFFSET 4#define OPBRK_CMD_HEADER_LEN 6#define OPBRK_MESSAGE_CMD_OFFSET 0/* * Oplock break command code to send over the udp socket. * * Form of this is : * * 0 2 6 10 14 14+devsize 14+devsize+inodesize * +----+--------+--------+--------+-------+--------+ * | cmd| pid | sec | usec | dev | inode | * +----+--------+--------+--------+-------+--------+ */#define OPLOCK_BREAK_CMD 0x1#define OPLOCK_BREAK_PID_OFFSET 2#define OPLOCK_BREAK_SEC_OFFSET 6#define OPLOCK_BREAK_USEC_OFFSET 10#define OPLOCK_BREAK_DEV_OFFSET 14#define OPLOCK_BREAK_INODE_OFFSET (OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))#define OPLOCK_BREAK_MSG_LEN (OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))/* * Capabilities abstracted for different systems. */#define KERNEL_OPLOCK_CAPABILITY 0x1#if defined(HAVE_KERNEL_OPLOCKS)/* * Oplock break command code sent via the kernel interface. * * Form of this is : * * 0 2 2+devsize 2+devsize+inodesize * +----+--------+--------+ * | cmd| dev | inode | * +----+--------+--------+ */#define KERNEL_OPLOCK_BREAK_CMD 0x2#define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2#define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))#define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))#endif /* HAVE_KERNEL_OPLOCKS */#define CMD_REPLY 0x8000/* useful macros *//* zero a structure */#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))/* zero a structure given a pointer to the structure - no zero check */#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))/* zero a structure given a pointer to the structure */#define ZERO_STRUCTP(x) { if ((x) != NULL) ZERO_STRUCTPN(x); }/* zero an array - note that sizeof(array) must work - ie. it must not be a pointer */#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))#define SMB_ASSERT(b) ((b)?(void)0: \ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ __FILE__, __LINE__)), smb_panic("assert failed")))#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n))#include "ntdomain.h"/* A netbios name structure. */struct nmb_name { char name[17]; char scope[64]; unsigned int name_type;};#include "client.h"#include "rpcclient.h"/* * Size of new password account encoding string. DO NOT CHANGE. */#define NEW_PW_FORMAT_SPACE_PADDED_LEN 14/* Do you want session setups at user level security with a invalid password to be rejected or allowed in as guest? WinNT rejects them but it can be a pain as it means "net view" needs to use a password You have 3 choices in the setting of map_to_guest: "NEVER_MAP_TO_GUEST" means session setups with an invalid password are rejected. This is the default. "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password are rejected, unless the username does not exist, in which case it is treated as a guest login "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password are treated as a guest login Note that map_to_guest only has an effect in user or server level security.*/#define NEVER_MAP_TO_GUEST 0#define MAP_TO_GUEST_ON_BAD_USER 1#define MAP_TO_GUEST_ON_BAD_PASSWORD 2#endif /* _SMB_H *//* _SMB_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -