summaryrefslogtreecommitdiff
path: root/tests/unit/protocols/cifsv2.cpp
blob: fe512091f0ea924994725a857486823cee566d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//------------------------------------------------------------------------------
// Author: Andrey Kuznetsov
// Description: CIFS v2 tests
// Copyright (c) 2013-2014 EPAM Systems
//------------------------------------------------------------------------------
/*
    This file is part of Nfstrace.

    Nfstrace is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 2 of the License.

    Nfstrace is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Nfstrace.  If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <arpa/inet.h>

#include "api/cifs2_commands.h"
#include "api/cifs_commands.h"
#include "protocols/cifs2/cifs2.h"
//------------------------------------------------------------------------------
using namespace NST::API::SMBv2;
using namespace NST::protocols::CIFSv2;
//------------------------------------------------------------------------------

TEST(CIFSv2, bodies)
{
    EXPECT_EQ(36u, sizeof(struct NegotiateRequest) - sizeof(Dialects));
    EXPECT_EQ(65u, sizeof(struct NegotiateResponse));

    EXPECT_EQ(25u, sizeof(struct SessionSetupRequest));
    EXPECT_EQ(9u,  sizeof(struct SessionSetupResponse));

    EXPECT_EQ(4u,  sizeof(struct LogOffRequest));
    EXPECT_EQ(4u,  sizeof(struct LogOffResponse));

    EXPECT_EQ(4u,  sizeof(struct EchoRequest));
    EXPECT_EQ(4u,  sizeof(struct EchoResponse));

    EXPECT_EQ(9u,  sizeof(struct TreeConnectRequest));
    EXPECT_EQ(16u, sizeof(struct TreeConnectResponse));

    EXPECT_EQ(4u,  sizeof(struct TreeDisconnectRequest));
    EXPECT_EQ(4u,  sizeof(struct TreeDisconnectResponse));

    EXPECT_EQ(57u, sizeof(struct CreateRequest));
    EXPECT_EQ(89u, sizeof(struct CreateResponse));

    EXPECT_EQ(24u, sizeof(struct CloseRequest));
    EXPECT_EQ(60u, sizeof(struct CloseResponse));

    EXPECT_EQ(41u, sizeof(struct QueryInfoRequest));
    EXPECT_EQ(9u,  sizeof(struct QueryInfoResponse));

    EXPECT_EQ(33u, sizeof(struct QueryDirRequest));
    EXPECT_EQ(9u,  sizeof(struct QueryDirResponse));

    EXPECT_EQ(24u, sizeof(struct FlushRequest));
    EXPECT_EQ(4u,  sizeof(struct FlushResponse));

    EXPECT_EQ(49u, sizeof(struct ReadRequest));
    EXPECT_EQ(17u, sizeof(struct ReadResponse));

    EXPECT_EQ(24u, sizeof(struct OplockAcknowledgment));
    EXPECT_EQ(24u, sizeof(struct OplockResponse));

    EXPECT_EQ(49u, sizeof(struct WriteRequest));
    EXPECT_EQ(16u, sizeof(struct WriteResponse));

    EXPECT_EQ(48u, sizeof(struct LockRequest));
    EXPECT_EQ(4u,  sizeof(struct LockResponse));

    EXPECT_EQ(4u,  sizeof(struct CancelRequest));

    EXPECT_EQ(32u, sizeof(struct ChangeNotifyRequest));
    EXPECT_EQ(8u + sizeof(struct FileNotifyInformation),  sizeof(struct ChangeNotifyResponse));

    EXPECT_EQ(57u, sizeof(struct IoCtlRequest));
    EXPECT_EQ(49u, sizeof(struct IoCtlResponse));

    EXPECT_EQ(33u, sizeof(struct SetInfoRequest));
    EXPECT_EQ(2u,  sizeof(struct SetInfoResponse));
}
//------------------------------------------------------------------------------