88 *
99 */
1010#include <linux/ctype.h>
11- #include "smb2pdu.h"
1211#include "cifsglob.h"
1312#include "cifsproto.h"
1413#include "smb2proto.h"
1918#include "nterr.h"
2019
2120static int
22- check_smb2_hdr (struct smb2_sync_hdr * shdr , __u64 mid )
21+ check_smb2_hdr (struct smb2_hdr * shdr , __u64 mid )
2322{
2423 __u64 wire_mid = le64_to_cpu (shdr -> MessageId );
2524
@@ -81,9 +80,9 @@ static const __le16 smb2_rsp_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = {
8180 /* SMB2_OPLOCK_BREAK */ cpu_to_le16 (24 )
8281};
8382
84- #define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_sync_hdr ) + sizeof(struct smb2_negotiate_rsp))
83+ #define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_hdr ) + sizeof(struct smb2_negotiate_rsp))
8584
86- static __u32 get_neg_ctxt_len (struct smb2_sync_hdr * hdr , __u32 len ,
85+ static __u32 get_neg_ctxt_len (struct smb2_hdr * hdr , __u32 len ,
8786 __u32 non_ctxlen )
8887{
8988 __u16 neg_count ;
@@ -135,13 +134,13 @@ static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len,
135134int
136135smb2_check_message (char * buf , unsigned int len , struct TCP_Server_Info * srvr )
137136{
138- struct smb2_sync_hdr * shdr = (struct smb2_sync_hdr * )buf ;
139- struct smb2_sync_pdu * pdu = (struct smb2_sync_pdu * )shdr ;
137+ struct smb2_hdr * shdr = (struct smb2_hdr * )buf ;
138+ struct smb2_pdu * pdu = (struct smb2_pdu * )shdr ;
140139 __u64 mid ;
141140 __u32 clc_len ; /* calculated length */
142141 int command ;
143- int pdu_size = sizeof (struct smb2_sync_pdu );
144- int hdr_size = sizeof (struct smb2_sync_hdr );
142+ int pdu_size = sizeof (struct smb2_pdu );
143+ int hdr_size = sizeof (struct smb2_hdr );
145144
146145 /*
147146 * Add function to do table lookup of StructureSize by command
@@ -155,7 +154,7 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
155154 /* decrypt frame now that it is completely read in */
156155 spin_lock (& cifs_tcp_ses_lock );
157156 list_for_each_entry (ses , & srvr -> smb_ses_list , smb_ses_list ) {
158- if (ses -> Suid == thdr -> SessionId )
157+ if (ses -> Suid == le64_to_cpu ( thdr -> SessionId ) )
159158 break ;
160159 }
161160 spin_unlock (& cifs_tcp_ses_lock );
@@ -296,7 +295,7 @@ static const bool has_smb2_data_area[NUMBER_OF_SMB2_COMMANDS] = {
296295 * area and the offset to it (from the beginning of the smb are also returned.
297296 */
298297char *
299- smb2_get_data_area_len (int * off , int * len , struct smb2_sync_hdr * shdr )
298+ smb2_get_data_area_len (int * off , int * len , struct smb2_hdr * shdr )
300299{
301300 * off = 0 ;
302301 * len = 0 ;
@@ -401,8 +400,8 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr)
401400unsigned int
402401smb2_calc_size (void * buf , struct TCP_Server_Info * srvr )
403402{
404- struct smb2_sync_pdu * pdu = (struct smb2_sync_pdu * )buf ;
405- struct smb2_sync_hdr * shdr = & pdu -> sync_hdr ;
403+ struct smb2_pdu * pdu = (struct smb2_pdu * )buf ;
404+ struct smb2_hdr * shdr = & pdu -> hdr ;
406405 int offset ; /* the offset from the beginning of SMB to data area */
407406 int data_length ; /* the length of the variable length data area */
408407 /* Structure Size has already been checked to make sure it is 64 */
@@ -669,7 +668,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
669668
670669 cifs_dbg (FYI , "Checking for oplock break\n" );
671670
672- if (rsp -> sync_hdr .Command != SMB2_OPLOCK_BREAK )
671+ if (rsp -> hdr .Command != SMB2_OPLOCK_BREAK )
673672 return false;
674673
675674 if (rsp -> StructureSize !=
@@ -816,25 +815,25 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
816815int
817816smb2_handle_cancelled_mid (struct mid_q_entry * mid , struct TCP_Server_Info * server )
818817{
819- struct smb2_sync_hdr * sync_hdr = mid -> resp_buf ;
818+ struct smb2_hdr * hdr = mid -> resp_buf ;
820819 struct smb2_create_rsp * rsp = mid -> resp_buf ;
821820 struct cifs_tcon * tcon ;
822821 int rc ;
823822
824- if ((mid -> optype & CIFS_CP_CREATE_CLOSE_OP ) || sync_hdr -> Command != SMB2_CREATE ||
825- sync_hdr -> Status != STATUS_SUCCESS )
823+ if ((mid -> optype & CIFS_CP_CREATE_CLOSE_OP ) || hdr -> Command != SMB2_CREATE ||
824+ hdr -> Status != STATUS_SUCCESS )
826825 return 0 ;
827826
828- tcon = smb2_find_smb_tcon (server , sync_hdr -> SessionId ,
829- sync_hdr -> TreeId );
827+ tcon = smb2_find_smb_tcon (server , le64_to_cpu ( hdr -> SessionId ) ,
828+ le32_to_cpu ( hdr -> Id . SyncId . TreeId ) );
830829 if (!tcon )
831830 return - ENOENT ;
832831
833832 rc = __smb2_handle_cancelled_cmd (tcon ,
834- le16_to_cpu (sync_hdr -> Command ),
835- le64_to_cpu (sync_hdr -> MessageId ),
836- rsp -> PersistentFileId ,
837- rsp -> VolatileFileId );
833+ le16_to_cpu (hdr -> Command ),
834+ le64_to_cpu (hdr -> MessageId ),
835+ le64_to_cpu ( rsp -> PersistentFileId ) ,
836+ le64_to_cpu ( rsp -> VolatileFileId ) );
838837 if (rc )
839838 cifs_put_tcon (tcon );
840839
@@ -856,10 +855,10 @@ smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec)
856855{
857856 int i , rc ;
858857 struct sdesc * d ;
859- struct smb2_sync_hdr * hdr ;
858+ struct smb2_hdr * hdr ;
860859 struct TCP_Server_Info * server = cifs_ses_server (ses );
861860
862- hdr = (struct smb2_sync_hdr * )iov [0 ].iov_base ;
861+ hdr = (struct smb2_hdr * )iov [0 ].iov_base ;
863862 /* neg prot are always taken */
864863 if (hdr -> Command == SMB2_NEGOTIATE )
865864 goto ok ;
0 commit comments