Commit 792af7b0 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Jeff Layton

CIFS: Separate protocol-specific code from transport routines

that lets us use this functions for SMB2.
Signed-off-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
parent 934e18b5
...@@ -32,7 +32,7 @@ void cifs_dump_mids(struct TCP_Server_Info *); ...@@ -32,7 +32,7 @@ void cifs_dump_mids(struct TCP_Server_Info *);
#define DBG2 0 #define DBG2 0
#endif #endif
extern int traceSMB; /* flag which enables the function below */ extern int traceSMB; /* flag which enables the function below */
void dump_smb(struct smb_hdr *, int); void dump_smb(void *, int);
#define CIFS_INFO 0x01 #define CIFS_INFO 0x01
#define CIFS_RC 0x02 #define CIFS_RC 0x02
#define CIFS_TIMER 0x04 #define CIFS_TIMER 0x04
......
...@@ -230,6 +230,12 @@ struct cifs_mnt_data { ...@@ -230,6 +230,12 @@ struct cifs_mnt_data {
int flags; int flags;
}; };
static inline unsigned int
get_rfc1002_length(void *buf)
{
return be32_to_cpu(*((__be32 *)buf));
}
struct TCP_Server_Info { struct TCP_Server_Info {
struct list_head tcp_ses_list; struct list_head tcp_ses_list;
struct list_head smb_ses_list; struct list_head smb_ses_list;
......
...@@ -77,7 +77,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, ...@@ -77,7 +77,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
struct smb_hdr * /* out */ , struct smb_hdr * /* out */ ,
int * /* bytes returned */ , const int long_op); int * /* bytes returned */ , const int long_op);
extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
struct smb_hdr *in_buf, int flags); char *in_buf, int flags);
extern int cifs_check_receive(struct mid_q_entry *mid, extern int cifs_check_receive(struct mid_q_entry *mid,
struct TCP_Server_Info *server, bool log_error); struct TCP_Server_Info *server, bool log_error);
extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
......
...@@ -696,7 +696,7 @@ CIFSSMBTDis(const int xid, struct cifs_tcon *tcon) ...@@ -696,7 +696,7 @@ CIFSSMBTDis(const int xid, struct cifs_tcon *tcon)
if (rc) if (rc)
return rc; return rc;
rc = SendReceiveNoRsp(xid, tcon->ses, smb_buffer, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *)smb_buffer, 0);
if (rc) if (rc)
cFYI(1, "Tree disconnect failed %d", rc); cFYI(1, "Tree disconnect failed %d", rc);
...@@ -792,7 +792,7 @@ CIFSSMBLogoff(const int xid, struct cifs_ses *ses) ...@@ -792,7 +792,7 @@ CIFSSMBLogoff(const int xid, struct cifs_ses *ses)
pSMB->hdr.Uid = ses->Suid; pSMB->hdr.Uid = ses->Suid;
pSMB->AndXCommand = 0xFF; pSMB->AndXCommand = 0xFF;
rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, ses, (char *) pSMB, 0);
session_already_dead: session_already_dead:
mutex_unlock(&ses->session_mutex); mutex_unlock(&ses->session_mutex);
...@@ -2420,8 +2420,7 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon, ...@@ -2420,8 +2420,7 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
(struct smb_hdr *) pSMB, &bytes_returned); (struct smb_hdr *) pSMB, &bytes_returned);
cifs_small_buf_release(pSMB); cifs_small_buf_release(pSMB);
} else { } else {
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *)pSMB, rc = SendReceiveNoRsp(xid, tcon->ses, (char *)pSMB, timeout);
timeout);
/* SMB buffer freed by function above */ /* SMB buffer freed by function above */
} }
cifs_stats_inc(&tcon->num_locks); cifs_stats_inc(&tcon->num_locks);
...@@ -2588,7 +2587,7 @@ CIFSSMBClose(const int xid, struct cifs_tcon *tcon, int smb_file_id) ...@@ -2588,7 +2587,7 @@ CIFSSMBClose(const int xid, struct cifs_tcon *tcon, int smb_file_id)
pSMB->FileID = (__u16) smb_file_id; pSMB->FileID = (__u16) smb_file_id;
pSMB->LastWriteTime = 0xFFFFFFFF; pSMB->LastWriteTime = 0xFFFFFFFF;
pSMB->ByteCount = 0; pSMB->ByteCount = 0;
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
cifs_stats_inc(&tcon->num_closes); cifs_stats_inc(&tcon->num_closes);
if (rc) { if (rc) {
if (rc != -EINTR) { if (rc != -EINTR) {
...@@ -2617,7 +2616,7 @@ CIFSSMBFlush(const int xid, struct cifs_tcon *tcon, int smb_file_id) ...@@ -2617,7 +2616,7 @@ CIFSSMBFlush(const int xid, struct cifs_tcon *tcon, int smb_file_id)
pSMB->FileID = (__u16) smb_file_id; pSMB->FileID = (__u16) smb_file_id;
pSMB->ByteCount = 0; pSMB->ByteCount = 0;
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
cifs_stats_inc(&tcon->num_flushes); cifs_stats_inc(&tcon->num_flushes);
if (rc) if (rc)
cERROR(1, "Send error in Flush = %d", rc); cERROR(1, "Send error in Flush = %d", rc);
...@@ -4625,7 +4624,7 @@ CIFSFindClose(const int xid, struct cifs_tcon *tcon, ...@@ -4625,7 +4624,7 @@ CIFSFindClose(const int xid, struct cifs_tcon *tcon,
pSMB->FileID = searchHandle; pSMB->FileID = searchHandle;
pSMB->ByteCount = 0; pSMB->ByteCount = 0;
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
if (rc) if (rc)
cERROR(1, "Send error in FindClose = %d", rc); cERROR(1, "Send error in FindClose = %d", rc);
...@@ -5646,7 +5645,7 @@ CIFSSMBSetFileSize(const int xid, struct cifs_tcon *tcon, __u64 size, ...@@ -5646,7 +5645,7 @@ CIFSSMBSetFileSize(const int xid, struct cifs_tcon *tcon, __u64 size,
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
inc_rfc1001_len(pSMB, byte_count); inc_rfc1001_len(pSMB, byte_count);
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
if (rc) { if (rc) {
cFYI(1, "Send error in SetFileInfo (SetFileSize) = %d", rc); cFYI(1, "Send error in SetFileInfo (SetFileSize) = %d", rc);
} }
...@@ -5715,7 +5714,7 @@ CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon, ...@@ -5715,7 +5714,7 @@ CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon,
inc_rfc1001_len(pSMB, byte_count); inc_rfc1001_len(pSMB, byte_count);
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); memcpy(data_offset, data, sizeof(FILE_BASIC_INFO));
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
if (rc) if (rc)
cFYI(1, "Send error in Set Time (SetFileInfo) = %d", rc); cFYI(1, "Send error in Set Time (SetFileInfo) = %d", rc);
...@@ -5774,7 +5773,7 @@ CIFSSMBSetFileDisposition(const int xid, struct cifs_tcon *tcon, ...@@ -5774,7 +5773,7 @@ CIFSSMBSetFileDisposition(const int xid, struct cifs_tcon *tcon,
inc_rfc1001_len(pSMB, byte_count); inc_rfc1001_len(pSMB, byte_count);
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
*data_offset = delete_file ? 1 : 0; *data_offset = delete_file ? 1 : 0;
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
if (rc) if (rc)
cFYI(1, "Send error in SetFileDisposition = %d", rc); cFYI(1, "Send error in SetFileDisposition = %d", rc);
...@@ -6006,7 +6005,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon, ...@@ -6006,7 +6005,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
cifs_fill_unix_set_info(data_offset, args); cifs_fill_unix_set_info(data_offset, args);
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
if (rc) if (rc)
cFYI(1, "Send error in Set Time (SetFileInfo) = %d", rc); cFYI(1, "Send error in Set Time (SetFileInfo) = %d", rc);
......
...@@ -604,16 +604,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) ...@@ -604,16 +604,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
} }
void void
dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) dump_smb(void *buf, int smb_buf_length)
{ {
int i, j; int i, j;
char debug_line[17]; char debug_line[17];
unsigned char *buffer; unsigned char *buffer = buf;
if (traceSMB == 0) if (traceSMB == 0)
return; return;
buffer = (unsigned char *) smb_buf;
for (i = 0, j = 0; i < smb_buf_length; i++, j++) { for (i = 0, j = 0; i < smb_buf_length; i++, j++) {
if (i % 8 == 0) { if (i % 8 == 0) {
/* have reached the beginning of line */ /* have reached the beginning of line */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment