Remove some inbuf references by adding "cmd" to smb_request
authorVolker Lendecke <vl@samba.org>
Sun, 2 Nov 2008 21:33:20 +0000 (22:33 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 2 Nov 2008 22:17:01 +0000 (23:17 +0100)
source3/include/smb.h
source3/smbd/blocking.c
source3/smbd/process.c
source3/smbd/reply.c
source3/smbd/trans2.c

index 3de782e8b8ab4593b6148c75c2761688a82f8152..bcf605ee53fe260e632bf9d7da7bce1d75366f12 100644 (file)
@@ -625,6 +625,7 @@ struct current_user {
 };
 
 struct smb_request {
+       uint8_t cmd;
        uint16 flags2;
        uint16 smbpid;
        uint16 mid;
index 14ce237ab8ebc641fa41c97b4fa1afccc710a9fe..a232249c8bf6f3bb84180496cc5e27b67853148f 100644 (file)
@@ -190,7 +190,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
                return False;
        }
 
-       blr->com_type = CVAL(req->inbuf,smb_com);
+       blr->com_type = req->cmd;
        blr->fsp = fsp;
        if (lock_timeout == -1) {
                blr->expire_time.tv_sec = 0;
index e32eea96a6594e349dd6fc8bf05fd451267d2129..215ae20077aec8e2258dd70a365ba44459116ead 100644 (file)
@@ -369,6 +369,7 @@ void init_smb_request(struct smb_request *req,
                        (unsigned int)req_size ));
                exit_server_cleanly("Invalid SMB request");
        }
+       req->cmd    = CVAL(inbuf, smb_com);
        req->flags2 = SVAL(inbuf, smb_flg2);
        req->smbpid = SVAL(inbuf, smb_pid);
        req->mid    = SVAL(inbuf, smb_mid);
@@ -1451,8 +1452,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
                        /* encrypted required from now on. */
                        conn->encrypt_level = Required;
                } else if (ENCRYPTION_REQUIRED(conn)) {
-                       uint8 com = CVAL(req->inbuf,smb_com);
-                       if (com != SMBtrans2 && com != SMBtranss2) {
+                       if (req->cmd != SMBtrans2 && req->cmd != SMBtranss2) {
                                exit_server_cleanly("encryption required "
                                        "on connection");
                                return conn;
@@ -1487,7 +1487,6 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
 
 static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool encrypted)
 {
-       uint8 type = CVAL(inbuf,smb_com);
        connection_struct *conn;
        struct smb_request *req;
 
@@ -1498,7 +1497,7 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc
        }
        init_smb_request(req, (uint8 *)inbuf, unread_bytes, encrypted);
 
-       conn = switch_message(type, req, size);
+       conn = switch_message(req->cmd, req, size);
 
        if (req->unread_bytes) {
                /* writeX failed. drain socket. */
index d88069c9df62aac86eebc7ab0f986d462218d4c0..7b5ed8feb451b224653dd70a23b66a9b24a4b78e 100644 (file)
@@ -1227,13 +1227,13 @@ void reply_search(struct smb_request *req)
        }
 
        if (lp_posix_pathnames()) {
-               reply_unknown_new(req, CVAL(req->inbuf, smb_com));
+               reply_unknown_new(req, req->cmd);
                END_PROFILE(SMBsearch);
                return;
        }
 
        /* If we were called as SMBffirst then we must expect close. */
-       if(CVAL(req->inbuf,smb_com) == SMBffirst) {
+       if(req->cmd == SMBffirst) {
                expect_close = True;
        }
 
@@ -1443,7 +1443,7 @@ void reply_search(struct smb_request *req)
        }
 
        /* If we were called as SMBfunique, then we can close the dirptr now ! */
-       if(dptr_num >= 0 && CVAL(req->inbuf,smb_com) == SMBfunique) {
+       if(dptr_num >= 0 && req->cmd == SMBfunique) {
                dptr_close(&dptr_num);
        }
 
@@ -1476,7 +1476,7 @@ void reply_search(struct smb_request *req)
        }
 
        DEBUG(4,("%s mask=%s path=%s dtype=%d nument=%u of %u\n",
-               smb_fn_name(CVAL(req->inbuf,smb_com)),
+               smb_fn_name(req->cmd),
                mask,
                directory ? directory : "./",
                dirtype,
@@ -1505,7 +1505,7 @@ void reply_fclose(struct smb_request *req)
        START_PROFILE(SMBfclose);
 
        if (lp_posix_pathnames()) {
-               reply_unknown_new(req, CVAL(req->inbuf, smb_com));
+               reply_unknown_new(req, req->cmd);
                END_PROFILE(SMBfclose);
                return;
        }
@@ -1891,7 +1891,6 @@ void reply_mknew(struct smb_request *req)
 {
        connection_struct *conn = req->conn;
        char *fname = NULL;
-       int com;
        uint32 fattr = 0;
        struct timespec ts[2];
        files_struct *fsp;
@@ -1914,7 +1913,6 @@ void reply_mknew(struct smb_request *req)
 
        fattr = SVAL(req->vwv+0, 0);
        oplock_request = CORE_OPLOCK_REQUEST(req->inbuf);
-       com = SVAL(req->inbuf,smb_com);
 
        ts[1] = convert_time_t_to_timespec(srv_make_unix_date3(req->vwv+1));
                        /* mtime. */
@@ -1932,7 +1930,7 @@ void reply_mknew(struct smb_request *req)
                        "please report this\n", fname));
        }
 
-       if(com == SMBmknew) {
+       if(req->cmd == SMBmknew) {
                /* We should fail if file exists. */
                create_disposition = FILE_CREATE;
        } else {
index df8b272c793d4c9b1a6323ae5072ce6626edaaba..9e150018efa90b1e9cff730a395fea7c379a3e4a 100644 (file)
@@ -2183,7 +2183,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        }
 
        DEBUG( 4, ( "%s mask=%s directory=%s dirtype=%d numentries=%d\n",
-               smb_fn_name(CVAL(req->inbuf,smb_com)),
+               smb_fn_name(req->cmd),
                mask, directory, dirtype, numentries ) );
 
        /*
@@ -2481,7 +2481,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        }
 
        DEBUG( 3, ( "%s mask=%s directory=%s dirtype=%d numentries=%d\n",
-               smb_fn_name(CVAL(req->inbuf,smb_com)),
+               smb_fn_name(req->cmd),
                mask, directory, dirtype, numentries ) );
 
        /* Check if we can close the dirptr */
@@ -3118,7 +3118,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                            max_data_bytes);
 
        DEBUG( 4, ( "%s info_level = %d\n",
-                   smb_fn_name(CVAL(req->inbuf,smb_com)), info_level) );
+                   smb_fn_name(req->cmd), info_level) );
 
        return;
 }