interfaces.h
来自「samba最新软件」· C头文件 代码 · 共 2,736 行 · 第 1/4 页
H
2,736 行
/* Unix SMB/CIFS implementation. SMB request interface structures Copyright (C) Andrew Tridgell 2003 Copyright (C) James J Myers 2003 <myersjj@samba.org> Copyright (C) James Peach 2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.*/#ifndef __LIBCLI_RAW_INTERFACES_H__#define __LIBCLI_RAW_INTERFACES_H__#include "smb.h" #include "librpc/gen_ndr/misc.h" /* for struct GUID *//* this structure is just a wrapper for a string, the only reason we bother with this is that it allows us to check the length provided on the wire in testsuite test code to ensure that we are terminating names in the same way that win2003 is. The *ONLY* time you should ever look at the 'private_length' field in this structure is inside compliance test code, in all other cases just use the null terminated char* as the definitive definition of the string also note that this structure is only used in packets where there is an explicit length provided on the wire (hence the name). That length is placed in 'private_length'. For packets where the length is always determined by NULL or packet termination a normal char* is used in the structure definition. */struct smb_wire_string { uint32_t private_length; const char *s;};/* * SMB2 uses a 16Byte handle, * (we can maybe use struct GUID later) */struct smb2_handle { uint64_t data[2];};struct ntvfs_handle;/* * a generic container for file handles or file pathes * for qfileinfo/setfileinfo and qpathinfo/setpathinfo*/union smb_handle_or_path { /* * this is used for * the qpathinfo and setpathinfo * calls */ const char *path; /* * this is used as file handle in SMB */ uint16_t fnum; /* * this is used as file handle in SMB2 */ struct smb2_handle handle; /* * this is used as generic file handle for the NTVFS layer */ struct ntvfs_handle *ntvfs;};/* a generic container for file handles*/union smb_handle { /* * this is used as file handle in SMB */ uint16_t fnum; /* * this is used as file handle in SMB2 */ struct smb2_handle handle; /* * this is used as generic file handle for the NTVFS layer */ struct ntvfs_handle *ntvfs;};/* this header defines the structures and unions used between the SMB parser and the backends.*//* struct used for SMBlseek call */union smb_seek { struct { struct { union smb_handle file; uint16_t mode; int32_t offset; /* signed */ } in; struct { int32_t offset; } out; } lseek, generic;};/* struct used in unlink() call */union smb_unlink { struct { struct { const char *pattern; uint16_t attrib; } in; } unlink;};/* struct used in chkpath() call */union smb_chkpath { struct { struct { const char *path; } in; } chkpath;};enum smb_mkdir_level {RAW_MKDIR_GENERIC, RAW_MKDIR_MKDIR, RAW_MKDIR_T2MKDIR};/* union used in mkdir() call */union smb_mkdir { /* generic level */ struct { enum smb_mkdir_level level; } generic; struct { enum smb_mkdir_level level; struct { const char *path; } in; } mkdir; struct { enum smb_mkdir_level level; struct { const char *path; uint_t num_eas; struct ea_struct *eas; } in; } t2mkdir;};/* struct used in rmdir() call */struct smb_rmdir { struct { const char *path; } in;};/* struct used in rename() call */enum smb_rename_level {RAW_RENAME_RENAME, RAW_RENAME_NTRENAME, RAW_RENAME_NTTRANS};union smb_rename { struct { enum smb_rename_level level; } generic; /* SMBrename interface */ struct { enum smb_rename_level level; struct { const char *pattern1; const char *pattern2; uint16_t attrib; } in; } rename; /* SMBntrename interface */ struct { enum smb_rename_level level; struct { uint16_t attrib; uint16_t flags; /* see RENAME_FLAG_* */ uint32_t cluster_size; const char *old_name; const char *new_name; } in; } ntrename; /* NT TRANS rename interface */ struct { enum smb_rename_level level; struct { union smb_handle file; uint16_t flags;/* see RENAME_REPLACE_IF_EXISTS */ const char *new_name; } in; } nttrans;};enum smb_tcon_level { RAW_TCON_TCON, RAW_TCON_TCONX, RAW_TCON_SMB2};/* union used in tree connect call */union smb_tcon { /* generic interface */ struct { enum smb_tcon_level level; } generic; /* SMBtcon interface */ struct { enum smb_tcon_level level; struct { const char *service; const char *password; const char *dev; } in; struct { uint16_t max_xmit; uint16_t tid; } out; } tcon; /* SMBtconX interface */ struct { enum smb_tcon_level level; struct { uint16_t flags; DATA_BLOB password; const char *path; const char *device; } in; struct { uint16_t options; char *dev_type; char *fs_type; uint16_t tid; } out; } tconx; /* SMB2 TreeConnect */ struct smb2_tree_connect { enum smb_tcon_level level; struct { /* static body buffer 8 (0x08) bytes */ uint16_t reserved; /* uint16_t path_ofs */ /* uint16_t path_size */ /* dynamic body */ const char *path; /* as non-terminated UTF-16 on the wire */ } in; struct { /* static body buffer 16 (0x10) bytes */ /* uint16_t buffer_code; 0x10 */ uint8_t share_type; uint8_t reserved; uint32_t flags; uint32_t capabilities; uint32_t access_mask; /* extracted from the SMB2 header */ uint32_t tid; } out; } smb2;};enum smb_sesssetup_level { RAW_SESSSETUP_OLD, RAW_SESSSETUP_NT1, RAW_SESSSETUP_SPNEGO, RAW_SESSSETUP_SMB2};/* union used in session_setup call */union smb_sesssetup { /* the pre-NT1 interface */ struct { enum smb_sesssetup_level level; struct { uint16_t bufsize; uint16_t mpx_max; uint16_t vc_num; uint32_t sesskey; DATA_BLOB password; const char *user; const char *domain; const char *os; const char *lanman; } in; struct { uint16_t action; uint16_t vuid; char *os; char *lanman; char *domain; } out; } old; /* the NT1 interface */ struct { enum smb_sesssetup_level level; struct { uint16_t bufsize; uint16_t mpx_max; uint16_t vc_num; uint32_t sesskey; uint32_t capabilities; DATA_BLOB password1; DATA_BLOB password2; const char *user; const char *domain; const char *os; const char *lanman; } in; struct { uint16_t action; uint16_t vuid; char *os; char *lanman; char *domain; } out; } nt1; /* the SPNEGO interface */ struct { enum smb_sesssetup_level level; struct { uint16_t bufsize; uint16_t mpx_max; uint16_t vc_num; uint32_t sesskey; uint32_t capabilities; DATA_BLOB secblob; const char *os; const char *lanman; const char *workgroup; } in; struct { uint16_t action; DATA_BLOB secblob; char *os; char *lanman; char *workgroup; uint16_t vuid; } out; } spnego; /* SMB2 SessionSetup */ struct smb2_session_setup { enum smb_sesssetup_level level; struct { /* static body 24 (0x18) bytes */ uint8_t vc_number; uint8_t security_mode; uint32_t capabilities; uint32_t channel; /* uint16_t secblob_ofs */ /* uint16_t secblob_size */ uint64_t previous_sessionid; /* dynamic body */ DATA_BLOB secblob; } in; struct { /* body buffer 8 (0x08) bytes */ uint16_t session_flags; /* uint16_t secblob_ofs */ /* uint16_t secblob_size */ /* dynamic body */ DATA_BLOB secblob; /* extracted from the SMB2 header */ uint64_t uid; } out; } smb2;};/* Note that the specified enum values are identical to the actual info-levels used * on the wire. */enum smb_fileinfo_level { RAW_FILEINFO_GENERIC = 0xF000, RAW_FILEINFO_GETATTR, /* SMBgetatr */ RAW_FILEINFO_GETATTRE, /* SMBgetattrE */ RAW_FILEINFO_SEC_DESC, /* NT_TRANSACT_QUERY_SECURITY_DESC */ RAW_FILEINFO_STANDARD = SMB_QFILEINFO_STANDARD, RAW_FILEINFO_EA_SIZE = SMB_QFILEINFO_EA_SIZE, RAW_FILEINFO_EA_LIST = SMB_QFILEINFO_EA_LIST, RAW_FILEINFO_ALL_EAS = SMB_QFILEINFO_ALL_EAS, RAW_FILEINFO_IS_NAME_VALID = SMB_QFILEINFO_IS_NAME_VALID, RAW_FILEINFO_BASIC_INFO = SMB_QFILEINFO_BASIC_INFO, RAW_FILEINFO_STANDARD_INFO = SMB_QFILEINFO_STANDARD_INFO, RAW_FILEINFO_EA_INFO = SMB_QFILEINFO_EA_INFO, RAW_FILEINFO_NAME_INFO = SMB_QFILEINFO_NAME_INFO, RAW_FILEINFO_ALL_INFO = SMB_QFILEINFO_ALL_INFO, RAW_FILEINFO_ALT_NAME_INFO = SMB_QFILEINFO_ALT_NAME_INFO, RAW_FILEINFO_STREAM_INFO = SMB_QFILEINFO_STREAM_INFO, RAW_FILEINFO_COMPRESSION_INFO = SMB_QFILEINFO_COMPRESSION_INFO, RAW_FILEINFO_UNIX_BASIC = SMB_QFILEINFO_UNIX_BASIC, RAW_FILEINFO_UNIX_INFO2 = SMB_QFILEINFO_UNIX_INFO2, RAW_FILEINFO_UNIX_LINK = SMB_QFILEINFO_UNIX_LINK, RAW_FILEINFO_BASIC_INFORMATION = SMB_QFILEINFO_BASIC_INFORMATION, RAW_FILEINFO_STANDARD_INFORMATION = SMB_QFILEINFO_STANDARD_INFORMATION, RAW_FILEINFO_INTERNAL_INFORMATION = SMB_QFILEINFO_INTERNAL_INFORMATION, RAW_FILEINFO_EA_INFORMATION = SMB_QFILEINFO_EA_INFORMATION, RAW_FILEINFO_ACCESS_INFORMATION = SMB_QFILEINFO_ACCESS_INFORMATION, RAW_FILEINFO_NAME_INFORMATION = SMB_QFILEINFO_NAME_INFORMATION, RAW_FILEINFO_POSITION_INFORMATION = SMB_QFILEINFO_POSITION_INFORMATION, RAW_FILEINFO_MODE_INFORMATION = SMB_QFILEINFO_MODE_INFORMATION, RAW_FILEINFO_ALIGNMENT_INFORMATION = SMB_QFILEINFO_ALIGNMENT_INFORMATION, RAW_FILEINFO_ALL_INFORMATION = SMB_QFILEINFO_ALL_INFORMATION, RAW_FILEINFO_ALT_NAME_INFORMATION = SMB_QFILEINFO_ALT_NAME_INFORMATION, RAW_FILEINFO_STREAM_INFORMATION = SMB_QFILEINFO_STREAM_INFORMATION, RAW_FILEINFO_COMPRESSION_INFORMATION = SMB_QFILEINFO_COMPRESSION_INFORMATION, RAW_FILEINFO_NETWORK_OPEN_INFORMATION = SMB_QFILEINFO_NETWORK_OPEN_INFORMATION, RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION = SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION, /* SMB2 specific levels */ RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01, RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201};/* union used in qfileinfo() and qpathinfo() backend calls */union smb_fileinfo { /* generic interface: * matches RAW_FILEINFO_GENERIC */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { uint32_t attrib; uint32_t ea_size; uint_t num_eas; struct ea_struct { uint8_t flags; struct smb_wire_string name; DATA_BLOB value; } *eas; NTTIME create_time; NTTIME access_time; NTTIME write_time; NTTIME change_time; uint64_t alloc_size; uint64_t size; uint32_t nlink; struct smb_wire_string fname; struct smb_wire_string alt_fname; uint8_t delete_pending; uint8_t directory; uint64_t compressed_size; uint16_t format; uint8_t unit_shift; uint8_t chunk_shift; uint8_t cluster_shift; uint64_t file_id; uint32_t access_flags; /* seen 0x001f01ff from w2k3 */ uint64_t position; uint32_t mode; uint32_t alignment_requirement; uint32_t reparse_tag; uint_t num_streams; struct stream_struct { uint64_t size; uint64_t alloc_size; struct smb_wire_string stream_name; } *streams; } out; } generic; /* SMBgetatr interface: * matches RAW_FILEINFO_GETATTR */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { uint16_t attrib; uint32_t size; time_t write_time; } out; } getattr; /* SMBgetattrE and RAW_FILEINFO_STANDARD interface */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { time_t create_time; time_t access_time; time_t write_time; uint32_t size; uint32_t alloc_size; uint16_t attrib; } out; } getattre, standard; /* trans2 RAW_FILEINFO_EA_SIZE interface */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { time_t create_time; time_t access_time; time_t write_time; uint32_t size; uint32_t alloc_size; uint16_t attrib; uint32_t ea_size; } out; } ea_size; /* trans2 RAW_FILEINFO_EA_LIST interface */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; uint_t num_names; struct ea_name { struct smb_wire_string name; } *ea_names; } in; struct smb_ea_list { uint_t num_eas; struct ea_struct *eas; } out; } ea_list; /* trans2 RAW_FILEINFO_ALL_EAS and RAW_FILEINFO_FULL_EA_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; /* SMB2 only - SMB2_CONTINUE_FLAG_* */ uint8_t continue_flags; } in; struct smb_ea_list out; } all_eas; /* trans2 qpathinfo RAW_FILEINFO_IS_NAME_VALID interface only valid for a QPATHNAME call - no returned data */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; } is_name_valid; /* RAW_FILEINFO_BASIC_INFO and RAW_FILEINFO_BASIC_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { NTTIME create_time; NTTIME access_time; NTTIME write_time; NTTIME change_time; uint32_t attrib; } out; } basic_info; /* RAW_FILEINFO_STANDARD_INFO and RAW_FILEINFO_STANDARD_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { uint64_t alloc_size; uint64_t size; uint32_t nlink; bool delete_pending; bool directory; } out; } standard_info; /* RAW_FILEINFO_EA_INFO and RAW_FILEINFO_EA_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { uint32_t ea_size; } out; } ea_info; /* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { struct smb_wire_string fname; } out; } name_info; /* RAW_FILEINFO_ALL_INFO and RAW_FILEINFO_ALL_INFORMATION interfaces */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { NTTIME create_time; NTTIME access_time; NTTIME write_time; NTTIME change_time; uint32_t attrib; uint64_t alloc_size; uint64_t size; uint32_t nlink; uint8_t delete_pending; uint8_t directory; uint32_t ea_size; struct smb_wire_string fname; } out; } all_info; /* RAW_FILEINFO_SMB2_ALL_INFORMATION interface */ struct { enum smb_fileinfo_level level; struct { union smb_handle_or_path file; } in; struct { NTTIME create_time; NTTIME access_time; NTTIME write_time; NTTIME change_time; uint32_t attrib; uint32_t unknown1; uint64_t alloc_size; uint64_t size; uint32_t nlink; uint8_t delete_pending; uint8_t directory; /* uint16_t _pad; */ uint64_t file_id; uint32_t ea_size;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?