?? smb.h
字號(hào):
unsigned short data_offset; // Offset (from header start) to data
unsigned short data_displacement; // Displacement of these data bytes
unsigned char setup_count; // Count of setup words
unsigned char reserved2; // Reserved (pad above to word)
unsigned short setup[1]; // Setup words (# = SetupWordCount)
};
//
// Server Message Block (SMB)
//
struct smb
{
unsigned char len[4]; // Length field
unsigned char protocol[4]; // Always 0xFF,'SMB'
unsigned char cmd; // Command
unsigned char error_class; // Error Class
unsigned char reserved; // Reserved
unsigned short error; // Error Code
unsigned char flags; // Flags
unsigned short flags2; // More flags
unsigned short pidhigh; // High part of PID
unsigned char secsig[8]; // Reserved for security
unsigned short pad;
unsigned short tid; // Tree identifier
unsigned short pid; // Caller's process id
unsigned short uid; // Unauthenticated user id
unsigned short mid; // Multiplex id
unsigned char wordcount; // Count of parameter words
union
{
unsigned short words[0];
struct smb_andx andx;
union
{
struct smb_session_setup_request setup;
struct smb_tree_connect_request connect;
struct smb_create_file_request create;
struct smb_close_file_request close;
struct smb_flush_file_request flush;
struct smb_read_file_request read;
struct smb_read_raw_request readraw;
struct smb_write_file_request write;
struct smb_trans_request trans;
struct smb_rename_request rename;
struct smb_delete_request del;
struct smb_copy_request copy;
struct smb_findclose_request findclose;
} req;
union
{
struct smb_negotiate_response negotiate;
struct smb_session_setup_response setup;
struct smb_tree_connect_response connect;
struct smb_create_file_response create;
struct smb_read_file_response read;
struct smb_write_file_response write;
struct smb_trans_response trans;
struct smb_copy_response copy;
} rsp;
} params;
};
//
// SMB TRANS request and response messages
//
struct smb_fileinfo_request
{
unsigned short fid; // File ID
unsigned short infolevel; // Information level
};
struct smb_pathinfo_request
{
unsigned short infolevel; // Information level
unsigned long reserved;
char filename[MAXPATH];
};
struct smb_set_fileinfo_request
{
unsigned short fid; // File ID
unsigned short infolevel; // Information level
unsigned short reserved;
};
struct smb_set_fileinfo_response
{
unsigned short reserved;
};
struct smb_fsinfo_request
{
unsigned short infolevel; // Information level
};
struct smb_info_standard
{
unsigned short creation_date; // Date when file was created
unsigned short creation_time; // Time when file was created
unsigned short last_access_date; // Date of last file access
unsigned short last_access_time; // Time of last file access
unsigned short last_write_date; // Date of last write to the file
unsigned short last_write_time; // Time of last write to the file
unsigned long data_size; // File Size
unsigned long allocation_size; // Size of filesystem allocation unit
unsigned short attributes; // File Attributes
unsigned long ea_size; // Size of file's EA information
};
struct smb_info_allocation
{
unsigned long file_system_id; // File system identifier. NT server always returns 0
unsigned long sector_per_unit; // Number of sectors per allocation unit
unsigned long units_total; // Total number of allocation units
unsigned long units_avail; // Total number of available allocation units
unsigned short sectorsize; // Number of bytes per sector
};
struct smb_file_basic_info
{
smb_time creation_time; // Time when file was created
smb_time last_access_time; // Time of last file access
smb_time last_write_time; // Time of last write to the file
smb_time change_time; // Time when file was last changed
unsigned long attributes; // File Attributes
unsigned long reserved;
};
struct smb_file_standard_info
{
smb_size allocation_size; // Allocated size of the file in number of bytes
smb_size end_of_file; // Offset to the first free byte in the file
unsigned long number_of_links; // Number of hard links to the file
unsigned char delete_pending; // Indicates whether the file is marked for deletion
unsigned char directory; // Indicates whether the file is a directory
unsigned short pad;
};
struct smb_file_all_info
{
struct smb_file_basic_info basic;
struct smb_file_standard_info standard;
__int64 index_number; // A file system unique identifier
unsigned long ea_size; // Size of the file抯 extended attributes in number of bytes
unsigned long access_flags; // Access that a caller has to the file; Possible values and meanings are specified below
__int64 current_byte_offset; // Current byte offset within the file
unsigned long mode; // Current Open mode of the file handle to the file
unsigned long alignment_requirement; // Buffer Alignment required by device; possible values detailed below
unsigned long file_name_length; // Length of the file name in number of bytes
char filename[256]; // Name of the file
};
struct smb_file_end_of_file_info
{
smb_size end_of_file; // Offset to the first free byte in the file
};
struct smb_findfirst_request
{
unsigned short search_attributes; // Search attributes
unsigned short search_count; // Maximum number of entries to return
unsigned short flags; // Additional information:
// Bit 0 - close search after this request
// Bit 1 - close search if end of search reached
// Bit 2 - return resume keys for each entry found
// Bit 3 - continue search from previous ending place
// Bit 4 - find with backup intent
unsigned short infolevel; // Information level
unsigned long search_storage_type;
char filename[MAXPATH]; // Pattern for the search
};
struct smb_findfirst_response
{
unsigned short sid; // Search handle
unsigned short search_count; // Number of entries returned
unsigned short end_of_search; // Was last entry returned?
unsigned short ea_error_offset; // Offset into EA list if EA error
unsigned short last_name_offset; // Offset into data to file name of last entry, if server needs it to resume search; else 0
};
struct smb_findnext_request
{
unsigned short sid; // Search handle
unsigned short search_count; // Maximum number of entries to return
unsigned short infolevel; // Levels described in TRANS2_FIND_FIRST2 request
unsigned long resume_key; // Value returned by previous find2 call
unsigned short flags; // Additional information::
// Bit 0 - close search after this request
// Bit 1 - close search if end of search reached
// Bit 2 - return resume keys for each entry found
// Bit 3 - resume/continue from previous ending place
// Bit 4 - find with backup intent
char filename[1]; // Resume file name
};
struct smb_findnext_response
{
unsigned short search_count; // Number of entries returned
unsigned short end_of_search; // Was last entry returned?
unsigned short ea_error_offset; // Offset into EA list if EA error
unsigned short last_name_offset; // Offset into data to file name of last entry, if server needs it to resume search; else 0
};
struct smb_file_directory_info
{
unsigned long next_entry_offset; // Offset from this structure to beginning of next one
unsigned long file_index;
smb_time creation_time; // File creation time
smb_time last_access_time; // Last access time
smb_time last_write_time; // Last write time
smb_time change_time; // Last attribute change time
smb_size end_of_file; // File size
smb_size allocation_aize; // Size of filesystem allocation information
unsigned long ext_file_attributes; // Extended file attributes (see section 3.12)
unsigned long filename_length; // Length of filename in bytes
char filename[0]; // Name of the file
};
struct smb_share;
//
// SMB directory entry
//
struct smb_dentry
{
char path[MAXPATH];
struct stat statbuf;
};
//
// SMB file
//
struct smb_file
{
unsigned short fid;
unsigned long attrs;
struct stat statbuf;
};
//
// SMF directory
//
struct smb_directory
{
unsigned short sid;
int eos;
int entries_left;
struct smb_file_directory_info *fi;
char path[MAXPATH];
char buffer[SMB_DIRBUF_SIZE];
};
//
// SMB server
//
struct smb_server
{
struct ip_addr ipaddr;
struct socket *sock;
char username[SMB_NAMELEN];
char password[SMB_NAMELEN];
char domain[SMB_NAMELEN];
unsigned short uid;
int refcnt;
struct smb_server *next;
struct mutex lock;
struct smb_share *shares;
int tzofs;
unsigned long server_caps;
unsigned long max_buffer_size;
char buffer[SMB_MAX_BUFFER + 4];
char auxbuf[SMB_MAX_BUFFER + 4];
};
//
// SMB share
//
struct smb_share
{
struct smb_server *server;
struct smb_share *next;
unsigned short tid;
char sharename[SMB_NAMELEN];
time_t mounttime;
int next_cacheidx;
struct smb_dentry dircache[SMB_DENTRY_CACHESIZE];
};
// smbutil.c
int recv_fully(struct socket *s, char *buf, int size, int flags);
char *addstr(char *p, char *s);
char *addstrz(char *p, char *s);
time_t ft2time(smb_time filetime);
smb_time time2ft(time_t time);
int smb_convert_filename(char *name);
int smb_errno(struct smb *smb);
// smbcache.c
void smb_add_to_cache(struct smb_share *share, char *path, char *filename, struct stat *statbuf);
struct smb_dentry *smb_find_in_cache(struct smb_share *share, char *path);
void smb_clear_cache(struct smb_share *share);
// smbproto.c
struct smb *smb_init(struct smb_share *share, int aux);
int smb_send(struct smb_share *share, struct smb *smb, unsigned char cmd, int params, char *data, int datasize);
int smb_recv(struct smb_share *share, struct smb *smb);
int smb_request(struct smb_share *share, struct smb *smb, unsigned char cmd, int params, char *data, int datasize, int retry);
int smb_trans(struct smb_share *share,
unsigned short cmd,
void *reqparams, int reqparamlen,
void *reqdata, int reqdatalen,
void *rspparams, int *rspparamlen,
void *rspdata, int *rspdatalen);
int smb_connect_tree(struct smb_share *share);
int smb_disconnect_tree(struct smb_share *share);
int smb_connect(struct smb_share *share);
int smb_disconnect(struct smb_share *share);
int smb_get_connection(struct smb_share *share, struct ip_addr *ipaddr, char *domain, char *username, char *password);
int smb_release_connection(struct smb_share *share);
int smb_check_connection(struct smb_share *share);
int smb_reconnect(struct smb_share *share);
#pragma pack(pop)
#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -