1 //--------------------------------------------------------------------------
2 // Copyright (C) 2016-2021 Cisco and/or its affiliates. All rights reserved.
3 //
4 // This program is free software; you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License Version 2 as published
6 // by the Free Software Foundation.  You may not use, modify or distribute
7 // this program under any other version of the GNU General Public License.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 //--------------------------------------------------------------------------
18 
19 // dce_smb_transaction_utils.h author Maya Dagon <mdagon@cisco.com>
20 // based on work by Todd Wease
21 
22 #ifndef DCE_SMB_TRANSACTION_UTILS_H
23 #define DCE_SMB_TRANSACTION_UTILS_H
24 
25 #include "dce_smb1.h"
26 
27 DCE2_Ret DCE2_SmbTransactionGetName(const uint8_t* nb_ptr,
28     uint32_t nb_len, uint16_t bcc, bool unicode);
29 
30 DCE2_Ret DCE2_SmbValidateTransactionFields(
31     DCE2_SmbSsnData* ssd, const uint8_t* smb_hdr_ptr,
32     const uint8_t* nb_ptr, const uint32_t nb_len, const uint16_t bcc,
33     const uint32_t tdcnt, const uint32_t tpcnt,
34     const uint32_t dcnt, const uint32_t doff, const uint32_t ddisp,
35     const uint32_t pcnt, const uint32_t poff, const uint32_t pdisp);
36 
37 DCE2_Ret DCE2_SmbValidateTransactionSent(
38     DCE2_SmbSsnData* ssd, uint32_t dsent, uint32_t dcnt, uint32_t tdcnt,
39     uint32_t psent, uint32_t pcnt, uint32_t tpcnt);
40 
41 DCE2_Ret DCE2_SmbBufferTransactionData(DCE2_SmbTransactionTracker* ttracker,
42     const uint8_t* data_ptr, uint16_t dcnt, uint16_t ddisp);
43 
44 DCE2_Ret DCE2_SmbBufferTransactionParameters(DCE2_SmbTransactionTracker* ttracker,
45     const uint8_t* param_ptr, uint16_t pcnt, uint16_t pdisp);
46 
47 DCE2_Ret DCE2_SmbCheckTotalCount(DCE2_SmbSsnData* ssd, const uint32_t tcnt, const uint32_t cnt,
48     const uint32_t disp);
49 
DCE2_SmbFileUpload(DCE2_SmbFileDirection dir)50 inline bool DCE2_SmbFileUpload(DCE2_SmbFileDirection dir)
51 {
52     return dir == DCE2_SMB_FILE_DIRECTION__UPLOAD;
53 }
54 
DCE2_SmbFileDownload(DCE2_SmbFileDirection dir)55 inline bool DCE2_SmbFileDownload(DCE2_SmbFileDirection dir)
56 {
57     return dir == DCE2_SMB_FILE_DIRECTION__DOWNLOAD;
58 }
59 
60 #endif
61 
62