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
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifndef __LIBCLI_RAW_INTERFACES_H__
+#define __LIBCLI_RAW_INTERFACES_H__
+
+#include "smb.h"
+
/* 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
uint64_t data[2];
};
+struct ntvfs_handle;
+
/*
* a generic container for file handles or file pathes
* for qfileinfo/setfileinfo and qpathinfo/setpathinfo
* 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 for
- * the qpathinfo and setpathinfo
- * calls
- */
- const char *path;
/*
* this is used as file handle in SMB
*/
* 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;
};
/*
struct {
int32_t offset;
} out;
- } lseek;
+ } lseek, generic;
};
/* struct used in unlink() call */
} ntrename;
};
-enum smb_tcon_level {RAW_TCON_TCON, RAW_TCON_TCONX};
+enum smb_tcon_level {
+ RAW_TCON_TCON,
+ RAW_TCON_TCONX,
+ RAW_TCON_SMB2
+};
/* union used in tree connect call */
union smb_tcon {
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 buffer_code; 0x09 = 0x08 + 1 */
+ uint16_t unknown1; /* 0x0000 */
+ /* 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 */
+ uint16_t unknown1; /* 0x02 */
+ uint32_t unknown2; /* 0x00 */
+ uint32_t unknown3; /* 0x00 */
+ 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};
+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 {
uint16_t vuid;
} out;
} spnego;
+
+ /* SMB2 SessionSetup */
+ struct smb2_session_setup {
+ enum smb_sesssetup_level level;
+
+ struct {
+ /* NOTE: this was 0x11 = 0x10 + 1 in vista-CTP
+ * and changed in vista-beta2, but both server's
+ * can handle the 0x18 clients
+ */
+ /* static body buffer 24 (0x18) bytes */
+ /* uint16_t buffer_code; 0x19 = 0x18 + 1 */
+ uint16_t _pad;
+ uint32_t unknown2; /* 0x0000000F(vista-CTP) 0x00000007(vista-beta2) */
+ uint32_t unknown3; /* 0x0000000 */
+ /* uint16_t secblob_ofs */
+ /* uint16_t secblob_size */
+ uint64_t unknown4; /* 0x0000000000000000 only present in vista-beta2 */
+
+ /* dynamic body */
+ DATA_BLOB secblob;
+ } in;
+ struct {
+ /* static body buffer 8 (0x08) bytes */
+ /* uint16_t buffer_code; 0x09 = 0x08 +1 */
+ uint16_t _pad;
+ /* 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
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,
} out;
} unix_basic_info;
+ /* RAW_FILEINFO_UNIX_INFO2 interface */
+ struct {
+ enum smb_fileinfo_level level;
+ struct {
+ union smb_handle_or_path file;
+ } in;
+ struct {
+ uint64_t end_of_file;
+ uint64_t num_bytes;
+ NTTIME status_change_time;
+ NTTIME access_time;
+ NTTIME change_time;
+ uint64_t uid;
+ uint64_t gid;
+ uint32_t file_type;
+ uint64_t dev_major;
+ uint64_t dev_minor;
+ uint64_t unique_id;
+ uint64_t permissions;
+ uint64_t nlink;
+ NTTIME create_time;
+ uint32_t file_flags;
+ uint32_t flags_mask;
+ } out;
+ } unix_info2;
+
/* RAW_FILEINFO_UNIX_LINK interface */
struct {
enum smb_fileinfo_level level;
RAW_SFILEINFO_ALLOCATION_INFO = SMB_SFILEINFO_ALLOCATION_INFO,
RAW_SFILEINFO_END_OF_FILE_INFO = SMB_SFILEINFO_END_OF_FILE_INFO,
RAW_SFILEINFO_UNIX_BASIC = SMB_SFILEINFO_UNIX_BASIC,
+ RAW_SFILEINFO_UNIX_INFO2 = SMB_SFILEINFO_UNIX_INFO2,
RAW_SFILEINFO_UNIX_LINK = SMB_SFILEINFO_UNIX_LINK,
RAW_SFILEINFO_UNIX_HLINK = SMB_SFILEINFO_UNIX_HLINK,
RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION,
} in;
} mode_information;
-
-
/* RAW_SFILEINFO_UNIX_BASIC interface */
struct {
enum smb_setfileinfo_level level;
uint64_t nlink;
} in;
} unix_basic;
-
+
+ /* RAW_SFILEINFO_UNIX_INFO2 interface */
+ struct {
+ enum smb_setfileinfo_level level;
+ struct {
+ union smb_handle_or_path file;
+ uint64_t end_of_file;
+ uint64_t num_bytes;
+ NTTIME status_change_time;
+ NTTIME access_time;
+ NTTIME change_time;
+ uint64_t uid;
+ uint64_t gid;
+ uint32_t file_type;
+ uint64_t dev_major;
+ uint64_t dev_minor;
+ uint64_t unique_id;
+ uint64_t permissions;
+ uint64_t nlink;
+ NTTIME create_time;
+ uint32_t file_flags;
+ uint32_t flags_mask;
+ } in;
+ } unix_info2;
+
/* RAW_SFILEINFO_UNIX_LINK, RAW_SFILEINFO_UNIX_HLINK interface */
struct {
enum smb_setfileinfo_level level;
enum smb_open_level {
- RAW_OPEN_OPEN, RAW_OPEN_OPENX,
- RAW_OPEN_MKNEW, RAW_OPEN_CREATE,
- RAW_OPEN_CTEMP, RAW_OPEN_SPLOPEN,
- RAW_OPEN_NTCREATEX, RAW_OPEN_T2OPEN,
- RAW_OPEN_NTTRANS_CREATE,
- RAW_OPEN_OPENX_READX};
+ RAW_OPEN_OPEN,
+ RAW_OPEN_OPENX,
+ RAW_OPEN_MKNEW,
+ RAW_OPEN_CREATE,
+ RAW_OPEN_CTEMP,
+ RAW_OPEN_SPLOPEN,
+ RAW_OPEN_NTCREATEX,
+ RAW_OPEN_T2OPEN,
+ RAW_OPEN_NTTRANS_CREATE,
+ RAW_OPEN_OPENX_READX,
+ RAW_OPEN_SMB2
+};
/* the generic interface is defined to be equal to the NTCREATEX interface */
#define RAW_OPEN_GENERIC RAW_OPEN_NTCREATEX
/* union for open() backend call */
union smb_open {
+/*
+ * because the *.out.file structs are not aligned to the same offset for each level
+ * we provide a hepler macro that should be used to find the current smb_handle structure
+ */
+#define SMB_OPEN_OUT_FILE(op, file) do { \
+ switch (op->generic.level) { \
+ case RAW_OPEN_OPEN: \
+ file = &op->openold.out.file; \
+ break; \
+ case RAW_OPEN_OPENX: \
+ file = &op->openx.out.file; \
+ break; \
+ case RAW_OPEN_MKNEW: \
+ file = &op->mknew.out.file; \
+ break; \
+ case RAW_OPEN_CREATE: \
+ file = &op->create.out.file; \
+ break; \
+ case RAW_OPEN_CTEMP: \
+ file = &op->ctemp.out.file; \
+ break; \
+ case RAW_OPEN_SPLOPEN: \
+ file = &op->splopen.out.file; \
+ break; \
+ case RAW_OPEN_NTCREATEX: \
+ file = &op->ntcreatex.out.file; \
+ break; \
+ case RAW_OPEN_T2OPEN: \
+ file = &op->t2open.out.file; \
+ break; \
+ case RAW_OPEN_NTTRANS_CREATE: \
+ file = &op->nttrans.out.file; \
+ break; \
+ case RAW_OPEN_OPENX_READX: \
+ file = &op->openxreadx.out.file; \
+ break; \
+ case RAW_OPEN_SMB2: \
+ file = &op->smb2.out.file; \
+ break; \
+ default: \
+ /* this must be a programmer error */ \
+ file = NULL; \
+ break; \
+ } \
+} while (0)
/* SMBNTCreateX interface */
struct {
enum smb_open_level level;
uint16_t ipc_state;
uint8_t is_directory;
} out;
- } ntcreatex, generic;
+ } ntcreatex, nttrans, generic;
/* TRANS2_OPEN interface */
struct {
uint16_t nread;
} out;
} openxreadx;
+
+#define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100
+#define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800
+#define SMB2_CREATE_FLAG_GRANT_OPLOCK 0x0001
+#define SMB2_CREATE_FLAG_GRANT_EXCLUSIVE_OPLOCK 0x0080
+
+ /* SMB2 Create */
+ struct smb2_create {
+ enum smb_open_level level;
+ struct {
+ /* static body buffer 56 (0x38) bytes */
+ /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
+ uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
+ uint32_t impersonation;
+ uint32_t unknown3[4];
+ uint32_t access_mask;
+
+ uint32_t file_attr;
+ uint32_t share_access;
+ uint32_t open_disposition;
+ uint32_t create_options;
+
+ /* uint16_t fname_ofs */
+ /* uint16_t fname_size */
+ /* uint32_t blob_ofs; */
+ /* uint32_t blob_size; */
+
+ /* dynamic body */
+ const char *fname;
+
+ /* optional list of extended attributes */
+ struct smb_ea_list eas;
+ } in;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 88 (0x58) bytes */
+ /* uint16_t buffer_code; 0x59 = 0x58 + 1 */
+ uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
+ uint32_t create_action;
+ NTTIME create_time;
+ NTTIME access_time;
+ NTTIME write_time;
+ NTTIME change_time;
+ uint64_t alloc_size;
+ uint64_t size;
+ uint32_t file_attr;
+ uint32_t _pad;
+ /* struct smb2_handle handle;*/
+ /* uint32_t blob_ofs; */
+ /* uint32_t blob_size; */
+
+ /* dynamic body */
+ DATA_BLOB blob;
+ } out;
+ } smb2;
};
-enum smb_read_level {RAW_READ_READBRAW, RAW_READ_LOCKREAD, RAW_READ_READ, RAW_READ_READX};
+enum smb_read_level {
+ RAW_READ_READBRAW,
+ RAW_READ_LOCKREAD,
+ RAW_READ_READ,
+ RAW_READ_READX,
+ RAW_READ_SMB2
+};
#define RAW_READ_GENERIC RAW_READ_READX
uint8_t *data;
uint16_t remaining;
uint16_t compaction_mode;
- uint16_t nread;
+ uint32_t nread;
} out;
} readx, generic;
uint16_t nread;
} out;
} read;
+
+ /* SMB2 Read */
+ struct smb2_read {
+ enum smb_read_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 48 (0x30) bytes */
+ /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
+ uint16_t _pad;
+ uint32_t length;
+ uint64_t offset;
+ /* struct smb2_handle handle; */
+ uint64_t unknown1; /* 0x0000000000000000 */
+ uint64_t unknown2; /* 0x0000000000000000 */
+ } in;
+ struct {
+ /* static body buffer 16 (0x10) bytes */
+ /* uint16_t buffer_code; 0x11 = 0x10 + 1 */
+ /* uint16_t data_ofs; */
+ /* uint32_t data_size; */
+ uint64_t unknown1; /* 0x0000000000000000 */
+
+ /* dynamic body */
+ DATA_BLOB data;
+ } out;
+ } smb2;
};
-enum smb_write_level {RAW_WRITE_WRITEUNLOCK, RAW_WRITE_WRITE,
- RAW_WRITE_WRITEX, RAW_WRITE_WRITECLOSE,
- RAW_WRITE_SPLWRITE};
+enum smb_write_level {
+ RAW_WRITE_WRITEUNLOCK,
+ RAW_WRITE_WRITE,
+ RAW_WRITE_WRITEX,
+ RAW_WRITE_WRITECLOSE,
+ RAW_WRITE_SPLWRITE,
+ RAW_WRITE_SMB2
+};
#define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
const uint8_t *data;
} in;
} splwrite;
+
+ /* SMB2 Write */
+ struct smb2_write {
+ enum smb_write_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 48 (0x30) bytes */
+ /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
+ /* uint16_t data_ofs; */
+ /* uint32_t data_size; */
+ uint64_t offset;
+ /* struct smb2_handle handle; */
+ uint64_t unknown1; /* 0xFFFFFFFFFFFFFFFF */
+ uint64_t unknown2; /* 0xFFFFFFFFFFFFFFFF */
+
+ /* dynamic body */
+ DATA_BLOB data;
+ } in;
+ struct {
+ /* static body buffer 17 (0x11) bytes */
+ /* uint16_t buffer_code; 0x11 = 0x10 + 1*/
+ uint16_t _pad;
+ uint32_t nwritten;
+ uint64_t unknown1; /* 0x0000000000000000 */
+ } out;
+ } smb2;
};
-enum smb_lock_level {RAW_LOCK_LOCK, RAW_LOCK_UNLOCK, RAW_LOCK_LOCKX};
+enum smb_lock_level {
+ RAW_LOCK_LOCK,
+ RAW_LOCK_UNLOCK,
+ RAW_LOCK_LOCKX,
+ RAW_LOCK_SMB2
+};
/* the generic interface is defined to be equal to the lockingX interface */
#define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
uint32_t offset;
} in;
} lock, unlock;
+
+ /* SMB2 Lock */
+ struct smb2_lock {
+ enum smb_lock_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 48 (0x30) bytes */
+ /* uint16_t buffer_code; 0x30 */
+ uint16_t unknown1; /* must be 0x0001 */
+ uint32_t unknown2;
+ /* struct smb2_handle handle; */
+ uint64_t offset;
+ uint64_t count;
+ uint32_t unknown5;
+#define SMB2_LOCK_FLAG_NONE 0x00000000
+#define SMB2_LOCK_FLAG_SHARED 0x00000001
+#define SMB2_LOCK_FLAG_EXCLUSIV 0x00000002
+#define SMB2_LOCK_FLAG_UNLOCK 0x00000004
+#define SMB2_LOCK_FLAG_NO_PENDING 0x00000010
+ uint32_t flags;
+ } in;
+ struct {
+ /* static body buffer 4 (0x04) bytes */
+ /* uint16_t buffer_code; 0x04 */
+ uint16_t unknown1;
+ } out;
+ } smb2;
};
-enum smb_close_level {RAW_CLOSE_CLOSE, RAW_CLOSE_SPLCLOSE};
+enum smb_close_level {
+ RAW_CLOSE_CLOSE,
+ RAW_CLOSE_SPLCLOSE,
+ RAW_CLOSE_SMB2
+};
#define RAW_CLOSE_GENERIC RAW_CLOSE_CLOSE
union smb_handle file;
} in;
} splclose;
+
+ /* SMB2 Close */
+ struct smb2_close {
+ enum smb_close_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 24 (0x18) bytes */
+ /* uint16_t buffer_code; 0x18 */
+#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
+ uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
+ uint32_t _pad;
+ } in;
+ struct {
+ /* static body buffer 60 (0x3C) bytes */
+ /* uint16_t buffer_code; 0x3C */
+ uint16_t flags;
+ uint32_t _pad;
+ NTTIME create_time;
+ NTTIME access_time;
+ NTTIME write_time;
+ NTTIME change_time;
+ uint64_t alloc_size;
+ uint64_t size;
+ uint32_t file_attr;
+ } out;
+ } smb2;
};
} retq;
};
-enum smb_ioctl_level {RAW_IOCTL_IOCTL, RAW_IOCTL_NTIOCTL};
+enum smb_ioctl_level {
+ RAW_IOCTL_IOCTL,
+ RAW_IOCTL_NTIOCTL,
+ RAW_IOCTL_SMB2,
+ RAW_IOCTL_SMB2_NO_HANDLE
+};
/*
union for ioctl() backend
uint32_t function;
BOOL fsctl;
uint8_t filter;
+ uint32_t max_data;
+ DATA_BLOB blob;
} in;
struct {
DATA_BLOB blob;
} out;
} ntioctl;
+
+ /* SMB2 Ioctl */
+ struct smb2_ioctl {
+ enum smb_ioctl_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 56 (0x38) bytes */
+ /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
+ uint16_t _pad;
+ uint32_t function;
+ /*struct smb2_handle handle;*/
+ /* uint32_t out_ofs; */
+ /* uint32_t out_size; */
+ uint32_t unknown2;
+ /* uint32_t in_ofs; */
+ /* uint32_t in_size; */
+ uint32_t max_response_size;
+ uint64_t flags;
+
+ /* dynamic body */
+ DATA_BLOB out;
+ DATA_BLOB in;
+ } in;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 48 (0x30) bytes */
+ /* uint16_t buffer_code; 0x31 = 0x30 + 1 */
+ uint16_t _pad;
+ uint32_t function;
+ /* struct smb2_handle handle; */
+ /* uint32_t in_ofs; */
+ /* uint32_t in_size; */
+ /* uint32_t out_ofs; */
+ /* uint32_t out_size; */
+ uint32_t unknown2;
+ uint32_t unknown3;
+
+ /* dynamic body */
+ DATA_BLOB in;
+ DATA_BLOB out;
+ } out;
+ } smb2;
+};
+
+enum smb_flush_level {
+ RAW_FLUSH_FLUSH,
+ RAW_FLUSH_ALL,
+ RAW_FLUSH_SMB2
};
-/* struct for SMBflush */
union smb_flush {
+ /* struct for SMBflush */
struct {
+ enum smb_flush_level level;
struct {
union smb_handle file;
} in;
- } flush;
-};
+ } flush, generic;
+
+ /* SMBflush with 0xFFFF wildcard fnum */
+ struct {
+ enum smb_flush_level level;
+ } flush_all;
+ /* SMB2 Flush */
+ struct smb2_flush {
+ enum smb_flush_level level;
+ struct {
+ union smb_handle file;
+ uint32_t unknown;
+ } in;
+ } smb2;
+};
/* struct for SMBcopy */
struct smb_copy {
uint32_t max_data;
uint32_t setup_count;
uint16_t function;
- uint16_t *setup;
+ uint8_t *setup;
DATA_BLOB params;
DATA_BLOB data;
} in;
struct {
- uint8_t setup_count;
- uint16_t *setup;
+ uint8_t setup_count; /* in units of 16 bit words */
+ uint8_t *setup;
DATA_BLOB params;
DATA_BLOB data;
} out;
};
+enum smb_notify_level {
+ RAW_NOTIFY_NTTRANS,
+ RAW_NOTIFY_SMB2
+};
-/* struct for nttrans change notify call */
union smb_notify {
+ /* struct for nttrans change notify call */
struct {
+ enum smb_notify_level level;
+
struct {
union smb_handle file;
uint32_t buffer_size;
struct smb_wire_string name;
} *changes;
} out;
- } notify;
+ } nttrans;
+
+ struct smb2_notify {
+ enum smb_notify_level level;
+
+ struct {
+ union smb_handle file;
+ /* static body buffer 32 (0x20) bytes */
+ /* uint16_t buffer_code; 0x32 */
+ uint16_t recursive;
+ uint32_t buffer_size;
+ /*struct smb2_handle file;*/
+ uint32_t completion_filter;
+ uint32_t unknown;
+ } in;
+
+ struct {
+ /* static body buffer 8 (0x08) bytes */
+ /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
+ /* uint16_t blob_ofs; */
+ /* uint16_t blob_size; */
+
+ /* dynamic body */
+ /*DATA_BLOB blob;*/
+
+ /* DATA_BLOB content */
+ uint32_t num_changes;
+ struct notify_changes *changes;
+ } out;
+ } smb2;
};
-enum smb_search_level {RAW_SEARCH_GENERIC = 0xF000,
- RAW_SEARCH_SEARCH, /* SMBsearch */
- RAW_SEARCH_FFIRST, /* SMBffirst */
- RAW_SEARCH_FUNIQUE, /* SMBfunique */
- RAW_SEARCH_STANDARD = SMB_FIND_STANDARD,
- RAW_SEARCH_EA_SIZE = SMB_FIND_EA_SIZE,
- RAW_SEARCH_EA_LIST = SMB_FIND_EA_LIST,
- RAW_SEARCH_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
- RAW_SEARCH_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
- RAW_SEARCH_NAME_INFO = SMB_FIND_NAME_INFO,
- RAW_SEARCH_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
- RAW_SEARCH_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
- RAW_SEARCH_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
- RAW_SEARCH_UNIX_INFO = SMB_FIND_UNIX_INFO};
+enum smb_search_level {
+ RAW_SEARCH_SEARCH, /* SMBsearch */
+ RAW_SEARCH_FFIRST, /* SMBffirst */
+ RAW_SEARCH_FUNIQUE, /* SMBfunique */
+ RAW_SEARCH_TRANS2, /* SMBtrans2 */
+ RAW_SEARCH_SMB2 /* SMB2 Find */
+};
+enum smb_search_data_level {
+ RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
+ RAW_SEARCH_DATA_SEARCH,
+ RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
+ RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
+ RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
+ RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
+ RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO,
+ RAW_SEARCH_DATA_UNIX_INFO2 = SMB_FIND_UNIX_INFO2
+};
/* union for file search */
union smb_search_first {
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
} generic;
/* search (old) findfirst interface.
Also used for ffirst and funique. */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t max_count;
/* trans2 findfirst interface */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t search_attrib;
uint16_t end_of_search;
} out;
} t2ffirst;
+
+/*
+ SMB2 uses different level numbers for the same old SMB trans2 search levels
+*/
+#define SMB2_FIND_DIRECTORY_INFO 0x01
+#define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
+#define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
+#define SMB2_FIND_NAME_INFO 0x0C
+#define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
+#define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
+
+/* flags for RAW_FILEINFO_SMB2_ALL_EAS */
+#define SMB2_CONTINUE_FLAG_RESTART 0x01
+#define SMB2_CONTINUE_FLAG_SINGLE 0x02
+#define SMB2_CONTINUE_FLAG_NEW 0x10
+
+ /* SMB2 Find */
+ struct smb2_find {
+ enum smb_search_level level;
+ enum smb_search_data_level data_level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 32 (0x20) bytes */
+ /* uint16_t buffer_code; 0x21 = 0x20 + 1 */
+ uint8_t level;
+ uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
+ uint32_t unknown; /* perhaps a continue token? */
+ /* struct smb2_handle handle; */
+ /* uint16_t pattern_ofs; */
+ /* uint16_t pattern_size; */
+ uint32_t max_response_size;
+
+ /* dynamic body */
+ const char *pattern;
+ } in;
+ struct {
+ /* static body buffer 8 (0x08) bytes */
+ /* uint16_t buffer_code; 0x08 */
+ /* uint16_t blob_ofs; */
+ /* uint32_t blob_size; */
+
+ /* dynamic body */
+ DATA_BLOB blob;
+ } out;
+ } smb2;
};
/* union for file search continue */
union smb_search_next {
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
} generic;
/* search (old) findnext interface. Also used
for ffirst when continuing */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t max_count;
/* trans2 findnext interface */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t handle;
uint16_t end_of_search;
} out;
} t2fnext;
+
+ /* SMB2 Find */
+ struct smb2_find smb2;
};
/* union for search reply file data */
union smb_search_data {
- /* search (old) findfirst */
+ /*
+ * search (old) findfirst
+ * RAW_SEARCH_DATA_SEARCH
+ */
struct {
uint16_t attrib;
time_t write_time;
struct smb_search_id id;
const char *name;
} search;
-
- /* trans2 findfirst RAW_SEARCH_STANDARD level */
+
+ /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
struct {
uint32_t resume_key;
time_t create_time;
struct smb_wire_string name;
} standard;
- /* trans2 findfirst RAW_SEARCH_EA_SIZE level */
+ /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
struct {
uint32_t resume_key;
time_t create_time;
struct smb_wire_string name;
} ea_size;
- /* trans2 findfirst RAW_SEARCH_EA_LIST level */
+ /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
struct {
uint32_t resume_key;
time_t create_time;
struct smb_wire_string name;
} ea_list;
- /* RAW_SEARCH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
struct smb_wire_string name;
} directory_info;
- /* RAW_SEARCH_FULL_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
struct smb_wire_string name;
} full_directory_info;
- /* RAW_SEARCH_NAME_INFO interface */
+ /* RAW_SEARCH_DATA_NAME_INFO interface */
struct {
uint32_t file_index;
struct smb_wire_string name;
} name_info;
- /* RAW_SEARCH_BOTH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
struct smb_wire_string name;
} both_directory_info;
- /* RAW_SEARCH_ID_FULL_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
struct smb_wire_string name;
} id_full_directory_info;
- /* RAW_SEARCH_ID_BOTH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
struct smb_wire_string name;
} id_both_directory_info;
- /* RAW_SEARCH_UNIX_INFO interface */
+ /* RAW_SEARCH_DATA_UNIX_INFO interface */
struct {
uint32_t file_index;
uint64_t size;
uint64_t nlink;
const char *name;
} unix_info;
+
+ /* RAW_SEARCH_DATA_UNIX_INFO2 interface */
+ struct {
+ uint32_t file_index;
+ uint64_t end_of_file;
+ uint64_t num_bytes;
+ NTTIME status_change_time;
+ NTTIME access_time;
+ NTTIME change_time;
+ uint64_t uid;
+ uint64_t gid;
+ uint32_t file_type;
+ uint64_t dev_major;
+ uint64_t dev_minor;
+ uint64_t unique_id;
+ uint64_t permissions;
+ uint64_t nlink;
+ NTTIME create_time;
+ uint32_t file_flags;
+ uint32_t flags_mask;
+ struct smb_wire_string name;
+ } unix_info2;
};
+/* Callback function passed to the raw search interface. */
+typedef BOOL (*smbcli_search_callback)(void *private, const union smb_search_data *file);
enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE};
} findclose;
};
+
+/*
+ struct for SMBecho call
+*/
+struct smb_echo {
+ struct {
+ uint16_t repeat_count;
+ uint16_t size;
+ uint8_t *data;
+ } in;
+ struct {
+ uint16_t count;
+ uint16_t sequence_number;
+ uint16_t size;
+ uint8_t *data;
+ } out;
+};
+
+/*
+ struct for shadow copy volumes
+ */
+struct smb_shadow_copy {
+ struct {
+ union smb_handle file;
+ uint32_t max_data;
+ } in;
+ struct {
+ uint32_t num_volumes;
+ uint32_t num_names;
+ const char **names;
+ } out;
+};
+
+#endif /* __LIBCLI_RAW_INTERFACES_H__ */