Codebase list nfstrace / 50a11af
Imported Upstream version 0.4.3.1 Andrew Shadura 7 years ago
203 changed file(s) with 5247 addition(s) and 8259 deletion(s). Raw diff Collapse all Expand all
0 ---
1 Language: Cpp
2 # BasedOnStyle: Google
3 AccessModifierOffset: -4
4 AlignAfterOpenBracket: Align
5 AlignConsecutiveAssignments: true
6 AlignConsecutiveDeclarations: true
7 AlignEscapedNewlinesLeft: true
8 AlignOperands: true
9 AlignTrailingComments: true
10 AllowAllParametersOfDeclarationOnNextLine: true
11 AllowShortBlocksOnASingleLine: true
12 AllowShortCaseLabelsOnASingleLine: false
13 AllowShortFunctionsOnASingleLine: Inline
14 AllowShortIfStatementsOnASingleLine: true
15 AllowShortLoopsOnASingleLine: true
16 AlwaysBreakAfterDefinitionReturnType: None
17 AlwaysBreakAfterReturnType: None
18 AlwaysBreakBeforeMultilineStrings: true
19 AlwaysBreakTemplateDeclarations: true
20 BinPackArguments: true
21 BinPackParameters: true
22 BraceWrapping:
23 AfterClass: false
24 AfterControlStatement: false
25 AfterEnum: false
26 AfterFunction: false
27 AfterNamespace: false
28 AfterObjCDeclaration: false
29 AfterStruct: false
30 AfterUnion: false
31 BeforeCatch: false
32 BeforeElse: false
33 IndentBraces: false
34 BreakBeforeBinaryOperators: None
35 BreakBeforeBraces: Allman
36 BreakBeforeTernaryOperators: true
37 BreakConstructorInitializersBeforeComma: true
38 BreakAfterJavaFieldAnnotations: false
39 BreakStringLiterals: true
40 ColumnLimit: 0
41 CommentPragmas: '^ IWYU pragma:'
42 ConstructorInitializerAllOnOneLineOrOnePerLine: false
43 ConstructorInitializerIndentWidth: 4
44 ContinuationIndentWidth: 4
45 Cpp11BracedListStyle: true
46 DerivePointerAlignment: false
47 DisableFormat: false
48 ExperimentalAutoDetectBinPacking: false
49 ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
50 IncludeCategories:
51 - Regex: '^<[a-z]*>' # language headers like <algorithm>
52 Priority: 1
53 - Regex: '^<.*\.h>' # platform headers like <unistd.h>
54 Priority: 2
55 - Regex: '^<.*' # other external headers
56 Priority: 3
57 - Regex: '.*' # any other files
58 Priority: 4
59 IndentCaseLabels: false
60 IndentWidth: 4
61 IndentWrappedFunctionNames: false
62 KeepEmptyLinesAtTheStartOfBlocks: false
63 MacroBlockBegin: ''
64 MacroBlockEnd: ''
65 MaxEmptyLinesToKeep: 1
66 NamespaceIndentation: None
67 ObjCBlockIndentWidth: 2
68 ObjCSpaceAfterProperty: false
69 ObjCSpaceBeforeProtocolList: false
70 PenaltyBreakBeforeFirstCallParameter: 1
71 PenaltyBreakComment: 300
72 PenaltyBreakFirstLessLess: 120
73 PenaltyBreakString: 1000
74 PenaltyExcessCharacter: 1000000
75 PenaltyReturnTypeOnItsOwnLine: 200
76 PointerAlignment: Left
77 ReflowComments: true
78 SortIncludes: true
79 SpaceAfterCStyleCast: false
80 SpaceBeforeAssignmentOperators: true
81 SpaceBeforeParens: Never
82 SpaceInEmptyParentheses: false
83 SpacesBeforeTrailingComments: 1
84 SpacesInAngles: false
85 SpacesInContainerLiterals: true
86 SpacesInCStyleCastParentheses: false
87 SpacesInParentheses: false
88 SpacesInSquareBrackets: false
89 Standard: Cpp11
90 TabWidth: 4
91 UseTab: Never
92 ...
93
0 [submodule "third_party/googletest"]
1 path = third_party/googletest
2 url = https://github.com/google/googletest.git
33 addons:
44 apt:
55 packages:
6 - ccache
6 - ccache
77 cache:
88 apt: true
99 directories:
1414 env:
1515 global:
1616 - DEPS_DIR="$HOME/install"
17 - CMAKE_DIR="$DEPS_DIR/cmake-3.3.2-Linux-x86_64"
18 - CMAKE="$CMAKE_DIR/bin/cmake"
17 - CMAKE_DIR="$DEPS_DIR/cmake-3.5.2-Linux-x86_64"
18 - CMAKE="$CMAKE_DIR/bin/cmake"
1919 - JSON_DIR="$DEPS_DIR/json-c-0.11"
20 - JSON_LIB="$JSON_DIR/install"
20 - JSON_LIB="$JSON_DIR/install"
2121 - JSON_INCLUDE_DIR="$JSON_DIR"
2222 - LCOV_DIR="$DEPS_DIR/lcov-1.11"
2323 - LCOV="$LCOV_DIR/bin/lcov"
24 - GMOCK_DIR="$DEPS_DIR/gmock-1.7.0"
24 - GTEST_DIR="$TRAVIS_BUILD_DIR/third_party/googletest"
2525
2626 matrix:
2727 include:
2828 - os: linux
29 compiler: gcc-4.9
29 compiler: gcc-6
3030 addons:
3131 apt:
3232 sources: ['ubuntu-toolchain-r-test']
33 packages: ['texlive-latex-base','gcc-4.9','g++-4.9','libpcap-dev','valgrind']
34 env:
33 packages: ['texlive-latex-base','gcc-6','g++-6','libpcap-dev','valgrind']
34 env:
3535 # You can not set CXX directly as Travis CI will overwrite it. You need an intermediate variable like COMPILER
36 - COMPILER=g++-4.9 CXX_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage -fPIC" C_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" gcov="/usr/bin/gcov-4.9"
36 - COMPILER=g++-6 CXX_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage -fPIC" C_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" gcov="/usr/bin/gcov-6"
37 fast_finish: true
38 - os: linux
39 compiler: clang-3.8
40 addons:
41 apt:
42 sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
43 packages: ['texlive-latex-base','clang-3.8','llvm-3.8-dev','libpcap-dev','valgrind']
44 env:
45 - COMPILER=/usr/bin/clang++-3.8 gcov="/usr/bin/gcov-6"
3746 fast_finish: true
3847
3948 before_install:
49 - git submodule update --init --recursive
4050 - uname -a
4151 - pwd
4252 - export
4757 - gem install coveralls-lcov
4858 - |
4959 if [ ! -f "$CMAKE" ]; then
50 wget -O - --no-check-certificate https://cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz | tar xz && cp -r cmake-3.3.2-Linux-x86_64 $DEPS_DIR
51 else
60 wget -O - --no-check-certificate https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | tar xz && cp -r cmake-3.5.2-Linux-x86_64 $DEPS_DIR
61 else
5262 echo "Using cached cmake"
5363 fi
5464 - |
55 if [ ! -f "$GMOCK_DIR/CMakeLists.txt" ]; then
56 wget -q https://googlemock.googlecode.com/files/gmock-1.7.0.zip && unzip gmock-1.7.0.zip -d $DEPS_DIR
57 else
58 echo "Using cached gmock"
59 fi
6065
6166 # installing libjson-c from source because #'ondrej/php5-5.6' is disallowed source in travis-ci
6267 - |
7378 else
7479 echo "Using cached lcov"
7580 fi
81
7682 before_script:
7783 - $CMAKE --version
7884 - gcov --version
79 - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --directory . --zerocounters
85 - $LCOV --gcov-tool "/usr/bin/gcov-6" --directory . --zerocounters
8086 script:
8187 - mkdir debug && cd debug
82 - $CMAKE -DCMAKE_CXX_COMPILER="$COMPILER" -DCMAKE_BUILD_TYPE=DEBUG -DGMOCK_SOURCE_DIR=$GMOCK_DIR -D"CMAKE_CXX_FLAGS=$CXX_FLAGS" -DCMAKE_C_FLAGS="$C_FLAGS" -DINCLUDE_COVERAGE_INFO="true" ../
88 - $CMAKE -DCMAKE_CXX_COMPILER="$COMPILER" -DCMAKE_BUILD_TYPE=DEBUG -DGTEST_SOURCE_DIR=$GTEST_DIR -D"CMAKE_CXX_FLAGS=$CXX_FLAGS" -DCMAKE_C_FLAGS="$C_FLAGS" -DINCLUDE_COVERAGE_INFO="true" ../
8389 - make
8490 - make test
8591 - make documentation-pdflatex
8692 - ccache -s
8793
8894 after_success:
89 - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --compat-libtool --directory . --capture --output-file coverage.info # capture coverage info
90 - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --remove coverage.info 'tests/*' '/usr/*' '*gmock*' --output-file coverage.info # filter out system and test code
91 - coveralls-lcov coverage.info
95 - |
96 if [[ "$COMPILER" == "g++"* ]]; then
97 $LCOV --gcov-tool "/usr/bin/gcov-6" --compat-libtool --directory . --capture --output-file coverage.info # capture coverage info
98 $LCOV --gcov-tool "/usr/bin/gcov-6" --remove coverage.info 'tests/*' '/usr/*' '*gmock*' --output-file coverage.info # filter out system and test code
99 coveralls-lcov coverage.info
100 fi
92101 # - coveralls --gcov "$(which "${GCOV}")" --encoding iso-8859-1 || echo 'coveralls upload failed.'
93102
0 0.4.3
1 =====
2 - Switched to C++14
3 - GCC updated to version 6; Clang updated to version 3.8
4 - Fixed calculation of struct's member offset on x32 platform (https://github.com/epam/nfstrace/issues/19)
5 - Fix unaligned access in buffer copies.
6
7 0.4.2
8 =====
9 - documentation converted to LaTeX format
10 - repository was cleaned up via BFG Repo-Cleaner tool (https://rtyley.github.io/bfg-repo-cleaner/) to reduce the size.
11
012 0.4.1
113 =====
214 - minor bug fixes for Debian platforms;
22
33 # check compiler and packages ==================================================
44 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
5 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
6 message (FATAL_ERROR "GCC version must be at least 4.8")
5 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
6 message (FATAL_ERROR "GCC version must be at least 5.1")
77 endif ()
88 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
9 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
10 message (FATAL_ERROR "Clang version must be at least 3.3")
9 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
10 message (FATAL_ERROR "Clang version must be at least 3.5")
1111 endif ()
1212 else ()
1313 message (WARNING "Compilation by ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} isn't tested")
2929 endif ()
3030
3131 # build application ============================================================
32 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall -Werror -Wextra -fPIC -fvisibility=hidden")
32 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pedantic -Wall -Werror -Wextra -Wno-invalid-offsetof -Wno-braced-scalar-init -fPIC -fvisibility=hidden")
3333 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
3434
3535 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${INCLUDE_COVERAGE_INFO}")
4646
4747 set (NST_VERSION_FULL "${PROJECT_NAME} ${NST_VERSION} (${CMAKE_BUILD_TYPE})")
4848
49 string (TIMESTAMP COMPILATION_DATE "%Y-%m-%d")
49 if (DEFINED ENV{SOURCE_DATE_EPOCH})
50 execute_process(
51 COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d"
52 OUTPUT_VARIABLE COMPILATION_DATE
53 OUTPUT_STRIP_TRAILING_WHITESPACE)
54 else ()
55 string (TIMESTAMP COMPILATION_DATE "%Y-%m-%d")
56 endif ()
5057
5158 include_directories (src)
5259
104111 add_subdirectory (docs)
105112
106113 # code style ===================================================================
107 find_program (ASTYLE_PATH astyle)
108
109 if (ASTYLE_PATH)
110 add_custom_target (codestyle
111 COMMAND find analyzers src tests -name '*.h' -o -name '*.cpp' |
112 xargs ${ASTYLE_PATH} --options=${CMAKE_SOURCE_DIR}/astyle.cfg
113 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
114 endif ()
114 include ("cmake/codeformat.cmake")
115115
116116 # valgrind reports =============================================================
117117 include ("cmake/valgrind.cmake")
1313 filtration, dumping, compression, statistical analysis, visualization and
1414 provides the API for custom pluggable analysis modules.
1515
16 `nfstrace` is written in C++11 programming language and currently supports the
16 `nfstrace` is written in C++ programming language and supports the
1717 following protocols:
1818
1919 - Ethernet
2020 - IPv4 | IPv6
21 - UPD | TCP
21 - UDP | TCP
2222 - NFSv3 | NFSv4 | NFSv4.1 | CIFSv1 | CIFSv2
2323
2424 `nfstrace` has been tested on the following GNU/Linux and FreeBSD systems:
2525
2626 - Debian Sid [packages](https://packages.debian.org/unstable/main/nfstrace) [build-logs](https://buildd.debian.org/status/logs.php?pkg=nfstrace)
27 - Fedora 20
27 - Fedora 23
2828 - OpenSUSE 13.2
2929 - Ubuntu 14.04/14.10
3030 - CentOS 7
4848 Building
4949 --------
5050
51 Since `nfstrace` is written in C++11 you have to use `gcc` >= 4.8 or
52 `clang` >= 3.3. Additionally, you need to install development version of
51 Since `nfstrace` is written in C++ you have to use `gcc` >= 6 or
52 `clang` >= 3.8. Additionally, you need to install development version of
5353 `libpcap` (version 1.3 or newer).
5454
55 You can build `nfstrace` using [CMake](http://cmake.org) (version 2.8.12 or
55 You can build `nfstrace` using [CMake](https://cmake.org/cmake/help/v3.5/index.html) (version 2.8.12 or
5656 newer). From the top level project's directory run:
5757
5858 $ mkdir release
6969
7070 $ cmake -DCMAKE_INSTALL_PREFIX=/your/path ../
7171
72 You can use different build tools, compilers, packaging systems with required parameters.
73 Please refer to
74 [CMake](https://cmake.org/cmake/help/v3.3/manual/cmake.1.html),
75 [CPack](https://cmake.org/cmake/help/v3.3/manual/cpack.1.html) and
76 [Reference Manuals](https://cmake.org/cmake/help/v3.3/index.html).
77
7278
7379 Installation
7480 ------------
7581
76 By default `nfstrace` will be installed to `/usr/`.
77 After you build `nfstrace` simply run:
82 You can install `nfstrace` to default location. After you build `nfstrace` simply run:
7883
7984 $ sudo make install
8085
0 0.4.2
0 0.4.3
4444 }
4545 };
4646
47 extern "C"
47 extern "C" {
48 const char* usage()
4849 {
50 return "No options";
51 }
4952
50 const char* usage()
51 {
52 return "No options";
53 }
53 IAnalyzer* create(const char*)
54 {
55 return new Analyzer();
56 }
5457
55 IAnalyzer* create(const char*)
56 {
57 return new Analyzer();
58 }
58 void destroy(IAnalyzer* instance)
59 {
60 delete instance;
61 }
5962
60 void destroy(IAnalyzer* instance)
61 {
62 delete instance;
63 }
63 NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr)
6464
65 NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr)
66
67 }//extern "C"
65 } //extern "C"
6866 //------------------------------------------------------------------------------
2525 //------------------------------------------------------------------------------
2626 using namespace NST::breakdown;
2727 //------------------------------------------------------------------------------
28 BreakdownCounter::BreakdownCounter(size_t count) : latencies(count, NST::breakdown::Latencies())
28 BreakdownCounter::BreakdownCounter(size_t count)
29 : latencies(count, NST::breakdown::Latencies())
2930 {
3031 }
3132
4041
4142 uint64_t BreakdownCounter::get_total_count() const
4243 {
43 return std::accumulate(std::begin(latencies), std::end(latencies), 0, [](int sum, const NST::breakdown::Latencies & latency)
44 {
44 return std::accumulate(std::begin(latencies), std::end(latencies), 0, [](int sum, const NST::breakdown::Latencies& latency) {
4545 return sum + latency.get_count();
4646 });
4747 }
5252 * \brief get_total_count returns total amount of commands
5353 * \return commands count
5454 */
55 uint64_t get_total_count () const;
55 uint64_t get_total_count() const;
5656
5757 private:
58 void operator= (const BreakdownCounter&) = delete;
58 void operator=(const BreakdownCounter&) = delete;
5959 std::vector<NST::breakdown::Latencies> latencies;
6060 };
6161 //------------------------------------------------------------------------------
62 #endif//BREAKDOWNCOUNTER_H
62 #endif //BREAKDOWNCOUNTER_H
6363 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include "cifsv1breakdownanalyzer.h"
2122 #include "cifsv1commands.h"
22 #include "cifsv1breakdownanalyzer.h"
2323 //------------------------------------------------------------------------------
2424 using namespace NST::breakdown;
2525 //------------------------------------------------------------------------------
3030 {
3131 namespace breakdown
3232 {
33
3433 /*! \class Analyzer for CIFS v1
3534 * Handles CIFS v1 commands
3635 */
3736 class CIFSBreakdownAnalyzer : virtual public IAnalyzer
3837 {
39 Statistics statistics; //!< Statistics
38 Statistics statistics; //!< Statistics
4039 Representer representer; //!< Class for statistics representation
4140 public:
4241 CIFSBreakdownAnalyzer(std::ostream& o = std::cout);
116115 void writeBulkDataSMBv1(const SMBv1::WriteBulkDataCommand* cmd, const SMBv1::WriteBulkDataArgumentType*, const SMBv1::WriteBulkDataResultType*) override final;
117116 void invalidSMBv1(const SMBv1::InvalidCommand* cmd, const SMBv1::InvalidArgumentType*, const SMBv1::InvalidResultType*) override final;
118117 void noAndxCommandSMBv1(const SMBv1::NoAndxCommand* cmd, const SMBv1::NoAndxCmdArgumentType*, const SMBv1::NoAndxCmdResultType*) override final;
118
119119 protected:
120120 void flush_statistics() override;
121121 };
123123 } // namespace breakdown
124124 } // namespace NST
125125 //------------------------------------------------------------------------------
126 #endif//CIFSBREAKDOWNANALYZER_H
126 #endif //CIFSBREAKDOWNANALYZER_H
127127 //------------------------------------------------------------------------------
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * Represents CIFS v1 commands
3332 * Converts commands to string
3635 {
3736 const char* command_description(int cmd_code) override final;
3837 const char* command_name(int cmd_code) override final;
39 size_t commands_count();
40 const char* protocol_name();
38 size_t commands_count() override final;
39 const char* protocol_name() override final;
4140 };
4241 } // namespace breakdown
4342 } // namespace NST
4443 //------------------------------------------------------------------------------
45 #endif//CIFS_COMMANDS_H
44 #endif //CIFS_COMMANDS_H
4645 //------------------------------------------------------------------------------
3030 {
3131 namespace breakdown
3232 {
33
3433 /*! \class Analyzer for CIFS v2
3534 * Handles CIFS v2 commands
3635 */
3736 class CIFSv2BreakdownAnalyzer : virtual public IAnalyzer
3837 {
39 Statistics stats; //!< Statistics
38 Statistics stats; //!< Statistics
4039 Representer cifs2Representer; //!< Class for statistics representation
4140 public:
4241 CIFSv2BreakdownAnalyzer(std::ostream& o = std::cout);
5958 void queryInfoSMBv2(const SMBv2::QueryInfoCommand* cmd, const SMBv2::QueryInfoRequest*, const SMBv2::QueryInfoResponse*) override final;
6059 void setInfoSMBv2(const SMBv2::SetInfoCommand* cmd, const SMBv2::SetInfoRequest*, const SMBv2::SetInfoResponse*) override final;
6160 void breakOplockSMBv2(const SMBv2::BreakOpLockCommand* cmd, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) override final;
61
6262 protected:
6363 void flush_statistics() override;
6464 };
6666 } // namespace breakdown
6767 } // namespace NST
6868 //------------------------------------------------------------------------------
69 #endif//CIFSV2BREAKDOWNANALYZER_H
69 #endif //CIFSV2BREAKDOWNANALYZER_H
7070 //------------------------------------------------------------------------------
2828 const char* NST::breakdown::SMBv2Commands::command_name(int cmd_code)
2929 {
3030 static std::map<Commands, const char*> cmdNames;
31 if (cmdNames.empty())
31 if(cmdNames.empty())
3232 {
33 cmdNames[Commands::NEGOTIATE] = "NEGOTIATE";
34 cmdNames[Commands::SESSION_SETUP] = "SESSION SETUP";
35 cmdNames[Commands::LOGOFF] = "LOGOFF";
36 cmdNames[Commands::TREE_CONNECT] = "TREE CONNECT";
37 cmdNames[Commands::TREE_DISCONNECT] = "TREE DISCONNECT";
38 cmdNames[Commands::CREATE] = "CREATE";
39 cmdNames[Commands::CLOSE] = "CLOSE";
40 cmdNames[Commands::FLUSH] = "FLUSH";
41 cmdNames[Commands::READ] = "READ";
42 cmdNames[Commands::WRITE] = "WRITE";
43 cmdNames[Commands::LOCK] = "LOCK";
44 cmdNames[Commands::IOCTL] = "IOCTL";
45 cmdNames[Commands::CANCEL] = "CANCEL";
46 cmdNames[Commands::ECHO] = "ECHO";
47 cmdNames[Commands::QUERY_DIRECTORY] = "QUERY DIRECTORY";
48 cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE NOTIFY";
49 cmdNames[Commands::QUERY_INFO] = "QUERY INFO";
50 cmdNames[Commands::SET_INFO] = "SET INFO";
51 cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK BREAK";
33 cmdNames[Commands::NEGOTIATE] = "NEGOTIATE";
34 cmdNames[Commands::SESSION_SETUP] = "SESSION SETUP";
35 cmdNames[Commands::LOGOFF] = "LOGOFF";
36 cmdNames[Commands::TREE_CONNECT] = "TREE CONNECT";
37 cmdNames[Commands::TREE_DISCONNECT] = "TREE DISCONNECT";
38 cmdNames[Commands::CREATE] = "CREATE";
39 cmdNames[Commands::CLOSE] = "CLOSE";
40 cmdNames[Commands::FLUSH] = "FLUSH";
41 cmdNames[Commands::READ] = "READ";
42 cmdNames[Commands::WRITE] = "WRITE";
43 cmdNames[Commands::LOCK] = "LOCK";
44 cmdNames[Commands::IOCTL] = "IOCTL";
45 cmdNames[Commands::CANCEL] = "CANCEL";
46 cmdNames[Commands::ECHO] = "ECHO";
47 cmdNames[Commands::QUERY_DIRECTORY] = "QUERY DIRECTORY";
48 cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE NOTIFY";
49 cmdNames[Commands::QUERY_INFO] = "QUERY INFO";
50 cmdNames[Commands::SET_INFO] = "SET INFO";
51 cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK BREAK";
5252 }
5353 return cmdNames[static_cast<Commands>(cmd_code)];
5454 }
6161 const char* NST::breakdown::SMBv2Commands::command_description(int cmd_code)
6262 {
6363 static std::map<Commands, const char*> cmdNames;
64 if (cmdNames.empty())
64 if(cmdNames.empty())
6565 {
66 cmdNames[Commands::NEGOTIATE] = "NEGOTIATE";
67 cmdNames[Commands::SESSION_SETUP] = "SESSION_SETUP";
68 cmdNames[Commands::LOGOFF] = "LOGOFF";
69 cmdNames[Commands::TREE_CONNECT] = "TREE_CONNECT";
70 cmdNames[Commands::TREE_DISCONNECT] = "TREE_DISCONNECT";
71 cmdNames[Commands::CREATE] = "CREATE";
72 cmdNames[Commands::CLOSE] = "CLOSE";
73 cmdNames[Commands::FLUSH] = "FLUSH";
74 cmdNames[Commands::READ] = "READ";
75 cmdNames[Commands::WRITE] = "WRITE";
76 cmdNames[Commands::LOCK] = "LOCK";
77 cmdNames[Commands::IOCTL] = "IOCTL";
78 cmdNames[Commands::CANCEL] = "CANCEL";
79 cmdNames[Commands::ECHO] = "ECHO";
80 cmdNames[Commands::QUERY_DIRECTORY] = "QUERY_DIRECTORY";
81 cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE_NOTIFY";
82 cmdNames[Commands::QUERY_INFO] = "QUERY_INFO";
83 cmdNames[Commands::SET_INFO] = "SET_INFO";
84 cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK_BREAK";
66 cmdNames[Commands::NEGOTIATE] = "NEGOTIATE";
67 cmdNames[Commands::SESSION_SETUP] = "SESSION_SETUP";
68 cmdNames[Commands::LOGOFF] = "LOGOFF";
69 cmdNames[Commands::TREE_CONNECT] = "TREE_CONNECT";
70 cmdNames[Commands::TREE_DISCONNECT] = "TREE_DISCONNECT";
71 cmdNames[Commands::CREATE] = "CREATE";
72 cmdNames[Commands::CLOSE] = "CLOSE";
73 cmdNames[Commands::FLUSH] = "FLUSH";
74 cmdNames[Commands::READ] = "READ";
75 cmdNames[Commands::WRITE] = "WRITE";
76 cmdNames[Commands::LOCK] = "LOCK";
77 cmdNames[Commands::IOCTL] = "IOCTL";
78 cmdNames[Commands::CANCEL] = "CANCEL";
79 cmdNames[Commands::ECHO] = "ECHO";
80 cmdNames[Commands::QUERY_DIRECTORY] = "QUERY_DIRECTORY";
81 cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE_NOTIFY";
82 cmdNames[Commands::QUERY_INFO] = "QUERY_INFO";
83 cmdNames[Commands::SET_INFO] = "SET_INFO";
84 cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK_BREAK";
8585 }
8686 return cmdNames[static_cast<Commands>(cmd_code)];
8787 }
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * Represents CIFS v2 commands
3332 * Converts commands to string
6564
6665 const char* command_name(int cmd_code) override final;
6766
68 size_t commands_count();
67 size_t commands_count() override final;
6968
70 const char* protocol_name();
69 const char* protocol_name() override final;
7170 };
7271
7372 } // namespace breakdown
7473 } // namespace NST
7574 //------------------------------------------------------------------------------
76 #endif//CIFS2_COMMANDS_H
75 #endif //CIFS2_COMMANDS_H
7776 //------------------------------------------------------------------------------
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * \brief The CommandRepresenter struct represents interface for command representers
3332 * Commands representer should be able to convert commands to string
6665 } // namespace breakdown
6766 } // namespace NST
6867 //------------------------------------------------------------------------------
69 #endif//COMMANDREPRESENTER_H
68 #endif //COMMANDREPRESENTER_H
7069 //------------------------------------------------------------------------------
2525 using namespace NST::breakdown;
2626 //------------------------------------------------------------------------------
2727
28 Latencies::Latencies() : count {0}, avg {0}, m2 {0}
28 Latencies::Latencies()
29 : count{0}
30 , avg{0}
31 , m2{0}
2932 {
3033 timerclear(&min);
3134 timerclear(&max);
3336
3437 void Latencies::add(const timeval& t)
3538 {
36 long double x = to_sec(t);
39 long double x = to_sec(t);
3740 long double delta = x - avg;
3841 avg += delta / (++count);
3942 m2 += delta * (x - avg);
5356
5457 long double Latencies::get_st_dev() const
5558 {
56 if (count < 2)
59 if(count < 2)
5760 {
5861 return 0;
5962 }
7275
7376 void Latencies::set_range(const timeval& t)
7477 {
75 if (timercmp(&t, &min, < ))
78 if(timercmp(&t, &min, <))
7679 {
7780 min = t;
7881 }
79 if (min.tv_sec == 0 && min.tv_usec == 0)
82 if(min.tv_sec == 0 && min.tv_usec == 0)
8083 {
8184 min = t;
8285 }
83 if (timercmp(&t, &max, > ))
86 if(timercmp(&t, &max, >))
8487 {
8588 max = t;
8689 }
2929 {
3030 namespace breakdown
3131 {
32
3332 /*!
3433 * \brief Latencies calculates latencies
3534 */
8180 timeval min;
8281 timeval max;
8382
84 uint64_t count;
83 uint64_t count;
8584 long double avg;
8685 long double m2;
8786 };
9695 } // namespace breakdown
9796 } // namespace NST
9897 //------------------------------------------------------------------------------
99 #endif//LATENCIES_H
98 #endif //LATENCIES_H
10099 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include "nfsv3breakdownanalyzer.h"
2122 #include "breakdowncounter.h"
22 #include "nfsv3breakdownanalyzer.h"
2323 #include "nfsv3commands.h"
2424 //------------------------------------------------------------------------------
2525 using namespace NST::breakdown;
100100 stats.account(proc, proc->call.ru.RM_cmb.cb_proc);
101101 }
102102
103
104103 void NFSv3BreakdownAnalyzer::rename3(const RPCProcedure* proc, const NFS3::RENAME3args*, const NFS3::RENAME3res*)
105104 {
106105 stats.account(proc, proc->call.ru.RM_cmb.cb_proc);
3030 {
3131 namespace breakdown
3232 {
33
3433 /*! \brief NFSv3BreakdownAnalyzer Analyzer for NFS v3
3534 * Handles NFS v3 commands
3635 */
3736 class NFSv3BreakdownAnalyzer : virtual public IAnalyzer
3837 {
39 Statistics stats; //!< Statistics
38 Statistics stats; //!< Statistics
4039 Representer representer; //!< Class for statistics representation
4140 public:
4241 NFSv3BreakdownAnalyzer(std::ostream& o = std::cout);
114113 } // namespace breakdown
115114 } // namespace NST
116115 //------------------------------------------------------------------------------
117 #endif//NFSV3BREAKDOWNANALYZER_H
116 #endif //NFSV3BREAKDOWNANALYZER_H
118117 //------------------------------------------------------------------------------
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * Represents NFS v3 commands
3332 * Converts commands to string
3736 public:
3837 const char* command_description(int cmd_code) override final;
3938 const char* command_name(int cmd_code) override final;
40 size_t commands_count() override final;
41 const char* protocol_name();
39 size_t commands_count() override final;
40 const char* protocol_name() override final;
4241 };
4342
4443 } // namespace breakdown
4544 } // namespace NST
4645 //------------------------------------------------------------------------------
47 #endif//NFSV3COMMANDS_H
46 #endif //NFSV3COMMANDS_H
4847 //------------------------------------------------------------------------------
4141
4242 void NFSv41BreakdownAnalyzer::access41(const RPCProcedure* proc, const NFS41::ACCESS4args*, const NFS41::ACCESS4res* res)
4343 {
44 if (res)
44 if(res)
4545 {
4646 stats.account(proc, ProcEnumNFS41::NFSProcedure::ACCESS);
4747 }
4949
5050 void NFSv41BreakdownAnalyzer::close41(const RPCProcedure* proc, const NFS41::CLOSE4args*, const NFS41::CLOSE4res* res)
5151 {
52 if (res)
52 if(res)
5353 {
5454 stats.account(proc, ProcEnumNFS41::NFSProcedure::CLOSE);
5555 }
5757
5858 void NFSv41BreakdownAnalyzer::commit41(const RPCProcedure* proc, const NFS41::COMMIT4args*, const NFS41::COMMIT4res* res)
5959 {
60 if (res)
60 if(res)
6161 {
6262 stats.account(proc, ProcEnumNFS41::NFSProcedure::COMMIT);
6363 }
6565
6666 void NFSv41BreakdownAnalyzer::create41(const RPCProcedure* proc, const NFS41::CREATE4args*, const NFS41::CREATE4res* res)
6767 {
68 if (res)
68 if(res)
6969 {
7070 stats.account(proc, ProcEnumNFS41::NFSProcedure::CREATE);
7171 }
7373
7474 void NFSv41BreakdownAnalyzer::delegpurge41(const RPCProcedure* proc, const NFS41::DELEGPURGE4args*, const NFS41::DELEGPURGE4res* res)
7575 {
76 if (res)
76 if(res)
7777 {
7878 stats.account(proc, ProcEnumNFS41::NFSProcedure::DELEGPURGE);
7979 }
8181
8282 void NFSv41BreakdownAnalyzer::delegreturn41(const RPCProcedure* proc, const NFS41::DELEGRETURN4args*, const NFS41::DELEGRETURN4res* res)
8383 {
84 if (res)
84 if(res)
8585 {
8686 stats.account(proc, ProcEnumNFS41::NFSProcedure::DELEGRETURN);
8787 }
8989
9090 void NFSv41BreakdownAnalyzer::getattr41(const RPCProcedure* proc, const NFS41::GETATTR4args*, const NFS41::GETATTR4res* res)
9191 {
92 if (res)
92 if(res)
9393 {
9494 stats.account(proc, ProcEnumNFS41::NFSProcedure::GETATTR);
9595 }
9797
9898 void NFSv41BreakdownAnalyzer::getfh41(const RPCProcedure* proc, const NFS41::GETFH4res* res)
9999 {
100 if (res)
100 if(res)
101101 {
102102 stats.account(proc, ProcEnumNFS41::NFSProcedure::GETFH);
103103 }
105105
106106 void NFSv41BreakdownAnalyzer::link41(const RPCProcedure* proc, const NFS41::LINK4args*, const NFS41::LINK4res* res)
107107 {
108 if (res)
108 if(res)
109109 {
110110 stats.account(proc, ProcEnumNFS41::NFSProcedure::LINK);
111111 }
113113
114114 void NFSv41BreakdownAnalyzer::lock41(const RPCProcedure* proc, const NFS41::LOCK4args*, const NFS41::LOCK4res* res)
115115 {
116 if (res)
116 if(res)
117117 {
118118 stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCK);
119119 }
121121
122122 void NFSv41BreakdownAnalyzer::lockt41(const RPCProcedure* proc, const NFS41::LOCKT4args*, const NFS41::LOCKT4res* res)
123123 {
124 if (res)
124 if(res)
125125 {
126126 stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCKT);
127127 }
129129
130130 void NFSv41BreakdownAnalyzer::locku41(const RPCProcedure* proc, const NFS41::LOCKU4args*, const NFS41::LOCKU4res* res)
131131 {
132 if (res)
132 if(res)
133133 {
134134 stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCKU);
135135 }
137137
138138 void NFSv41BreakdownAnalyzer::lookup41(const RPCProcedure* proc, const NFS41::LOOKUP4args*, const NFS41::LOOKUP4res* res)
139139 {
140 if (res)
140 if(res)
141141 {
142142 stats.account(proc, ProcEnumNFS41::NFSProcedure::LOOKUP);
143143 }
145145
146146 void NFSv41BreakdownAnalyzer::lookupp41(const RPCProcedure* proc, const NFS41::LOOKUPP4res* res)
147147 {
148 if (res)
148 if(res)
149149 {
150150 stats.account(proc, ProcEnumNFS41::NFSProcedure::LOOKUPP);
151151 }
153153
154154 void NFSv41BreakdownAnalyzer::nverify41(const RPCProcedure* proc, const NFS41::NVERIFY4args*, const NFS41::NVERIFY4res* res)
155155 {
156 if (res)
156 if(res)
157157 {
158158 stats.account(proc, ProcEnumNFS41::NFSProcedure::NVERIFY);
159159 }
161161
162162 void NFSv41BreakdownAnalyzer::open41(const RPCProcedure* proc, const NFS41::OPEN4args*, const NFS41::OPEN4res* res)
163163 {
164 if (res)
164 if(res)
165165 {
166166 stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN);
167167 }
169169
170170 void NFSv41BreakdownAnalyzer::openattr41(const RPCProcedure* proc, const NFS41::OPENATTR4args*, const NFS41::OPENATTR4res* res)
171171 {
172 if (res)
172 if(res)
173173 {
174174 stats.account(proc, ProcEnumNFS41::NFSProcedure::OPENATTR);
175175 }
177177
178178 void NFSv41BreakdownAnalyzer::open_confirm41(const RPCProcedure* proc, const NFS41::OPEN_CONFIRM4args*, const NFS41::OPEN_CONFIRM4res* res)
179179 {
180 if (res)
180 if(res)
181181 {
182182 stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN_CONFIRM);
183183 }
185185
186186 void NFSv41BreakdownAnalyzer::open_downgrade41(const RPCProcedure* proc, const NFS41::OPEN_DOWNGRADE4args*, const NFS41::OPEN_DOWNGRADE4res* res)
187187 {
188 if (res)
188 if(res)
189189 {
190190 stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN_DOWNGRADE);
191191 }
193193
194194 void NFSv41BreakdownAnalyzer::putfh41(const RPCProcedure* proc, const NFS41::PUTFH4args*, const NFS41::PUTFH4res* res)
195195 {
196 if (res)
196 if(res)
197197 {
198198 stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTFH);
199199 }
201201
202202 void NFSv41BreakdownAnalyzer::putpubfh41(const RPCProcedure* proc, const NFS41::PUTPUBFH4res* res)
203203 {
204 if (res)
204 if(res)
205205 {
206206 stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTPUBFH);
207207 }
209209
210210 void NFSv41BreakdownAnalyzer::putrootfh41(const RPCProcedure* proc, const NFS41::PUTROOTFH4res* res)
211211 {
212 if (res)
212 if(res)
213213 {
214214 stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTROOTFH);
215215 }
217217
218218 void NFSv41BreakdownAnalyzer::read41(const RPCProcedure* proc, const NFS41::READ4args*, const NFS41::READ4res* res)
219219 {
220 if (res)
220 if(res)
221221 {
222222 stats.account(proc, ProcEnumNFS41::NFSProcedure::READ);
223223 }
225225
226226 void NFSv41BreakdownAnalyzer::readdir41(const RPCProcedure* proc, const NFS41::READDIR4args*, const NFS41::READDIR4res* res)
227227 {
228 if (res)
228 if(res)
229229 {
230230 stats.account(proc, ProcEnumNFS41::NFSProcedure::READDIR);
231231 }
233233
234234 void NFSv41BreakdownAnalyzer::readlink41(const RPCProcedure* proc, const NFS41::READLINK4res* res)
235235 {
236 if (res)
236 if(res)
237237 {
238238 stats.account(proc, ProcEnumNFS41::NFSProcedure::READLINK);
239239 }
241241
242242 void NFSv41BreakdownAnalyzer::remove41(const RPCProcedure* proc, const NFS41::REMOVE4args*, const NFS41::REMOVE4res* res)
243243 {
244 if (res)
244 if(res)
245245 {
246246 stats.account(proc, ProcEnumNFS41::NFSProcedure::REMOVE);
247247 }
249249
250250 void NFSv41BreakdownAnalyzer::rename41(const RPCProcedure* proc, const NFS41::RENAME4args*, const NFS41::RENAME4res* res)
251251 {
252 if (res)
252 if(res)
253253 {
254254 stats.account(proc, ProcEnumNFS41::NFSProcedure::RENAME);
255255 }
257257
258258 void NFSv41BreakdownAnalyzer::renew41(const RPCProcedure* proc, const NFS41::RENEW4args*, const NFS41::RENEW4res* res)
259259 {
260 if (res)
260 if(res)
261261 {
262262 stats.account(proc, ProcEnumNFS41::NFSProcedure::RENEW);
263263 }
265265
266266 void NFSv41BreakdownAnalyzer::restorefh41(const RPCProcedure* proc, const NFS41::RESTOREFH4res* res)
267267 {
268 if (res)
268 if(res)
269269 {
270270 stats.account(proc, ProcEnumNFS41::NFSProcedure::RESTOREFH);
271271 }
273273
274274 void NFSv41BreakdownAnalyzer::savefh41(const RPCProcedure* proc, const NFS41::SAVEFH4res* res)
275275 {
276 if (res)
276 if(res)
277277 {
278278 stats.account(proc, ProcEnumNFS41::NFSProcedure::SAVEFH);
279279 }
281281
282282 void NFSv41BreakdownAnalyzer::secinfo41(const RPCProcedure* proc, const NFS41::SECINFO4args*, const NFS41::SECINFO4res* res)
283283 {
284 if (res)
284 if(res)
285285 {
286286 stats.account(proc, ProcEnumNFS41::NFSProcedure::SECINFO);
287287 }
289289
290290 void NFSv41BreakdownAnalyzer::setattr41(const RPCProcedure* proc, const NFS41::SETATTR4args*, const NFS41::SETATTR4res* res)
291291 {
292 if (res)
292 if(res)
293293 {
294294 stats.account(proc, ProcEnumNFS41::NFSProcedure::SETATTR);
295295 }
297297
298298 void NFSv41BreakdownAnalyzer::setclientid41(const RPCProcedure* proc, const NFS41::SETCLIENTID4args*, const NFS41::SETCLIENTID4res* res)
299299 {
300 if (res)
300 if(res)
301301 {
302302 stats.account(proc, ProcEnumNFS41::NFSProcedure::SETCLIENTID);
303303 }
305305
306306 void NFSv41BreakdownAnalyzer::setclientid_confirm41(const RPCProcedure* proc, const NFS41::SETCLIENTID_CONFIRM4args*, const NFS41::SETCLIENTID_CONFIRM4res* res)
307307 {
308 if (res)
308 if(res)
309309 {
310310 stats.account(proc, ProcEnumNFS41::NFSProcedure::SETCLIENTID_CONFIRM);
311311 }
313313
314314 void NFSv41BreakdownAnalyzer::verify41(const RPCProcedure* proc, const NFS41::VERIFY4args*, const NFS41::VERIFY4res* res)
315315 {
316 if (res)
316 if(res)
317317 {
318318 stats.account(proc, ProcEnumNFS41::NFSProcedure::VERIFY);
319319 }
321321
322322 void NFSv41BreakdownAnalyzer::write41(const RPCProcedure* proc, const NFS41::WRITE4args*, const NFS41::WRITE4res* res)
323323 {
324 if (res)
324 if(res)
325325 {
326326 stats.account(proc, ProcEnumNFS41::NFSProcedure::WRITE);
327327 }
329329
330330 void NFSv41BreakdownAnalyzer::release_lockowner41(const RPCProcedure* proc, const NFS41::RELEASE_LOCKOWNER4args*, const NFS41::RELEASE_LOCKOWNER4res* res)
331331 {
332 if (res)
332 if(res)
333333 {
334334 stats.account(proc, ProcEnumNFS41::NFSProcedure::RELEASE_LOCKOWNER);
335335 }
337337
338338 void NFSv41BreakdownAnalyzer::backchannel_ctl41(const RPCProcedure* proc, const NFS41::BACKCHANNEL_CTL4args*, const NFS41::BACKCHANNEL_CTL4res* res)
339339 {
340 if (res)
340 if(res)
341341 {
342342 stats.account(proc, ProcEnumNFS41::NFSProcedure::BACKCHANNEL_CTL);
343343 }
345345
346346 void NFSv41BreakdownAnalyzer::bind_conn_to_session41(const RPCProcedure* proc, const NFS41::BIND_CONN_TO_SESSION4args*, const NFS41::BIND_CONN_TO_SESSION4res* res)
347347 {
348 if (res)
348 if(res)
349349 {
350350 stats.account(proc, ProcEnumNFS41::NFSProcedure::BIND_CONN_TO_SESSION);
351351 }
353353
354354 void NFSv41BreakdownAnalyzer::exchange_id41(const RPCProcedure* proc, const NFS41::EXCHANGE_ID4args*, const NFS41::EXCHANGE_ID4res* res)
355355 {
356 if (res)
356 if(res)
357357 {
358358 stats.account(proc, ProcEnumNFS41::NFSProcedure::EXCHANGE_ID);
359359 }
361361
362362 void NFSv41BreakdownAnalyzer::create_session41(const RPCProcedure* proc, const NFS41::CREATE_SESSION4args*, const NFS41::CREATE_SESSION4res* res)
363363 {
364 if (res)
364 if(res)
365365 {
366366 stats.account(proc, ProcEnumNFS41::NFSProcedure::CREATE_SESSION);
367367 }
369369
370370 void NFSv41BreakdownAnalyzer::destroy_session41(const RPCProcedure* proc, const NFS41::DESTROY_SESSION4args*, const NFS41::DESTROY_SESSION4res* res)
371371 {
372 if (res)
372 if(res)
373373 {
374374 stats.account(proc, ProcEnumNFS41::NFSProcedure::DESTROY_SESSION);
375375 }
377377
378378 void NFSv41BreakdownAnalyzer::free_stateid41(const RPCProcedure* proc, const NFS41::FREE_STATEID4args*, const NFS41::FREE_STATEID4res* res)
379379 {
380 if (res)
380 if(res)
381381 {
382382 stats.account(proc, ProcEnumNFS41::NFSProcedure::FREE_STATEID);
383383 }
385385
386386 void NFSv41BreakdownAnalyzer::get_dir_delegation41(const RPCProcedure* proc, const NFS41::GET_DIR_DELEGATION4args*, const NFS41::GET_DIR_DELEGATION4res* res)
387387 {
388 if (res)
388 if(res)
389389 {
390390 stats.account(proc, ProcEnumNFS41::NFSProcedure::GET_DIR_DELEGATION);
391391 }
393393
394394 void NFSv41BreakdownAnalyzer::getdeviceinfo41(const RPCProcedure* proc, const NFS41::GETDEVICEINFO4args*, const NFS41::GETDEVICEINFO4res* res)
395395 {
396 if (res)
396 if(res)
397397 {
398398 stats.account(proc, ProcEnumNFS41::NFSProcedure::GETDEVICEINFO);
399399 }
401401
402402 void NFSv41BreakdownAnalyzer::getdevicelist41(const RPCProcedure* proc, const NFS41::GETDEVICELIST4args*, const NFS41::GETDEVICELIST4res* res)
403403 {
404 if (res)
404 if(res)
405405 {
406406 stats.account(proc, ProcEnumNFS41::NFSProcedure::GETDEVICELIST);
407407 }
409409
410410 void NFSv41BreakdownAnalyzer::layoutcommit41(const RPCProcedure* proc, const NFS41::LAYOUTCOMMIT4args*, const NFS41::LAYOUTCOMMIT4res* res)
411411 {
412 if (res)
412 if(res)
413413 {
414414 stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTCOMMIT);
415415 }
417417
418418 void NFSv41BreakdownAnalyzer::layoutget41(const RPCProcedure* proc, const NFS41::LAYOUTGET4args*, const NFS41::LAYOUTGET4res* res)
419419 {
420 if (res)
420 if(res)
421421 {
422422 stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTGET);
423423 }
425425
426426 void NFSv41BreakdownAnalyzer::layoutreturn41(const RPCProcedure* proc, const NFS41::LAYOUTRETURN4args*, const NFS41::LAYOUTRETURN4res* res)
427427 {
428 if (res)
428 if(res)
429429 {
430430 stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTRETURN);
431431 }
433433
434434 void NFSv41BreakdownAnalyzer::secinfo_no_name41(const RPCProcedure* proc, const NFS41::SECINFO_NO_NAME4args*, const NFS41::SECINFO_NO_NAME4res* res)
435435 {
436 if (res)
436 if(res)
437437 {
438438 stats.account(proc, ProcEnumNFS41::NFSProcedure::SECINFO_NO_NAME);
439439 }
441441
442442 void NFSv41BreakdownAnalyzer::sequence41(const RPCProcedure* proc, const NFS41::SEQUENCE4args*, const NFS41::SEQUENCE4res* res)
443443 {
444 if (res)
444 if(res)
445445 {
446446 stats.account(proc, ProcEnumNFS41::NFSProcedure::SEQUENCE);
447447 }
449449
450450 void NFSv41BreakdownAnalyzer::set_ssv41(const RPCProcedure* proc, const NFS41::SET_SSV4args*, const NFS41::SET_SSV4res* res)
451451 {
452 if (res)
452 if(res)
453453 {
454454 stats.account(proc, ProcEnumNFS41::NFSProcedure::SET_SSV);
455455 }
457457
458458 void NFSv41BreakdownAnalyzer::test_stateid41(const RPCProcedure* proc, const NFS41::TEST_STATEID4args*, const NFS41::TEST_STATEID4res* res)
459459 {
460 if (res)
460 if(res)
461461 {
462462 stats.account(proc, ProcEnumNFS41::NFSProcedure::TEST_STATEID);
463463 }
465465
466466 void NFSv41BreakdownAnalyzer::want_delegation41(const RPCProcedure* proc, const NFS41::WANT_DELEGATION4args*, const NFS41::WANT_DELEGATION4res* res)
467467 {
468 if (res)
468 if(res)
469469 {
470470 stats.account(proc, ProcEnumNFS41::NFSProcedure::WANT_DELEGATION);
471471 }
473473
474474 void NFSv41BreakdownAnalyzer::destroy_clientid41(const RPCProcedure* proc, const NFS41::DESTROY_CLIENTID4args*, const NFS41::DESTROY_CLIENTID4res* res)
475475 {
476 if (res)
476 if(res)
477477 {
478478 stats.account(proc, ProcEnumNFS41::NFSProcedure::DESTROY_CLIENTID);
479479 }
481481
482482 void NFSv41BreakdownAnalyzer::reclaim_complete41(const RPCProcedure* proc, const NFS41::RECLAIM_COMPLETE4args*, const NFS41::RECLAIM_COMPLETE4res* res)
483483 {
484 if (res)
484 if(res)
485485 {
486486 stats.account(proc, ProcEnumNFS41::NFSProcedure::RECLAIM_COMPLETE);
487487 }
489489
490490 void NFSv41BreakdownAnalyzer::illegal41(const RPCProcedure* proc, const NFS41::ILLEGAL4res* res)
491491 {
492 if (res)
492 if(res)
493493 {
494494 stats.account(proc, ProcEnumNFS41::NFSProcedure::ILLEGAL);
495495 }
3030 {
3131 namespace breakdown
3232 {
33
3433 /*! \brief Analyzer for NFS v4.1
3534 * Handles NFS v4.1 commands
3635 */
3736 class NFSv41BreakdownAnalyzer : virtual public IAnalyzer
3837 {
39 Statistics compound_stats; //!< Statistics
40 Statistics stats; //!< Statistics
41 NFSv4Representer representer; //!< Class for statistics representation
38 Statistics compound_stats; //!< Statistics
39 Statistics stats; //!< Statistics
40 NFSv4Representer representer; //!< Class for statistics representation
4241 public:
4342 NFSv41BreakdownAnalyzer(std::ostream& o = std::cout);
4443 // NFSv4.1 procedures
45 void compound41(const RPCProcedure* proc,
44 void compound41(const RPCProcedure* proc,
4645 const struct NFS41::COMPOUND4args*,
4746 const struct NFS41::COMPOUND4res*) override final;
4847 // NFSv4.1 operations
6867 void getattr41(const RPCProcedure* proc,
6968 const struct NFS41::GETATTR4args*,
7069 const struct NFS41::GETATTR4res* res) override final;
71 void getfh41(const RPCProcedure* proc,
70 void getfh41(const RPCProcedure* proc,
7271 const struct NFS41::GETFH4res* res) override final;
7372 void link41(const RPCProcedure* proc,
7473 const struct NFS41::LINK4args*,
8584 void lookup41(const RPCProcedure* proc,
8685 const struct NFS41::LOOKUP4args*,
8786 const struct NFS41::LOOKUP4res* res) override final;
88 void lookupp41(const RPCProcedure* proc,
87 void lookupp41(const RPCProcedure* proc,
8988 const struct NFS41::LOOKUPP4res* res) override final;
9089 void nverify41(const RPCProcedure* proc,
9190 const struct NFS41::NVERIFY4args*,
105104 void putfh41(const RPCProcedure* proc,
106105 const struct NFS41::PUTFH4args*,
107106 const struct NFS41::PUTFH4res* res) override final;
108 void putpubfh41(const RPCProcedure* proc,
107 void putpubfh41(const RPCProcedure* proc,
109108 const struct NFS41::PUTPUBFH4res* res) override final;
110 void putrootfh41(const RPCProcedure* proc,
109 void putrootfh41(const RPCProcedure* proc,
111110 const struct NFS41::PUTROOTFH4res* res) override final;
112111 void read41(const RPCProcedure* proc,
113112 const struct NFS41::READ4args*,
115114 void readdir41(const RPCProcedure* proc,
116115 const struct NFS41::READDIR4args*,
117116 const struct NFS41::READDIR4res* res) override final;
118 void readlink41(const RPCProcedure* proc,
117 void readlink41(const RPCProcedure* proc,
119118 const struct NFS41::READLINK4res* res) override final;
120119 void remove41(const RPCProcedure* proc,
121120 const struct NFS41::REMOVE4args*,
126125 void renew41(const RPCProcedure* proc,
127126 const struct NFS41::RENEW4args*,
128127 const struct NFS41::RENEW4res* res) override final;
129 void restorefh41(const RPCProcedure* proc,
128 void restorefh41(const RPCProcedure* proc,
130129 const struct NFS41::RESTOREFH4res* res) override final;
131 void savefh41(const RPCProcedure* proc,
130 void savefh41(const RPCProcedure* proc,
132131 const struct NFS41::SAVEFH4res* res) override final;
133132 void secinfo41(const RPCProcedure* proc,
134133 const struct NFS41::SECINFO4args*,
208207 void reclaim_complete41(const RPCProcedure* proc,
209208 const struct NFS41::RECLAIM_COMPLETE4args*,
210209 const struct NFS41::RECLAIM_COMPLETE4res* res) override final;
211 void illegal41(const RPCProcedure* proc,
210 void illegal41(const RPCProcedure* proc,
212211 const struct NFS41::ILLEGAL4res* res) override final;
213212
214213 void flush_statistics() override;
217216 } // namespace protocols
218217 } // namespace NST
219218 //------------------------------------------------------------------------------
220 #endif//NFSV41BREAKDOWNANALYZER_H
221 //------------------------------------------------------------------------------
219 #endif //NFSV41BREAKDOWNANALYZER_H
220 //------------------------------------------------------------------------------
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * Represents NFS v 4.0 commands
3332 * Converts commands to string
3837 const char* command_description(int cmd_code);
3938 const char* command_name(int cmd_code);
4039 const char* protocol_name();
41 size_t commands_count();
40 size_t commands_count();
4241 };
4342
4443 } // namespace breakdown
4544 } // namespace NST
4645 //------------------------------------------------------------------------------
47 #endif//NFSV41COMMANDS_H
46 #endif //NFSV41COMMANDS_H
4847 //------------------------------------------------------------------------------
4848
4949 void NFSv4BreakdownAnalyzer::access40(const RPCProcedure* proc, const NFS4::ACCESS4args*, const NFS4::ACCESS4res* res)
5050 {
51 if (res)
51 if(res)
5252 {
5353 stats.account(proc, ProcEnumNFS4::NFSProcedure::ACCESS);
5454 }
5656
5757 void NFSv4BreakdownAnalyzer::close40(const RPCProcedure* proc, const NFS4::CLOSE4args*, const NFS4::CLOSE4res* res)
5858 {
59 if (res)
59 if(res)
6060 {
6161 stats.account(proc, ProcEnumNFS4::NFSProcedure::CLOSE);
6262 }
6464
6565 void NFSv4BreakdownAnalyzer::commit40(const RPCProcedure* proc, const NFS4::COMMIT4args*, const NFS4::COMMIT4res* res)
6666 {
67 if (res)
67 if(res)
6868 {
6969 stats.account(proc, ProcEnumNFS4::NFSProcedure::COMMIT);
7070 }
7272
7373 void NFSv4BreakdownAnalyzer::create40(const RPCProcedure* proc, const NFS4::CREATE4args*, const NFS4::CREATE4res* res)
7474 {
75 if (res)
75 if(res)
7676 {
7777 stats.account(proc, ProcEnumNFS4::NFSProcedure::CREATE);
7878 }
8080
8181 void NFSv4BreakdownAnalyzer::delegpurge40(const RPCProcedure* proc, const NFS4::DELEGPURGE4args*, const NFS4::DELEGPURGE4res* res)
8282 {
83 if (res)
83 if(res)
8484 {
8585 stats.account(proc, ProcEnumNFS4::NFSProcedure::DELEGPURGE);
8686 }
8888
8989 void NFSv4BreakdownAnalyzer::delegreturn40(const RPCProcedure* proc, const NFS4::DELEGRETURN4args*, const NFS4::DELEGRETURN4res* res)
9090 {
91 if (res)
91 if(res)
9292 {
9393 stats.account(proc, ProcEnumNFS4::NFSProcedure::DELEGRETURN);
9494 }
9696
9797 void NFSv4BreakdownAnalyzer::getattr40(const RPCProcedure* proc, const NFS4::GETATTR4args*, const NFS4::GETATTR4res* res)
9898 {
99 if (res)
99 if(res)
100100 {
101101 stats.account(proc, ProcEnumNFS4::NFSProcedure::GETATTR);
102102 }
104104
105105 void NFSv4BreakdownAnalyzer::getfh40(const RPCProcedure* proc, const NFS4::GETFH4res* res)
106106 {
107 if (res)
107 if(res)
108108 {
109109 stats.account(proc, ProcEnumNFS4::NFSProcedure::GETFH);
110110 }
112112
113113 void NFSv4BreakdownAnalyzer::link40(const RPCProcedure* proc, const NFS4::LINK4args*, const NFS4::LINK4res* res)
114114 {
115 if (res)
115 if(res)
116116 {
117117 stats.account(proc, ProcEnumNFS4::NFSProcedure::LINK);
118118 }
120120
121121 void NFSv4BreakdownAnalyzer::lock40(const RPCProcedure* proc, const NFS4::LOCK4args*, const NFS4::LOCK4res* res)
122122 {
123 if (res)
123 if(res)
124124 {
125125 stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCK);
126126 }
128128
129129 void NFSv4BreakdownAnalyzer::lockt40(const RPCProcedure* proc, const NFS4::LOCKT4args*, const NFS4::LOCKT4res* res)
130130 {
131 if (res)
131 if(res)
132132 {
133133 stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCKT);
134134 }
136136
137137 void NFSv4BreakdownAnalyzer::locku40(const RPCProcedure* proc, const NFS4::LOCKU4args*, const NFS4::LOCKU4res* res)
138138 {
139 if (res)
139 if(res)
140140 {
141141 stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCKU);
142142 }
144144
145145 void NFSv4BreakdownAnalyzer::lookup40(const RPCProcedure* proc, const NFS4::LOOKUP4args*, const NFS4::LOOKUP4res* res)
146146 {
147 if (res)
147 if(res)
148148 {
149149 stats.account(proc, ProcEnumNFS4::NFSProcedure::LOOKUP);
150150 }
152152
153153 void NFSv4BreakdownAnalyzer::lookupp40(const RPCProcedure* proc, const NFS4::LOOKUPP4res* res)
154154 {
155 if (res)
155 if(res)
156156 {
157157 stats.account(proc, ProcEnumNFS4::NFSProcedure::LOOKUPP);
158158 }
160160
161161 void NFSv4BreakdownAnalyzer::nverify40(const RPCProcedure* proc, const NFS4::NVERIFY4args*, const NFS4::NVERIFY4res* res)
162162 {
163 if (res)
163 if(res)
164164 {
165165 stats.account(proc, ProcEnumNFS4::NFSProcedure::NVERIFY);
166166 }
168168
169169 void NFSv4BreakdownAnalyzer::open40(const RPCProcedure* proc, const NFS4::OPEN4args*, const NFS4::OPEN4res* res)
170170 {
171 if (res)
171 if(res)
172172 {
173173 stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN);
174174 }
176176
177177 void NFSv4BreakdownAnalyzer::openattr40(const RPCProcedure* proc, const NFS4::OPENATTR4args*, const NFS4::OPENATTR4res* res)
178178 {
179 if (res)
179 if(res)
180180 {
181181 stats.account(proc, ProcEnumNFS4::NFSProcedure::OPENATTR);
182182 }
184184
185185 void NFSv4BreakdownAnalyzer::open_confirm40(const RPCProcedure* proc, const NFS4::OPEN_CONFIRM4args*, const NFS4::OPEN_CONFIRM4res* res)
186186 {
187 if (res)
187 if(res)
188188 {
189189 stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN_CONFIRM);
190190 }
192192
193193 void NFSv4BreakdownAnalyzer::open_downgrade40(const RPCProcedure* proc, const NFS4::OPEN_DOWNGRADE4args*, const NFS4::OPEN_DOWNGRADE4res* res)
194194 {
195 if (res)
195 if(res)
196196 {
197197 stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN_DOWNGRADE);
198198 }
200200
201201 void NFSv4BreakdownAnalyzer::putfh40(const RPCProcedure* proc, const NFS4::PUTFH4args*, const NFS4::PUTFH4res* res)
202202 {
203 if (res)
203 if(res)
204204 {
205205 stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTFH);
206206 }
208208
209209 void NFSv4BreakdownAnalyzer::putpubfh40(const RPCProcedure* proc, const NFS4::PUTPUBFH4res* res)
210210 {
211 if (res)
211 if(res)
212212 {
213213 stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTPUBFH);
214214 }
216216
217217 void NFSv4BreakdownAnalyzer::putrootfh40(const RPCProcedure* proc, const NFS4::PUTROOTFH4res* res)
218218 {
219 if (res)
219 if(res)
220220 {
221221 stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTROOTFH);
222222 }
224224
225225 void NFSv4BreakdownAnalyzer::read40(const RPCProcedure* proc, const NFS4::READ4args*, const NFS4::READ4res* res)
226226 {
227 if (res)
227 if(res)
228228 {
229229 stats.account(proc, ProcEnumNFS4::NFSProcedure::READ);
230230 }
232232
233233 void NFSv4BreakdownAnalyzer::readdir40(const RPCProcedure* proc, const NFS4::READDIR4args*, const NFS4::READDIR4res* res)
234234 {
235 if (res)
235 if(res)
236236 {
237237 stats.account(proc, ProcEnumNFS4::NFSProcedure::READDIR);
238238 }
240240
241241 void NFSv4BreakdownAnalyzer::readlink40(const RPCProcedure* proc, const NFS4::READLINK4res* res)
242242 {
243 if (res)
243 if(res)
244244 {
245245 stats.account(proc, ProcEnumNFS4::NFSProcedure::READLINK);
246246 }
248248
249249 void NFSv4BreakdownAnalyzer::remove40(const RPCProcedure* proc, const NFS4::REMOVE4args*, const NFS4::REMOVE4res* res)
250250 {
251 if (res)
251 if(res)
252252 {
253253 stats.account(proc, ProcEnumNFS4::NFSProcedure::REMOVE);
254254 }
256256
257257 void NFSv4BreakdownAnalyzer::rename40(const RPCProcedure* proc, const NFS4::RENAME4args*, const NFS4::RENAME4res* res)
258258 {
259 if (res)
259 if(res)
260260 {
261261 stats.account(proc, ProcEnumNFS4::NFSProcedure::RENAME);
262262 }
264264
265265 void NFSv4BreakdownAnalyzer::renew40(const RPCProcedure* proc, const NFS4::RENEW4args*, const NFS4::RENEW4res* res)
266266 {
267 if (res)
267 if(res)
268268 {
269269 stats.account(proc, ProcEnumNFS4::NFSProcedure::RENEW);
270270 }
272272
273273 void NFSv4BreakdownAnalyzer::restorefh40(const RPCProcedure* proc, const NFS4::RESTOREFH4res* res)
274274 {
275 if (res)
275 if(res)
276276 {
277277 stats.account(proc, ProcEnumNFS4::NFSProcedure::RESTOREFH);
278278 }
280280
281281 void NFSv4BreakdownAnalyzer::savefh40(const RPCProcedure* proc, const NFS4::SAVEFH4res* res)
282282 {
283 if (res)
283 if(res)
284284 {
285285 stats.account(proc, ProcEnumNFS4::NFSProcedure::SAVEFH);
286286 }
288288
289289 void NFSv4BreakdownAnalyzer::secinfo40(const RPCProcedure* proc, const NFS4::SECINFO4args*, const NFS4::SECINFO4res* res)
290290 {
291 if (res)
291 if(res)
292292 {
293293 stats.account(proc, ProcEnumNFS4::NFSProcedure::SECINFO);
294294 }
296296
297297 void NFSv4BreakdownAnalyzer::setattr40(const RPCProcedure* proc, const NFS4::SETATTR4args*, const NFS4::SETATTR4res* res)
298298 {
299 if (res)
299 if(res)
300300 {
301301 stats.account(proc, ProcEnumNFS4::NFSProcedure::SETATTR);
302302 }
304304
305305 void NFSv4BreakdownAnalyzer::setclientid40(const RPCProcedure* proc, const NFS4::SETCLIENTID4args*, const NFS4::SETCLIENTID4res* res)
306306 {
307 if (res)
307 if(res)
308308 {
309309 stats.account(proc, ProcEnumNFS4::NFSProcedure::SETCLIENTID);
310310 }
312312
313313 void NFSv4BreakdownAnalyzer::setclientid_confirm40(const RPCProcedure* proc, const NFS4::SETCLIENTID_CONFIRM4args*, const NFS4::SETCLIENTID_CONFIRM4res* res)
314314 {
315 if (res)
315 if(res)
316316 {
317317 stats.account(proc, ProcEnumNFS4::NFSProcedure::SETCLIENTID_CONFIRM);
318318 }
320320
321321 void NFSv4BreakdownAnalyzer::verify40(const RPCProcedure* proc, const NFS4::VERIFY4args*, const NFS4::VERIFY4res* res)
322322 {
323 if (res)
323 if(res)
324324 {
325325 stats.account(proc, ProcEnumNFS4::NFSProcedure::VERIFY);
326326 }
328328
329329 void NFSv4BreakdownAnalyzer::write40(const RPCProcedure* proc, const NFS4::WRITE4args*, const NFS4::WRITE4res* res)
330330 {
331 if (res)
331 if(res)
332332 {
333333 stats.account(proc, ProcEnumNFS4::NFSProcedure::WRITE);
334334 }
336336
337337 void NFSv4BreakdownAnalyzer::release_lockowner40(const RPCProcedure* proc, const NFS4::RELEASE_LOCKOWNER4args*, const NFS4::RELEASE_LOCKOWNER4res* res)
338338 {
339 if (res)
339 if(res)
340340 {
341341 stats.account(proc, ProcEnumNFS4::NFSProcedure::RELEASE_LOCKOWNER);
342342 }
344344
345345 void NFSv4BreakdownAnalyzer::get_dir_delegation40(const RPCProcedure* proc, const NFS4::GET_DIR_DELEGATION4args*, const NFS4::GET_DIR_DELEGATION4res* res)
346346 {
347 if (res)
347 if(res)
348348 {
349349 stats.account(proc, ProcEnumNFS4::NFSProcedure::GET_DIR_DELEGATION);
350350 }
352352
353353 void NFSv4BreakdownAnalyzer::illegal40(const RPCProcedure* proc, const NFS4::ILLEGAL4res* res)
354354 {
355 if (res)
355 if(res)
356356 {
357357 stats.account(proc, ProcEnumNFS4::NFSProcedure::ILLEGAL);
358358 }
3030 {
3131 namespace breakdown
3232 {
33
3433 /*! \brief Analyzer for NFS v4
3534 * Handles NFS v4 commands
3635 */
3837 {
3938 protected:
4039 private:
41 Statistics compound_stats; //!< Statistics
42 Statistics stats; //!< Statistics
43 NFSv4Representer representer; //!< stream to output
40 Statistics compound_stats; //!< Statistics
41 Statistics stats; //!< Statistics
42 NFSv4Representer representer; //!< stream to output
4443 public:
4544 NFSv4BreakdownAnalyzer(std::ostream& o = std::cout);
4645
4948 void null4(const RPCProcedure* proc,
5049 const struct NFS4::NULL4args*,
5150 const struct NFS4::NULL4res*) override final;
52 void compound4(const RPCProcedure* proc,
51 void compound4(const RPCProcedure* proc,
5352 const struct NFS4::COMPOUND4args*,
5453 const struct NFS4::COMPOUND4res*) override final;
5554
7776 void getattr40(const RPCProcedure* proc,
7877 const struct NFS4::GETATTR4args*,
7978 const struct NFS4::GETATTR4res* res) override final;
80 void getfh40(const RPCProcedure* proc,
79 void getfh40(const RPCProcedure* proc,
8180 const struct NFS4::GETFH4res* res) override final;
8281 void link40(const RPCProcedure* proc,
8382 const struct NFS4::LINK4args*,
9493 void lookup40(const RPCProcedure* proc,
9594 const struct NFS4::LOOKUP4args*,
9695 const struct NFS4::LOOKUP4res* res) override final;
97 void lookupp40(const RPCProcedure* proc,
96 void lookupp40(const RPCProcedure* proc,
9897 const struct NFS4::LOOKUPP4res* res) override final;
9998 void nverify40(const RPCProcedure* proc,
10099 const struct NFS4::NVERIFY4args*,
114113 void putfh40(const RPCProcedure* proc,
115114 const struct NFS4::PUTFH4args*,
116115 const struct NFS4::PUTFH4res* res) override final;
117 void putpubfh40(const RPCProcedure* proc,
116 void putpubfh40(const RPCProcedure* proc,
118117 const struct NFS4::PUTPUBFH4res* res) override final;
119 void putrootfh40(const RPCProcedure* proc,
118 void putrootfh40(const RPCProcedure* proc,
120119 const struct NFS4::PUTROOTFH4res* res) override final;
121120 void read40(const RPCProcedure* proc,
122121 const struct NFS4::READ4args*,
124123 void readdir40(const RPCProcedure* proc,
125124 const struct NFS4::READDIR4args*,
126125 const struct NFS4::READDIR4res* res) override final;
127 void readlink40(const RPCProcedure* proc,
126 void readlink40(const RPCProcedure* proc,
128127 const struct NFS4::READLINK4res* res) override final;
129128 void remove40(const RPCProcedure* proc,
130129 const struct NFS4::REMOVE4args*,
135134 void renew40(const RPCProcedure* proc,
136135 const struct NFS4::RENEW4args*,
137136 const struct NFS4::RENEW4res* res) override final;
138 void restorefh40(const RPCProcedure* proc,
137 void restorefh40(const RPCProcedure* proc,
139138 const struct NFS4::RESTOREFH4res* res) override final;
140 void savefh40(const RPCProcedure* proc,
139 void savefh40(const RPCProcedure* proc,
141140 const struct NFS4::SAVEFH4res* res) override final;
142141 void secinfo40(const RPCProcedure* proc,
143142 const struct NFS4::SECINFO4args*,
163162 void get_dir_delegation40(const RPCProcedure* proc,
164163 const struct NFS4::GET_DIR_DELEGATION4args*,
165164 const struct NFS4::GET_DIR_DELEGATION4res* res) override final;
166 void illegal40(const RPCProcedure* proc,
165 void illegal40(const RPCProcedure* proc,
167166 const struct NFS4::ILLEGAL4res* res) override final;
168167 void flush_statistics() override;
169168 };
171170 } // namespace breakdown
172171 } // namespace NST
173172 //------------------------------------------------------------------------------
174 #endif//NFSV4BREAKDOWNANALYZER_H
173 #endif //NFSV4BREAKDOWNANALYZER_H
175174 //------------------------------------------------------------------------------
2727 {
2828 namespace breakdown
2929 {
30
3130 /*!
3231 * Represents NFS v 4.0 commands
3332 * Converts commands to string
3736 public:
3837 const char* command_description(int cmd_code) override final;
3938 const char* command_name(int cmd_code) override final;
40 size_t commands_count() override final;
41 const char* protocol_name();
39 size_t commands_count() override final;
40 const char* protocol_name() override final;
4241 };
4342
4443 } // namespace breakdown
4544 } // namespace NST
4645 //------------------------------------------------------------------------------
47 #endif//NFSV4COMMANDS_H
46 #endif //NFSV4COMMANDS_H
4847 //------------------------------------------------------------------------------
2323 using namespace NST::breakdown;
2424 //------------------------------------------------------------------------------
2525 NFSv4Representer::NFSv4Representer(std::ostream& o, CommandRepresenter* cmdRep, size_t space_for_cmd_name, size_t count_of_compounds)
26 : Representer(o, cmdRep, space_for_cmd_name), count_of_compounds(count_of_compounds)
26 : Representer(o, cmdRep, space_for_cmd_name)
27 , count_of_compounds(count_of_compounds)
2728 {
2829 }
2930
3031 void NFSv4Representer::onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const
3132 {
32 if (procedure == 0)
33 if(procedure == 0)
3334 {
3435 o << "Total procedures: " << breakdown.get_total_count()
35 << ". Per procedure:" << std::endl;
36 << ". Per procedure:" << std::endl;
3637 }
37 if (procedure == count_of_compounds)
38 if(procedure == count_of_compounds)
3839 {
3940 o << "Total operations: " << breakdown.get_total_count()
40 << ". Per operation:" << std::endl;
41 << ". Per operation:" << std::endl;
4142 }
4243 }
2727 {
2828 namespace breakdown
2929 {
30
3130 /**
3231 * @brief The NFSv4Representer class
3332 * Splits output into commands/operations lists for NFS v4.* protocols
3534 class NFSv4Representer : public Representer
3635 {
3736 const size_t count_of_compounds;
37
3838 public:
3939 NFSv4Representer(std::ostream& o, CommandRepresenter* cmdRep, size_t space_for_cmd_name, size_t count_of_compounds);
4040 void onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const override final;
4343 } // namespace breakdown
4444 } // namespace NST
4545 //------------------------------------------------------------------------------
46 #endif//NFSV4REPRESENTER_H
46 #endif //NFSV4REPRESENTER_H
4747 //------------------------------------------------------------------------------
3535
3636 void Representer::flush_statistics(const Statistics& statistics)
3737 {
38 out << "### Breakdown analyzer ###"
39 << std::endl
40 << cmd_representer->protocol_name()
41 << " protocol"
42 << std::endl;
38 out << "### Breakdown analyzer ###" << std::endl
39 << cmd_representer->protocol_name() << " protocol";
4340
44 statistics.for_each_procedure([&](const BreakdownCounter& breakdown, size_t procedure)
41 if(statistics.has_session())
4542 {
46 onProcedureInfoPrinted(out, breakdown, procedure);
47 size_t procedure_count = breakdown[procedure].get_count();
48 out.width(space_for_cmd_name);
49 out << std::left
50 << cmd_representer->command_name(procedure);
51 out.width(5);
52 out << std::right
53 << procedure_count;
54 out.width(7);
55 out.setf(std::ios::fixed, std::ios::floatfield);
56 out.precision(2);
57 out << (breakdown.get_total_count() ? ((1.0 * procedure_count / breakdown.get_total_count()) * 100.0) : 0);
58 out.setf(std::ios::fixed | std::ios::scientific , std::ios::floatfield);
59 out << '%' << std::endl;
60 });
43 out << std::endl;
6144
62 if (statistics.has_session()) // is not empty?
63 {
45 statistics.for_each_procedure([&](const BreakdownCounter& breakdown, size_t procedure) {
46 onProcedureInfoPrinted(out, breakdown, procedure);
47 size_t procedure_count = breakdown[procedure].get_count();
48 out.width(space_for_cmd_name);
49 out << std::left
50 << cmd_representer->command_name(procedure);
51 out.width(5);
52 out << std::right
53 << procedure_count;
54 out.width(7);
55 out.setf(std::ios::fixed, std::ios::floatfield);
56 out.precision(2);
57 out << (breakdown.get_total_count() ? ((1.0 * procedure_count / breakdown.get_total_count()) * 100.0) : 0);
58 out.setf(std::ios::fixed | std::ios::scientific, std::ios::floatfield);
59 out << '%' << std::endl;
60 });
61
6462 out << "Per connection info: " << std::endl;
6563
66 statistics.for_each_session([&](const Session& session)
67 {
64 statistics.for_each_session([&](const Session& session) {
6865 std::stringstream ssession;
6966 print_session(ssession, session);
7067 print_per_session(statistics, session, ssession.str());
7168 std::ofstream file("breakdown_" + ssession.str() + ".dat", std::ios::out | std::ios::trunc);
7269 store_per_session(file, statistics, session, ssession.str());
7370 });
71 }
72 else
73 {
74 out << ": Data transmission has not been detected." << std::endl;
7475 }
7576 }
7677
7980 //TODO: does it make sense to join store_per_session & print_per_session?
8081 file << "Session: " << ssession << std::endl;
8182
82 statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure)
83 {
83 statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) {
8484 uint64_t s_total_proc = breakdown.get_total_count();
8585 file << cmd_representer->command_name(procedure);
8686 file << ' ' << breakdown[procedure].get_count() << ' ';
9797 {
9898 out << "Session: " << ssession << std::endl;
9999
100 statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure)
101 {
100 statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) {
102101 uint64_t s_total_proc = breakdown.get_total_count();
103102 onProcedureInfoPrinted(out, breakdown, procedure);
104103 out.width(22);
135134
136135 void Representer::onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const
137136 {
138 if (procedure == 0)
137 if(procedure == 0)
139138 {
140139 o << "Total operations: " << breakdown.get_total_count()
141 << ". Per operation:" << std::endl;
140 << ". Per operation:" << std::endl;
142141 }
143142 }
144143 //------------------------------------------------------------------------------
2424 #include <memory>
2525 #include <ostream>
2626
27 #include "breakdowncounter.h"
2728 #include "commandrepresenter.h"
28 #include "breakdowncounter.h"
2929 #include "statistics.h"
3030 //------------------------------------------------------------------------------
3131 namespace NST
3232 {
3333 namespace breakdown
3434 {
35
3635 /*! \class Represents statistics and sends it to screen
3736 */
3837 class Representer
3938 {
40 std::ostream& out;
39 std::ostream& out;
4140 std::unique_ptr<CommandRepresenter> cmd_representer;
42 size_t space_for_cmd_name;
41 size_t space_for_cmd_name;
4342
44 void store_per_session(std::ostream& file,
45 const Statistics& statistics,
46 const Session& session,
43 void store_per_session(std::ostream& file,
44 const Statistics& statistics,
45 const Session& session,
4746 const std::string& ssession) const;
4847
4948 void print_per_session(const Statistics& statistics, const Session& session, const std::string& ssession) const;
49
5050 protected:
5151 /**
5252 * @brief handler of one procedure output event
5555 * @param procedure - procedure ID
5656 */
5757 virtual void onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const;
58
5859 public:
5960 /**
6061 * @brief Representer's constructor
7475 } // namespace breakdown
7576 } // namespace NST
7677 //------------------------------------------------------------------------------
77 #endif//REPRESENTER_H
78 #endif //REPRESENTER_H
7879 //------------------------------------------------------------------------------
2424 //------------------------------------------------------------------------------
2525 bool Less::operator()(const Session& a, const Session& b) const
2626 {
27 return ( (std::uint16_t)(a.ip_type) < (std::uint16_t)(b.ip_type) ) || // compare versions of IP address
28 ( ntohs(a.port[0]) < ntohs(b.port[0]) ) || // compare Source(client) ports
29 ( ntohs(a.port[1]) < ntohs(b.port[1]) ) || // compare Destination(server) ports
27 return ((std::uint16_t)(a.ip_type) < (std::uint16_t)(b.ip_type)) || // compare versions of IP address
28 (ntohs(a.port[0]) < ntohs(b.port[0])) || // compare Source(client) ports
29 (ntohs(a.port[1]) < ntohs(b.port[1])) || // compare Destination(server) ports
3030
31 ( (a.ip_type == Session::IPType::v4) ? // compare IPv4
32 ((ntohl(a.ip.v4.addr[0]) < ntohl(b.ip.v4.addr[0])) || (ntohl(a.ip.v4.addr[1]) < ntohl(b.ip.v4.addr[1])))
33 :
34 (memcmp(&a.ip.v6, &b.ip.v6, sizeof(a.ip.v6)) < 0 )
35 );
31 ((a.ip_type == Session::IPType::v4) ? // compare IPv4
32 ((ntohl(a.ip.v4.addr[0]) < ntohl(b.ip.v4.addr[0])) || (ntohl(a.ip.v4.addr[1]) < ntohl(b.ip.v4.addr[1])))
33 : (memcmp(&a.ip.v6, &b.ip.v6, sizeof(a.ip.v6)) < 0));
3634 }
3735
3836 Statistics::Statistics(size_t proc_types_count)
4139 {
4240 }
4341
44 void Statistics::for_each_procedure(std::function<void (const BreakdownCounter&, size_t)> on_procedure) const
42 void Statistics::for_each_procedure(std::function<void(const BreakdownCounter&, size_t)> on_procedure) const
4543 {
46 for (size_t procedure = 0; procedure < proc_types_count; ++procedure)
44 for(size_t procedure = 0; procedure < proc_types_count; ++procedure)
4745 {
4846 on_procedure(counter, procedure);
4947 }
5048 }
5149
52 void Statistics::for_each_session(std::function<void (const Session&)> on_session) const
50 void Statistics::for_each_session(std::function<void(const Session&)> on_session) const
5351 {
54 for (auto& it : per_session_statistics)
52 for(auto& it : per_session_statistics)
5553 {
5654 on_session(it.first);
5755 }
5856 }
5957
60 void Statistics::for_each_procedure_in_session(const Session& session, std::function<void (const BreakdownCounter&, size_t)> on_procedure) const
58 void Statistics::for_each_procedure_in_session(const Session& session, std::function<void(const BreakdownCounter&, size_t)> on_procedure) const
6159 {
62 if (per_session_statistics.find(session) == per_session_statistics.end())
60 if(per_session_statistics.find(session) == per_session_statistics.end())
6361 {
6462 return;
6563 }
6664
6765 const BreakdownCounter& current = per_session_statistics.at(session);
68 for (size_t procedure = 0; procedure < proc_types_count; ++procedure)
66 for(size_t procedure = 0; procedure < proc_types_count; ++procedure)
6967 {
7068 on_procedure(current, procedure);
7169 }
8179 counter[cmd_index].add(latency);
8280
8381 auto i = per_session_statistics.find(session);
84 if (i == per_session_statistics.end())
82 if(i == per_session_statistics.end())
8583 {
86 auto session_res = per_session_statistics.emplace(session, BreakdownCounter {proc_types_count});
87 if (session_res.second == false)
84 auto session_res = per_session_statistics.emplace(session, BreakdownCounter{proc_types_count});
85 if(session_res.second == false)
8886 {
8987 return;
9088 }
9290 }
9391
9492 (i->second)[cmd_index].add(latency);
95
9693 }
9794 //------------------------------------------------------------------------------
3232 {
3333 namespace breakdown
3434 {
35
3635 /*! \brief Comparator for sessions
3736 */
3837 struct Less
3938 {
40 bool operator() (const Session& a, const Session& b) const;
39 bool operator()(const Session& a, const Session& b) const;
4140 };
4241
4342 /*! \brief All statistics data's container
4544 struct Statistics
4645 {
4746 using PerSessionStatistics = std::map<Session, BreakdownCounter, Less>;
48 using ProceduresCount = std::vector<int>;
47 using ProceduresCount = std::vector<int>;
4948
5049 const size_t proc_types_count; //!< Count of types of procedures
5150
8584 * @param cmd_code - commands code
8685 * @param stats - statistics
8786 */
88 template<typename Cmd, typename Code>
87 template <typename Cmd, typename Code>
8988 void account(const Cmd* proc, Code cmd_code)
9089 {
91 timeval latency {0, 0};
92 const int cmd_index = static_cast<int>(cmd_code);
93 const Session& session = *proc->session;
90 timeval latency{0, 0};
91 const int cmd_index = static_cast<int>(cmd_code);
92 const Session& session = *proc->session;
9493
9594 // diff between 'reply' and 'call' timestamps
9695 timersub(proc->rtimestamp, proc->ctimestamp, &latency);
9796
9897 account(cmd_index, session, latency);
9998 }
99
100100 protected:
101101 void account(const int cmd_index, const Session& session, const timeval latency);
102102
103 BreakdownCounter counter; //!< Statistics for all sessions
103 BreakdownCounter counter; //!< Statistics for all sessions
104104 PerSessionStatistics per_session_statistics; //!< Statistics for each session
105105 };
106106
107107 } // namespace breakdown
108108 } // namespace NST
109109 //------------------------------------------------------------------------------
110 #endif//STATISTICS_H
110 #endif //STATISTICS_H
111111 //------------------------------------------------------------------------------
2828 : Statistics(operations_stats)
2929 , procedures_stats(procedures_stats)
3030 {
31 procedures_stats.for_each_session([&](const Session& session)
32 {
31 procedures_stats.for_each_session([&](const Session& session) {
3332 auto i = per_session_statistics.find(session);
34 if (i == per_session_statistics.end())
33 if(i == per_session_statistics.end())
3534 {
36 per_session_statistics.emplace(session, BreakdownCounter {proc_types_count});
35 per_session_statistics.emplace(session, BreakdownCounter{proc_types_count});
3736 }
3837 });
3938 }
4443
4544 procedures_stats.for_each_procedure(on_procedure);
4645
47 for (size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure)
46 for(size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure)
4847 {
4948 on_procedure(counter, procedure);
5049 }
5150 }
5251
53 void StatisticsCompositor::for_each_procedure_in_session(const Session& session, std::function<void (const BreakdownCounter&, size_t)> on_procedure) const
52 void StatisticsCompositor::for_each_procedure_in_session(const Session& session, std::function<void(const BreakdownCounter&, size_t)> on_procedure) const
5453 {
5554 bool has_procedures_in_session = false;
5655
57 procedures_stats.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t proc)
58 {
56 procedures_stats.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t proc) {
5957 on_procedure(breakdown, proc);
6058 has_procedures_in_session = true;
6159 });
6260
63 if (!has_procedures_in_session)
61 if(!has_procedures_in_session)
6462 {
6563 BreakdownCounter empty(procedures_stats.proc_types_count);
66 for (size_t procedure = 0; procedure < procedures_stats.proc_types_count; ++procedure)
64 for(size_t procedure = 0; procedure < procedures_stats.proc_types_count; ++procedure)
6765 {
6866 on_procedure(empty, procedure);
6967 }
7068 }
7169
7270 const BreakdownCounter& current = per_session_statistics.at(session);
73 for (size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure)
71 for(size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure)
7472 {
7573 on_procedure(current, procedure);
7674 }
2727 {
2828 namespace breakdown
2929 {
30
3130 /**
3231 * @brief Composes 2 statistics: for procedures and functions
3332 * It is useful for NFS v4.* protocols
3534 class StatisticsCompositor : public Statistics
3635 {
3736 Statistics& procedures_stats;
37
3838 public:
3939 StatisticsCompositor(Statistics& procedures_stats, Statistics& operations_stats);
4040 void for_each_procedure(std::function<void(const BreakdownCounter&, size_t)> on_procedure) const override;
4545 } // namespace breakdown
4646 } // namespace NST
4747 //------------------------------------------------------------------------------
48 #endif//STATISTICSCOMPOSITOR_H
48 #endif //STATISTICSCOMPOSITOR_H
4949 //------------------------------------------------------------------------------
2222 #include <functional>
2323 #include <system_error>
2424
25 #include <sys/socket.h>
2526 #include <sys/types.h>
26 #include <sys/socket.h>
2727 #include <unistd.h>
2828
2929 #include "abstract_tcp_service.h"
3030 #include "utils/log.h"
3131 //------------------------------------------------------------------------------
3232
33 AbstractTcpService::AbstractTcpService(std::size_t workersAmount, int port, const std::string& host, int backlog) :
34 _port{port},
35 _host{host},
36 _backlog{backlog},
37 _isRunning{true},
38 _threadPool{workersAmount},
39 _listenerThread{},
40 _serverSocket{0},
41 _tasksQueue{},
42 _tasksQueueMutex{},
43 _tasksQueueCond{}
33 AbstractTcpService::AbstractTcpService(std::size_t workersAmount, int port, const std::string& host, int backlog)
34 : _port{port}
35 , _host{host}
36 , _backlog{backlog}
37 , _isRunning{true}
38 , _threadPool{workersAmount}
39 , _listenerThread{}
40 , _serverSocket{0}
41 , _tasksQueue{}
42 , _tasksQueueMutex{}
43 , _tasksQueueCond{}
4444 {
4545 }
4646
4747 AbstractTcpService::~AbstractTcpService()
4848 {
4949 // Disposing tasks which are still in queue
50 while (!_tasksQueue.empty())
50 while(!_tasksQueue.empty())
5151 {
5252 delete _tasksQueue.front();
5353 _tasksQueue.pop();
5959 _isRunning = true;
6060 // Setting up server TCP-socket
6161 _serverSocket = socket(PF_INET, SOCK_STREAM, 0);
62 if (_serverSocket < 0)
62 if(_serverSocket < 0)
6363 {
6464 throw std::system_error{errno, std::system_category(), "Opening server socket error"};
6565 }
6666 // Setting SO_REUSEADDR to true
6767 int reuseAddr = 1;
68 if (setsockopt(_serverSocket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) < 0)
68 if(setsockopt(_serverSocket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) < 0)
6969 {
7070 throw std::system_error{errno, std::system_category(), "Setting SO_REUSEADDR socket option error"};
7171 }
7272 // Binding server socket to endpoint
7373 IpEndpoint endpoint{_host.c_str(), _port};
74 if (bind(_serverSocket, endpoint.addrinfo()->ai_addr, endpoint.addrinfo()->ai_addrlen) != 0)
74 if(bind(_serverSocket, endpoint.addrinfo()->ai_addr, endpoint.addrinfo()->ai_addrlen) != 0)
7575 {
7676 throw std::system_error{errno, std::system_category(), "Binding server socket error"};
7777 }
7878 // Converting socket to listening state
79 if (listen(_serverSocket, _backlog) != 0)
79 if(listen(_serverSocket, _backlog) != 0)
8080 {
8181 throw std::system_error{errno, std::system_category(), "Converting socket to listening state error"};
8282 }
8383 // Creating threads for thread-pool
84 for (auto & thr : _threadPool)
84 for(auto& thr : _threadPool)
8585 {
8686 thr = std::thread{&AbstractTcpService::runWorker, this};
8787 }
9797 _tasksQueueCond.notify_all();
9898 }
9999 // Joining to thread-pool threads and disposing them
100 for (auto & thr : _threadPool)
100 for(auto& thr : _threadPool)
101101 {
102102 thr.join();
103103 }
108108
109109 void AbstractTcpService::runWorker()
110110 {
111 while (true)
111 while(true)
112112 {
113113 std::unique_ptr<AbstractTask> pendingTask;
114114 {
115115 std::unique_lock<std::mutex> lock{_tasksQueueMutex};
116 while (!pendingTask)
117 {
118 if (!_isRunning.load())
116 while(!pendingTask)
117 {
118 if(!_isRunning.load())
119119 {
120120 return;
121121 }
122 if (!_tasksQueue.empty())
122 if(!_tasksQueue.empty())
123123 {
124124 pendingTask.reset(_tasksQueue.front());
125125 _tasksQueue.pop();
136136
137137 void AbstractTcpService::runListener()
138138 {
139 while (_isRunning.load())
139 while(_isRunning.load())
140140 {
141141 // Accepting incoming connection on socket
142142 struct timespec acceptDuration;
145145 FD_ZERO(&readDescriptorsSet);
146146 FD_SET(_serverSocket, &readDescriptorsSet);
147147 int descriptorsCount = pselect(_serverSocket + 1, &readDescriptorsSet, NULL, NULL, &acceptDuration, NULL);
148 if (descriptorsCount == 0)
148 if(descriptorsCount == 0)
149149 {
150150 // Timeout expired
151151 continue;
152152 }
153 else if (descriptorsCount < 0)
153 else if(descriptorsCount < 0)
154154 {
155155 std::system_error e{errno, std::system_category(), "Awaiting for incoming connection on server socket error"};
156156 LOG("ERROR: %s", e.what());
157157 #ifdef __gnu_linux__
158158 // Several first pselect(2) calls cause "Interrupted system call" error (errno == EINTR)
159159 // if drop privileges option is used on Linux (see https://access.redhat.com/solutions/165483)
160 if (errno == EINTR)
160 if(errno == EINTR)
161161 {
162162 continue;
163163 }
166166 }
167167 // Extracting and returning pending connection
168168 int pendingSocketDescriptor = accept(_serverSocket, NULL, NULL);
169 if (pendingSocketDescriptor < 0)
169 if(pendingSocketDescriptor < 0)
170170 {
171171 std::system_error e{errno, std::system_category(), "Accepting incoming connection on server socket error"};
172172 LOG("ERROR: %s", e.what());
176176 std::unique_ptr<AbstractTask> newTask{createTask(pendingSocketDescriptor)};
177177 {
178178 std::unique_lock<std::mutex> lock(_tasksQueueMutex);
179 if (_tasksQueue.size() < MaxTasksQueueSize)
179 if(_tasksQueue.size() < MaxTasksQueueSize)
180180 {
181181 _tasksQueue.push(newTask.get());
182182 newTask.release();
192192
193193 //------------------------------------------------------------------------------
194194
195 AbstractTcpService::AbstractTask::AbstractTask(int socket) :
196 _socket{socket}
197 {}
195 AbstractTcpService::AbstractTask::AbstractTask(int socket)
196 : _socket{socket}
197 {
198 }
198199
199200 AbstractTcpService::AbstractTask::~AbstractTask()
200201 {
2222 #define ABSTRACT_TCP_SERVICE_H
2323 //------------------------------------------------------------------------------
2424 #include <atomic>
25 #include <condition_variable>
2625 #include <mutex>
2726 #include <queue>
2827 #include <thread>
2928 #include <vector>
29 #include <condition_variable>
3030
3131 #include "ip_endpoint.h"
3232 //------------------------------------------------------------------------------
6363 //! Fills 'struct timespec' value using clock timeout
6464 inline static void fillDuration(struct timespec& ts)
6565 {
66 ts.tv_sec = ClockTimeoutMs / 1000;
66 ts.tv_sec = ClockTimeoutMs / 1000;
6767 ts.tv_nsec = ClockTimeoutMs % 1000 * 1000000;
6868 }
6969
7171 virtual void start();
7272 //! Stops TCP-service
7373 virtual void stop();
74
7475 protected:
7576 //! Asbtract TCP-service task
7677 class AbstractTask
9394
9495 //! Task execution pure virtual method to override
9596 virtual void execute() = 0;
97
9698 private:
9799 int _socket;
98100 };
99101
100102 virtual AbstractTask* createTask(int socket) = 0;
103
101104 private:
102105 using ThreadPool = std::vector<std::thread>;
103106
104 static constexpr int ClockTimeoutMs = 100;
105 static constexpr std::size_t ReadBufferSize = 1024;
106 static constexpr std::size_t WriteBufferSize = 4096;
107 static constexpr std::size_t HeaderPartSize = 1024;
108 static constexpr int MaxTasksQueueSize = 128;
107 static constexpr int ClockTimeoutMs = 100;
108 static constexpr std::size_t ReadBufferSize = 1024;
109 static constexpr std::size_t WriteBufferSize = 4096;
110 static constexpr std::size_t HeaderPartSize = 1024;
111 static constexpr int MaxTasksQueueSize = 128;
109112
110113 void runWorker();
111114 void runListener();
112115
113 const int _port;
114 const std::string _host;
115 const int _backlog;
116 std::atomic_bool _isRunning;
117 ThreadPool _threadPool;
118 std::thread _listenerThread;
119 int _serverSocket;
116 const int _port;
117 const std::string _host;
118 const int _backlog;
119 std::atomic_bool _isRunning;
120 ThreadPool _threadPool;
121 std::thread _listenerThread;
122 int _serverSocket;
120123 std::queue<AbstractTask*> _tasksQueue;
121 std::mutex _tasksQueueMutex;
122 std::condition_variable _tasksQueueCond;
124 std::mutex _tasksQueueMutex;
125 std::condition_variable _tasksQueueCond;
123126 };
124127 //------------------------------------------------------------------------------
125 #endif//ABSTRACT_TCP_SERVICE_H
128 #endif //ABSTRACT_TCP_SERVICE_H
126129 //------------------------------------------------------------------------------
2626 #include "ip_endpoint.h"
2727 //------------------------------------------------------------------------------
2828
29 IpEndpoint::IpEndpoint(const std::string& host, int port, bool hostAsAddress) :
30 _addrinfo{}
29 IpEndpoint::IpEndpoint(const std::string& host, int port, bool hostAsAddress)
30 : _addrinfo{}
3131 {
3232 struct addrinfo hints;
3333 memset(&hints, 0, sizeof hints);
34 hints.ai_family = AF_INET;
34 hints.ai_family = AF_INET;
3535 hints.ai_socktype = SOCK_STREAM;
3636 hints.ai_flags |= AI_NUMERICSERV;
3737 std::string serviceStr{std::to_string(port)};
38 if (host == WildcardAddress)
38 if(host == WildcardAddress)
3939 {
4040 hints.ai_flags |= AI_PASSIVE;
4141 }
42 if ((host != WildcardAddress) && (host != LoopbackAddress))
42 if((host != WildcardAddress) && (host != LoopbackAddress))
4343 {
4444 hints.ai_flags |= AI_CANONNAME;
45 if (hostAsAddress)
45 if(hostAsAddress)
4646 {
4747 hints.ai_flags |= AI_NUMERICHOST;
4848 }
4949 }
5050 int status = getaddrinfo((host == LoopbackAddress) || (host == WildcardAddress) ? nullptr : host.c_str(),
5151 serviceStr.c_str(), &hints, &_addrinfo);
52 if (status != 0)
52 if(status != 0)
5353 {
5454 throw std::runtime_error{gai_strerror(status)};
5555 }
5050 {
5151 return _addrinfo;
5252 }
53
5354 private:
5455 struct addrinfo* _addrinfo;
5556 };
5657 //------------------------------------------------------------------------------
57 #endif//IP_ENDPOINT_H
58 #endif //IP_ENDPOINT_H
5859 //------------------------------------------------------------------------------
2121 #include "json_analyzer.h"
2222 //------------------------------------------------------------------------------
2323
24 JsonAnalyzer::JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog) :
25 _jsonTcpService{*this, workersAmount, port, host, maxServingDurationMs, backlog},
26 _nfsV3Stat{},
27 _nfsV40Stat{},
28 _nfsV41Stat{}
24 JsonAnalyzer::JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog)
25 : _jsonTcpService{*this, workersAmount, port, host, maxServingDurationMs, backlog}
26 , _nfsV3Stat{}
27 , _nfsV40Stat{}
28 , _nfsV41Stat{}
2929 {
3030 _jsonTcpService.start();
3131 }
3636 }
3737
3838 // NFS3
39 // Procedures:
39 // Procedures:
4040
4141 void JsonAnalyzer::null(const RPCProcedure* /*proc*/,
4242 const struct NFS3::NULL3args* /*args*/,
193193 }
194194
195195 // NFS4.0
196 // Procedures:
196 // Procedures:
197197
198198 void JsonAnalyzer::null4(const RPCProcedure* /*proc*/,
199199 const struct NFS4::NULL4args* /*args*/,
476476 }
477477
478478 // NFS4.1
479 // Procedures:
480
479 // Procedures:
480
481481 void JsonAnalyzer::compound41(const RPCProcedure* /*proc*/,
482482 const struct NFS41::COMPOUND4args* /*args*/,
483483 const struct NFS41::COMPOUND4res* /*res*/)
747747 }
748748
749749 void JsonAnalyzer::bind_conn_to_session41(const RPCProcedure* /* proc */,
750 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
750 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
751751 const struct NFS41::BIND_CONN_TO_SESSION4res* res)
752752 {
753753 if(res) _nfsV41Stat.bind_conn_to_sessionOpsAmount++;
3434 struct NfsV3Stat
3535 {
3636 // Procedures:
37 std::atomic_int nullProcsAmount = {0};
38 std::atomic_int getattrProcsAmount = {0};
39 std::atomic_int setattrProcsAmount = {0};
40 std::atomic_int lookupProcsAmount = {0};
41 std::atomic_int accessProcsAmount = {0};
42 std::atomic_int readlinkProcsAmount = {0};
43 std::atomic_int readProcsAmount = {0};
44 std::atomic_int writeProcsAmount = {0};
45 std::atomic_int createProcsAmount = {0};
46 std::atomic_int mkdirProcsAmount = {0};
47 std::atomic_int symlinkProcsAmount = {0};
48 std::atomic_int mknodProcsAmount = {0};
49 std::atomic_int removeProcsAmount = {0};
50 std::atomic_int rmdirProcsAmount = {0};
51 std::atomic_int renameProcsAmount = {0};
52 std::atomic_int linkProcsAmount = {0};
53 std::atomic_int readdirProcsAmount = {0};
37 std::atomic_int nullProcsAmount = {0};
38 std::atomic_int getattrProcsAmount = {0};
39 std::atomic_int setattrProcsAmount = {0};
40 std::atomic_int lookupProcsAmount = {0};
41 std::atomic_int accessProcsAmount = {0};
42 std::atomic_int readlinkProcsAmount = {0};
43 std::atomic_int readProcsAmount = {0};
44 std::atomic_int writeProcsAmount = {0};
45 std::atomic_int createProcsAmount = {0};
46 std::atomic_int mkdirProcsAmount = {0};
47 std::atomic_int symlinkProcsAmount = {0};
48 std::atomic_int mknodProcsAmount = {0};
49 std::atomic_int removeProcsAmount = {0};
50 std::atomic_int rmdirProcsAmount = {0};
51 std::atomic_int renameProcsAmount = {0};
52 std::atomic_int linkProcsAmount = {0};
53 std::atomic_int readdirProcsAmount = {0};
5454 std::atomic_int readdirplusProcsAmount = {0};
55 std::atomic_int fsstatProcsAmount = {0};
56 std::atomic_int fsinfoProcsAmount = {0};
57 std::atomic_int pathconfProcsAmount = {0};
58 std::atomic_int commitProcsAmount = {0};
55 std::atomic_int fsstatProcsAmount = {0};
56 std::atomic_int fsinfoProcsAmount = {0};
57 std::atomic_int pathconfProcsAmount = {0};
58 std::atomic_int commitProcsAmount = {0};
5959 };
6060 struct NfsV40Stat
6161 {
6262 // Procedures:
63 std::atomic_int nullProcsAmount = {0};
63 std::atomic_int nullProcsAmount = {0};
6464 std::atomic_int compoundProcsAmount = {0};
6565
6666 // Operations:
67 std::atomic_int accessOpsAmount = {0};
68 std::atomic_int closeOpsAmount = {0};
69 std::atomic_int commitOpsAmount = {0};
70 std::atomic_int createOpsAmount = {0};
71 std::atomic_int delegpurgeOpsAmount = {0};
72 std::atomic_int delegreturnOpsAmount = {0};
73 std::atomic_int getattrOpsAmount = {0};
74 std::atomic_int getfhOpsAmount = {0};
75 std::atomic_int linkOpsAmount = {0};
76 std::atomic_int lockOpsAmount = {0};
77 std::atomic_int locktOpsAmount = {0};
78 std::atomic_int lockuOpsAmount = {0};
79 std::atomic_int lookupOpsAmount = {0};
80 std::atomic_int lookuppOpsAmount = {0};
81 std::atomic_int nverifyOpsAmount = {0};
82 std::atomic_int openOpsAmount = {0};
83 std::atomic_int openattrOpsAmount = {0};
84 std::atomic_int open_confirmOpsAmount = {0};
85 std::atomic_int open_downgradeOpsAmount = {0};
86 std::atomic_int putfhOpsAmount = {0};
87 std::atomic_int putpubfhOpsAmount = {0};
88 std::atomic_int putrootfhOpsAmount = {0};
89 std::atomic_int readOpsAmount = {0};
90 std::atomic_int readdirOpsAmount = {0};
91 std::atomic_int readlinkOpsAmount = {0};
92 std::atomic_int removeOpsAmount = {0};
93 std::atomic_int renameOpsAmount = {0};
94 std::atomic_int renewOpsAmount = {0};
95 std::atomic_int restorefhOpsAmount = {0};
96 std::atomic_int savefhOpsAmount = {0};
97 std::atomic_int secinfoOpsAmount = {0};
98 std::atomic_int setattrOpsAmount = {0};
99 std::atomic_int setclientidOpsAmount = {0};
67 std::atomic_int accessOpsAmount = {0};
68 std::atomic_int closeOpsAmount = {0};
69 std::atomic_int commitOpsAmount = {0};
70 std::atomic_int createOpsAmount = {0};
71 std::atomic_int delegpurgeOpsAmount = {0};
72 std::atomic_int delegreturnOpsAmount = {0};
73 std::atomic_int getattrOpsAmount = {0};
74 std::atomic_int getfhOpsAmount = {0};
75 std::atomic_int linkOpsAmount = {0};
76 std::atomic_int lockOpsAmount = {0};
77 std::atomic_int locktOpsAmount = {0};
78 std::atomic_int lockuOpsAmount = {0};
79 std::atomic_int lookupOpsAmount = {0};
80 std::atomic_int lookuppOpsAmount = {0};
81 std::atomic_int nverifyOpsAmount = {0};
82 std::atomic_int openOpsAmount = {0};
83 std::atomic_int openattrOpsAmount = {0};
84 std::atomic_int open_confirmOpsAmount = {0};
85 std::atomic_int open_downgradeOpsAmount = {0};
86 std::atomic_int putfhOpsAmount = {0};
87 std::atomic_int putpubfhOpsAmount = {0};
88 std::atomic_int putrootfhOpsAmount = {0};
89 std::atomic_int readOpsAmount = {0};
90 std::atomic_int readdirOpsAmount = {0};
91 std::atomic_int readlinkOpsAmount = {0};
92 std::atomic_int removeOpsAmount = {0};
93 std::atomic_int renameOpsAmount = {0};
94 std::atomic_int renewOpsAmount = {0};
95 std::atomic_int restorefhOpsAmount = {0};
96 std::atomic_int savefhOpsAmount = {0};
97 std::atomic_int secinfoOpsAmount = {0};
98 std::atomic_int setattrOpsAmount = {0};
99 std::atomic_int setclientidOpsAmount = {0};
100100 std::atomic_int setclientid_confirmOpsAmount = {0};
101 std::atomic_int verifyOpsAmount = {0};
102 std::atomic_int writeOpsAmount = {0};
103 std::atomic_int release_lockownerOpsAmount = {0};
104 std::atomic_int get_dir_delegationOpsAmount = {0};
105 std::atomic_int illegalOpsAmount = {0};
101 std::atomic_int verifyOpsAmount = {0};
102 std::atomic_int writeOpsAmount = {0};
103 std::atomic_int release_lockownerOpsAmount = {0};
104 std::atomic_int get_dir_delegationOpsAmount = {0};
105 std::atomic_int illegalOpsAmount = {0};
106106 };
107107 struct NfsV41Stat
108108 {
109109 // Procedures:
110 std::atomic_int nullProcsAmount = {0};
110 std::atomic_int nullProcsAmount = {0};
111111 std::atomic_int compoundProcsAmount = {0};
112112
113113 // Operations:
114 std::atomic_int accessOpsAmount = {0};
115 std::atomic_int closeOpsAmount = {0};
116 std::atomic_int commitOpsAmount = {0};
117 std::atomic_int createOpsAmount = {0};
118 std::atomic_int delegpurgeOpsAmount = {0};
119 std::atomic_int delegreturnOpsAmount = {0};
120 std::atomic_int getattrOpsAmount = {0};
121 std::atomic_int getfhOpsAmount = {0};
122 std::atomic_int linkOpsAmount = {0};
123 std::atomic_int lockOpsAmount = {0};
124 std::atomic_int locktOpsAmount = {0};
125 std::atomic_int lockuOpsAmount = {0};
126 std::atomic_int lookupOpsAmount = {0};
127 std::atomic_int lookuppOpsAmount = {0};
128 std::atomic_int nverifyOpsAmount = {0};
129 std::atomic_int openOpsAmount = {0};
130 std::atomic_int openattrOpsAmount = {0};
131 std::atomic_int open_confirmOpsAmount = {0};
132 std::atomic_int open_downgradeOpsAmount = {0};
133 std::atomic_int putfhOpsAmount = {0};
134 std::atomic_int putpubfhOpsAmount = {0};
135 std::atomic_int putrootfhOpsAmount = {0};
136 std::atomic_int readOpsAmount = {0};
137 std::atomic_int readdirOpsAmount = {0};
138 std::atomic_int readlinkOpsAmount = {0};
139 std::atomic_int removeOpsAmount = {0};
140 std::atomic_int renameOpsAmount = {0};
141 std::atomic_int renewOpsAmount = {0};
142 std::atomic_int restorefhOpsAmount = {0};
143 std::atomic_int savefhOpsAmount = {0};
144 std::atomic_int secinfoOpsAmount = {0};
145 std::atomic_int setattrOpsAmount = {0};
146 std::atomic_int setclientidOpsAmount = {0};
147 std::atomic_int setclientid_confirmOpsAmount = {0};
148 std::atomic_int verifyOpsAmount = {0};
149 std::atomic_int writeOpsAmount = {0};
150 std::atomic_int release_lockownerOpsAmount = {0};
151 std::atomic_int backchannel_ctlOpsAmount = {0};
114 std::atomic_int accessOpsAmount = {0};
115 std::atomic_int closeOpsAmount = {0};
116 std::atomic_int commitOpsAmount = {0};
117 std::atomic_int createOpsAmount = {0};
118 std::atomic_int delegpurgeOpsAmount = {0};
119 std::atomic_int delegreturnOpsAmount = {0};
120 std::atomic_int getattrOpsAmount = {0};
121 std::atomic_int getfhOpsAmount = {0};
122 std::atomic_int linkOpsAmount = {0};
123 std::atomic_int lockOpsAmount = {0};
124 std::atomic_int locktOpsAmount = {0};
125 std::atomic_int lockuOpsAmount = {0};
126 std::atomic_int lookupOpsAmount = {0};
127 std::atomic_int lookuppOpsAmount = {0};
128 std::atomic_int nverifyOpsAmount = {0};
129 std::atomic_int openOpsAmount = {0};
130 std::atomic_int openattrOpsAmount = {0};
131 std::atomic_int open_confirmOpsAmount = {0};
132 std::atomic_int open_downgradeOpsAmount = {0};
133 std::atomic_int putfhOpsAmount = {0};
134 std::atomic_int putpubfhOpsAmount = {0};
135 std::atomic_int putrootfhOpsAmount = {0};
136 std::atomic_int readOpsAmount = {0};
137 std::atomic_int readdirOpsAmount = {0};
138 std::atomic_int readlinkOpsAmount = {0};
139 std::atomic_int removeOpsAmount = {0};
140 std::atomic_int renameOpsAmount = {0};
141 std::atomic_int renewOpsAmount = {0};
142 std::atomic_int restorefhOpsAmount = {0};
143 std::atomic_int savefhOpsAmount = {0};
144 std::atomic_int secinfoOpsAmount = {0};
145 std::atomic_int setattrOpsAmount = {0};
146 std::atomic_int setclientidOpsAmount = {0};
147 std::atomic_int setclientid_confirmOpsAmount = {0};
148 std::atomic_int verifyOpsAmount = {0};
149 std::atomic_int writeOpsAmount = {0};
150 std::atomic_int release_lockownerOpsAmount = {0};
151 std::atomic_int backchannel_ctlOpsAmount = {0};
152152 std::atomic_int bind_conn_to_sessionOpsAmount = {0};
153 std::atomic_int exchange_idOpsAmount = {0};
154 std::atomic_int create_sessionOpsAmount = {0};
155 std::atomic_int destroy_sessionOpsAmount = {0};
156 std::atomic_int free_stateidOpsAmount = {0};
157 std::atomic_int get_dir_delegationOpsAmount = {0};
158 std::atomic_int getdeviceinfoOpsAmount = {0};
159 std::atomic_int getdevicelistOpsAmount = {0};
160 std::atomic_int layoutcommitOpsAmount = {0};
161 std::atomic_int layoutgetOpsAmount = {0};
162 std::atomic_int layoutreturnOpsAmount = {0};
163 std::atomic_int secinfo_no_nameOpsAmount = {0};
164 std::atomic_int sequenceOpsAmount = {0};
165 std::atomic_int set_ssvOpsAmount = {0};
166 std::atomic_int test_stateidOpsAmount = {0};
167 std::atomic_int want_delegationOpsAmount = {0};
168 std::atomic_int destroy_clientidOpsAmount = {0};
169 std::atomic_int reclaim_completeOpsAmount = {0};
170 std::atomic_int illegalOpsAmount = {0};
153 std::atomic_int exchange_idOpsAmount = {0};
154 std::atomic_int create_sessionOpsAmount = {0};
155 std::atomic_int destroy_sessionOpsAmount = {0};
156 std::atomic_int free_stateidOpsAmount = {0};
157 std::atomic_int get_dir_delegationOpsAmount = {0};
158 std::atomic_int getdeviceinfoOpsAmount = {0};
159 std::atomic_int getdevicelistOpsAmount = {0};
160 std::atomic_int layoutcommitOpsAmount = {0};
161 std::atomic_int layoutgetOpsAmount = {0};
162 std::atomic_int layoutreturnOpsAmount = {0};
163 std::atomic_int secinfo_no_nameOpsAmount = {0};
164 std::atomic_int sequenceOpsAmount = {0};
165 std::atomic_int set_ssvOpsAmount = {0};
166 std::atomic_int test_stateidOpsAmount = {0};
167 std::atomic_int want_delegationOpsAmount = {0};
168 std::atomic_int destroy_clientidOpsAmount = {0};
169 std::atomic_int reclaim_completeOpsAmount = {0};
170 std::atomic_int illegalOpsAmount = {0};
171171 };
172172
173173 JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog);
264264 const struct NFS3::COMMIT3res* /*res*/) override final;
265265
266266 // NFS4.0 procedures
267
267
268268 void null4(const RPCProcedure* /*proc*/,
269269 const struct NFS4::NULL4args* /*args*/,
270270 const struct NFS4::NULL4res* /*res*/) override final;
279279 const struct NFS4::ACCESS4args* /* args */,
280280 const struct NFS4::ACCESS4res* res) override final;
281281 void close40(const RPCProcedure* /* proc */,
282 const struct NFS4::CLOSE4args* /* args */,
283 const struct NFS4::CLOSE4res* res) override final;
282 const struct NFS4::CLOSE4args* /* args */,
283 const struct NFS4::CLOSE4res* res) override final;
284284 void commit40(const RPCProcedure* /* proc */,
285285 const struct NFS4::COMMIT4args* /* args */,
286286 const struct NFS4::COMMIT4res* res) override final;
386386 const struct NFS4::ILLEGAL4res* res) override final;
387387
388388 // NFSv4.1 procedures
389
389
390390 void compound41(const RPCProcedure* /*proc*/,
391391 const struct NFS41::COMPOUND4args* /*args*/,
392392 const struct NFS41::COMPOUND4res* /*res*/) override final;
397397 const struct NFS41::ACCESS4args* /* args */,
398398 const struct NFS41::ACCESS4res* res) override final;
399399 void close41(const RPCProcedure* /* proc */,
400 const struct NFS41::CLOSE4args* /* args */,
401 const struct NFS41::CLOSE4res* res) override final;
400 const struct NFS41::CLOSE4args* /* args */,
401 const struct NFS41::CLOSE4res* res) override final;
402402 void commit41(const RPCProcedure* /* proc */,
403403 const struct NFS41::COMMIT4args* /* args */,
404404 const struct NFS41::COMMIT4res* res) override final;
501501 const struct NFS41::BACKCHANNEL_CTL4args* /* args */,
502502 const struct NFS41::BACKCHANNEL_CTL4res* res) override final;
503503 void bind_conn_to_session41(const RPCProcedure* /* proc */,
504 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
504 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
505505 const struct NFS41::BIND_CONN_TO_SESSION4res* res) override final;
506506 void exchange_id41(const RPCProcedure* /* proc */,
507507 const struct NFS41::EXCHANGE_ID4args* /* args */,
534534 const struct NFS41::LAYOUTRETURN4args* /* args */,
535535 const struct NFS41::LAYOUTRETURN4res* res) override final;
536536 void secinfo_no_name41(const RPCProcedure* /* proc */,
537 const NFS41::SECINFO_NO_NAME4args* /* args */,
538 const NFS41::SECINFO_NO_NAME4res* res) override final;
537 const NFS41::SECINFO_NO_NAME4args* /* args */,
538 const NFS41::SECINFO_NO_NAME4res* res) override final;
539539 void sequence41(const RPCProcedure* /* proc */,
540540 const struct NFS41::SEQUENCE4args* /* args */,
541541 const struct NFS41::SEQUENCE4res* res) override final;
576576
577577 private:
578578 JsonTcpService _jsonTcpService;
579 NfsV3Stat _nfsV3Stat;
580 NfsV40Stat _nfsV40Stat;
581 NfsV41Stat _nfsV41Stat;
579 NfsV3Stat _nfsV3Stat;
580 NfsV40Stat _nfsV40Stat;
581 NfsV41Stat _nfsV41Stat;
582582 };
583583 //------------------------------------------------------------------------------
584 #endif//JSON_ANALYZER_H
585 //------------------------------------------------------------------------------
584 #endif //JSON_ANALYZER_H
585 //------------------------------------------------------------------------------
2222 #include "json_analyzer.h"
2323 //------------------------------------------------------------------------------
2424
25 static constexpr int DefaultPort = 8888;
26 static constexpr const char * DefaultHost = IpEndpoint::WildcardAddress;
27 static constexpr std::size_t DefaultWorkersAmount = 10U;
28 static constexpr int DefaultBacklog = 15;
25 static constexpr int DefaultPort = 8888;
26 static constexpr const char* DefaultHost = IpEndpoint::WildcardAddress;
27 static constexpr std::size_t DefaultWorkersAmount = 10U;
28 static constexpr int DefaultBacklog = 15;
2929 static constexpr std::size_t DefaultMaxServingDurationMs = 500U;
3030
31 extern "C"
31 extern "C" {
32
33 const char* usage()
3234 {
35 return "host - Network interface to listen (default is to listen all interfaces)\n"
36 "port - IP-port to bind to (default is 8888)\n"
37 "workers - Amount of worker threads (default is 10)\n"
38 "duration - Max serving duration in milliseconds (default is 500 ms)\n"
39 "backlog - Listen backlog (default is 15)";
40 }
3341
34 const char* usage()
42 IAnalyzer* create(const char* opts)
43 {
44 // Initializing plugin options with default values
45 int backlog = DefaultBacklog;
46 std::size_t maxServingDurationMs = DefaultMaxServingDurationMs;
47 std::string host{DefaultHost};
48 int port = DefaultPort;
49 std::size_t workersAmount = DefaultWorkersAmount;
50 // Parising plugin options
51 enum
3552 {
36 return "host - Network interface to listen (default is to listen all interfaces)\n"
37 "port - IP-port to bind to (default is 8888)\n"
38 "workers - Amount of worker threads (default is 10)\n"
39 "duration - Max serving duration in milliseconds (default is 500 ms)\n"
40 "backlog - Listen backlog (default is 15)";
41 }
42
43 IAnalyzer* create(const char* opts)
44 {
45 // Initializing plugin options with default values
46 int backlog = DefaultBacklog;
47 std::size_t maxServingDurationMs = DefaultMaxServingDurationMs;
48 std::string host{DefaultHost};
49 int port = DefaultPort;
50 std::size_t workersAmount = DefaultWorkersAmount;
51 // Parising plugin options
52 enum
53 {
54 BACKLOG_SUBOPT_INDEX = 0,
55 DURATION_SUBOPT_INDEX,
56 HOST_SUBOPT_INDEX,
57 PORT_SUBOPT_INDEX,
58 WORKERS_SUBOPT_INDEX
59 };
60 char backlogSubOptName[] = "backlog";
61 char durationSubOptName[] = "duration";
62 char hostSubOptName[] = "host";
63 char portSubOptName[] = "port";
64 char workersSubOptName[] = "workers";
65 char* const tokens[] =
53 BACKLOG_SUBOPT_INDEX = 0,
54 DURATION_SUBOPT_INDEX,
55 HOST_SUBOPT_INDEX,
56 PORT_SUBOPT_INDEX,
57 WORKERS_SUBOPT_INDEX
58 };
59 char backlogSubOptName[] = "backlog";
60 char durationSubOptName[] = "duration";
61 char hostSubOptName[] = "host";
62 char portSubOptName[] = "port";
63 char workersSubOptName[] = "workers";
64 char* const tokens[] =
6665 {
6766 backlogSubOptName,
6867 durationSubOptName,
6968 hostSubOptName,
7069 portSubOptName,
7170 workersSubOptName,
72 NULL
73 };
74 std::size_t optsLen = strlen(opts);
75 std::vector<char> optsBuf{opts, opts + optsLen + 2};
76 char* optionp = &optsBuf[0];
77 char* valuep;
78 int optIndex;
79 while ((optIndex = getsubopt(&optionp, tokens, &valuep)) >= 0)
71 NULL};
72 std::size_t optsLen = strlen(opts);
73 std::vector<char> optsBuf{opts, opts + optsLen + 2};
74 char* optionp = &optsBuf[0];
75 char* valuep;
76 int optIndex;
77 while((optIndex = getsubopt(&optionp, tokens, &valuep)) >= 0)
78 {
79 try
8080 {
81 try
81 switch(optIndex)
8282 {
83 switch (optIndex)
84 {
85 case BACKLOG_SUBOPT_INDEX:
86 backlog = std::stoi(valuep);
87 break;
88 case DURATION_SUBOPT_INDEX:
89 maxServingDurationMs = std::stoul(valuep);
90 break;
91 case HOST_SUBOPT_INDEX:
92 host = valuep;
93 break;
94 case PORT_SUBOPT_INDEX:
95 port = std::stoi(valuep);
96 break;
97 case WORKERS_SUBOPT_INDEX:
98 workersAmount = std::stoul(valuep);
99 break;
100 default:
101 throw std::runtime_error{std::string{"Invalid suboption index: "} + std::to_string(optIndex)};
102 }
103 }
104 catch (std::logic_error& e)
105 {
106 throw std::runtime_error{std::string{"Invalid value provided for '"} + tokens[optIndex] + "' suboption"};
83 case BACKLOG_SUBOPT_INDEX:
84 backlog = std::stoi(valuep);
85 break;
86 case DURATION_SUBOPT_INDEX:
87 maxServingDurationMs = std::stoul(valuep);
88 break;
89 case HOST_SUBOPT_INDEX:
90 host = valuep;
91 break;
92 case PORT_SUBOPT_INDEX:
93 port = std::stoi(valuep);
94 break;
95 case WORKERS_SUBOPT_INDEX:
96 workersAmount = std::stoul(valuep);
97 break;
98 default:
99 throw std::runtime_error{std::string{"Invalid suboption index: "} + std::to_string(optIndex)};
107100 }
108101 }
109 // Creating and returning plugin
110 return new JsonAnalyzer{workersAmount, port, host, maxServingDurationMs, backlog};
102 catch(std::logic_error& e)
103 {
104 throw std::runtime_error{std::string{"Invalid value provided for '"} + tokens[optIndex] + "' suboption"};
105 }
111106 }
107 // Creating and returning plugin
108 return new JsonAnalyzer{workersAmount, port, host, maxServingDurationMs, backlog};
109 }
112110
113 void destroy(IAnalyzer* instance)
114 {
115 delete instance;
116 }
111 void destroy(IAnalyzer* instance)
112 {
113 delete instance;
114 }
117115
118 NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr)
116 NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr)
119117
120118 } //extern "C"
121119
2828 //------------------------------------------------------------------------------
2929
3030 JsonTcpService::JsonTcpService(JsonAnalyzer& analyzer, std::size_t workersAmount, int port, const std::string& host,
31 std::size_t maxServingDurationMs, int backlog) :
32 AbstractTcpService{workersAmount, port, host, backlog},
33 _analyzer(analyzer),
34 _maxServingDurationMs{maxServingDurationMs}
35 {}
31 std::size_t maxServingDurationMs, int backlog)
32 : AbstractTcpService{workersAmount, port, host, backlog}
33 , _analyzer(analyzer)
34 , _maxServingDurationMs{maxServingDurationMs}
35 {
36 }
3637
3738 AbstractTcpService::AbstractTask* JsonTcpService::createTask(int socket)
3839 {
4142
4243 //------------------------------------------------------------------------------
4344
44 JsonTcpService::Task::Task(JsonTcpService& service, int socket) :
45 AbstractTask{socket},
46 _service(service)
47 {}
45 JsonTcpService::Task::Task(JsonTcpService& service, int socket)
46 : AbstractTask{socket}
47 , _service(service)
48 {
49 }
4850
4951 void JsonTcpService::Task::execute()
5052 {
5153 std::chrono::system_clock::time_point servingStarted = std::chrono::system_clock::now();
5254 // Composing JSON with statistics
53 struct json_object* root = json_object_new_object();
55 struct json_object* root = json_object_new_object();
5456 struct json_object* nfsV3Stat = json_object_new_object();
5557 // NFS3 procedures:
5658 json_object_object_add(nfsV3Stat, "null", json_object_new_int64(_service._analyzer.getNfsV3Stat().nullProcsAmount.load()));
189191
190192 // Sending JSON to the client
191193 std::size_t totalBytesSent = 0U;
192 while (totalBytesSent < json.length())
194 while(totalBytesSent < json.length())
193195 {
194 if (!_service.isRunning())
196 if(!_service.isRunning())
195197 {
196198 LOG("WARNING: Service shutdown detected - terminating task execution");
197199 return;
198200 }
199 if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - servingStarted).count() >
200 static_cast<std::chrono::milliseconds::rep>(_service._maxServingDurationMs))
201 if(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - servingStarted).count() >
202 static_cast<std::chrono::milliseconds::rep>(_service._maxServingDurationMs))
201203 {
202204 // TODO: Use general logging
203205 LOG("WARNING: A client is too slow - terminating task execution");
209211 FD_ZERO(&writeDescriptorsSet);
210212 FD_SET(socket(), &writeDescriptorsSet);
211213 int descriptorsCount = pselect(socket() + 1, NULL, &writeDescriptorsSet, NULL, &writeDuration, NULL);
212 if (descriptorsCount < 0)
214 if(descriptorsCount < 0)
213215 {
214216 throw std::system_error{errno, std::system_category(), "Error awaiting for sending data availability on socket"};
215217 }
216 else if (descriptorsCount == 0)
218 else if(descriptorsCount == 0)
217219 {
218220 // Timeout expired
219221 continue;
220222 }
221223 ssize_t bytesSent = send(socket(), json.data() + totalBytesSent, json.length() - totalBytesSent, MSG_NOSIGNAL);
222 if (bytesSent < 0)
224 if(bytesSent < 0)
223225 {
224226 std::system_error e{errno, std::system_category(), "Sending data to client error"};
225227 LOG("WARNING: %s", e.what());
226228 return;
227229 }
228 else if (bytesSent == 0)
230 else if(bytesSent == 0)
229231 {
230232 LOG("WARNING: Connection has been aborted by client while sending data");
231233 return;
2929 JsonTcpService() = delete;
3030 JsonTcpService(class JsonAnalyzer& analyzer, std::size_t workersAmount, int port, const std::string& host,
3131 std::size_t maxServingDurationMs, int backlog);
32
3233 private:
3334 class Task : public AbstractTask
3435 {
3738 Task() = delete;
3839
3940 void execute() override final;
41
4042 private:
4143 JsonTcpService& _service;
4244 };
4446 AbstractTask* createTask(int socket) override final;
4547
4648 JsonAnalyzer& _analyzer;
47 std::size_t _maxServingDurationMs;
49 std::size_t _maxServingDurationMs;
4850 };
4951 //------------------------------------------------------------------------------
50 #endif//JSON_TCP_SERVICE_H
52 #endif //JSON_TCP_SERVICE_H
5153 //------------------------------------------------------------------------------
2626 class TestAnalyzer : public IAnalyzer
2727 {
2828 public:
29 TestAnalyzer(const char* opts):options(opts)
29 TestAnalyzer(const char* opts)
30 : options(opts)
3031 {
3132 std::cout << "TestAnalyzer::TestAnalyzer(" << options << ')' << std::endl;
3233 }
3940 // NFSv3 procedures
4041
4142 void null(const RPCProcedure* /*proc*/,
42 const struct NFS3::NULL3args* /*args*/,
43 const struct NFS3::NULL3res* /*res*/) override final
43 const struct NFS3::NULL3args* /*args*/,
44 const struct NFS3::NULL3res* /*res*/) override final
4445 {
4546 std::cout << "TestAnalyzer::null()" << std::endl;
4647 }
4748
4849 void getattr3(const RPCProcedure* /*proc*/,
49 const struct NFS3::GETATTR3args* /*args*/,
50 const struct NFS3::GETATTR3res* /*res*/) override final
50 const struct NFS3::GETATTR3args* /*args*/,
51 const struct NFS3::GETATTR3res* /*res*/) override final
5152 {
5253 std::cout << "TestAnalyzer::getattr3()" << std::endl;
5354 }
5455
5556 void setattr3(const RPCProcedure* /*proc*/,
56 const struct NFS3::SETATTR3args* /*args*/,
57 const struct NFS3::SETATTR3res* /*res*/) override final
57 const struct NFS3::SETATTR3args* /*args*/,
58 const struct NFS3::SETATTR3res* /*res*/) override final
5859 {
5960 std::cout << "TestAnalyzer::setattr3()" << std::endl;
6061 }
6162
6263 void lookup3(const RPCProcedure* /*proc*/,
63 const struct NFS3::LOOKUP3args* /*args*/,
64 const struct NFS3::LOOKUP3res* /*res*/) override final
64 const struct NFS3::LOOKUP3args* /*args*/,
65 const struct NFS3::LOOKUP3res* /*res*/) override final
6566 {
6667 std::cout << "TestAnalyzer::lookup3()" << std::endl;
6768 }
6869
6970 void access3(const RPCProcedure* /*proc*/,
70 const struct NFS3::ACCESS3args* /*args*/,
71 const struct NFS3::ACCESS3res* /*res*/) override final
71 const struct NFS3::ACCESS3args* /*args*/,
72 const struct NFS3::ACCESS3res* /*res*/) override final
7273 {
7374 std::cout << "TestAnalyzer::access3()" << std::endl;
7475 }
7576
7677 void readlink3(const RPCProcedure* /*proc*/,
77 const struct NFS3::READLINK3args* /*args*/,
78 const struct NFS3::READLINK3res* /*res*/) override final
78 const struct NFS3::READLINK3args* /*args*/,
79 const struct NFS3::READLINK3res* /*res*/) override final
7980 {
8081 std::cout << "TestAnalyzer::readlink3()" << std::endl;
8182 }
8283
8384 void read3(const RPCProcedure* /*proc*/,
84 const struct NFS3::READ3args* /*args*/,
85 const struct NFS3::READ3res* /*res*/) override final
85 const struct NFS3::READ3args* /*args*/,
86 const struct NFS3::READ3res* /*res*/) override final
8687 {
8788 std::cout << "TestAnalyzer::read3()" << std::endl;
8889 }
8990
9091 void write3(const RPCProcedure* /*proc*/,
91 const struct NFS3::WRITE3args* /*args*/,
92 const struct NFS3::WRITE3res* /*res*/) override final
92 const struct NFS3::WRITE3args* /*args*/,
93 const struct NFS3::WRITE3res* /*res*/) override final
9394 {
9495 std::cout << "TestAnalyzer::write3()" << std::endl;
9596 }
9697
9798 void create3(const RPCProcedure* /*proc*/,
98 const struct NFS3::CREATE3args* /*args*/,
99 const struct NFS3::CREATE3res* /*res*/) override final
99 const struct NFS3::CREATE3args* /*args*/,
100 const struct NFS3::CREATE3res* /*res*/) override final
100101 {
101102 std::cout << "TestAnalyzer::create3()" << std::endl;
102103 }
103104
104105 void mkdir3(const RPCProcedure* /*proc*/,
105 const struct NFS3::MKDIR3args* /*args*/,
106 const struct NFS3::MKDIR3res* /*res*/) override final
106 const struct NFS3::MKDIR3args* /*args*/,
107 const struct NFS3::MKDIR3res* /*res*/) override final
107108 {
108109 std::cout << "TestAnalyzer::mkdir3()" << std::endl;
109110 }
110111
111112 void symlink3(const RPCProcedure* /*proc*/,
112 const struct NFS3::SYMLINK3args* /*args*/,
113 const struct NFS3::SYMLINK3res* /*res*/) override final
113 const struct NFS3::SYMLINK3args* /*args*/,
114 const struct NFS3::SYMLINK3res* /*res*/) override final
114115 {
115116 std::cout << "TestAnalyzer::symlink3()" << std::endl;
116117 }
117118
118119 void mknod3(const RPCProcedure* /*proc*/,
119 const struct NFS3::MKNOD3args* /*args*/,
120 const struct NFS3::MKNOD3res* /*res*/) override final
120 const struct NFS3::MKNOD3args* /*args*/,
121 const struct NFS3::MKNOD3res* /*res*/) override final
121122 {
122123 std::cout << "TestAnalyzer::mknod3()" << std::endl;
123124 }
124125
125126 void remove3(const RPCProcedure* /*proc*/,
126 const struct NFS3::REMOVE3args* /*args*/,
127 const struct NFS3::REMOVE3res* /*res*/) override final
127 const struct NFS3::REMOVE3args* /*args*/,
128 const struct NFS3::REMOVE3res* /*res*/) override final
128129 {
129130 std::cout << "TestAnalyzer::remove3()" << std::endl;
130131 }
131132
132133 void rmdir3(const RPCProcedure* /*proc*/,
133 const struct NFS3::RMDIR3args* /*args*/,
134 const struct NFS3::RMDIR3res* /*res*/) override final
134 const struct NFS3::RMDIR3args* /*args*/,
135 const struct NFS3::RMDIR3res* /*res*/) override final
135136 {
136137 std::cout << "TestAnalyzer::rmdir3()" << std::endl;
137138 }
138139
139140 void rename3(const RPCProcedure* /*proc*/,
140 const struct NFS3::RENAME3args* /*args*/,
141 const struct NFS3::RENAME3res* /*res*/) override final
141 const struct NFS3::RENAME3args* /*args*/,
142 const struct NFS3::RENAME3res* /*res*/) override final
142143 {
143144 std::cout << "TestAnalyzer::rename3()" << std::endl;
144145 }
145146
146147 void link3(const RPCProcedure* /*proc*/,
147 const struct NFS3::LINK3args* /*args*/,
148 const struct NFS3::LINK3res* /*res*/) override final
148 const struct NFS3::LINK3args* /*args*/,
149 const struct NFS3::LINK3res* /*res*/) override final
149150 {
150151 std::cout << "TestAnalyzer::link3()" << std::endl;
151152 }
152153
153154 void readdir3(const RPCProcedure* /*proc*/,
154 const struct NFS3::READDIR3args* /*args*/,
155 const struct NFS3::READDIR3res* /*res*/) override final
155 const struct NFS3::READDIR3args* /*args*/,
156 const struct NFS3::READDIR3res* /*res*/) override final
156157 {
157158 std::cout << "TestAnalyzer::readdir3()" << std::endl;
158159 }
159160
160161 void readdirplus3(const RPCProcedure* /*proc*/,
161 const struct NFS3::READDIRPLUS3args* /*args*/,
162 const struct NFS3::READDIRPLUS3res* /*res*/) override final
162 const struct NFS3::READDIRPLUS3args* /*args*/,
163 const struct NFS3::READDIRPLUS3res* /*res*/) override final
163164 {
164165 std::cout << "TestAnalyzer::readdirplus3()" << std::endl;
165166 }
166167
167168 void fsstat3(const RPCProcedure* /*proc*/,
168 const struct NFS3::FSSTAT3args* /*args*/,
169 const struct NFS3::FSSTAT3res* /*res*/) override final
169 const struct NFS3::FSSTAT3args* /*args*/,
170 const struct NFS3::FSSTAT3res* /*res*/) override final
170171 {
171172 std::cout << "TestAnalyzer::fsstat3()" << std::endl;
172173 }
173174
174175 void fsinfo3(const RPCProcedure* /*proc*/,
175 const struct NFS3::FSINFO3args* /*args*/,
176 const struct NFS3::FSINFO3res* /*res*/) override final
176 const struct NFS3::FSINFO3args* /*args*/,
177 const struct NFS3::FSINFO3res* /*res*/) override final
177178 {
178179 std::cout << "TestAnalyzer::fsinfo3()" << std::endl;
179180 }
180181
181182 void pathconf3(const RPCProcedure* /*proc*/,
182 const struct NFS3::PATHCONF3args* /*args*/,
183 const struct NFS3::PATHCONF3res* /*res*/) override final
183 const struct NFS3::PATHCONF3args* /*args*/,
184 const struct NFS3::PATHCONF3res* /*res*/) override final
184185 {
185186 std::cout << "TestAnalyzer::pathconf3()" << std::endl;
186187 }
187188
188189 void commit3(const RPCProcedure* /*proc*/,
189 const struct NFS3::COMMIT3args* /*args*/,
190 const struct NFS3::COMMIT3res* /*res*/) override final
190 const struct NFS3::COMMIT3args* /*args*/,
191 const struct NFS3::COMMIT3res* /*res*/) override final
191192 {
192193 std::cout << "TestAnalyzer::commit3()" << std::endl;
193194 }
201202 std::cout << "TestAnalyzer::null4()" << std::endl;
202203 }
203204 void compound4(const RPCProcedure* /*proc*/,
204 const struct NFS4::COMPOUND4args* /*args*/,
205 const struct NFS4::COMPOUND4res* /*res*/) override final
205 const struct NFS4::COMPOUND4args* /*args*/,
206 const struct NFS4::COMPOUND4res* /*res*/) override final
206207 {
207208 std::cout << "TestAnalyzer::compound4()" << std::endl;
208209 }
216217 std::cout << "TestAnalyzer" << std::endl;
217218 }
218219 void close40(const RPCProcedure* /* proc */,
219 const struct NFS4::CLOSE4args* /* args */,
220 const struct NFS4::CLOSE4res* /* res */) override final
220 const struct NFS4::CLOSE4args* /* args */,
221 const struct NFS4::CLOSE4res* /* res */) override final
221222 {
222223 std::cout << "TestAnalyzer" << std::endl;
223224 }
439440 // NFSv4.1 procedures
440441
441442 void compound41(const RPCProcedure* /*proc*/,
442 const struct NFS41::COMPOUND4args* /*args*/,
443 const struct NFS41::COMPOUND4res* /*res*/) override final
443 const struct NFS41::COMPOUND4args* /*args*/,
444 const struct NFS41::COMPOUND4res* /*res*/) override final
444445 {
445446 std::cout << "TestAnalyzer::compound4()" << std::endl;
446447 }
454455 std::cout << "TestAnalyzer" << std::endl;
455456 }
456457 void close41(const RPCProcedure* /* proc */,
457 const struct NFS41::CLOSE4args* /* args */,
458 const struct NFS41::CLOSE4res* /* res */) override final
458 const struct NFS41::CLOSE4args* /* args */,
459 const struct NFS41::CLOSE4res* /* res */) override final
459460 {
460461 std::cout << "TestAnalyzer" << std::endl;
461462 }
669670 std::cout << "TestAnalyzer" << std::endl;
670671 }
671672 void bind_conn_to_session41(const RPCProcedure* /* proc */,
672 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
673 const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */,
673674 const struct NFS41::BIND_CONN_TO_SESSION4res* /* res */) override final
674675 {
675676 std::cout << "TestAnalyzer" << std::endl;
735736 std::cout << "TestAnalyzer" << std::endl;
736737 }
737738 void secinfo_no_name41(const RPCProcedure* /* proc */,
738 const NFS41::SECINFO_NO_NAME4args* /* args */,
739 const NFS41::SECINFO_NO_NAME4res* /* res */) override final
739 const NFS41::SECINFO_NO_NAME4args* /* args */,
740 const NFS41::SECINFO_NO_NAME4res* /* res */) override final
740741 {
741742 std::cout << "TestAnalyzer" << std::endl;
742743 }
782783 std::cout << "TestAnalyzer" << std::endl;
783784 }
784785
785 virtual void flush_statistics()
786 virtual void flush_statistics() override
786787 {
787788 std::cout << "TestAnalyzer::flush_statistics()" << std::endl;
788789 }
790
789791 private:
790792 std::string options;
791793 };
792794
793 extern "C"
794 {
795 extern "C" {
795796
796797 const char* usage()
797798 {
814815 return &requirements;
815816 }
816817
817 NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr)
818
819 }//extern "C"
818 NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr)
819
820 } //extern "C"
820821 //------------------------------------------------------------------------------
2929 //------------------------------------------------------------------------------
3030 namespace HEADER
3131 {
32 const int MEMO_LINE = 1;
33 const int HOST_LINE = 2;
34 const int DATE_LINE = 3;
32 const int MEMO_LINE = 1;
33 const int HOST_LINE = 2;
34 const int DATE_LINE = 3;
3535 const int ELAPSED_LINE = 4;
36 const int HOST_SIZE = 128;
36 const int HOST_SIZE = 128;
3737 }
3838
3939 void HeaderWindow::destroy()
4040 {
41 if (_window == nullptr)
41 if(_window == nullptr)
4242 {
4343 return;
4444 }
4949 }
5050
5151 HeaderWindow::HeaderWindow(MainWindow& w)
52 : _start_time {time(NULL)}
52 : _start_time{time(NULL)}
5353 {
54 if (w._window == nullptr)
54 if(w._window == nullptr)
5555 {
5656 throw std::runtime_error("Initialization of Header window failed.");
5757 }
6464
6565 void HeaderWindow::update()
6666 {
67 if (_window == nullptr)
67 if(_window == nullptr)
6868 {
6969 return;
7070 }
7171 time_t actual_time = time(nullptr);
72 tm* t = localtime(&actual_time);
73 time_t shift_time = actual_time - _start_time;
72 tm* t = localtime(&actual_time);
73 time_t shift_time = actual_time - _start_time;
7474 /* tm starts with 0 month and 1900 year*/
7575 mvwprintw(_window, HEADER::DATE_LINE, FIRST_CHAR_POS, "Date: \t %d.%d.%d \t Time: %d:%d:%d ", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900, t->tm_hour, t->tm_min, t->tm_sec);
7676 mvwprintw(_window, HEADER::ELAPSED_LINE, FIRST_CHAR_POS, "Elapsed time: \t %d days; %d:%d:%d times",
7777 shift_time / SECINDAY, shift_time % SECINDAY / SECINHOUR, shift_time % SECINHOUR / SECINMIN, shift_time % SECINMIN);
78 wrefresh (_window);
78 wrefresh(_window);
7979 }
8080
8181 void HeaderWindow::resize(MainWindow& m)
8282 {
83 if (_window != nullptr)
83 if(_window != nullptr)
8484 {
8585 destroy();
8686 }
87 if (m._window != nullptr)
87 if(m._window != nullptr)
8888 {
8989 _window = subwin(m._window, std::min(static_cast<int>(m._window->_maxy), GUI_HEADER_HEIGHT), std::min(static_cast<int>(m._window->_maxx), GUI_LENGTH), 0, 0);
9090 }
91 if (_window != nullptr)
91 if(_window != nullptr)
9292 {
9393 werase(_window);
94 wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER , ACS_LLCORNER, ACS_LRCORNER);
94 wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);
9595 char HOST_NAME[HEADER::HOST_SIZE];
9696 gethostname(HOST_NAME, HEADER::HOST_SIZE);
9797 mvwprintw(_window, HEADER::MEMO_LINE, FIRST_CHAR_POS, "%s", "Nfstrace watch plugin. To scroll press up or down keys. Ctrl + c to exit.");
2828 class HeaderWindow
2929 {
3030 WINDOW* _window;
31 time_t _start_time;
32 void destroy();
31 time_t _start_time;
32 void destroy();
3333
3434 public:
3535 HeaderWindow() = delete;
4545 void resize(MainWindow&);
4646 };
4747 //------------------------------------------------------------------------------
48 #endif//HEADER_WINDOWS_H
48 #endif //HEADER_WINDOWS_H
4949 //------------------------------------------------------------------------------
2626 //------------------------------------------------------------------------------
2727 void MainWindow::init()
2828 {
29 if (_window != nullptr)
29 if(_window != nullptr)
3030 {
3131 destroy();
3232 }
3333 _window = initscr();
34 if (_window == nullptr)
34 if(_window == nullptr)
3535 {
3636 throw std::runtime_error("Initialization of Main window failed.");
3737 }
3838 noecho();
3939 cbreak();
40 intrflush(stdscr, false); // flush main window
41 curs_set(0); // disable blinking cursore
42
43 keypad(_window, true); // init keyboard
44 timeout(200); // set keyboard timeout
45
46 start_color(); // set background color
47 if (_window != nullptr)
40 intrflush(stdscr, false); // flush main window
41 curs_set(0); // disable blinking cursore
42 keypad(_window, true); // init keyboard
43 timeout(200); // set keyboard timeout
44 start_color(); // set background color
45 if(_window != nullptr)
4846 {
4947 werase(_window);
5048 }
6260
6361 void MainWindow::cleanStdin(int key)
6462 {
65 while ((key != EOF) && (key != '\n') && (key != ' '))
63 while((key != EOF) && (key != '\n') && (key != ' '))
6664 {
6765 key = getch();
6866 }
6967 }
7068
7169 MainWindow::MainWindow()
72 : _window {nullptr}
70 : _window{nullptr}
7371 {
7472 init();
7573 }
8381 {
8482 int key = wgetch(_window);
8583
86 if (key != KEY_UP && key != KEY_DOWN && key != KEY_LEFT && key != KEY_RIGHT)
84 if(key != KEY_UP && key != KEY_DOWN && key != KEY_LEFT && key != KEY_RIGHT)
8785 {
8886 key = 0;
8987 }
9391
9492 void MainWindow::resize()
9593 {
96 if (_window != nullptr)
94 if(_window != nullptr)
9795 {
9896 destroy();
9997 }
102100
103101 void MainWindow::update() const
104102 {
105 if (_window != nullptr)
103 if(_window != nullptr)
106104 {
107105 refresh();
108106 }
109107 }
110 //------------------------------------------------------------------------------
108 //------------------------------------------------------------------------------
3131
3232 void init();
3333 void destroy();
34
3435 static void cleanStdin(int);
3536
3637 public:
37
3838 MainWindow();
3939 ~MainWindow();
4040
5151 void update() const;
5252 };
5353 //------------------------------------------------------------------------------
54 #endif//MAIN_WINDOW_H
54 #endif //MAIN_WINDOW_H
5555 //------------------------------------------------------------------------------
2323 //------------------------------------------------------------------------------
2424 namespace
2525 {
26
2726 const unsigned int SECINMIN = 60;
2827 const unsigned int SECINHOUR = 60 * 60;
2928 const unsigned int SECINDAY = 60 * 60 * 24;
4039
4140 const int FIRST_CHAR_POS = 1;
4241 const int EMPTY_LINE = 1;
43
4442 }
4543 //------------------------------------------------------------------------------
46 #endif//NC_WINDOW_CONST_H
44 #endif //NC_WINDOW_CONST_H
4745 //------------------------------------------------------------------------------
2828 //------------------------------------------------------------------------------
2929 namespace STATISTICS
3030 {
31 const int PROTOCOLS_LINE = 1;
31 const int PROTOCOLS_LINE = 1;
3232 const int FIRST_OPERATION_LINE = 3;
33 const int DEFAULT_LINES = 10;
34 const int DEFAULT_GROUP = 1;
33 const int DEFAULT_LINES = 10;
34 const int DEFAULT_GROUP = 1;
3535 }
3636
3737 void StatisticsWindow::destroy()
3838 {
39 if (_window == nullptr)
39 if(_window == nullptr)
4040 {
4141 return;
4242 }
4848
4949 bool StatisticsWindow::canWrite(unsigned int i)
5050 {
51 return (i >= _scrollOffset.at(_activeProtocol) + STATISTICS::FIRST_OPERATION_LINE && i - _scrollOffset.at(_activeProtocol) + BORDER_SIZE < static_cast<unsigned int>(_window->_maxy));
51 return (i >= _scrollOffset.at(_activeProtocol) + STATISTICS::FIRST_OPERATION_LINE && i - _scrollOffset.at(_activeProtocol) + BORDER_SIZE < static_cast<unsigned int>(_window->_maxy));
5252 }
5353
5454 StatisticsWindow::StatisticsWindow(MainWindow& w, StatisticsContainers& c)
55 : _window {nullptr}
56 , _activeProtocol {nullptr}
55 : _window{nullptr}
56 , _activeProtocol{nullptr}
5757 {
58 if (w._window == nullptr)
58 if(w._window == nullptr)
5959 {
6060 throw std::runtime_error("Initialization of Header window failed.");
6161 }
62 for (auto i : c)
62 for(auto i : c)
6363 {
6464 _allProtocols.push_back((i.first)->getProtocolName());
6565 _scrollOffset.insert(std::make_pair<AbstractProtocol*, std::size_t>(reinterpret_cast<AbstractProtocol*>(i.first), 0));
6666 };
6767 _activeProtocol = (c.begin())->first;
68 _statistic = c.at(_activeProtocol);
68 _statistic = c.at(_activeProtocol);
6969 resize(w);
7070 }
7171
7575
7676 void StatisticsWindow::scrollContent(int i)
7777 {
78 if (i > 0 && _scrollOffset.at(_activeProtocol) <= MAXSHIFT - SHIFTCU)
78 if(i > 0 && _scrollOffset.at(_activeProtocol) <= MAXSHIFT - SHIFTCU)
7979 {
8080 _scrollOffset.at(_activeProtocol) += SHIFTCU;
8181 updateProtocol(_activeProtocol);
8282 }
83 else if (i < 0 && _scrollOffset.at(_activeProtocol) >= SHIFTCU)
83 else if(i < 0 && _scrollOffset.at(_activeProtocol) >= SHIFTCU)
8484 {
8585 _scrollOffset.at(_activeProtocol) -= SHIFTCU;
8686 updateProtocol(_activeProtocol);
9191 {
9292 if(p != nullptr)
9393 _activeProtocol = p;
94 if (_window == nullptr)
94 if(_window == nullptr)
9595 {
9696 return;
9797 }
9898 werase(_window);
99 wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER , ACS_LLCORNER, ACS_LRCORNER);
99 wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);
100100
101101 std::string tmp(" ");
102 for_each (_allProtocols.begin(), _allProtocols.end(), [&](std::string& s)
103 {
104 if (!s.compare(_activeProtocol->getProtocolName()))
102 for_each(_allProtocols.begin(), _allProtocols.end(), [&](std::string& s) {
103 if(!s.compare(_activeProtocol->getProtocolName()))
105104 {
106105 tmp += std::string(" < ") + s + std::string(" > ");
107106 }
111110 }
112111
113112 });
114 mvwprintw(_window, STATISTICS::PROTOCOLS_LINE , FIRST_CHAR_POS, "%s", tmp.c_str());
113 mvwprintw(_window, STATISTICS::PROTOCOLS_LINE, FIRST_CHAR_POS, "%s", tmp.c_str());
115114
116115 unsigned int line = STATISTICS::FIRST_OPERATION_LINE;
117116 for(unsigned int i = STATISTICS::DEFAULT_GROUP; i <= _activeProtocol->getGroups(); i++)
118117 {
119 if ( canWrite(line))
118 if(canWrite(line))
120119 {
121120 mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", "Total:");
122121 }
123122 line++;
124 for (unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++)
123 for(unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++)
125124 {
126 if ( canWrite(line))
125 if(canWrite(line))
127126 {
128127 mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", p->printProcedure(j));
129128 }
131130 }
132131 line++;
133132 }
134
135133 }
136134
137135 void StatisticsWindow::update(const ProtocolStatistic& d)
138136 {
139137 _statistic = d;
140 if (_statistic.empty() || _window == nullptr)
138 if(_statistic.empty() || _window == nullptr)
141139 {
142140 return;
143141 }
151149 {
152150 m += _statistic[tmp];
153151 }
154 if ( canWrite(line))
152 if(canWrite(line))
155153 {
156154 mvwprintw(_window, line - (_scrollOffset.at(_activeProtocol)), FIRST_CHAR_POS + 25, "%d", m);
157155 }
158156 line++;
159 for (unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++)
157 for(unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++)
160158 {
161 if ( canWrite(line))
159 if(canWrite(line))
162160 {
163161 mvwprintw(_window, line - _scrollOffset.at(_activeProtocol), COUNTERS_POS, "%lu ", _statistic[j]);
164162 mvwprintw(_window, line - _scrollOffset.at(_activeProtocol), PERSENT_POS, "%-3.2f%% ",
173171
174172 void StatisticsWindow::resize(MainWindow& m)
175173 {
176 if (_window != nullptr)
174 if(_window != nullptr)
177175 {
178176 destroy();
179177 }
180178 int tmp_size = STATISTICS::DEFAULT_LINES;
181 if (_activeProtocol != nullptr)
179 if(_activeProtocol != nullptr)
182180 {
183181 tmp_size = _activeProtocol->getAmount() + 2 * BORDER_SIZE + 2 * EMPTY_LINE + STATISTICS::PROTOCOLS_LINE + _activeProtocol->getGroups() * EMPTY_LINE * _activeProtocol->getGroups();
184182 }
185 if (m._window != nullptr && m._window->_maxy > GUI_HEADER_HEIGHT)
183 if(m._window != nullptr && m._window->_maxy > GUI_HEADER_HEIGHT)
186184 {
187185 _window = subwin(m._window, std::min(static_cast<int>(m._window->_maxy - GUI_HEADER_HEIGHT), tmp_size),
188186 std::min(static_cast<int>(m._window->_maxx), GUI_LENGTH), GUI_HEADER_HEIGHT - BORDER_SIZE, 0);
2121 #ifndef STATISTICS_WINDOW_H
2222 #define STATISTICS_WINDOW_H
2323 //------------------------------------------------------------------------------
24 #include <vector>
2425 #include <unordered_map>
25 #include <vector>
2626
2727 #include "../protocols/abstract_protocol.h"
2828 #include "main_window.h"
2929 //------------------------------------------------------------------------------
3030 class StatisticsWindow
3131 {
32 using ProtocolStatistic = std::vector<std::size_t>;
32 using ProtocolStatistic = std::vector<std::size_t>;
3333 using StatisticsContainers = std::unordered_map<AbstractProtocol*, ProtocolStatistic>;
3434
35 private:
36 WINDOW* _window;
37 AbstractProtocol* _activeProtocol;
38 std::vector<std::string> _allProtocols;
39 std::unordered_map<AbstractProtocol*, unsigned int> _scrollOffset;
40 ProtocolStatistic _statistic;
41 void destroy();
42 bool canWrite(unsigned int);
43
4435 public:
45 StatisticsWindow() = delete;
4636 StatisticsWindow(MainWindow&, StatisticsContainers&);
4737 ~StatisticsWindow();
4838
6555 /*! Only set active protocol, do not update new protocol's commands.
6656 */
6757 void setProtocol(AbstractProtocol*);
58
59 private:
60 void destroy();
61 bool canWrite(unsigned int);
62
63 WINDOW* _window;
64 AbstractProtocol* _activeProtocol;
65 std::vector<std::string> _allProtocols;
66 std::unordered_map<AbstractProtocol*, unsigned int> _scrollOffset;
67 ProtocolStatistic _statistic;
6868 };
6969 //------------------------------------------------------------------------------
70 #endif//STATISTICS_WINDOWS_H
70 #endif //STATISTICS_WINDOWS_H
7171 //------------------------------------------------------------------------------
2323 //------------------------------------------------------------------------------
2424 namespace
2525 {
26 const int EMPTY_GROUP = 1;
26 const int EMPTY_GROUP = 1;
2727 }
2828
2929 AbstractProtocol::AbstractProtocol(const char* n, std::size_t i)
30 : name {n}
31 , amount {i}
30 : name{n}
31 , amount{i}
3232 {
3333 }
3434
5858
5959 std::size_t AbstractProtocol::getGroupBegin(std::size_t i)
6060 {
61 if( i == EMPTY_GROUP)
61 if(i == EMPTY_GROUP)
6262 return 0;
6363 else
6464 return amount;
6161 std::size_t amount;
6262 };
6363 //------------------------------------------------------------------------------
64 #endif//ABSTRACT_PROTOCOL_H
64 #endif //ABSTRACT_PROTOCOL_H
6565 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <api/plugin_api.h> // include plugin development definitions
22
2223 #include "cifsv1_protocol.h"
2324 //------------------------------------------------------------------------------
2425 //------------------------------------------------------------------------------
2526 CIFSv1Protocol::CIFSv1Protocol()
26 : AbstractProtocol {"CIFS v1", static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)}
27 : AbstractProtocol{"CIFS v1", static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)}
2728 {
2829 }
2930
3334
3435 const char* CIFSv1Protocol::printProcedure(std::size_t i)
3536 {
36 if ( i >= static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)) { return nullptr; }
37 if(i >= static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT))
38 {
39 return nullptr;
40 }
3741 return print_cifs1_procedures(static_cast<SMBv1::SMBv1Commands>(i));
3842 }
3943 //------------------------------------------------------------------------------
3131 virtual const char* printProcedure(std::size_t);
3232 };
3333 //------------------------------------------------------------------------------
34 #endif//CIFSV1_PROTOCOL_H
34 #endif //CIFSV1_PROTOCOL_H
3535 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <api/plugin_api.h> // include plugin development definitions
22
2223 #include "cifsv2_protocol.h"
2324 //------------------------------------------------------------------------------
2425 CIFSv2Protocol::CIFSv2Protocol()
25 : AbstractProtocol {"CIFS v2", static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)}
26 : AbstractProtocol{"CIFS v2", static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)}
2627 {
2728 }
2829
3233
3334 const char* CIFSv2Protocol::printProcedure(std::size_t i)
3435 {
35 if ( i >= static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)) { return nullptr; }
36 if(i >= static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT))
37 {
38 return nullptr;
39 }
3640 return print_cifs2_procedures(static_cast<SMBv2::SMBv2Commands>(i));
3741 }
3842 //------------------------------------------------------------------------------
3131 virtual const char* printProcedure(std::size_t);
3232 };
3333 //------------------------------------------------------------------------------
34 #endif//CIFSV2_PROTOCOL_H
34 #endif //CIFSV2_PROTOCOL_H
3535 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <api/plugin_api.h> // include plugin development definitions
22
2223 #include "nfsv3_protocol.h"
2324 //------------------------------------------------------------------------------
2425 NFSv3Protocol::NFSv3Protocol()
25 : AbstractProtocol {"NFS v3", ProcEnumNFS3::count}
26 : AbstractProtocol{"NFS v3", ProcEnumNFS3::count}
2627 {
2728 }
2829
3233
3334 const char* NFSv3Protocol::printProcedure(std::size_t i)
3435 {
35 if ( i > ProcEnumNFS3::count) { return nullptr; }
36 return print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(i));
36 if(i > ProcEnumNFS3::count)
37 {
38 return nullptr;
39 }
40 return print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(i));
3741 }
3842 //------------------------------------------------------------------------------
3131 virtual const char* printProcedure(std::size_t);
3232 };
3333 //------------------------------------------------------------------------------
34 #endif//NFSV3_PROTOCOL_H
34 #endif //NFSV3_PROTOCOL_H
3535 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <api/plugin_api.h> // include plugin development definitions
22
2223 #include "nfsv41_protocol.h"
2324 //------------------------------------------------------------------------------
2425 namespace
2526 {
2627 const int NFSV41_NUMBEROFGROUPS = 2;
27 const int PROCEDURES_GROUP = 1;
28 const int OPERATIONS_GROUP = 2;
28 const int PROCEDURES_GROUP = 1;
29 const int OPERATIONS_GROUP = 2;
2930 }
3031
3132 NFSv41Protocol::NFSv41Protocol()
32 : AbstractProtocol {"NFS v41", ProcEnumNFS41::count}
33 : AbstractProtocol{"NFS v41", ProcEnumNFS41::count}
3334 {
3435 }
3536
3940
4041 const char* NFSv41Protocol::printProcedure(std::size_t i)
4142 {
42 if ( i > ProcEnumNFS41::count) { return nullptr; }
43 return print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(i));
43 if(i > ProcEnumNFS41::count)
44 {
45 return nullptr;
46 }
47 return print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(i));
4448 }
4549
4650 std::size_t NFSv41Protocol::getGroups()
3333 virtual std::size_t getGroupBegin(std::size_t);
3434 };
3535 //------------------------------------------------------------------------------
36 #endif//NFSV41_PROTOCOL_H
36 #endif //NFSV41_PROTOCOL_H
3737 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <api/plugin_api.h> // include plugin development definitions
22
2223 #include "nfsv4_protocol.h"
2324 //------------------------------------------------------------------------------
2425 namespace
2526 {
2627 const int NFSV4_NUMBER_OF_GROUPS = 2;
27 const int PROCEDURES_GROUP = 1;
28 const int OPERATIONS_GROUP = 2;
28 const int PROCEDURES_GROUP = 1;
29 const int OPERATIONS_GROUP = 2;
2930 }
3031
3132 NFSv4Protocol::NFSv4Protocol()
32 : AbstractProtocol {"NFS v4", ProcEnumNFS4::count}
33 : AbstractProtocol{"NFS v4", ProcEnumNFS4::count}
3334 {
3435 }
3536
3940
4041 const char* NFSv4Protocol::printProcedure(std::size_t i)
4142 {
42 if ( i > ProcEnumNFS4::count) { return nullptr; }
43 return print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(i));
43 if(i > ProcEnumNFS4::count)
44 {
45 return nullptr;
46 }
47 return print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(i));
4448 }
4549
4650 std::size_t NFSv4Protocol::getGroups()
3333 virtual std::size_t getGroupBegin(std::size_t);
3434 };
3535 //------------------------------------------------------------------------------
36 #endif//PROTOCOLS_H
36 #endif //PROTOCOLS_H
3737 //------------------------------------------------------------------------------
4545 // prepare for select
4646 fd_set rfds;
4747
48 MainWindow mainWindow;
48 MainWindow mainWindow;
4949 HeaderWindow headerWindow(mainWindow);
5050 StatisticsWindow statisticsWindow(mainWindow, _statisticsContainers);
5151
6262
6363 statisticsWindow.updateProtocol(_activeProtocol);
6464
65 while (_running.test_and_set())
66 {
67 if (_shouldResize)
65 while(_running.test_and_set())
66 {
67 if(_shouldResize)
6868 {
6969 mainWindow.resize();
7070 headerWindow.resize(mainWindow);
7373
7474 _shouldResize = false;
7575 }
76 if (_running.test_and_set())
77 {
78 std::unique_lock<std::mutex>lck(_statisticsDeltaMutex);
76 if(_running.test_and_set())
77 {
78 std::unique_lock<std::mutex> lck(_statisticsDeltaMutex);
7979 tmp = _statisticsContainers.at(_activeProtocol);
8080 }
8181 headerWindow.update();
8282 statisticsWindow.update(tmp);
8383 mainWindow.update();
8484
85 if( select(STDIN_FILENO + 1, &rfds, nullptr, nullptr, &tv) == -1)
85 if(select(STDIN_FILENO + 1, &rfds, nullptr, nullptr, &tv) == -1)
8686 {
8787 break;
8888 }
8989 else
9090 {
9191 key = mainWindow.inputKeys();
92 if (key == KEY_LEFT || key == KEY_RIGHT)
92 if(key == KEY_LEFT || key == KEY_RIGHT)
9393 {
94 auto it = find_if (_allProtocols.begin(), _allProtocols.end(), [&](std::string s)
95 {
94 auto it = find_if(_allProtocols.begin(), _allProtocols.end(), [&](std::string s) {
9695 return !(s.compare(_activeProtocol->getProtocolName()));
9796 });
98 if (it != _allProtocols.end())
97 if(it != _allProtocols.end())
9998 {
100 if (key == KEY_LEFT)
99 if(key == KEY_LEFT)
101100 {
102 if (it + 1 == _allProtocols.end())
101 if(it + 1 == _allProtocols.end())
103102 it = _allProtocols.begin();
104103 else
105104 ++it;
106105 }
107 else if (key == KEY_RIGHT)
106 else if(key == KEY_RIGHT)
108107 {
109 if (it == _allProtocols.begin())
108 if(it == _allProtocols.begin())
110109 it = _allProtocols.end() - 1;
111110 else
112111 --it;
113112 }
114 auto a = find_if ( _statisticsContainers.begin(), _statisticsContainers.end(),[&](std::pair<AbstractProtocol*, std::vector<std::size_t> > p)
115 {
113 auto a = find_if(_statisticsContainers.begin(), _statisticsContainers.end(), [&](std::pair<AbstractProtocol*, std::vector<std::size_t>> p) {
116114 return !(p.first->getProtocolName().compare(*it));
117115 });
118 if (a != _statisticsContainers.end())
116 if(a != _statisticsContainers.end())
119117 {
120118 _activeProtocol = a->first;
121119 statisticsWindow.setProtocol(_activeProtocol);
122120 statisticsWindow.resize(mainWindow);
123121 {
124 std::unique_lock<std::mutex>lck(_statisticsDeltaMutex);
122 std::unique_lock<std::mutex> lck(_statisticsDeltaMutex);
125123 tmp = a->second;
126124 }
127125 statisticsWindow.update(tmp);
128126 }
129127 }
130128 }
131 else if (key == KEY_UP)
129 else if(key == KEY_UP)
132130 {
133131 statisticsWindow.scrollContent(SCROLL_UP);
134132 statisticsWindow.update(tmp);
135133 }
136 else if (key == KEY_DOWN)
134 else if(key == KEY_DOWN)
137135 {
138136 statisticsWindow.scrollContent(SCROLL_DOWN);
139137 statisticsWindow.update(tmp);
142140 tv = getTimeval();
143141 }
144142 }
145 catch (std::runtime_error& e)
143 catch(std::runtime_error& e)
146144 {
147145 std::cerr << "Watch plugin error: " << e.what();
148146 }
151149 timeval UserGUI::getTimeval() const
152150 {
153151 struct timeval tv;
154 tv.tv_sec = _refresh_delta / MSEC;
152 tv.tv_sec = _refresh_delta / MSEC;
155153 tv.tv_usec = _refresh_delta % MSEC;
156154 return tv;
157155 }
158156
159 UserGUI::UserGUI(const char* opts, std::vector<AbstractProtocol* >& data)
160 : _refresh_delta {900000}
161 , _shouldResize {false}
162 , _running {ATOMIC_FLAG_INIT}
163 , _activeProtocol(nullptr)
157 UserGUI::UserGUI(const char* opts, std::vector<AbstractProtocol*>& data)
158 : _refresh_delta{900000}
159 , _shouldResize{false}
160 , _running{ATOMIC_FLAG_INIT}
161 , _activeProtocol(nullptr)
164162 {
165163 try
166164 {
167 if (opts != nullptr && *opts != '\0' )
165 if(opts != nullptr && *opts != '\0')
168166 {
169167 _refresh_delta = std::stoul(opts);
170168 }
171 for (auto it = data.begin(); it != data.end(); ++it)
169 for(auto it = data.begin(); it != data.end(); ++it)
172170 {
173171 _allProtocols.push_back((*it)->getProtocolName());
174 _statisticsContainers.insert(std::make_pair<AbstractProtocol*, std::vector<std::size_t> >((AbstractProtocol*&&)(*it), std::vector<std::size_t>((*it)->getAmount(), 0)));
175 }
176 if (_activeProtocol == nullptr && ! data.empty())
172 _statisticsContainers.insert(std::make_pair<AbstractProtocol*, std::vector<std::size_t>>((AbstractProtocol * &&)(*it), std::vector<std::size_t>((*it)->getAmount(), 0)));
173 }
174 if(_activeProtocol == nullptr && !data.empty())
177175 {
178176 _activeProtocol = data.back();
179177 }
180178 }
181 catch (std::exception& e)
182 {
183 throw std::runtime_error {std::string{"Error in plugin options processing. OPTS: "} + opts + std::string(" Error: ") + e.what()};
179 catch(std::exception& e)
180 {
181 throw std::runtime_error{std::string{"Error in plugin options processing. OPTS: "} + opts + std::string(" Error: ") + e.what()};
184182 }
185183 _running.test_and_set();
186184 _guiThread = std::thread(&UserGUI::run, this);
196194 {
197195 std::vector<std::size_t>::iterator it;
198196 std::vector<std::size_t>::iterator st;
199 std::unique_lock<std::mutex>lck(_statisticsDeltaMutex);
200 for (it = (_statisticsContainers.at(p)).begin(), st = d.begin(); it != (_statisticsContainers.at(p)).end() && st != d.end(); ++it, ++st)
197 std::unique_lock<std::mutex> lck(_statisticsDeltaMutex);
198 for(it = (_statisticsContainers.at(p)).begin(), st = d.begin(); it != (_statisticsContainers.at(p)).end() && st != d.end(); ++it, ++st)
201199 {
202200 (*it) += (*st);
203201 }
2828 #include <vector>
2929
3030 #include <ncurses.h>
31
3132 #include "protocols/abstract_protocol.h"
3233 //------------------------------------------------------------------------------
3334 class UserGUI
3435 {
3536 public:
36 using ProtocolStatistic = std::vector<std::size_t>;
37 using ProtocolStatistic = std::vector<std::size_t>;
3738 using StatisticsContainers = std::unordered_map<AbstractProtocol*, ProtocolStatistic>;
3839
39 private:
40 unsigned long _refresh_delta; // in microseconds
41
42 std::atomic<bool> _shouldResize;
43 std::mutex _statisticsDeltaMutex;
44 std::atomic_flag _running;
45
46 StatisticsContainers _statisticsContainers;
47
48 AbstractProtocol* _activeProtocol;
49 std::thread _guiThread;
50 std::vector<std::string> _allProtocols;
51 void run();
52 timeval getTimeval() const;
53 public:
54
5540 UserGUI() = delete;
56 UserGUI(const char*, std::vector<AbstractProtocol* >&);
41 UserGUI(const char*, std::vector<AbstractProtocol*>&);
5742 ~UserGUI();
5843
5944 /*! Update Protocol's data.
6348 /*! Enable screen full update. Use for resize main window.
6449 */
6550 void enableUpdate();
51
52 private:
53 void run();
54 timeval getTimeval() const;
55
56 unsigned long _refresh_delta; // in microseconds
57 std::atomic<bool> _shouldResize;
58 std::mutex _statisticsDeltaMutex;
59 std::atomic_flag _running;
60 StatisticsContainers _statisticsContainers;
61 AbstractProtocol* _activeProtocol;
62 std::thread _guiThread;
63 std::vector<std::string> _allProtocols;
6664 };
6765 //------------------------------------------------------------------------------
68 #endif//USERGUI_H
66 #endif //USERGUI_H
6967 //------------------------------------------------------------------------------
2323 #include <string>
2424 #include <unordered_map>
2525
26 #include <unistd.h>
2726 #include <signal.h>
2827 #include <sys/time.h>
2928 #include <sys/types.h>
29 #include <unistd.h>
3030
3131 #include "watch_analyzer.h"
3232 //------------------------------------------------------------------------------
3333 WatchAnalyzer::WatchAnalyzer(const char* opts)
34 : _cifsv2 {}
35 , _cifsv1 {}
36 , _nfsv41 {}
37 , _nfsv4 {}
38 , _nfsv3 {}
39 , protocols {&_cifsv2, &_cifsv1, &_nfsv41, &_nfsv4, &_nfsv3}
40 , gui {opts, protocols}
34 : _cifsv2{}
35 , _cifsv1{}
36 , _nfsv41{}
37 , _nfsv4{}
38 , _nfsv3{}
39 , protocols{&_cifsv2, &_cifsv1, &_nfsv41, &_nfsv4, &_nfsv3}
40 , gui{opts, protocols}
4141 {
4242 }
4343
4545 {
4646 }
4747
48 // clang-format off
4849 void WatchAnalyzer::null(const RPCProcedure* proc,
4950 const struct NFS3::NULL3args*,
5051 const struct NFS3::NULL3res*) { nfs_account(proc); }
877878 {
878879 cifs_account(_cifsv2, static_cast<int>(SMBv2::SMBv2Commands::OPLOCK_BREAK));
879880 }
881 // clang-format on
880882
881883 void WatchAnalyzer::flush_statistics()
882884 {
884886
885887 void WatchAnalyzer::on_unix_signal(int signo)
886888 {
887 if (signo == SIGWINCH)
889 if(signo == SIGWINCH)
888890 {
889891 gui.enableUpdate();
890892 }
891893 }
892894
893 void WatchAnalyzer::cifs_account(AbstractProtocol &protocol, int cmd_code)
894 {
895 std::vector<std::size_t> cifs_proc_count (static_cast<std::size_t>(protocol.getAmount()), 0);
895 void WatchAnalyzer::cifs_account(AbstractProtocol& protocol, int cmd_code)
896 {
897 std::vector<std::size_t> cifs_proc_count(static_cast<std::size_t>(protocol.getAmount()), 0);
896898 ++cifs_proc_count[cmd_code];
897899 gui.update(&protocol, cifs_proc_count);
898900 }
902904 const u_int nfs_proc = proc->call.ru.RM_cmb.cb_proc;
903905 const u_int nfs_vers = proc->call.ru.RM_cmb.cb_vers;
904906
905 if (nfs_vers == NFS_V4)
907 if(nfs_vers == NFS_V4)
906908 {
907 if (nfs_minor_vers == NFS_V40)
909 if(nfs_minor_vers == NFS_V40)
908910 {
909 std::vector<std::size_t> nfs4_proc_count (ProcEnumNFS4::count, 0);
911 std::vector<std::size_t> nfs4_proc_count(ProcEnumNFS4::count, 0);
910912 ++nfs4_proc_count[nfs_proc];
911913 gui.update(&_nfsv4, nfs4_proc_count);
912914 }
913915
914 if (nfs_minor_vers == NFS_V41 || nfs_proc == ProcEnumNFS4::NFS_NULL)
916 if(nfs_minor_vers == NFS_V41 || nfs_proc == ProcEnumNFS4::NFS_NULL)
915917 {
916 std::vector<std::size_t> nfs41_proc_count (ProcEnumNFS41::count, 0);
918 std::vector<std::size_t> nfs41_proc_count(ProcEnumNFS41::count, 0);
917919 ++nfs41_proc_count[nfs_proc];
918920 gui.update(&_nfsv41, nfs41_proc_count);
919921 }
920922 }
921 else if (nfs_vers == NFS_V3)
923 else if(nfs_vers == NFS_V3)
922924 {
923 std::vector<std::size_t> nfs3_proc_count (ProcEnumNFS3::count, 0);
925 std::vector<std::size_t> nfs3_proc_count(ProcEnumNFS3::count, 0);
924926 ++nfs3_proc_count[nfs_proc];
925927 gui.update(&_nfsv3, nfs3_proc_count);
926928 }
928930
929931 void WatchAnalyzer::account40_op(const RPCProcedure* /*proc*/, const ProcEnumNFS4::NFSProcedure operation)
930932 {
931 std::vector<std::size_t> nfs4_proc_count (ProcEnumNFS4::count, 0);
933 std::vector<std::size_t> nfs4_proc_count(ProcEnumNFS4::count, 0);
932934 ++nfs4_proc_count[operation];
933935 gui.update(&_nfsv4, nfs4_proc_count);
934936 }
935937
936938 void WatchAnalyzer::account41_op(const RPCProcedure* /*proc*/, const ProcEnumNFS41::NFSProcedure operation)
937939 {
938 std::vector<std::size_t> nfs41_proc_count (ProcEnumNFS41::count, 0);
940 std::vector<std::size_t> nfs41_proc_count(ProcEnumNFS41::count, 0);
939941 ++nfs41_proc_count[operation];
940942 gui.update(&_nfsv41, nfs41_proc_count);
941943 }
942944 //------------------------------------------------------------------------------
943 extern "C"
944 {
945
946 const char* usage()
945 extern "C" {
946
947 const char* usage()
948 {
949 return "User can set chrono output timeout in msec.\n"
950 "You have to run nfstrace with verbosity level set to 0 (nfstrace -v 0 ...)";
951 }
952
953 IAnalyzer* create(const char* opts)
954 {
955 try
947956 {
948 return "User can set chrono output timeout in msec.\n"
949 "You have to run nfstrace with verbosity level set to 0 (nfstrace -v 0 ...)";
957 return new WatchAnalyzer(opts);
950958 }
951
952 IAnalyzer* create(const char* opts)
959 catch(std::exception& e)
953960 {
954 try
955 {
956 return new WatchAnalyzer(opts);
957 }
958 catch (std::exception& e)
959 {
960 std::cerr << "Can't initalize plugin: " << e.what() << std::endl;
961 return nullptr;
962 }
961 std::cerr << "Can't initalize plugin: " << e.what() << std::endl;
962 return nullptr;
963963 }
964
965 void destroy(IAnalyzer* instance)
966 {
967 delete instance;
968 }
969
970 const AnalyzerRequirements* requirements()
971 {
972 static const AnalyzerRequirements requirements{true};
973 return &requirements;
974 }
975
976 NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, &requirements)
964 }
965
966 void destroy(IAnalyzer* instance)
967 {
968 delete instance;
969 }
970
971 const AnalyzerRequirements* requirements()
972 {
973 static const AnalyzerRequirements requirements{true};
974 return &requirements;
975 }
976
977 NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, &requirements)
977978 }
978979 //------------------------------------------------------------------------------
2525 #include <condition_variable>
2626
2727 #include <api/plugin_api.h> // include plugin development definitions
28 #include "protocols/nfsv3_protocol.h"
29 #include "protocols/nfsv4_protocol.h"
30 #include "protocols/nfsv41_protocol.h"
28
3129 #include "protocols/cifsv1_protocol.h"
3230 #include "protocols/cifsv2_protocol.h"
31 #include "protocols/nfsv3_protocol.h"
32 #include "protocols/nfsv41_protocol.h"
33 #include "protocols/nfsv4_protocol.h"
3334 #include "user_gui.h"
3435 //------------------------------------------------------------------------------
3536 class WatchAnalyzer : public IAnalyzer
109110 const struct NFS3::COMMIT3res*) override final;
110111 // NFS v4
111112 virtual void null4(const RPCProcedure*,
112 const struct NFS4::NULL4args*,
113 const struct NFS4::NULL4res*) override final;
113 const struct NFS4::NULL4args*,
114 const struct NFS4::NULL4res*) override final;
114115 virtual void compound4(const RPCProcedure*,
115116 const struct NFS4::COMPOUND4args*,
116117 const struct NFS4::COMPOUND4res*) override final;
491492 virtual void breakOplockSMBv2(const SMBv2::BreakOpLockCommand*, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) override final;
492493
493494 private:
494
495495 void count_proc(const RPCProcedure* proc);
496 void cifs_account(AbstractProtocol &protocol, int cmd_code);
496 void cifs_account(AbstractProtocol& protocol, int cmd_code);
497497 void nfs_account(const RPCProcedure*,
498498 const unsigned int nfs_minor_vers = NFS_V41);
499499 void account40_op(const RPCProcedure*, const ProcEnumNFS4::NFSProcedure);
505505 NFSv4Protocol _nfsv4;
506506 NFSv3Protocol _nfsv3;
507507
508 std::vector<AbstractProtocol* > protocols;
509 UserGUI gui;
508 std::vector<AbstractProtocol*> protocols;
509 UserGUI gui;
510510 };
511511 //------------------------------------------------------------------------------
512 #endif//WATCH_ANALYZER_H
513 //------------------------------------------------------------------------------
512 #endif //WATCH_ANALYZER_H
513 //------------------------------------------------------------------------------
+0
-23
astyle.cfg less more
0 # Bracket style
1 --style=ansi
2
3 # Tab
4 --indent=spaces=4
5
6 # Indentation
7 --indent-preprocessor
8 --max-instatement-indent=80
9
10 # Padding
11 --pad-oper
12 --pad-header
13 --align-pointer=type
14 --align-reference=type
15
16 # Formatting
17 --add-brackets
18 --keep-one-line-blocks
19 --convert-tabs
20
21 # Other
22 --lineend=linux
1616 # in sid:
1717 # $ sudo apt-get install libjson-c-dev
1818
19 find_path(JSON_INCLUDE_DIR NAMES json-c/json.h json/json.h)
19
20 #[[
21 Debian and Ubuntu have json-c in /usr/include/json-c and jsoncpp in /usr/include/jsoncpp/json
22 Arch and Fedora have json-c in /usr/include/json-c and jsoncpp in /usr/include/json
23 Searching for json_c_version.h avoids finding json.h of jsoncpp.
24 ]]
25 find_path(JSON_INCLUDE_DIR NAMES json_c_version.h json.h PATHS /usr/include/json-c /usr/include/json)
2026 find_library(JSON_LIBRARY NAMES json-c json)
2127
2228 include(FindPackageHandleStandardArgs)
2329 find_package_handle_standard_args(JSON DEFAULT_MSG
24 JSON_LIBRARY
25 JSON_INCLUDE_DIR
26 )
30 JSON_LIBRARY JSON_INCLUDE_DIR
31 )
2732
2833 if(JSON_FOUND)
29 set(JSON_LIBRARIES ${JSON_LIBRARY})
30 # hack to get old and new layout working:
31 set(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR}/json-c
32 ${JSON_INCLUDE_DIR}/json)
34 set(JSON_LIBRARIES ${JSON_LIBRARY})
35 set(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR})
3336 endif()
3437
3538 mark_as_advanced(
36 JSON_LIBRARY
37 JSON_INCLUDE_DIR
39 JSON_LIBRARY
40 JSON_INCLUDE_DIRS
3841 )
0 find_program (clangformat clang-format)
1 if (clangformat)
2 execute_process (COMMAND ${clangformat} -version OUTPUT_VARIABLE version_string)
3 string (REGEX MATCH "([0-9]\\.[0-9]\\.?[0-9]?)" version "${version_string}")
4 if (${version} VERSION_LESS "3.9")
5 message (STATUS "Found ${version_string} less that required clang-format 3.9")
6 else()
7 add_custom_target (clang-format
8 COMMAND find analyzers src tests docs -name '*.h' -o -name '*.cpp' | xargs ${clangformat} -i -style=file
9 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
10 COMMENT "Reformat sources by clang-format"
11 SOURCES ${CMAKE_SOURCE_DIR}/.clang-format)
12 endif()
13 endif()
0 set (CPACK_PACKAGE_VENDOR "EPAM Systems")
01 set (CPACK_PACKAGE_VERSION ${NST_VERSION})
12 set (CPACK_PACKAGING_INSTALL_PREFIX "/usr")
23 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "NFS tracing/monitoring/capturing/statistic tool")
45
56 set (CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
67 set (CPACK_RPM_PACKAGE_LICENSE "GPLv2")
7 set (CPACK_RPM_PACKAGE_VENDOR "EPAM Systems")
88 set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man /usr/share/man/man8)
99 set (CPACK_RPM_PACKAGE_REQUIRES "libpcap >= 1.3.0-1")
1010 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND EXISTS "/etc/os-release")
3030 //------------------------------------------------------------------------------
3131 namespace hello
3232 {
33
34 SayHello::SayHello() : text{"Hello, World!"}, value{0}
33 SayHello::SayHello()
34 : text{"Hello, World!"}
35 , value{0}
3536 {
3637 }
3738 SayHello::~SayHello()
6061 assert(42 == hello.get());
6162
6263 // FizzBuzz
63 for(std::size_t i=1; i<=100; i++)
64 for(std::size_t i = 1; i <= 100; i++)
6465 {
6566 if((i % 15) == 0)
6667 {
6768 std::cout << "FizzBuzz\n";
6869 }
69 else if(i % 3 == 0) std::cout << "Fizz\n";
70 else if(i % 5 == 0) std::cout << "Buzz\n";
70 else if(i % 3 == 0)
71 std::cout << "Fizz\n";
72 else if(i % 5 == 0)
73 std::cout << "Buzz\n";
7174 else
7275 {
7376 std::cout << i << '\n';
2121 #ifndef TEMPLATE_H
2222 #define TEMPLATE_H
2323 //------------------------------------------------------------------------------
24 #include <cstdint> // include language headers in alphabetical order
24 #include <cstdint> // include language headers in alphabetical order
2525 #include <string>
2626 //------------------------------------------------------------------------------
27 #define MY_MIN(a,b) (((a) < (b)) ? (a) : (b)) //!< This is example of preprocessor usage
27 #define MY_MIN(a, b) (((a) < (b)) ? (a) : (b)) //!< This is example of preprocessor usage
2828 //------------------------------------------------------------------------------
2929 namespace hello
3030 {
31
3231 /*! \class Represents some entity
3332 */
3433 class SayHello
3534 {
3635 public:
37 SayHello();// May be uncommented
38 ~SayHello();// May be uncommented
36 SayHello(); // May be uncommented
37 ~SayHello(); // May be uncommented
3938
40 SayHello(const SayHello&) = delete;
39 SayHello(const SayHello&) = delete;
4140 SayHello& operator=(const SayHello&) = delete;
4241
4342 /*! small functions may be implemented in-place
4443 * \return hello string
4544 */
4645 inline const std::string& say() const { return text; }
47
4846 /*! Sets some value
4947 * \param v - new value
5048 */
5654 std::uint32_t get_value() const;
5755
5856 private:
59 std::string text;//!< Hello phrase
57 std::string text; //!< Hello phrase
6058 std::uint32_t value; //!< just a value for get/set methods
6159
62 static const unsigned int BAD_COFFEE;//!< Some constant
60 static const unsigned int BAD_COFFEE; //!< Some constant
6361 };
6462
6563 } // namespace hello
6664 //------------------------------------------------------------------------------
67 #endif//TEMPLATE_H
65 #endif //TEMPLATE_H
6866 //------------------------------------------------------------------------------
2424 {
2525 namespace analysis
2626 {
27
2827 AnalysisManager::AnalysisManager(RunningStatus& status, const Parameters& params)
29 : analysiss {nullptr}
30 , queue {nullptr}
31 , parser_thread{nullptr}
28 : analysiss{nullptr}
29 , queue{nullptr}
30 , parser_thread{nullptr}
3231 {
3332 analysiss.reset(new Analyzers(params));
3433
2525
2626 #include "analysis/analyzers.h"
2727 #include "analysis/parser_thread.h"
28 #include "analysis/parsers.h"
2829 #include "controller/parameters.h"
2930 #include "controller/running_status.h"
3031 #include "utils/filtered_data.h"
31 #include "analysis/parsers.h"
3232 //------------------------------------------------------------------------------
3333 namespace NST
3434 {
3535 namespace analysis
3636 {
37
3837 class AnalysisManager
3938 {
4039 using Parameters = NST::controller::Parameters;
4140 using RunningStatus = NST::controller::RunningStatus;
4241 using FilteredDataQueue = NST::utils::FilteredDataQueue;
42
4343 public:
4444 AnalysisManager(RunningStatus& status, const Parameters& params);
45 AnalysisManager(const AnalysisManager&) = delete;
45 AnalysisManager(const AnalysisManager&) = delete;
4646 AnalysisManager& operator=(const AnalysisManager&) = delete;
47 ~AnalysisManager() = default;
47 ~AnalysisManager() = default;
4848
4949 FilteredDataQueue& get_queue() { return *queue; }
50
51 void start();
52 void stop();
50 void start();
51 void stop();
5352
5453 inline void on_unix_signal(int signo)
5554 {
6059 {
6160 return analysiss->isSilent();
6261 }
62
6363 private:
64 std::unique_ptr<Analyzers> analysiss;
65 std::unique_ptr<FilteredDataQueue> queue;
64 std::unique_ptr<Analyzers> analysiss;
65 std::unique_ptr<FilteredDataQueue> queue;
6666 std::unique_ptr<ParserThread<Parsers>> parser_thread;
6767 };
6868
6969 } // namespace analysis
7070 } // namespace NST
7171 //------------------------------------------------------------------------------
72 #endif//ANALYSIS_MANAGER_H
72 #endif //ANALYSIS_MANAGER_H
7373 //------------------------------------------------------------------------------
2626 {
2727 namespace analysis
2828 {
29
3029 Analyzers::Analyzers(const controller::Parameters& params)
31 : _silent{false}
30 : _silent{false}
3231 {
3332 for(const auto& a : params.analysis_modules())
3433 {
3232 {
3333 namespace analysis
3434 {
35
3635 class Analyzers
3736 {
38 using Storage = std::vector<IAnalyzer*>;
39 using Plugins = std::vector< std::unique_ptr<PluginInstance> >;
40 using BuiltIns= std::vector< std::unique_ptr<IAnalyzer> >;
37 using Storage = std::vector<IAnalyzer*>;
38 using Plugins = std::vector<std::unique_ptr<PluginInstance>>;
39 using BuiltIns = std::vector<std::unique_ptr<IAnalyzer>>;
4140
4241 public:
4342 Analyzers(const controller::Parameters& params);
44 Analyzers(const Analyzers&) = delete;
43 Analyzers(const Analyzers&) = delete;
4544 Analyzers& operator=(const Analyzers&) = delete;
4645
4746 //! This function is used for passing ALL possible procedures to analyzers
48 template
49 <
47 template <
5048 typename Handle,
51 typename Procedure
52 >
49 typename Procedure>
5350 inline void operator()(Handle handle, const Procedure& proc)
5451 {
5552 for(const auto a : modules)
5956 }
6057
6158 //! This function is used for passing args- or res-only NFS4.x operations (ex. NFSv4 ILLEGAL) to analyzers
62 template
63 <
59 template <
6460 typename Handle,
65 typename ArgOrResType
66 >
61 typename ArgOrResType>
6762 inline void operator()(Handle handle, const RPCProcedure* rpc, ArgOrResType* arg_or_res)
6863 {
6964 for(const auto a : modules)
7368 }
7469
7570 //! This function is used for passing args + res NFS4.x operations (ex. NFSv4.x ACCESS) to analyzers
76 template
77 <
71 template <
7872 typename Handle,
7973 typename ArgopType,
80 typename ResopType
81 >
74 typename ResopType>
8275 inline void operator()(Handle handle, const RPCProcedure* rpc, ArgopType* arg, ResopType* res)
8376 {
8477 for(const auto a : modules)
10699 {
107100 return _silent;
108101 }
102
109103 private:
110104 Storage modules; // pointers to all modules (plugins and builtins)
111105 Plugins plugins;
112106 BuiltIns builtin;
113 bool _silent;
107 bool _silent;
114108 };
115109
116110 } // namespace analysis
117111 } // namespace NST
118112 //------------------------------------------------------------------------------
119 #endif//ANALYZERS_H
113 #endif //ANALYZERS_H
120114 //------------------------------------------------------------------------------
2626 using namespace NST::analysis;
2727
2828 CIFSParser::CIFSParser(Analyzers& a)
29 : analyzers(a)
29 : analyzers(a)
3030 {
3131 }
3232
3333 bool CIFSParser::parse_data(FilteredDataQueue::Ptr& data)
3434 {
35 if (const CIFSv1::MessageHeader* header = CIFSv1::get_header(data->data))
35 if(const CIFSv1::MessageHeader* header = CIFSv1::get_header(data->data))
3636 {
3737 parse_packet(header, std::move(data));
3838 return true;
3939 }
40 else if (const CIFSv2::MessageHeader* header = CIFSv2::get_header(data->data))
40 else if(const CIFSv2::MessageHeader* header = CIFSv2::get_header(data->data))
4141 {
4242 parse_packet(header, std::move(data));
4343 return true;
5454 using namespace NST::API::SMBv1;
5555 using namespace NST::protocols::CIFSv1;
5656
57 if (header->isFlag(Flags::REPLY))
57 if(header->isFlag(Flags::REPLY))
5858 {
5959 // It is response
60 if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY))
60 if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY))
6161 {
6262 FilteredDataQueue::Ptr&& requestData = session->get_call_data(header->sec.sequenceNumber);
63 if (requestData)
63 if(requestData)
6464 {
65 if (const MessageHeader* request = get_header(requestData->data))
65 if(const MessageHeader* request = get_header(requestData->data))
6666 {
6767 return analyse_operation(session, request, header, std::move(requestData), std::move(ptr));
6868 }
7474 else
7575 {
7676 // It is request
77 if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL))
77 if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL))
7878 {
7979 return session->save_call_data(header->sec.sequenceNumber, std::move(ptr));
8080 }
8787 using namespace NST::API::SMBv2;
8888 using namespace NST::protocols::CIFSv2;
8989
90 if (header->isFlag(Flags::SERVER_TO_REDIR))
90 if(header->isFlag(Flags::SERVER_TO_REDIR))
9191 {
9292 // It is response
93 if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY))
93 if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY))
9494 {
9595 FilteredDataQueue::Ptr&& requestData = session->get_call_data(header->messageId);
96 if (requestData)
96 if(requestData)
9797 {
98 if (const MessageHeader* request = get_header(requestData->data))
98 if(const MessageHeader* request = get_header(requestData->data))
9999 {
100100 return analyse_operation(session, request, header, std::move(requestData), std::move(ptr));
101101 }
107107 else
108108 {
109109 // It is request
110 if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL))
110 if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL))
111111 {
112112 // It is async request
113 if (header->isFlag(Flags::ASYNC_COMMAND))
113 if(header->isFlag(Flags::ASYNC_COMMAND))
114114 {
115115 return analyse_operation(session, header, nullptr, std::move(ptr), std::move(nullptr));
116116 }
120120 }
121121 }
122122
123 void CIFSParser::analyse_operation(Session* session,
123 void CIFSParser::analyse_operation(Session* session,
124124 const CIFSv1::MessageHeader* request,
125125 const CIFSv1::MessageHeader* /*response*/,
126126 NST::utils::FilteredDataQueue::Ptr&& requestData,
129129 using namespace NST::API::SMBv1;
130130 using namespace NST::protocols::CIFSv1;
131131
132 //FIXME: code smells. Too much code
133 switch (request->cmd_code)
132 switch(request->cmd_code)
134133 {
135134 case Commands::CREATE_DIRECTORY:
136 return analyzers(&IAnalyzer::ISMBv1::createDirectorySMBv1, command<CreateDirectoryCommand>(requestData, responseData, session));
135 return analyzers(&IAnalyzer::ISMBv1::createDirectorySMBv1, command<CreateDirectoryCommand>(requestData, responseData, session));
137136 case Commands::DELETE_DIRECTORY:
138 return analyzers(&IAnalyzer::ISMBv1::deleteDirectorySMBv1, command<DeleteDirectoryCommand>(requestData, responseData, session));
137 return analyzers(&IAnalyzer::ISMBv1::deleteDirectorySMBv1, command<DeleteDirectoryCommand>(requestData, responseData, session));
139138 case Commands::OPEN:
140 return analyzers(&IAnalyzer::ISMBv1::openSMBv1, command<OpenCommand>(requestData, responseData, session));
139 return analyzers(&IAnalyzer::ISMBv1::openSMBv1, command<OpenCommand>(requestData, responseData, session));
141140 case Commands::CREATE:
142 return analyzers(&IAnalyzer::ISMBv1::createSMBv1, command<CreateCommand>(requestData, responseData, session));
141 return analyzers(&IAnalyzer::ISMBv1::createSMBv1, command<CreateCommand>(requestData, responseData, session));
143142 case Commands::CLOSE:
144 return analyzers(&IAnalyzer::ISMBv1::closeSMBv1, command<CloseCommand>(requestData, responseData, session));
143 return analyzers(&IAnalyzer::ISMBv1::closeSMBv1, command<CloseCommand>(requestData, responseData, session));
145144 case Commands::FLUSH:
146 return analyzers(&IAnalyzer::ISMBv1::flushSMBv1, command<FlushCommand>(requestData, responseData, session));
145 return analyzers(&IAnalyzer::ISMBv1::flushSMBv1, command<FlushCommand>(requestData, responseData, session));
147146 case Commands::DELETE:
148 return analyzers(&IAnalyzer::ISMBv1::deleteSMBv1, command<DeleteCommand>(requestData, responseData, session));
147 return analyzers(&IAnalyzer::ISMBv1::deleteSMBv1, command<DeleteCommand>(requestData, responseData, session));
149148 case Commands::RENAME:
150 return analyzers(&IAnalyzer::ISMBv1::renameSMBv1, command<RenameCommand>(requestData, responseData, session));
149 return analyzers(&IAnalyzer::ISMBv1::renameSMBv1, command<RenameCommand>(requestData, responseData, session));
151150 case Commands::QUERY_INFORMATION:
152 return analyzers(&IAnalyzer::ISMBv1::queryInfoSMBv1, command<QueryInformationCommand>(requestData, responseData, session));
151 return analyzers(&IAnalyzer::ISMBv1::queryInfoSMBv1, command<QueryInformationCommand>(requestData, responseData, session));
153152 case Commands::SET_INFORMATION:
154 return analyzers(&IAnalyzer::ISMBv1::setInfoSMBv1, command<SetInformationCommand>(requestData, responseData, session));
153 return analyzers(&IAnalyzer::ISMBv1::setInfoSMBv1, command<SetInformationCommand>(requestData, responseData, session));
155154 case Commands::READ:
156 return analyzers(&IAnalyzer::ISMBv1::readSMBv1, command<ReadCommand>(requestData, responseData, session));
155 return analyzers(&IAnalyzer::ISMBv1::readSMBv1, command<ReadCommand>(requestData, responseData, session));
157156 case Commands::WRITE:
158 return analyzers(&IAnalyzer::ISMBv1::writeSMBv1, command<WriteCommand>(requestData, responseData, session));
157 return analyzers(&IAnalyzer::ISMBv1::writeSMBv1, command<WriteCommand>(requestData, responseData, session));
159158 case Commands::LOCK_BYTE_RANGE:
160 return analyzers(&IAnalyzer::ISMBv1::lockByteRangeSMBv1, command<LockByteRangeCommand>(requestData, responseData, session));
159 return analyzers(&IAnalyzer::ISMBv1::lockByteRangeSMBv1, command<LockByteRangeCommand>(requestData, responseData, session));
161160 case Commands::UNLOCK_BYTE_RANGE:
162 return analyzers(&IAnalyzer::ISMBv1::unlockByteRangeSMBv1, command<UnlockByteRangeCommand>(requestData, responseData, session));
161 return analyzers(&IAnalyzer::ISMBv1::unlockByteRangeSMBv1, command<UnlockByteRangeCommand>(requestData, responseData, session));
163162 case Commands::CREATE_TEMPORARY:
164 return analyzers(&IAnalyzer::ISMBv1::createTmpSMBv1, command<CreateTemporaryCommand>(requestData, responseData, session));
163 return analyzers(&IAnalyzer::ISMBv1::createTmpSMBv1, command<CreateTemporaryCommand>(requestData, responseData, session));
165164 case Commands::CREATE_NEW:
166 return analyzers(&IAnalyzer::ISMBv1::createNewSMBv1, command<CreateNewCommand>(requestData, responseData, session));
165 return analyzers(&IAnalyzer::ISMBv1::createNewSMBv1, command<CreateNewCommand>(requestData, responseData, session));
167166 case Commands::CHECK_DIRECTORY:
168 return analyzers(&IAnalyzer::ISMBv1::checkDirectorySMBv1, command<CheckDirectoryCommand>(requestData, responseData, session));
167 return analyzers(&IAnalyzer::ISMBv1::checkDirectorySMBv1, command<CheckDirectoryCommand>(requestData, responseData, session));
169168 case Commands::PROCESS_EXIT:
170 return analyzers(&IAnalyzer::ISMBv1::processExitSMBv1, command<ProcessExitCommand>(requestData, responseData, session));
169 return analyzers(&IAnalyzer::ISMBv1::processExitSMBv1, command<ProcessExitCommand>(requestData, responseData, session));
171170 case Commands::SEEK:
172 return analyzers(&IAnalyzer::ISMBv1::seekSMBv1, command<SeekCommand>(requestData, responseData, session));
171 return analyzers(&IAnalyzer::ISMBv1::seekSMBv1, command<SeekCommand>(requestData, responseData, session));
173172 case Commands::LOCK_AND_READ:
174 return analyzers(&IAnalyzer::ISMBv1::lockAndReadSMBv1, command<LockAndReadCommand>(requestData, responseData, session));
173 return analyzers(&IAnalyzer::ISMBv1::lockAndReadSMBv1, command<LockAndReadCommand>(requestData, responseData, session));
175174 case Commands::WRITE_AND_UNLOCK:
176 return analyzers(&IAnalyzer::ISMBv1::writeAndUnlockSMBv1, command<WriteAndUnlockCommand>(requestData, responseData, session));
175 return analyzers(&IAnalyzer::ISMBv1::writeAndUnlockSMBv1, command<WriteAndUnlockCommand>(requestData, responseData, session));
177176 case Commands::READ_RAW:
178 return analyzers(&IAnalyzer::ISMBv1::readRawSMBv1, command<ReadRawCommand>(requestData, responseData, session));
177 return analyzers(&IAnalyzer::ISMBv1::readRawSMBv1, command<ReadRawCommand>(requestData, responseData, session));
179178 case Commands::READ_MPX:
180 return analyzers(&IAnalyzer::ISMBv1::readMpxSMBv1, command<ReadMpxCommand>(requestData, responseData, session));
179 return analyzers(&IAnalyzer::ISMBv1::readMpxSMBv1, command<ReadMpxCommand>(requestData, responseData, session));
181180 case Commands::READ_MPX_SECONDARY:
182 return analyzers(&IAnalyzer::ISMBv1::readMpxSecondarySMBv1, command<ReadMpxSecondaryCommand>(requestData, responseData, session));
181 return analyzers(&IAnalyzer::ISMBv1::readMpxSecondarySMBv1, command<ReadMpxSecondaryCommand>(requestData, responseData, session));
183182 case Commands::WRITE_RAW:
184 return analyzers(&IAnalyzer::ISMBv1::writeRawSMBv1, command<WriteRawCommand>(requestData, responseData, session));
183 return analyzers(&IAnalyzer::ISMBv1::writeRawSMBv1, command<WriteRawCommand>(requestData, responseData, session));
185184 case Commands::WRITE_MPX:
186 return analyzers(&IAnalyzer::ISMBv1::writeMpxSMBv1, command<WriteMpxCommand>(requestData, responseData, session));
185 return analyzers(&IAnalyzer::ISMBv1::writeMpxSMBv1, command<WriteMpxCommand>(requestData, responseData, session));
187186 case Commands::WRITE_MPX_SECONDARY:
188 return analyzers(&IAnalyzer::ISMBv1::writeMpxSecondarySMBv1, command<WriteMpxSecondaryCommand>(requestData, responseData, session));
187 return analyzers(&IAnalyzer::ISMBv1::writeMpxSecondarySMBv1, command<WriteMpxSecondaryCommand>(requestData, responseData, session));
189188 case Commands::WRITE_COMPLETE:
190 return analyzers(&IAnalyzer::ISMBv1::writeCompleteSMBv1, command<WriteCompleteCommand>(requestData, responseData, session));
189 return analyzers(&IAnalyzer::ISMBv1::writeCompleteSMBv1, command<WriteCompleteCommand>(requestData, responseData, session));
191190 case Commands::QUERY_SERVER:
192 return analyzers(&IAnalyzer::ISMBv1::queryServerSMBv1, command<QueryServerCommand>(requestData, responseData, session));
191 return analyzers(&IAnalyzer::ISMBv1::queryServerSMBv1, command<QueryServerCommand>(requestData, responseData, session));
193192 case Commands::SET_INFORMATION2:
194 return analyzers(&IAnalyzer::ISMBv1::setInfo2SMBv1, command<SetInformation2Command>(requestData, responseData, session));
193 return analyzers(&IAnalyzer::ISMBv1::setInfo2SMBv1, command<SetInformation2Command>(requestData, responseData, session));
195194 case Commands::QUERY_INFORMATION2:
196 return analyzers(&IAnalyzer::ISMBv1::queryInfo2SMBv1, command<QueryInformation2Command>(requestData, responseData, session));
195 return analyzers(&IAnalyzer::ISMBv1::queryInfo2SMBv1, command<QueryInformation2Command>(requestData, responseData, session));
197196 case Commands::LOCKING_ANDX:
198 return analyzers(&IAnalyzer::ISMBv1::lockingAndxSMBv1, command<LockingAndxCommand>(requestData, responseData, session));
197 return analyzers(&IAnalyzer::ISMBv1::lockingAndxSMBv1, command<LockingAndxCommand>(requestData, responseData, session));
199198 case Commands::TRANSACTION:
200 return analyzers(&IAnalyzer::ISMBv1::transactionSMBv1, command<TransactionCommand>(requestData, responseData, session));
199 return analyzers(&IAnalyzer::ISMBv1::transactionSMBv1, command<TransactionCommand>(requestData, responseData, session));
201200 case Commands::TRANSACTION_SECONDARY:
202201 return analyzers(&IAnalyzer::ISMBv1::transactionSecondarySMBv1, command<TransactionSecondaryCommand>(requestData, responseData, session));
203202 case Commands::IOCTL:
204 return analyzers(&IAnalyzer::ISMBv1::ioctlSMBv1, command<IoctlCommand>(requestData, responseData, session));
203 return analyzers(&IAnalyzer::ISMBv1::ioctlSMBv1, command<IoctlCommand>(requestData, responseData, session));
205204 case Commands::IOCTL_SECONDARY:
206 return analyzers(&IAnalyzer::ISMBv1::ioctlSecondarySMBv1, command<IoctlSecondaryCommand>(requestData, responseData, session));
205 return analyzers(&IAnalyzer::ISMBv1::ioctlSecondarySMBv1, command<IoctlSecondaryCommand>(requestData, responseData, session));
207206 case Commands::COPY:
208 return analyzers(&IAnalyzer::ISMBv1::copySMBv1, command<CopyCommand>(requestData, responseData, session));
207 return analyzers(&IAnalyzer::ISMBv1::copySMBv1, command<CopyCommand>(requestData, responseData, session));
209208 case Commands::MOVE:
210 return analyzers(&IAnalyzer::ISMBv1::moveSMBv1, command<MoveCommand>(requestData, responseData, session));
209 return analyzers(&IAnalyzer::ISMBv1::moveSMBv1, command<MoveCommand>(requestData, responseData, session));
211210 case Commands::ECHO:
212 return analyzers(&IAnalyzer::ISMBv1::echoSMBv1, command<EchoCommand>(requestData, responseData, session));
211 return analyzers(&IAnalyzer::ISMBv1::echoSMBv1, command<EchoCommand>(requestData, responseData, session));
213212 case Commands::WRITE_AND_CLOSE:
214 return analyzers(&IAnalyzer::ISMBv1::writeAndCloseSMBv1, command<WriteAndCloseCommand>(requestData, responseData, session));
213 return analyzers(&IAnalyzer::ISMBv1::writeAndCloseSMBv1, command<WriteAndCloseCommand>(requestData, responseData, session));
215214 case Commands::OPEN_ANDX:
216 return analyzers(&IAnalyzer::ISMBv1::openAndxSMBv1, command<OpenAndxCommand>(requestData, responseData, session));
215 return analyzers(&IAnalyzer::ISMBv1::openAndxSMBv1, command<OpenAndxCommand>(requestData, responseData, session));
217216 case Commands::READ_ANDX:
218 return analyzers(&IAnalyzer::ISMBv1::readAndxSMBv1, command<ReadAndxCommand>(requestData, responseData, session));
217 return analyzers(&IAnalyzer::ISMBv1::readAndxSMBv1, command<ReadAndxCommand>(requestData, responseData, session));
219218 case Commands::WRITE_ANDX:
220 return analyzers(&IAnalyzer::ISMBv1::writeAndxSMBv1, command<WriteAndxCommand>(requestData, responseData, session));
219 return analyzers(&IAnalyzer::ISMBv1::writeAndxSMBv1, command<WriteAndxCommand>(requestData, responseData, session));
221220 case Commands::NEW_FILE_SIZE:
222 return analyzers(&IAnalyzer::ISMBv1::newFileSizeSMBv1, command<NewFileSizeCommand>(requestData, responseData, session));
221 return analyzers(&IAnalyzer::ISMBv1::newFileSizeSMBv1, command<NewFileSizeCommand>(requestData, responseData, session));
223222 case Commands::CLOSE_AND_TREE_DISC:
224 return analyzers(&IAnalyzer::ISMBv1::closeAndTreeDiscSMBv1, command<CloseAndTreeDiscCommand>(requestData, responseData, session));
223 return analyzers(&IAnalyzer::ISMBv1::closeAndTreeDiscSMBv1, command<CloseAndTreeDiscCommand>(requestData, responseData, session));
225224 case Commands::TRANSACTION2:
226 return analyzers(&IAnalyzer::ISMBv1::transaction2SMBv1, command<Transaction2Command>(requestData, responseData, session));
225 return analyzers(&IAnalyzer::ISMBv1::transaction2SMBv1, command<Transaction2Command>(requestData, responseData, session));
227226 case Commands::TRANSACTION2_SECONDARY:
228227 return analyzers(&IAnalyzer::ISMBv1::transaction2SecondarySMBv1, command<Transaction2SecondaryCommand>(requestData, responseData, session));
229228 case Commands::FIND_CLOSE2:
230 return analyzers(&IAnalyzer::ISMBv1::findClose2SMBv1, command<FindClose2Command>(requestData, responseData, session));
229 return analyzers(&IAnalyzer::ISMBv1::findClose2SMBv1, command<FindClose2Command>(requestData, responseData, session));
231230 case Commands::FIND_NOTIFY_CLOSE:
232 return analyzers(&IAnalyzer::ISMBv1::findNotifyCloseSMBv1, command<FindNotifyCloseCommand>(requestData, responseData, session));
231 return analyzers(&IAnalyzer::ISMBv1::findNotifyCloseSMBv1, command<FindNotifyCloseCommand>(requestData, responseData, session));
233232 case Commands::TREE_CONNECT:
234 return analyzers(&IAnalyzer::ISMBv1::treeConnectSMBv1, command<TreeConnectCommand>(requestData, responseData, session));
233 return analyzers(&IAnalyzer::ISMBv1::treeConnectSMBv1, command<TreeConnectCommand>(requestData, responseData, session));
235234 case Commands::TREE_DISCONNECT:
236 return analyzers(&IAnalyzer::ISMBv1::treeDisconnectSMBv1, command<TreeDisconnectCommand>(requestData, responseData, session));
235 return analyzers(&IAnalyzer::ISMBv1::treeDisconnectSMBv1, command<TreeDisconnectCommand>(requestData, responseData, session));
237236 case Commands::NEGOTIATE:
238 return analyzers(&IAnalyzer::ISMBv1::negotiateSMBv1, command<NegotiateCommand>(requestData, responseData, session));
237 return analyzers(&IAnalyzer::ISMBv1::negotiateSMBv1, command<NegotiateCommand>(requestData, responseData, session));
239238 case Commands::SESSION_SETUP_ANDX:
240 return analyzers(&IAnalyzer::ISMBv1::sessionSetupAndxSMBv1, command<SessionSetupAndxCommand>(requestData, responseData, session));
239 return analyzers(&IAnalyzer::ISMBv1::sessionSetupAndxSMBv1, command<SessionSetupAndxCommand>(requestData, responseData, session));
241240 case Commands::LOGOFF_ANDX:
242 return analyzers(&IAnalyzer::ISMBv1::logoffAndxSMBv1, command<LogoffAndxCommand>(requestData, responseData, session));
241 return analyzers(&IAnalyzer::ISMBv1::logoffAndxSMBv1, command<LogoffAndxCommand>(requestData, responseData, session));
243242 case Commands::TREE_CONNECT_ANDX:
244 return analyzers(&IAnalyzer::ISMBv1::treeConnectAndxSMBv1, command<TreeConnectAndxCommand>(requestData, responseData, session));
243 return analyzers(&IAnalyzer::ISMBv1::treeConnectAndxSMBv1, command<TreeConnectAndxCommand>(requestData, responseData, session));
245244 case Commands::SECURITY_PACKAGE_ANDX:
246 return analyzers(&IAnalyzer::ISMBv1::securityPackageAndxSMBv1, command<SecurityPackageAndxCommand>(requestData, responseData, session));
245 return analyzers(&IAnalyzer::ISMBv1::securityPackageAndxSMBv1, command<SecurityPackageAndxCommand>(requestData, responseData, session));
247246 case Commands::QUERY_INFORMATION_DISK:
248247 return analyzers(&IAnalyzer::ISMBv1::queryInformationDiskSMBv1, command<QueryInformationDiskCommand>(requestData, responseData, session));
249248 case Commands::SEARCH:
250 return analyzers(&IAnalyzer::ISMBv1::searchSMBv1, command<SearchCommand>(requestData, responseData, session));
249 return analyzers(&IAnalyzer::ISMBv1::searchSMBv1, command<SearchCommand>(requestData, responseData, session));
251250 case Commands::FIND:
252 return analyzers(&IAnalyzer::ISMBv1::findSMBv1, command<FindCommand>(requestData, responseData, session));
251 return analyzers(&IAnalyzer::ISMBv1::findSMBv1, command<FindCommand>(requestData, responseData, session));
253252 case Commands::FIND_UNIQUE:
254 return analyzers(&IAnalyzer::ISMBv1::findUniqueSMBv1, command<FindUniqueCommand>(requestData, responseData, session));
253 return analyzers(&IAnalyzer::ISMBv1::findUniqueSMBv1, command<FindUniqueCommand>(requestData, responseData, session));
255254 case Commands::FIND_CLOSE:
256 return analyzers(&IAnalyzer::ISMBv1::findCloseSMBv1, command<FindCloseCommand>(requestData, responseData, session));
255 return analyzers(&IAnalyzer::ISMBv1::findCloseSMBv1, command<FindCloseCommand>(requestData, responseData, session));
257256 case Commands::NT_TRANSACT:
258 return analyzers(&IAnalyzer::ISMBv1::ntTransactSMBv1, command<NtTransactCommand>(requestData, responseData, session));
257 return analyzers(&IAnalyzer::ISMBv1::ntTransactSMBv1, command<NtTransactCommand>(requestData, responseData, session));
259258 case Commands::NT_TRANSACT_SECONDARY:
260 return analyzers(&IAnalyzer::ISMBv1::ntTransactSecondarySMBv1, command<NtTransactSecondaryCommand>(requestData, responseData, session));
259 return analyzers(&IAnalyzer::ISMBv1::ntTransactSecondarySMBv1, command<NtTransactSecondaryCommand>(requestData, responseData, session));
261260 case Commands::NT_CREATE_ANDX:
262 return analyzers(&IAnalyzer::ISMBv1::ntCreateAndxSMBv1, command<NtCreateAndxCommand>(requestData, responseData, session));
261 return analyzers(&IAnalyzer::ISMBv1::ntCreateAndxSMBv1, command<NtCreateAndxCommand>(requestData, responseData, session));
263262 case Commands::NT_CANCEL:
264 return analyzers(&IAnalyzer::ISMBv1::ntCancelSMBv1, command<NtCancelCommand>(requestData, responseData, session));
263 return analyzers(&IAnalyzer::ISMBv1::ntCancelSMBv1, command<NtCancelCommand>(requestData, responseData, session));
265264 case Commands::NT_RENAME:
266 return analyzers(&IAnalyzer::ISMBv1::ntRenameSMBv1, command<NtRenameCommand>(requestData, responseData, session));
265 return analyzers(&IAnalyzer::ISMBv1::ntRenameSMBv1, command<NtRenameCommand>(requestData, responseData, session));
267266 case Commands::OPEN_PRINT_FILE:
268 return analyzers(&IAnalyzer::ISMBv1::openPrintFileSMBv1, command<OpenPrintFileCommand>(requestData, responseData, session));
267 return analyzers(&IAnalyzer::ISMBv1::openPrintFileSMBv1, command<OpenPrintFileCommand>(requestData, responseData, session));
269268 case Commands::WRITE_PRINT_FILE:
270 return analyzers(&IAnalyzer::ISMBv1::writePrintFileSMBv1, command<WritePrintFileCommand>(requestData, responseData, session));
269 return analyzers(&IAnalyzer::ISMBv1::writePrintFileSMBv1, command<WritePrintFileCommand>(requestData, responseData, session));
271270 case Commands::CLOSE_PRINT_FILE:
272 return analyzers(&IAnalyzer::ISMBv1::closePrintFileSMBv1, command<ClosePrintFileCommand>(requestData, responseData, session));
271 return analyzers(&IAnalyzer::ISMBv1::closePrintFileSMBv1, command<ClosePrintFileCommand>(requestData, responseData, session));
273272 case Commands::GET_PRINT_QUEUE:
274 return analyzers(&IAnalyzer::ISMBv1::getPrintQueueSMBv1, command<GetPrintQueueCommand>(requestData, responseData, session));
273 return analyzers(&IAnalyzer::ISMBv1::getPrintQueueSMBv1, command<GetPrintQueueCommand>(requestData, responseData, session));
275274 case Commands::READ_BULK:
276 return analyzers(&IAnalyzer::ISMBv1::readBulkSMBv1, command<ReadBulkCommand>(requestData, responseData, session));
275 return analyzers(&IAnalyzer::ISMBv1::readBulkSMBv1, command<ReadBulkCommand>(requestData, responseData, session));
277276 case Commands::WRITE_BULK:
278 return analyzers(&IAnalyzer::ISMBv1::writeBulkSMBv1, command<WriteBulkCommand>(requestData, responseData, session));
277 return analyzers(&IAnalyzer::ISMBv1::writeBulkSMBv1, command<WriteBulkCommand>(requestData, responseData, session));
279278 case Commands::WRITE_BULK_DATA:
280 return analyzers(&IAnalyzer::ISMBv1::writeBulkDataSMBv1, command<WriteBulkDataCommand>(requestData, responseData, session));
279 return analyzers(&IAnalyzer::ISMBv1::writeBulkDataSMBv1, command<WriteBulkDataCommand>(requestData, responseData, session));
281280 case Commands::INVALID:
282 return analyzers(&IAnalyzer::ISMBv1::invalidSMBv1, command<InvalidCommand>(requestData, responseData, session));
281 return analyzers(&IAnalyzer::ISMBv1::invalidSMBv1, command<InvalidCommand>(requestData, responseData, session));
283282 case Commands::NO_ANDX_COMMAND:
284 return analyzers(&IAnalyzer::ISMBv1::noAndxCommandSMBv1, command<NoAndxCommand>(requestData, responseData, session));
283 return analyzers(&IAnalyzer::ISMBv1::noAndxCommandSMBv1, command<NoAndxCommand>(requestData, responseData, session));
285284 default:
286285 LOG("Usupported command");
287286 }
288287 }
289288
290
291 void CIFSParser::analyse_operation(Session* session,
289 void CIFSParser::analyse_operation(Session* session,
292290 const CIFSv2::MessageHeader* request,
293291 const CIFSv2::MessageHeader* /*response*/,
294292 NST::utils::FilteredDataQueue::Ptr&& requestData,
297295 using namespace NST::API::SMBv2;
298296 using namespace NST::protocols::CIFSv2;
299297
300 switch (request->cmd_code)
298 switch(request->cmd_code)
301299 {
302300 case SMBv2Commands::CLOSE:
303 return analyzers(&IAnalyzer::ISMBv2::closeFileSMBv2, command<CloseFileCommand>(requestData, responseData, session));
301 return analyzers(&IAnalyzer::ISMBv2::closeFileSMBv2, command<CloseFileCommand>(requestData, responseData, session));
304302 case SMBv2Commands::NEGOTIATE:
305 return analyzers(&IAnalyzer::ISMBv2::negotiateSMBv2, command<NegotiateCommand>(requestData, responseData, session));
303 return analyzers(&IAnalyzer::ISMBv2::negotiateSMBv2, command<NegotiateCommand>(requestData, responseData, session));
306304 case SMBv2Commands::SESSION_SETUP:
307 return analyzers(&IAnalyzer::ISMBv2::sessionSetupSMBv2, command<SessionSetupCommand>(requestData, responseData, session));
305 return analyzers(&IAnalyzer::ISMBv2::sessionSetupSMBv2, command<SessionSetupCommand>(requestData, responseData, session));
308306 case SMBv2Commands::LOGOFF:
309 return analyzers(&IAnalyzer::ISMBv2::logOffSMBv2, command<LogOffCommand>(requestData, responseData, session));
307 return analyzers(&IAnalyzer::ISMBv2::logOffSMBv2, command<LogOffCommand>(requestData, responseData, session));
310308 case SMBv2Commands::TREE_CONNECT:
311 return analyzers(&IAnalyzer::ISMBv2::treeConnectSMBv2, command<TreeConnectCommand>(requestData, responseData, session));
309 return analyzers(&IAnalyzer::ISMBv2::treeConnectSMBv2, command<TreeConnectCommand>(requestData, responseData, session));
312310 case SMBv2Commands::TREE_DISCONNECT:
313 return analyzers(&IAnalyzer::ISMBv2::treeDisconnectSMBv2, command<TreeDisconnectCommand>(requestData, responseData, session));
311 return analyzers(&IAnalyzer::ISMBv2::treeDisconnectSMBv2, command<TreeDisconnectCommand>(requestData, responseData, session));
314312 case SMBv2Commands::CREATE:
315 return analyzers(&IAnalyzer::ISMBv2::createSMBv2, command<CreateCommand>(requestData, responseData, session));
313 return analyzers(&IAnalyzer::ISMBv2::createSMBv2, command<CreateCommand>(requestData, responseData, session));
316314 case SMBv2Commands::FLUSH:
317 return analyzers(&IAnalyzer::ISMBv2::flushSMBv2, command<FlushCommand>(requestData, responseData, session));
315 return analyzers(&IAnalyzer::ISMBv2::flushSMBv2, command<FlushCommand>(requestData, responseData, session));
318316 case SMBv2Commands::READ:
319 return analyzers(&IAnalyzer::ISMBv2::readSMBv2, command<ReadCommand>(requestData, responseData, session));
317 return analyzers(&IAnalyzer::ISMBv2::readSMBv2, command<ReadCommand>(requestData, responseData, session));
320318 case SMBv2Commands::WRITE:
321 return analyzers(&IAnalyzer::ISMBv2::writeSMBv2, command<WriteCommand>(requestData, responseData, session));
319 return analyzers(&IAnalyzer::ISMBv2::writeSMBv2, command<WriteCommand>(requestData, responseData, session));
322320 case SMBv2Commands::LOCK:
323 return analyzers(&IAnalyzer::ISMBv2::lockSMBv2, command<LockCommand>(requestData, responseData, session));
321 return analyzers(&IAnalyzer::ISMBv2::lockSMBv2, command<LockCommand>(requestData, responseData, session));
324322 case SMBv2Commands::IOCTL:
325 return analyzers(&IAnalyzer::ISMBv2::ioctlSMBv2, command<IoctlCommand>(requestData, responseData, session));
323 return analyzers(&IAnalyzer::ISMBv2::ioctlSMBv2, command<IoctlCommand>(requestData, responseData, session));
326324 case SMBv2Commands::CANCEL:
327 return analyzers(&IAnalyzer::ISMBv2::cancelSMBv2, command<CancelCommand>(requestData, responseData, session));
325 return analyzers(&IAnalyzer::ISMBv2::cancelSMBv2, command<CancelCommand>(requestData, responseData, session));
328326 case SMBv2Commands::ECHO:
329 return analyzers(&IAnalyzer::ISMBv2::echoSMBv2, command<EchoCommand>(requestData, responseData, session));
327 return analyzers(&IAnalyzer::ISMBv2::echoSMBv2, command<EchoCommand>(requestData, responseData, session));
330328 case SMBv2Commands::QUERY_DIRECTORY:
331 return analyzers(&IAnalyzer::ISMBv2::queryDirSMBv2, command<QueryDirCommand>(requestData, responseData, session));
329 return analyzers(&IAnalyzer::ISMBv2::queryDirSMBv2, command<QueryDirCommand>(requestData, responseData, session));
332330 case SMBv2Commands::CHANGE_NOTIFY:
333 return analyzers(&IAnalyzer::ISMBv2::changeNotifySMBv2, command<ChangeNotifyCommand>(requestData, responseData, session));
331 return analyzers(&IAnalyzer::ISMBv2::changeNotifySMBv2, command<ChangeNotifyCommand>(requestData, responseData, session));
334332 case SMBv2Commands::QUERY_INFO:
335 return analyzers(&IAnalyzer::ISMBv2::queryInfoSMBv2, command<QueryInfoCommand>(requestData, responseData, session));
333 return analyzers(&IAnalyzer::ISMBv2::queryInfoSMBv2, command<QueryInfoCommand>(requestData, responseData, session));
336334 case SMBv2Commands::SET_INFO:
337 return analyzers(&IAnalyzer::ISMBv2::setInfoSMBv2, command<SetInfoCommand>(requestData, responseData, session));
335 return analyzers(&IAnalyzer::ISMBv2::setInfoSMBv2, command<SetInfoCommand>(requestData, responseData, session));
338336 case SMBv2Commands::OPLOCK_BREAK:
339 return analyzers(&IAnalyzer::ISMBv2::breakOplockSMBv2, command<BreakOpLockCommand>(requestData, responseData, session));
337 return analyzers(&IAnalyzer::ISMBv2::breakOplockSMBv2, command<BreakOpLockCommand>(requestData, responseData, session));
340338 default:
341339 LOG("Usupported command");
342340 }
3131 {
3232 namespace analysis
3333 {
34
3534 /*! \class It is class which can parse CIFS messages and it called by ParserThread
3635 */
3736 class CIFSParser
3837 {
39 using FilteredDataQueue = NST::utils::FilteredDataQueue;//!< Packets queue
38 using FilteredDataQueue = NST::utils::FilteredDataQueue; //!< Packets queue
4039
41 Analyzers& analyzers;//!< Plugins manager
42 Sessions<Session> sessions;//!< Sessions list
40 Analyzers& analyzers; //!< Plugins manager
41 Sessions<Session> sessions; //!< Sessions list
4342
4443 /*! Parses SMBv1 packet
4544 * \param header - Message's header
5453 * \param requestData - Call's data
5554 * \param responseData - Reply's data
5655 */
57 inline void analyse_operation(Session* session,
56 inline void analyse_operation(Session* session,
5857 const protocols::CIFSv1::MessageHeader* request,
5958 const protocols::CIFSv1::MessageHeader* response,
60 FilteredDataQueue::Ptr&& requestData,
61 FilteredDataQueue::Ptr&& responseData);
59 FilteredDataQueue::Ptr&& requestData,
60 FilteredDataQueue::Ptr&& responseData);
6261
6362 /*! Parses SMB v2 packet
6463 * \param header - Message's header
7372 * \param requestData - Call's data
7473 * \param responseData - Reply's data
7574 */
76 inline void analyse_operation(Session* session,
75 inline void analyse_operation(Session* session,
7776 const protocols::CIFSv2::MessageHeader* request,
7877 const protocols::CIFSv2::MessageHeader* response,
79 FilteredDataQueue::Ptr&& requestData,
80 FilteredDataQueue::Ptr&& responseData);
78 FilteredDataQueue::Ptr&& requestData,
79 FilteredDataQueue::Ptr&& responseData);
80
8181 public:
82
8382 CIFSParser(Analyzers& a);
84 CIFSParser(CIFSParser& c) : analyzers(c.analyzers) {}
83 CIFSParser(CIFSParser& c)
84 : analyzers(c.analyzers)
85 {
86 }
8587
8688 /*! Function which will be called by ParserThread class
8789 * \param data - raw packet
9395 } // analysis
9496 } // NST
9597 //------------------------------------------------------------------------------
96 #endif//CIFS_PARSER_H
98 #endif //CIFS_PARSER_H
9799 //------------------------------------------------------------------------------
3030 {
3131 namespace analysis
3232 {
33
34
3533 bool NFSParser::parse_data(FilteredDataQueue::Ptr& ptr)
3634 {
3735 using namespace NST::protocols::rpc;
3836
3937 // TODO: refactor and generalize this code
40 if (ptr->dlen < sizeof(MessageHeader))
38 if(ptr->dlen < sizeof(MessageHeader))
4139 {
4240 return false;
4341 }
4442 auto msg = reinterpret_cast<const MessageHeader*>(ptr->data);
45 switch (msg->type())
43 switch(msg->type())
4644 {
4745 case MsgType::CALL:
4846 {
49 if (ptr->dlen < sizeof(CallHeader))
47 if(ptr->dlen < sizeof(CallHeader))
5048 {
5149 return false;
5250 }
5351
5452 auto call = static_cast<const CallHeader*>(msg);
5553
56 if (RPCValidator::check(call) && (protocols::NFS4::Validator::check(call) ||
57 protocols::NFS3::Validator::check(call)))
54 if(RPCValidator::check(call) && (protocols::NFS4::Validator::check(call) ||
55 protocols::NFS3::Validator::check(call)))
5856 {
5957 Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL);
60 if (session)
58 if(session)
6159 {
6260 session->save_call_data(call->xid(), std::move(ptr));
6361 }
6765 break;
6866 case MsgType::REPLY:
6967 {
70 if (ptr->dlen < sizeof(ReplyHeader))
68 if(ptr->dlen < sizeof(ReplyHeader))
7169 {
7270 return false;
7371 }
7472 auto reply = static_cast<const ReplyHeader*>(msg);
7573
76 if (!RPCValidator::check(reply))
74 if(!RPCValidator::check(reply))
7775 {
7876 return false;
7977 }
8078
8179 Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY);
82 if (session)
80 if(session)
8381 {
8482 FilteredDataQueue::Ptr&& call_data = session->get_call_data(reply->xid());
85 if (call_data)
83 if(call_data)
8684 {
8785 analyze_nfs_procedure(std::move(call_data), std::move(ptr), session);
8886 }
103101 using NFS40CompoundType = NST::protocols::NFS4::NFSPROC4RPCGEN_COMPOUND;
104102 using NFS41CompoundType = NST::protocols::NFS41::NFSPROC41RPCGEN_COMPOUND;
105103
106 template
107 <
108 typename ArgOpType,
109 typename ResOpType,
110 typename NFS4CompoundType
111 >
104 template <
105 typename ArgOpType,
106 typename ResOpType,
107 typename NFS4CompoundType>
112108 void analyze_nfs4_operations(Analyzers& analyzers, NFS4CompoundType& nfs4_compound_procedure);
113109
114110 inline void analyze_nfs40_operations(Analyzers& analyzers, NFS40CompoundType& nfs40_compound_procedure)
115111 {
116 analyze_nfs4_operations < NST::API::NFS4::nfs_argop4,
112 analyze_nfs4_operations<NST::API::NFS4::nfs_argop4,
117113 NST::API::NFS4::nfs_resop4,
118 NFS40CompoundType > (analyzers, nfs40_compound_procedure);
114 NFS40CompoundType>(analyzers, nfs40_compound_procedure);
119115 }
120116
121117 inline void analyze_nfs41_operations(Analyzers& analyzers, NFS41CompoundType& nfs41_compound_procedure)
122118 {
123 analyze_nfs4_operations < NST::API::NFS41::nfs_argop4,
119 analyze_nfs4_operations<NST::API::NFS41::nfs_argop4,
124120 NST::API::NFS41::nfs_resop4,
125 NFS41CompoundType > (analyzers, nfs41_compound_procedure);
126 }
127
128 void nfs4_ops_switch(Analyzers& analyzers,
129 const RPCProcedure* rpc_procedure,
121 NFS41CompoundType>(analyzers, nfs41_compound_procedure);
122 }
123
124 void nfs4_ops_switch(Analyzers& analyzers,
125 const RPCProcedure* rpc_procedure,
130126 const NST::API::NFS4::nfs_argop4* arg,
131127 const NST::API::NFS4::nfs_resop4* res);
132128
133 void nfs4_ops_switch(Analyzers& analyzers,
134 const RPCProcedure* rpc_procedure,
129 void nfs4_ops_switch(Analyzers& analyzers,
130 const RPCProcedure* rpc_procedure,
135131 const NST::API::NFS41::nfs_argop4* arg,
136132 const NST::API::NFS41::nfs_resop4* res);
137133
140136 static inline void analyze_nfsv3_procedure(const uint32_t procedure, XDRDecoder&& c, XDRDecoder&& r, const Session* s, Analyzers& analyzers)
141137 {
142138 using namespace NST::protocols::NFS3;
143 switch (procedure)
139 switch(procedure)
144140 {
145141 case ProcEnumNFS3::NFS_NULL:
146 analyzers(&IAnalyzer::INFSv3rpcgen::null, NFSPROC3RPCGEN_NULL {c, r, s});
142 analyzers(&IAnalyzer::INFSv3rpcgen::null, NFSPROC3RPCGEN_NULL{c, r, s});
147143 break;
148144 case ProcEnumNFS3::GETATTR:
149 analyzers(&IAnalyzer::INFSv3rpcgen::getattr3, NFSPROC3RPCGEN_GETATTR {c, r, s});
145 analyzers(&IAnalyzer::INFSv3rpcgen::getattr3, NFSPROC3RPCGEN_GETATTR{c, r, s});
150146 break;
151147 case ProcEnumNFS3::SETATTR:
152 analyzers(&IAnalyzer::INFSv3rpcgen::setattr3, NFSPROC3RPCGEN_SETATTR {c, r, s});
148 analyzers(&IAnalyzer::INFSv3rpcgen::setattr3, NFSPROC3RPCGEN_SETATTR{c, r, s});
153149 break;
154150 case ProcEnumNFS3::LOOKUP:
155 analyzers(&IAnalyzer::INFSv3rpcgen::lookup3, NFSPROC3RPCGEN_LOOKUP {c, r, s});
151 analyzers(&IAnalyzer::INFSv3rpcgen::lookup3, NFSPROC3RPCGEN_LOOKUP{c, r, s});
156152 break;
157153 case ProcEnumNFS3::ACCESS:
158 analyzers(&IAnalyzer::INFSv3rpcgen::access3, NFSPROC3RPCGEN_ACCESS {c, r, s});
154 analyzers(&IAnalyzer::INFSv3rpcgen::access3, NFSPROC3RPCGEN_ACCESS{c, r, s});
159155 break;
160156 case ProcEnumNFS3::READLINK:
161 analyzers(&IAnalyzer::INFSv3rpcgen::readlink3, NFSPROC3RPCGEN_READLINK {c, r, s});
157 analyzers(&IAnalyzer::INFSv3rpcgen::readlink3, NFSPROC3RPCGEN_READLINK{c, r, s});
162158 break;
163159 case ProcEnumNFS3::READ:
164 analyzers(&IAnalyzer::INFSv3rpcgen::read3, NFSPROC3RPCGEN_READ {c, r, s});
160 analyzers(&IAnalyzer::INFSv3rpcgen::read3, NFSPROC3RPCGEN_READ{c, r, s});
165161 break;
166162 case ProcEnumNFS3::WRITE:
167 analyzers(&IAnalyzer::INFSv3rpcgen::write3, NFSPROC3RPCGEN_WRITE {c, r, s});
163 analyzers(&IAnalyzer::INFSv3rpcgen::write3, NFSPROC3RPCGEN_WRITE{c, r, s});
168164 break;
169165 case ProcEnumNFS3::CREATE:
170 analyzers(&IAnalyzer::INFSv3rpcgen::create3, NFSPROC3RPCGEN_CREATE {c, r, s});
166 analyzers(&IAnalyzer::INFSv3rpcgen::create3, NFSPROC3RPCGEN_CREATE{c, r, s});
171167 break;
172168 case ProcEnumNFS3::MKDIR:
173 analyzers(&IAnalyzer::INFSv3rpcgen::mkdir3, NFSPROC3RPCGEN_MKDIR {c, r, s});
169 analyzers(&IAnalyzer::INFSv3rpcgen::mkdir3, NFSPROC3RPCGEN_MKDIR{c, r, s});
174170 break;
175171 case ProcEnumNFS3::SYMLINK:
176 analyzers(&IAnalyzer::INFSv3rpcgen::symlink3, NFSPROC3RPCGEN_SYMLINK {c, r, s});
172 analyzers(&IAnalyzer::INFSv3rpcgen::symlink3, NFSPROC3RPCGEN_SYMLINK{c, r, s});
177173 break;
178174 case ProcEnumNFS3::MKNOD:
179 analyzers(&IAnalyzer::INFSv3rpcgen::mknod3, NFSPROC3RPCGEN_MKNOD {c, r, s});
175 analyzers(&IAnalyzer::INFSv3rpcgen::mknod3, NFSPROC3RPCGEN_MKNOD{c, r, s});
180176 break;
181177 case ProcEnumNFS3::REMOVE:
182 analyzers(&IAnalyzer::INFSv3rpcgen::remove3, NFSPROC3RPCGEN_REMOVE {c, r, s});
178 analyzers(&IAnalyzer::INFSv3rpcgen::remove3, NFSPROC3RPCGEN_REMOVE{c, r, s});
183179 break;
184180 case ProcEnumNFS3::RMDIR:
185 analyzers(&IAnalyzer::INFSv3rpcgen::rmdir3, NFSPROC3RPCGEN_RMDIR {c, r, s});
181 analyzers(&IAnalyzer::INFSv3rpcgen::rmdir3, NFSPROC3RPCGEN_RMDIR{c, r, s});
186182 break;
187183 case ProcEnumNFS3::RENAME:
188 analyzers(&IAnalyzer::INFSv3rpcgen::rename3, NFSPROC3RPCGEN_RENAME {c, r, s});
184 analyzers(&IAnalyzer::INFSv3rpcgen::rename3, NFSPROC3RPCGEN_RENAME{c, r, s});
189185 break;
190186 case ProcEnumNFS3::LINK:
191 analyzers(&IAnalyzer::INFSv3rpcgen::link3, NFSPROC3RPCGEN_LINK {c, r, s});
187 analyzers(&IAnalyzer::INFSv3rpcgen::link3, NFSPROC3RPCGEN_LINK{c, r, s});
192188 break;
193189 case ProcEnumNFS3::READDIR:
194 analyzers(&IAnalyzer::INFSv3rpcgen::readdir3, NFSPROC3RPCGEN_READDIR {c, r, s});
190 analyzers(&IAnalyzer::INFSv3rpcgen::readdir3, NFSPROC3RPCGEN_READDIR{c, r, s});
195191 break;
196192 case ProcEnumNFS3::READDIRPLUS:
197 analyzers(&IAnalyzer::INFSv3rpcgen::readdirplus3, NFSPROC3RPCGEN_READDIRPLUS {c, r, s});
193 analyzers(&IAnalyzer::INFSv3rpcgen::readdirplus3, NFSPROC3RPCGEN_READDIRPLUS{c, r, s});
198194 break;
199195 case ProcEnumNFS3::FSSTAT:
200 analyzers(&IAnalyzer::INFSv3rpcgen::fsstat3, NFSPROC3RPCGEN_FSSTAT {c, r, s});
196 analyzers(&IAnalyzer::INFSv3rpcgen::fsstat3, NFSPROC3RPCGEN_FSSTAT{c, r, s});
201197 break;
202198 case ProcEnumNFS3::FSINFO:
203 analyzers(&IAnalyzer::INFSv3rpcgen::fsinfo3, NFSPROC3RPCGEN_FSINFO {c, r, s});
199 analyzers(&IAnalyzer::INFSv3rpcgen::fsinfo3, NFSPROC3RPCGEN_FSINFO{c, r, s});
204200 break;
205201 case ProcEnumNFS3::PATHCONF:
206 analyzers(&IAnalyzer::INFSv3rpcgen::pathconf3, NFSPROC3RPCGEN_PATHCONF {c, r, s});
202 analyzers(&IAnalyzer::INFSv3rpcgen::pathconf3, NFSPROC3RPCGEN_PATHCONF{c, r, s});
207203 break;
208204 case ProcEnumNFS3::COMMIT:
209 analyzers(&IAnalyzer::INFSv3rpcgen::commit3, NFSPROC3RPCGEN_COMMIT {c, r, s});
205 analyzers(&IAnalyzer::INFSv3rpcgen::commit3, NFSPROC3RPCGEN_COMMIT{c, r, s});
210206 break;
211207 }
212208 }
216212 using namespace NST::protocols::NFS4;
217213 using namespace NST::protocols::NFS41;
218214
219 switch (get_nfs4_compound_minor_version(procedure, c.data().data))
215 switch(get_nfs4_compound_minor_version(procedure, c.data().data))
220216 {
221217 case NFS_V40:
222 switch (procedure)
218 switch(procedure)
223219 {
224220 case ProcEnumNFS4::NFS_NULL:
225 analyzers(&IAnalyzer::INFSv4rpcgen::null4, NFSPROC4RPCGEN_NULL { c, r, s });
221 analyzers(&IAnalyzer::INFSv4rpcgen::null4, NFSPROC4RPCGEN_NULL{c, r, s});
226222 break;
227223 case ProcEnumNFS4::COMPOUND:
228 NFSPROC4RPCGEN_COMPOUND compound { c, r, s };
224 NFSPROC4RPCGEN_COMPOUND compound{c, r, s};
229225 analyzers(&IAnalyzer::INFSv4rpcgen::compound4, compound);
230226 analyze_nfs40_operations(analyzers, compound);
231227 break;
232228 }
233229 break;
234230 case NFS_V41:
235 if (ProcEnumNFS41::COMPOUND == procedure)
236 {
237 NFSPROC41RPCGEN_COMPOUND compound { c, r, s };
231 if(ProcEnumNFS41::COMPOUND == procedure)
232 {
233 NFSPROC41RPCGEN_COMPOUND compound{c, r, s};
238234 analyzers(&IAnalyzer::INFSv41rpcgen::compound41, compound);
239235 analyze_nfs41_operations(analyzers, compound);
240236 }
242238 }
243239 }
244240
245 void NFSParser::analyze_nfs_procedure( FilteredDataQueue::Ptr&& call,
246 FilteredDataQueue::Ptr&& reply,
247 Session* session)
241 void NFSParser::analyze_nfs_procedure(FilteredDataQueue::Ptr&& call,
242 FilteredDataQueue::Ptr&& reply,
243 Session* session)
248244 {
249245 using namespace NST::protocols::rpc;
250246
251 auto header = reinterpret_cast<const CallHeader*>(call->data);
252 const uint32_t major_version {header->vers()};
253 const uint32_t procedure {header->proc()};
247 auto header = reinterpret_cast<const CallHeader*>(call->data);
248 const uint32_t major_version{header->vers()};
249 const uint32_t procedure{header->proc()};
254250
255251 try
256252 {
257 const Session* s { session->get_session() };
258
259 switch (major_version)
253 const Session* s{session->get_session()};
254
255 switch(major_version)
260256 {
261257 case NFS_V4:
262258 analyze_nfsv4_procedure(procedure, std::move(call), std::move(reply), s, this->analyzers);
266262 break;
267263 }
268264 }
269 catch (XDRDecoderError& e)
270 {
271 const char* procedure_name {"Unknown procedure"};
272 switch (major_version)
265 catch(XDRDecoderError& e)
266 {
267 const char* procedure_name{"Unknown procedure"};
268 switch(major_version)
273269 {
274270 case NFS_V4:
275271 procedure_name = print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(procedure));
293289 */
294290 static uint32_t get_nfs4_compound_minor_version(const uint32_t procedure, const std::uint8_t* rpc_nfs4_call)
295291 {
296 if (ProcEnumNFS4::COMPOUND != procedure)
292 if(ProcEnumNFS4::COMPOUND != procedure)
297293 {
298294 return 0;
299295 }
320316
321317 //! Common internal function for parsing NFSv4.x's COMPOUND procedure
322318 //! It's supposed to be used inside analyze_nfs_procedure only
323 template
324 <
325 typename ArgOpType, // Type of arguments(call part of nfs's procedure)
326 typename ResOpType, // Type of results(reply part of nfs's procedure)
327 typename NFS4CompoundType // Type of NFSv4.x COMPOUND procedure. Can be 4.0 or 4.1
328 >
319 template <
320 typename ArgOpType, // Type of arguments(call part of nfs's procedure)
321 typename ResOpType, // Type of results(reply part of nfs's procedure)
322 typename NFS4CompoundType // Type of NFSv4.x COMPOUND procedure. Can be 4.0 or 4.1
323 >
329324 void analyze_nfs4_operations(Analyzers& analyzers, NFS4CompoundType& nfs4_compound_procedure)
330325 {
331 ArgOpType* arg {nullptr};
332 ResOpType* res {nullptr};
333
334 uint32_t arg_ops_count {0}; // Amount of NFS operations (call part)
335 uint32_t res_ops_count {0}; // Amount of NFS operations (reply part)
336 uint32_t total_ops_count {0};
337
338 if (nfs4_compound_procedure.parg) // Checking if COMPOUND procedure has valid arg
326 ArgOpType* arg{nullptr};
327 ResOpType* res{nullptr};
328
329 uint32_t arg_ops_count{0}; // Amount of NFS operations (call part)
330 uint32_t res_ops_count{0}; // Amount of NFS operations (reply part)
331 uint32_t total_ops_count{0};
332
333 if(nfs4_compound_procedure.parg) // Checking if COMPOUND procedure has valid arg
339334 {
340335 arg_ops_count = nfs4_compound_procedure.parg->argarray.argarray_len;
341 arg = nfs4_compound_procedure.parg->argarray.argarray_val;
342 }
343
344 if (nfs4_compound_procedure.pres) // Checking if COMPOUND procedure has valid res
336 arg = nfs4_compound_procedure.parg->argarray.argarray_val;
337 }
338
339 if(nfs4_compound_procedure.pres) // Checking if COMPOUND procedure has valid res
345340 {
346341 res_ops_count = nfs4_compound_procedure.pres->resarray.resarray_len;
347 res = nfs4_compound_procedure.pres->resarray.resarray_val;
342 res = nfs4_compound_procedure.pres->resarray.resarray_val;
348343 }
349344
350345 // Determing which part of COMPOUND has the biggest amount of operations.
351346 total_ops_count = arg_ops_count > res_ops_count ? arg_ops_count : res_ops_count;
352347
353348 // Traversing through ALL COMPOUND procedure's operations
354 for (uint32_t i {0}; i < total_ops_count; i++)
355 {
356 if ((arg && res) && (arg->argop != res->resop))
349 for(uint32_t i{0}; i < total_ops_count; i++)
350 {
351 if((arg && res) && (arg->argop != res->resop))
357352 {
358353 // Passing each operation to analyzers using the helper's function
359354 nfs4_ops_switch(analyzers, &nfs4_compound_procedure, arg, nullptr);
364359 nfs4_ops_switch(analyzers, &nfs4_compound_procedure, arg, res);
365360 }
366361
367 if (arg && i < (arg_ops_count - 1)) { arg++; }
368 else { arg = nullptr; }
369 if (res && i < (res_ops_count - 1)) { res++; }
370 else { res = nullptr; }
362 if(arg && i < (arg_ops_count - 1))
363 {
364 arg++;
365 }
366 else
367 {
368 arg = nullptr;
369 }
370 if(res && i < (res_ops_count - 1))
371 {
372 res++;
373 }
374 else
375 {
376 res = nullptr;
377 }
371378 }
372379 }
373380
374381 //! Internal function for proper passing NFSv4.x's arg + res operations to analyzers
375382 //! It's supposed to be used inside nfs4_ops_switch only
376 template
377 <
378 typename nfs_argop4_t,
379 typename nfs_resop4_t,
380 typename IAnalyzer_func_t,
381 typename nfs_argop_member_t,
382 typename nfs_resop_member_t
383 >
384 inline void analyze(Analyzers& analyzers,
383 template <
384 typename nfs_argop4_t,
385 typename nfs_resop4_t,
386 typename IAnalyzer_func_t,
387 typename nfs_argop_member_t,
388 typename nfs_resop_member_t>
389 inline void analyze(Analyzers& analyzers,
385390 const RPCProcedure* rpc_procedure,
386391 const nfs_argop4_t* arg,
387392 const nfs_resop4_t* res,
388 IAnalyzer_func_t&& IAnalyzer_function,
389 nfs_argop_member_t arg_operation,
390 nfs_resop_member_t res_operation)
393 IAnalyzer_func_t&& IAnalyzer_function,
394 nfs_argop_member_t arg_operation,
395 nfs_resop_member_t res_operation)
391396 {
392397 analyzers(IAnalyzer_function, rpc_procedure,
393 arg == nullptr ? nullptr : & (arg->nfs_argop4_u.*arg_operation),
394 res == nullptr ? nullptr : & (res->nfs_resop4_u.*res_operation));
398 arg == nullptr ? nullptr : &(arg->nfs_argop4_u.*arg_operation),
399 res == nullptr ? nullptr : &(res->nfs_resop4_u.*res_operation));
395400 }
396401
397402 //! Internal function for proper passing NFSv4.x's res-only operations to analyzers
398403 //! It's supposed to be used inside nfs4_ops_switch only
399 template
400 <
401 typename nfs_resop4_t,
402 typename IAnalyzer_func_t,
403 typename nfs_resop_member_t
404 >
405 inline void analyze(Analyzers& analyzers,
404 template <
405 typename nfs_resop4_t,
406 typename IAnalyzer_func_t,
407 typename nfs_resop_member_t>
408 inline void analyze(Analyzers& analyzers,
406409 const RPCProcedure* rpc_procedure,
407410 const nfs_resop4_t* res,
408 IAnalyzer_func_t&& IAnalyzer_function,
409 nfs_resop_member_t res_operation)
411 IAnalyzer_func_t&& IAnalyzer_function,
412 nfs_resop_member_t res_operation)
410413 {
411414 analyzers(IAnalyzer_function, rpc_procedure,
412 res == nullptr ? nullptr : & (res->nfs_resop4_u.*res_operation));
415 res == nullptr ? nullptr : &(res->nfs_resop4_u.*res_operation));
413416 }
414417
415418 //! Internal function for proper passing NFSv4.0's operations to analyzers
416419 //! It's supposed to be used inside analyze_nfs4_operations only
417 void nfs4_ops_switch(Analyzers& analyzers,
418 const RPCProcedure* rpc_procedure,
420 void nfs4_ops_switch(Analyzers& analyzers,
421 const RPCProcedure* rpc_procedure,
419422 const NST::API::NFS4::nfs_argop4* arg,
420423 const NST::API::NFS4::nfs_resop4* res)
421424 {
424427 using res_t = NST::API::NFS4::nfs_resop4_u_t;
425428
426429 uint32_t nfs_op_num = arg ? arg->argop : res->resop;
427 switch (nfs_op_num)
430 switch(nfs_op_num)
428431 {
429432 case ProcEnumNFS4::ACCESS:
430433 analyze(analyzers, rpc_procedure, arg, res,
659662
660663 //! Internal function for proper passing NFSv4.1's operations to analyzers
661664 //! It's supposed to be used inside analyze_nfs4_operations only
662 void nfs4_ops_switch(Analyzers& analyzers,
663 const RPCProcedure* rpc_procedure,
665 void nfs4_ops_switch(Analyzers& analyzers,
666 const RPCProcedure* rpc_procedure,
664667 const NST::API::NFS41::nfs_argop4* arg,
665668 const NST::API::NFS41::nfs_resop4* res)
666669 {
669672 using res_t = NST::API::NFS41::nfs_resop4_u_t;
670673
671674 uint32_t nfs_op_num = arg ? arg->argop : res->resop;
672 switch (nfs_op_num)
675 switch(nfs_op_num)
673676 {
674677 case ProcEnumNFS41::ACCESS:
675678 analyze(analyzers, rpc_procedure, arg, res,
3131 {
3232 namespace analysis
3333 {
34
3534 /*! \class It is class which can parse NFS messages and it called by ParserThread
3635 */
3736 class NFSParser
3837 {
3938 using FilteredDataQueue = NST::utils::FilteredDataQueue;
4039
41 Analyzers& analyzers;
40 Analyzers& analyzers;
4241 Sessions<Session> sessions;
42
4343 public:
44
45 NFSParser(Analyzers& a) : analyzers(a) {}
46 NFSParser(NFSParser& c) : analyzers(c.analyzers) {}
44 NFSParser(Analyzers& a)
45 : analyzers(a)
46 {
47 }
48 NFSParser(NFSParser& c)
49 : analyzers(c.analyzers)
50 {
51 }
4752
4853 /*! Function which will be called by ParserThread class
4954 * \param data - RPC packet
5459 void parse_data(FilteredDataQueue::Ptr&& data);
5560 void analyze_nfs_procedure(FilteredDataQueue::Ptr&& call,
5661 FilteredDataQueue::Ptr&& reply,
57 Session* session);
62 Session* session);
5863 };
5964
6065 } // analysis
6166 } // NST
6267 //------------------------------------------------------------------------------
63 #endif//NFS_PARSER_H
68 #endif //NFS_PARSER_H
6469 //------------------------------------------------------------------------------
3232 {
3333 namespace analysis
3434 {
35
3635 template <typename Parser>
3736 class ParserThread
3837 {
3938 using RunningStatus = NST::controller::RunningStatus;
4039 using FilteredDataQueue = NST::utils::FilteredDataQueue;
40
4141 public:
4242 ParserThread(Parser p, FilteredDataQueue& q, RunningStatus& s)
43 : status (s)
44 , queue (q)
45 , running {ATOMIC_FLAG_INIT} // false
46 , parser(p)
43 : status(s)
44 , queue(q)
45 , running{ATOMIC_FLAG_INIT} // false
46 , parser(p)
4747 {
4848 }
4949
5050 ~ParserThread()
5151 {
52 if (parsing.joinable()) stop();
52 if(parsing.joinable()) stop();
5353 }
5454
5555 void start()
6464 parsing.join();
6565 }
6666
67
6867 private:
69
7068 inline void thread()
7169 {
7270 try
102100 {
103101 FilteredDataQueue::Ptr data = list.get_current();
104102 parser.parse_data(data);
105 }
106 while(list);
103 } while(list);
107104 }
108105 }
109106
110 RunningStatus& status;
107 RunningStatus& status;
111108 FilteredDataQueue& queue;
112109
113 std::thread parsing;
110 std::thread parsing;
114111 std::atomic_flag running;
115 Parser parser;
112 Parser parser;
116113 };
117114
118115 } // namespace analysis
119116 } // namespace NST
120117 //------------------------------------------------------------------------------
121 #endif//NFS_PARSER_THREAD_H
118 #endif //NFS_PARSER_THREAD_H
122119 //------------------------------------------------------------------------------
2929 {
3030 namespace analysis
3131 {
32
3332 /*!
3433 * Composite parser which parses both CIFS&NFS
3534 */
3635 class Parsers
3736 {
3837 using FilteredDataQueue = NST::utils::FilteredDataQueue;
39 CIFSParser parser_cifs;//!< CIFS parser
40 NFSParser parser_nfs;//!< NFS parser
38 CIFSParser parser_cifs; //!< CIFS parser
39 NFSParser parser_nfs; //!< NFS parser
4140 public:
42
4341 Parsers(Analyzers& a)
4442 : parser_cifs(a)
4543 , parser_nfs(a)
46 {}
44 {
45 }
4746
4847 Parsers(Parsers& c)
4948 : parser_cifs(c.parser_cifs)
5049 , parser_nfs(c.parser_nfs)
51 {}
50 {
51 }
5252
5353 /*! Function which will be called by ParserThread class
5454 * \param data - packet
5555 */
5656 inline void parse_data(FilteredDataQueue::Ptr& data)
5757 {
58 if (!parser_nfs.parse_data(data))
58 if(!parser_nfs.parse_data(data))
5959 {
60 if (!parser_cifs.parse_data(data))
60 if(!parser_cifs.parse_data(data))
6161 {
6262 LOG("Unknown packet to analysis");
6363 }
6464 }
6565 }
66
6766 };
6867
6968 } // analysis
2626 {
2727 namespace analysis
2828 {
29
3029 bool Plugin::isSilent()
3130 {
32 if (requirements != nullptr)
31 if(requirements != nullptr)
3332 {
3433 // Processing analyzer requirements
3534 const AnalyzerRequirements* r = requirements();
36 if (r != nullptr)
35 if(r != nullptr)
3736 {
3837 return r->silence;
3938 }
4342
4443 Plugin::Plugin(const std::string& path)
4544 : DynamicLoad{path}
46 , usage {nullptr}
47 , create {nullptr}
45 , usage{nullptr}
46 , create{nullptr}
4847 , destroy{nullptr}
4948 , requirements{nullptr}
5049 {
6463 // Add 2.0 specific initialization here
6564 case NST_PLUGIN_API_VERSION:
6665 default:
67 usage = entry_points->usage;
68 create = entry_points->create;
69 destroy = entry_points->destroy;
66 usage = entry_points->usage;
67 create = entry_points->create;
68 destroy = entry_points->destroy;
7069 requirements = entry_points->requirements;
7170 }
7271
73 if(!usage || !create || !destroy)
72 if(!usage || !create || !destroy)
7473 {
7574 throw std::runtime_error{path + ": can't load entry point for some plugin function(s)"};
7675 }
8382 }
8483
8584 PluginInstance::PluginInstance(const std::string& path, const std::string& args)
86 : Plugin{path}
85 : Plugin{path}
8786 {
8887 analysis = create(args.c_str());
8988 if(!analysis) throw std::runtime_error{path + ": create call returns NULL-pointer"};
3030 {
3131 namespace analysis
3232 {
33
3433 class Plugin : private NST::utils::DynamicLoad
3534 {
3635 public:
3938
4039 protected:
4140 explicit Plugin(const std::string& path);
42 Plugin(const Plugin&) = delete;
41 Plugin(const Plugin&) = delete;
4342 Plugin& operator=(const Plugin&) = delete;
4443
45 plugin_usage_func usage;
46 plugin_create_func create;
47 plugin_destroy_func destroy;
44 plugin_usage_func usage;
45 plugin_create_func create;
46 plugin_destroy_func destroy;
4847 plugin_requirements_func requirements;
4948 };
5049
5251 {
5352 public:
5453 PluginInstance(const std::string& path, const std::string& args);
55 PluginInstance(const PluginInstance&) = delete;
54 PluginInstance(const PluginInstance&) = delete;
5655 PluginInstance& operator=(const PluginInstance&) = delete;
5756 ~PluginInstance();
5857
5958 inline IAnalyzer* instance() const { return analysis; }
60 inline bool silent(){ return isSilent(); }
59 inline bool silent() { return isSilent(); }
6160 private:
6261 IAnalyzer* analysis;
6362 };
6564 } // namespace analysis
6665 } // namespace NST
6766 //------------------------------------------------------------------------------
68 #endif//PLUGIN_H
67 #endif //PLUGIN_H
6968 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include <algorithm>
22 #include <ctime>
2123 #include <iomanip>
22 #include <time.h>
23 #include <algorithm>
24 #include <sstream>
2425 #include <utility>
25 #include <sstream>
2626
2727 #include "analysis/print_analyzer.h"
2828 #include "protocols/cifs/cifs.h"
2929 #include "protocols/cifs2/cifs2.h"
30 #include "protocols/cifs2/cifs2_utils.h"
3031 #include "protocols/nfs/nfs_utils.h"
3132 #include "protocols/nfs3/nfs3_utils.h"
33 #include "protocols/nfs4/nfs41_utils.h"
3234 #include "protocols/nfs4/nfs4_utils.h"
33 #include "protocols/nfs4/nfs41_utils.h"
34 #include "protocols/cifs2/cifs2_utils.h"
3535 #include "utils/sessions.h"
3636 //------------------------------------------------------------------------------
3737 namespace NST
3838 {
3939 namespace analysis
4040 {
41
4241 using SMBv1Commands = NST::API::SMBv1::SMBv1Commands;
4342 using SMBv2Commands = NST::API::SMBv2::SMBv2Commands;
4443 using namespace NST::protocols::CIFSv2;
5150 namespace NFS41 = NST::API::NFS41;
5251
5352 namespace
54 {
53 {
5554 bool print_procedure(std::ostream& out, const RPCProcedure* proc)
5655 {
5756 using namespace NST::utils;
58 bool result {false};
57 bool result{false};
5958 out << *(proc->session);
6059
61 auto& call = proc->call;
62 const unsigned long nfs_version {call.ru.RM_cmb.cb_vers};
63 if (out_all())
64 {
65 out << " XID: " << call.rm_xid
60 auto& call = proc->call;
61 const unsigned long nfs_version{call.ru.RM_cmb.cb_vers};
62 if(out_all())
63 {
64 out << " XID: " << call.rm_xid
6665 << " RPC version: " << call.ru.RM_cmb.cb_rpcvers
6766 << " RPC program: " << call.ru.RM_cmb.cb_prog
68 << " version: " << nfs_version << ' ';
69 }
70 switch (nfs_version)
67 << " version: " << nfs_version << ' ';
68 }
69 switch(nfs_version)
7170 {
7271 case NFS_V3:
7372 out << print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(call.ru.RM_cmb.cb_proc));
7978
8079 // check procedure reply
8180 auto& reply = proc->reply;
82 if (reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED)
83 {
84 switch (reply.ru.RM_rmb.ru.RP_ar.ar_stat)
81 if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED)
82 {
83 switch(reply.ru.RM_rmb.ru.RP_ar.ar_stat)
8584 {
8685 case accept_stat::SUCCESS:
87 result = true; // Ok, reply is correct
86 result = true; // Ok, reply is correct
8887 break;
8988 case accept_stat::PROG_MISMATCH:
9089 out << " Program mismatch: "
91 << " low: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.low
90 << " low: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.low
9291 << " high: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.high;
9392 break;
9493 case accept_stat::PROG_UNAVAIL:
105104 break;
106105 }
107106 }
108 else if (reply.ru.RM_rmb.rp_stat == reply_stat::MSG_DENIED)
107 else if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_DENIED)
109108 {
110109 out << " RPC Call rejected: ";
111 switch (reply.ru.RM_rmb.ru.RP_dr.rj_stat)
110 switch(reply.ru.RM_rmb.ru.RP_dr.rj_stat)
112111 {
113112 case reject_stat::RPC_MISMATCH:
114113 out << "RPC version number mismatch, "
120119 case reject_stat::AUTH_ERROR:
121120 {
122121 out << " Authentication check: ";
123 switch (reply.ru.RM_rmb.ru.RP_dr.ru.RJ_why)
122 switch(reply.ru.RM_rmb.ru.RP_dr.ru.RJ_why)
124123 {
125124 case auth_stat::AUTH_OK:
126125 out << "OK";
165164 std::ostream& print_time(std::ostream& out, uint64_t time)
166165 {
167166 // TODO: Replace with C++ 11 functions
168 if (time != 0)
167 if(time != 0)
169168 {
170169 const auto EPOCH_DIFF = 0x019DB1DED53E8000LL; /* 116444736000000000 nsecs */
171 const auto RATE_DIFF = 10000000; /* 100 nsecs */
170 const auto RATE_DIFF = 10000000; /* 100 nsecs */
172171
173172 uint64_t unixTimestamp = (time - EPOCH_DIFF) / RATE_DIFF;
174 time_t t = static_cast<time_t>(unixTimestamp);
173 time_t t = static_cast<time_t>(unixTimestamp);
175174
176175 // NOTE: If you ever want to print the year/day/month separately like this:
177176 //
180179 // do not forget adding 1900 to tm_year field, just to get current year
181180 // lt->tm_year + 1900
182181
183 const char *pTime = ctime(&t);
184 if (pTime != nullptr)
182 const char* pTime = ctime(&t);
183 if(pTime != nullptr)
185184 {
186185 // ctime adds "\n" at the end - remove it.
187186 size_t len = std::strlen(pTime);
196195 return out;
197196 }
198197
199 std::ostream& print_buffer(std::ostream& out, const uint8_t *buffer, uint16_t len)
198 std::ostream& print_buffer(std::ostream& out, const uint8_t* buffer, uint16_t len)
200199 {
201200 // TODO: Add unicode support
202201 const char* char_buffer = reinterpret_cast<const char*>(buffer);
210209 return out;
211210 }
212211
213 std::ostream& print_buffer_hex(std::ostream& out, const uint8_t *buffer, uint16_t len)
212 std::ostream& print_buffer_hex(std::ostream& out, const uint8_t* buffer, uint16_t len)
214213 {
215214 for(uint16_t i = 0; i < len; i++)
216215 {
228227
229228 // print hex value with preceding 0 (zeros) if necessary
230229 // ( e.g: 0x01 will be printed as 01 or 0x00 as 00 )
231 auto print_hex = [&out](uint32_t value, uint8_t bitShift)
232 {
230 auto print_hex = [&out](uint32_t value, uint8_t bitShift) {
233231 out << std::hex << std::setfill('0') << std::setw(2)
234232 << (static_cast<uint32_t>(value >> bitShift) & 0xFF) << std::dec;
235233 };
236234
237235 print_hex(refGuid.Data1, 24);
238236 print_hex(refGuid.Data1, 16);
239 print_hex(refGuid.Data1, 8);
240 print_hex(refGuid.Data1, 0);
237 print_hex(refGuid.Data1, 8);
238 print_hex(refGuid.Data1, 0);
241239 out << "-";
242240 print_hex(refGuid.Data2, 8);
243241 print_hex(refGuid.Data2, 0);
255253 }
256254 }
257255
258 template<typename CommandType>
256 template <typename CommandType>
259257 std::ostream& print_session(std::ostream& out, CommandType* cmd)
260258 {
261259 using namespace NST::utils;
264262 return out;
265263 }
266264
267 template<typename CommandType>
265 template <typename CommandType>
268266 std::ostream& print_smbv2_common_info_req(std::ostream& out, SMBv2Commands, CommandType* cmd)
269267 {
270268 out << " Structure size = ";
272270 return out;
273271 }
274272
275 template<typename CommandType>
273 template <typename CommandType>
276274 std::ostream& print_smbv2_common_info_resp(std::ostream& out, SMBv2Commands, CommandType* cmd)
277275 {
278276 out << " Structure size = ";
279277 print_hex16(out, cmd->pres->structureSize);
280278 return out;
281 }
279 }
282280
283281 std::ostream& print_smbv2_header(std::ostream& out, const RawMessageHeader* header)
284282 {
285 if (header == nullptr)
283 if(header == nullptr)
286284 {
287285 return out;
288286 }
308306 out << " Credit Charge = " << header->CreditCharge << "\n";
309307
310308 bool isResponse = header->flags & static_cast<uint32_t>(Flags::SERVER_TO_REDIR);
311 if (isResponse)
309 if(isResponse)
312310 {
313311 SMBv2::NTStatus status = static_cast<SMBv2::NTStatus>(header->status);
314312 print_enum(out, "NT Status", status);
321319 out << "\n";
322320 print_enum(out, "Command", header->cmd_code) << "\n";
323321
324 if (isResponse)
322 if(isResponse)
325323 {
326324 out << " Credits granted = " << header->Credit << "\n";
327325 }
408406 << "\n";
409407
410408 print_enum(out, "Security mode", cmd->parg->securityMode) << "\n";
411 print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n";
409 print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n";
412410
413411 out << " Client Guid = ";
414412 print_guid(out, cmd->parg->clientGUID);
427425 print_smbv2_header(out, cmd->res_header) << "\n";
428426 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
429427
430 print_enum(out, "Security mode", res->securityMode) << "\n";
428 print_enum(out, "Security mode", res->securityMode) << "\n";
431429
432430 out << " Dialect = ";
433431 print_hex16(out, res->dialectRevision);
456454
457455 out << "\n Boot Time = ";
458456 print_time(out, res->serverStartTime);
459
460457 }
461458
462459 void PrintAnalyzer::sessionSetupSMBv2(const SMBv2::SessionSetupCommand* cmd,
468465 print_session(out, cmd) << "\n";
469466 print_smbv2_header(out, cmd->req_header) << "\n";
470467 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
471 print_enum(out, "Flags", cmd->parg->VcNumber) << "\n";
472 print_enum(out, "Security mode", cmd->parg->securityMode) << "\n";
473 print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n";
468 print_enum(out, "Flags", cmd->parg->VcNumber) << "\n";
469 print_enum(out, "Security mode", cmd->parg->securityMode) << "\n";
470 print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n";
474471 out << " Channel = " << cmd->parg->Channel << "\n"
475472 << " Previous session id = " << cmd->parg->PreviousSessionId << "\n";
476473 print_smbv2_header(out, cmd->res_header) << "\n";
506503 if(plen > 0)
507504 {
508505 out << " Tree =";
509 print_buffer(out,cmd->parg->Buffer, plen) << "\n";
506 print_buffer(out, cmd->parg->Buffer, plen) << "\n";
510507 }
511508 print_smbv2_header(out, cmd->res_header) << "\n";
512509 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
513510 print_enum(out, "Share types", res->ShareType) << "\n";
514511 print_enum(out, "Capabilities", res->capabilities) << "\n";
515512 print_enum(out, "Share flags", res->shareFlags) << "\n";
516 print_enum(out, "Access mask", static_cast<SMBv2::AccessMask>(res->MaximalAccess));
513 print_enum(out, "Access mask", static_cast<SMBv2::AccessMask>(res->MaximalAccess));
517514 }
518515
519516 void PrintAnalyzer::treeDisconnectSMBv2(const SMBv2::TreeDisconnectCommand* cmd,
537534 print_session(out, cmd) << "\n";
538535 print_smbv2_header(out, cmd->req_header) << "\n";
539536 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
540 print_enum(out, "Oplock", cmd->parg->RequestedOplockLevel) << "\n";
541 print_enum(out, "Impersonation", cmd->parg->ImpersonationLevel) << "\n";
542 out << " Create Flags = ";
537 print_enum(out, "Oplock", cmd->parg->RequestedOplockLevel) << "\n";
538 print_enum(out, "Impersonation", cmd->parg->ImpersonationLevel) << "\n";
539 out << " Create Flags = ";
543540 print_hex64(out, cmd->parg->SmbCreateFlags);
544541 out << "\n";
545 print_enum(out, "Access Mask", cmd->parg->desiredAccess) << "\n";
546 print_enum(out, "File Attributes", cmd->parg->attributes) << "\n";
547 print_enum(out, "Share Access", cmd->parg->shareAccess) << "\n";
548 print_enum(out, "Disposition", cmd->parg->createDisposition) << "\n";
549 print_enum(out, "Create Options", cmd->parg->createOptions) << "\n";
542 print_enum(out, "Access Mask", cmd->parg->desiredAccess) << "\n";
543 print_enum(out, "File Attributes", cmd->parg->attributes) << "\n";
544 print_enum(out, "Share Access", cmd->parg->shareAccess) << "\n";
545 print_enum(out, "Disposition", cmd->parg->createDisposition) << "\n";
546 print_enum(out, "Create Options", cmd->parg->createOptions) << "\n";
550547
551548 const auto len = NST::API::SMBv2::pc_to_net(cmd->parg->NameLength);
552549 if(len > 0)
559556 print_smbv2_header(out, cmd->res_header) << "\n";
560557 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
561558
562 print_enum(out, "Oplock", res->oplockLevel) << "\n";
559 print_enum(out, "Oplock", res->oplockLevel) << "\n";
563560 out << " Response Flags = ";
564561 print_hex8(out, res->flag);
565562 out << "\n";
566 print_enum(out, "Create Action", res->CreateAction) << "\n";
567
568 if (cmd->res_header && cmd->res_header->status == to_integral(SMBv2::NTStatus::STATUS_SUCCESS))
563 print_enum(out, "Create Action", res->CreateAction) << "\n";
564
565 if(cmd->res_header && cmd->res_header->status == to_integral(SMBv2::NTStatus::STATUS_SUCCESS))
569566 {
570567 out << " Create = ";
571568 print_time(out, res->CreationTime);
585582 out << "\n End Of File = ";
586583 out << res->EndofFile << "\n";
587584
588 print_enum(out, "File Attributes", res->attributes);
585 print_enum(out, "File Attributes", res->attributes);
589586 }
590587 }
591588
642639 print_hex16(out, cmd->parg->dataOffset);
643640
644641 out << "\n"
645 << " Write Length = " << cmd->parg->Length << "\n"
646 << " File Offset = " << cmd->parg->Offset << "\n"
647 << " Channel = " << to_integral(cmd->parg->Channel) << "\n"
648 << " Remaining Bytes = " << cmd->parg->RemainingBytes << "\n"
649 << " Channel Info Offset = " << cmd->parg->WriteChannelInfoOffset << "\n"
650 << " Channel Info Length = " << cmd->parg->WriteChannelInfoLength << "\n";
651 print_enum(out, "Write Flags", cmd->parg->Flags) << "\n";
642 << " Write Length = " << cmd->parg->Length << "\n"
643 << " File Offset = " << cmd->parg->Offset << "\n"
644 << " Channel = " << to_integral(cmd->parg->Channel) << "\n"
645 << " Remaining Bytes = " << cmd->parg->RemainingBytes << "\n"
646 << " Channel Info Offset = " << cmd->parg->WriteChannelInfoOffset << "\n"
647 << " Channel Info Length = " << cmd->parg->WriteChannelInfoLength << "\n";
648 print_enum(out, "Write Flags", cmd->parg->Flags) << "\n";
652649
653650 print_smbv2_header(out, cmd->res_header) << "\n";
654651 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
680677 SMBv2Commands cmdEnum = SMBv2Commands::IOCTL;
681678 print_session(out, cmd) << "\n";
682679 print_smbv2_header(out, cmd->req_header) << "\n";
683 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
684 print_enum(out, "Control Code", cmd->parg->CtlCode) << "\n";
680 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
681 print_enum(out, "Control Code", cmd->parg->CtlCode) << "\n";
685682 out << " Input offset = " << cmd->parg->InputOffset << "\n"
686683 << " Input count = " << cmd->parg->InputCount << "\n"
687684 << " Max input response = " << cmd->parg->MaxInputResponse << "\n"
690687 << " Max output response = " << cmd->parg->MaxOutputResponse << "\n";
691688 print_smbv2_header(out, cmd->res_header) << "\n";
692689 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
693 print_enum(out, "Control Code", res->CtlCode) << "\n";
690 print_enum(out, "Control Code", res->CtlCode) << "\n";
694691 out << " Input offset = " << res->InputOffset << "\n"
695692 << " Input count = " << res->InputCount << "\n"
696693 << " Output offset = " << res->OutputOffset << "\n"
725722 print_session(out, cmd) << "\n";
726723 print_smbv2_header(out, cmd->req_header) << "\n";
727724 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
728 print_enum(out, "Info level", cmd->parg->infoType) << "\n";
725 print_enum(out, "Info level", cmd->parg->infoType) << "\n";
729726 out << " File index = " << cmd->parg->FileIndex << "\n"
730727 << " Output buffer length = " << cmd->parg->OutputBufferLength << "\n"
731728 << " Search pattern =";
748745 print_smbv2_header(out, cmd->res_header) << "\n";
749746 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
750747 out << " Offset = ";
751 print_hex32(out, res->OutputBufferOffset);
748 print_hex32(out, res->OutputBufferOffset);
752749 out << "\n";
753750 out << " Length = ";
754751 print_hex32(out, res->OutputBufferLength);
761758 print_session(out, cmd) << "\n";
762759 print_smbv2_header(out, cmd->req_header) << "\n";
763760 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
764 print_enum(out, "Class", cmd->parg->infoType) << "\n";
761 print_enum(out, "Class", cmd->parg->infoType) << "\n";
765762 print_info_levels(out, cmd->parg->infoType, cmd->parg->FileInfoClass) << "\n";
766763 //TODO: Print GUID handle file
767764 print_smbv2_header(out, cmd->res_header) << "\n";
768765 print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n";
769766 out << " Offset = ";
770 print_hex32(out, res->OutputBufferOffset);
767 print_hex32(out, res->OutputBufferOffset);
771768 out << "\n Length = ";
772769 print_hex32(out, res->OutputBufferLength);
773770 }
779776 print_session(out, cmd) << "\n";
780777 print_smbv2_header(out, cmd->req_header) << "\n";
781778 print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n";
782 print_enum(out, "Class", cmd->parg->infoType) << "\n";
779 print_enum(out, "Class", cmd->parg->infoType) << "\n";
783780 print_info_levels(out, cmd->parg->infoType, cmd->parg->FileInfoClass) << "\n";
784781 out << " Setinfo Size = ";
785 print_hex32(out, cmd->parg->BufferLength);
782 print_hex32(out, cmd->parg->BufferLength);
786783 out << "\n Setinfo Offset = ";
787784 print_hex16(out, cmd->parg->BufferOffset);
788785 out << "\n";
791788 }
792789
793790 void PrintAnalyzer::breakOplockSMBv2(const SMBv2::BreakOpLockCommand* cmd,
794 const SMBv2::OplockAcknowledgment*,
795 const SMBv2::OplockResponse* res)
791 const SMBv2::OplockAcknowledgment*,
792 const SMBv2::OplockResponse* res)
796793 {
797794 SMBv2Commands cmdEnum = SMBv2Commands::OPLOCK_BREAK;
798795
817814 const struct NFS3::NULL3args*,
818815 const struct NFS3::NULL3res*)
819816 {
820 if (!print_procedure(out, proc)) { return; }
817 if(!print_procedure(out, proc)) {
818 return;
819 }
821820 out << "\tCALL []\n\tREPLY []\n";
822821 }
823822
825824 const struct NFS3::GETATTR3args* args,
826825 const struct NFS3::GETATTR3res* res)
827826 {
828 if (!print_procedure(out, proc)) { return; }
829
830 if (args)
827 if(!print_procedure(out, proc)) {
828 return;
829 }
830
831 if(args)
831832 {
832833 out << "\tCALL ["
833834 << " object: " << args->object
834835 << " ]\n";
835836 }
836 if (res)
837 if(res)
837838 {
838839 out << "\tREPLY [ status: " << res->status;
839 if (out_all() && res->status == NFS3::nfsstat3::NFS3_OK)
840 if(out_all() && res->status == NFS3::nfsstat3::NFS3_OK)
840841 out << " obj attributes: "
841842 << res->GETATTR3res_u.resok.obj_attributes;
842843 out << " ]\n";
847848 const struct NFS3::SETATTR3args* args,
848849 const struct NFS3::SETATTR3res* res)
849850 {
850 if (!print_procedure(out, proc)) { return; }
851
852 if (args)
851 if(!print_procedure(out, proc)) {
852 return;
853 }
854
855 if(args)
853856 {
854857 out << "\tCALL [ object: " << args->object
855 << " new attributes: " << args->new_attributes
856 << " guard: " << args->guard
858 << " new attributes: " << args->new_attributes
859 << " guard: " << args->guard
857860 << " ]\n";
858861 }
859 if (res)
862 if(res)
860863 {
861864 out << "\tREPLY [ status: " << res->status;
862 if (out_all())
863 {
864 if (res->status == NFS3::nfsstat3::NFS3_OK)
865 if(out_all())
866 {
867 if(res->status == NFS3::nfsstat3::NFS3_OK)
865868 out << " obj_wcc: "
866869 << res->SETATTR3res_u.resok.obj_wcc;
867870 else
876879 const struct NFS3::LOOKUP3args* args,
877880 const struct NFS3::LOOKUP3res* res)
878881 {
879 if (!print_procedure(out, proc)) { return; }
880
881 if (args) { out << "\tCALL [ what: " << args->what << " ]\n"; }
882 if (res)
882 if(!print_procedure(out, proc)) {
883 return;
884 }
885
886 if(args) {
887 out << "\tCALL [ what: " << args->what << " ]\n";
888 }
889 if(res)
883890 {
884891 out << "\tREPLY [ status: " << res->status;
885 if (out_all())
886 {
887 if (res->status == NFS3::nfsstat3::NFS3_OK)
892 if(out_all())
893 {
894 if(res->status == NFS3::nfsstat3::NFS3_OK)
888895 out << " object: "
889896 << res->LOOKUP3res_u.resok.object
890897 << " object attributes: "
903910 const struct NFS3::ACCESS3args* args,
904911 const struct NFS3::ACCESS3res* res)
905912 {
906 if (!print_procedure(out, proc)) { return; }
907
908 if (args)
913 if(!print_procedure(out, proc)) {
914 return;
915 }
916
917 if(args)
909918 {
910919 out << "\tCALL [ object: ";
911920 print_nfs_fh(out,
916925 out << " ]\n";
917926 }
918927
919 if (res)
928 if(res)
920929 {
921930 out << "\tREPLY [ status: " << res->status;
922 if (out_all())
923 {
924 if (res->status == NFS3::nfsstat3::NFS3_OK)
931 if(out_all())
932 {
933 if(res->status == NFS3::nfsstat3::NFS3_OK)
925934 {
926935 out << " object attributes: "
927936 << res->ACCESS3res_u.resok.obj_attributes
942951 const struct NFS3::READLINK3args* args,
943952 const struct NFS3::READLINK3res* res)
944953 {
945 if (!print_procedure(out, proc)) { return; }
946
947 if (args) { out << "\tCALL [ symlink: " << args->symlink << " ]\n"; }
948 if (res)
954 if(!print_procedure(out, proc)) {
955 return;
956 }
957
958 if(args) {
959 out << "\tCALL [ symlink: " << args->symlink << " ]\n";
960 }
961 if(res)
949962 {
950963 out << "\tREPLY [ status: " << res->status;
951 if (out_all())
952 {
953 if (res->status == NFS3::nfsstat3::NFS3_OK)
964 if(out_all())
965 {
966 if(res->status == NFS3::nfsstat3::NFS3_OK)
954967 out << " symlink attributes: "
955968 << res->READLINK3res_u.resok.symlink_attributes
956969 << " data: "
967980 const struct NFS3::READ3args* args,
968981 const struct NFS3::READ3res* res)
969982 {
970 if (!print_procedure(out, proc)) { return; }
971
972 if (args)
983 if(!print_procedure(out, proc)) {
984 return;
985 }
986
987 if(args)
973988 {
974989 out << "\tCALL [ file: " << args->file
975990 << " offset: " << args->offset
976 << " count: " << args->count
991 << " count: " << args->count
977992 << " ]\n";
978993 }
979 if (res)
994 if(res)
980995 {
981996 out << "\tREPLY [ status: " << res->status;
982 if (out_all())
983 {
984 if (res->status == NFS3::nfsstat3::NFS3_OK)
997 if(out_all())
998 {
999 if(res->status == NFS3::nfsstat3::NFS3_OK)
9851000 {
9861001 out << " file attributes: "
9871002 << res->READ3res_u.resok.file_attributes
10041019 const struct NFS3::WRITE3args* args,
10051020 const struct NFS3::WRITE3res* res)
10061021 {
1007 if (!print_procedure(out, proc)) { return; }
1008
1009 if (args)
1022 if(!print_procedure(out, proc)) {
1023 return;
1024 }
1025
1026 if(args)
10101027 {
10111028 out << "\tCALL [ file: " << args->file
10121029 << " offset: " << args->offset
1013 << " count: " << args->count
1030 << " count: " << args->count
10141031 << " stable: " << args->stable
10151032 << " ]\n";
10161033 }
1017 if (res)
1034 if(res)
10181035 {
10191036 out << "\tREPLY [ status: " << res->status;
1020 if (out_all())
1021 {
1022 if (res->status == NFS3::nfsstat3::NFS3_OK)
1037 if(out_all())
1038 {
1039 if(res->status == NFS3::nfsstat3::NFS3_OK)
10231040 {
10241041 out << " file_wcc: "
10251042 << res->WRITE3res_u.resok.file_wcc
10461063 const struct NFS3::CREATE3args* args,
10471064 const struct NFS3::CREATE3res* res)
10481065 {
1049 if (!print_procedure(out, proc)) { return; }
1050
1051 if (args)
1066 if(!print_procedure(out, proc)) {
1067 return;
1068 }
1069
1070 if(args)
10521071 out << "\tCALL [ where: " << args->where
10531072 << " how: " << args->how
10541073 << " ]\n";
1055 if (res)
1074 if(res)
10561075 {
10571076 out << "\tREPLY [ status: " << res->status;
1058 if (out_all())
1059 {
1060 if (res->status == NFS3::nfsstat3::NFS3_OK)
1077 if(out_all())
1078 {
1079 if(res->status == NFS3::nfsstat3::NFS3_OK)
10611080 out << " obj: "
10621081 << res->CREATE3res_u.resok.obj
10631082 << " obj attributes: "
10761095 const struct NFS3::MKDIR3args* args,
10771096 const struct NFS3::MKDIR3res* res)
10781097 {
1079 if (!print_procedure(out, proc)) { return; }
1080
1081 if (args)
1098 if(!print_procedure(out, proc)) {
1099 return;
1100 }
1101
1102 if(args)
10821103 out << "\tCALL [ where: " << args->where
1083 << " attributes: " << args->attributes
1104 << " attributes: " << args->attributes
10841105 << " ]\n";
1085 if (res)
1106 if(res)
10861107 {
10871108 out << "\tREPLY [ status: " << res->status;
1088 if (out_all())
1089 {
1090 if (res->status == NFS3::nfsstat3::NFS3_OK)
1109 if(out_all())
1110 {
1111 if(res->status == NFS3::nfsstat3::NFS3_OK)
10911112 out << " obj: "
10921113 << res->MKDIR3res_u.resok.obj
10931114 << " obj attributes: "
11061127 const struct NFS3::SYMLINK3args* args,
11071128 const struct NFS3::SYMLINK3res* res)
11081129 {
1109 if (!print_procedure(out, proc)) { return; }
1110
1111 if (args)
1130 if(!print_procedure(out, proc)) {
1131 return;
1132 }
1133
1134 if(args)
11121135 out << "\tCALL [ where: " << args->where
1113 << " symlink: " << args->symlink
1136 << " symlink: " << args->symlink
11141137 << " ]\n";
1115 if (res)
1138 if(res)
11161139 {
11171140 out << "\tREPLY [ status: " << res->status;
1118 if (out_all())
1119 {
1120 if (res->status == NFS3::nfsstat3::NFS3_OK)
1141 if(out_all())
1142 {
1143 if(res->status == NFS3::nfsstat3::NFS3_OK)
11211144 out << " obj: "
11221145 << res->SYMLINK3res_u.resok.obj
11231146 << " obj attributes: "
11361159 const struct NFS3::MKNOD3args* args,
11371160 const struct NFS3::MKNOD3res* res)
11381161 {
1139 if (!print_procedure(out, proc)) { return; }
1140
1141 if (args)
1162 if(!print_procedure(out, proc)) {
1163 return;
1164 }
1165
1166 if(args)
11421167 {
11431168 out << "\tCALL [ where: " << args->where
1144 << " what: " << args->what
1169 << " what: " << args->what
11451170 << " ]\n";
11461171 }
1147 if (res)
1172 if(res)
11481173 {
11491174 out << "\tREPLY [ status: " << res->status;
1150 if (out_all())
1151 {
1152 if (res->status == NFS3::nfsstat3::NFS3_OK)
1175 if(out_all())
1176 {
1177 if(res->status == NFS3::nfsstat3::NFS3_OK)
11531178 out << " obj: "
11541179 << res->MKNOD3res_u.resok.obj
11551180 << " obj attributes: "
11681193 const struct NFS3::REMOVE3args* args,
11691194 const struct NFS3::REMOVE3res* res)
11701195 {
1171 if (!print_procedure(out, proc)) { return; }
1172
1173 if (args)
1196 if(!print_procedure(out, proc)) {
1197 return;
1198 }
1199
1200 if(args)
11741201 {
11751202 out << "\tCALL [ object: " << args->object << " ]\n";
11761203 }
1177 if (res)
1204 if(res)
11781205 {
11791206 out << "\tREPLY [ status: " << res->status;
1180 if (out_all())
1181 {
1182 if (res->status == NFS3::nfsstat3::NFS3_OK)
1207 if(out_all())
1208 {
1209 if(res->status == NFS3::nfsstat3::NFS3_OK)
11831210 out << " dir_wcc: "
11841211 << res->REMOVE3res_u.resok.dir_wcc;
11851212 else
11941221 const struct NFS3::RMDIR3args* args,
11951222 const struct NFS3::RMDIR3res* res)
11961223 {
1197 if (!print_procedure(out, proc)) { return; }
1198
1199 if (args)
1224 if(!print_procedure(out, proc)) {
1225 return;
1226 }
1227
1228 if(args)
12001229 {
12011230 out << "\tCALL [ object: " << args->object << " ]\n";
12021231 }
1203 if (res)
1232 if(res)
12041233 {
12051234 out << "\tREPLY [ status: " << res->status;
1206 if (out_all())
1207 {
1208 if (res->status == NFS3::nfsstat3::NFS3_OK)
1235 if(out_all())
1236 {
1237 if(res->status == NFS3::nfsstat3::NFS3_OK)
12091238 out << " dir_wcc: "
12101239 << res->RMDIR3res_u.resok.dir_wcc;
12111240 else
12201249 const struct NFS3::RENAME3args* args,
12211250 const struct NFS3::RENAME3res* res)
12221251 {
1223 if (!print_procedure(out, proc)) { return; }
1224
1225 if (args)
1252 if(!print_procedure(out, proc)) {
1253 return;
1254 }
1255
1256 if(args)
12261257 out << "\tCALL [ from: " << args->from
1227 << " to: " << args->to
1258 << " to: " << args->to
12281259 << " ]\n";
1229 if (res)
1260 if(res)
12301261 {
12311262 out << "\tREPLY [ status: " << res->status;
1232 if (out_all())
1233 {
1234 if (res->status == NFS3::nfsstat3::NFS3_OK)
1263 if(out_all())
1264 {
1265 if(res->status == NFS3::nfsstat3::NFS3_OK)
12351266 out << " from dir_wcc: "
12361267 << res->RENAME3res_u.resok.fromdir_wcc
12371268 << " to dir_wcc: "
12501281 const struct NFS3::LINK3args* args,
12511282 const struct NFS3::LINK3res* res)
12521283 {
1253 if (!print_procedure(out, proc)) { return; }
1254
1255 if (args)
1284 if(!print_procedure(out, proc)) {
1285 return;
1286 }
1287
1288 if(args)
12561289 out << "\tCALL [ file: " << args->file
1257 << " link: " << args->link
1290 << " link: " << args->link
12581291 << " ]\n";
1259 if (res)
1292 if(res)
12601293 {
12611294 out << "\tREPLY [ status: " << res->status;
1262 if (out_all())
1263 {
1264 if (res->status == NFS3::nfsstat3::NFS3_OK)
1295 if(out_all())
1296 {
1297 if(res->status == NFS3::nfsstat3::NFS3_OK)
12651298 out << " file attributes: "
12661299 << res->LINK3res_u.resok.file_attributes
12671300 << " link dir_wcc: "
12801313 const struct NFS3::READDIR3args* args,
12811314 const struct NFS3::READDIR3res* res)
12821315 {
1283 if (!print_procedure(out, proc)) { return; }
1284
1285 if (args)
1316 if(!print_procedure(out, proc)) {
1317 return;
1318 }
1319
1320 if(args)
12861321 {
12871322 out << "\tCALL [ dir: " << args->dir
1288 << " cookie: " << args->cookie
1323 << " cookie: " << args->cookie
12891324 << " cookieverf: ";
12901325 print_hex(out,
12911326 args->cookieverf,
12931328 out << " count: " << args->count
12941329 << " ]\n";
12951330 }
1296 if (res)
1331 if(res)
12971332 {
12981333 out << "\tREPLY [ status: " << res->status;
1299 if (out_all())
1300 {
1301 if (res->status == NFS3::nfsstat3::NFS3_OK)
1334 if(out_all())
1335 {
1336 if(res->status == NFS3::nfsstat3::NFS3_OK)
13021337 {
13031338 out << " dir attributes: "
13041339 << res->READDIR3res_u.resok.dir_attributes
13231358 const struct NFS3::READDIRPLUS3args* args,
13241359 const struct NFS3::READDIRPLUS3res* res)
13251360 {
1326 if (!print_procedure(out, proc)) { return; }
1327
1328 if (args)
1361 if(!print_procedure(out, proc)) {
1362 return;
1363 }
1364
1365 if(args)
13291366 {
13301367 out << "\tCALL [ dir: " << args->dir
1331 << " cookie: " << args->cookie
1368 << " cookie: " << args->cookie
13321369 << " cookieverf: ";
13331370 print_hex(out,
13341371 args->cookieverf,
13371374 << " max count: " << args->maxcount
13381375 << " ]\n";
13391376 }
1340 if (res)
1377 if(res)
13411378 {
13421379 out << "\tREPLY [ status: " << res->status;
1343 if (out_all())
1344 {
1345 if (res->status == NFS3::nfsstat3::NFS3_OK)
1380 if(out_all())
1381 {
1382 if(res->status == NFS3::nfsstat3::NFS3_OK)
13461383 {
13471384 out << " dir attributes: "
13481385 << res->READDIRPLUS3res_u.resok.dir_attributes
13671404 const struct NFS3::FSSTAT3args* args,
13681405 const struct NFS3::FSSTAT3res* res)
13691406 {
1370 if (!print_procedure(out, proc)) { return; }
1371
1372 if (args)
1407 if(!print_procedure(out, proc)) {
1408 return;
1409 }
1410
1411 if(args)
13731412 {
13741413 out << "\tCALL [ fsroot: " << args->fsroot << " ]\n";
13751414 }
1376 if (res)
1415 if(res)
13771416 {
13781417 out << "\tREPLY [ status: " << res->status;
1379 if (out_all())
1380 {
1381 if (res->status == NFS3::nfsstat3::NFS3_OK)
1418 if(out_all())
1419 {
1420 if(res->status == NFS3::nfsstat3::NFS3_OK)
13821421 out << " obj attributes: "
13831422 << res->FSSTAT3res_u.resok.obj_attributes
13841423 << " tbytes: "
14071446 const struct NFS3::FSINFO3args* args,
14081447 const struct NFS3::FSINFO3res* res)
14091448 {
1410 if (!print_procedure(out, proc)) { return; }
1411
1412 if (args)
1449 if(!print_procedure(out, proc)) {
1450 return;
1451 }
1452
1453 if(args)
14131454 {
14141455 out << "\tCALL [ fsroot: " << args->fsroot << " ]\n";
14151456 }
1416 if (res)
1457 if(res)
14171458 {
14181459 out << "\tREPLY [ status: " << res->status;
1419 if (out_all())
1420 {
1421 if (res->status == NFS3::nfsstat3::NFS3_OK)
1460 if(out_all())
1461 {
1462 if(res->status == NFS3::nfsstat3::NFS3_OK)
14221463 out << " obj attributes: "
14231464 << res->FSINFO3res_u.resok.obj_attributes
14241465 << " rtmax: "
14651506 const struct NFS3::PATHCONF3args* args,
14661507 const struct NFS3::PATHCONF3res* res)
14671508 {
1468 if (!print_procedure(out, proc)) { return; }
1469
1470 if (args)
1509 if(!print_procedure(out, proc)) {
1510 return;
1511 }
1512
1513 if(args)
14711514 {
14721515 out << "\tCALL [ object: " << args->object << " ]\n";
14731516 }
1474 if (res)
1517 if(res)
14751518 {
14761519 out << "\tREPLY [ status: " << res->status;
1477 if (out_all())
1478 {
1479 if (res->status == NFS3::nfsstat3::NFS3_OK)
1520 if(out_all())
1521 {
1522 if(res->status == NFS3::nfsstat3::NFS3_OK)
14801523 out << " obj attributes: "
14811524 << res->PATHCONF3res_u.resok.obj_attributes
14821525 << " link max: "
15031546 const struct NFS3::COMMIT3args* args,
15041547 const struct NFS3::COMMIT3res* res)
15051548 {
1506 if (!print_procedure(out, proc)) { return; }
1507
1508 if (args)
1549 if(!print_procedure(out, proc)) {
1550 return;
1551 }
1552
1553 if(args)
15091554 out << "\tCALL [ file: " << args->file
1510 << " offset: " << args->offset
1511 << " count: " << args->count
1555 << " offset: " << args->offset
1556 << " count: " << args->count
15121557 << " ]\n";
1513 if (res)
1558 if(res)
15141559 {
15151560 out << "\tREPLY [ status: " << res->status;
1516 if (out_all())
1517 {
1518 if (res->status == NFS3::nfsstat3::NFS3_OK)
1561 if(out_all())
1562 {
1563 if(res->status == NFS3::nfsstat3::NFS3_OK)
15191564 {
15201565 out << " file_wcc: "
15211566 << res->COMMIT3res_u.resok.file_wcc
15341579 }
15351580 }
15361581
1537
15381582 // Print NFSv4 procedures
15391583 // 1st line - PRC information: src and dst hosts, status of RPC procedure
15401584 // 2nd line - <tabulation>related RPC procedure-specific arguments
15461590 const struct NFS4::NULL4args*,
15471591 const struct NFS4::NULL4res*)
15481592 {
1549 if (!print_procedure(out, proc)) { return; }
1593 if(!print_procedure(out, proc)) {
1594 return;
1595 }
15501596
15511597 out << "\tCALL []\n\tREPLY []\n";
15521598 }
15551601 const struct NFS4::COMPOUND4args* args,
15561602 const struct NFS4::COMPOUND4res* res)
15571603 {
1558 if (!print_procedure(out, proc)) { return; }
1559
1560 const u_int* array_len {};
1561 if (args)
1604 if(!print_procedure(out, proc)) {
1605 return;
1606 }
1607
1608 const u_int* array_len{};
1609 if(args)
15621610 {
15631611 array_len = &args->argarray.argarray_len;
15641612 out << "\tCALL [ operations: " << *array_len
1565 << " tag: " << args->tag
1566 << " minor version: " << args->minorversion;
1567 if (*array_len)
1568 {
1569 NFS4::nfs_argop4* current_el {args->argarray.argarray_val};
1570 for (u_int i = 0; i < *array_len; i++, current_el++)
1613 << " tag: " << args->tag
1614 << " minor version: " << args->minorversion;
1615 if(*array_len)
1616 {
1617 NFS4::nfs_argop4* current_el{args->argarray.argarray_val};
1618 for(u_int i = 0; i < *array_len; i++, current_el++)
15711619 {
15721620 out << "\n\t\t[ ";
15731621 nfs4_operation(current_el);
15761624 out << " ]\n";
15771625 }
15781626 }
1579 if (res)
1627 if(res)
15801628 {
15811629 array_len = &res->resarray.resarray_len;
15821630 out << "\tREPLY [ operations: " << *array_len;
1583 if (*array_len)
1584 {
1585 NFS4::nfs_resop4* current_el {res->resarray.resarray_val};
1586 for (u_int i = 0; i < *array_len; i++, current_el++)
1631 if(*array_len)
1632 {
1633 NFS4::nfs_resop4* current_el{res->resarray.resarray_val};
1634 for(u_int i = 0; i < *array_len; i++, current_el++)
15871635 {
15881636 out << "\n\t\t[ ";
15891637 nfs4_operation(current_el);
15961644
15971645 void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_argop4* op)
15981646 {
1599 if (op)
1647 if(op)
16001648 {
16011649 out << print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(op->argop))
16021650 << '(' << op->argop << ") [ ";
1603 switch (op->argop)
1651 switch(op->argop)
16041652 {
16051653 case NFS4::OP_ACCESS:
16061654 return nfs4_operation(&op->nfs_argop4_u.opaccess);
16871735
16881736 void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_resop4* op)
16891737 {
1690 if (op)
1738 if(op)
16911739 {
16921740 out << print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(op->resop))
16931741 << '(' << op->resop << ") [ ";
1694 switch (op->resop)
1742 switch(op->resop)
16951743 {
16961744 case NFS4::OP_ACCESS:
16971745 return nfs4_operation(&op->nfs_resop4_u.opaccess);
17781826
17791827 void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4args* args)
17801828 {
1781 if (args)
1782 {
1783 if ((args->access) & NFS4::ACCESS4_READ) { out << "READ "; }
1784 if ((args->access) & NFS4::ACCESS4_LOOKUP) { out << "LOOKUP "; }
1785 if ((args->access) & NFS4::ACCESS4_MODIFY) { out << "MODIFY "; }
1786 if ((args->access) & NFS4::ACCESS4_EXTEND) { out << "EXTEND "; }
1787 if ((args->access) & NFS4::ACCESS4_DELETE) { out << "DELETE "; }
1788 if ((args->access) & NFS4::ACCESS4_EXECUTE) { out << "EXECUTE "; }
1789 }
1790 }
1791
1792 void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4res* res)
1793 {
1794 if (res)
1795 {
1796 out << "status: " << res->status;
1797 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
1829 if(args)
1830 {
1831 if((args->access) & NFS4::ACCESS4_READ) {
1832 out << "READ ";
1833 }
1834 if((args->access) & NFS4::ACCESS4_LOOKUP) {
1835 out << "LOOKUP ";
1836 }
1837 if((args->access) & NFS4::ACCESS4_MODIFY) {
1838 out << "MODIFY ";
1839 }
1840 if((args->access) & NFS4::ACCESS4_EXTEND) {
1841 out << "EXTEND ";
1842 }
1843 if((args->access) & NFS4::ACCESS4_DELETE) {
1844 out << "DELETE ";
1845 }
1846 if((args->access) & NFS4::ACCESS4_EXECUTE) {
1847 out << "EXECUTE ";
1848 }
1849 }
1850 }
1851
1852 void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4res* res)
1853 {
1854 if(res)
1855 {
1856 out << "status: " << res->status;
1857 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
17981858 {
17991859 out << " supported: ";
1800 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_READ)
1860 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_READ)
18011861 {
18021862 out << "READ ";
18031863 }
1804 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_LOOKUP)
1864 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_LOOKUP)
18051865 {
18061866 out << "LOOKUP ";
18071867 }
1808 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_MODIFY)
1868 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_MODIFY)
18091869 {
18101870 out << "MODIFY ";
18111871 }
1812 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXTEND)
1872 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXTEND)
18131873 {
18141874 out << "EXTEND ";
18151875 }
1816 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_DELETE)
1876 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_DELETE)
18171877 {
18181878 out << "DELETE ";
18191879 }
1820 if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXECUTE)
1880 if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXECUTE)
18211881 {
18221882 out << "EXECUTE ";
18231883 }
18241884 out << " access: ";
1825 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_READ)
1885 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_READ)
18261886 {
18271887 out << "READ ";
18281888 }
1829 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_LOOKUP)
1889 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_LOOKUP)
18301890 {
18311891 out << "LOOKUP ";
18321892 }
1833 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_MODIFY)
1893 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_MODIFY)
18341894 {
18351895 out << "MODIFY ";
18361896 }
1837 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXTEND)
1897 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXTEND)
18381898 {
18391899 out << "EXTEND ";
18401900 }
1841 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_DELETE)
1901 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_DELETE)
18421902 {
18431903 out << "DELETE ";
18441904 }
1845 if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXECUTE)
1905 if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXECUTE)
18461906 {
18471907 out << "EXECUTE ";
18481908 }
18521912
18531913 void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4args* args)
18541914 {
1855 if (args)
1856 {
1857 out << "seqid: " << std::hex << args->seqid << std::dec
1915 if(args)
1916 {
1917 out << "seqid: " << std::hex << args->seqid << std::dec
18581918 << " open state id:" << args->open_stateid;
18591919 }
18601920 }
18611921
1862 void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4res* res)
1863 {
1864 if (res)
1865 {
1866 out << "status: " << res->status;
1867 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
1922 void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4res* res)
1923 {
1924 if(res)
1925 {
1926 out << "status: " << res->status;
1927 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
18681928 {
18691929 out << " open state id:" << res->CLOSE4res_u.open_stateid;
18701930 }
18731933
18741934 void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4args* args)
18751935 {
1876 if (args)
1877 {
1878 out << "offset: " << args->offset
1879 << " count: " << args->count;
1880 }
1881 }
1882
1883 void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4res* res)
1884 {
1885 if (res)
1886 {
1887 out << "status: " << res->status;
1888 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
1936 if(args)
1937 {
1938 out << "offset: " << args->offset
1939 << " count: " << args->count;
1940 }
1941 }
1942
1943 void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4res* res)
1944 {
1945 if(res)
1946 {
1947 out << "status: " << res->status;
1948 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
18891949 {
18901950 out << " write verifier: ";
18911951 print_hex(out,
18971957
18981958 void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4args* args)
18991959 {
1900 if (args)
1901 {
1902 out << "object type: " << args->objtype
1903 << " object name: " << args->objname
1960 if(args)
1961 {
1962 out << "object type: " << args->objtype
1963 << " object name: " << args->objname
19041964 << " create attributes: " << args->createattrs;
19051965 }
19061966 }
19071967
1908 void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4res* res)
1909 {
1910 if (res)
1911 {
1912 out << "status: " << res->status;
1913 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
1968 void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4res* res)
1969 {
1970 if(res)
1971 {
1972 out << "status: " << res->status;
1973 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
19141974 out << res->CREATE4res_u.resok4.cinfo << ' '
19151975 << res->CREATE4res_u.resok4.attrset;
19161976 }
19181978
19191979 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4args* args)
19201980 {
1921 if (args) { out << "client id: " << std::hex << args->clientid << std::dec; }
1922 }
1923
1924 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4res* res)
1925 {
1926 if (res) { out << "status: " << res->status; }
1981 if(args) {
1982 out << "client id: " << std::hex << args->clientid << std::dec;
1983 }
1984 }
1985
1986 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4res* res)
1987 {
1988 if(res) {
1989 out << "status: " << res->status;
1990 }
19271991 }
19281992
19291993 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4args* args)
19301994 {
1931 if (args) { out << args->deleg_stateid; }
1932 }
1933
1934 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4res* res)
1935 {
1936 if (res) { out << "status: " << res->status; }
1995 if(args) {
1996 out << args->deleg_stateid;
1997 }
1998 }
1999
2000 void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4res* res)
2001 {
2002 if(res) {
2003 out << "status: " << res->status;
2004 }
19372005 }
19382006
19392007 void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4args* args)
19402008 {
1941 if (args) { out << args->attr_request; }
1942 }
1943
1944 void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4res* res)
1945 {
1946 if (res)
1947 {
1948 out << "status: " << res->status;
1949 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2009 if(args) {
2010 out << args->attr_request;
2011 }
2012 }
2013
2014 void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4res* res)
2015 {
2016 if(res)
2017 {
2018 out << "status: " << res->status;
2019 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
19502020 {
19512021 out << ' ' << res->GETATTR4res_u.resok4.obj_attributes;
19522022 }
19552025
19562026 void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4args* args)
19572027 {
1958 if (args) { out << "new name: " << args->newname; }
1959 }
1960
1961 void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4res* res)
1962 {
1963 if (res)
1964 {
1965 out << "status: " << res->status;
1966 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2028 if(args) {
2029 out << "new name: " << args->newname;
2030 }
2031 }
2032
2033 void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4res* res)
2034 {
2035 if(res)
2036 {
2037 out << "status: " << res->status;
2038 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
19672039 {
19682040 out << ' ' << res->LINK4res_u.resok4.cinfo;
19692041 }
19722044
19732045 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4args* args)
19742046 {
1975 if (args)
1976 {
1977 out << "lock type: " << args->locktype
1978 << " reclaim: " << args->reclaim
1979 << " offset: " << args->offset
1980 << " length: " << args->length
1981 << " locker: " << args->locker;
1982 }
1983 }
1984
1985 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4res* res)
1986 {
1987 if (res)
1988 {
1989 out << "status: " << res->status;
1990 if (out_all())
1991 {
1992 switch (res->status)
2047 if(args)
2048 {
2049 out << "lock type: " << args->locktype
2050 << " reclaim: " << args->reclaim
2051 << " offset: " << args->offset
2052 << " length: " << args->length
2053 << " locker: " << args->locker;
2054 }
2055 }
2056
2057 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4res* res)
2058 {
2059 if(res)
2060 {
2061 out << "status: " << res->status;
2062 if(out_all())
2063 {
2064 switch(res->status)
19932065 {
19942066 case NFS4::nfsstat4::NFS4_OK:
19952067 out << " lock stat id: "
19962068 << res->LOCK4res_u.resok4.lock_stateid;
19972069 break;
19982070 case NFS4::nfsstat4::NFS4ERR_DENIED:
1999 out << " offset: " << res->LOCK4res_u.denied.offset
2000 << " length: " << res->LOCK4res_u.denied.length
2071 out << " offset: " << res->LOCK4res_u.denied.offset
2072 << " length: " << res->LOCK4res_u.denied.length
20012073 << " lock type: " << res->LOCK4res_u.denied.locktype
2002 << " owner: " << res->LOCK4res_u.denied.owner;
2074 << " owner: " << res->LOCK4res_u.denied.owner;
20032075 break;
20042076 default:
20052077 break;
20102082
20112083 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4args* args)
20122084 {
2013 if (args)
2014 {
2015 out << "lock type: " << args->locktype
2016 << " offset: " << args->offset
2017 << " length: " << args->length
2018 << " owner: " << args->owner;
2019 }
2020 }
2021
2022 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4res* res)
2023 {
2024 if (res)
2025 {
2026 out << "status: " << res->status;
2027 if (out_all() && res->status == NFS4::nfsstat4::NFS4ERR_DENIED)
2028 out << " offset: " << res->LOCKT4res_u.denied.offset
2029 << " length: " << res->LOCKT4res_u.denied.length
2085 if(args)
2086 {
2087 out << "lock type: " << args->locktype
2088 << " offset: " << args->offset
2089 << " length: " << args->length
2090 << " owner: " << args->owner;
2091 }
2092 }
2093
2094 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4res* res)
2095 {
2096 if(res)
2097 {
2098 out << "status: " << res->status;
2099 if(out_all() && res->status == NFS4::nfsstat4::NFS4ERR_DENIED)
2100 out << " offset: " << res->LOCKT4res_u.denied.offset
2101 << " length: " << res->LOCKT4res_u.denied.length
20302102 << " lock type: " << res->LOCKT4res_u.denied.locktype
2031 << " owner: " << res->LOCKT4res_u.denied.owner;
2103 << " owner: " << res->LOCKT4res_u.denied.owner;
20322104 }
20332105 }
20342106
20352107 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4args* args)
20362108 {
2037 if (args)
2038 {
2039 out << "lock type: " << args->locktype
2040 << " seqid: " << std::hex << args->seqid << std::dec
2109 if(args)
2110 {
2111 out << "lock type: " << args->locktype
2112 << " seqid: " << std::hex << args->seqid << std::dec
20412113 << " lock state id: " << args->lock_stateid
2042 << " offset: " << args->offset
2043 << " length: " << args->length;
2044 }
2045 }
2046
2047 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4res* res)
2048 {
2049 if (res)
2050 {
2051 out << "status: " << res->status;
2052 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2114 << " offset: " << args->offset
2115 << " length: " << args->length;
2116 }
2117 }
2118
2119 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4res* res)
2120 {
2121 if(res)
2122 {
2123 out << "status: " << res->status;
2124 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
20532125 {
20542126 out << " lock state id: " << res->LOCKU4res_u.lock_stateid;
20552127 }
20582130
20592131 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4args* args)
20602132 {
2061 if (args) { out << "object name: " << args->objname; }
2062 }
2063
2064 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4res* res)
2065 {
2066 if (res) { out << "status: " << res->status; }
2133 if(args) {
2134 out << "object name: " << args->objname;
2135 }
2136 }
2137
2138 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4res* res)
2139 {
2140 if(res) {
2141 out << "status: " << res->status;
2142 }
20672143 }
20682144
20692145 void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4args* args)
20702146 {
2071 if (args) { out << "object attributes: " << args->obj_attributes; }
2072 }
2073
2074 void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4res* res)
2075 {
2076 if (res) { out << "status: " << res->status; }
2147 if(args) {
2148 out << "object attributes: " << args->obj_attributes;
2149 }
2150 }
2151
2152 void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4res* res)
2153 {
2154 if(res) {
2155 out << "status: " << res->status;
2156 }
20772157 }
20782158
20792159 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4args* args)
20802160 {
2081 static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"};
2161 static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"};
20822162 static const char* const open4_share_deny[4] = {"NONE", "READ", "WRITE", "BOTH"};
20832163
2084 if (args)
2085 {
2086 out << "seqid: " << std::hex << args->seqid << std::dec
2164 if(args)
2165 {
2166 out << "seqid: " << std::hex << args->seqid << std::dec
20872167 << " share access: " << open4_share_access[args->share_access]
2088 << " share deny: " << open4_share_deny[args->share_deny]
2168 << " share deny: " << open4_share_deny[args->share_deny]
20892169 << ' ' << args->owner
20902170 << ' ' << args->openhow
20912171 << ' ' << args->claim;
20922172 }
20932173 }
20942174
2095 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4res* res)
2096 {
2097 if (res)
2098 {
2099 out << "status: " << res->status;
2100 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2175 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4res* res)
2176 {
2177 if(res)
2178 {
2179 out << "status: " << res->status;
2180 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
21012181 out << res->OPEN4res_u.resok4.stateid
21022182 << res->OPEN4res_u.resok4.cinfo
21032183 << " results flags: "
21092189
21102190 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4args* args)
21112191 {
2112 if (args) { out << "create directory: " << args->createdir; }
2113 }
2114
2115 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4res* res)
2116 {
2117 if (res) { out << "status: " << res->status; }
2192 if(args) {
2193 out << "create directory: " << args->createdir;
2194 }
2195 }
2196
2197 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4res* res)
2198 {
2199 if(res) {
2200 out << "status: " << res->status;
2201 }
21182202 }
21192203
21202204 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4args* args)
21212205 {
2122 if (args)
2123 {
2124 out << "open state id:" << args->open_stateid
2125 << " seqid: " << std::hex << args->seqid << std::dec;
2126 }
2127 }
2128
2129 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4res* res)
2130 {
2131 if (res)
2132 {
2133 out << "status: " << res->status;
2134 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2206 if(args)
2207 {
2208 out << "open state id:" << args->open_stateid
2209 << " seqid: " << std::hex << args->seqid << std::dec;
2210 }
2211 }
2212
2213 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4res* res)
2214 {
2215 if(res)
2216 {
2217 out << "status: " << res->status;
2218 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
21352219 {
21362220 out << " open state id:" << res->OPEN_CONFIRM4res_u.resok4.open_stateid;
21372221 }
21402224
21412225 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4args* args)
21422226 {
2143 if (args)
2227 if(args)
21442228 {
21452229 out << " open state id: " << args->open_stateid
2146 << " seqid: " << std::hex << args->seqid << std::dec
2147 << " share access: " << args->share_access
2148 << " share deny: " << args->share_deny;
2149 }
2150 }
2151
2152 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4res* res)
2153 {
2154 if (res)
2155 {
2156 out << "status: " << res->status;
2157 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2230 << " seqid: " << std::hex << args->seqid << std::dec
2231 << " share access: " << args->share_access
2232 << " share deny: " << args->share_deny;
2233 }
2234 }
2235
2236 void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4res* res)
2237 {
2238 if(res)
2239 {
2240 out << "status: " << res->status;
2241 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
21582242 {
21592243 out << ' ' << res->OPEN_DOWNGRADE4res_u.resok4.open_stateid;
21602244 }
21632247
21642248 void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4args* args)
21652249 {
2166 if (args)
2250 if(args)
21672251 {
21682252 out << "object: ";
21692253 print_nfs_fh(out, args->object.nfs_fh4_val, args->object.nfs_fh4_len);
21702254 }
21712255 }
21722256
2173 void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4res* res)
2174 {
2175 if (res) { out << "status: " << res->status; }
2257 void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4res* res)
2258 {
2259 if(res) {
2260 out << "status: " << res->status;
2261 }
21762262 }
21772263
21782264 void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4args* args)
21792265 {
2180 if (args)
2266 if(args)
21812267 {
21822268 out << args->stateid
2183 << " offset: " << args->offset
2184 << " count: " << args->count;
2185 }
2186 }
2187
2188 void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4res* res)
2189 {
2190 if (res)
2191 {
2192 out << "status: " << res->status;
2193 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2269 << " offset: " << args->offset
2270 << " count: " << args->count;
2271 }
2272 }
2273
2274 void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4res* res)
2275 {
2276 if(res)
2277 {
2278 out << "status: " << res->status;
2279 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
21942280 {
21952281 out << " eof: " << res->READ4res_u.resok4.eof;
2196 if (res->READ4res_u.resok4.data.data_len)
2282 if(res->READ4res_u.resok4.data.data_len)
21972283 {
21982284 out << " data : " << *res->READ4res_u.resok4.data.data_val;
21992285 }
22032289
22042290 void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4args* args)
22052291 {
2206 if (args)
2207 {
2208 out << "cookie: " << args->cookie
2209 << " cookieverf: " << args->cookieverf
2210 << " dir count: " << args->dircount
2211 << " max count: " << args->maxcount
2292 if(args)
2293 {
2294 out << "cookie: " << args->cookie
2295 << " cookieverf: " << args->cookieverf
2296 << " dir count: " << args->dircount
2297 << " max count: " << args->maxcount
22122298 << " attributes request: " << args->attr_request;
22132299 }
22142300 }
22152301
2216 void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4res* res)
2217 {
2218 if (res)
2219 {
2220 out << "status: " << res->status;
2221 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2302 void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4res* res)
2303 {
2304 if(res)
2305 {
2306 out << "status: " << res->status;
2307 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
22222308 out << " cookie verifier: " << res->READDIR4res_u.resok4.cookieverf
2223 << " reply: " << res->READDIR4res_u.resok4.reply;
2309 << " reply: " << res->READDIR4res_u.resok4.reply;
22242310 }
22252311 }
22262312
22272313 void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4args* args)
22282314 {
2229 if (args) { out << "target: " << args->target; }
2230 }
2231
2232 void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4res* res)
2233 {
2234 if (res)
2235 {
2236 out << "status: " << res->status;
2237 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2315 if(args) {
2316 out << "target: " << args->target;
2317 }
2318 }
2319
2320 void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4res* res)
2321 {
2322 if(res)
2323 {
2324 out << "status: " << res->status;
2325 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
22382326 {
22392327 out << ' ' << res->REMOVE4res_u.resok4.cinfo;
22402328 }
22432331
22442332 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4args* args)
22452333 {
2246 if (args)
2247 {
2248 out << "old name: " << args->oldname
2334 if(args)
2335 {
2336 out << "old name: " << args->oldname
22492337 << " new name: " << args->newname;
22502338 }
22512339 }
22522340
2253 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4res* res)
2254 {
2255 if (res)
2256 {
2257 out << "status: " << res->status;
2258 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2341 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4res* res)
2342 {
2343 if(res)
2344 {
2345 out << "status: " << res->status;
2346 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
22592347 out << " source: "
22602348 << res->RENAME4res_u.resok4.source_cinfo
22612349 << " target: "
22652353
22662354 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4args* args)
22672355 {
2268 if (args)
2356 if(args)
22692357 {
22702358 out << "client id: "
22712359 << std::hex << args->clientid << std::dec;
22722360 }
22732361 }
22742362
2275 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4res* res)
2276 {
2277 if (res) { out << "status: " << res->status; }
2363 void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4res* res)
2364 {
2365 if(res) {
2366 out << "status: " << res->status;
2367 }
22782368 }
22792369
22802370 void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4args* args)
22812371 {
2282 if (args) { out << "name: " << args->name; }
2283 }
2284
2285 void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4res* res)
2286 {
2287 if (res)
2288 {
2289 out << "status: " << res->status;
2290 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2291 {
2292 if (res->SECINFO4res_u.resok4.SECINFO4resok_len)
2372 if(args) {
2373 out << "name: " << args->name;
2374 }
2375 }
2376
2377 void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4res* res)
2378 {
2379 if(res)
2380 {
2381 out << "status: " << res->status;
2382 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2383 {
2384 if(res->SECINFO4res_u.resok4.SECINFO4resok_len)
22932385 out << " data : "
22942386 << *res->SECINFO4res_u.resok4.SECINFO4resok_val;
22952387 }
22982390
22992391 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4args* args)
23002392 {
2301 if (args)
2393 if(args)
23022394 {
23032395 out << "state id:" << args->stateid
23042396 << ' ' << args->obj_attributes;
23052397 }
23062398 }
23072399
2308 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4res* res)
2309 {
2310 if (res)
2311 {
2312 out << "status: " << res->status;
2313 if (out_all()) { out << ' ' << res->attrsset; }
2400 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4res* res)
2401 {
2402 if(res)
2403 {
2404 out << "status: " << res->status;
2405 if(out_all()) {
2406 out << ' ' << res->attrsset;
2407 }
23142408 }
23152409 }
23162410
23172411 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4args* args)
23182412 {
2319 if (args)
2413 if(args)
23202414 {
23212415 out << args->client
23222416 << " callback: "
23262420 }
23272421 }
23282422
2329 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4res* res)
2330 {
2331 if (res)
2332 {
2333 out << "status: " << res->status;
2334 if (out_all())
2335 {
2336 switch (res->status)
2423 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4res* res)
2424 {
2425 if(res)
2426 {
2427 out << "status: " << res->status;
2428 if(out_all())
2429 {
2430 switch(res->status)
23372431 {
23382432 case NFS4::nfsstat4::NFS4_OK:
23392433 out << " client id: "
23552449
23562450 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4args* args)
23572451 {
2358 if (args)
2452 if(args)
23592453 {
23602454 out << " client id: " << std::hex << args->clientid << std::dec
23612455 << " verifier: ";
23632457 }
23642458 }
23652459
2366 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4res* res)
2367 {
2368 if (res) { out << "status: " << res->status; }
2460 void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4res* res)
2461 {
2462 if(res) {
2463 out << "status: " << res->status;
2464 }
23692465 }
23702466
23712467 void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4args* args)
23722468 {
2373 if (args) { out << "object attributes: " << args->obj_attributes; }
2374 }
2375
2376 void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4res* res)
2377 {
2378 if (res) { out << "status: " << res->status; }
2469 if(args) {
2470 out << "object attributes: " << args->obj_attributes;
2471 }
2472 }
2473
2474 void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4res* res)
2475 {
2476 if(res) {
2477 out << "status: " << res->status;
2478 }
23792479 }
23802480
23812481 void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4args* args)
23822482 {
2383 if (args)
2483 if(args)
23842484 {
23852485 out << args->stateid
2386 << " offset: " << args->offset
2387 << " stable: " << args->stable
2486 << " offset: " << args->offset
2487 << " stable: " << args->stable
23882488 << " data length: " << args->data.data_len;
23892489 }
23902490 }
23912491
2392 void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4res* res)
2393 {
2394 if (res)
2395 {
2396 out << "status: " << res->status;
2397 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2398 {
2399 out << " count: " << res->WRITE4res_u.resok4.count
2400 << " committed: " << res->WRITE4res_u.resok4.committed
2492 void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4res* res)
2493 {
2494 if(res)
2495 {
2496 out << "status: " << res->status;
2497 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2498 {
2499 out << " count: " << res->WRITE4res_u.resok4.count
2500 << " committed: " << res->WRITE4res_u.resok4.committed
24012501 << " write verifier: ";
24022502 print_hex(out,
24032503 res->WRITE4res_u.resok4.writeverf,
24082508
24092509 void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4args* args)
24102510 {
2411 if (args) { out << "lock owner: " << args->lock_owner; }
2412 }
2413
2414 void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4res* res)
2415 {
2416 if (res) { out << "status: " << res->status; }
2511 if(args) {
2512 out << "lock owner: " << args->lock_owner;
2513 }
2514 }
2515
2516 void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4res* res)
2517 {
2518 if(res) {
2519 out << "status: " << res->status;
2520 }
24172521 }
24182522
24192523 void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4args* args)
24202524 {
2421 if (args)
2422 out << "client id: " << args->clientid
2423 << " notification types: " << args->notif_types
2424 << " dir notification delay: " << args->dir_notif_delay
2525 if(args)
2526 out << "client id: " << args->clientid
2527 << " notification types: " << args->notif_types
2528 << " dir notification delay: " << args->dir_notif_delay
24252529 << " dir entry notification delay: " << args->dir_entry_notif_delay;
24262530 }
24272531
2428 void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4res* res)
2429 {
2430 if (res)
2431 {
2432 out << "status: " << res->status;
2433 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2532 void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4res* res)
2533 {
2534 if(res)
2535 {
2536 out << "status: " << res->status;
2537 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
24342538 out << ' ' << res->GET_DIR_DELEGATION4res_u.resok4.stateid
24352539 << " status: "
24362540 << res->GET_DIR_DELEGATION4res_u.resok4.status
24452549
24462550 void PrintAnalyzer::nfs4_operation(const struct NFS4::GETFH4res* res)
24472551 {
2448 if (res)
2449 {
2450 out << "status: " << res->status;
2451 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2552 if(res)
2553 {
2554 out << "status: " << res->status;
2555 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
24522556 {
24532557 out << " object: " << res->GETFH4res_u.resok4.object;
24542558 }
24572561
24582562 void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUPP4res* res)
24592563 {
2460 if (res) { out << "status: " << res->status; }
2564 if(res) {
2565 out << "status: " << res->status;
2566 }
24612567 }
24622568
24632569 void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTPUBFH4res* res)
24642570 {
2465 if (res) { out << "status: " << res->status; }
2571 if(res) {
2572 out << "status: " << res->status;
2573 }
24662574 }
24672575
24682576 void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTROOTFH4res* res)
24692577 {
2470 if (res) { out << "status: " << res->status; }
2578 if(res) {
2579 out << "status: " << res->status;
2580 }
24712581 }
24722582
24732583 void PrintAnalyzer::nfs4_operation(const struct NFS4::READLINK4res* res)
24742584 {
2475 if (res)
2476 {
2477 out << "status: " << res->status;
2478 if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
2585 if(res)
2586 {
2587 out << "status: " << res->status;
2588 if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK)
24792589 {
24802590 out << " link: " << res->READLINK4res_u.resok4.link;
24812591 }
24842594
24852595 void PrintAnalyzer::nfs4_operation(const struct NFS4::RESTOREFH4res* res)
24862596 {
2487 if (res) { out << "status: " << res->status; }
2597 if(res) {
2598 out << "status: " << res->status;
2599 }
24882600 }
24892601
24902602 void PrintAnalyzer::nfs4_operation(const struct NFS4::SAVEFH4res* res)
24912603 {
2492 if (res) { out << "status: " << res->status; }
2604 if(res) {
2605 out << "status: " << res->status;
2606 }
24932607 }
24942608
24952609 void PrintAnalyzer::nfs4_operation(const struct NFS4::ILLEGAL4res* res)
24962610 {
2497 if (res) { out << "status: " << res->status; }
2611 if(res) {
2612 out << "status: " << res->status;
2613 }
24982614 }
24992615
25002616 // Print NFSv4.1 procedures
25042620 // 4th line - <tabulation>related RPC procedure-specific results
25052621 // 5rd line - <tabulation>related NFSv4-operations
25062622
2507
25082623 void PrintAnalyzer::compound41(const RPCProcedure* proc,
25092624 const struct NFS41::COMPOUND4args* args,
25102625 const struct NFS41::COMPOUND4res* res)
25112626 {
2512 if (!print_procedure(out, proc)) { return; }
2513
2514 const u_int* array_len {};
2515 if (args)
2627 if(!print_procedure(out, proc)) {
2628 return;
2629 }
2630
2631 const u_int* array_len{};
2632 if(args)
25162633 {
25172634 array_len = &args->argarray.argarray_len;
25182635 out << "\tCALL [ operations: " << *array_len
2519 << " tag: " << args->tag
2520 << " minor version: " << args->minorversion;
2521
2522 if (*array_len)
2523 {
2524 NFS41::nfs_argop4* current_el {args->argarray.argarray_val};
2525 for (u_int i {0}; i < *array_len; i++, current_el++)
2636 << " tag: " << args->tag
2637 << " minor version: " << args->minorversion;
2638
2639 if(*array_len)
2640 {
2641 NFS41::nfs_argop4* current_el{args->argarray.argarray_val};
2642 for(u_int i{0}; i < *array_len; i++, current_el++)
25262643 {
25272644 out << "\n\t\t[ ";
25282645 nfs41_operation(current_el);
25312648 out << " ]\n";
25322649 }
25332650 }
2534 if (res)
2651 if(res)
25352652 {
25362653 array_len = &res->resarray.resarray_len;
25372654 out << "\tREPLY [ operations: " << *array_len
2538 << " status: " << res->status
2539 << " tag: " << res->tag;
2540 if (*array_len)
2541 {
2542 NFS41::nfs_resop4* current_el {res->resarray.resarray_val};
2543 for (u_int i {0}; i < *array_len; i++, current_el++)
2655 << " status: " << res->status
2656 << " tag: " << res->tag;
2657 if(*array_len)
2658 {
2659 NFS41::nfs_resop4* current_el{res->resarray.resarray_val};
2660 for(u_int i{0}; i < *array_len; i++, current_el++)
25442661 {
25452662 out << "\n\t\t[ ";
25462663 nfs41_operation(current_el);
25532670
25542671 void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_argop4* op)
25552672 {
2556 if (op)
2673 if(op)
25572674 {
25582675 out << print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(op->argop))
25592676 << '(' << op->argop << ") [ ";
2560 switch (op->argop)
2677 switch(op->argop)
25612678 {
25622679 case NFS41::OP_ACCESS:
25632680 return nfs41_operation(&op->nfs_argop4_u.opaccess);
26822799
26832800 void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_resop4* op)
26842801 {
2685 if (op)
2802 if(op)
26862803 {
26872804 out << print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(op->resop))
26882805 << '(' << op->resop << ") [ ";
2689 switch (op->resop)
2806 switch(op->resop)
26902807 {
26912808 case NFS41::OP_ACCESS:
26922809 return nfs41_operation(&op->nfs_resop4_u.opaccess);
28112928
28122929 void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4args* args)
28132930 {
2814 if (args)
2815 {
2816 if ((args->access) & NFS41::ACCESS4_READ) { out << "READ "; }
2817 if ((args->access) & NFS41::ACCESS4_LOOKUP) { out << "LOOKUP "; }
2818 if ((args->access) & NFS41::ACCESS4_MODIFY) { out << "MODIFY "; }
2819 if ((args->access) & NFS41::ACCESS4_EXTEND) { out << "EXTEND "; }
2820 if ((args->access) & NFS41::ACCESS4_DELETE) { out << "DELETE "; }
2821 if ((args->access) & NFS41::ACCESS4_EXECUTE) { out << "EXECUTE "; }
2822 }
2823 }
2824
2825 void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4res* res)
2826 {
2827 if (res)
2828 {
2829 out << "status: " << res->status;
2830 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
2931 if(args)
2932 {
2933 if((args->access) & NFS41::ACCESS4_READ) {
2934 out << "READ ";
2935 }
2936 if((args->access) & NFS41::ACCESS4_LOOKUP) {
2937 out << "LOOKUP ";
2938 }
2939 if((args->access) & NFS41::ACCESS4_MODIFY) {
2940 out << "MODIFY ";
2941 }
2942 if((args->access) & NFS41::ACCESS4_EXTEND) {
2943 out << "EXTEND ";
2944 }
2945 if((args->access) & NFS41::ACCESS4_DELETE) {
2946 out << "DELETE ";
2947 }
2948 if((args->access) & NFS41::ACCESS4_EXECUTE) {
2949 out << "EXECUTE ";
2950 }
2951 }
2952 }
2953
2954 void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4res* res)
2955 {
2956 if(res)
2957 {
2958 out << "status: " << res->status;
2959 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
28312960 {
28322961 out << " supported: ";
2833 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_READ)
2962 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_READ)
28342963 {
28352964 out << "READ ";
28362965 }
2837 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_LOOKUP)
2966 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_LOOKUP)
28382967 {
28392968 out << "LOOKUP ";
28402969 }
2841 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_MODIFY)
2970 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_MODIFY)
28422971 {
28432972 out << "MODIFY ";
28442973 }
2845 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXTEND)
2974 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXTEND)
28462975 {
28472976 out << "EXTEND ";
28482977 }
2849 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_DELETE)
2978 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_DELETE)
28502979 {
28512980 out << "DELETE ";
28522981 }
2853 if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXECUTE)
2982 if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXECUTE)
28542983 {
28552984 out << "EXECUTE ";
28562985 }
28572986 out << " access: ";
2858 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_READ)
2987 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_READ)
28592988 {
28602989 out << "READ ";
28612990 }
2862 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_LOOKUP)
2991 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_LOOKUP)
28632992 {
28642993 out << "LOOKUP ";
28652994 }
2866 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_MODIFY)
2995 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_MODIFY)
28672996 {
28682997 out << "MODIFY ";
28692998 }
2870 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXTEND)
2999 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXTEND)
28713000 {
28723001 out << "EXTEND ";
28733002 }
2874 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_DELETE)
3003 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_DELETE)
28753004 {
28763005 out << "DELETE ";
28773006 }
2878 if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXECUTE)
3007 if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXECUTE)
28793008 {
28803009 out << "EXECUTE ";
28813010 }
28853014
28863015 void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4args* args)
28873016 {
2888 if (args)
2889 {
2890 out << "seqid: " << std::hex << args->seqid << std::dec
3017 if(args)
3018 {
3019 out << "seqid: " << std::hex << args->seqid << std::dec
28913020 << " open state id:" << args->open_stateid;
28923021 }
28933022 }
28943023
2895 void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4res* res)
2896 {
2897 if (res)
2898 {
2899 out << "status: " << res->status;
2900 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3024 void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4res* res)
3025 {
3026 if(res)
3027 {
3028 out << "status: " << res->status;
3029 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
29013030 {
29023031 out << " open state id:" << res->CLOSE4res_u.open_stateid;
29033032 }
29063035
29073036 void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4args* args)
29083037 {
2909 if (args)
2910 {
2911 out << "offset: " << args->offset
2912 << " count: " << args->count;
2913 }
2914 }
2915
2916 void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4res* res)
2917 {
2918 if (res)
2919 {
2920 out << "status: " << res->status;
2921 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3038 if(args)
3039 {
3040 out << "offset: " << args->offset
3041 << " count: " << args->count;
3042 }
3043 }
3044
3045 void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4res* res)
3046 {
3047 if(res)
3048 {
3049 out << "status: " << res->status;
3050 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
29223051 {
29233052 out << " write verifier: ";
29243053 print_hex(out,
29303059
29313060 void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4args* args)
29323061 {
2933 if (args)
2934 {
2935 out << "object type: " << args->objtype
2936 << " object name: " << args->objname
3062 if(args)
3063 {
3064 out << "object type: " << args->objtype
3065 << " object name: " << args->objname
29373066 << " create attributes: " << args->createattrs;
29383067 }
29393068 }
29403069
2941 void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4res* res)
2942 {
2943 if (res)
2944 {
2945 out << "status: " << res->status;
2946 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3070 void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4res* res)
3071 {
3072 if(res)
3073 {
3074 out << "status: " << res->status;
3075 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
29473076 out << res->CREATE4res_u.resok4.cinfo << ' '
29483077 << res->CREATE4res_u.resok4.attrset;
29493078 }
29513080
29523081 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4args* args)
29533082 {
2954 if (args) { out << "client id: " << std::hex << args->clientid << std::dec; }
2955 }
2956
2957 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4res* res)
2958 {
2959 if (res) { out << "status: " << res->status; }
3083 if(args) {
3084 out << "client id: " << std::hex << args->clientid << std::dec;
3085 }
3086 }
3087
3088 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4res* res)
3089 {
3090 if(res) {
3091 out << "status: " << res->status;
3092 }
29603093 }
29613094
29623095 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4args* args)
29633096 {
2964 if (args) { out << args->deleg_stateid; }
2965 }
2966
2967 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4res* res)
2968 {
2969 if (res) { out << "status: " << res->status; }
3097 if(args) {
3098 out << args->deleg_stateid;
3099 }
3100 }
3101
3102 void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4res* res)
3103 {
3104 if(res) {
3105 out << "status: " << res->status;
3106 }
29703107 }
29713108
29723109 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4args* args)
29733110 {
2974 if (args) { out << args->attr_request; }
2975 }
2976
2977 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4res* res)
2978 {
2979 if (res)
2980 {
2981 out << "status: " << res->status;
2982 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3111 if(args) {
3112 out << args->attr_request;
3113 }
3114 }
3115
3116 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4res* res)
3117 {
3118 if(res)
3119 {
3120 out << "status: " << res->status;
3121 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
29833122 {
29843123 out << ' ' << res->GETATTR4res_u.resok4.obj_attributes;
29853124 }
29883127
29893128 void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4args* args)
29903129 {
2991 if (args) { out << "new name: " << args->newname; }
2992 }
2993
2994 void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4res* res)
2995 {
2996 if (res)
2997 {
2998 out << "status: " << res->status;
2999 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3130 if(args) {
3131 out << "new name: " << args->newname;
3132 }
3133 }
3134
3135 void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4res* res)
3136 {
3137 if(res)
3138 {
3139 out << "status: " << res->status;
3140 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
30003141 {
30013142 out << ' ' << res->LINK4res_u.resok4.cinfo;
30023143 }
30053146
30063147 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4args* args)
30073148 {
3008 if (args)
3009 {
3010 out << "lock type: " << args->locktype
3011 << " reclaim: " << args->reclaim
3012 << " offset: " << args->offset
3013 << " length: " << args->length
3014 << " locker: " << args->locker;
3015 }
3016 }
3017
3018 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4res* res)
3019 {
3020 if (res)
3021 {
3022 out << "status: " << res->status;
3023 if (out_all())
3024 {
3025 switch (res->status)
3149 if(args)
3150 {
3151 out << "lock type: " << args->locktype
3152 << " reclaim: " << args->reclaim
3153 << " offset: " << args->offset
3154 << " length: " << args->length
3155 << " locker: " << args->locker;
3156 }
3157 }
3158
3159 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4res* res)
3160 {
3161 if(res)
3162 {
3163 out << "status: " << res->status;
3164 if(out_all())
3165 {
3166 switch(res->status)
30263167 {
30273168 case NFS41::nfsstat4::NFS4_OK:
30283169 out << " lock stat id: "
30293170 << res->LOCK4res_u.resok4.lock_stateid;
30303171 break;
30313172 case NFS41::nfsstat4::NFS4ERR_DENIED:
3032 out << " offset: " << res->LOCK4res_u.denied.offset
3033 << " length: " << res->LOCK4res_u.denied.length
3173 out << " offset: " << res->LOCK4res_u.denied.offset
3174 << " length: " << res->LOCK4res_u.denied.length
30343175 << " lock type: " << res->LOCK4res_u.denied.locktype
3035 << " owner: " << res->LOCK4res_u.denied.owner;
3176 << " owner: " << res->LOCK4res_u.denied.owner;
30363177 break;
30373178 default:
30383179 break;
30433184
30443185 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4args* args)
30453186 {
3046 if (args)
3047 {
3048 out << "lock type: " << args->locktype
3049 << " offset: " << args->offset
3050 << " length: " << args->length
3051 << " owner: " << args->owner;
3052 }
3053 }
3054
3055 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4res* res)
3056 {
3057 if (res)
3058 {
3059 out << "status: " << res->status;
3060 if (out_all() && res->status == NFS41::nfsstat4::NFS4ERR_DENIED)
3061 out << " offset: " << res->LOCKT4res_u.denied.offset
3062 << " length: " << res->LOCKT4res_u.denied.length
3187 if(args)
3188 {
3189 out << "lock type: " << args->locktype
3190 << " offset: " << args->offset
3191 << " length: " << args->length
3192 << " owner: " << args->owner;
3193 }
3194 }
3195
3196 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4res* res)
3197 {
3198 if(res)
3199 {
3200 out << "status: " << res->status;
3201 if(out_all() && res->status == NFS41::nfsstat4::NFS4ERR_DENIED)
3202 out << " offset: " << res->LOCKT4res_u.denied.offset
3203 << " length: " << res->LOCKT4res_u.denied.length
30633204 << " lock type: " << res->LOCKT4res_u.denied.locktype
3064 << " owner: " << res->LOCKT4res_u.denied.owner;
3205 << " owner: " << res->LOCKT4res_u.denied.owner;
30653206 }
30663207 }
30673208
30683209 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4args* args)
30693210 {
3070 if (args)
3071 {
3072 out << "lock type: " << args->locktype
3073 << " seqid: " << std::hex << args->seqid << std::dec
3211 if(args)
3212 {
3213 out << "lock type: " << args->locktype
3214 << " seqid: " << std::hex << args->seqid << std::dec
30743215 << " lock state id: " << args->lock_stateid
3075 << " offset: " << args->offset
3076 << " length: " << args->length;
3077 }
3078 }
3079
3080 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4res* res)
3081 {
3082 if (res)
3083 {
3084 out << "status: " << res->status;
3085 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3216 << " offset: " << args->offset
3217 << " length: " << args->length;
3218 }
3219 }
3220
3221 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4res* res)
3222 {
3223 if(res)
3224 {
3225 out << "status: " << res->status;
3226 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
30863227 {
30873228 out << " lock state id: " << res->LOCKU4res_u.lock_stateid;
30883229 }
30913232
30923233 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4args* args)
30933234 {
3094 if (args) { out << "object name: " << args->objname; }
3095 }
3096
3097 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4res* res)
3098 {
3099 if (res) { out << "status: " << res->status; }
3235 if(args) {
3236 out << "object name: " << args->objname;
3237 }
3238 }
3239
3240 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4res* res)
3241 {
3242 if(res) {
3243 out << "status: " << res->status;
3244 }
31003245 }
31013246
31023247 void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4args* args)
31033248 {
3104 if (args) { out << "object attributes: " << args->obj_attributes; }
3105 }
3106
3107 void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4res* res)
3108 {
3109 if (res) { out << "status: " << res->status; }
3249 if(args) {
3250 out << "object attributes: " << args->obj_attributes;
3251 }
3252 }
3253
3254 void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4res* res)
3255 {
3256 if(res) {
3257 out << "status: " << res->status;
3258 }
31103259 }
31113260
31123261 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4args* args)
31133262 {
3114 static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"};
3263 static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"};
31153264 static const char* const open4_share_deny[4] = {"NONE", "READ", "WRITE", "BOTH"};
31163265
3117 if (args)
3118 {
3119 out << "seqid: " << std::hex << args->seqid << std::dec
3266 if(args)
3267 {
3268 out << "seqid: " << std::hex << args->seqid << std::dec
31203269 << " share access: " << open4_share_access[args->share_access]
3121 << " share deny: " << open4_share_deny[args->share_deny]
3270 << " share deny: " << open4_share_deny[args->share_deny]
31223271 << ' ' << args->owner
31233272 << ' ' << args->openhow
31243273 << ' ' << args->claim;
31253274 }
31263275 }
31273276
3128 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4res* res)
3129 {
3130 if (res)
3131 {
3132 out << "status: " << res->status;
3133 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3277 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4res* res)
3278 {
3279 if(res)
3280 {
3281 out << "status: " << res->status;
3282 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
31343283 out << res->OPEN4res_u.resok4.stateid
31353284 << res->OPEN4res_u.resok4.cinfo
31363285 << " results flags: "
31423291
31433292 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4args* args)
31443293 {
3145 if (args) { out << "create directory: " << args->createdir; }
3146 }
3147
3148 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4res* res)
3149 {
3150 if (res) { out << "status: " << res->status; }
3294 if(args) {
3295 out << "create directory: " << args->createdir;
3296 }
3297 }
3298
3299 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4res* res)
3300 {
3301 if(res) {
3302 out << "status: " << res->status;
3303 }
31513304 }
31523305
31533306 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4args* args)
31543307 {
3155 if (args)
3156 {
3157 out << "open state id:" << args->open_stateid
3158 << " seqid: " << std::hex << args->seqid << std::dec;
3159 }
3160 }
3161
3162 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4res* res)
3163 {
3164 if (res)
3165 {
3166 out << "status: " << res->status;
3167 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3308 if(args)
3309 {
3310 out << "open state id:" << args->open_stateid
3311 << " seqid: " << std::hex << args->seqid << std::dec;
3312 }
3313 }
3314
3315 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4res* res)
3316 {
3317 if(res)
3318 {
3319 out << "status: " << res->status;
3320 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
31683321 {
31693322 out << " open state id:" << res->OPEN_CONFIRM4res_u.resok4.open_stateid;
31703323 }
31733326
31743327 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4args* args)
31753328 {
3176 if (args)
3329 if(args)
31773330 {
31783331 out << " open state id: " << args->open_stateid
3179 << " seqid: " << std::hex << args->seqid << std::dec
3180 << " share access: " << args->share_access
3181 << " share deny: " << args->share_deny;
3182 }
3183 }
3184
3185 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4res* res)
3186 {
3187 if (res)
3188 {
3189 out << "status: " << res->status;
3190 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3332 << " seqid: " << std::hex << args->seqid << std::dec
3333 << " share access: " << args->share_access
3334 << " share deny: " << args->share_deny;
3335 }
3336 }
3337
3338 void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4res* res)
3339 {
3340 if(res)
3341 {
3342 out << "status: " << res->status;
3343 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
31913344 {
31923345 out << ' ' << res->OPEN_DOWNGRADE4res_u.resok4.open_stateid;
31933346 }
31963349
31973350 void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4args* args)
31983351 {
3199 if (args)
3352 if(args)
32003353 {
32013354 out << "object: ";
32023355 print_nfs_fh(out, args->object.nfs_fh4_val, args->object.nfs_fh4_len);
32033356 }
32043357 }
32053358
3206 void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4res* res)
3207 {
3208 if (res) { out << "status: " << res->status; }
3359 void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4res* res)
3360 {
3361 if(res) {
3362 out << "status: " << res->status;
3363 }
32093364 }
32103365
32113366 void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4args* args)
32123367 {
3213 if (args)
3368 if(args)
32143369 {
32153370 out << args->stateid
3216 << " offset: " << args->offset
3217 << " count: " << args->count;
3218 }
3219 }
3220
3221 void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4res* res)
3222 {
3223 if (res)
3224 {
3225 out << "status: " << res->status;
3226 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3371 << " offset: " << args->offset
3372 << " count: " << args->count;
3373 }
3374 }
3375
3376 void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4res* res)
3377 {
3378 if(res)
3379 {
3380 out << "status: " << res->status;
3381 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
32273382 {
32283383 out << " eof: " << res->READ4res_u.resok4.eof;
3229 if (res->READ4res_u.resok4.data.data_len)
3384 if(res->READ4res_u.resok4.data.data_len)
32303385 {
32313386 out << " data: " << *res->READ4res_u.resok4.data.data_val;
32323387 }
32363391
32373392 void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4args* args)
32383393 {
3239 if (args)
3240 {
3241 out << "cookie: " << args->cookie
3242 << " cookieverf: " << args->cookieverf
3243 << " dir count: " << args->dircount
3244 << " max count: " << args->maxcount
3394 if(args)
3395 {
3396 out << "cookie: " << args->cookie
3397 << " cookieverf: " << args->cookieverf
3398 << " dir count: " << args->dircount
3399 << " max count: " << args->maxcount
32453400 << " attributes request: " << args->attr_request;
32463401 }
32473402 }
32483403
3249 void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4res* res)
3250 {
3251 if (res)
3252 {
3253 out << "status: " << res->status;
3254 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3404 void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4res* res)
3405 {
3406 if(res)
3407 {
3408 out << "status: " << res->status;
3409 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
32553410 out << " cookie verifier: " << res->READDIR4res_u.resok4.cookieverf
3256 << " reply: " << res->READDIR4res_u.resok4.reply;
3411 << " reply: " << res->READDIR4res_u.resok4.reply;
32573412 }
32583413 }
32593414
32603415 void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4args* args)
32613416 {
3262 if (args) { out << "target: " << args->target; }
3263 }
3264
3265 void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4res* res)
3266 {
3267 if (res)
3268 {
3269 out << "status: " << res->status;
3270 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3417 if(args) {
3418 out << "target: " << args->target;
3419 }
3420 }
3421
3422 void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4res* res)
3423 {
3424 if(res)
3425 {
3426 out << "status: " << res->status;
3427 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
32713428 {
32723429 out << ' ' << res->REMOVE4res_u.resok4.cinfo;
32733430 }
32763433
32773434 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4args* args)
32783435 {
3279 if (args)
3280 {
3281 out << "old name: " << args->oldname
3436 if(args)
3437 {
3438 out << "old name: " << args->oldname
32823439 << " new name: " << args->newname;
32833440 }
32843441 }
32853442
3286 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4res* res)
3287 {
3288 if (res)
3289 {
3290 out << "status: " << res->status;
3291 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3443 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4res* res)
3444 {
3445 if(res)
3446 {
3447 out << "status: " << res->status;
3448 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
32923449 out << " source: "
32933450 << res->RENAME4res_u.resok4.source_cinfo
32943451 << " target: "
32983455
32993456 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4args* args)
33003457 {
3301 if (args)
3458 if(args)
33023459 {
33033460 out << "client id: "
33043461 << std::hex << args->clientid << std::dec;
33053462 }
33063463 }
33073464
3308 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4res* res)
3309 {
3310 if (res) { out << "status: " << res->status; }
3465 void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4res* res)
3466 {
3467 if(res) {
3468 out << "status: " << res->status;
3469 }
33113470 }
33123471
33133472 void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4args* args)
33143473 {
3315 if (args) { out << "name: " << args->name; }
3316 }
3317
3318 void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4res* res)
3319 {
3320 if (res)
3321 {
3322 out << "status: " << res->status;
3323 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3324 {
3325 if (res->SECINFO4res_u.resok4.SECINFO4resok_len)
3474 if(args) {
3475 out << "name: " << args->name;
3476 }
3477 }
3478
3479 void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4res* res)
3480 {
3481 if(res)
3482 {
3483 out << "status: " << res->status;
3484 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3485 {
3486 if(res->SECINFO4res_u.resok4.SECINFO4resok_len)
33263487 {
33273488 out << *res->SECINFO4res_u.resok4.SECINFO4resok_val;
33283489 }
33323493
33333494 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4args* args)
33343495 {
3335 if (args)
3496 if(args)
33363497 {
33373498 out << "state id:" << args->stateid
33383499 << ' ' << args->obj_attributes;
33393500 }
33403501 }
33413502
3342 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4res* res)
3343 {
3344 if (res)
3345 {
3346 out << "status: " << res->status;
3347 if (out_all()) { out << ' ' << res->attrsset; }
3503 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4res* res)
3504 {
3505 if(res)
3506 {
3507 out << "status: " << res->status;
3508 if(out_all()) {
3509 out << ' ' << res->attrsset;
3510 }
33483511 }
33493512 }
33503513
33513514 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4args* args)
33523515 {
3353 if (args)
3516 if(args)
33543517 {
33553518 out << args->client
33563519 << " callback: "
33603523 }
33613524 }
33623525
3363 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4res* res)
3364 {
3365 if (res)
3366 {
3367 out << "status: " << res->status;
3368 if (out_all())
3369 {
3370 switch (res->status)
3526 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4res* res)
3527 {
3528 if(res)
3529 {
3530 out << "status: " << res->status;
3531 if(out_all())
3532 {
3533 switch(res->status)
33713534 {
33723535 case NFS41::nfsstat4::NFS4_OK:
33733536 out << " client id: "
33893552
33903553 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4args* args)
33913554 {
3392 if (args)
3555 if(args)
33933556 {
33943557 out << " client id: " << std::hex << args->clientid << std::dec
33953558 << " verifier: ";
33973560 }
33983561 }
33993562
3400 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4res* res)
3401 {
3402 if (res) { out << "status: " << res->status; }
3563 void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4res* res)
3564 {
3565 if(res) {
3566 out << "status: " << res->status;
3567 }
34033568 }
34043569
34053570 void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4args* args)
34063571 {
3407 if (args) { out << "object attributes: " << args->obj_attributes; }
3408 }
3409
3410 void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4res* res)
3411 {
3412 if (res) { out << "status: " << res->status; }
3572 if(args) {
3573 out << "object attributes: " << args->obj_attributes;
3574 }
3575 }
3576
3577 void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4res* res)
3578 {
3579 if(res) {
3580 out << "status: " << res->status;
3581 }
34133582 }
34143583
34153584 void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4args* args)
34163585 {
3417 if (args)
3586 if(args)
34183587 {
34193588 out << args->stateid
3420 << " offset: " << args->offset
3421 << " stable: " << args->stable
3589 << " offset: " << args->offset
3590 << " stable: " << args->stable
34223591 << " data length: " << args->data.data_len;
34233592 }
34243593 }
34253594
3426 void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4res* res)
3427 {
3428 if (res)
3429 {
3430 out << "status: " << res->status;
3431 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3432 {
3433 out << " count: " << res->WRITE4res_u.resok4.count
3434 << " committed: " << res->WRITE4res_u.resok4.committed
3595 void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4res* res)
3596 {
3597 if(res)
3598 {
3599 out << "status: " << res->status;
3600 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3601 {
3602 out << " count: " << res->WRITE4res_u.resok4.count
3603 << " committed: " << res->WRITE4res_u.resok4.committed
34353604 << " write verifier: ";
34363605 print_hex(out,
34373606 res->WRITE4res_u.resok4.writeverf,
34423611
34433612 void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4args* args)
34443613 {
3445 if (args) { out << "lock owner: " << args->lock_owner; }
3446 }
3447
3448 void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4res* res)
3449 {
3450 if (res) { out << "status: " << res->status; }
3614 if(args) {
3615 out << "lock owner: " << args->lock_owner;
3616 }
3617 }
3618
3619 void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4res* res)
3620 {
3621 if(res) {
3622 out << "status: " << res->status;
3623 }
34513624 }
34523625
34533626 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETFH4res* res)
34543627 {
3455 if (res)
3456 {
3457 out << "status: " << res->status;
3458 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3628 if(res)
3629 {
3630 out << "status: " << res->status;
3631 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
34593632 {
34603633 out << " object: " << res->GETFH4res_u.resok4.object;
34613634 }
34643637
34653638 void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUPP4res* res)
34663639 {
3467 if (res) { out << "status: " << res->status; }
3640 if(res) {
3641 out << "status: " << res->status;
3642 }
34683643 }
34693644
34703645 void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTPUBFH4res* res)
34713646 {
3472 if (res) { out << "status: " << res->status; }
3647 if(res) {
3648 out << "status: " << res->status;
3649 }
34733650 }
34743651
34753652 void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTROOTFH4res* res)
34763653 {
3477 if (res) { out << "status: " << res->status; }
3654 if(res) {
3655 out << "status: " << res->status;
3656 }
34783657 }
34793658
34803659 void PrintAnalyzer::nfs41_operation(const struct NFS41::READLINK4res* res)
34813660 {
3482 if (res)
3483 {
3484 out << "status: " << res->status;
3485 if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
3661 if(res)
3662 {
3663 out << "status: " << res->status;
3664 if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK)
34863665 {
34873666 out << " link: " << res->READLINK4res_u.resok4.link;
34883667 }
34913670
34923671 void PrintAnalyzer::nfs41_operation(const struct NFS41::RESTOREFH4res* res)
34933672 {
3494 if (res) { out << "status: " << res->status; }
3673 if(res) {
3674 out << "status: " << res->status;
3675 }
34953676 }
34963677
34973678 void PrintAnalyzer::nfs41_operation(const struct NFS41::SAVEFH4res* res)
34983679 {
3499 if (res) { out << "status: " << res->status; }
3680 if(res) {
3681 out << "status: " << res->status;
3682 }
35003683 }
35013684
35023685 void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4args* args)
35033686 {
3504 if (args)
3505 out << "signal delegation available: " << args->gdda_signal_deleg_avail
3506 << " notification types: " << args->gdda_notification_types
3507 << " child attr delay: " << args->gdda_child_attr_delay
3508 << " dir attr delay: " << args->gdda_dir_attr_delay
3509 << " child child attributes: " << args->gdda_child_attributes
3510 << " child dir attributes: " << args->gdda_dir_attributes;
3511 }
3512
3513 void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4res* res)
3514 {
3515 if (res)
3687 if(args)
3688 out << "signal delegation available: " << args->gdda_signal_deleg_avail
3689 << " notification types: " << args->gdda_notification_types
3690 << " child attr delay: " << args->gdda_child_attr_delay
3691 << " dir attr delay: " << args->gdda_dir_attr_delay
3692 << " child child attributes: " << args->gdda_child_attributes
3693 << " child dir attributes: " << args->gdda_dir_attributes;
3694 }
3695
3696 void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4res* res)
3697 {
3698 if(res)
35163699 {
35173700 out << "status: " << res->gddr_status;
3518 if (out_all() && res->gddr_status == NFS41::nfsstat4::NFS4_OK)
3701 if(out_all() && res->gddr_status == NFS41::nfsstat4::NFS4_OK)
35193702 {
35203703 out << " status: " << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status;
3521 if (out_all() && res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status == NFS41::gddrnf4_status::GDD4_OK)
3522 {
3523 out << " cookieverf: ";
3704 if(out_all() && res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status == NFS41::gddrnf4_status::GDD4_OK)
3705 {
3706 out << " cookieverf: ";
35243707 print_hex(out,
35253708 res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_cookieverf,
35263709 NFS41::NFS4_VERIFIER_SIZE);
35273710 out << " stateid: "
3528 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_stateid
3711 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_stateid
35293712 << " notification: "
3530 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_notification
3713 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_notification
35313714 << " child attributes: "
3532 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_child_attributes
3715 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_child_attributes
35333716 << " dir attributes: "
3534 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_dir_attributes;
3717 << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_dir_attributes;
35353718 }
35363719 else
35373720 {
35443727
35453728 void PrintAnalyzer::nfs41_operation(const struct NFS41::BACKCHANNEL_CTL4args* args)
35463729 {
3547 if (args)
3548 {
3549 out << "program: " << args->bca_cb_program
3730 if(args)
3731 {
3732 out << "program: " << args->bca_cb_program
35503733 << " sec parms: ";
3551 NFS41::callback_sec_parms4* current_el {args->bca_sec_parms.bca_sec_parms_val};
3552 for (u_int i {0}; i < args->bca_sec_parms.bca_sec_parms_len; i++, current_el++)
3734 NFS41::callback_sec_parms4* current_el{args->bca_sec_parms.bca_sec_parms_val};
3735 for(u_int i{0}; i < args->bca_sec_parms.bca_sec_parms_len; i++, current_el++)
35533736 {
35543737 out << ' ' << current_el;
35553738 }
35583741
35593742 void PrintAnalyzer::nfs41_operation(const struct NFS41::BACKCHANNEL_CTL4res* res)
35603743 {
3561 if (res) { out << "status: " << res->bcr_status; }
3744 if(res) {
3745 out << "status: " << res->bcr_status;
3746 }
35623747 }
35633748
35643749 void PrintAnalyzer::nfs41_operation(const struct NFS41::BIND_CONN_TO_SESSION4args* args)
35653750 {
3566 if (args)
3567 {
3568 out << "sessid: ";
3751 if(args)
3752 {
3753 out << "sessid: ";
35693754 print_hex(out,
35703755 args->bctsa_sessid,
35713756 NFS41::NFS4_SESSIONID_SIZE);
3572 out << " dir: " << args->bctsa_dir
3757 out << " dir: " << args->bctsa_dir
35733758 << " use conn in rdma mode: " << args->bctsa_use_conn_in_rdma_mode;
35743759 }
35753760 }
35763761
35773762 void PrintAnalyzer::nfs41_operation(const struct NFS41::BIND_CONN_TO_SESSION4res* res)
35783763 {
3579 if (res)
3764 if(res)
35803765 {
35813766 out << "status: " << res->bctsr_status;
3582 if (out_all() && res->bctsr_status == NFS41::nfsstat4::NFS4_OK)
3767 if(out_all() && res->bctsr_status == NFS41::nfsstat4::NFS4_OK)
35833768 {
35843769 out << " sessid: ";
35853770 print_hex(out,
35953780
35963781 void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4args* args)
35973782 {
3598 if (args)
3599 {
3600 out << "client owner: " << args->eia_clientowner
3601 << " flags: " << args->eia_flags
3783 if(args)
3784 {
3785 out << "client owner: " << args->eia_clientowner
3786 << " flags: " << args->eia_flags
36023787 << " state protect: " << args->eia_state_protect
36033788 << " client impl id: ";
3604 NFS41::nfs_impl_id4* current_el {args->eia_client_impl_id.eia_client_impl_id_val};
3605 for (u_int i {0}; i < args->eia_client_impl_id.eia_client_impl_id_len; i++, current_el++)
3789 NFS41::nfs_impl_id4* current_el{args->eia_client_impl_id.eia_client_impl_id_val};
3790 for(u_int i{0}; i < args->eia_client_impl_id.eia_client_impl_id_len; i++, current_el++)
36063791 {
36073792 out << ' ' << current_el;
36083793 }
36113796
36123797 void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4res* res)
36133798 {
3614 if (res)
3799 if(res)
36153800 {
36163801 out << "status: " << res->eir_status;
3617 if (out_all() && res->eir_status == NFS41::nfsstat4::NFS4_OK)
3618 {
3619 out << " clientid: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_clientid
3802 if(out_all() && res->eir_status == NFS41::nfsstat4::NFS4_OK)
3803 {
3804 out << " clientid: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_clientid
36203805 << " sequenceid: 0x" << std::hex << res->EXCHANGE_ID4res_u.eir_resok4.eir_sequenceid << std::dec
3621 << " flags: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_flags
3622 << " state protect: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_state_protect
3623 << " server owner: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner
3806 << " flags: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_flags
3807 << " state protect: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_state_protect
3808 << " server owner: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner
36243809 << " server scope: ";
36253810 print_hex(out,
36263811 res->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_val,
36273812 res->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_len);
36283813 out << " server impl id:";
3629 NFS41::nfs_impl_id4* current_el {res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val};
3630 for (u_int i {0}; i < res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_len; i++, current_el++)
3814 NFS41::nfs_impl_id4* current_el{res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val};
3815 for(u_int i{0}; i < res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_len; i++, current_el++)
36313816 {
36323817 out << ' ' << current_el;
36333818 }
36373822
36383823 void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE_SESSION4args* args)
36393824 {
3640 if (args)
3641 {
3642 out << "clientid: 0x" << std::hex << args->csa_clientid
3643 << "; seqid: 0x" << std::hex << args->csa_sequence << std::dec
3644 << "; flags: " << args->csa_flags
3645 << "; fore chan attrs: [ " << args->csa_fore_chan_attrs << " ] "
3646 << "; fore back attrs: [ " << args->csa_back_chan_attrs << " ] "
3647 << "; cb program: 0x" << std::hex << args->csa_cb_program << std::dec
3825 if(args)
3826 {
3827 out << "clientid: 0x" << std::hex << args->csa_clientid
3828 << "; seqid: 0x" << std::hex << args->csa_sequence << std::dec
3829 << "; flags: " << args->csa_flags
3830 << "; fore chan attrs: [ " << args->csa_fore_chan_attrs << " ] "
3831 << "; fore back attrs: [ " << args->csa_back_chan_attrs << " ] "
3832 << "; cb program: 0x" << std::hex << args->csa_cb_program << std::dec
36483833 << "; callback sec parms:";
3649 NFS41::callback_sec_parms4* current_el {args->csa_sec_parms.csa_sec_parms_val};
3650 for (u_int i {0}; i < args->csa_sec_parms.csa_sec_parms_len; i++, current_el++)
3834 NFS41::callback_sec_parms4* current_el{args->csa_sec_parms.csa_sec_parms_val};
3835 for(u_int i{0}; i < args->csa_sec_parms.csa_sec_parms_len; i++, current_el++)
36513836 {
36523837 out << ' ' << current_el;
36533838 }
36563841
36573842 void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE_SESSION4res* res)
36583843 {
3659 if (res)
3844 if(res)
36603845 {
36613846 out << "status: " << res->csr_status;
3662 if (out_all() && res->csr_status == NFS41::nfsstat4::NFS4_OK)
3847 if(out_all() && res->csr_status == NFS41::nfsstat4::NFS4_OK)
36633848 {
36643849 out << " session id: ";
36653850 print_hex(out,
36663851 res->CREATE_SESSION4res_u.csr_resok4.csr_sessionid,
36673852 NFS41::NFS4_SESSIONID_SIZE);
36683853 out << " sequenceid: 0x" << std::hex << res->CREATE_SESSION4res_u.csr_resok4.csr_sequence << std::dec
3669 << " flags: " << res->CREATE_SESSION4res_u.csr_resok4.csr_flags
3670 << " fore chan attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_fore_chan_attrs
3671 << " fore back attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_back_chan_attrs;
3854 << " flags: " << res->CREATE_SESSION4res_u.csr_resok4.csr_flags
3855 << " fore chan attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_fore_chan_attrs
3856 << " fore back attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_back_chan_attrs;
36723857 }
36733858 }
36743859 }
36753860
36763861 void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4args* args)
36773862 {
3678 if (args)
3863 if(args)
36793864 {
36803865 out << "session id: ";
36813866 print_hex(out,
36863871
36873872 void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4res* res)
36883873 {
3689 if (res)
3874 if(res)
36903875 {
36913876 out << "status: " << res->dsr_status;
36923877 }
36943879
36953880 void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4args* args)
36963881 {
3697 if (args)
3882 if(args)
36983883 {
36993884 out << "stateid: " << args->fsa_stateid;
37003885 }
37023887
37033888 void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4res* res)
37043889 {
3705 if (res)
3890 if(res)
37063891 {
37073892 out << "status: " << res->fsr_status;
37083893 }
37103895
37113896 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICEINFO4args* args)
37123897 {
3713 if (args)
3714 {
3715 out << "device id: " << args->gdia_device_id
3716 << " layout type: " << args->gdia_layout_type
3717 << " maxcount: " << args->gdia_maxcount
3898 if(args)
3899 {
3900 out << "device id: " << args->gdia_device_id
3901 << " layout type: " << args->gdia_layout_type
3902 << " maxcount: " << args->gdia_maxcount
37183903 << " notify types: " << args->gdia_notify_types;
37193904 }
37203905 }
37213906
37223907 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICEINFO4res* res)
37233908 {
3724 if (res)
3909 if(res)
37253910 {
37263911 out << "status: " << res->gdir_status;
3727 if (out_all())
3728 {
3729 if (res->gdir_status == NFS41::nfsstat4::NFS4_OK)
3730 {
3731 out << " device addr: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_device_addr
3912 if(out_all())
3913 {
3914 if(res->gdir_status == NFS41::nfsstat4::NFS4_OK)
3915 {
3916 out << " device addr: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_device_addr
37323917 << " notification: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_notification;
37333918 }
3734 if (res->gdir_status == NFS41::nfsstat4::NFS4ERR_TOOSMALL)
3919 if(res->gdir_status == NFS41::nfsstat4::NFS4ERR_TOOSMALL)
37353920 {
37363921 out << " min count: " << res->GETDEVICEINFO4res_u.gdir_mincount;
37373922 }
37413926
37423927 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICELIST4args* args)
37433928 {
3744 if (args)
3745 {
3746 out << "layout type: " << args->gdla_layout_type
3929 if(args)
3930 {
3931 out << "layout type: " << args->gdla_layout_type
37473932 << " max devices: " << args->gdla_maxdevices
3748 << " cookie: " << args->gdla_cookie
3749 << " cookieverf: " << args->gdla_cookieverf;
3933 << " cookie: " << args->gdla_cookie
3934 << " cookieverf: " << args->gdla_cookieverf;
37503935 }
37513936 }
37523937
37533938 void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICELIST4res* res)
37543939 {
3755 if (res)
3940 if(res)
37563941 {
37573942 out << "status: " << res->gdlr_status;
3758 if (out_all() && res->gdlr_status == NFS41::nfsstat4::NFS4_OK)
3759 {
3760 out << " cookie: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookie
3761 << " cookieverf: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookieverf
3943 if(out_all() && res->gdlr_status == NFS41::nfsstat4::NFS4_OK)
3944 {
3945 out << " cookie: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookie
3946 << " cookieverf: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookieverf
37623947 << " device id list: ";
3763 NFS41::deviceid4* current_el {res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_val};
3764 for (u_int i {0}; i < res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_len; i++, current_el++)
3948 NFS41::deviceid4* current_el{res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_val};
3949 for(u_int i{0}; i < res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_len; i++, current_el++)
37653950 {
37663951 out << ' ' << current_el;
37673952 }
3768 out << " eof: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_eof;
3953 out << " eof: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_eof;
37693954 }
37703955 }
37713956 }
37723957
37733958 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTCOMMIT4args* args)
37743959 {
3775 if (args)
3776 {
3777 out << "offset: " << args->loca_offset
3778 << " length: " << args->loca_length
3779 << " reclaim: " << args->loca_reclaim
3780 << " stateid: " << args->loca_stateid
3781 << " last write offset: " << args->loca_last_write_offset
3782 << " time modify: " << args->loca_time_modify
3783 << " tayout update: " << args->loca_layoutupdate;
3960 if(args)
3961 {
3962 out << "offset: " << args->loca_offset
3963 << " length: " << args->loca_length
3964 << " reclaim: " << args->loca_reclaim
3965 << " stateid: " << args->loca_stateid
3966 << " last write offset: " << args->loca_last_write_offset
3967 << " time modify: " << args->loca_time_modify
3968 << " tayout update: " << args->loca_layoutupdate;
37843969 }
37853970 }
37863971
37873972 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTCOMMIT4res* res)
37883973 {
3789 if (res)
3974 if(res)
37903975 {
37913976 out << "status: " << res->locr_status;
3792 if (out_all() && res->locr_status == NFS41::nfsstat4::NFS4_OK)
3977 if(out_all() && res->locr_status == NFS41::nfsstat4::NFS4_OK)
37933978 {
37943979 out << " new size: " << res->LAYOUTCOMMIT4res_u.locr_resok4.locr_newsize;
37953980 }
37983983
37993984 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4args* args)
38003985 {
3801 if (args)
3802 {
3803 out << "signal layout avail: " << args->loga_signal_layout_avail
3804 << " layout type: " << args->loga_layout_type
3805 << " iomode: " << args->loga_iomode
3806 << " offset: " << args->loga_offset
3807 << " length: " << args->loga_length
3808 << " minlength: " << args->loga_minlength
3809 << " stateid: " << args->loga_stateid
3810 << " maxcount: " << args->loga_maxcount;
3986 if(args)
3987 {
3988 out << "signal layout avail: " << args->loga_signal_layout_avail
3989 << " layout type: " << args->loga_layout_type
3990 << " iomode: " << args->loga_iomode
3991 << " offset: " << args->loga_offset
3992 << " length: " << args->loga_length
3993 << " minlength: " << args->loga_minlength
3994 << " stateid: " << args->loga_stateid
3995 << " maxcount: " << args->loga_maxcount;
38113996 }
38123997 }
38133998
38143999 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4res* res)
38154000 {
3816 if (res)
4001 if(res)
38174002 {
38184003 out << "status: " << res->logr_status;
3819 if (out_all())
3820 {
3821 if (res->logr_status == NFS41::nfsstat4::NFS4_OK)
4004 if(out_all())
4005 {
4006 if(res->logr_status == NFS41::nfsstat4::NFS4_OK)
38224007 {
38234008 out << " return on close: "
38244009 << res->LAYOUTGET4res_u.logr_resok4.logr_return_on_close
38264011 << res->LAYOUTGET4res_u.logr_resok4.logr_stateid
38274012 << " layout:x ";
38284013 NFS41::layout4* current_el = res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_val;
3829 for (u_int i {0}; i < res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_len; i++, current_el++)
4014 for(u_int i{0}; i < res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_len; i++, current_el++)
38304015 {
38314016 out << ' ' << current_el;
38324017 }
38334018 }
38344019 }
3835 if (res->logr_status == NFS41::nfsstat4::NFS4ERR_LAYOUTTRYLATER)
4020 if(res->logr_status == NFS41::nfsstat4::NFS4ERR_LAYOUTTRYLATER)
38364021 {
38374022 out << "will signal layout avail: "
38384023 << res->LAYOUTGET4res_u.logr_will_signal_layout_avail;
38424027
38434028 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTRETURN4args* args)
38444029 {
3845 if (args)
3846 {
3847 out << "reclaim: " << args->lora_reclaim
3848 << " layout type: " << args->lora_layout_type
3849 << " iomode: " << args->lora_iomode
4030 if(args)
4031 {
4032 out << "reclaim: " << args->lora_reclaim
4033 << " layout type: " << args->lora_layout_type
4034 << " iomode: " << args->lora_iomode
38504035 << " layout return: " << args->lora_layoutreturn;
38514036 }
38524037 }
38534038
38544039 void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTRETURN4res* res)
38554040 {
3856 if (res)
4041 if(res)
38574042 {
38584043 out << "status: " << res->lorr_status;
3859 if (out_all() && res->lorr_status == NFS41::nfsstat4::NFS4_OK)
4044 if(out_all() && res->lorr_status == NFS41::nfsstat4::NFS4_OK)
38604045 {
38614046 out << " stateid: " << res->LAYOUTRETURN4res_u.lorr_stateid;
38624047 }
38654050
38664051 void PrintAnalyzer::nfs41_operation(const struct NFS41::SEQUENCE4args* args)
38674052 {
3868 if (args)
3869 {
3870 out << "sessionid: ";
4053 if(args)
4054 {
4055 out << "sessionid: ";
38714056 print_hex(out,
38724057 args->sa_sessionid,
38734058 NFS41::NFS4_SESSIONID_SIZE);
38744059 out << " sequenceid: 0x" << std::hex << args->sa_sequenceid << std::dec
3875 << " slotid: " << args->sa_slotid
3876 << " cache this: " << args->sa_cachethis;
4060 << " slotid: " << args->sa_slotid
4061 << " cache this: " << args->sa_cachethis;
38774062 }
38784063 }
38794064
38804065 void PrintAnalyzer::nfs41_operation(const struct NFS41::SEQUENCE4res* res)
38814066 {
3882 if (res)
4067 if(res)
38834068 {
38844069 out << "status: " << res->sr_status;
3885 if (out_all() && res->sr_status == NFS41::nfsstat4::NFS4_OK)
4070 if(out_all() && res->sr_status == NFS41::nfsstat4::NFS4_OK)
38864071 {
38874072 out << " session: ";
38884073 print_hex(out,
38894074 res->SEQUENCE4res_u.sr_resok4.sr_sessionid,
38904075 NFS41::NFS4_SESSIONID_SIZE);
38914076 out << " sequenceid: 0x" << std::hex << res->SEQUENCE4res_u.sr_resok4.sr_sequenceid << std::dec
3892 << " slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_slotid
3893 << " highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_highest_slotid
3894 << " target highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_target_highest_slotid
3895 << " status flags: " << res->SEQUENCE4res_u.sr_resok4.sr_status_flags;
4077 << " slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_slotid
4078 << " highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_highest_slotid
4079 << " target highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_target_highest_slotid
4080 << " status flags: " << res->SEQUENCE4res_u.sr_resok4.sr_status_flags;
38964081 }
38974082 }
38984083 }
39004085 //SECINFO_NO_NAME4args
39014086 void PrintAnalyzer::nfs41_operation(const enum NFS41::secinfo_style4* args)
39024087 {
3903 if (args)
4088 if(args)
39044089 {
39054090 out << ' ' << *args;
39064091 }
39084093
39094094 void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4args* args)
39104095 {
3911 if (args)
4096 if(args)
39124097 {
39134098 out << "ssv: ";
39144099 out.write(args->ssa_ssv.ssa_ssv_val,
39214106
39224107 void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4res* res)
39234108 {
3924 if (res)
4109 if(res)
39254110 {
39264111 out << "status: " << res->ssr_status;
3927 if (out_all() && res->ssr_status == NFS41::nfsstat4::NFS4_OK)
4112 if(out_all() && res->ssr_status == NFS41::nfsstat4::NFS4_OK)
39284113 {
39294114 out << " digest: ";
39304115 out.write(res->SET_SSV4res_u.ssr_resok4.ssr_digest.ssr_digest_val,
39354120
39364121 void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4args* args)
39374122 {
3938 if (args)
4123 if(args)
39394124 {
39404125 out << "stateids:";
39414126 NFS41::stateid4* current_el = args->ts_stateids.ts_stateids_val;
3942 for (u_int i {0}; i < args->ts_stateids.ts_stateids_len; i++, current_el++)
4127 for(u_int i{0}; i < args->ts_stateids.ts_stateids_len; i++, current_el++)
39434128 {
39444129 out << ' ' << current_el;
39454130 }
39484133
39494134 void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4res* res)
39504135 {
3951 if (res)
4136 if(res)
39524137 {
39534138 out << "status: " << res->tsr_status;
3954 if (out_all() && res->tsr_status == NFS41::nfsstat4::NFS4_OK)
4139 if(out_all() && res->tsr_status == NFS41::nfsstat4::NFS4_OK)
39554140 {
39564141 out << " status codes: ";
39574142 NFS41::nfsstat4* current_el = res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_val;
3958 for (u_int i {0}; i < res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_len; i++, current_el++)
4143 for(u_int i{0}; i < res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_len; i++, current_el++)
39594144 {
39604145 out << ' ' << current_el;
39614146 }
39654150
39664151 void PrintAnalyzer::nfs41_operation(const struct NFS41::WANT_DELEGATION4args* args)
39674152 {
3968 if (args)
3969 {
3970 out << "want: " << args->wda_want
4153 if(args)
4154 {
4155 out << "want: " << args->wda_want
39714156 << " claim: " << args->wda_claim;
39724157 }
39734158 }
39744159
39754160 void PrintAnalyzer::nfs41_operation(const struct NFS41::WANT_DELEGATION4res* res)
39764161 {
3977 if (res)
4162 if(res)
39784163 {
39794164 out << "status: " << res->wdr_status;
3980 if (out_all() && res->wdr_status == NFS41::nfsstat4::NFS4_OK)
4165 if(out_all() && res->wdr_status == NFS41::nfsstat4::NFS4_OK)
39814166 {
39824167 out << res->WANT_DELEGATION4res_u.wdr_resok4;
39834168 }
39864171
39874172 void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4args* args)
39884173 {
3989 if (args)
4174 if(args)
39904175 {
39914176 out << "clientid: " << args->dca_clientid;
39924177 }
39944179
39954180 void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4res* res)
39964181 {
3997 if (res)
4182 if(res)
39984183 {
39994184 out << "status: " << res->dcr_status;
40004185 }
40024187
40034188 void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4args* args)
40044189 {
4005 if (args)
4190 if(args)
40064191 {
40074192 out << "one fs: " << args->rca_one_fs;
40084193 }
40104195
40114196 void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4res* res)
40124197 {
4013 if (res)
4198 if(res)
40144199 {
40154200 out << "status: " << res->rcr_status;
40164201 }
40184203
40194204 void PrintAnalyzer::nfs41_operation(const struct NFS41::ILLEGAL4res* res)
40204205 {
4021 if (res) { out << "status: " << res->status; }
4022 }
4023
4206 if(res) {
4207 out << "status: " << res->status;
4208 }
4209 }
40244210
40254211 void PrintAnalyzer::flush_statistics()
40264212 {
2929 {
3030 namespace analysis
3131 {
32
3332 namespace NFS3 = NST::API::NFS3;
3433 namespace NFS4 = NST::API::NFS4;
3534 namespace NFS41 = NST::API::NFS41;
3736 class PrintAnalyzer : public IAnalyzer
3837 {
3938 public:
40 PrintAnalyzer(std::ostream& o) : out(o)
39 PrintAnalyzer(std::ostream& o)
40 : out(o)
4141 {
4242 }
4343 ~PrintAnalyzer()
4444 {
4545 }
4646
47 // clang-format off
4748 void closeFileSMBv2(const SMBv2::CloseFileCommand*,
4849 const SMBv2::CloseRequest*,
4950 const SMBv2::CloseResponse*) override final;
455456 void nfs41_operation(const struct NFS41::SAVEFH4res* res);
456457
457458 void nfs41_operation(const struct NFS41::ILLEGAL4res* res);
458
459 // clang-format on
459460 void flush_statistics() override final;
460461
461462 private:
462 PrintAnalyzer(const PrintAnalyzer&) = delete;
463 PrintAnalyzer(const PrintAnalyzer&) = delete;
463464 PrintAnalyzer& operator=(const PrintAnalyzer&) = delete;
464465
465466 std::ostream& out;
468469 } // namespace analysis
469470 } // namespace NST
470471 //------------------------------------------------------------------------------
471 #endif//PRINT_ANALYZER_H
472 //------------------------------------------------------------------------------
472 #endif //PRINT_ANALYZER_H
473 //------------------------------------------------------------------------------
2424 #include <cinttypes>
2525 #include <memory>
2626 #include <string>
27 #include <utility>
2728 #include <vector>
2829 #include <unordered_map>
29 #include <utility>
3030
3131 #include "protocols/rpc/rpc_header.h"
3232 #include "utils/filtered_data.h"
3838 {
3939 namespace analysis
4040 {
41
4241 class Session : public utils::ApplicationSession
4342 {
4443 using FilteredDataQueue = NST::utils::FilteredDataQueue;
44
4545 public:
46
4746 Session(const utils::NetworkSession& s, utils::Session::Direction call_direction)
48 : utils::ApplicationSession{s, call_direction}
47 : utils::ApplicationSession{s, call_direction}
4948 {
5049 utils::Out message;
5150 message << "Detect session " << str();
5251 }
53 ~Session() = default;
54 Session(const Session&) = delete;
52 ~Session() = default;
53 Session(const Session&) = delete;
5554 Session& operator=(const Session&) = delete;
56
55
5756 void save_call_data(const std::uint64_t xid, FilteredDataQueue::Ptr&& data)
5857 {
5958 FilteredDataQueue::Ptr& e = operations[xid];
60 if(e) // xid call already exists
59 if(e) // xid call already exists
6160 {
6261 LOG("replace RPC Call XID:%" PRIu64 " for %s", xid, str().c_str());
6362 }
6463
65 e = std::move(data); // replace existing or set new
64 e = std::move(data); // replace existing or set new
6665 }
6766 inline FilteredDataQueue::Ptr get_call_data(const std::uint64_t xid)
6867 {
8382
8483 inline const Session* get_session() const { return this; }
8584 private:
86
8785 // TODO: add custom allocator based on BlockAllocator
8886 // to decrease cost of expensive insert/erase operations
8987 std::unordered_map<std::uint64_t, FilteredDataQueue::Ptr> operations;
9593 public:
9694 using MsgType = NST::protocols::rpc::MsgType;
9795
98 Sessions() = default;
99 ~Sessions()= default;
100 Sessions(const Sessions&) = delete;
96 Sessions() = default;
97 ~Sessions() = default;
98 Sessions(const Sessions&) = delete;
10199 Sessions& operator=(const Sessions&) = delete;
102100
103101 Session* get_session(utils::NetworkSession* app, NST::utils::Session::Direction dir, MsgType type)
106104 {
107105 if(type == MsgType::CALL) // add new session only for Call
108106 {
109 std::unique_ptr<Session> ptr{ new Session{*app, dir} };
107 std::unique_ptr<Session> ptr{new Session{*app, dir}};
110108 sessions.emplace_back(std::move(ptr));
111109
112110 app->application = sessions.back().get(); // set reference
117115 }
118116
119117 private:
120 std::vector< std::unique_ptr<Session> > sessions;
118 std::vector<std::unique_ptr<Session>> sessions;
121119 };
122120
123121 } // namespace analysis
124122 } // namespace NST
125123 //------------------------------------------------------------------------------
126 #endif//RPC_SESSIONS_H
124 #endif //RPC_SESSIONS_H
127125 //------------------------------------------------------------------------------
3131 */
3232 namespace SMBv2
3333 {
34 // clang-format off
3435
3536 /*! CIFS v2 commands
3637 */
12511252 } __attribute__ ((__packed__));
12521253
12531254 } // namespace SMBv2
1255
1256 // clang-format on
1257
12541258 } // namespace API
12551259 } // namespace NST
12561260 //------------------------------------------------------------------------------
1257 #endif//API_CIFS2_COMMANDS_H
1261 #endif // API_CIFS2_COMMANDS_H
12581262 //------------------------------------------------------------------------------
3333 */
3434 namespace SMBv1
3535 {
36 // clang-format off
3637
3738 /*! CIFS v1 commands list
3839 */
343344 struct NoAndxCmdArgumentType{} __attribute__ ((__packed__)); //!< No command's arguments
344345 struct NoAndxCmdResultType{} __attribute__ ((__packed__)); //!< No command's results
345346
347 // clang-format om
348
346349 } // namespace SMBv1
347350 } // namespace API
348351 } // namespace NST
349352 //------------------------------------------------------------------------------
350 #endif//API_CIFS_COMMANDS_H
351 //------------------------------------------------------------------------------
353 #endif// API_CIFS_COMMANDS_H
354 //------------------------------------------------------------------------------
2929 #define NFSTRACE_BIG_ENDIAN __BIG_ENDIAN
3030 #define NFSTRACE_LITTLE_ENDIAN __LITTLE_ENDIAN
3131 #else
32 #include <machine/endian.h>
3233 #include <sys/param.h>
33 #include <machine/endian.h>
3434 #define NFSTRACE_BYTE_ORDER BYTE_ORDER
3535 #define NFSTRACE_BIG_ENDIAN BIG_ENDIAN
3636 #define NFSTRACE_LITTLE_ENDIAN LITTLE_ENDIAN
4242 {
4343 namespace SMBv2
4444 {
45
46 # if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN
45 #if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN
4746
4847 // TODO: rename this function template to LEconstant2host
4948
50 template<class T>
49 template <class T>
5150 constexpr T pc_to_net(T t)
5251 {
5352 static_assert(t == T{}, "try to not use pc_to_net w/o specialization");
5453 return t;
5554 }
5655
57 template<>
56 // clang-format off
57
58 template <>
5859 constexpr std::uint64_t pc_to_net(std::uint64_t t)
5960 {
6061 return ((t & 0xFF00000000000000) >> 56)
6768 | ((t & 0x00000000000000FF) << 56);
6869 }
6970
70 template<>
71 template <>
7172 constexpr uint32_t pc_to_net(uint32_t t)
7273 {
7374 return ((t & 0xFF000000) >> 24)
7677 | ((t & 0x000000FF) << 24);
7778 }
7879
79 template<>
80 template <>
8081 constexpr uint16_t pc_to_net(uint16_t t)
8182 {
8283 return ((t & 0xFF00) >> 8)
8384 | ((t & 0x00FF) << 8);
8485 }
8586
86 template<>
87 // clang-format on
88
89 template <>
8790 constexpr std::uint8_t pc_to_net(std::uint8_t v)
8891 {
8992 return v;
9093 }
9194
92 template<>
95 template <>
9396 constexpr std::int64_t pc_to_net(std::int64_t v)
9497 {
9598 return pc_to_net((std::uint64_t)v);
9699 }
97100
98 template<>
101 template <>
99102 constexpr std::int32_t pc_to_net(std::int32_t v)
100103 {
101104 return pc_to_net((std::uint32_t)v);
102105 }
103106
104 template<>
107 template <>
105108 constexpr std::int16_t pc_to_net(std::int16_t v)
106109 {
107110 return pc_to_net((std::uint16_t)v);
108111 }
109112
110 template<>
113 template <>
111114 constexpr std::int8_t pc_to_net(std::int8_t v)
112115 {
113116 return pc_to_net((std::uint8_t)v);
114117 }
115118
116 # else
117 # if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN
119 #else
120 #if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN
118121
119122 /*!
120123 * Does nothing for Intel
121124 */
122 template<class T>
125 template <class T>
123126 constexpr T pc_to_net(T t)
124127 {
125128 return t;
126129 }
127130
128 # endif
131 #endif
129132 #endif
130133
131134 } // SMBv2
132135 } // API
133136 } // NST
134137 //------------------------------------------------------------------------------
135 #endif//PC_TO_NET_H
138 #endif // PC_TO_NET_H
136139 //------------------------------------------------------------------------------
2323 //------------------------------------------------------------------------------
2424 #include <sys/time.h>
2525
26 #include "cifs2_commands.h"
2627 #include "cifs_commands.h"
27 #include "cifs2_commands.h"
2828 #include "procedure.h"
2929 //------------------------------------------------------------------------------
3030 namespace NST
3333 {
3434 namespace CIFSv1
3535 {
36 struct RawMessageHeader;
36 struct RawMessageHeader;
3737 }
3838 namespace CIFSv2
3939 {
40 struct RawMessageHeader;
40 struct RawMessageHeader;
4141 }
4242 } // namespace protocols
4343 namespace API
4444 {
45
4645 /*! SMB 1 version
4746 */
4847 namespace SMBv1
4948 {
50
51 using Session = u_int16_t;//!< Session IDentifier
49 using Session = u_int16_t; //!< Session IDentifier
5250
5351 /*! Represents one SMB command
5452 */
5553 template <
5654 typename Header,
5755 typename Request,
58 typename Response
59 >
56 typename Response>
6057 class Command : public Procedure<int>
6158 {
6259 public:
63 using RequestType = Request;
64 using ResponseType = Response;
65 using HeaderType = Header;
66 const HeaderType* req_header = nullptr;
67 const HeaderType* res_header = nullptr;
68 const RequestType* parg = nullptr;//!< Arguments of specified command
69 const ResponseType* pres = nullptr;//!< Results of specified command
60 using RequestType = Request;
61 using ResponseType = Response;
62 using HeaderType = Header;
63 const HeaderType* req_header = nullptr;
64 const HeaderType* res_header = nullptr;
65 const RequestType* parg = nullptr; //!< Arguments of specified command
66 const ResponseType* pres = nullptr; //!< Results of specified command
7067 };
7168
72 using CreateDirectoryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateDirectoryArgumentType, CreateDirectoryResultType>; //!< CreateDirectory command
73 using DeleteDirectoryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, DeleteDirectoryArgumentType, DeleteDirectoryResultType>; //!< DeleteDirectory command
74 using OpenCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenArgumentType, OpenResultType>; //!< Open command
75 using CreateCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateArgumentType, CreateResultType>; //!< Create command
76 using CloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CloseArgumentType, CloseResultType>; //!< Close command
77 using FlushCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FlushArgumentType, FlushResultType>; //!< Flush command
78 using DeleteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, DeleteArgumentType, DeleteResultType>; //!< Delete command
79 using RenameCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, RenameArgumentType, RenameResultType>; //!< Rename command
80 using QueryInformationCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryInformationArgumentType, QueryInformationResultType>; //!< QueryInformation command. This transaction is used to get information about a specific file or directory. There are several information levels that can be queried.
81 using SetInformationCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SetInformationArgumentType, SetInformationResultType>; //!< Set Information command. This transaction is used to set the standard and extended attribute information of a specific file or directory on the server.
82 using ReadCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadArgumentType, ReadResultType>; //!< Read command
83 using WriteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteArgumentType, WriteResultType>; //!< Write command
84 using LockByteRangeCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LockByteRangeArgumentType, LockByteRangeResultType>; //!< Lock Byte Range command. This command is used to explicitly lock a contiguous range of bytes in an open regular file.
85 using UnlockByteRangeCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, UnlockByteRangeArgumentType, UnlockByteRangeResultType>; //!< UnLock Byte Range command
86 using CreateTemporaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateTemporaryArgumentType, CreateTemporaryResultType>; //!< Create Temporary file command. This command is used to create a file for temporary use by the client.
87 using CreateNewCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateNewArgumentType, CreateNewResultType>; //!< Create a new file command. This command is used to create a new file. It MUST NOT truncate or overwrite an existing file.
88 using CheckDirectoryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CheckDirectoryArgumentType, CheckDirectoryResultType>; //!< CheckDirectory command. This command is used to verify that a specified path resolves to a valid directory on the server.
89 using ProcessExitCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ProcessExitArgumentType, ProcessExitResultType>; //!< Process Exit command.An SMB_COM_PROCESS_EXIT request is sent by the client to indicate the catastrophic failure of a client process.
90 using SeekCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SeekArgumentType, SeekResultType>; //!< Seek command
91 using LockAndReadCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LockAndReadArgumentType, LockAndReadResultType>; //!< Lock And Read command
92 using WriteAndUnlockCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndUnlockArgumentType, WriteAndUnlockResultType>; //!< Write And Unlock command
93 using ReadRawCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadRawArgumentType, ReadRawResultType>; //!< Read raw command
94 using ReadMpxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadMpxArgumentType, ReadMpxResultType>; //!< Read Mpx command. This is a specialized read command intended to maximize the performance of reading large blocks of data from a regular file while allowing for other operations to take place between the client and the server.
95 using ReadMpxSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadMpxSecondaryArgumentType, ReadMpxSecondaryResultType>; //!< Read Read Mpx Secondary command
96 using WriteRawCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteRawArgumentType, WriteRawResultType>; //!< Write Raw command. The command permits a client to send a large unformatted data (raw byte) message over the SMB transport without requiring the usual SMB request format
97 using WriteMpxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteMpxArgumentType, WriteMpxResultType>; //!< Write Mpx command
98 using WriteMpxSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteMpxSecondaryArgumentType, WriteMpxSecondaryResultType>; //!< Write Mpx 2 command
99 using WriteCompleteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteCompleteArgumentType, WriteCompleteResultType>; //!< Write Complete command
100 using QueryServerCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryServerArgumentType, QueryServerResultType>; //!< Query Server (reserved) command
101 using SetInformation2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SetInformation2ArgumentType, SetInformation2ResultType>; //!< Set Information 2 command
102 using QueryInformation2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryInformation2ArgumentType, QueryInformation2ResultType>; //!< Query Information 2 command
103 using LockingAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LockingAndxArgumentType, LockingAndxResultType>; //!< Lock some bytes of the file command
104 using TransactionCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TransactionArgumentType, TransactionResultType>; //!< Transaction command.These commands operate on mailslots and named pipes, which are interprocess communication endpoints within the CIFS file system
105 using TransactionSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TransactionSecondaryArgumentType, TransactionSecondaryResultType>; //!< Transaction 2 command
106 using IoctlCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, IoctlArgumentType, IoctlResultType>; //!< Ioctl command
107 using IoctlSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, IoctlSecondaryArgumentType, IoctlSecondaryResultType>; //!< Ioctl 2 command
108 using CopyCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CopyArgumentType, CopyResultType>; //!< Copy command
109 using MoveCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, MoveArgumentType, MoveResultType>; //!< Move command
110 using EchoCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, EchoArgumentType, EchoResultType>; //!< Echo command
111 using WriteAndCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndCloseArgumentType, WriteAndCloseResultType>; //!< Write And Close command
112 using OpenAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenAndxArgumentType, OpenAndxResultType>; //!< Open 2 command
113 using ReadAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadAndxArgumentType, ReadAndxResultType>; //!< Read 2 command
114 using WriteAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndxArgumentType, WriteAndxResultType>; //!< Write 2 command
115 using NewFileSizeCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NewFileSizeArgumentType, NewFileSizeResultType>; //!< New File Size command. Reserved but not implemented
116 using CloseAndTreeDiscCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CloseAndTreeDiscArgumentType, CloseAndTreeDiscResultType>; //!< Reserved command
117 using Transaction2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, Transaction2ArgumentType, Transaction2ResultType>; //!< Transaction 2 command
118 using Transaction2SecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, Transaction2SecondaryArgumentType, Transaction2SecondaryResultType>; //!< Transaction 3 command
119 using FindClose2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindClose2ArgumentType, FindClose2ResultType>; //!< Search handle close command
120 using FindNotifyCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindNotifyCloseArgumentType, FindNotifyCloseResultType>; //!< Search handle close command
121 using TreeConnectCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeConnectArgumentType, TreeConnectResultType>; //!< establish a client connection to a server share command
122 using TreeDisconnectCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeDisconnectArgumentType, TreeDisconnectResultType>; //!< Disconnect command
123 using NegotiateCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NegotiateArgumentType, NegotiateResultType>; //!< Negotiate command
124 using SessionSetupAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SessionSetupAndxArgumentType, SessionSetupAndxResultType>; //!< Session setup command
125 using LogoffAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LogoffAndxArgumentType, LogoffAndxResultType>; //!< Log off command
126 using TreeConnectAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeConnectAndxArgumentType, TreeConnectAndxResultType>; //!< Tree Connect command
127 using SecurityPackageAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SecurityPackageAndxArgumentType, SecurityPackageAndxResultType>; //!< Security Package command
128 using QueryInformationDiskCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryInformationDiskArgumentType, QueryInformationDiskResultType>; //!< Query Disk Information command
129 using SearchCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SearchArgumentType, SearchResultType>; //!< Search command
130 using FindCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindArgumentType, FindResultType>; //!< Find command
131 using FindUniqueCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindUniqueArgumentType, FindUniqueResultType>; //!< Find unique command
132 using FindCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindCloseArgumentType, FindCloseResultType>; //!< Find close command
133 using NtTransactCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtTransactArgumentType, NtTransactResultType>; //!< Transact command
134 using NtTransactSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtTransactSecondaryArgumentType, NtTransactSecondaryResultType>; //!< Transact 2 command
135 using NtCreateAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtCreateAndxArgumentType, NtCreateAndxResultType>; //!< Create command
136 using NtCancelCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtCancelArgumentType, NtCancelResultType>; //!< Cancel command
137 using NtRenameCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtRenameArgumentType, NtRenameResultType>; //!< Rename command
138 using OpenPrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenPrintFileArgumentType, OpenPrintFileResultType>; //!< Open Print File command
139 using WritePrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WritePrintFileArgumentType, WritePrintFileResultType>; //!< Write Print File command
140 using ClosePrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ClosePrintFileArgumentType, ClosePrintFileResultType>; //!< Close Print File command
141 using GetPrintQueueCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, GetPrintQueueArgumentType, GetPrintQueueResultType>; //!< Get Print Queue command
142 using ReadBulkCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadBulkArgumentType, ReadBulkResultType>; //!< Read Bulk command
143 using WriteBulkCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteBulkArgumentType, WriteBulkResultType>; //!< Write Bulk command
144 using WriteBulkDataCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteBulkDataArgumentType, WriteBulkDataResultType>; //!< Write Bulk command
145 using InvalidCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, InvalidArgumentType, InvalidResultType>; //!< Invalid command
146 using NoAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NoAndxCmdArgumentType, NoAndxCmdResultType>; //!< No command
69 using CreateDirectoryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateDirectoryArgumentType, CreateDirectoryResultType>; //!< CreateDirectory command
70 using DeleteDirectoryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, DeleteDirectoryArgumentType, DeleteDirectoryResultType>; //!< DeleteDirectory command
71 using OpenCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenArgumentType, OpenResultType>; //!< Open command
72 using CreateCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateArgumentType, CreateResultType>; //!< Create command
73 using CloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CloseArgumentType, CloseResultType>; //!< Close command
74 using FlushCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FlushArgumentType, FlushResultType>; //!< Flush command
75 using DeleteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, DeleteArgumentType, DeleteResultType>; //!< Delete command
76 using RenameCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, RenameArgumentType, RenameResultType>; //!< Rename command
77 using QueryInformationCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryInformationArgumentType, QueryInformationResultType>; //!< QueryInformation command. This transaction is used to get information about a specific file or directory. There are several information levels that can be queried.
78 using SetInformationCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SetInformationArgumentType, SetInformationResultType>; //!< Set Information command. This transaction is used to set the standard and extended attribute information of a specific file or directory on the server.
79 using ReadCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadArgumentType, ReadResultType>; //!< Read command
80 using WriteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteArgumentType, WriteResultType>; //!< Write command
81 using LockByteRangeCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LockByteRangeArgumentType, LockByteRangeResultType>; //!< Lock Byte Range command. This command is used to explicitly lock a contiguous range of bytes in an open regular file.
82 using UnlockByteRangeCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, UnlockByteRangeArgumentType, UnlockByteRangeResultType>; //!< UnLock Byte Range command
83 using CreateTemporaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateTemporaryArgumentType, CreateTemporaryResultType>; //!< Create Temporary file command. This command is used to create a file for temporary use by the client.
84 using CreateNewCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateNewArgumentType, CreateNewResultType>; //!< Create a new file command. This command is used to create a new file. It MUST NOT truncate or overwrite an existing file.
85 using CheckDirectoryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CheckDirectoryArgumentType, CheckDirectoryResultType>; //!< CheckDirectory command. This command is used to verify that a specified path resolves to a valid directory on the server.
86 using ProcessExitCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ProcessExitArgumentType, ProcessExitResultType>; //!< Process Exit command.An SMB_COM_PROCESS_EXIT request is sent by the client to indicate the catastrophic failure of a client process.
87 using SeekCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SeekArgumentType, SeekResultType>; //!< Seek command
88 using LockAndReadCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LockAndReadArgumentType, LockAndReadResultType>; //!< Lock And Read command
89 using WriteAndUnlockCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndUnlockArgumentType, WriteAndUnlockResultType>; //!< Write And Unlock command
90 using ReadRawCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadRawArgumentType, ReadRawResultType>; //!< Read raw command
91 using ReadMpxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadMpxArgumentType, ReadMpxResultType>; //!< Read Mpx command. This is a specialized read command intended to maximize the performance of reading large blocks of data from a regular file while allowing for other operations to take place between the client and the server.
92 using ReadMpxSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadMpxSecondaryArgumentType, ReadMpxSecondaryResultType>; //!< Read Read Mpx Secondary command
93 using WriteRawCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteRawArgumentType, WriteRawResultType>; //!< Write Raw command. The command permits a client to send a large unformatted data (raw byte) message over the SMB transport without requiring the usual SMB request format
94 using WriteMpxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteMpxArgumentType, WriteMpxResultType>; //!< Write Mpx command
95 using WriteMpxSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteMpxSecondaryArgumentType, WriteMpxSecondaryResultType>; //!< Write Mpx 2 command
96 using WriteCompleteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteCompleteArgumentType, WriteCompleteResultType>; //!< Write Complete command
97 using QueryServerCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryServerArgumentType, QueryServerResultType>; //!< Query Server (reserved) command
98 using SetInformation2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SetInformation2ArgumentType, SetInformation2ResultType>; //!< Set Information 2 command
99 using QueryInformation2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryInformation2ArgumentType, QueryInformation2ResultType>; //!< Query Information 2 command
100 using LockingAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LockingAndxArgumentType, LockingAndxResultType>; //!< Lock some bytes of the file command
101 using TransactionCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TransactionArgumentType, TransactionResultType>; //!< Transaction command.These commands operate on mailslots and named pipes, which are interprocess communication endpoints within the CIFS file system
102 using TransactionSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TransactionSecondaryArgumentType, TransactionSecondaryResultType>; //!< Transaction 2 command
103 using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, IoctlArgumentType, IoctlResultType>; //!< Ioctl command
104 using IoctlSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, IoctlSecondaryArgumentType, IoctlSecondaryResultType>; //!< Ioctl 2 command
105 using CopyCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CopyArgumentType, CopyResultType>; //!< Copy command
106 using MoveCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, MoveArgumentType, MoveResultType>; //!< Move command
107 using EchoCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, EchoArgumentType, EchoResultType>; //!< Echo command
108 using WriteAndCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndCloseArgumentType, WriteAndCloseResultType>; //!< Write And Close command
109 using OpenAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenAndxArgumentType, OpenAndxResultType>; //!< Open 2 command
110 using ReadAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadAndxArgumentType, ReadAndxResultType>; //!< Read 2 command
111 using WriteAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndxArgumentType, WriteAndxResultType>; //!< Write 2 command
112 using NewFileSizeCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NewFileSizeArgumentType, NewFileSizeResultType>; //!< New File Size command. Reserved but not implemented
113 using CloseAndTreeDiscCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CloseAndTreeDiscArgumentType, CloseAndTreeDiscResultType>; //!< Reserved command
114 using Transaction2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, Transaction2ArgumentType, Transaction2ResultType>; //!< Transaction 2 command
115 using Transaction2SecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, Transaction2SecondaryArgumentType, Transaction2SecondaryResultType>; //!< Transaction 3 command
116 using FindClose2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindClose2ArgumentType, FindClose2ResultType>; //!< Search handle close command
117 using FindNotifyCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindNotifyCloseArgumentType, FindNotifyCloseResultType>; //!< Search handle close command
118 using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeConnectArgumentType, TreeConnectResultType>; //!< establish a client connection to a server share command
119 using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeDisconnectArgumentType, TreeDisconnectResultType>; //!< Disconnect command
120 using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NegotiateArgumentType, NegotiateResultType>; //!< Negotiate command
121 using SessionSetupAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SessionSetupAndxArgumentType, SessionSetupAndxResultType>; //!< Session setup command
122 using LogoffAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LogoffAndxArgumentType, LogoffAndxResultType>; //!< Log off command
123 using TreeConnectAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeConnectAndxArgumentType, TreeConnectAndxResultType>; //!< Tree Connect command
124 using SecurityPackageAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SecurityPackageAndxArgumentType, SecurityPackageAndxResultType>; //!< Security Package command
125 using QueryInformationDiskCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryInformationDiskArgumentType, QueryInformationDiskResultType>; //!< Query Disk Information command
126 using SearchCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SearchArgumentType, SearchResultType>; //!< Search command
127 using FindCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindArgumentType, FindResultType>; //!< Find command
128 using FindUniqueCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindUniqueArgumentType, FindUniqueResultType>; //!< Find unique command
129 using FindCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindCloseArgumentType, FindCloseResultType>; //!< Find close command
130 using NtTransactCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtTransactArgumentType, NtTransactResultType>; //!< Transact command
131 using NtTransactSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtTransactSecondaryArgumentType, NtTransactSecondaryResultType>; //!< Transact 2 command
132 using NtCreateAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtCreateAndxArgumentType, NtCreateAndxResultType>; //!< Create command
133 using NtCancelCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtCancelArgumentType, NtCancelResultType>; //!< Cancel command
134 using NtRenameCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtRenameArgumentType, NtRenameResultType>; //!< Rename command
135 using OpenPrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenPrintFileArgumentType, OpenPrintFileResultType>; //!< Open Print File command
136 using WritePrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WritePrintFileArgumentType, WritePrintFileResultType>; //!< Write Print File command
137 using ClosePrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ClosePrintFileArgumentType, ClosePrintFileResultType>; //!< Close Print File command
138 using GetPrintQueueCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, GetPrintQueueArgumentType, GetPrintQueueResultType>; //!< Get Print Queue command
139 using ReadBulkCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadBulkArgumentType, ReadBulkResultType>; //!< Read Bulk command
140 using WriteBulkCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteBulkArgumentType, WriteBulkResultType>; //!< Write Bulk command
141 using WriteBulkDataCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteBulkDataArgumentType, WriteBulkDataResultType>; //!< Write Bulk command
142 using InvalidCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, InvalidArgumentType, InvalidResultType>; //!< Invalid command
143 using NoAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NoAndxCmdArgumentType, NoAndxCmdResultType>; //!< No command
147144
148 }//SMBv1
145 } //SMBv1
149146
150147 /*! SMB 2 version
151148 */
152149 namespace SMBv2
153150 {
154
155 using CloseFileCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CloseRequest, CloseResponse>; //!< Close file command
156 using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, NegotiateRequest, NegotiateResponse>; //!< Negotiate command
157 using SessionSetupCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SessionSetupRequest, SessionSetupResponse>; //!< Session setup command
158 using EchoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, EchoRequest, EchoResponse>; //!< Echo command
159 using LogOffCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LogOffRequest, LogOffResponse>; //!< Log off command
160 using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeConnectRequest, TreeConnectResponse>; //!< Tree connect command
161 using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeDisconnectRequest, TreeDisconnectResponse>; //!< Tree disconnect command
162 using CreateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CreateRequest, CreateResponse>; //!< Create command
163 using QueryInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryInfoRequest, QueryInfoResponse>; //!< Query Info command
164 using QueryDirCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryDirRequest, QueryDirResponse>; //!< Query directory command
165 using FlushCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, FlushRequest, FlushResponse>; //!< Flush command
166 using ReadCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ReadRequest, ReadResponse>; //!< Read command
167 using WriteCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, WriteRequest, WriteResponse>; //!< Write command
168 using LockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LockRequest, LockResponse>; //!< Lock command
169 using CancelCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CancelRequest, CancelResponce>; //!< Cancel command
170 using ChangeNotifyCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ChangeNotifyRequest, ChangeNotifyResponse>; //!< Change Notify command
171 using BreakOpLockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, OplockAcknowledgment, OplockResponse>; //!< Break opportunistic lock command
172 using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, IoCtlRequest, IoCtlResponse>; //!< Ioctl command
173 using SetInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SetInfoRequest, SetInfoResponse>; //!< Set Info command
151 using CloseFileCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CloseRequest, CloseResponse>; //!< Close file command
152 using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, NegotiateRequest, NegotiateResponse>; //!< Negotiate command
153 using SessionSetupCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SessionSetupRequest, SessionSetupResponse>; //!< Session setup command
154 using EchoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, EchoRequest, EchoResponse>; //!< Echo command
155 using LogOffCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LogOffRequest, LogOffResponse>; //!< Log off command
156 using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeConnectRequest, TreeConnectResponse>; //!< Tree connect command
157 using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeDisconnectRequest, TreeDisconnectResponse>; //!< Tree disconnect command
158 using CreateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CreateRequest, CreateResponse>; //!< Create command
159 using QueryInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryInfoRequest, QueryInfoResponse>; //!< Query Info command
160 using QueryDirCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryDirRequest, QueryDirResponse>; //!< Query directory command
161 using FlushCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, FlushRequest, FlushResponse>; //!< Flush command
162 using ReadCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ReadRequest, ReadResponse>; //!< Read command
163 using WriteCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, WriteRequest, WriteResponse>; //!< Write command
164 using LockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LockRequest, LockResponse>; //!< Lock command
165 using CancelCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CancelRequest, CancelResponce>; //!< Cancel command
166 using ChangeNotifyCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ChangeNotifyRequest, ChangeNotifyResponse>; //!< Change Notify command
167 using BreakOpLockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, OplockAcknowledgment, OplockResponse>; //!< Break opportunistic lock command
168 using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, IoCtlRequest, IoCtlResponse>; //!< Ioctl command
169 using SetInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SetInfoRequest, SetInfoResponse>; //!< Set Info command
174170
175171 } // namespace SMBv2
176172 } // namespace API
177173 } // namespace NST
178174 //------------------------------------------------------------------------------
179 #endif//CIFS_TYPES_H
175 #endif // CIFS_TYPES_H
180176 //------------------------------------------------------------------------------
2424 #define IANALYZER_TYPE_H
2525 //------------------------------------------------------------------------------
2626 #include "cifs_types.h"
27 #include "nfs3_types_rpcgen.h"
28 #include "nfs41_types_rpcgen.h"
29 #include "nfs4_types_rpcgen.h"
2730 #include "nfs_types.h"
28 #include "nfs3_types_rpcgen.h"
29 #include "nfs4_types_rpcgen.h"
30 #include "nfs41_types_rpcgen.h"
3131 #include "rpc_types.h"
3232 //------------------------------------------------------------------------------
3333 namespace NST
3434 {
3535 namespace API
3636 {
37
3837 /*! Abstract interface for plugins that collect NFS3 statistics
3938 */
4039 class INFSv3rpcgen
4140 {
4241 public:
4342 virtual ~INFSv3rpcgen() {}
44
43 // clang-format off
4544 /*! NFSv3 "NULL" procedure
4645 * \param RPCProcedure - Specified procedure
4746 * \param NULL3args - procedure arguments
17901789 * \param res - result of the command
17911790 */
17921791 virtual void breakOplockSMBv2(const SMBv2::BreakOpLockCommand*, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) {}
1792 // clang-format on
17931793 };
17941794
17951795 /*! Base interface for all nfstrace plugins.
18061806 } // namespace API
18071807 } // namespace NST
18081808 //------------------------------------------------------------------------------
1809 #endif//IANALYZER_TYPE_H
1809 #endif // IANALYZER_TYPE_H
18101810 //------------------------------------------------------------------------------
2929 {
3030 namespace NFS3
3131 {
32 // clang-format off
3233
3334 const uint32_t NFS3_FHSIZE {64};
3435 const uint32_t NFS3_COOKIEVERFSIZE {8};
950951
951952 #define NFS_V3 3
952953
954 // clang-format on
955
953956 } // namespace NFS3
954957 } // namespace API
955958 } // namespace NST
956959 //------------------------------------------------------------------------------
957 #endif//NFS3_TYPES_RPCGEN_H
960 #endif // NFS3_TYPES_RPCGEN_H
958961 //------------------------------------------------------------------------------
00 //------------------------------------------------------------------------------
11 // Author: Alexey Costroma
2 // Generated by rpcgen with minor compatibility fixes
2 // Generated by rpcgen with minor compatibility fixes
33 // Description: All RFC5661 declared structures.
44 // Copyright (c) 2015 EPAM Systems
55 //------------------------------------------------------------------------------
3030 {
3131 namespace NFS41
3232 {
33 // clang-format off
3334
3435 using authsys_parms = authunix_parms;
3536
31203121 const uint32_t CB_NULL {0};
31213122 const uint32_t CB_COMPOUND {1};
31223123
3124 // clang-format on
3125
31233126 } // namespace NFS41
31243127 } // namespace API
31253128 } // namespace NST
31263129 //------------------------------------------------------------------------------
3127 #endif//NFS41_TYPES_RPCGEN_H
3130 #endif // NFS41_TYPES_RPCGEN_H
31283131 //------------------------------------------------------------------------------
00 //------------------------------------------------------------------------------
11 // Author: Alexey Costroma
2 // Generated by rpcgen with minor compatibility fixes
2 // Generated by rpcgen with minor compatibility fixes
33 // Description: All RFC3530 declared structures.
44 // Copyright (c) 2014 EPAM Systems
55 //------------------------------------------------------------------------------
3030 {
3131 namespace NFS4
3232 {
33 // clang-format off
3334
3435 #ifndef RPCSEC_GSS
3536 #define RPCSEC_GSS 6
16101611 const uint32_t CB_NULL {0};
16111612 const uint32_t CB_COMPOUND {1};
16121613
1614 // clang-format on
1615
16131616 } // namespace NFS4
16141617 } // namespace API
16151618 } // namespace NST
16161619 //------------------------------------------------------------------------------
1617 #endif//NFS4_TYPES_RPCGEN_H
1620 #endif //NFS4_TYPES_RPCGEN_H
16181621 //------------------------------------------------------------------------------
2525 {
2626 namespace API
2727 {
28
29 static const unsigned int NFS_V40 {0};
30 static const unsigned int NFS_V41 {1};
28 static const unsigned int NFS_V40{0};
29 static const unsigned int NFS_V41{1};
3130
3231 //! struct ProcEnumNFS3 - containts all NFSv3 procedures
3332 struct ProcEnumNFS3
5756 PATHCONF = 20,
5857 COMMIT = 21
5958 };
60 static const unsigned int count {22}; //!< amount of procedures
59 static const unsigned int count{22}; //!< amount of procedures
6160 };
6261
6362 //! struct ProcEnumNFS4 - containts all NFSv4.0 procedures and operations
109108 // Pleause, keep in mind that in all cases we suppose that NFSv4.0
110109 // operation ILLEGAL(10044) has the second position in ProcEnumNFS4
111110 };
112 static const unsigned int count {41}; //!< amount of procedures & operations together
113 static const unsigned int count_proc {2}; //!< amount of procedures
111 static const unsigned int count{41}; //!< amount of procedures & operations together
112 static const unsigned int count_proc{2}; //!< amount of procedures
114113 };
115114
116115 //! struct ProcEnumNFS41 - containts all NFSv4.1 procedures and operations
180179 // Pleause, keep in mind that in all cases we suppose that NFSv4.1
181180 // operation ILLEGAL(10044) has the second position in ProcEnumNFS41
182181 };
183 static const unsigned int count {59}; //!< amount of procedures & operations together
184 static const unsigned int count_proc {2}; //!< amount of procedures
182 static const unsigned int count{59}; //!< amount of procedures & operations together
183 static const unsigned int count_proc{2}; //!< amount of procedures
185184 };
186185
187186 } // namespace API
188187 } // namespace NST
189188 //------------------------------------------------------------------------------
190 #endif//NFS_TYPES_H
189 #endif // NFS_TYPES_H
191190 //------------------------------------------------------------------------------
2929 {
3030 namespace API
3131 {
32
33 template<typename ProcedureType>
32 template <typename ProcedureType>
3433 struct Procedure
3534 {
3635 ProcedureType call;
4443 } // namespace API
4544 } // namespace NST
4645 //------------------------------------------------------------------------------
47 #endif//PROCEDURE_H
46 #endif // PROCEDURE_H
4847 //------------------------------------------------------------------------------
2929 {
3030 namespace API
3131 {
32
3332 using RPCProcedure = Procedure<struct rpc_msg>;
3433
3534 const uint32_t SUNRPC_MSG_VERSION = 2;
3635
3736 enum MsgType : int32_t
3837 {
39 CALL =0,
40 REPLY=1
38 CALL = 0,
39 REPLY = 1
4140 };
4241
4342 enum ReplyStat : int32_t
4443 {
45 MSG_ACCEPTED=0,
46 MSG_DENIED =1
44 MSG_ACCEPTED = 0,
45 MSG_DENIED = 1
4746 };
4847
4948 enum AcceptStat : int32_t
5049 {
51 SUCCESS =0, /* RPC executed successfully */
52 PROG_UNAVAIL =1, /* remote hasn't exported program */
53 PROG_MISMATCH=2, /* remote can't support version # */
54 PROC_UNAVAIL =3, /* program can't support procedure */
55 GARBAGE_ARGS =4, /* procedure can't decode params */
56 SYSTEM_ERR =5 /* errors like memory allocation failure */
50 SUCCESS = 0, /* RPC executed successfully */
51 PROG_UNAVAIL = 1, /* remote hasn't exported program */
52 PROG_MISMATCH = 2, /* remote can't support version # */
53 PROC_UNAVAIL = 3, /* program can't support procedure */
54 GARBAGE_ARGS = 4, /* procedure can't decode params */
55 SYSTEM_ERR = 5 /* errors like memory allocation failure */
5756 };
5857
5958 enum RejectStat : int32_t
6059 {
61 RPC_MISMATCH =0, /* RPC version number != 2 */
62 AUTH_ERROR =1 /* remote can't authenticate caller */
60 RPC_MISMATCH = 0, /* RPC version number != 2 */
61 AUTH_ERROR = 1 /* remote can't authenticate caller */
6362 };
6463
6564 // Status returned from authentication check
6665 enum AuthStat : int32_t
6766 {
68 AUTH_OK =0, /* success */
67 AUTH_OK = 0, /* success */
6968 /*
7069 * failed at remote end
7170 */
72 AUTH_BADCRED =1, /* bad credential (seal broken) */
73 AUTH_REJECTEDCRED =2, /* client must begin new session */
74 AUTH_BADVERF =3, /* bad verifier (seal broken) */
75 AUTH_REJECTEDVERF =4, /* verifier expired or replayed */
76 AUTH_TOOWEAK =5, /* rejected for security reasons */
71 AUTH_BADCRED = 1, /* bad credential (seal broken) */
72 AUTH_REJECTEDCRED = 2, /* client must begin new session */
73 AUTH_BADVERF = 3, /* bad verifier (seal broken) */
74 AUTH_REJECTEDVERF = 4, /* verifier expired or replayed */
75 AUTH_TOOWEAK = 5, /* rejected for security reasons */
7776 /*
7877 * failed locally
7978 */
80 SUNRPC_AUTH_INVALIDRESP =6, /* bogus response verifier */
81 SUNRPC_AUTH_FAILED =7, /* reason unknown */
79 SUNRPC_AUTH_INVALIDRESP = 6, /* bogus response verifier */
80 SUNRPC_AUTH_FAILED = 7, /* reason unknown */
8281 /*
8382 * AUTH_KERB errors; deprecated. See [RFC2695]
8483 */
85 AUTH_KERB_GENERIC = 8, /* kerberos generic error */
86 AUTH_TIMEEXPIRE = 9, /* time of credential expired */
87 AUTH_TKT_FILE = 10,/* problem with ticket file */
88 AUTH_DECODE = 11,/* can't decode authenticator */
89 AUTH_NET_ADDR = 12,/* wrong net address in ticket */
84 AUTH_KERB_GENERIC = 8, /* kerberos generic error */
85 AUTH_TIMEEXPIRE = 9, /* time of credential expired */
86 AUTH_TKT_FILE = 10, /* problem with ticket file */
87 AUTH_DECODE = 11, /* can't decode authenticator */
88 AUTH_NET_ADDR = 12, /* wrong net address in ticket */
9089 /*
9190 * RPCSEC_GSS GSS related errors
9291 */
93 RPCSEC_GSS_CREDPROBLEM = 13,/* no credentials for user */
94 RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */
92 RPCSEC_GSS_CREDPROBLEM = 13, /* no credentials for user */
93 RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */
9594 };
9695
9796 struct OpaqueAuth
108107
109108 struct RPCMessage
110109 {
111 uint32_t xid;
110 uint32_t xid;
112111 uint32_t type;
113112 };
114113
115114 struct RPCCall : public RPCMessage
116115 {
117 uint32_t rpcvers;
118 uint32_t prog;
119 uint32_t vers;
120 uint32_t proc;
116 uint32_t rpcvers;
117 uint32_t prog;
118 uint32_t vers;
119 uint32_t proc;
121120 OpaqueAuth cred;
122121 OpaqueAuth verf;
123122 };
124123
125124 struct AcceptedReply
126125 {
127 OpaqueAuth verf;
128 uint32_t stat;
129 MismatchInfo mismatch_info;
126 OpaqueAuth verf;
127 uint32_t stat;
128 MismatchInfo mismatch_info;
130129 };
131130
132131 struct RejectedReply
133132 {
134 uint32_t stat;
135 union U
136 {
133 uint32_t stat;
134 union U {
137135 MismatchInfo mismatch_info;
138136 OpaqueAuth auth_stat;
139137 } u;
141139
142140 struct RPCReply : public RPCMessage
143141 {
144 uint32_t stat;
145 union U
146 {
142 uint32_t stat;
143 union U {
147144 AcceptedReply accepted;
148145 RejectedReply rejected;
149146 } u;
152149 } // namespace API
153150 } // namespace NST
154151 //------------------------------------------------------------------------------
155 #endif//RPC_TYPES_H
152 #endif // RPC_TYPES_H
156153 //------------------------------------------------------------------------------
2929 {
3030 namespace API
3131 {
32
3332 struct Session
3433 {
3534 enum Direction
3635 {
37 Source =0,
38 Destination =1,
39 Unknown =0xBAD
36 Source = 0,
37 Destination = 1,
38 Unknown = 0xBAD
4039 };
4140
4241 enum Type
4342 {
44 TCP=0,
45 UDP=1
46 } type :16; // 16 bit for alignment following integers
43 TCP = 0,
44 UDP = 1
45 } type : 16; // 16 bit for alignment following integers
4746
4847 enum IPType
4948 {
50 v4=0,
51 v6=1
52 } ip_type:16; // 16 bit for alignment following integers
49 v4 = 0,
50 v6 = 1
51 } ip_type : 16; // 16 bit for alignment following integers
5352
54 in_port_t port[2]; // 2 ports in network byte order
53 in_port_t port[2]; // 2 ports in network byte order
5554
56 union IPAddress
57 {
58 struct // 2 IPv4 addresses in network byte order
55 union IPAddress {
56 struct // 2 IPv4 addresses in network byte order
5957 {
6058 in_addr_t addr[2];
6159 } v4;
62 union // 2 IPv6 addresses in network byte order
60 union // 2 IPv6 addresses in network byte order
6361 {
64 uint8_t addr [2][16];
62 uint8_t addr[2][16];
6563 uint32_t addr_uint32[2][4];
66 } __attribute__ ((__packed__)) v6;
64 } __attribute__((__packed__)) v6;
6765 } ip;
6866 };
6967
7068 } // namespace API
7169 } // namespace NST
7270 //------------------------------------------------------------------------------
73 #endif//SESSION_H
71 #endif // SESSION_H
7472 //------------------------------------------------------------------------------
2121 #ifndef XDR_TYPES_H
2222 #define XDR_TYPES_H
2323 //------------------------------------------------------------------------------
24 #include <cstddef>
2425 #include <cstdint>
25 #include <cstddef>
2626 //------------------------------------------------------------------------------
2727 namespace NST
2828 {
2929 namespace API
3030 {
31
3231 struct Opaque
3332 {
3433 inline void set(const uint8_t* p, uint32_t n)
3837 }
3938
4039 inline uint8_t operator[](size_t i) const { return ptr[i]; }
41 inline const uint8_t* data() const { return ptr; }
42 inline uint32_t size() const { return len; }
43
44 const uint8_t* ptr;
45 uint32_t len;
40 inline const uint8_t* data() const { return ptr; }
41 inline uint32_t size() const { return len; }
42 const uint8_t* ptr;
43 uint32_t len;
4644 };
4745
4846 } // namespace API
4947 } // namespace NST
5048 //------------------------------------------------------------------------------
51 #endif//XDR_TYPES_H
49 #endif //XDR_TYPES_H
5250 //------------------------------------------------------------------------------
3030 constexpr char PROGRAM_BUILD_INFO[]=
3131 "@NST_VERSION_FULL@\n"
3232 "built on @CMAKE_SYSTEM@\n"
33 "by C++ compiler @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@";
33 "by C++ compiler @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@ on @COMPILATION_DATE@";
3434
3535 constexpr char MODULES_DIRECTORY_PATH[] = "@CMAKE_INSTALL_PREFIX@/lib/nfstrace/";
3636
2020 //------------------------------------------------------------------------------
2121 #include "controller/cmdline_args.h"
2222 //------------------------------------------------------------------------------
23 #define LIVE "live"
24 #define DUMP "dump"
25 #define STAT "stat"
23 #define LIVE "live"
24 #define DUMP "dump"
25 #define STAT "stat"
2626 #define DRAIN "drain"
2727 //------------------------------------------------------------------------------
2828 namespace NST
3131 {
3232 namespace cmdline
3333 {
34 // clang-format off
3435
3536 const char* const Args::profiling_mode {LIVE};
3637 const char* const Args::dumping_mode {DUMP};
6364 {'h', "help", Opt::NOA, "false", "print help message and usage for modules passed with -a options, then exit", nullptr, nullptr, false}
6465 };
6566
67 // clang-format on
68
6669 } // namespace cmdline
6770 } // namespace controller
6871 } // namespace NST
2929 {
3030 namespace cmdline
3131 {
32
3332 struct Args
3433 {
3534 friend class CmdlineParser<Args>;
6463 static const char* const dumping_mode;
6564 static const char* const analysis_mode;
6665 static const char* const draining_mode;
66
6767 private:
6868 static Opt options[num];
6969
7474 } // namespace controller
7575 } // namespace NST
7676 //------------------------------------------------------------------------------
77 #endif//CMDLINE_PARSER_H
77 #endif // CMDLINE_PARSER_H
7878 //------------------------------------------------------------------------------
3636 {
3737 namespace cmdline
3838 {
39
4039 class CLIError : public std::runtime_error
4140 {
4241 public:
43 explicit CLIError(const std::string& msg) : std::runtime_error{msg} { }
42 explicit CLIError(const std::string& msg)
43 : std::runtime_error{msg}
44 {
45 }
4446 };
4547
4648 struct Opt
4749 {
50 // clang-format off
4851 class Value
4952 {
5053 public:
7376 const char* value_pattern;
7477 const char* value;
7578 bool passed; // is option parsed
79
80 // clang-format on
7681 };
77
7882
7983 template <typename CLI>
8084 class CmdlineParser
8185 {
8286 public:
83 CmdlineParser() = default;
84 virtual ~CmdlineParser() = default;
85 CmdlineParser(const CmdlineParser&) = delete;
86 CmdlineParser& operator=(const CmdlineParser&) = delete;
87 CmdlineParser() = default;
88 virtual ~CmdlineParser() = default;
89 CmdlineParser(const CmdlineParser&) = delete;
90 CmdlineParser& operator=(const CmdlineParser&) = delete;
8791
8892 void parse(int argc, char** argv);
8993 void validate();
101105 static bool is_default(typename CLI::Names name)
102106 {
103107 const Opt& a = CLI::options[name];
104 return a.value == a.deflt; // compare pointers
108 return a.value == a.deflt; // compare pointers
105109 }
106110
107111 static void print_usage(std::ostream& out, const char* executable);
108112
109113 private:
110 virtual void set_multiple_value(int /*index*/, char *const /*v*/){}
111
112 void set_value(int index, char *const v)
114 virtual void set_multiple_value(int /*index*/, char* const /*v*/) {}
115 void set_value(int index, char* const v)
113116 {
114117 Opt& a = CLI::options[index];
115118 // if option argument specified - set it otherwise
116119 // set valid default OR "true" for no-args options
117 a.value = v ? v : (a.deflt && a.type != Opt::Type::NOA ? a.deflt : "true");
120 a.value = v ? v : (a.deflt && a.type != Opt::Type::NOA ? a.deflt : "true");
118121 a.passed = true;
119122
120123 if(a.type == Opt::Type::MUL)
127130 {
128131 if(short_name)
129132 {
130 return { '\'', '-', short_name, '\'' };
133 return {'\'', '-', short_name, '\''};
131134 }
132135 return std::string{'\''} + long_name + '\'';
133136 }
150153 {
151154 // generate input data for getopt_long()
152155 option long_opts[CLI::num + 1]; // +1 for NULL-option
153 char short_opts[CLI::num * 2 + 2] = {0};
156 char short_opts[CLI::num * 2 + 2] = {0};
154157
155158 short_opts[0] = ':';
156159
157 char *short_p = &short_opts[1];
158 for (int i = 0; i < CLI::num; ++i)
160 char* short_p = &short_opts[1];
161 for(int i = 0; i < CLI::num; ++i)
159162 {
160163 const Opt& a = CLI::options[i];
161164
199202
200203 case '?':
201204 {
202 std::string unkn{ build_name(optopt, argv[optind-1]) };
205 std::string unkn{build_name(optopt, argv[optind - 1])};
203206 throw CLIError{std::string{"Unrecognized option: "} + unkn};
204207 }
205208
206209 case ':':
207210 {
208 std::string miss{ build_name(optopt, argv[optind-1]) };
211 std::string miss{build_name(optopt, argv[optind - 1])};
209212 throw CLIError{std::string{"Option requires an argument: "} + miss};
210213 }
211214
225228 if(optind != argc)
226229 {
227230 // quote non-option
228 std::string name{ build_name(0, argv[optind]) };
229 throw CLIError{std::string{"Unexpected operand on command line: "}
230 + name};
231 std::string name{build_name(0, argv[optind])};
232 throw CLIError{std::string{"Unexpected operand on command line: "} + name};
231233 }
232234
233235 // set default values
234236 for(Opt& o : CLI::options)
235237 {
236 if(o.value == nullptr // is value still uninitialized?
237 && o.deflt != nullptr) // try to substitute by default value
238 {
239 o.value = o.deflt;
238 if(o.value == nullptr // is value still uninitialized?
239 && o.deflt != nullptr) // try to substitute by default value
240 {
241 o.value = o.deflt;
240242 o.passed = false;
241243 }
242244 }
250252 {
251253 if(o.value == nullptr) // is value still uninitialized?
252254 {
253 std::string lopt{ o.long_opt ? std::string("--") + o.long_opt : ""};
254 std::string name{ build_name(o.short_opt, lopt) };
255 std::string lopt{o.long_opt ? std::string("--") + o.long_opt : ""};
256 std::string name{build_name(o.short_opt, lopt)};
255257 throw CLIError{std::string{"Missing required option: "} + name};
256258 }
257259 }
270272
271273 if(o.short_opt) // print out short key
272274 {
273 char tmp[]{ '-', o.short_opt, ' ', '\0' };
275 char tmp[]{'-', o.short_opt, ' ', '\0'};
274276 if(o.long_opt) tmp[2] = ',';
275 s_opt = std::string{" "} + tmp; //indentation
277 s_opt = std::string{" "} + tmp; //indentation
276278 }
277279 if(o.long_opt) // print out long key
278280 {
308310 } // namespace controller
309311 } // namespace NST
310312 //------------------------------------------------------------------------------
311 #endif//CMDLINE_PARSER_H
312 //------------------------------------------------------------------------------
313 #endif // CMDLINE_PARSER_H
314 //------------------------------------------------------------------------------
2525 #include <sys/types.h>
2626 #include <unistd.h>
2727
28 #include "utils/filtered_data.h"
2928 #include "controller/controller.h"
3029 #include "controller/parameters.h"
30 #include "utils/filtered_data.h"
3131 //------------------------------------------------------------------------------
3232 namespace NST
3333 {
3434 namespace controller
3535 {
36
36 // clang-format off
3737 Controller::Running::Running(Controller& i)
3838 : controller(i)
3939 {
5656 controller.analysis->stop();
5757 }
5858 }
59
59 // clang-format off
6060 Controller::Controller(const Parameters& params) try
6161 : gout {utils::Out::Level(params.verbose_level())}
6262 , glog {params.log_path()}
6464 , analysis {}
6565 , filtration {new FiltrationManager{status}}
6666 {
67 // clang-format on
6768 switch(params.running_mode())
6869 {
69 case RunningMode::Profiling:
70 {
71 analysis.reset(new AnalysisManager{status, params});
72 if(analysis->isSilent())
73 utils::Out::Global::set_level(utils::Out::Level::Silent);
74
75 filtration->add_online_analysis(params, analysis->get_queue());
76 }
77 break;
78 case RunningMode::Dumping:
79 {
80 filtration->add_online_dumping(params);
81 }
82 break;
83 case RunningMode::Analysis:
84 {
85 analysis.reset(new AnalysisManager{status, params});
86 if(analysis->isSilent())
87 utils::Out::Global::set_level(utils::Out::Level::Silent);
88
89 filtration->add_offline_analysis(params.input_file(),
90 analysis->get_queue());
91 }
92 break;
93 case RunningMode::Draining:
94 {
95 filtration->add_offline_dumping(params);
96 }
97 break;
70 case RunningMode::Profiling:
71 {
72 analysis.reset(new AnalysisManager{status, params});
73 if(analysis->isSilent())
74 utils::Out::Global::set_level(utils::Out::Level::Silent);
75
76 filtration->add_online_analysis(params, analysis->get_queue());
77 }
78 break;
79 case RunningMode::Dumping:
80 {
81 filtration->add_online_dumping(params);
82 }
83 break;
84 case RunningMode::Analysis:
85 {
86 analysis.reset(new AnalysisManager{status, params});
87 if(analysis->isSilent())
88 utils::Out::Global::set_level(utils::Out::Level::Silent);
89
90 filtration->add_offline_analysis(params.input_file(),
91 analysis->get_queue());
92 }
93 break;
94 case RunningMode::Draining:
95 {
96 filtration->add_offline_dumping(params);
97 }
98 break;
9899 }
99100 droproot(params.dropuser());
100101 }
187188 }
188189 else if(!dropuser.empty())
189190 {
190 struct passwd *pw = getpwnam(dropuser.c_str()); //get user uid & gid
191 struct passwd* pw = getpwnam(dropuser.c_str()); //get user uid & gid
191192
192193 if(!pw)
193194 {
2525 #include <memory>
2626
2727 #include "analysis/analysis_manager.h"
28 #include "filtration/filtration_manager.h"
2928 #include "controller/parameters.h"
3029 #include "controller/running_status.h"
3130 #include "controller/signal_handler.h"
31 #include "filtration/filtration_manager.h"
3232 #include "utils/log.h"
3333 #include "utils/out.h"
3434 //------------------------------------------------------------------------------
3636 {
3737 namespace controller
3838 {
39
4039 class ControllerError : public std::runtime_error
4140 {
4241 public:
43 explicit ControllerError(const std::string& msg) : std::runtime_error{msg} { }
42 explicit ControllerError(const std::string& msg)
43 : std::runtime_error{msg}
44 {
45 }
4446 };
4547
4648 class Controller
5254 {
5355 public:
5456 inline Running(Controller&);
55 Running() = delete;
56 Running(const Running&) = delete;
57 Running& operator=(const Running&) = delete;
57 Running() = delete;
58 Running(const Running&) = delete;
59 Running& operator=(const Running&) = delete;
5860 inline ~Running();
61
5962 private:
6063 Controller& controller;
6164 };
6265
6366 public:
64
6567 Controller(const Parameters&);
66 Controller(const Controller&) = delete;
68 Controller(const Controller&) = delete;
6769 Controller& operator=(const Controller&) = delete;
6870 ~Controller();
6971
7072 int run();
7173
7274 private:
73
7475 // initializer for global outptut
7576 utils::Out::Global gout;
7677 // initializer for global logger
8586 // controller subsystems
8687 std::unique_ptr<AnalysisManager> analysis;
8788 std::unique_ptr<FiltrationManager> filtration;
88
8989 };
9090
9191 /*! Drop root privileges
100100 } // namespace controller
101101 } // namespace NST
102102 //------------------------------------------------------------------------------
103 #endif//CONTROLLER_H
103 #endif // CONTROLLER_H
104104 //------------------------------------------------------------------------------
2424 #include <unistd.h>
2525
2626 #include "analysis/plugin.h"
27 #include "controller/build_info.h"
2728 #include "controller/cmdline_args.h"
2829 #include "controller/cmdline_parser.h"
2930 #include "controller/parameters.h"
30 #include "controller/build_info.h"
3131 #include "filtration/pcap/network_interfaces.h"
3232 //------------------------------------------------------------------------------
3333 namespace NST
3434 {
3535 namespace controller
3636 {
37
3837 namespace // implementation
3938 {
40
4139 static const class ParametersImpl* impl = nullptr;
4240
4341 using CLI = NST::controller::cmdline::Args;
4745 friend class NST::controller::Parameters;
4846
4947 ParametersImpl(int argc, char** argv)
50 : rpc_message_limit{0}
48 : rpc_message_limit{0}
5149 {
5250 parse(argc, argv);
5351 if(get(CLI::ArgHelp).to_bool())
5755
5856 for(const auto& a : analysis_modules)
5957 {
60 const std::string& path {a.path};
58 const std::string& path{a.path};
6159 try
6260 {
6361 std::cout << "Usage of " << path << ":\n";
8381 std::cout << i << '\n';
8482 for(auto a : i) std::cout << '\t' << a << '\n';
8583 }
86 std::cout << "[default]: " << interfaces.default_device() << '\n';
84 std::cout << "[default]: " << interfaces.default_device() << '\n';
8785 }
8886 else
8987 {
9088 std::cerr << "Note: Reading list of network interfaces may "
91 "require that you have special privileges." << std::endl;
89 "require that you have special privileges."
90 << std::endl;
9291 }
9392 }
9493
9594 if(get(CLI::ArgEnum).is("-") || get(CLI::ArgEnum).is("plugins"))
9695 {
9796 std::cout << "\nAvailable plugins:" << std::endl;
98 DIR *dir;
97 DIR* dir;
9998
10099 if((dir = opendir(MODULES_DIRECTORY_PATH)) != nullptr)
101100 {
102 struct dirent *ent;
101 struct dirent* ent;
103102 while((ent = readdir(dir)) != nullptr)
104103 {
105 std::string full_path = std::string{MODULES_DIRECTORY_PATH}
106 + ent->d_name;
104 std::string full_path = std::string{MODULES_DIRECTORY_PATH} + ent->d_name;
107105 std::string plugin_usage;
108106 try
109107 {
113111 std::cout << plugin_usage << std::endl;
114112 std::cout << std::endl;
115113 }
116 catch(std::runtime_error& e) { }
114 catch(std::runtime_error& e)
115 {
116 }
117117 }
118118 closedir(dir);
119119 }
120120 else
121121 {
122 std::cerr << "Error: Can't access " << MODULES_DIRECTORY_PATH <<std::endl;
122 std::cerr << "Error: Can't access " << MODULES_DIRECTORY_PATH << std::endl;
123123 }
124124 }
125125
127127
128128 // cashed values
129129 const std::string program_path(argv[0]);
130 size_t found {program_path.find_last_of("/\\")};
131 program = program_path.substr(found+1);
132
133 const int limit {get(CLI::ArgMSize).to_int()};
130 size_t found{program_path.find_last_of("/\\")};
131 program = program_path.substr(found + 1);
132
133 const int limit{get(CLI::ArgMSize).to_int()};
134134 if(limit < 1 || limit > 4000)
135135 {
136136 throw cmdline::CLIError{std::string{"Invalid limit of RPC messages: "} + get(CLI::ArgMSize).to_cstr()};
138138
139139 rpc_message_limit = limit;
140140 }
141 virtual ~ParametersImpl(){}
142 ParametersImpl(const ParametersImpl&) = delete;
141 virtual ~ParametersImpl() {}
142 ParametersImpl(const ParametersImpl&) = delete;
143143 ParametersImpl& operator=(const ParametersImpl&) = delete;
144144
145145 protected:
146 void set_multiple_value(int index, char *const v) override
146 void set_multiple_value(int index, char* const v) override
147147 {
148148 if(index == CLI::ArgAnalyzers) // may have multiple values
149149 {
150150 const std::string arg{v};
151 size_t ind {arg.find('#')};
151 size_t ind{arg.find('#')};
152152 if(ind == std::string::npos)
153153 {
154154 analysis_modules.emplace_back(path_to_pam(arg));
166166 std::string default_iofile() const
167167 {
168168 // create string: PROGRAMNAME-BPF-FILTER.pcap
169 std::string str { impl->program };
169 std::string str{impl->program};
170170 str.push_back('-');
171171 str.append(get(CLI::ArgFilter).to_cstr());
172172 str.append(".pcap");
190190 }
191191
192192 // cashed values
193 unsigned short rpc_message_limit;
194 std::string program; // name of program in command line
193 unsigned short rpc_message_limit;
194 std::string program; // name of program in command line
195195 std::vector<AParams> analysis_modules;
196196 };
197197
268268 const int capacity = impl->get(CLI::ArgQSize).to_int();
269269 if(capacity < 1 || capacity > 65535)
270270 {
271 throw cmdline::CLIError(std::string{"Invalid value of queue capacity: "}
272 + impl->get(CLI::ArgQSize).to_cstr());
271 throw cmdline::CLIError(std::string{"Invalid value of queue capacity: "} + impl->get(CLI::ArgQSize).to_cstr());
273272 }
274273
275274 return capacity;
289288 const Parameters::CaptureParams Parameters::capture_params() const
290289 {
291290 Parameters::CaptureParams params;
292 params.interface = impl->get(CLI::ArgInterface);
293 params.filter = impl->get(CLI::ArgFilter);
294 params.snaplen = impl->get(CLI::ArgSnaplen).to_int();
295 params.timeout_ms = impl->get(CLI::ArgTimeout).to_int();
296 params.buffer_size = impl->get(CLI::ArgBSize).to_int() * 1024 * 1024; // MBytes
297 params.promisc = impl->get(CLI::ArgPromisc).to_bool();
291 params.interface = impl->get(CLI::ArgInterface);
292 params.filter = impl->get(CLI::ArgFilter);
293 params.snaplen = impl->get(CLI::ArgSnaplen).to_int();
294 params.timeout_ms = impl->get(CLI::ArgTimeout).to_int();
295 params.buffer_size = impl->get(CLI::ArgBSize).to_int() * 1024 * 1024; // MBytes
296 params.promisc = impl->get(CLI::ArgPromisc).to_bool();
298297
299298 // check interface
300299 if(impl->is_default(CLI::ArgInterface))
305304 // check capture buffer size
306305 if(params.buffer_size < 1024 * 1024) // less than 1 MBytes
307306 {
308 throw cmdline::CLIError{std::string{"Invalid value of kernel buffer size: "}
309 + impl->get(CLI::ArgBSize).to_cstr()};
307 throw cmdline::CLIError{std::string{"Invalid value of kernel buffer size: "} + impl->get(CLI::ArgBSize).to_cstr()};
310308 }
311309
312310 // check max length of raw captured UDP packet
313311 if(params.snaplen < 1 || params.snaplen > 65535)
314312 {
315 throw cmdline::CLIError{std::string{"Invalid value of max length of raw captured UDP packet: "}
316 + impl->get(CLI::ArgSnaplen).to_cstr()};
313 throw cmdline::CLIError{std::string{"Invalid value of max length of raw captured UDP packet: "} + impl->get(CLI::ArgSnaplen).to_cstr()};
317314 }
318315
319316 // check the read timeout that will be used on a capture
320317 if(params.timeout_ms < 1)
321318 {
322 throw cmdline::CLIError{std::string{"Invalid value of read timeout that will be used on a capture: "}
323 + impl->get(CLI::ArgTimeout).to_cstr()};
319 throw cmdline::CLIError{std::string{"Invalid value of read timeout that will be used on a capture: "} + impl->get(CLI::ArgTimeout).to_cstr()};
324320 }
325321
326322 // check and set capture direction
339335 }
340336 else
341337 {
342 throw cmdline::CLIError{std::string{"Unknown capturing direction: "}
343 + direction.to_cstr()};
338 throw cmdline::CLIError{std::string{"Unknown capturing direction: "} + direction.to_cstr()};
344339 }
345340
346341 return params;
3131 {
3232 namespace controller
3333 {
34
3534 enum class RunningMode
3635 {
3736 Profiling,
4241
4342 struct AParams
4443 {
45 AParams(const std::string& p) : path{p}, args{} {}
46 AParams(const std::string& p, const std::string& a) : path{p}, args{a} {}
44 AParams(const std::string& p)
45 : path{p}
46 , args{}
47 {
48 }
49 AParams(const std::string& p, const std::string& a)
50 : path{p}
51 , args{a}
52 {
53 }
4754
4855 const std::string path;
4956 const std::string args;
5360 */
5461 enum class NetProtocol
5562 {
56 NFS = 0x01, //!< NFS protocol
57 CIFS = 0x02 //!< CIFS protocol
63 NFS = 0x01, //!< NFS protocol
64 CIFS = 0x02 //!< CIFS protocol
5865 };
5966
6067 class Parameters
6774 Parameters(int argc, char** argv);
6875 ~Parameters();
6976
70 Parameters(const Parameters&) = delete;
77 Parameters(const Parameters&) = delete;
7178 Parameters& operator=(const Parameters&) = delete;
7279
7380 bool show_help() const;
7481 bool show_enum() const;
7582
7683 // access helpers
77 const std::string& program_name() const;
78 RunningMode running_mode() const;
79 std::string input_file() const;
80 const std::string dropuser() const;
81 const std::string log_path() const;
82 unsigned short queue_capacity() const;
83 bool trace() const;
84 int verbose_level() const;
85 const CaptureParams capture_params() const;
86 const DumpingParams dumping_params() const;
84 const std::string& program_name() const;
85 RunningMode running_mode() const;
86 std::string input_file() const;
87 const std::string dropuser() const;
88 const std::string log_path() const;
89 unsigned short queue_capacity() const;
90 bool trace() const;
91 int verbose_level() const;
92 const CaptureParams capture_params() const;
93 const DumpingParams dumping_params() const;
8794 const std::vector<AParams>& analysis_modules() const;
88 static unsigned short rpcmsg_limit();
95 static unsigned short rpcmsg_limit();
8996 };
9097
9198 } // namespace controller
9299 } // namespace NST
93100 //------------------------------------------------------------------------------
94 #endif//PARAMETERS_H
101 #endif // PARAMETERS_H
95102 //------------------------------------------------------------------------------
2121 #ifndef RUNNING_STATUS_H
2222 #define RUNNING_STATUS_H
2323 //------------------------------------------------------------------------------
24 #include <condition_variable>
2524 #include <exception>
2625 #include <iostream>
2726 #include <list>
2827 #include <mutex>
28 #include <condition_variable>
2929 #include <type_traits>
3030 //------------------------------------------------------------------------------
3131 namespace NST
3232 {
3333 namespace controller
3434 {
35
3635 class ProcessingDone : public std::runtime_error
3736 {
3837 public:
39 explicit ProcessingDone(const std::string& in) : std::runtime_error{in} { }
38 explicit ProcessingDone(const std::string& in)
39 : std::runtime_error{in}
40 {
41 }
4042 };
4143
4244 class RunningStatus
4345 {
4446 public:
45 RunningStatus() = default;
46 RunningStatus(const RunningStatus&) = delete;
47 RunningStatus() = default;
48 RunningStatus(const RunningStatus&) = delete;
4749 RunningStatus& operator=(const RunningStatus&) = delete;
4850
4951 template <typename ExceptionType>
6264 std::exception_ptr wait_exception()
6365 {
6466 std::unique_lock<std::mutex> lock(mutex);
65 while(fifo.empty())
66 {
67 condition.wait(lock);
68 }
69 std::exception_ptr e = fifo.front();
70 fifo.pop_front();
71 return e;
67 while(fifo.empty())
68 {
69 condition.wait(lock);
70 }
71 std::exception_ptr e = fifo.front();
72 fifo.pop_front();
73 return e;
7274 }
7375
7476 void wait_and_rethrow_exception()
8082 void print(std::ostream& out)
8183 {
8284 std::unique_lock<std::mutex> lock(mutex);
83 if(!fifo.empty())
85 if(!fifo.empty())
86 {
87 out << "list of unhandled exceptions:" << std::endl;
88 for(auto& e : fifo)
8489 {
85 out << "list of unhandled exceptions:" << std::endl;
86 for(auto& e : fifo)
90 try
8791 {
88 try
89 {
90 std::rethrow_exception(e);
91 }
92 catch(const std::exception& e)
93 {
94 out << '\t' << e.what() << std::endl;
95 }
96 catch(...)
97 {
98 out << '\t' << "Unknown exception" << std::endl;
99 }
92 std::rethrow_exception(e);
93 }
94 catch(const std::exception& e)
95 {
96 out << '\t' << e.what() << std::endl;
97 }
98 catch(...)
99 {
100 out << '\t' << "Unknown exception" << std::endl;
100101 }
101102 }
103 }
102104 }
103105
104106 private:
106108 {
107109 if(e == nullptr) return;
108110 std::unique_lock<std::mutex> lock(mutex);
109 fifo.emplace_front(e);
110 condition.notify_one();
111 fifo.emplace_front(e);
112 condition.notify_one();
111113 }
112114
113115 std::list<std::exception_ptr> fifo;
114 std::mutex mutex;
115 std::condition_variable condition;
116 std::mutex mutex;
117 std::condition_variable condition;
116118 };
117119
118120 } // namespace controller
119121 } // namespace NST
120122 //------------------------------------------------------------------------------
121 #endif//RUNNING_STATUS_H
123 #endif // RUNNING_STATUS_H
122124 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <cerrno>
22 #include <functional> // std::ref
22 #include <functional> // std::ref
2323 #include <system_error>
2424
25 #include <unistd.h>
2625 #include <pthread.h>
2726 #include <signal.h>
28 #include <string.h> // for strsignal()
27 #include <string.h> // for strsignal()
28 #include <unistd.h>
2929
3030 #include <sys/wait.h>
3131
3535 {
3636 namespace controller
3737 {
38
3938 SignalHandler::Signal::Signal(int sig)
40 : std::runtime_error{::strsignal(sig)}
41 , signal_number{sig}
39 : std::runtime_error{::strsignal(sig)}
40 , signal_number{sig}
4241 {
4342 }
4443
4948 {
5049 while(running.test_and_set())
5150 {
52 int signo {0};
53 const int err {::sigwait(&waitmask, &signo)};
51 int signo{0};
52 const int err{::sigwait(&waitmask, &signo)};
5453 if(err != 0)
5554 {
5655 status.push(std::system_error{err, std::system_category(),
6160 if(signo == SIGCHLD)
6261 {
6362 // wait childern(compression in dumping mode may call fork())
64 const pid_t pid {::wait(nullptr)};
63 const pid_t pid{::wait(nullptr)};
6564 if(pid == -1 && errno != ECHILD)
6665 {
6766 status.push(std::system_error{errno, std::system_category(),
7574 }
7675 }
7776
78 static void dummy(int) {}
77 static void dummy(int)
78 {
79 }
7980
8081 SignalHandler::SignalHandler(RunningStatus& s)
81 : handler{}
82 , running{ATOMIC_FLAG_INIT} // false
82 : handler{}
83 , running{ATOMIC_FLAG_INIT} // false
8384 {
8485 // set dummy handler for SIGCHLD to prevent ignoring it
8586 // in ::sigwait() on FreeBSD by default
9495
9596 sigset_t mask;
9697 ::sigemptyset(&mask);
97 ::sigaddset(&mask, SIGINT); // correct exit from program by Ctrl-C
98 ::sigaddset(&mask, SIGTERM); // correct exit when SIGTERM has been received
99 ::sigaddset(&mask, SIGCHLD); // stop sigwait-thread and wait children
100 ::sigaddset(&mask, SIGHUP); // signal for losing terminal
101 ::sigaddset(&mask, SIGWINCH); // signal for changing terminal size
98 ::sigaddset(&mask, SIGINT); // correct exit from program by Ctrl-C
99 ::sigaddset(&mask, SIGTERM); // correct exit when SIGTERM has been received
100 ::sigaddset(&mask, SIGCHLD); // stop sigwait-thread and wait children
101 ::sigaddset(&mask, SIGHUP); // signal for losing terminal
102 ::sigaddset(&mask, SIGWINCH); // signal for changing terminal size
102103 const int err = ::pthread_sigmask(SIG_BLOCK, &mask, nullptr);
103104 if(err != 0)
104105 {
105106 throw std::system_error(err, std::system_category(),
106 "error in SignalHandler pthread_sigmask");
107 "error in SignalHandler pthread_sigmask");
107108 }
108109
109110 running.test_and_set();
120121 } // namespace controller
121122 } // namespace NST
122123 //------------------------------------------------------------------------------
123
3131 {
3232 namespace controller
3333 {
34
3534 class SignalHandler
3635 {
3736 public:
4342 };
4443
4544 SignalHandler(RunningStatus&);
46 SignalHandler(const SignalHandler&) = delete;
45 SignalHandler(const SignalHandler&) = delete;
4746 SignalHandler& operator=(const SignalHandler&) = delete;
4847 ~SignalHandler();
4948
5049 private:
51 std::thread handler;
50 std::thread handler;
5251 std::atomic_flag running;
5352 };
5453
5554 } // namespace controller
5655 } // namespace NST
5756 //------------------------------------------------------------------------------
58 #endif//SIGNAL_HANDLER_H
57 #endif // SIGNAL_HANDLER_H
5958 //------------------------------------------------------------------------------
2626
2727 #include <pcap/pcap.h>
2828
29 #include "filtration/packet.h"
29 #include "api/cifs2_commands.h"
3030 #include "filtration/filtratorimpl.h"
3131 #include "protocols/cifs/cifs.h"
3232 #include "protocols/cifs2/cifs2.h"
3333 #include "protocols/netbios/netbios.h"
3434 #include "utils/log.h"
35 #include "api/cifs2_commands.h"
3635 //------------------------------------------------------------------------------
3736 namespace NST
3837 {
3938 namespace filtration
4039 {
41
4240 using SMBv2Commands = NST::API::SMBv2::SMBv2Commands;
4341
44 template<typename Writer>
42 template <typename Writer>
4543 class CIFSFiltrator : public FiltratorImpl<CIFSFiltrator<Writer>, Writer>
4644 {
4745 using BaseImpl = FiltratorImpl<CIFSFiltrator<Writer>, Writer>;
48 size_t rw_hdr_max {512}; // limit for SMB header to truncate messages
46 size_t rw_hdr_max{512}; // limit for SMB header to truncate messages
4947 public:
50
5148 CIFSFiltrator()
5249 : BaseImpl()
5350 {
9895 {
9996 size_t length = 0;
10097 if(collection && collection.data_size() >= lengthOfBaseHeader())
101 { //enough data is copied from previous packets to see its type
98 { //enough data is copied from previous packets to see its type
10299 if(isCIFSV1Header(collection.data()))
103100 {
104101 length = sizeof(NetBIOS::MessageHeader) + sizeof(CIFSv1::RawMessageHeader);
108105 length = sizeof(NetBIOS::MessageHeader) + sizeof(CIFSv2::RawMessageHeader);
109106 }
110107 else
111 { //got header but it is not CIFS
112 collection.reset();//dismiss copied data
113 info.dlen = 0;//skip entire packet
108 { //got header but it is not CIFS
109 collection.reset(); //dismiss copied data
110 info.dlen = 0; //skip entire packet
114111 return false;
115112 }
116113 return BaseImpl::collect_header(info, length, length);
117114 }
118 BaseImpl::collect_header(info, lengthOfBaseHeader(), lengthOfBaseHeader());//try to read base header
119 return false;//continue to read full header
115 BaseImpl::collect_header(info, lengthOfBaseHeader(), lengthOfBaseHeader()); //try to read base header
116 return false; //continue to read full header
120117 }
121118
122119 inline bool find_and_read_message(PacketInfo& info, typename Writer::Collection& collection)
123120 {
124 if (const NetBIOS::MessageHeader* nb_header = NetBIOS::get_header(collection.data()))
121 if(const NetBIOS::MessageHeader* nb_header = NetBIOS::get_header(collection.data()))
125122 {
126123 const size_t length = nb_header->len() + sizeof(NetBIOS::MessageHeader);
127 if (const CIFSv1::MessageHeader* header = CIFSv1::get_header(collection.data() + sizeof(NetBIOS::MessageHeader)))
124 if(const CIFSv1::MessageHeader* header = CIFSv1::get_header(collection.data() + sizeof(NetBIOS::MessageHeader)))
128125 {
129126 BaseImpl::setMsgLen(length);
130127 set_msg_size(header, length);
131128 return BaseImpl::read_message(info);
132129 }
133 else if (const CIFSv2::MessageHeader* header = CIFSv2::get_header(collection.data() + sizeof(NetBIOS::MessageHeader)))
130 else if(const CIFSv2::MessageHeader* header = CIFSv2::get_header(collection.data() + sizeof(NetBIOS::MessageHeader)))
134131 {
135132 BaseImpl::setMsgLen(length);
136133 set_msg_size(header, length);
143140 private:
144141 inline void set_msg_size(const CIFSv1::MessageHeader* header, const size_t length)
145142 {
146 if ((header->cmd_code == CIFSv1::Commands::READ) || (header->cmd_code == CIFSv1::Commands::WRITE))
143 if((header->cmd_code == CIFSv1::Commands::READ) || (header->cmd_code == CIFSv1::Commands::WRITE))
147144 {
148145 return BaseImpl::setToBeCopied(std::min(length, rw_hdr_max));
149146 }
152149
153150 inline void set_msg_size(const CIFSv2::MessageHeader* header, const size_t length)
154151 {
155 if (((header->cmd_code == SMBv2Commands::READ) || (header->cmd_code == SMBv2Commands::WRITE)) && !header->nextCommand)
152 if(((header->cmd_code == SMBv2Commands::READ) || (header->cmd_code == SMBv2Commands::WRITE)) && !header->nextCommand)
156153 {
157154 return BaseImpl::setToBeCopied(std::min(length, rw_hdr_max));
158155 }
159156 BaseImpl::setToBeCopied(length);
160157 }
161
162158 };
163159
164160 } // namespace filtration
165161 } // namespace NST
166162 //------------------------------------------------------------------------------
167 #endif//CIFS_FILTRATOR_H
163 #endif // CIFS_FILTRATOR_H
168164 //------------------------------------------------------------------------------
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <cerrno>
22 #include <exception> // std::terminate()
22 #include <exception> // std::terminate()
2323 #include <vector>
2424
2525 #include <unistd.h>
3030 {
3131 namespace filtration
3232 {
33
34 Dumping::Dumping(pcap_t*const h, const Params& params)
35 : handle {h}
36 , base {params.output_file}
37 , name {params.output_file}
38 , command {params.command}
39 , limit {params.size_limit}
40 , part {0}
41 , size {0}
33 Dumping::Dumping(pcap_t* const h, const Params& params)
34 : handle{h}
35 , base{params.output_file}
36 , name{params.output_file}
37 , command{params.command}
38 , limit{params.size_limit}
39 , part{0}
40 , size{0}
4241 {
4342 open_dumping_file(name);
4443 }
4948
5049 void Dumping::open_dumping_file(const std::string& file_path)
5150 {
52 const char* path {file_path.c_str()};
51 const char* path{file_path.c_str()};
5352 LOG("Dumping packets to file:%s", path);
5453 dumper.reset(new pcap::PacketDumper{handle, path});
5554 }
6463 {
6564 if(command.empty()) return;
6665
67 NST::utils::Log::flush(); // flush buffer
66 NST::utils::Log::flush(); // flush buffer
6867
6968 if(pid_t pid = fork()) // spawn child process
7069 {
7170 // parent process
7271 LOG("Try to execute(%s %s) in %u child process", command.c_str(), name.c_str(), pid);
73 NST::utils::Log::flush(); // flush buffer
72 NST::utils::Log::flush(); // flush buffer
7473 return;
7574 }
7675 else
7776 {
7877 // child process
79 std::istringstream ss(command);
78 std::istringstream ss(command);
8079 std::vector<std::string> tokens;
81 std::vector<char*> args;
80 std::vector<char*> args;
8281
8382 // TODO: this parser doesn't work with dual quotes, like rm "a file.cpp"
8483 for(std::string arg; ss >> arg;)
8584 {
86 tokens.emplace_back(arg);
87 args .emplace_back(const_cast<char*>(tokens.back().c_str()));
85 tokens.emplace_back(arg);
86 args.emplace_back(const_cast<char*>(tokens.back().c_str()));
8887 }
8988 args.push_back(const_cast<char*>(name.c_str()));
90 args.push_back(nullptr); // need termination null pointer
89 args.push_back(nullptr); // need termination null pointer
9190
9291 if(execvp(args[0], &args[0]) == -1)
9392 {
107106 return out;
108107 }
109108
110
111109 } // namespace filtration
112110 } // namespace NST
113111 //------------------------------------------------------------------------------
3636 {
3737 namespace filtration
3838 {
39
4039 class Dumping
4140 {
4241 public:
43
4442 class Collection
4543 {
4644 private:
47 const static int cache_size {4096};
45 const static int cache_size{4096};
4846
4947 public:
5048 inline Collection()
51 : dumper {nullptr}
52 , buff_size {cache_size}
53 , payload {cache}
54 , payload_len {0}
49 : dumper{nullptr}
50 , buff_size{cache_size}
51 , payload{cache}
52 , payload_len{0}
5553 {
5654 }
5755 inline Collection(Dumping* d, utils::NetworkSession* /*unused*/)
58 : dumper {d}
59 , buff_size {cache_size}
60 , payload {cache}
61 , payload_len {0}
56 : dumper{d}
57 , buff_size{cache_size}
58 , payload{cache}
59 , payload_len{0}
6260 {
6361 }
6462 inline ~Collection()
6664 if(payload != cache)
6765 delete[] payload;
6866 }
69 Collection(Collection&&) = delete;
70 Collection(const Collection&) = delete;
67 Collection(Collection&&) = delete;
68 Collection(const Collection&) = delete;
7169 Collection& operator=(const Collection&) = delete;
7270
7371 inline void set(Dumping& d, utils::NetworkSession* /*unused*/)
9088 inline void resize(uint32_t amount)
9189 {
9290 buff_size = amount;
93 uint8_t* buff {new uint8_t[amount]};
91 uint8_t* buff{new uint8_t[amount]};
9492 memcpy(buff, payload, payload_len);
9593 if(payload != cache)
9694 delete[] payload;
9997
10098 inline void push(const PacketInfo& info, const uint32_t len)
10199 {
102 if(info.dumped) // if this packet not dumped yet
100 if(info.dumped) // if this packet not dumped yet
103101 {
104102 TRACE("The packet was collected before");
105103 }
107105 {
108106 // direct dumping without waiting completeness of analysis and complete() call
109107 dumper->dump(info.header, info.packet);
110 info.dumped = true; // set marker of damped packet
108 info.dumped = true; // set marker of damped packet
111109 }
112110 if((payload_len + len) > capacity())
113111 {
114112 resize(payload_len + len);
115113 }
116114 // copy payload
117 memcpy(payload+payload_len, info.data, len);
115 memcpy(payload + payload_len, info.data, len);
118116 payload_len += len;
119117 }
120118
128126 reset();
129127 }
130128
131 inline uint32_t data_size() const { return payload_len; }
132 inline uint32_t capacity() const { return buff_size; }
133 inline const uint8_t* data() const { return payload; }
134 inline operator bool() const { return dumper != nullptr; }
135
129 inline uint32_t data_size() const { return payload_len; }
130 inline uint32_t capacity() const { return buff_size; }
131 inline const uint8_t* data() const { return payload; }
132 inline operator bool() const { return dumper != nullptr; }
136133 private:
137134 Dumping* dumper;
138135 uint32_t buff_size;
139136 uint8_t* payload;
140 uint8_t cache[cache_size];
137 uint8_t cache[cache_size];
141138 uint32_t payload_len;
142139 };
143140
144141 struct Params
145142 {
146 std::string output_file{ };
147 std::string command { };
148 uint32_t size_limit {0};
143 std::string output_file{};
144 std::string command{};
145 uint32_t size_limit{0};
149146 };
150147
151 Dumping(pcap_t*const h, const Params& params);
148 Dumping(pcap_t* const h, const Params& params);
152149 ~Dumping();
153 Dumping(const Dumping&) = delete;
150 Dumping(const Dumping&) = delete;
154151 Dumping& operator=(const Dumping&) = delete;
155152
156153 inline void dump(const pcap_pkthdr* header, const u_char* packet)
157154 {
158155 if(limit)
159156 {
160 if( (size + sizeof(pcap_pkthdr) + header->caplen) > limit )
157 if((size + sizeof(pcap_pkthdr) + header->caplen) > limit)
161158 {
162159 close_dumping_file();
163160
183180 void exec_command() const;
184181
185182 std::unique_ptr<pcap::PacketDumper> dumper;
186 pcap_t* const handle;
187 const std::string base;
188 std::string name;
189 const std::string command;
190 const uint32_t limit;
191 uint32_t part;
192 uint32_t size;
183
184 pcap_t* const handle;
185 const std::string base;
186 std::string name;
187 const std::string command;
188 const uint32_t limit;
189 uint32_t part;
190 uint32_t size;
193191 };
194192
195193 std::ostream& operator<<(std::ostream& out, const Dumping::Params& params);
197195 } // namespace filtration
198196 } // namespace NST
199197 //------------------------------------------------------------------------------
200 #endif//DUMPING_H
201 //------------------------------------------------------------------------------
198 #endif // DUMPING_H
199 //------------------------------------------------------------------------------
3333 {
3434 namespace filtration
3535 {
36
3736 using CaptureReader = NST::filtration::pcap::CaptureReader;
3837 using FileReader = NST::filtration::pcap::FileReader;
3938
4342
4443 namespace // unnamed
4544 {
46
4745 // FiltrationProcessor in separate processing thread
48 template
49 <
46 template <
5047 typename Reader,
51 typename Writer
52 >
48 typename Writer>
5349 class FiltrationImpl : public ProcessingThread
5450 {
55 using Processor = FiltrationProcessor<Reader, Writer, Filtrators< Writer >>;
51 using Processor = FiltrationProcessor<Reader, Writer, Filtrators<Writer>>;
52
5653 public:
5754 explicit FiltrationImpl(std::unique_ptr<Reader>& reader,
5855 std::unique_ptr<Writer>& writer,
59 RunningStatus& status)
60 : ProcessingThread {status}
61 , processor{}
56 RunningStatus& status)
57 : ProcessingThread{status}
58 , processor{}
6259 {
6360 processor.reset(new Processor{reader, writer});
6461 }
65 ~FiltrationImpl() = default;
66 FiltrationImpl(const FiltrationImpl&) = delete;
62 ~FiltrationImpl() = default;
63 FiltrationImpl(const FiltrationImpl&) = delete;
6764 FiltrationImpl& operator=(const FiltrationImpl&) = delete;
6865
6966 virtual void stop() override final
7067 {
7168 processor->stop();
7269 }
70
7371 private:
74
7572 virtual void run() override final
7673 {
7774 try
8885 };
8986
9087 // create Filtration thread emplaced in unique_ptr
91 template
92 <
88 template <
9389 typename Reader,
94 typename Writer
95 >
90 typename Writer>
9691 static auto create_thread(std::unique_ptr<Reader>& reader,
9792 std::unique_ptr<Writer>& writer,
98 RunningStatus& status)
99 -> std::unique_ptr<FiltrationImpl<Reader, Writer>>
93 RunningStatus& status)
94 -> std::unique_ptr<FiltrationImpl<Reader, Writer>>
10095 {
10196 using Thread = FiltrationImpl<Reader, Writer>;
10297
10398 return std::unique_ptr<Thread>{new Thread{reader, writer, status}};
10499 }
105
106100
107101 // create CaptureReader from Parameters emplaced in unique_ptr
108102 static auto create_capture_reader(const Parameters& params)
109 -> std::unique_ptr<CaptureReader>
103 -> std::unique_ptr<CaptureReader>
110104 {
111105 auto& capture_params = params.capture_params();
112106 if(utils::Out message{}) // print parameters to user
113107 {
114108 message << capture_params;
115109 }
116 return std::unique_ptr<CaptureReader>{ new CaptureReader{capture_params} };
110 return std::unique_ptr<CaptureReader>{new CaptureReader{capture_params}};
117111 }
118112
119113 } // unnamed namespace
121115 // capture from network interface and dump to file - OnlineDumping(Dumping)
122116 void FiltrationManager::add_online_dumping(const Parameters& params)
123117 {
124 std::unique_ptr<CaptureReader> reader { create_capture_reader(params) };
118 std::unique_ptr<CaptureReader> reader{create_capture_reader(params)};
125119
126120 auto& dumping_params = params.dumping_params();
127121 if(utils::Out message{}) // print parameters to user
128122 {
129123 message << dumping_params;
130124 }
131 std::unique_ptr<Dumping> writer { new Dumping{ reader->get_handle(), dumping_params } };
125 std::unique_ptr<Dumping> writer{new Dumping{reader->get_handle(), dumping_params}};
132126 threads.emplace_back(create_thread(reader, writer, status));
133127 }
134128
135129 //capture data from input file or cin to destination file
136 void FiltrationManager::add_offline_dumping (const Parameters& params)
130 void FiltrationManager::add_offline_dumping(const Parameters& params)
137131 {
138132 auto& dumping_params = params.dumping_params();
139 auto& ofile = dumping_params.output_file;
140 auto ifile = params.input_file();
133 auto& ofile = dumping_params.output_file;
134 auto ifile = params.input_file();
141135
142136 if(ofile.compare("-"))
143137 {
151145 throw std::runtime_error{"Input and output files are equal. Use the -I and -O options to setup them explicitly."};
152146 }
153147 }
154
155 }
156 std::unique_ptr<FileReader> reader { new FileReader{ifile} };
148 }
149 std::unique_ptr<FileReader> reader{new FileReader{ifile}};
157150
158151 if(utils::Out message{}) // print parameters to user
159152 {
160153 message << *reader;
161154 }
162 std::unique_ptr<Dumping> writer { new Dumping{ reader->get_handle(),
163 dumping_params
164 }
165 };
155 std::unique_ptr<Dumping> writer{new Dumping{reader->get_handle(),
156 dumping_params}};
166157
167158 threads.emplace_back(create_thread(reader, writer, status));
168159 }
169160
170161 // capture from network interface and pass to queue - OnlineAnalysis(Profiling)
171 void FiltrationManager::add_online_analysis(const Parameters& params,
162 void FiltrationManager::add_online_analysis(const Parameters& params,
172163 FilteredDataQueue& queue)
173164 {
174 std::unique_ptr<CaptureReader> reader { create_capture_reader(params) };
175 std::unique_ptr<Queueing> writer { new Queueing{queue} };
165 std::unique_ptr<CaptureReader> reader{create_capture_reader(params)};
166 std::unique_ptr<Queueing> writer{new Queueing{queue}};
176167
177168 threads.emplace_back(create_thread(reader, writer, status));
178169 }
181172 void FiltrationManager::add_offline_analysis(const std::string& ifile,
182173 FilteredDataQueue& queue)
183174 {
184 std::unique_ptr<FileReader> reader { new FileReader{ifile} };
175 std::unique_ptr<FileReader> reader{new FileReader{ifile}};
185176 if(utils::Out message{}) // print parameters to user
186177 {
187178 message << *reader;
188179 }
189 std::unique_ptr<Queueing> writer { new Queueing{queue} };
180 std::unique_ptr<Queueing> writer{new Queueing{queue}};
190181
191182 threads.emplace_back(create_thread(reader, writer, status));
192183 }
193184
194185 FiltrationManager::FiltrationManager(RunningStatus& s)
195 : status(s)
186 : status(s)
196187 {
197188 if(utils::Out message{utils::Out::Level::All})
198189 {
3232 {
3333 namespace filtration
3434 {
35
3635 class FiltrationManager
3736 {
3837 using Parameters = NST::controller::Parameters;
4241 public:
4342 FiltrationManager(RunningStatus&);
4443 ~FiltrationManager();
45 FiltrationManager(const FiltrationManager&) = delete;
44 FiltrationManager(const FiltrationManager&) = delete;
4645 FiltrationManager& operator=(const FiltrationManager&) = delete;
4746
48 void add_online_dumping (const Parameters& params); // dump to file
49 void add_offline_dumping (const Parameters& params); // dump to file from input file
50 void add_online_analysis (const Parameters& params, FilteredDataQueue& queue); // capture to queue
51 void add_offline_analysis(const std::string& ifile, FilteredDataQueue& queue); // read file to queue
47 void add_online_dumping(const Parameters& params); // dump to file
48 void add_offline_dumping(const Parameters& params); // dump to file from input file
49 void add_online_analysis(const Parameters& params, FilteredDataQueue& queue); // capture to queue
50 void add_offline_analysis(const std::string& ifile, FilteredDataQueue& queue); // read file to queue
5251
5352 void start();
5453 void stop();
5554
5655 private:
57
5856 RunningStatus& status;
5957
60 std::vector< std::unique_ptr<class ProcessingThread> > threads;
58 std::vector<std::unique_ptr<class ProcessingThread>> threads;
6159 };
6260
6361 } // namespace filtration
6462 } // namespace NST
6563 //------------------------------------------------------------------------------
66 #endif//FILTRATION_MANAGER_H
64 #endif // FILTRATION_MANAGER_H
6765 //------------------------------------------------------------------------------
3131
3232 #include <pcap/pcap.h>
3333
34 #include "utils/log.h"
35 #include "utils/out.h"
36 #include "utils/sessions.h"
37 #include "utils/profiler.h"
3834 #include "controller/parameters.h"
3935 #include "filtration/packet.h"
4036 #include "filtration/sessions_hash.h"
41 #include "protocols/rpc/rpc_header.h"
4237 #include "protocols/nfs3/nfs3_utils.h"
4338 #include "protocols/nfs4/nfs4_utils.h"
39 #include "protocols/rpc/rpc_header.h"
40 #include "utils/log.h"
41 #include "utils/out.h"
42 #include "utils/profiler.h"
43 #include "utils/sessions.h"
4444 //------------------------------------------------------------------------------
4545 namespace NST
4646 {
4747 namespace filtration
4848 {
49
50 using namespace NST::protocols::rpc;//FIXME: It is not good to use "using" in headers - should be removed
49 using namespace NST::protocols::rpc; //FIXME: It is not good to use "using" in headers - should be removed
5150 using ProcEnumNFS3 = API::ProcEnumNFS3;
5251 using NFS3Validator = NST::protocols::NFS3::Validator;
5352 using NFS4Validator = NST::protocols::NFS4::Validator;
6665 {
6766 public:
6867 UDPSession(Writer* w, uint32_t max_rpc_hdr)
69 : collection{w, this}
70 , nfs3_rw_hdr_max{max_rpc_hdr}
71 {
72 }
73 UDPSession(UDPSession&&) = delete;
74 UDPSession(const UDPSession&) = delete;
68 : collection{w, this}
69 , nfs3_rw_hdr_max{max_rpc_hdr}
70 {
71 }
72 UDPSession(UDPSession&&) = delete;
73 UDPSession(const UDPSession&) = delete;
7574 UDPSession& operator=(const UDPSession&) = delete;
7675
7776 void collect(PacketInfo& info)
7877 {
7978 // TODO: this code must be generalized with RPCFiltrator class
80 uint32_t hdr_len {0};
81 auto msg = reinterpret_cast<const MessageHeader*const>(info.data);
79 uint32_t hdr_len{0};
80 auto msg = reinterpret_cast<const MessageHeader* const>(info.data);
8281 switch(msg->type())
8382 {
84 case MsgType::CALL:
85 {
86 auto call = static_cast<const CallHeader*const>(msg);
87 if(RPCValidator::check(call))
88 {
89 if (NFS3Validator::check(call))
90 {
91 uint32_t proc {call->proc()};
92 if (ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit
93 {
94 hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen);
95 }
96 else
97 {
98 if (ProcEnumNFS3::READ == proc)
99 nfs3_read_match.insert(call->xid());
100 hdr_len = info.dlen;
101 }
102 }
103 else if (NFS4Validator::check(call))
104 {
105 hdr_len = info.dlen; // fully collect NFSv4 messages
83 case MsgType::CALL:
84 {
85 auto call = static_cast<const CallHeader* const>(msg);
86 if(RPCValidator::check(call))
87 {
88 if(NFS3Validator::check(call))
89 {
90 uint32_t proc{call->proc()};
91 if(ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit
92 {
93 hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen);
10694 }
10795 else
10896 {
109 return;
110 }
97 if(ProcEnumNFS3::READ == proc)
98 nfs3_read_match.insert(call->xid());
99 hdr_len = info.dlen;
100 }
101 }
102 else if(NFS4Validator::check(call))
103 {
104 hdr_len = info.dlen; // fully collect NFSv4 messages
111105 }
112106 else
113107 {
114108 return;
115109 }
116110 }
117 break;
118 case MsgType::REPLY:
119 {
120 auto reply = static_cast<const ReplyHeader*const>(msg);
121 if(RPCValidator::check(reply))
122 {
123 // Truncate NFSv3 READ reply message to NFSv3-RW-limit
124 //* Collect fully if reply received before matching call
125 if (nfs3_read_match.erase(reply->xid()) > 0)
126 {
127 hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen);
128 }
129 else
130 hdr_len = info.dlen;
131 }
132 else // isn't RPC reply, stream is corrupt
133 {
134 return;
135 }
136 }
137 break;
138 default:
111 else
112 {
139113 return;
114 }
115 }
116 break;
117 case MsgType::REPLY:
118 {
119 auto reply = static_cast<const ReplyHeader* const>(msg);
120 if(RPCValidator::check(reply))
121 {
122 // Truncate NFSv3 READ reply message to NFSv3-RW-limit
123 //* Collect fully if reply received before matching call
124 if(nfs3_read_match.erase(reply->xid()) > 0)
125 {
126 hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen);
127 }
128 else
129 hdr_len = info.dlen;
130 }
131 else // isn't RPC reply, stream is corrupt
132 {
133 return;
134 }
135 }
136 break;
137 default:
138 return;
140139 }
141140
142141 collection.allocate();
147146 }
148147
149148 typename Writer::Collection collection;
150 uint32_t nfs3_rw_hdr_max;
151 MessageSet nfs3_read_match;
149 uint32_t nfs3_rw_hdr_max;
150 MessageSet nfs3_read_match;
152151 };
153152
154153 // Represents TCP conversation between node A and node B
156155 class TCPSession : public utils::NetworkSession
157156 {
158157 public:
159
160158 struct Flow
161159 {
162160 // Helpers for comparison sequence numbers
163161 // Idea for gt: either x > y, or y is much bigger (assume wrap)
164 inline static bool GT_SEQ(uint32_t x, uint32_t y){ return (int32_t)((y) - (x)) < 0; }
165 inline static bool LT_SEQ(uint32_t x, uint32_t y){ return (int32_t)((x) - (y)) < 0; }
166 inline static bool GE_SEQ(uint32_t x, uint32_t y){ return (int32_t)((y) - (x)) <= 0; }
167 inline static bool LE_SEQ(uint32_t x, uint32_t y){ return (int32_t)((x) - (y)) <= 0; }
168 inline static bool EQ_SEQ(uint32_t x, uint32_t y){ return (x) ==(y); }
169
162 inline static bool GT_SEQ(uint32_t x, uint32_t y) { return (int32_t)((y) - (x)) < 0; }
163 inline static bool LT_SEQ(uint32_t x, uint32_t y) { return (int32_t)((x) - (y)) < 0; }
164 inline static bool GE_SEQ(uint32_t x, uint32_t y) { return (int32_t)((y) - (x)) <= 0; }
165 inline static bool LE_SEQ(uint32_t x, uint32_t y) { return (int32_t)((x) - (y)) <= 0; }
166 inline static bool EQ_SEQ(uint32_t x, uint32_t y) { return (x) == (y); }
170167 friend class TCPSession<StreamReader>;
171168
172 Flow() : fragments{nullptr}, sequence{0}
169 Flow()
170 : fragments{nullptr}
171 , sequence{0}
173172 {
174173 }
175174 ~Flow()
176175 {
177176 reset();
178177 }
179 Flow(Flow&&) = delete;
180 Flow(const Flow&) = delete;
178 Flow(Flow&&) = delete;
179 Flow(const Flow&) = delete;
181180 Flow& operator=(const Flow&) = delete;
182181
183182 void reset()
195194
196195 void reassemble(PacketInfo& info)
197196 {
198 uint32_t seq {info.tcp->seq()};
199 uint32_t len {info.dlen};
200
201 if( sequence == 0 ) // this is the first time we have seen this src's sequence number
197 uint32_t seq{info.tcp->seq()};
198 uint32_t len{info.dlen};
199
200 if(sequence == 0) // this is the first time we have seen this src's sequence number
202201 {
203202 sequence = seq + len;
204 if( info.tcp->is(tcp_header::SYN) )
203 if(info.tcp->is(tcp_header::SYN))
205204 {
206205 sequence++;
207206 }
208207
209208 if(len > 0)
210209 {
211 reader.push(info); // write out the packet data
210 reader.push(info); // write out the packet data
212211 }
213212
214213 return;
216215
217216 // if we are here, we have already seen this src, let's
218217 // try and figure out if this packet is in the right place
219 if( LT_SEQ(seq, sequence) )
218 if(LT_SEQ(seq, sequence))
220219 {
221220 // this sequence number seems dated, but
222221 // check the end to make sure it has no more
223222 // info than we have already seen
224 uint32_t newseq {seq + len};
225 if( GT_SEQ(newseq, sequence) )
226 {
227
223 uint32_t newseq{seq + len};
224 if(GT_SEQ(newseq, sequence))
225 {
228226 // this one has more than we have seen. let's get the
229227 // payload that we have not seen
230 uint32_t new_len {sequence - seq};
231
232 if ( info.dlen <= new_len )
228 uint32_t new_len{sequence - seq};
229
230 if(info.dlen <= new_len)
233231 {
234232 info.data = nullptr;
235233 info.dlen = 0;
248246 }
249247 }
250248
251 if ( EQ_SEQ(seq, sequence) ) // right on time
249 if(EQ_SEQ(seq, sequence)) // right on time
252250 {
253251 sequence += len;
254 if( info.tcp->is(tcp_header::SYN) ) sequence++;
255
256 if( info.data && info.dlen > 0)
252 if(info.tcp->is(tcp_header::SYN)) sequence++;
253
254 if(info.data && info.dlen > 0)
257255 {
258256 reader.push(info);
259257 }
260258 // done with the packet, see if it caused a fragment to fit
261 while( check_fragments(0) );
259 while(check_fragments(0))
260 ;
262261 }
263262 else // out of order packet
264263 {
265 if(info.dlen > 0 && GT_SEQ(seq, sequence) )
264 if(info.dlen > 0 && GT_SEQ(seq, sequence))
266265 {
267266 //TRACE("ADD FRAGMENT seq: %u dlen: %u sequence: %u", seq, info.dlen, sequence);
268267 fragments = Packet::create(info, fragments);
272271
273272 bool check_fragments(const uint32_t acknowledged)
274273 {
275 Packet* current {fragments};
276 if( current )
277 {
278 Packet* prev {nullptr};
279 uint32_t lowest_seq {current->tcp->seq()};
280 while( current )
281 {
282 const uint32_t current_seq {current->tcp->seq()};
283 const uint32_t current_len {current->dlen};
284
285 if( GT_SEQ(lowest_seq, current_seq) ) // lowest_seq > current_seq
274 Packet* current{fragments};
275 if(current)
276 {
277 Packet* prev{nullptr};
278 uint32_t lowest_seq{current->tcp->seq()};
279 while(current)
280 {
281 const uint32_t current_seq{current->tcp->seq()};
282 const uint32_t current_len{current->dlen};
283
284 if(GT_SEQ(lowest_seq, current_seq)) // lowest_seq > current_seq
286285 {
287286 lowest_seq = current_seq;
288287 }
289288
290 if( LT_SEQ(current_seq, sequence) ) // current_seq < sequence
289 if(LT_SEQ(current_seq, sequence)) // current_seq < sequence
291290 {
292291 // this sequence number seems dated, but
293292 // check the end to make sure it has no more
294293 // info than we have already seen
295 uint32_t newseq {current_seq + current_len};
296 if( GT_SEQ(newseq, sequence) )
294 uint32_t newseq{current_seq + current_len};
295 if(GT_SEQ(newseq, sequence))
297296 {
298297 // this one has more than we have seen. let's get the
299298 // payload that we have not seen. This happens when
300299 // part of this frame has been retransmitted
301 uint32_t new_pos {sequence - current_seq};
300 uint32_t new_pos{sequence - current_seq};
302301
303302 sequence += (current_len - new_pos);
304303
305 if ( current->dlen > new_pos )
304 if(current->dlen > new_pos)
306305 {
307306 current->data += new_pos;
308307 current->dlen -= new_pos;
311310 }
312311
313312 // Remove the fragment from the list as the "new" part of it
314 // has been processed or its data has been seen already in
313 // has been processed or its data has been seen already in
315314 // another packet.
316 if( prev )
315 if(prev)
317316 {
318317 prev->next = current->next;
319318 }
327326 return true;
328327 }
329328
330 if( EQ_SEQ(current_seq, sequence) )
329 if(EQ_SEQ(current_seq, sequence))
331330 {
332331 // this fragment fits the stream
333332 sequence += current_len;
334 if( prev )
333 if(prev)
335334 {
336335 prev->next = current->next;
337336 }
345344
346345 return true;
347346 }
348 prev = current;
347 prev = current;
349348 current = current->next;
350 }// end while
351
352 if( GT_SEQ(acknowledged, lowest_seq) ) // acknowledged > lowest_seq
349 } // end while
350
351 if(GT_SEQ(acknowledged, lowest_seq)) // acknowledged > lowest_seq
353352 {
354353 //TRACE("acknowledged(%u) > lowest_seq(%u) seq:%u", acknowledged, lowest_seq, sequence);
355354 // There are frames missing in the capture stream that were seen
364363 }
365364
366365 private:
367 StreamReader reader; // reader of acknowledged data stream
368 Packet* fragments; // list of not yet acked fragments
369 uint32_t sequence;
366 StreamReader reader; // reader of acknowledged data stream
367 Packet* fragments; // list of not yet acked fragments
368 uint32_t sequence;
370369 };
371370
372371 template <typename Writer>
375374 flows[0].reader.set_writer(this, w, max_rpc_hdr);
376375 flows[1].reader.set_writer(this, w, max_rpc_hdr);
377376 }
378 TCPSession(TCPSession&&) = delete;
379 TCPSession(const TCPSession&) = delete;
377 TCPSession(TCPSession&&) = delete;
378 TCPSession(const TCPSession&) = delete;
380379 TCPSession& operator=(const TCPSession&) = delete;
381380
382381 void collect(PacketInfo& info)
383382 {
384 const uint32_t ack {info.tcp->ack()};
383 const uint32_t ack{info.tcp->ack()};
385384
386385 //check whether this frame acks fragments that were already seen.
387 while( flows[1-info.direction].check_fragments(ack) );
386 while(flows[1 - info.direction].check_fragments(ack))
387 ;
388388
389389 flows[info.direction].reassemble(info);
390390 }
392392 Flow flows[2];
393393 };
394394
395 template
396 <
395 template <
397396 typename Reader,
398397 typename Writer,
399 typename Filtrator
400 >
398 typename Filtrator>
401399 class FiltrationProcessor
402400 {
403401 public:
404
405402 explicit FiltrationProcessor(std::unique_ptr<Reader>& r,
406403 std::unique_ptr<Writer>& w)
407 : reader{std::move(r)}
408 , writer{std::move(w)}
409 , ipv4_tcp_sessions{writer.get()}
410 , ipv4_udp_sessions{writer.get()}
411 , ipv6_tcp_sessions{writer.get()}
412 , ipv6_udp_sessions{writer.get()}
404 : reader{std::move(r)}
405 , writer{std::move(w)}
406 , ipv4_tcp_sessions{writer.get()}
407 , ipv4_udp_sessions{writer.get()}
408 , ipv6_tcp_sessions{writer.get()}
409 , ipv6_udp_sessions{writer.get()}
413410 {
414411 // check datalink layer
415412 datalink = reader->datalink();
426423
427424 void run()
428425 {
429 bool done {reader->loop(this, callback)};
426 bool done{reader->loop(this, callback)};
430427 if(done)
431428 {
432429 throw controller::ProcessingDone("Filtration is done");
438435 reader->break_loop();
439436 }
440437
441 static void callback(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char* packet)
442 {
443 PROF;// Calc how much time was spent in this func
438 static void callback(u_char* user, const struct pcap_pkthdr* pkthdr, const u_char* packet)
439 {
440 PROF; // Calc how much time was spent in this func
444441 auto processor = reinterpret_cast<FiltrationProcessor*>(user);
445442
446443 PacketInfo info(pkthdr, packet, processor->datalink);
449446 {
450447 if(pkthdr->caplen != pkthdr->len)
451448 {
452 LOGONCE("pcap packet was truncated by snaplen option this "
453 "packed won't correclty reassembled to TCP stream");
449 LOGONCE(
450 "pcap packet was truncated by snaplen option this "
451 "packed won't correclty reassembled to TCP stream");
454452 return;
455453 }
456454
457 if(info.ipv4) // Ethernet:IPv4:TCP
455 if(info.ipv4) // Ethernet:IPv4:TCP
458456 {
459457 return processor->ipv4_tcp_sessions.collect_packet(info);
460458 }
461 else if(info.ipv6) // Ethernet:IPv6:TCP
459 else if(info.ipv6) // Ethernet:IPv6:TCP
462460 {
463461 return processor->ipv6_tcp_sessions.collect_packet(info);
464462 }
465463 }
466464 else if(info.udp)
467465 {
468 if(info.ipv4) // Ethernet:IPv4:UDP
466 if(info.ipv4) // Ethernet:IPv4:UDP
469467 {
470468 return processor->ipv4_udp_sessions.collect_packet(info);
471469 }
472 else if(info.ipv6) // Ethernet:IPv6:UDP
470 else if(info.ipv6) // Ethernet:IPv6:UDP
473471 {
474472 return processor->ipv6_udp_sessions.collect_packet(info);
475473 }
476474 }
477475
478 LOGONCE("only following stack of protocol is supported: "
479 "Ethernet II:IPv4|IPv6(except additional fragments):TCP|UDP");
476 LOGONCE(
477 "only following stack of protocol is supported: "
478 "Ethernet II:IPv4|IPv6(except additional fragments):TCP|UDP");
480479 }
481480
482481 private:
483
484482 std::unique_ptr<Reader> reader;
485483 std::unique_ptr<Writer> writer;
486484
487 SessionsHash< IPv4TCPMapper, TCPSession <Filtrator> , Writer > ipv4_tcp_sessions;
488 SessionsHash< IPv4UDPMapper, UDPSession < Writer > , Writer > ipv4_udp_sessions;
489
490 SessionsHash< IPv6TCPMapper, TCPSession < Filtrator> , Writer > ipv6_tcp_sessions;
491 SessionsHash< IPv6UDPMapper, UDPSession < Writer > , Writer > ipv6_udp_sessions;
485 SessionsHash<IPv4TCPMapper, TCPSession<Filtrator>, Writer> ipv4_tcp_sessions;
486 SessionsHash<IPv4UDPMapper, UDPSession<Writer>, Writer> ipv4_udp_sessions;
487
488 SessionsHash<IPv6TCPMapper, TCPSession<Filtrator>, Writer> ipv6_tcp_sessions;
489 SessionsHash<IPv6UDPMapper, UDPSession<Writer>, Writer> ipv6_udp_sessions;
492490
493491 int datalink;
494492 };
496494 } // namespace filtration
497495 } // namespace NST
498496 //------------------------------------------------------------------------------
499 #endif//FILTRATION_PROCESSOR_H
500 //------------------------------------------------------------------------------
497 #endif // FILTRATION_PROCESSOR_H
498 //------------------------------------------------------------------------------
2222 #ifndef IFILTRATOR_H
2323 #define IFILTRATOR_H
2424 //------------------------------------------------------------------------------
25 #include "filtration/packet.h"
26 #include "utils/log.h"
27 //------------------------------------------------------------------------------
2528 namespace NST
2629 {
2730 namespace filtration
2831 {
29
3032 /*!
3133 * Filtering TCP stream strategy (implementation)
3234 * Implemented via CRTP - Curiously recurring template pattern,
3335 * (see http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern)
3436 */
35 template<typename Filtrator, typename Writer>
37 template <typename Filtrator, typename Writer>
3638 class FiltratorImpl
3739 {
38 size_t msg_len; //!< length of current message
39 size_t to_be_copied; //!< length of readable piece of message. Initially msg_len or 0 in case of unknown msg
40 size_t msg_len; //!< length of current message
41 size_t to_be_copied; //!< length of readable piece of message. Initially msg_len or 0 in case of unknown msg
4042 using Collection = typename Writer::Collection; //!< Type of collection
41 Collection collection;//!< storage for collection packet data
42
43 FiltratorImpl(FiltratorImpl&&) = delete;
44 FiltratorImpl(const FiltratorImpl&) = delete;
43 Collection collection; //!< storage for collection packet data
44
45 FiltratorImpl(FiltratorImpl&&) = delete;
46 FiltratorImpl(const FiltratorImpl&) = delete;
4547 FiltratorImpl& operator=(const FiltratorImpl&) = delete;
48
4649 public:
4750 FiltratorImpl()
4851 {
6164 */
6265 inline void reset()
6366 {
64 msg_len = 0;
67 msg_len = 0;
6568 to_be_copied = 0;
6669 collection.reset();
6770 }
7275 */
7376 inline bool inProgress(PacketInfo& info)
7477 {
75 Filtrator* filtrator = static_cast<Filtrator* >(this);
78 Filtrator* filtrator = static_cast<Filtrator*>(this);
7679 constexpr size_t callHeaderLen = Filtrator::lengthOfBaseHeader();
77 if (msg_len || to_be_copied)
80 if(msg_len || to_be_copied)
7881 {
7982 return true;
8083 }
8184
82 if (!collection) // collection isn't allocated
85 if(!collection) // collection isn't allocated
8386 {
8487 collection.allocate(); // allocate new collection from writer
8588 }
8689 const size_t data_size = collection.data_size();
8790
88 if (data_size + info.dlen > callHeaderLen)
91 if(data_size + info.dlen > callHeaderLen)
8992 {
9093 static uint8_t buffer[callHeaderLen];
9194 const uint8_t* header = info.data;
9295
93 if (data_size > 0)
96 if(data_size > 0)
9497 {
9598 // Coping happends only once per TCP-session
9699 memcpy(buffer, collection.data(), data_size);
99102 }
100103
101104 // It is right header
102 if (filtrator->isRightHeader(header))
105 if(filtrator->isRightHeader(header))
103106 {
104107 return true;
105108 }
120123 */
121124 inline void lost(const uint32_t n) // we are lost n bytes in sequence
122125 {
123 Filtrator* filtrator = static_cast<Filtrator* >(this);
124 if (msg_len != 0)
125 {
126 if (to_be_copied == 0 && msg_len >= n)
126 Filtrator* filtrator = static_cast<Filtrator*>(this);
127 if(msg_len != 0)
128 {
129 if(to_be_copied == 0 && msg_len >= n)
127130 {
128131 TRACE("We are lost %u bytes of payload marked for discard", n);
129132 msg_len -= n;
146149 */
147150 inline void push(PacketInfo& info)
148151 {
149 Filtrator* filtrator = static_cast<Filtrator* >(this);
152 Filtrator* filtrator = static_cast<Filtrator*>(this);
150153 assert(info.dlen != 0);
151154
152 while (info.dlen) // loop over data in packet
153 {
154 if (msg_len) // we are on-stream and we are looking to some message
155 {
156 if (to_be_copied)
155 while(info.dlen) // loop over data in packet
156 {
157 if(msg_len) // we are on-stream and we are looking to some message
158 {
159 if(to_be_copied)
157160 {
158161 // hdr_len != 0, readout a part of header of current message
159 if (to_be_copied > info.dlen) // got new part of header (not the all!)
162 if(to_be_copied > info.dlen) // got new part of header (not the all!)
160163 {
161164 //TRACE("got new part of header (not the all!)");
162165 collection.push(info, info.dlen);
163166 to_be_copied -= info.dlen;
164167 msg_len -= info.dlen;
165 info.dlen = 0; // return from while
168 info.dlen = 0; // return from while
166169 }
167170 else // hdr_len <= dlen, current message will be complete, also we have some additional data
168171 {
169172 //TRACE("current message will be complete, also we have some additional data");
170173 collection.push(info, to_be_copied);
171 info.dlen -= to_be_copied;
172 info.data += to_be_copied;
174 info.dlen -= to_be_copied;
175 info.data += to_be_copied;
173176
174177 msg_len -= to_be_copied;
175178 to_be_copied = 0;
176179
177180 collection.skip_first(Filtrator::lengthOfFirstSkipedPart());
178 collection.complete(info); // push complete message to queue
181 collection.complete(info); // push complete message to queue
179182 }
180183 }
181184 else
182185 {
183186 // message header is readout, discard the unused tail of message
184 if (msg_len >= info.dlen) // discard whole new packet
187 if(msg_len >= info.dlen) // discard whole new packet
185188 {
186189 //TRACE("discard whole new packet");
187190 msg_len -= info.dlen;
188191 return; //info.dlen = 0; // return from while
189192 }
190 else // discard only a part of packet payload related to current message
193 else // discard only a part of packet payload related to current message
191194 {
192195 //TRACE("discard only a part of packet payload related to current message");
193196 info.dlen -= msg_len;
210213 */
211214 inline void find_message(PacketInfo& info)
212215 {
213 assert(msg_len == 0); // Message still undetected
214 Filtrator* filtrator = static_cast<Filtrator* >(this);
215
216 if (!filtrator->collect_header(info, collection))
216 assert(msg_len == 0); // Message still undetected
217 Filtrator* filtrator = static_cast<Filtrator*>(this);
218
219 if(!filtrator->collect_header(info, collection))
217220 {
218221 return;
219222 }
220223
221 assert(collection); // collection must be initialized
222
223 if (filtrator->find_and_read_message(info, collection))
224 assert(collection); // collection must be initialized
225
226 if(filtrator->find_and_read_message(info, collection))
224227 {
225228 return;
226229 }
227230
228 assert(msg_len == 0); // message is not found
229 assert(to_be_copied == 0); // header should be skipped
230 collection.reset(); // skip collected data
231 assert(msg_len == 0); // message is not found
232 assert(to_be_copied == 0); // header should be skipped
233 collection.reset(); // skip collected data
231234 //[ Optimization ] skip data of current packet at all
232235 info.dlen = 0;
233236 }
243246 to_be_copied = value;
244247 }
245248
246 inline void setWriterImpl(utils::NetworkSession* session_ptr, Writer* w, uint32_t )
249 inline void setWriterImpl(utils::NetworkSession* session_ptr, Writer* w, uint32_t)
247250 {
248251 assert(w);
249252 collection.set(*w, session_ptr);
251254
252255 inline bool collect_header(PacketInfo& info, size_t callHeaderLen, size_t replyHeaderLen)
253256 {
254 if (collection && (collection.data_size() > 0)) // collection is allocated
257 if(collection && (collection.data_size() > 0)) // collection is allocated
255258 {
256259 assert(collection.capacity() >= callHeaderLen);
257 const size_t tocopy {callHeaderLen - collection.data_size()};
260 const size_t tocopy{callHeaderLen - collection.data_size()};
258261 assert(tocopy != 0);
259 if (info.dlen < tocopy)
262 if(info.dlen < tocopy)
260263 {
261264 collection.push(info, info.dlen);
262 info.data += info.dlen;// optimization
265 info.data += info.dlen; // optimization
263266 info.dlen = 0;
264267 return false;
265268 }
272275 }
273276 else // collection is empty
274277 {
275 collection.allocate(); // allocate new collection from writer
276 if (info.dlen >= callHeaderLen) // is data enough to message validation?
278 collection.allocate(); // allocate new collection from writer
279 if(info.dlen >= callHeaderLen) // is data enough to message validation?
277280 {
278281 collection.push(info, callHeaderLen); // probability that message will be rejected / probability of valid message
279282 info.data += callHeaderLen;
284287 collection.push(info, info.dlen);
285288 //info.data += info.dlen;// optimization
286289 size_t copied = info.dlen;
287 info.dlen = 0;
290 info.dlen = 0;
288291 return copied >= replyHeaderLen;
289292 }
290293 }
293296
294297 inline bool read_message(PacketInfo& info)
295298 {
296 assert(msg_len != 0); // message is found
299 assert(msg_len != 0); // message is found
297300 assert(msg_len >= collection.data_size());
298301 assert(to_be_copied <= msg_len);
299 Filtrator* filtrator = static_cast<Filtrator* >(this);
300
301 const size_t written {collection.data_size()};
302 Filtrator* filtrator = static_cast<Filtrator*>(this);
303
304 const size_t written{collection.data_size()};
302305 msg_len -= written; // substract how written (if written)
303306 to_be_copied -= std::min(to_be_copied, written);
304 if (0 == to_be_copied) // Avoid infinity loop when "msg len" == "data size(collection) (max_header)" {msg_len >= hdr_len}
305 // Next find message call will finding next message
307 if(0 == to_be_copied) // Avoid infinity loop when "msg len" == "data size(collection) (max_header)" {msg_len >= hdr_len}
308 // Next find message call will finding next message
306309 {
307310 collection.skip_first(filtrator->lengthOfFirstSkipedPart());
308311 collection.complete(info);
309312 }
310313 return true;
311314 }
312
313315 };
314316
315317 } // namespace filtration
316318 } // namespace NST
317319 //------------------------------------------------------------------------------
318 #endif//IFILTRATOR_H
319 //------------------------------------------------------------------------------
320 #endif // IFILTRATOR_H
321 //------------------------------------------------------------------------------
3030 {
3131 namespace filtration
3232 {
33
3433 /*!
3534 * Composite filtrator which composites both CIFS&NFS
3635 */
37 template<typename Writer>
36 template <typename Writer>
3837 class Filtrators
3938 {
4039 enum class FiltratorTypes
4443 CIFS
4544 };
4645
47 CIFSFiltrator<Writer> filtratorCIFS;//!< CIFS filtrator
48 RPCFiltrator<Writer> filtratorRPC;//!< RPC filtrator
49 FiltratorTypes currentFiltrator;//!< Indicates which filtrator is currently active?
46 CIFSFiltrator<Writer> filtratorCIFS; //!< CIFS filtrator
47 RPCFiltrator<Writer> filtratorRPC; //!< RPC filtrator
48 FiltratorTypes currentFiltrator; //!< Indicates which filtrator is currently active?
5049 public:
51 Filtrators() :
52 currentFiltrator(FiltratorTypes::DEFAULT)
50 Filtrators()
51 : currentFiltrator(FiltratorTypes::DEFAULT)
5352 {
5453 }
5554
56 Filtrators(Filtrators&&) = delete;
57 Filtrators(const Filtrators&) = delete;
55 Filtrators(Filtrators&&) = delete;
56 Filtrators(const Filtrators&) = delete;
5857 Filtrators& operator=(const Filtrators&) = delete;
5958
6059 /*!
6362 inline void reset()
6463 {
6564 filtratorCIFS.reset();
66 filtratorRPC.reset ();
65 filtratorRPC.reset();
6766 currentFiltrator = FiltratorTypes::DEFAULT;
6867 }
6968
7675 inline void set_writer(utils::NetworkSession* session_ptr, Writer* w, uint32_t max_rpc_hdr)
7776 {
7877 assert(w);
79 filtratorCIFS.set_writer (session_ptr, w, max_rpc_hdr);
80 filtratorRPC.set_writer (session_ptr, w, max_rpc_hdr);
78 filtratorCIFS.set_writer(session_ptr, w, max_rpc_hdr);
79 filtratorRPC.set_writer(session_ptr, w, max_rpc_hdr);
8180 }
8281
8382 inline void lost(const uint32_t n) // we are lost n bytes in sequence
8483 {
85 filtratorCIFS.lost (n);
86 filtratorRPC.lost (n);
84 filtratorCIFS.lost(n);
85 filtratorRPC.lost(n);
8786 }
8887
8988 /*!
9392 inline void push(PacketInfo& info)
9493 {
9594 // is it RPC message?
96 if (currentFiltrator == FiltratorTypes::RPC || filtratorRPC.inProgress(info))
95 if(currentFiltrator == FiltratorTypes::RPC || filtratorRPC.inProgress(info))
9796 {
9897 currentFiltrator = FiltratorTypes::RPC;
99 filtratorRPC.push (info);
98 filtratorRPC.push(info);
10099 }
101100 // is it CIFS message?
102 else if (currentFiltrator == FiltratorTypes::CIFS || filtratorCIFS.inProgress(info))
101 else if(currentFiltrator == FiltratorTypes::CIFS || filtratorCIFS.inProgress(info))
103102 {
104103 currentFiltrator = FiltratorTypes::CIFS;
105 filtratorCIFS.push (info);
104 filtratorCIFS.push(info);
106105 }
107106 // it is Unknown message
108107 else
115114 } // namespace filtration
116115 } // namespace NST
117116 //------------------------------------------------------------------------------
118 #endif//FILTRATORS_H
117 #endif // FILTRATORS_H
119118 //------------------------------------------------------------------------------
2121 #ifndef PACKET_H
2222 #define PACKET_H
2323 //------------------------------------------------------------------------------
24 #include <algorithm> // for std::min()
24 #include <algorithm> // for std::min()
2525 #include <cassert>
26 #include <cstring> // for memcpy()
26 #include <cstring> // for memcpy()
2727
2828 #include <pcap/pcap.h>
2929
3737 {
3838 namespace filtration
3939 {
40
4140 using namespace NST::protocols;
4241 using namespace NST::protocols::ethernet;
4342 using namespace NST::protocols::ip;
5554 friend struct Packet;
5655
5756 public:
58 Dumped() : flag{false}{};
57 Dumped()
58 : flag{false} {};
5959 Dumped(const Dumped& in) = delete;
6060 ~Dumped(){};
6161
6262 private:
63 inline operator bool() const { return flag; }
63 inline operator bool() const { return flag; }
6464 inline void operator=(const bool stat) { flag = stat; }
65 bool flag;
65 bool flag;
6666 };
6767
6868 inline PacketInfo(const pcap_pkthdr* h,
69 const uint8_t* p,
70 const uint32_t datalink)
71 : header {h}
72 , packet {p}
73 , eth {nullptr}
74 , ipv4 {nullptr}
75 , ipv6 {nullptr}
76 , tcp {nullptr}
77 , udp {nullptr}
78 , data {packet}
79 , dlen {header->caplen}
80 , direction{Direction::Unknown}
81 , dumped {}
69 const uint8_t* p,
70 const uint32_t datalink)
71 : header{h}
72 , packet{p}
73 , eth{nullptr}
74 , ipv4{nullptr}
75 , ipv6{nullptr}
76 , tcp{nullptr}
77 , udp{nullptr}
78 , data{packet}
79 , dlen{header->caplen}
80 , direction{Direction::Unknown}
81 , dumped{}
8282 {
8383 switch(datalink)
8484 {
85 case DLT_EN10MB: check_eth(); break;
86 case DLT_LINUX_SLL: check_sll(); break;
87 }
88 }
89 PacketInfo(const PacketInfo&) = delete;
85 case DLT_EN10MB:
86 check_eth();
87 break;
88 case DLT_LINUX_SLL:
89 check_sll();
90 break;
91 }
92 }
93 PacketInfo(const PacketInfo&) = delete;
9094 PacketInfo& operator=(const PacketInfo&) = delete;
91 void* operator new (size_t ) = delete; // only on stack
92 void* operator new[] (size_t ) = delete; // only on stack
93 void operator delete (void*) = delete; // only on stack
94 void operator delete[](void*) = delete; // only on stack
95 void* operator new(size_t) = delete; // only on stack
96 void* operator new[](size_t) = delete; // only on stack
97 void operator delete(void*) = delete; // only on stack
98 void operator delete[](void*) = delete; // only on stack
9599
96100 inline void check_eth()
97101 {
103107
104108 switch(header->type())
105109 {
106 case ethernet_header::IP: check_ipv4(); break;
107 case ethernet_header::IPV6: check_ipv6(); break;
110 case ethernet_header::IP:
111 check_ipv4();
112 break;
113 case ethernet_header::IPV6:
114 check_ipv6();
115 break;
108116 default:
109117 return;
110118 }
114122
115123 inline void check_sll()
116124 {
117 // TODO: add support Linux cooked sockets
125 // TODO: add support Linux cooked sockets
118126 }
119127
120128 inline void check_ipv4() __attribute__((always_inline))
122130 if(dlen < sizeof(IPv4Header)) return;
123131 auto header = reinterpret_cast<const IPv4Header*>(data);
124132
125 if(header->version() != 4) return;
133 if(header->version() != 4) return;
126134
127135 /*
128136 IP packet may be fragmented by NIC or snaplen parameter of libpcap
138146 }
139147
140148 const uint32_t ihl = header->ihl();
141 if(dlen < ihl) return; // truncated packet
149 if(dlen < ihl) return; // truncated packet
142150 if((header->length()) < ihl) return; // incorrect packet
143151
144152 data += ihl;
145 dlen = (std::min((uint16_t)dlen, header->length())) - ihl; // trunk data to length of IP packet
153 dlen = (std::min((uint16_t)dlen, header->length())) - ihl; // trunk data to length of IP packet
146154
147155 switch(header->protocol())
148156 {
149 case ip::NextProtocol::TCP: check_tcp(); break;
150 case ip::NextProtocol::UDP: check_udp(); break;
157 case ip::NextProtocol::TCP:
158 check_tcp();
159 break;
160 case ip::NextProtocol::UDP:
161 check_udp();
162 break;
151163 default:
152164 return;
153165 }
160172 if(dlen < sizeof(IPv6Header)) return;
161173 auto header = reinterpret_cast<const IPv6Header*>(data);
162174
163 if(header->version() != 6) return;
175 if(header->version() != 6) return;
164176
165177 data += sizeof(IPv6Header);
166178 dlen -= sizeof(IPv6Header);
167179
168180 const uint32_t payload = header->payload_len();
169 if(payload == 0) return; // The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option
181 if(payload == 0) return; // The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option
170182 if(dlen < payload) return; // truncated packet
171183
172184 dlen = payload; // skip padding at the end
173185 // handling optional headers
174186 uint8_t htype = header->nexthdr();
175 switch_type: // TODO: remove ugly goto
187 switch_type: // TODO: remove ugly goto
176188 switch(htype)
177189 {
178 case ip::NextProtocol::TCP: check_tcp(); break;
179 case ip::NextProtocol::UDP: check_udp(); break;
190 case ip::NextProtocol::TCP:
191 check_tcp();
192 break;
193 case ip::NextProtocol::UDP:
194 check_udp();
195 break;
180196
181197 case ip::NextProtocol::HOPOPTS:
182198 {
183 auto hbh = reinterpret_cast<const ipv6_hbh*>(data);
199 auto hbh = reinterpret_cast<const ipv6_hbh*>(data);
184200 const unsigned int size{1U + hbh->hbh_len};
185201
186202 if(dlen < size) return; // truncated packet
194210
195211 case ip::NextProtocol::DSTOPTS:
196212 {
197 auto dest = reinterpret_cast<const ipv6_dest*>(data);
213 auto dest = reinterpret_cast<const ipv6_dest*>(data);
198214 const unsigned int size{1U + dest->dest_len};
199215
200216 if(dlen < size) return; // truncated packet
208224
209225 case ip::NextProtocol::ROUTING:
210226 {
211 auto route = reinterpret_cast<const ipv6_route*>(data);
227 auto route = reinterpret_cast<const ipv6_route*>(data);
212228 const unsigned int size{1U + route->route_len};
213229
214230 if(dlen < size) return; // truncated packet
238254 goto switch_type;
239255 }
240256 case ip::NextProtocol::NONE:
241 default: // unknown header
257 default: // unknown header
242258 return;
243259 }
244260
247263
248264 inline void check_tcp() __attribute__((always_inline))
249265 {
250 if(dlen < sizeof(TCPHeader)) return; // truncated TCP header
266 if(dlen < sizeof(TCPHeader)) return; // truncated TCP header
251267 auto header = reinterpret_cast<const TCPHeader*>(data);
252268
253 uint8_t offset {header->offset()};
269 uint8_t offset{header->offset()};
254270 if(offset < 20 || offset > 60) return; // invalid length of TCP header
255271
256272 if(dlen < offset) return; // truncated packet
267283
268284 inline void check_udp() __attribute__((always_inline))
269285 {
270 if(dlen < sizeof(UDPHeader)) return; // fragmented UDP header
271 const UDPHeader* header {reinterpret_cast<const UDPHeader*>(data)};
286 if(dlen < sizeof(UDPHeader)) return; // fragmented UDP header
287 const UDPHeader* header{reinterpret_cast<const UDPHeader*>(data)};
272288
273289 data += sizeof(UDPHeader);
274290 dlen -= sizeof(UDPHeader);
277293 }
278294
279295 // libpcap structures
280 const pcap_pkthdr* header;
281 const uint8_t* packet; // real length is in header->caplen
296 const pcap_pkthdr* header;
297 const uint8_t* packet; // real length is in header->caplen
282298
283299 // all pointers point to packet array
284300
288304
289305 // Internet Layer
290306 // IP version 4
291 const ip::IPv4Header* ipv4;
307 const ip::IPv4Header* ipv4;
292308 // IP version 6
293 const ip::IPv6Header* ipv6;
309 const ip::IPv6Header* ipv6;
294310
295311 // Transport Layer
296312 // TCP
297 const tcp::TCPHeader* tcp;
313 const tcp::TCPHeader* tcp;
298314 // UDP
299 const udp::UDPHeader* udp;
300
301 const uint8_t* data; // pointer to packet data
302 uint32_t dlen; // length of packet data
315 const udp::UDPHeader* udp;
316
317 const uint8_t* data; // pointer to packet data
318 uint32_t dlen; // length of packet data
303319
304320 // Packet transmission direction, set after match packet to session
305 Direction direction;
306
307 mutable Dumped dumped; // flag for dumped packet
321 Direction direction;
322
323 mutable Dumped dumped; // flag for dumped packet
308324 };
309325
310326 // PCAP packet in dynamic allocated memory
311 struct Packet: public PacketInfo
327 struct Packet : public PacketInfo
312328 {
313 Packet() = delete;
314 Packet(const Packet&) = delete;
329 Packet() = delete;
330 Packet(const Packet&) = delete;
315331 Packet& operator=(const Packet&) = delete;
316332
317 Packet* next; // pointer to next packet or nullptr
333 Packet* next; // pointer to next packet or nullptr
318334
319335 static Packet* create(const PacketInfo& info, Packet* next)
320336 {
322338
323339 // allocate memory for Packet structure and PCAP packet data
324340 // TODO: performance drop! improve data alignment!
325 uint8_t* memory { new uint8_t[sizeof(Packet) + sizeof(pcap_pkthdr) + info.header->caplen]};
326
327 Packet* fragment { (Packet*) ((uint8_t*)memory )};
328 pcap_pkthdr* header{ (pcap_pkthdr*) ((uint8_t*)memory + sizeof(Packet) )};
329 uint8_t* packet { (uint8_t*) ((uint8_t*)memory + sizeof(Packet) + sizeof(pcap_pkthdr))};
341 uint8_t* memory{new uint8_t[sizeof(Packet) + sizeof(pcap_pkthdr) + info.header->caplen]};
342
343 Packet* fragment{(Packet*)((uint8_t*)memory)};
344 pcap_pkthdr* header{(pcap_pkthdr*)((uint8_t*)memory + sizeof(Packet))};
345 uint8_t* packet{(uint8_t*)((uint8_t*)memory + sizeof(Packet) + sizeof(pcap_pkthdr))};
330346
331347 // copy data
332348 *header = *info.header; // copy packet header
336352 fragment->packet = packet;
337353
338354 // fix pointers from PacketInfo to point to owned copy of packet data
339 fragment->eth = info.eth ? (const ethernet::EthernetHeader*) (packet + ( ((const uint8_t*)info.eth ) - info.packet)) : nullptr;
340 fragment->ipv4 = info.ipv4 ? (const ip::IPv4Header*) (packet + ( ((const uint8_t*)info.ipv4) - info.packet)) : nullptr;
341 fragment->ipv6 = info.ipv6 ? (const ip::IPv6Header*) (packet + ( ((const uint8_t*)info.ipv6) - info.packet)) : nullptr;
342 fragment->tcp = info.tcp ? (const tcp::TCPHeader*) (packet + ( ((const uint8_t*)info.tcp ) - info.packet)) : nullptr;
343 fragment->udp = info.udp ? (const udp::UDPHeader*) (packet + ( ((const uint8_t*)info.udp ) - info.packet)) : nullptr;
355 fragment->eth = info.eth ? (const ethernet::EthernetHeader*)(packet + (((const uint8_t*)info.eth) - info.packet)) : nullptr;
356 fragment->ipv4 = info.ipv4 ? (const ip::IPv4Header*)(packet + (((const uint8_t*)info.ipv4) - info.packet)) : nullptr;
357 fragment->ipv6 = info.ipv6 ? (const ip::IPv6Header*)(packet + (((const uint8_t*)info.ipv6) - info.packet)) : nullptr;
358 fragment->tcp = info.tcp ? (const tcp::TCPHeader*)(packet + (((const uint8_t*)info.tcp) - info.packet)) : nullptr;
359 fragment->udp = info.udp ? (const udp::UDPHeader*)(packet + (((const uint8_t*)info.udp) - info.packet)) : nullptr;
344360
345361 fragment->data = packet + (info.data - info.packet);
346362 fragment->dlen = info.dlen;
354370
355371 static void destroy(Packet* fragment)
356372 {
357 uint8_t* ptr { (uint8_t*)fragment };
373 uint8_t* ptr{(uint8_t*)fragment};
358374 delete[] ptr;
359375 }
360376 };
362378 } // namespace filtration
363379 } // namespace NST
364380 //------------------------------------------------------------------------------
365 #endif//PACKET_H
366 //------------------------------------------------------------------------------
381 #endif // PACKET_H
382 //------------------------------------------------------------------------------
3434 {
3535 namespace pcap
3636 {
37
38 inline const char* library_version() { return pcap_lib_version(); }
37 inline const char* library_version()
38 {
39 return pcap_lib_version();
40 }
3941
4042 class BaseReader
4143 {
4244 protected:
4345 BaseReader(const std::string& input)
44 : handle{nullptr}
45 , source{input}
46 : handle{nullptr}
47 , source{input}
4648 {
4749 }
4850
5557 }
5658
5759 public:
58 bool loop(void* user, pcap_handler callback, int count=0)
60 bool loop(void* user, pcap_handler callback, int count = 0)
5961 {
60 const int err {pcap_loop(handle, count, callback, (u_char*)user)};
62 const int err{pcap_loop(handle, count, callback, (u_char*)user)};
6163 if(err == -1) throw PcapError("pcap_loop", pcap_geterr(handle));
6264
6365 return err == 0; // count is exhausted
6466 }
6567
66 inline void break_loop() { pcap_breakloop(handle); }
67 inline pcap_t*& get_handle() { return handle; }
68
69 inline int datalink () const { return pcap_datalink(handle); }
70 inline static const char* datalink_name (const int dlt) { return pcap_datalink_val_to_name(dlt); }
71 inline static const char* datalink_description (const int dlt) { return pcap_datalink_val_to_description(dlt); }
72
68 inline void break_loop() { pcap_breakloop(handle); }
69 inline pcap_t*& get_handle() { return handle; }
70 inline int datalink() const { return pcap_datalink(handle); }
71 inline static const char* datalink_name(const int dlt) { return pcap_datalink_val_to_name(dlt); }
72 inline static const char* datalink_description(const int dlt) { return pcap_datalink_val_to_description(dlt); }
7373 virtual void print_statistic(std::ostream& out) const = 0;
7474
7575 protected:
76 pcap_t* handle;
76 pcap_t* handle;
7777 const std::string source;
7878 };
7979
8181 } // namespace filtration
8282 } // namespace NST
8383 //------------------------------------------------------------------------------
84 #endif//BASE_READER_H
84 #endif // BASE_READER_H
8585 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #ifndef BPF_H
22 #define BPF_H
21 #ifndef BPF_HEADER_H
22 #define BPF_HEADER_H
2323 //------------------------------------------------------------------------------
2424 #include <pcap/pcap.h>
2525
3131 {
3232 namespace pcap
3333 {
34
3534 class BPF
3635 {
3736 public:
4241 throw PcapError("pcap_compile", pcap_geterr(handle));
4342 }
4443 }
45 BPF(const BPF&) = delete;
44 BPF(const BPF&) = delete;
4645 BPF& operator=(const BPF&) = delete;
4746 ~BPF()
4847 {
5049 }
5150
5251 inline operator bpf_program*() { return &bpf; }
53
5452 private:
5553 bpf_program bpf;
5654 };
5957 } // namespace filtration
6058 } // namespace NST
6159 //------------------------------------------------------------------------------
62 #endif//BPF_H
60 #endif // BPF_HEADER_H
6361 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include "filtration/pcap/capture_reader.h"
2122 #include "filtration/pcap/bpf.h"
22 #include "filtration/pcap/capture_reader.h"
2323 #include "filtration/pcap/pcap_error.h"
2424 //------------------------------------------------------------------------------
2525 namespace NST
2828 {
2929 namespace pcap
3030 {
31
32 CaptureReader::CaptureReader(const Params& params) : BaseReader{params.interface}
31 CaptureReader::CaptureReader(const Params& params)
32 : BaseReader{params.interface}
3333 {
34 char errbuf[PCAP_ERRBUF_SIZE]; // storage of error description
35 const char* device {source.c_str()};
34 char errbuf[PCAP_ERRBUF_SIZE]; // storage of error description
35 const char* device{source.c_str()};
3636 handle = pcap_create(device, errbuf);
3737 if(!handle)
3838 {
3939 throw PcapError("pcap_create", errbuf);
4040 }
4141
42 if(int status {pcap_set_snaplen(handle, params.snaplen)})
42 if(int status{pcap_set_snaplen(handle, params.snaplen)})
4343 {
4444 throw PcapError("pcap_set_snaplen", pcap_statustostr(status));
4545 }
4646
47 if(int status {pcap_set_promisc(handle, params.promisc ? 1 : 0)})
47 if(int status{pcap_set_promisc(handle, params.promisc ? 1 : 0)})
4848 {
4949 throw PcapError("pcap_set_promisc", pcap_statustostr(status));
5050 }
5151
52 if(int status {pcap_set_timeout(handle, params.timeout_ms)})
52 if(int status{pcap_set_timeout(handle, params.timeout_ms)})
5353 {
5454 throw PcapError("pcap_set_timeout", pcap_statustostr(status));
5555 }
5656
57 if(int status {pcap_set_buffer_size(handle, params.buffer_size)})
57 if(int status{pcap_set_buffer_size(handle, params.buffer_size)})
5858 {
5959 throw PcapError("pcap_set_buffer_size", pcap_statustostr(status));
6060 }
6161
62 if(int status {pcap_activate(handle)})
62 if(int status{pcap_activate(handle)})
6363 {
6464 throw PcapError("pcap_activate", pcap_statustostr(status));
6565 }
6666
67 pcap_direction_t direction {PCAP_D_INOUT};
67 pcap_direction_t direction{PCAP_D_INOUT};
6868 switch(params.direction)
6969 {
7070 using Direction = CaptureReader::Direction;
71 case Direction::IN : direction = PCAP_D_IN; break;
72 case Direction::OUT : direction = PCAP_D_OUT; break;
73 case Direction::INOUT: direction = PCAP_D_INOUT; break;
71 case Direction::IN:
72 direction = PCAP_D_IN;
73 break;
74 case Direction::OUT:
75 direction = PCAP_D_OUT;
76 break;
77 case Direction::INOUT:
78 direction = PCAP_D_INOUT;
79 break;
7480 }
75 if(int status {pcap_setdirection(handle, direction)})
81 if(int status{pcap_setdirection(handle, direction)})
7682 {
7783 throw PcapError("pcap_setdirection", pcap_statustostr(status));
7884 }
9399
94100 void CaptureReader::print_statistic(std::ostream& out) const
95101 {
96 struct pcap_stat stat={0,0,0};
102 struct pcap_stat stat = {0, 0, 0};
97103 if(pcap_stats(handle, &stat) == 0)
98104 {
99105 out << "Statistics from interface: " << source << '\n'
116122 << " buffer size : " << params.buffer_size << " bytes\n"
117123 << " promiscuous mode: " << (params.promisc ? "on" : "off") << '\n'
118124 << " capture traffic : ";
119 switch(params.direction)
120 {
121 using Direction = CaptureReader::Direction;
122 case Direction::IN : out << "in"; break;
123 case Direction::OUT : out << "out"; break;
124 case Direction::INOUT: out << "inout"; break;
125 }
125 switch(params.direction)
126 {
127 using Direction = CaptureReader::Direction;
128 case Direction::IN:
129 out << "in";
130 break;
131 case Direction::OUT:
132 out << "out";
133 break;
134 case Direction::INOUT:
135 out << "inout";
136 break;
137 }
126138 return out;
127139 }
128140
3131 {
3232 namespace pcap
3333 {
34
3534 class CaptureReader : public BaseReader
3635 {
3736 public:
4443
4544 struct Params
4645 {
47 std::string interface { };
48 std::string filter { };
49 int snaplen {0};
50 int timeout_ms {0};
46 std::string interface{};
47 std::string filter{};
48 int snaplen{0};
49 int timeout_ms{0};
5150 int buffer_size{0};
52 bool promisc {true};
53 Direction direction {Direction::INOUT};
51 bool promisc{true};
52 Direction direction{Direction::INOUT};
5453 };
5554
5655 CaptureReader(const Params& params);
5756 ~CaptureReader() = default;
5857
5958 void print_statistic(std::ostream& out) const override;
60
6159 };
6260
6361 std::ostream& operator<<(std::ostream&, const CaptureReader::Params&);
6664 } // namespace filtration
6765 } // namespace NST
6866 //------------------------------------------------------------------------------
69 #endif//CAPTURE_READER_H
67 #endif // CAPTURE_READER_H
7068 //------------------------------------------------------------------------------
2727 {
2828 namespace pcap
2929 {
30
31 FileReader::FileReader(const std::string& file) : BaseReader{file}
30 FileReader::FileReader(const std::string& file)
31 : BaseReader{file}
3232 {
3333 char errbuf[PCAP_ERRBUF_SIZE];
3434
4343 std::ostream& operator<<(std::ostream& out, FileReader& f)
4444 {
4545 out << "Read packets from: " << f.source << '\n';
46 const int dlt {f.datalink()};
46 const int dlt{f.datalink()};
4747 out << " datalink: " << f.datalink_name(dlt) << " (" << f.datalink_description(dlt) << ")\n";
4848 out << " version: " << f.major_version() << '.' << f.minor_version();
4949 if(f.is_swapped()) out << "\n Note: file has data in swapped byte-order";
3131 {
3232 namespace pcap
3333 {
34
3534 class FileReader : public BaseReader
3635 {
3736 public:
3837 explicit FileReader(const std::string& file);
3938 ~FileReader() = default;
4039
41 inline FILE* get_file() { return pcap_file(handle); }
42
43 void print_statistic(std::ostream& /*out*/) const override { /*dummy method*/ }
44
45 inline int major_version() { return pcap_major_version(handle); }
46 inline int minor_version() { return pcap_minor_version(handle); }
47 inline bool is_swapped() { return pcap_is_swapped(handle); }
48
40 inline FILE* get_file() { return pcap_file(handle); }
41 void print_statistic(std::ostream& /*out*/) const override {}
42 inline int major_version() { return pcap_major_version(handle); }
43 inline int minor_version() { return pcap_minor_version(handle); }
44 inline bool is_swapped() { return pcap_is_swapped(handle); }
4945 friend std::ostream& operator<<(std::ostream& out, FileReader& f);
5046 };
5147
5349 } // namespace filtration
5450 } // namespace NST
5551 //------------------------------------------------------------------------------
56 #endif//FILE_READER_H
52 #endif // FILE_READER_H
5753 //------------------------------------------------------------------------------
2121 #ifndef NETWORK_INTERFACES_H
2222 #define NETWORK_INTERFACES_H
2323 //------------------------------------------------------------------------------
24 #include <pcap/pcap.h>
2524 #include <arpa/inet.h>
2625 #include <netinet/in.h>
26 #include <pcap/pcap.h>
2727 #include <sys/socket.h>
2828
2929 #include "filtration/pcap/pcap_error.h"
3434 {
3535 namespace pcap
3636 {
37
3837 class NetworkInterfaces
3938 {
4039 public:
4241 class Address
4342 {
4443 friend class Interface;
44
4545 public:
46 inline sockaddr* address() const noexcept { return addr->addr; }
47 inline sockaddr* netmask() const noexcept { return addr->netmask; }
46 inline sockaddr* address() const noexcept { return addr->addr; }
47 inline sockaddr* netmask() const noexcept { return addr->netmask; }
4848 inline sockaddr* broadaddr() const noexcept { return addr->broadaddr; }
49 inline sockaddr* destaddr() const noexcept { return addr->dstaddr; }
50
51 Address& operator= (const Address&) = delete;
52 void operator& () = delete;
53 void* operator new (size_t) = delete;
54 void operator delete (void*) = delete;
55
56 inline operator bool() const noexcept { return addr != nullptr; }
57 inline void operator ++() noexcept { addr = addr->next; }
58 inline bool operator !=(const Address& a) const noexcept { return addr != a.addr; }
49 inline sockaddr* destaddr() const noexcept { return addr->dstaddr; }
50 Address& operator=(const Address&) = delete;
51 void operator&() = delete;
52 void* operator new(size_t) = delete;
53 void operator delete(void*) = delete;
54
55 inline operator bool() const noexcept { return addr != nullptr; }
56 inline void operator++() noexcept { addr = addr->next; }
57 inline bool operator!=(const Address& a) const noexcept { return addr != a.addr; }
5958 inline const Address operator*() const noexcept { return *this; }
60
61 Address(const Address& a) : addr{a.addr}{}
62
59 Address(const Address& a)
60 : addr{a.addr}
61 {
62 }
63
6364 private:
64 Address(pcap_addr_t* a) : addr{a}{}
65 Address(pcap_addr_t* a)
66 : addr{a}
67 {
68 }
6569 pcap_addr_t* addr;
6670 };
6771
6872 class Interface
6973 {
7074 friend class NetworkInterfaces;
75
7176 public:
72
73 inline const char* name() const noexcept { return ptr->name; }
74 inline const char* dscr() const noexcept { return ptr->description; }
75 inline bool is_loopback() const noexcept { return ptr->flags & PCAP_IF_LOOPBACK; }
76
77 Interface& operator= (const Interface&) = delete;
78 void operator& () = delete;
79 void* operator new (size_t) = delete;
80 void operator delete (void*) = delete;
81
82 inline operator bool() const noexcept { return ptr != nullptr; }
83 inline void operator ++() noexcept { ptr = ptr->next; }
84 inline bool operator !=(const Interface& i) const noexcept { return ptr != i.ptr; }
77 inline const char* name() const noexcept { return ptr->name; }
78 inline const char* dscr() const noexcept { return ptr->description; }
79 inline bool is_loopback() const noexcept { return ptr->flags & PCAP_IF_LOOPBACK; }
80 Interface& operator=(const Interface&) = delete;
81 void operator&() = delete;
82 void* operator new(size_t) = delete;
83 void operator delete(void*) = delete;
84
85 inline operator bool() const noexcept { return ptr != nullptr; }
86 inline void operator++() noexcept { ptr = ptr->next; }
87 inline bool operator!=(const Interface& i) const noexcept { return ptr != i.ptr; }
8588 inline const Interface operator*() const noexcept { return *this; }
86
87 Interface(const Interface& i) : ptr{i.ptr}{}
89 Interface(const Interface& i)
90 : ptr{i.ptr}
91 {
92 }
8893
8994 const Address begin() const noexcept { return Address{ptr->addresses}; }
90 const Address end() const noexcept { return Address{nullptr}; }
91
95 const Address end() const noexcept { return Address{nullptr}; }
9296 private:
93 Interface(pcap_if_t* p) : ptr{p}{}
97 Interface(pcap_if_t* p)
98 : ptr{p}
99 {
100 }
94101 pcap_if_t* ptr;
95102 };
96103
97 inline NetworkInterfaces() : interfaces{nullptr}
104 inline NetworkInterfaces()
105 : interfaces{nullptr}
98106 {
99107 char errbuf[PCAP_ERRBUF_SIZE];
100108 if(pcap_findalldevs(&interfaces, errbuf) == -1)
127135 throw std::runtime_error{"No suitable device found.\n Note: reading an ip address of a network device may require special privileges."};
128136 }
129137
130 NetworkInterfaces(const NetworkInterfaces&) = delete;
138 NetworkInterfaces(const NetworkInterfaces&) = delete;
131139 NetworkInterfaces& operator=(const NetworkInterfaces&) = delete;
132 void operator& () = delete;
133 void* operator new (size_t) = delete;
134 void operator delete (void*) = delete;
140 void operator&() = delete;
141 void* operator new(size_t) = delete;
142 void operator delete(void*) = delete;
135143
136144 const Interface begin() const noexcept { return Interface{interfaces}; }
137 const Interface end() const noexcept { return Interface{nullptr}; }
138
145 const Interface end() const noexcept { return Interface{nullptr}; }
139146 private:
140147 pcap_if_t* interfaces;
141148 };
142149
143 std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Interface& i)
150 std::ostream& operator<<(std::ostream& out, const NetworkInterfaces::Interface& i)
144151 {
145152 out.width(8);
146153 out << std::left << i.name();
147 const char* dscr {i.dscr()};
154 const char* dscr{i.dscr()};
148155 if(dscr)
149156 {
150157 out << '(' << dscr << ')';
156163 return out;
157164 }
158165
159 std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Address& a)
160 {
161 sockaddr* s_address {a.address()};
162 sockaddr* s_netmask {a.netmask()};
166 std::ostream& operator<<(std::ostream& out, const NetworkInterfaces::Address& a)
167 {
168 sockaddr* s_address{a.address()};
169 sockaddr* s_netmask{a.netmask()};
163170 if(s_address)
164171 {
165172 switch(s_address->sa_family)
180187 sizeof(netmask));
181188 out << " netmask " << netmask;
182189
183 sockaddr* s_broadaddr {a.broadaddr()};
190 sockaddr* s_broadaddr{a.broadaddr()};
184191 if(s_broadaddr)
185192 {
186193 char broadaddr[INET_ADDRSTRLEN]{};
191198 out << " broadcast " << broadaddr;
192199 }
193200
194 sockaddr* s_destaddr {a.destaddr()};
201 sockaddr* s_destaddr{a.destaddr()};
195202 if(s_destaddr)
196203 {
197204 char destaddr[INET_ADDRSTRLEN]{};
237244 } // namespace filtration
238245 } // namespace NST
239246 //------------------------------------------------------------------------------
240 #endif//NETWORK_INTERFACES_H
241 //------------------------------------------------------------------------------
247 #endif // NETWORK_INTERFACES_H
248 //------------------------------------------------------------------------------
3131 {
3232 namespace pcap
3333 {
34
3534 class PacketDumper
3635 {
3736 public:
3837 PacketDumper(pcap_t* handle, const char* path)
39 : dumper{ pcap_dump_open(handle, path) }
38 : dumper{pcap_dump_open(handle, path)}
4039 {
4140 if(dumper == nullptr)
4241 {
4342 throw PcapError{"pcap_dump_open", pcap_geterr(handle)};
4443 }
4544 }
46 PacketDumper(const PacketDumper&) = delete;
45 PacketDumper(const PacketDumper&) = delete;
4746 PacketDumper& operator=(const PacketDumper&) = delete;
4847 ~PacketDumper()
4948 {
5049 pcap_dump_close(dumper);
5150 }
5251
53 inline void dump(const pcap_pkthdr *h, const u_char *sp)
52 inline void dump(const pcap_pkthdr* h, const u_char* sp)
5453 {
5554 pcap_dump((u_char*)dumper, h, sp);
5655 }
5756
58 inline void flush() { pcap_dump_flush(dumper); }
57 inline void flush() { pcap_dump_flush(dumper); }
5958 inline pcap_dumper_t* get_dumper() { return dumper; }
6059 inline FILE* get_stream() { return pcap_dump_file(dumper); }
61
62 void truncate_all_pcap_data_and_header()
60 void truncate_all_pcap_data_and_header()
6361 {
6462 pcap_dump_flush(dumper);
65 FILE* stream {pcap_dump_file(dumper)};
63 FILE* stream{pcap_dump_file(dumper)};
6664 rewind(stream); // truncate a file to zero
6765 pcap_dump_flush(dumper);
6866 }
7573 } // namespace filtration
7674 } // namespace NST
7775 //------------------------------------------------------------------------------
78 #endif//PACKET_DUMPER_H
76 #endif // PACKET_DUMPER_H
7977 //------------------------------------------------------------------------------
3030 {
3131 namespace pcap
3232 {
33
3433 class PcapError : public std::runtime_error
3534 {
3635 public:
3736 explicit PcapError(const char* func, const char* errbuf)
38 : std::runtime_error{std::string{func}+"():"+std::string{errbuf}} { }
37 : std::runtime_error{std::string{func} + "():" + std::string{errbuf}}
38 {
39 }
3940 };
4041
4142 } // namespace pcap
4243 } // namespace filtration
4344 } // namespace NST
4445 //------------------------------------------------------------------------------
45 #endif//PCAP_ERROR_H
46 #endif // PCAP_ERROR_H
4647 //------------------------------------------------------------------------------
2929 {
3030 namespace filtration
3131 {
32
3332 class ProcessingThread
3433 {
3534 protected:
3635 ProcessingThread(NST::controller::RunningStatus& s)
37 : status (s)
38 , processing {}
36 : status(s)
37 , processing{}
3938 {
4039 }
40
4141 public:
4242 virtual ~ProcessingThread()
4343 {
4949
5050 void start()
5151 {
52 if(processing.joinable()) return; // already started
52 if(processing.joinable()) return; // already started
5353
5454 processing = std::thread(&ProcessingThread::thread, this);
5555 }
5656
57 virtual void stop()= 0;
57 virtual void stop() = 0;
5858
5959 private:
6060 virtual void run() = 0;
6363 {
6464 try
6565 {
66 this->run(); // virtual call
66 this->run(); // virtual call
6767 }
6868 catch(...)
6969 {
7373
7474 protected:
7575 NST::controller::RunningStatus& status;
76 std::thread processing;
76 std::thread processing;
7777 };
7878
7979 } // namespace filtration
8080 } // namespace NST
8181 //------------------------------------------------------------------------------
82 #endif//PROCESSING_THREAD_H
82 #endif // PROCESSING_THREAD_H
8383 //------------------------------------------------------------------------------
3131 {
3232 namespace filtration
3333 {
34
3534 class Queueing
3635 {
3736 using Queue = NST::utils::FilteredDataQueue;
3837 using Data = NST::utils::FilteredData;
3938
4039 public:
41
4240 class Collection
4341 {
4442 public:
4543 inline Collection() noexcept
46 : queue {nullptr}
47 , ptr {nullptr}
48 , session {nullptr}
44 : queue{nullptr}
45 , ptr{nullptr}
46 , session{nullptr}
4947 {
5048 }
5149 inline Collection(Queueing* q, utils::NetworkSession* s) noexcept
52 : queue {&q->queue}
53 , ptr {nullptr}
54 , session {s}
50 : queue{&q->queue}
51 , ptr{nullptr}
52 , session{s}
5553 {
5654 }
5755 inline ~Collection()
6159 queue->deallocate(ptr);
6260 }
6361 }
64 Collection(Collection&&) = delete;
65 Collection(const Collection&) = delete;
62 Collection(Collection&&) = delete;
63 Collection(const Collection&) = delete;
6664 Collection& operator=(const Collection&) = delete;
6765
6866 inline void set(Queueing& q, utils::NetworkSession* s)
6967 {
70 queue = &q.queue;
68 queue = &q.queue;
7169 session = s;
7270 }
7371
7775 {
7876 // we have a reference to queue, just do allocate and reset
7977 ptr = queue->allocate();
80 if (!ptr)
78 if(!ptr)
8179 {
8280 LOG("free elements of the Queue are exhausted");
8381 }
113111 {
114112 assert(nullptr != ptr);
115113
116 uint8_t* offset_ptr { ptr->data + ptr->dlen };
117 const uint32_t avail { ptr->capacity() - ptr->dlen};
114 uint8_t* offset_ptr{ptr->data + ptr->dlen};
115 const uint32_t avail{ptr->capacity() - ptr->dlen};
118116 if(len > avail) // inappropriate case. Must be one resize when get entire message size
119117 {
120 ptr->resize(ptr->dlen + len); // [! unbound extension !]
118 ptr->resize(ptr->dlen + len); // [! unbound extension !]
121119 offset_ptr = ptr->data + ptr->dlen; // update pointer
122120 }
123121 memcpy(offset_ptr, info.data, len);
147145 ptr = nullptr;
148146 }
149147
150 inline uint32_t data_size() const { return ptr->dlen; }
151 inline uint32_t capacity() const { return ptr->capacity(); }
152 inline const uint8_t* data() const { return ptr->data; }
153 inline operator bool() const { return ptr != nullptr; }
154
148 inline uint32_t data_size() const { return ptr->dlen; }
149 inline uint32_t capacity() const { return ptr->capacity(); }
150 inline const uint8_t* data() const { return ptr->data; }
151 inline operator bool() const { return ptr != nullptr; }
155152 private:
156 Queue* queue;
157 Data* ptr;
153 Queue* queue;
154 Data* ptr;
158155 utils::NetworkSession* session;
159156 };
160157
161158 Queueing(Queue& q)
162 : queue(q)
159 : queue(q)
163160 {
164161 }
165162 ~Queueing()
166163 {
167164 }
168 Queueing(Queueing&&) = delete;
169 Queueing(const Queueing&) = delete;
165 Queueing(Queueing&&) = delete;
166 Queueing(const Queueing&) = delete;
170167 Queueing& operator=(const Queueing&) = delete;
171168
172169 private:
176173 } // namespace filtration
177174 } // namespace NST
178175 //------------------------------------------------------------------------------
179 #endif//QUEUING_H
176 #endif // QUEUING_H
180177 //------------------------------------------------------------------------------
2626
2727 #include <pcap/pcap.h>
2828
29 #include "filtration/packet.h"
3029 #include "filtration/filtratorimpl.h"
30 #include "protocols/netbios/netbios.h"
3131 #include "protocols/nfs3/nfs3_utils.h"
3232 #include "protocols/nfs4/nfs4_utils.h"
33 #include "protocols/netbios/netbios.h"
3433 #include "protocols/rpc/rpc_header.h"
3534 #include "utils/log.h"
3635 //------------------------------------------------------------------------------
3837 {
3938 namespace filtration
4039 {
41
4240 /*
4341 Stateful reader of Sun RPC messages
4442 Reads data from PacketInfo passed via push() method
4543 aggregates length of current RPC message and length of RPC message useful for analysis
4644 TODO: add matching Calls and replies by XID of message
4745 */
48 template<typename Writer>
46 template <typename Writer>
4947 class RPCFiltrator : public FiltratorImpl<RPCFiltrator<Writer>, Writer>
5048 {
5149 using BaseImpl = FiltratorImpl<RPCFiltrator<Writer>, Writer>;
50
5251 public:
5352 RPCFiltrator()
5453 : BaseImpl()
6463
6564 constexpr static size_t lengthOfBaseHeader()
6665 {
67 return sizeof(RecordMark) + sizeof(ReplyHeader);// Minimum of replay&call headers
66 return sizeof(RecordMark) + sizeof(ReplyHeader); // Minimum of replay&call headers
6867 }
6968
7069 constexpr static size_t lengthOfReplyHeader()
7978
8079 inline static bool isRightHeader(const uint8_t* header)
8180 {
82 const RecordMark* rm {reinterpret_cast<const RecordMark*>(header)};
81 const RecordMark* rm{reinterpret_cast<const RecordMark*>(header)};
8382 const MessageHeader* const msg = rm->fragment();
84 if (msg->type() == MsgType::REPLY)
83 if(msg->type() == MsgType::REPLY)
8584 {
8685 return RPCValidator::check(static_cast<const ReplyHeader* const>(msg));
8786 }
88 if (msg->type() == MsgType::CALL)
87 if(msg->type() == MsgType::CALL)
8988 {
9089 return RPCValidator::check(static_cast<const CallHeader* const>(msg));
9190 }
104103
105104 inline bool find_and_read_message(PacketInfo& info, typename Writer::Collection& collection)
106105 {
107 const RecordMark* rm {reinterpret_cast<const RecordMark*>(collection.data())};
106 const RecordMark* rm{reinterpret_cast<const RecordMark*>(collection.data())};
108107 //if(rm->is_last()); // TODO: handle sequence field of record mark
109 if (collection.data_size() < (sizeof(CallHeader) + sizeof(RecordMark)) && (rm->fragment())->type() != MsgType::REPLY ) // if message not Reply, try collect the rest for Call
108 if(collection.data_size() < (sizeof(CallHeader) + sizeof(RecordMark)) && (rm->fragment())->type() != MsgType::REPLY) // if message not Reply, try collect the rest for Call
110109 {
111110 return true;
112111 }
113 if (rm->fragment_len() >= sizeof(ReplyHeader)) // incorrect fragment len, not valid rpc message
114 {
115 if (validate_header(rm->fragment(), rm->fragment_len() + sizeof(RecordMark) ) )
112 if(rm->fragment_len() >= sizeof(ReplyHeader)) // incorrect fragment len, not valid rpc message
113 {
114 if(validate_header(rm->fragment(), rm->fragment_len() + sizeof(RecordMark)))
116115 {
117116 return BaseImpl::read_message(info);
118117 }
122121
123122 inline bool validate_header(const MessageHeader* const msg, const size_t len)
124123 {
125 switch (msg->type())
124 switch(msg->type())
126125 {
127126 case MsgType::CALL:
128127 {
129128 auto call = static_cast<const CallHeader* const>(msg);
130 if (RPCValidator::check(call))
131 {
132 BaseImpl::setMsgLen(len); // length of current RPC message
133 if (protocols::NFS3::Validator::check(call))
134 {
135 uint32_t proc {call->proc()};
136 if (API::ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit
129 if(RPCValidator::check(call))
130 {
131 BaseImpl::setMsgLen(len); // length of current RPC message
132 if(protocols::NFS3::Validator::check(call))
133 {
134 uint32_t proc{call->proc()};
135 if(API::ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit
137136 {
138137 BaseImpl::setToBeCopied(nfs3_rw_hdr_max < len ? nfs3_rw_hdr_max : len);
139138 }
140139 else
141140 {
142 if (API::ProcEnumNFS3::READ == proc)
141 if(API::ProcEnumNFS3::READ == proc)
143142 {
144143 nfs3_read_match.insert(call->xid());
145144 }
147146 }
148147 //TRACE("%p| MATCH RPC Call xid:%u len: %u procedure: %u", this, call->xid(), msg_len, call->proc());
149148 }
150 else if (protocols::NFS4::Validator::check(call))
149 else if(protocols::NFS4::Validator::check(call))
151150 {
152151 BaseImpl::setToBeCopied(len);
153152 }
154153 else
155154 {
156155 //* RPC call message must be read out ==> msg_len !=0
157 BaseImpl::setToBeCopied(0);// don't collect headers of unknown calls
156 BaseImpl::setToBeCopied(0); // don't collect headers of unknown calls
158157 //TRACE("Unknown RPC call of program: %u version: %u procedure: %u", call->prog(), call->vers(), call->proc());
159158 }
160159 return true;
161160 }
162161 else
163162 {
164 return false; // isn't RPC Call, stream is corrupt
163 return false; // isn't RPC Call, stream is corrupt
165164 }
166165 }
167166 break;
168167 case MsgType::REPLY:
169168 {
170169 auto reply = static_cast<const ReplyHeader* const>(msg);
171 if (RPCValidator::check(reply))
172 {
173 BaseImpl::setMsgLen(len); // length of current RPC message
170 if(RPCValidator::check(reply))
171 {
172 BaseImpl::setMsgLen(len); // length of current RPC message
174173 // Truncate NFSv3 READ reply message to NFSv3-RW-limit
175174 //* Collect fully if reply received before matching call
176 if (nfs3_read_match.erase(reply->xid()) > 0)
175 if(nfs3_read_match.erase(reply->xid()) > 0)
177176 {
178177 BaseImpl::setToBeCopied(std::min(nfs3_rw_hdr_max, len));
179178 }
180179 else
181180 {
182 BaseImpl::setToBeCopied(len);// length of current RPC message
181 BaseImpl::setToBeCopied(len); // length of current RPC message
183182 }
184183 //TRACE("%p| MATCH RPC Reply xid:%u len: %u", this, reply->xid(), msg_len);
185184 return true;
203202 }
204203
205204 private:
206 size_t nfs3_rw_hdr_max {512}; // limit for NFSv3 to truncate WRITE call and READ reply messages
205 size_t nfs3_rw_hdr_max{512}; // limit for NFSv3 to truncate WRITE call and READ reply messages
207206 MessageSet nfs3_read_match;
208207 };
209208
210209 } // namespace filtration
211210 } // namespace NST
212211 //------------------------------------------------------------------------------
213 #endif//RPC_FILTRATOR_H
214 //------------------------------------------------------------------------------
212 #endif // RPC_FILTRATOR_H
213 //------------------------------------------------------------------------------
3737 {
3838 namespace filtration
3939 {
40
4140 struct MapperImpl
4241 {
4342 using Session = NST::utils::Session;
4746
4847 static inline Session::Direction ipv4_direction(const Session& key)
4948 {
50 if(key.port[0] < key.port[1]) return Session::Source;
51 else
52 if(key.port[0] > key.port[1]) return Session::Destination;
49 if(key.port[0] < key.port[1])
50 return Session::Source;
51 else if(key.port[0] > key.port[1])
52 return Session::Destination;
5353
5454 // Ok, ports are equal, compare addresses
5555 return (key.ip.v4.addr[0] < key.ip.v4.addr[1]) ? Session::Source : Session::Destination;
5757
5858 struct IPv4PortsKeyHash
5959 {
60 inline std::size_t operator() (const Session& key) const
60 inline std::size_t operator()(const Session& key) const
6161 {
6262 return key.port[0] +
6363 key.port[1] +
6868
6969 struct IPv4PortsKeyEqual
7070 {
71 inline bool operator() (const Session& a, const Session& b) const
71 inline bool operator()(const Session& a, const Session& b) const
7272 {
7373 if((a.port[0] == b.port[0]) &&
7474 (a.port[1] == b.port[1]) &&
8787
8888 static inline Session::Direction ipv6_direction(const Session& key)
8989 {
90 if(key.port[0] < key.port[1]) return Session::Source;
91 else
92 if(key.port[0] > key.port[1]) return Session::Destination;
90 if(key.port[0] < key.port[1])
91 return Session::Source;
92 else if(key.port[0] > key.port[1])
93 return Session::Destination;
9394
9495 // Ok, ports are equal, compare addresses
95 const uint32_t* s { key.ip.v6.addr_uint32[0] };
96 const uint32_t* d { key.ip.v6.addr_uint32[1] };
96 const uint32_t* s{key.ip.v6.addr_uint32[0]};
97 const uint32_t* d{key.ip.v6.addr_uint32[1]};
9798
9899 if(s[0] != d[0]) return (s[0] < d[0]) ? Session::Source : Session::Destination;
99100 if(s[1] != d[1]) return (s[1] < d[1]) ? Session::Source : Session::Destination;
100101 if(s[2] != d[2]) return (s[2] < d[2]) ? Session::Source : Session::Destination;
101102
102 return (s[3] < d[3]) ? Session::Source : Session::Destination;
103 return (s[3] < d[3]) ? Session::Source : Session::Destination;
103104 }
104105
105106 static inline void copy_ipv6(uint32_t dst[4], const uint8_t src[16])
106107 {
107 // TODO:: fix alignment of src!
108 const uint32_t* s { reinterpret_cast<const uint32_t*>(src) };
109 dst[0] = s[0];
110 dst[1] = s[1];
111 dst[2] = s[2];
112 dst[3] = s[3];
108 uint8_t* d{reinterpret_cast<uint8_t*>(dst)};
109 memcpy(d, src, sizeof(uint32_t) * 4);
113110 }
114111
115112 struct IPv6PortsKeyHash
116113 {
117 std::size_t operator() (const Session& key) const
114 std::size_t operator()(const Session& key) const
118115 {
119116 std::size_t ret = key.port[0] + key.port[1];
120117
142139 a[3] == b[3];
143140 }
144141
145 bool operator() (const Session& a, const Session& b) const
142 bool operator()(const Session& a, const Session& b) const
146143 {
147144 if((a.port[0] == b.port[0]) && (a.port[1] == b.port[1]))
148145 {
149 if( eq_ipv6_address(a.ip.v6.addr_uint32[0], b.ip.v6.addr_uint32[0] )
150 && eq_ipv6_address(a.ip.v6.addr_uint32[1], b.ip.v6.addr_uint32[1] ))
146 if(eq_ipv6_address(a.ip.v6.addr_uint32[0], b.ip.v6.addr_uint32[0]) && eq_ipv6_address(a.ip.v6.addr_uint32[1], b.ip.v6.addr_uint32[1]))
151147 return true;
152148 }
153149
154150 if((a.port[1] == b.port[0]) && (a.port[0] == b.port[1]))
155151 {
156 if( eq_ipv6_address(a.ip.v6.addr_uint32[1], b.ip.v6.addr_uint32[0] )
157 && eq_ipv6_address(a.ip.v6.addr_uint32[0], b.ip.v6.addr_uint32[1] ))
152 if(eq_ipv6_address(a.ip.v6.addr_uint32[1], b.ip.v6.addr_uint32[0]) && eq_ipv6_address(a.ip.v6.addr_uint32[0], b.ip.v6.addr_uint32[1]))
158153 return true;
159154 }
160155 return false;
283278 };
284279
285280 // SessionsHash creates sessions and stores them in hash
286 template
287 <
288 typename Mapper, // map PacketInfo& to SessionImpl*
289 typename SessionImpl, // mapped type
290 typename Writer
291 >
281 template <
282 typename Mapper, // map PacketInfo& to SessionImpl*
283 typename SessionImpl, // mapped type
284 typename Writer>
292285 class SessionsHash
293286 {
294287 public:
300293 typename Mapper::KeyEqual>;
301294
302295 SessionsHash(Writer* w)
303 : sessions { }
304 , writer {w}
305 , max_hdr {0}
296 : sessions{}
297 , writer{w}
298 , max_hdr{0}
306299 {
307300 max_hdr = controller::Parameters::rpcmsg_limit();
308301 }
322315 auto i = sessions.find(key);
323316 if(i == sessions.end())
324317 {
325 std::unique_ptr<SessionImpl> ptr{ new SessionImpl{writer, max_hdr} };
318 std::unique_ptr<SessionImpl> ptr{new SessionImpl{writer, max_hdr}};
326319
327320 auto res = sessions.emplace(key, ptr.get());
328321 if(res.second) // add new - success
342335 private:
343336 Container sessions;
344337 Writer* writer;
345 uint32_t max_hdr;
338 uint32_t max_hdr;
346339 };
347340
348341 } // namespace filtration
349342 } // namespace NST
350343 //------------------------------------------------------------------------------
351 #endif//SESSIONS_HASH_H
352 //------------------------------------------------------------------------------
344 #endif // SESSIONS_HASH_H
345 //------------------------------------------------------------------------------
3030 {
3131 Parameters params(argc, argv); // set and validate CLI options
3232
33 if (params.show_help() || params.show_enum())
33 if(params.show_help() || params.show_enum())
3434 {
3535 return 0; // -h or -E were passed
3636 }
3939
4040 return controller.run();
4141 }
42 catch (const std::exception& e)
42 catch(const std::exception& e)
4343 {
4444 std::cerr << argv[0] << ": " << e.what() << std::endl;
4545 return -1;
4646 }
47 catch (...)
47 catch(...)
4848 {
4949 std::cerr << argv[0] << ": Unknown exception" << std::endl;
5050 return -1;
2020 //------------------------------------------------------------------------------
2121 #include <cassert>
2222
23 #include "api/plugin_api.h" // for NST_PUBLIC
2324 #include "protocols/cifs/cifs.h"
2425 //------------------------------------------------------------------------------
2526 using namespace NST::protocols::CIFSv1;
2627 using namespace NST::API;
27 union SMBCode
28 {
29 uint8_t codes[4];
28 union SMBCode {
29 uint8_t codes[4];
3030 uint32_t code;
3131 };
3232
4444
4545 const NST::protocols::CIFSv1::MessageHeader* NST::protocols::CIFSv1::get_header(const uint8_t* data)
4646 {
47 static uint32_t code = get_code ();
47 static uint32_t code = get_code();
4848
49 const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data));
50 if (header->head_code == code)
49 const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data));
50 if(header->head_code == code)
5151 {
5252 return header;
5353 }
5959 return static_cast<const uint8_t>(flag) & static_cast<const uint8_t>(flags);
6060 }
6161
62 const char* NST::protocols::CIFSv1::print_cifs1_procedures(SMBv1Commands cmd_code)
62 extern "C" NST_PUBLIC const char* print_cifs1_procedures(SMBv1Commands cmd_code)
6363 {
6464 assert(cmd_code < SMBv1Commands::CMD_COUNT);
6565
66 // clang-format off
6667 static const char* const commandNames[] =
6768 {
6869 "CREATE_DIRECTORY", "DELETE_DIRECTORY", "OPEN", "CREATE",
8586 "CLOSE_PRINT_FILE", "GET_PRINT_QUEUE", "READ_BULK", "WRITE_BULK",
8687 "WRITE_BULK_DATA", "INVALID", "NO_ANDX_COMMAND"
8788 };
89 // clang-format on
8890
8991 return commandNames[static_cast<int>(cmd_code)];
9092 }
2626 #include "api/cifs_types.h"
2727 #include "protocols/netbios/netbios.h"
2828 //------------------------------------------------------------------------------
29 #define NST_PUBLIC __attribute__ ((visibility("default")))
3029 //------------------------------------------------------------------------------
3130 namespace NST
3231 {
3433 {
3534 namespace CIFSv1
3635 {
36 // clang-format off
3737
3838 using SMBv1Commands = NST::API::SMBv1::SMBv1Commands;
3939
220220 return cmd;
221221 }
222222
223 extern "C"
224 NST_PUBLIC
225 const char* print_cifs1_procedures(SMBv1Commands cmd_code);
223 // clang-format on
226224
227225 } // namespace CIFSv1
228226 } // namespace protocols
229227 } // namespace NST
230228 //------------------------------------------------------------------------------
231 #endif//CIFS_HEADER_H
232 //------------------------------------------------------------------------------
229 #endif // CIFS_HEADER_H
230 //------------------------------------------------------------------------------
2323 #include <arpa/inet.h>
2424 #include <assert.h>
2525
26 #include "api/cifs_pc_to_net.h"
27 #include "api/plugin_api.h" // for NST_PUBLIC
28 #include "protocols/cifs/cifs.h"
2629 #include "protocols/cifs2/cifs2.h"
27 #include "protocols/cifs/cifs.h"
28 #include "api/cifs_pc_to_net.h"
2930 //------------------------------------------------------------------------------
3031 using namespace NST::protocols::CIFSv2;
3132
32 # if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN
33 #if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN
3334
3435 inline uint64_t ntohll(uint64_t input)
3536 {
3738 return input;
3839 }
3940
40 # else
41 # if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN
41 #else
42 #if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN
4243
4344 inline uint64_t ntohll(uint64_t input)
4445 {
4546 return be64toh(input);
4647 }
47 # endif
48 # endif
48 #endif
49 #endif
4950
50 union SMBCode
51 {
52 uint8_t codes[4];
51 union SMBCode {
52 uint8_t codes[4];
5353 uint32_t code;
5454 };
5555
6767
6868 const NST::protocols::CIFSv2::MessageHeader* NST::protocols::CIFSv2::get_header(const uint8_t* data)
6969 {
70 static uint32_t code = get_code ();
70 static uint32_t code = get_code();
7171
72 const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data));
73 if (header->head_code == code)
72 const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data));
73 if(header->head_code == code)
7474 {
7575 return header;
7676 }
8484
8585 void NST::protocols::CIFSv2::parseGuid(uint8_t (&guid)[16])
8686 {
87 Guid &p = reinterpret_cast<Guid&>(guid);
87 Guid& p = reinterpret_cast<Guid&>(guid);
8888 p.Data1 = le32toh(p.Data1);
8989 p.Data2 = le16toh(p.Data2);
9090 p.Data3 = le16toh(p.Data3);
9191 }
9292
93 void NST::protocols::CIFSv2::parse(SMBv2::ErrResponse*&) { }
93 void NST::protocols::CIFSv2::parse(SMBv2::ErrResponse*&)
94 {
95 }
9496 void NST::protocols::CIFSv2::parse(SMBv2::NegotiateRequest*& p)
9597 {
9698 parseGuid(p->clientGUID);
99101 {
100102 parseGuid(p->serverGUID);
101103 }
104
105 // clang-format off
102106 void NST::protocols::CIFSv2::parse(SMBv2::SessionSetupRequest*&){ }
103107 void NST::protocols::CIFSv2::parse(SMBv2::SessionSetupResponse*&) { }
104108 void NST::protocols::CIFSv2::parse(SMBv2::LogOffRequest*&) { }
137141 void NST::protocols::CIFSv2::parse(SMBv2::SetInfoResponse*&){ }
138142 void NST::protocols::CIFSv2::parse(SMBv2::CancelResponce*&){ }
139143 void NST::protocols::CIFSv2::parse(SMBv2::CancelRequest*&){ }
144 // clang-format on
140145
141146 // TODO: This implementation currently copy of
142147 // epm-nfs/analyzers/src/cifs/cifs2_commands.cpp
143148 // const std::string NST::breakdown::SMBv2Commands::command_name(int cmd_code)
144149 // Futre fix: We need to merege these enums
145150 // TODO: Move implementation to some common module
146 const char* NST::protocols::CIFSv2::print_cifs2_procedures(SMBv2Commands cmd)
151 extern "C" NST_PUBLIC const char* print_cifs2_procedures(SMBv2Commands cmd)
147152 {
148153 assert(cmd < SMBv2Commands::CMD_COUNT);
149154
155 // clang-format off
150156 static const char* const commandNames[] =
151157 {
152158 "NEGOTIATE", "SESSION SETUP", "LOGOFF", "TREE CONNECT",
155161 "CANCEL", "ECHO", "QUERY DIRECTORY", "CHANGE NOTIFY",
156162 "QUERY INFO", "SET INFO", "OPLOCK BREAK"
157163 };
164 // clang-format on
158165
159166 return commandNames[static_cast<int>(cmd)];
160167 }
161
2121 #ifndef CIFSv2_HEADER_H
2222 #define CIFSv2_HEADER_H
2323 //------------------------------------------------------------------------------
24 #include "api/cifs2_commands.h"
2425 #include "api/cifs_commands.h"
25 #include "api/cifs2_commands.h"
2626 #include "protocols/cifs/cifs.h"
2727 //------------------------------------------------------------------------------
2828 namespace NST
3131 {
3232 namespace CIFSv2
3333 {
34
3534 using SMBv2Commands = NST::API::SMBv2::SMBv2Commands;
36 namespace SMBv2 = NST::API::SMBv2;
35 namespace SMBv2 = NST::API::SMBv2;
36 // clang-format off
3737 // https://msdn.microsoft.com/en-us/library/ff718266.aspx
3838 struct Guid
3939 {
112112 * \return pointer to input data which is casted to header structure or nullptr (if it is not valid header)
113113 */
114114 const MessageHeader* get_header(const uint8_t* data);
115
116 // clang-format on
115117
116118 void parseGuid(uint8_t (&guid)[16]);
117119 void parse(SMBv2::ErrResponse*&);
176178 // we have to cast raw data to pointer type ( in contrast to const pointer )
177179 //
178180 auto req_header = reinterpret_cast<RawMessageHeader*>(request->data);
179 auto pargs = reinterpret_cast<typename Cmd::RequestType*>(request->data + sizeof(RawMessageHeader));
181 auto pargs = reinterpret_cast<typename Cmd::RequestType*>(request->data + sizeof(RawMessageHeader));
180182
181183 parse(pargs);
182184
184186 if(response)
185187 {
186188 cmd.res_header = reinterpret_cast<RawMessageHeader*>(response->data);
187 cmd.pres = reinterpret_cast<typename Cmd::ResponseType*>(response->data + sizeof(RawMessageHeader));
189 cmd.pres = reinterpret_cast<typename Cmd::ResponseType*>(response->data + sizeof(RawMessageHeader));
188190 }
189 cmd.parg = pargs;
191 cmd.parg = pargs;
190192 return cmd;
191193 }
192
193 extern "C"
194 NST_PUBLIC
195 const char* print_cifs2_procedures(SMBv2Commands cmd_code);
196194
197195 } // namespace CIFSv2
198196 } // namespace protocols
199197 } // namespace NST
200198 //------------------------------------------------------------------------------
201 #endif//CIFSv2_HEADER_H
202 //------------------------------------------------------------------------------
199 #endif // CIFSv2_HEADER_H
200 //------------------------------------------------------------------------------
00 //------------------------------------------------------------------------------
1 // Author: Artsem Iliasau
1 // Author: Artsem Iliasau
22 // Description: Helpers for parsing CIFSv2 structures.
33 // Copyright (c) 2015 EPAM Systems
44 //------------------------------------------------------------------------------
2121 #include <iostream>
2222 #include <type_traits>
2323
24 #include "cifs2.h"
25 #include "cifs2_utils.h"
24 #include "api/plugin_api.h" // for print_cifs2_procedures(value)
25 #include "protocols/cifs2/cifs2.h"
26 #include "protocols/cifs2/cifs2_utils.h"
2627 #include "protocols/nfs/nfs_utils.h"
2728 //------------------------------------------------------------------------------
2829 static const std::string flagDelimiter = " | ";
3334 {
3435 namespace CIFSv2
3536 {
36
3737 using namespace NST::API::SMBv2;
3838
3939 namespace
4040 {
41
4241 template <typename T>
4342 void print_flag_if_set(std::ostream& out, const std::string& name, typename std::underlying_type<T>::type& value, T flag)
4443 {
4544 auto int_flag = to_integral(flag);
46 if (value & int_flag)
45 if(value & int_flag)
4746 {
4847 out << name;
4948 value = value & ~int_flag;
5453
5554 const char* enumToString(OplockLevels value)
5655 {
56 // clang-format off
5757 switch (value)
5858 {
5959 case OplockLevels::NONE: return "NONE";
6262 case OplockLevels::BATCH: return "BATCH";
6363 case OplockLevels::LEASE: return "LEASE";
6464 }
65 // clang-format on
6566
6667 return nullptr;
6768 }
6869
6970 const char* enumToString(ImpersonationLevels value)
7071 {
72 // clang-format off
7173 switch (value)
7274 {
7375 case ImpersonationLevels::ANONYMOUS: return "ANONYMOUS";
7577 case ImpersonationLevels::IMPERSONATION: return "IMPERSONATION";
7678 case ImpersonationLevels::DELEGATE: return "DELEGATE";
7779 }
80 // clang-format on
7881
7982 return nullptr;
8083 }
8184
8285 const char* enumToString(CreateDisposition value)
8386 {
87 // clang-format off
8488 switch (value)
8589 {
8690 case CreateDisposition::SUPERSEDE: return "SUPERSEDE";
9094 case CreateDisposition::OVERWRITE: return "OVERWRITE";
9195 case CreateDisposition::OVERWRITE_IF: return "OVERWRITE_IF";
9296 }
97 // clang-format on
9398
9499 return nullptr;
95100 }
96101
97102 const char* enumToString(CreateActions value)
98103 {
104 // clang-format off
99105 switch (value)
100106 {
101107 case CreateActions::SUPERSEDED: return "SUPERSEDED";
103109 case CreateActions::CREATED: return "CREATED";
104110 case CreateActions::FILE_OVERWRITTEN: return "FILE_OVERWRITTEN";
105111 }
112 // clang-format on
106113
107114 return nullptr;
108115 }
109116
110117 const char* enumToString(ShareTypes value)
111118 {
119 // clang-format off
112120 switch (value)
113121 {
114122 case ShareTypes::DISK: return "SMB2_SHARE_TYPE_DISK";
115123 case ShareTypes::PIPE: return "SMB2_SHARE_TYPE_PIPE";
116124 case ShareTypes::PRINT: return "SMB2_SHARE_TYPE_PRINT";
117125 }
126 // clang-format on
118127
119128 return nullptr;
120129 }
121130
122131 const char* enumToString(NTStatus value)
123132 {
133 // clang-format off
124134 switch (value)
125135 {
126136 case NTStatus::STATUS_SUCCESS: return "STATUS_SUCCESS";
150160 case NTStatus::STATUS_NOT_A_DIRECTORY: return "STATUS_NOT_A_DIRECTORY";
151161 case NTStatus::STATUS_CANCELLED: return "STATUS_CANCELLED";
152162 }
163 // clang-format on
153164
154165 return nullptr;
155166 }
156167
157168 const char* enumToString(FsInfoLevels value)
158169 {
170 // clang-format off
159171 switch (value)
160172 {
161173 case FsInfoLevels::SMB2_FS_INFO_01: return "SMB2_FS_INFO_01";
166178 case FsInfoLevels::SMB2_FS_INFO_06: return "SMB2_FS_INFO_06";
167179 case FsInfoLevels::SMB2_FS_INFO_07: return "SMB2_FS_INFO_07";
168180 }
181 // clang-format on
169182
170183 return nullptr;
171184 }
172185
173186 const char* enumToString(QueryInfoLevels value)
174187 {
188 // clang-format off
175189 switch (value)
176190 {
177191 case QueryInfoLevels::DIRECTORY_INFORMATION: return "DIRECTORY_INFORMATION";
220234 case QueryInfoLevels::ID_GLOBAL_TX_DIRECTORY_INFORMATION: return "ID_GLOBAL_TX_DIRECTORY_INFORMATION";
221235 case QueryInfoLevels::STANDARD_LINK_INFORMATION: return "STANDARD_LINK_INFORMATION";
222236 }
237 // clang-format on
223238
224239 return nullptr;
225240 }
226241
227242 const char* enumToString(CtlCodes value)
228243 {
244 // clang-format off
229245 switch (value)
230246 {
231247 case CtlCodes::SCTL_DFS_GET_REFERRALS: return "SCTL_DFS_GET_REFERRALS";
244260 case CtlCodes::FSCTL_FILE_LEVEL_TRIM: return "FSCTL_FILE_LEVEL_TRIM";
245261 case CtlCodes::FSCTL_VALIDATE_NEGOTIATE_INFO: return "FSCTL_VALIDATE_NEGOTIATE_INFO";
246262 }
263 // clang-format on
247264
248265 return nullptr;
249266 }
250267
251268 const char* enumToString(InfoTypes value)
252269 {
270 // clang-format off
253271 switch (value)
254272 {
255273 case InfoTypes::FILE: return "SMB2_0_INFO_FILE";
257275 case InfoTypes::SECURITY: return "SMB2_0_INFO_SECURITY";
258276 case InfoTypes::QUOTA: return "SMB2_0_INFO_QUOTA";
259277 }
278 // clang-format on
260279
261280 return nullptr;
262281 }
263282
264283 const char* enumToString(SessionFlagsBinding value)
265 {
266 switch (value)
267 {
268 case SessionFlagsBinding::NONE: return "NONE";
269 case SessionFlagsBinding::BINDING: return "BINDING";
270 }
271
272 return nullptr;
273 }
274
275 }
284 {
285 // clang-format off
286 switch (value)
287 {
288 case SessionFlagsBinding::NONE: return "NONE";
289 case SessionFlagsBinding::BINDING: return "BINDING";
290 }
291 // clang-format on
292
293 return nullptr;
294 }
295
296 } // namespace <unnamed>
276297
277298 std::ostream& operator<<(std::ostream& out, const SMBv2::SMBv2Commands value)
278299 {
279 const char* strCommand = NST::protocols::CIFSv2::print_cifs2_procedures(value);
300 const char* strCommand = print_cifs2_procedures(value);
280301
281302 out << "(" << strCommand << ")";
282303
285306
286307 std::ostream& operator<<(std::ostream& out, const OplockLevels value)
287308 {
288 const char *strValue = enumToString(value);
289 if (strValue != nullptr)
309 const char* strValue = enumToString(value);
310 if(strValue != nullptr)
290311 {
291312 out << "(" << strValue << ")";
292313 }
296317
297318 std::ostream& operator<<(std::ostream& out, const ImpersonationLevels value)
298319 {
299 const char *strValue = enumToString(value);
300 if (strValue != nullptr)
320 const char* strValue = enumToString(value);
321 if(strValue != nullptr)
301322 {
302323 out << "(" << strValue << ")";
303324 }
307328
308329 std::ostream& operator<<(std::ostream& out, const CreateDisposition value)
309330 {
310 const char *strValue = enumToString(value);
311 if (strValue != nullptr)
331 const char* strValue = enumToString(value);
332 if(strValue != nullptr)
312333 {
313334 out << "(" << strValue << ")";
314335 }
318339
319340 std::ostream& operator<<(std::ostream& out, const CreateActions value)
320341 {
321 const char *strValue = enumToString(value);
322 if (strValue != nullptr)
342 const char* strValue = enumToString(value);
343 if(strValue != nullptr)
323344 {
324345 out << "(" << strValue << ")";
325346 }
329350
330351 std::ostream& operator<<(std::ostream& out, const ShareTypes value)
331352 {
332 const char *strValue = enumToString(value);
333 if (strValue != nullptr)
353 const char* strValue = enumToString(value);
354 if(strValue != nullptr)
334355 {
335356 out << "(" << strValue << ")";
336357 }
339360 }
340361
341362 std::ostream& operator<<(std::ostream& out, const NTStatus value)
342 {
343 const char *strValue = enumToString(value);
344 if (strValue != nullptr)
363 {
364 const char* strValue = enumToString(value);
365 if(strValue != nullptr)
345366 {
346367 out << "(" << strValue << ")";
347368 }
353374 {
354375 auto int_value = to_integral(value);
355376
356 if (int_value > 0)
357 {
358 out << "(";
377 if(int_value > 0)
378 {
379 out << "(";
380 // clang-format off
359381 print_flag_if_set(out, "READ_DATA_LE", int_value, DesiredAccessFlags::READ_DATA_LE);
360382 print_flag_if_set(out, "WRITE_DATA_LE", int_value, DesiredAccessFlags::WRITE_DATA_LE);
361383 print_flag_if_set(out, "APPEND_DATA_LE", int_value, DesiredAccessFlags::APPEND_DATA_LE);
375397 print_flag_if_set(out, "GENERIC_EXECUTE_LE", int_value, DesiredAccessFlags::GENERIC_EXECUTE_LE);
376398 print_flag_if_set(out, "GENERIC_WRITE_LE", int_value, DesiredAccessFlags::GENERIC_WRITE_LE);
377399 print_flag_if_set(out, "GENERIC_READ_LE", int_value, DesiredAccessFlags::GENERIC_READ_LE);
400 // clang-format on
378401 out << ")";
379402 }
380403 return out;
384407 {
385408 auto int_value = to_integral(value);
386409
387 if (int_value > 0)
388 {
389 out << "(";
410 if(int_value > 0)
411 {
412 out << "(";
413 // clang-format off
390414 print_flag_if_set(out, "READONLY", int_value, FileAttributes::READONLY);
391415 print_flag_if_set(out, "HIDDEN", int_value, FileAttributes::HIDDEN);
392416 print_flag_if_set(out, "SYSTEM", int_value, FileAttributes::SYSTEM);
400424 print_flag_if_set(out, "OFFLINE", int_value, FileAttributes::OFFLINE);
401425 print_flag_if_set(out, "NOT_CONTENT_INDEXED", int_value, FileAttributes::NOT_CONTENT_INDEXED);
402426 print_flag_if_set(out, "ENCRYPTED", int_value, FileAttributes::ENCRYPTED);
427 // clang-format on
403428 out << ")";
404429 }
405430
409434 std::ostream& operator<<(std::ostream& out, const ShareAccessFlags value)
410435 {
411436 auto int_value = to_integral(value);
412 if (int_value > 0)
413 {
414 out << "(";
437 if(int_value > 0)
438 {
439 out << "(";
440 // clang-format off
415441 print_flag_if_set(out, "SHARE_READ_LE", int_value, ShareAccessFlags::SHARE_READ_LE);
416442 print_flag_if_set(out, "SHARE_WRITE_LE", int_value, ShareAccessFlags::SHARE_WRITE_LE);
417443 print_flag_if_set(out, "SHARE_DELETE_LE", int_value, ShareAccessFlags::SHARE_DELETE_LE);
444 // clang-format on
418445 out << ")";
419446 }
420447
425452 {
426453 auto int_value = to_integral(value);
427454
428 if (int_value > 0)
429 {
430 out << "(";
455 if(int_value > 0)
456 {
457 out << "(";
458 // clang-format off
431459 print_flag_if_set(out, "DIRECTORY_FILE_LE", int_value, CreateOptionsFlags::DIRECTORY_FILE_LE);
432460 print_flag_if_set(out, "WRITE_THROUGH_LE", int_value, CreateOptionsFlags::WRITE_THROUGH_LE);
433461 print_flag_if_set(out, "SEQUENTIAL_ONLY_LE", int_value, CreateOptionsFlags::SEQUENTIAL_ONLY_LE);
446474 print_flag_if_set(out, "OPEN_REPARSE_POINT_LE", int_value, CreateOptionsFlags::OPEN_REPARSE_POINT_LE);
447475 print_flag_if_set(out, "OPEN_NO_RECALL_LE", int_value, CreateOptionsFlags::OPEN_NO_RECALL_LE);
448476 print_flag_if_set(out, "OPEN_FOR_FREE_SPACE_QUERY_LE", int_value, CreateOptionsFlags::OPEN_FOR_FREE_SPACE_QUERY_LE);
477 // clang-format on
449478 out << ")";
450479 }
451480
456485 {
457486 auto int_value = to_integral(value);
458487
459 if (int_value > 0)
460 {
461 out << "(";
488 if(int_value > 0)
489 {
490 out << "(";
491 // clang-format off
462492 print_flag_if_set(out, "SMB2_WRITEFLAG_WRITE_THROUGH", int_value, WriteFlags::SMB2_WRITEFLAG_WRITE_THROUGH);
463493 print_flag_if_set(out, "SMB2_WRITEFLAG_WRITE_UNBUFFERED", int_value, WriteFlags::SMB2_WRITEFLAG_WRITE_UNBUFFERED);
494 // clang-format on
464495 out << ")";
465496 }
466497 return out;
471502 auto int_value = to_integral(value) & ~to_integral(ShareFlags::NO_CACHING);
472503
473504 out << "Caching policy = ";
505 // clang-format off
474506 switch(to_integral(value) & to_integral(ShareFlags::NO_CACHING))
475507 {
476508 case to_integral(ShareFlags::MANUAL_CACHING): out << "MANUAL_CACHING"; break;
493525 print_flag_if_set(out, "SMB2_SHAREFLAG_ENABLE_HASH_V2", int_value, ShareFlags::ENABLE_HASH_2);
494526 print_flag_if_set(out, "SMB2_SHAREFLAG_ENCRYPT_DATA", int_value, ShareFlags::ENABLE_ENCRYPT_DATA);
495527 }
528 // clang-format on
496529
497530 return out;
498531 }
502535 auto int_value = to_integral(value);
503536
504537 if(int_value > 0)
505 {
506 out << "(";
538 {
539 out << "(";
540 // clang-format off
507541 print_flag_if_set(out, "SMB2_SHARE_CAP_DFS", int_value, ShareCapabilities::DFS);
508542 print_flag_if_set(out, "SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY", int_value, ShareCapabilities::CONTINUOUS_AVAILABILITY);
509543 print_flag_if_set(out, "SMB2_SHARE_CAP_SCALEOUT", int_value, ShareCapabilities::SCALEOUT);
510544 print_flag_if_set(out, "SMB2_SHARE_CAP_CLUSTER", int_value, ShareCapabilities::CLUSTER);
511545 print_flag_if_set(out, "SMB2_SHARE_CAP_ASYMMETRIC", int_value, ShareCapabilities::ASYMMETRIC);
546 // clang-format on
512547 out << ")";
513548 }
514549
519554 {
520555 auto int_value = to_integral(value);
521556
522 if (int_value > 0)
523 {
524 out << "(";
557 if(int_value > 0)
558 {
559 out << "(";
560 // clang-format off
525561 print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityModeShort::SIGNING_ENABLED);
526562 print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityModeShort::SIGNING_REQUIRED);
563 // clang-format on
527564 out << ")";
528565 }
529566 return out;
536573 if(int_value > 0)
537574 {
538575 out << "(";
576 // clang-format off
539577 print_flag_if_set(out, "DFS", int_value, Capabilities::DFS);
540578 print_flag_if_set(out, "LEASING", int_value, Capabilities::LEASING);
541579 print_flag_if_set(out, "LARGE_MTU", int_value, Capabilities::LARGE_MTU);
543581 print_flag_if_set(out, "PERSISTENT_HANDLES",int_value, Capabilities::PERSISTENT_HANDLES);
544582 print_flag_if_set(out, "DIRECTORY_LEASING", int_value, Capabilities::DIRECTORY_LEASING);
545583 print_flag_if_set(out, "ENCRYPTION", int_value, Capabilities::ENCRYPTION);
584 // clang-format on
546585 out << ")";
547586 }
548587
552591 std::ostream& operator<<(std::ostream& out, const SessionFlags value)
553592 {
554593 auto int_value = to_integral(value);
555
594 // clang-format off
556595 print_flag_if_set(out, "NONE", int_value, SessionFlags::NONE);
557596 print_flag_if_set(out, "SMB2_SESSION_FLAG_IS_GUEST", int_value, SessionFlags::IS_GUEST);
558597 print_flag_if_set(out, "SMB2_SESSION_FLAG_IS_NULL", int_value, SessionFlags::IS_NULL);
559598 print_flag_if_set(out, "SMB2_SESSION_FLAG_ENCRYPT_DATA",int_value, SessionFlags::IS_ENCRYPT_DATA);
560
599 // clang-format on
561600 return out;
562601 }
563602
565604 {
566605 auto int_value = to_integral(value);
567606
568 if (int_value > 0)
569 {
570 out << "(";
607 if(int_value > 0)
608 {
609 out << "(";
610 // clang-format off
571611 print_flag_if_set(out, "FILE_READ_DATA", int_value, AccessMask::FILE_READ_DATA);
572612 print_flag_if_set(out, "FILE_WRITE_DATA", int_value, AccessMask::FILE_WRITE_DATA);
573613 print_flag_if_set(out, "FILE_APPEND_DATA", int_value, AccessMask::FILE_APPEND_DATA);
588628 print_flag_if_set(out, "GENERIC_EXECUTE", int_value, AccessMask::GENERIC_EXECUTE);
589629 print_flag_if_set(out, "GENERIC_WRITE", int_value, AccessMask::GENERIC_WRITE);
590630 print_flag_if_set(out, "GENERIC_READ", int_value, AccessMask::GENERIC_READ);
631 // clang-format on
591632 out << ")";
592633 }
593634
601642 if(int_value > 0)
602643 {
603644 out << "(";
604 print_flag_if_set(out, "POSTQUERY_ATTRIB", int_value, CloseFlags::POSTQUERY_ATTRIB);
645 print_flag_if_set(out, "POSTQUERY_ATTRIB", int_value, CloseFlags::POSTQUERY_ATTRIB);
605646 out << ")";
606647 }
607648
612653 {
613654 auto int_value = to_integral(value);
614655
615 if (int_value > 0)
616 {
617 out << "(";
618 print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityMode::SIGNING_ENABLED);
619 print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityMode::SIGNING_REQUIRED);
656 if(int_value > 0)
657 {
658 out << "(";
659 print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityMode::SIGNING_ENABLED);
660 print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityMode::SIGNING_REQUIRED);
620661 out << ")";
621662 }
622663
625666
626667 std::ostream& operator<<(std::ostream& out, const FsInfoLevels value)
627668 {
628 const char *strValue = enumToString(value);
629 if (strValue != nullptr)
669 const char* strValue = enumToString(value);
670 if(strValue != nullptr)
630671 {
631672 out << "(" << strValue << ")";
632673 }
636677
637678 std::ostream& operator<<(std::ostream& out, const QueryInfoLevels value)
638679 {
639 const char *strValue = enumToString(value);
640 if (strValue != nullptr)
680 const char* strValue = enumToString(value);
681 if(strValue != nullptr)
641682 {
642683 out << "(" << strValue << ")";
643684 }
647688
648689 std::ostream& operator<<(std::ostream& out, const CtlCodes value)
649690 {
650 const char *strValue = enumToString(value);
651 if (strValue != nullptr)
691 const char* strValue = enumToString(value);
692 if(strValue != nullptr)
652693 {
653694 out << "(" << strValue << ")";
654695 }
658699
659700 std::ostream& operator<<(std::ostream& out, const InfoTypes value)
660701 {
661 const char *strValue = enumToString(value);
662 if (strValue != nullptr)
702 const char* strValue = enumToString(value);
703 if(strValue != nullptr)
663704 {
664705 out << "(" << strValue << ")";
665706 }
669710
670711 std::ostream& operator<<(std::ostream& out, const SessionFlagsBinding value)
671712 {
672 const char *strValue = enumToString(value);
673 if (strValue != nullptr)
713 const char* strValue = enumToString(value);
714 if(strValue != nullptr)
674715 {
675716 out << "(" << strValue << ")";
676717 }
681722 std::ostream& operator<<(std::ostream& out, const Flags value)
682723 {
683724 auto int_value = to_integral(value);
684 if (int_value > 0)
725 if(int_value > 0)
685726 {
686727 out << "(";
687728 print_flag_if_set(out, "SERVER_TO_REDIR", int_value, Flags::SERVER_TO_REDIR);
700741 {
701742 switch(infoType)
702743 {
703 case InfoTypes::FILE:
704 print_enum(out, "InfoLevel", static_cast<QueryInfoLevels>(infoClass));
705 break;
706 case InfoTypes::FILESYSTEM:
707 print_enum(out, "InfoLevel", static_cast<FsInfoLevels>(infoClass));
708 break;
709 default:
710 //we dont handle other classes
711 ;
744 case InfoTypes::FILE:
745 print_enum(out, "InfoLevel", static_cast<QueryInfoLevels>(infoClass));
746 break;
747 case InfoTypes::FILESYSTEM:
748 print_enum(out, "InfoLevel", static_cast<FsInfoLevels>(infoClass));
749 break;
750 default:
751 //we dont handle other classes
752 ;
712753 }
713754 return out;
714755 }
00 //------------------------------------------------------------------------------
1 // Author: Artsem Iliasau
1 // Author: Artsem Iliasau
22 // Description: Helpers for parsing CIFSv2 structures.
33 // Copyright (c) 2015 EPAM Systems
44 //------------------------------------------------------------------------------
3434 {
3535 namespace CIFSv2
3636 {
37
3837 namespace SMBv2 = NST::API::SMBv2;
3938
4039 /*! Convert enum type to underlying integer type
4140 * \param e - instance of enumeration to be converted
4241 * \return integer representation of enumeration
4342 */
44 template<typename E>
43 template <typename E>
4544 inline constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type
4645 {
4746 return static_cast<typename std::underlying_type<E>::type>(e);
7069 std::ostream& operator<<(std::ostream& out, const SMBv2::NTStatus value);
7170 std::ostream& operator<<(std::ostream& out, const SMBv2::AccessMask value);
7271 std::ostream& operator<<(std::ostream& out, const SMBv2::CloseFlags value);
73 std::ostream& operator<<(std::ostream& out, const SMBv2::SecurityMode value);
72 std::ostream& operator<<(std::ostream& out, const SMBv2::SecurityMode value);
7473 std::ostream& operator<<(std::ostream& out, Flags value);
7574
7675 template <typename T>
8382 print_hex(out, int_value);
8483 out << " " << (T)int_value;
8584 return out;
86 }
85 }
8786
8887 std::ostream& print_info_levels(std::ostream& os, const NST::API::SMBv2::InfoTypes infoType, const uint8_t infoClass);
8988
9190 } // namespace protocols
9291 } // namespace NST
9392 //------------------------------------------------------------------------------
94 #endif//CIFS2_UTILS_H
93 #endif // CIFS2_UTILS_H
9594 //------------------------------------------------------------------------------
2323 //------------------------------------------------------------------------------
2424 #include <cstdint>
2525
26 #include <arpa/inet.h> // for ntohs()
26 #include <arpa/inet.h> // for ntohs()
2727 //------------------------------------------------------------------------------
2828 namespace NST
2929 {
3131 {
3232 namespace ethernet
3333 {
34
3534 // Ethernet II (aka DIX v2.0 Ethernet)
3635 struct ethernet_header
3736 {
38 enum { ADDR_LEN = 6 };
37 enum
38 {
39 ADDR_LEN = 6
40 };
3941
4042 enum EtherType
4143 {
42 PUP = 0x0200, // Xerox PUP
43 SPRITE = 0x0500, // Sprite
44 IP = 0x0800, // IP
45 ARP = 0x0806, // Address resolution
46 REVARP = 0x8035, // Reverse ARP
47 AT = 0x809B, // AppleTalk protocol
48 AARP = 0x80F3, // AppleTalk ARP
49 VLAN = 0x8100, // IEEE 802.1Q VLAN tagging
50 IPX = 0x8137, // IPX
51 IPV6 = 0x86dd, // IP protocol version 6
52 LOOPBACK= 0x9000 // used to test interfaces
44 PUP = 0x0200, // Xerox PUP
45 SPRITE = 0x0500, // Sprite
46 IP = 0x0800, // IP
47 ARP = 0x0806, // Address resolution
48 REVARP = 0x8035, // Reverse ARP
49 AT = 0x809B, // AppleTalk protocol
50 AARP = 0x80F3, // AppleTalk ARP
51 VLAN = 0x8100, // IEEE 802.1Q VLAN tagging
52 IPX = 0x8137, // IPX
53 IPV6 = 0x86dd, // IP protocol version 6
54 LOOPBACK = 0x9000 // used to test interfaces
5355 };
5456
55 uint8_t eth_dhost[ADDR_LEN]; // destination host address
56 uint8_t eth_shost[ADDR_LEN]; // source host address
57 uint16_t eth_type; // protocol (EtherType values)
57 uint8_t eth_dhost[ADDR_LEN]; // destination host address
58 uint8_t eth_shost[ADDR_LEN]; // source host address
59 uint16_t eth_type; // protocol (EtherType values)
5860 } __attribute__((packed));
5961
6062 struct EthernetHeader : private ethernet_header
6163 {
62 inline const uint8_t* dst() const { return eth_dhost; }
63 inline const uint8_t* src() const { return eth_shost; }
64 inline const uint8_t* dst() const { return eth_dhost; }
65 inline const uint8_t* src() const { return eth_shost; }
6466 inline uint16_t type() const { return ntohs(eth_type); }
65 } __attribute__ ((__packed__));
67 } __attribute__((__packed__));
6668
6769 } // namespace ethernet
6870 } // namespace protocols
6971 } // namespace NST
7072 //------------------------------------------------------------------------------
71 #endif//ETHERNET_HEADER_H
73 #endif // ETHERNET_HEADER_H
7274 //------------------------------------------------------------------------------
3030 {
3131 namespace ip
3232 {
33
34 enum NextProtocol // ID of next protocol header
33 enum NextProtocol // ID of next protocol header
3534 {
36 IP = 0, // Dummy protocol for TCP
37 HOPOPTS = 0, // IPv6 Hop-by-Hop options
38 ICMP = 1, // Internet Control Message Protocol
39 IGMP = 2, // Internet Group Management Protocol
40 IPIP = 4, // IPIP tunnels (older KA9Q tunnels use 94)
41 TCP = 6, // Transmission Control Protocol
42 EGP = 8, // Exterior Gateway Protocol
43 PUP = 12, // PUP protocol
44 UDP = 17, // User Datagram Protocol
45 IDP = 22, // XNS IDP protocol
46 TP = 29, // SO Transport Protocol Class 4
47 DCCP = 33, // Datagram Congestion Control Protocol
48 IPV6 = 41, // IPv6 header
49 ROUTING = 43, // IPv6 routing header
50 FRAGMENT= 44, // IPv6 fragmentation header
51 RSVP = 46, // Reservation Protocol
52 GRE = 47, // General Routing Encapsulation
53 ESP = 50, // encapsulating security payload
54 AH = 51, // authentication header
55 ICMPV6 = 58, // ICMPv6
56 NONE = 59, // IPv6 no next header
57 DSTOPTS = 60, // IPv6 destination options
58 MTP = 92, // Multicast Transport Protocol
59 ENCAP = 98, // Encapsulation Header
60 PIM = 103, // Protocol Independent Multicast
61 COMP = 108, // Compression Header Protocol
62 SCTP = 132, // Stream Control Transmission Protocol
63 UDPLITE = 136, // UDP-Lite protocol
64 RAW = 255 // Raw IP packets
35 IP = 0, // Dummy protocol for TCP
36 HOPOPTS = 0, // IPv6 Hop-by-Hop options
37 ICMP = 1, // Internet Control Message Protocol
38 IGMP = 2, // Internet Group Management Protocol
39 IPIP = 4, // IPIP tunnels (older KA9Q tunnels use 94)
40 TCP = 6, // Transmission Control Protocol
41 EGP = 8, // Exterior Gateway Protocol
42 PUP = 12, // PUP protocol
43 UDP = 17, // User Datagram Protocol
44 IDP = 22, // XNS IDP protocol
45 TP = 29, // SO Transport Protocol Class 4
46 DCCP = 33, // Datagram Congestion Control Protocol
47 IPV6 = 41, // IPv6 header
48 ROUTING = 43, // IPv6 routing header
49 FRAGMENT = 44, // IPv6 fragmentation header
50 RSVP = 46, // Reservation Protocol
51 GRE = 47, // General Routing Encapsulation
52 ESP = 50, // encapsulating security payload
53 AH = 51, // authentication header
54 ICMPV6 = 58, // ICMPv6
55 NONE = 59, // IPv6 no next header
56 DSTOPTS = 60, // IPv6 destination options
57 MTP = 92, // Multicast Transport Protocol
58 ENCAP = 98, // Encapsulation Header
59 PIM = 103, // Protocol Independent Multicast
60 COMP = 108, // Compression Header Protocol
61 SCTP = 132, // Stream Control Transmission Protocol
62 UDPLITE = 136, // UDP-Lite protocol
63 RAW = 255 // Raw IP packets
6564 };
6665
6766 } // namespace ip
6867 } // namespace protocols
6968 } // namespace NST
7069 //------------------------------------------------------------------------------
71 #endif//IP_HEADER_H
70 #endif // IP_HEADER_H
7271 //------------------------------------------------------------------------------
3232 {
3333 namespace ip
3434 {
35
3635 // Internet Protocol, version 4
3736 struct ipv4_header
3837 {
5251 OFFMASK = 0x1fff // mask for fragmenting bits
5352 };
5453
55 uint8_t ipv4_vhl; // header length and version
56 uint8_t ipv4_tos; // type of service
57 uint16_t ipv4_len; // total length
58 uint16_t ipv4_id; // identification
59 uint16_t ipv4_fragmentation;// fragmentation
60 uint8_t ipv4_ttl; // time to live
61 uint8_t ipv4_protocol; // protocol
62 uint16_t ipv4_checksum; // checksum
63 in_addr_t ipv4_src; // source address
64 in_addr_t ipv4_dst; // destination address
65 } __attribute__ ((__packed__));
54 uint8_t ipv4_vhl; // header length and version
55 uint8_t ipv4_tos; // type of service
56 uint16_t ipv4_len; // total length
57 uint16_t ipv4_id; // identification
58 uint16_t ipv4_fragmentation; // fragmentation
59 uint8_t ipv4_ttl; // time to live
60 uint8_t ipv4_protocol; // protocol
61 uint16_t ipv4_checksum; // checksum
62 in_addr_t ipv4_src; // source address
63 in_addr_t ipv4_dst; // destination address
64 } __attribute__((__packed__));
6665
6766 struct IPv4Header : private ipv4_header
6867 {
68 // clang-format off
6969 inline uint8_t version() const { return ipv4_vhl >> 4; }
7070 inline uint8_t ihl() const { return (ipv4_vhl & 0x0f) << 2 /* *4 */; } // return number of bytes
7171 inline uint16_t length() const { return ntohs(ipv4_len); }
8080 {
8181 return ipv4_fragmentation & htons(OFFMASK) /*offset() != 0*/;
8282 }
83 } __attribute__ ((__packed__));
83 // clang-format on
84 } __attribute__((__packed__));
8485
8586 } // namespace ip
8687 } // namespace protocols
8788 } // namespace NST
8889 //------------------------------------------------------------------------------
89 #endif//IPV4_HEADER_H
90 #endif // IPV4_HEADER_H
9091 //------------------------------------------------------------------------------
3232 {
3333 namespace ip
3434 {
35
3635 typedef uint8_t in6_addr_t[16];
3736
3837 static_assert(sizeof(in6_addr) == sizeof(in6_addr_t), "sizeof in6_addr should be 16 bytes");
4039 // Internet Protocol, version 6
4140 struct ipv6_header
4241 {
43 uint32_t ipv6_vtcflow; // version(4), traffic class(8), flow label(20)
44 uint16_t ipv6_plen; // size of payload, including any extension header
45 uint8_t ipv6_nexthdr; // next header type
46 uint8_t ipv6_hlimit; // hop limit
47 in6_addr_t ipv6_src; // source address
48 in6_addr_t ipv6_dst; // destination address
49 } __attribute__ ((__packed__));
42 uint32_t ipv6_vtcflow; // version(4), traffic class(8), flow label(20)
43 uint16_t ipv6_plen; // size of payload, including any extension header
44 uint8_t ipv6_nexthdr; // next header type
45 uint8_t ipv6_hlimit; // hop limit
46 in6_addr_t ipv6_src; // source address
47 in6_addr_t ipv6_dst; // destination address
48 } __attribute__((__packed__));
5049
5150 // Hop-by-Hop options header
52 struct ipv6_hbh {
53 uint8_t hbh_nexthdr; // next header type
54 uint8_t hbh_len; // length in units of 8 octets
51 struct ipv6_hbh
52 {
53 uint8_t hbh_nexthdr; // next header type
54 uint8_t hbh_len; // length in units of 8 octets
5555 // addition data
56 } __attribute__ ((__packed__));
56 } __attribute__((__packed__));
5757
5858 // Destination options header
59 struct ipv6_dest {
60 uint8_t dest_nexthdr; // next header type
61 uint8_t dest_len; // length in units of 8 octets
59 struct ipv6_dest
60 {
61 uint8_t dest_nexthdr; // next header type
62 uint8_t dest_len; // length in units of 8 octets
6263 // addition data
63 } __attribute__ ((__packed__));
64 } __attribute__((__packed__));
6465
6566 // Routing header
66 struct ipv6_route {
67 uint8_t route_nexthdr; // next header
68 uint8_t route_len; // length in units of 8 octets
69 uint8_t route_type; // routing type
70 uint8_t route_segleft; // segments left
67 struct ipv6_route
68 {
69 uint8_t route_nexthdr; // next header
70 uint8_t route_len; // length in units of 8 octets
71 uint8_t route_type; // routing type
72 uint8_t route_segleft; // segments left
7173 // routing type specific data
72 } __attribute__ ((__packed__));
74 } __attribute__((__packed__));
7375
7476 // Fragment header
75 struct ipv6_frag {
76
77 struct ipv6_frag
78 {
7779 enum Fragmentation : uint16_t
7880 {
79 MORE = 0x0001, // more-fragments flag
80 RESERVED= 0x0006, // mask out reserved bits
81 OFFSET = 0xfff8 // mask out offset from frag_offlg
81 MORE = 0x0001, // more-fragments flag
82 RESERVED = 0x0006, // mask out reserved bits
83 OFFSET = 0xfff8 // mask out offset from frag_offlg
8284 };
8385
8486 uint8_t frag_nexthdr; // next header
8587 uint8_t frag_reserved; // reserved field
8688 uint16_t frag_offlg; // offset, reserved, and flag
8789 uint32_t frag_ident; // identification
88 } __attribute__ ((__packed__));
90 } __attribute__((__packed__));
8991
9092 struct IPv6Header : private ipv6_header
9193 {
92 inline uint8_t version() const { return ntohl(ipv6_vtcflow) >> 28; }
93 inline uint8_t tclass() const { return (ntohl(ipv6_vtcflow) >> 20) & 0xFF;}
94 inline uint32_t flowid() const { return ntohl(ipv6_vtcflow) & 0xFFFFF;}
95 inline uint16_t payload_len() const { return ntohs(ipv6_plen); }
96 inline uint8_t nexthdr() const { return ipv6_nexthdr; }
97 inline const in6_addr_t& src() const { return ipv6_src; }
98 inline const in6_addr_t& dst() const { return ipv6_dst; }
99 } __attribute__ ((__packed__));
94 uint8_t version() const { return ntohl(ipv6_vtcflow) >> 28; }
95 uint8_t tclass() const { return (ntohl(ipv6_vtcflow) >> 20) & 0xFF; }
96 uint32_t flowid() const { return ntohl(ipv6_vtcflow) & 0xFFFFF; }
97 uint16_t payload_len() const { return ntohs(ipv6_plen); }
98 uint8_t nexthdr() const { return ipv6_nexthdr; }
99 const in6_addr_t& src() const { return ipv6_src; }
100 const in6_addr_t& dst() const { return ipv6_dst; }
101 } __attribute__((__packed__));
100102
101103 } // namespace ip
102104 } // namespace protocols
103105 } // namespace NST
104106 //------------------------------------------------------------------------------
105 #endif//IPV6_HEADER_H
107 #endif // IPV6_HEADER_H
106108 //------------------------------------------------------------------------------
2121 #ifndef NETBIOS_HEADER_H
2222 #define NETBIOS_HEADER_H
2323 //------------------------------------------------------------------------------
24 #include <stdlib.h>
2524 #include <cstdint>
25 #include <cstdlib>
2626 //------------------------------------------------------------------------------
2727 namespace NST
2828 {
3030 {
3131 namespace NetBIOS
3232 {
33
3433 /*! \class NetBIOS message header in SMB-direct case
3534 */
3635 struct RawMessageHeader
3736 {
38 uint8_t _start;//!< In SMB direct always 0x00
39 uint8_t _;
40 uint16_t length;//!< Packet length
41 } __attribute__ ((__packed__));
37 uint8_t _start; //!< In SMB direct always 0x00
38 uint8_t _;
39 uint16_t length; //!< Packet length
40 } __attribute__((__packed__));
4241
4342 /*! \class NetBIOS message header wrapper
4443 */
5453 */
5554 inline const struct MessageHeader* get_header(const uint8_t* data)
5655 {
57 const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data));
58 if (header->start() == 0x00)
56 const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data));
57 if(header->start() == 0x00)
5958 {
6059 return header;
6160 }
6665 } // namespace protocols
6766 } // namespace NST
6867 //------------------------------------------------------------------------------
69 #endif//NETBIOS_HEADER_H
68 #endif // NETBIOS_HEADER_H
7069 //------------------------------------------------------------------------------
2525
2626 #include "api/rpc_types.h"
2727 #include "protocols/nfs3/nfs3_utils.h"
28 #include "protocols/nfs4/nfs41_utils.h"
2829 #include "protocols/nfs4/nfs4_utils.h"
29 #include "protocols/nfs4/nfs41_utils.h"
3030 #include "utils/sessions.h"
3131 //------------------------------------------------------------------------------
3232 namespace NST
3333 {
3434 namespace protocols
3535 {
36
3736 using NFS3::proc_t_of;
3837 using NFS4::proc_t_of;
3938 using NFS41::proc_t_of;
4039
41 template
42 <
40 template <
4341 typename ArgType, // structure of RPC procedure parameters
4442 typename ResType // structure of RPC procedure results
45 >
46 class NFSProcedure: public NST::API::RPCProcedure
43 >
44 class NFSProcedure : public NST::API::RPCProcedure
4745 {
4846 public:
4947 inline NFSProcedure(xdr::XDRDecoder& c, xdr::XDRDecoder& r, const Session* s)
50 : parg{&arg} // set pointer to argument
51 , pres{&res} // set pointer to result
48 : parg{&arg} // set pointer to argument
49 , pres{&res} // set pointer to result
5250 {
53 memset(&call, 0,sizeof(call ));
54 memset(&reply,0,sizeof(reply));
55 memset(&arg, 0,sizeof(arg ));
56 memset(&res, 0,sizeof(res ));
51 memset(&call, 0, sizeof(call));
52 memset(&reply, 0, sizeof(reply));
53 memset(&arg, 0, sizeof(arg));
54 memset(&res, 0, sizeof(res));
5755
5856 // fill call
5957 if(!xdr_callmsg(c.xdr(), &call))
6361 }
6462
6563 // fill call arguments
66 if(!proc_t_of(arg)(c.xdr(),&arg))
64 if(!proc_t_of(arg)(c.xdr(), &arg))
6765 {
68 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg );
69 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call);
66 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg);
67 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call);
7068 throw xdr::XDRDecoderError{"XDRDecoder: cann't read call arguments"};
7169 }
7270
7371 reply.ru.RM_rmb.ru.RP_ar.ru.AR_results.proc = &return_true;
7472
7573 // fill reply
76 if(!xdr_replymsg (r.xdr(), &reply))
74 if(!xdr_replymsg(r.xdr(), &reply))
7775 {
78 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
79 xdr_free((xdrproc_t)proc_t_of(arg),(char*)&arg );
80 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call );
76 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
77 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg);
78 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call);
8179 throw xdr::XDRDecoderError{"XDRDecoder: cann't read reply data"};
8280 }
83
81
8482 if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED &&
8583 reply.ru.RM_rmb.ru.RP_ar.ar_stat == accept_stat::SUCCESS)
8684 {
8785 // fill reply results
88 if(!proc_t_of(res)(r.xdr(),&res))
86 if(!proc_t_of(res)(r.xdr(), &res))
8987 {
90 xdr_free((xdrproc_t)proc_t_of(res), (char*)&res );
91 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
92 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg );
93 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call );
88 xdr_free((xdrproc_t)proc_t_of(res), (char*)&res);
89 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
90 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg);
91 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call);
9492 throw xdr::XDRDecoderError{"XDRDecoder: cann't read reply results"};
9593 }
9694 }
107105
108106 inline ~NFSProcedure()
109107 {
110 if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res );
111 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
112 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg );
113 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call );
108 if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res);
109 xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply);
110 xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg);
111 xdr_free((xdrproc_t)xdr_callmsg, (char*)&call);
114112 }
115113
116114 // pointers to procedure specific argument and result
119117
120118 private:
121119 inline static bool_t return_true(XDR*, void*, ...) { return 1; }
122 inline static bool_t return_true(XDR*, ...) { return 1; }
120 inline static bool_t return_true(XDR*, ...) { return 1; }
121 ArgType arg;
122 ResType res;
123 };
123124
124 ArgType arg;
125 ResType res;
126 };
125 // clang-format off
127126
128127 namespace NFS3
129128 {
166165 using NFSPROC41RPCGEN_COMPOUND = NFSProcedure <NFS41::COMPOUND4args, NFS41::COMPOUND4res>;
167166 }
168167
168 // clang-format on
169
169170 } // namespace protocols
170171 } // namespace NST
171172 //------------------------------------------------------------------------------
172 #endif//NFS_PROCEDURE_H
173 #endif // NFS_PROCEDURE_H
173174 //------------------------------------------------------------------------------
2020 //------------------------------------------------------------------------------
2121 #include <iomanip>
2222
23 #include "api/plugin_api.h" // for NST_PUBLIC
2324 #include "protocols/nfs/nfs_utils.h"
2425 //------------------------------------------------------------------------------
2526 namespace NST
2829 {
2930 namespace NFS
3031 {
31
3232 void print_hex64(std::ostream& out, uint64_t val)
3333
3434 {
5151 void print_hex8(std::ostream& out, uint8_t val)
5252 {
5353 out << "0x" << std::setfill('0') << std::setw(2) << std::hex
54 << static_cast<u_int16_t>(val) // prevent implicit cast to char
54 << static_cast<u_int16_t>(val) // prevent implicit cast to char
5555 << std::dec << std::setfill(' ');
5656 }
5757
58
5958 void print_hex(std::ostream& out, const uint32_t* const val, const uint32_t len)
6059 {
61 if (len)
60 if(len)
6261 {
6362 out << std::hex << std::setfill('0') << "0x";
64 for (uint32_t i {0}; i < len; i++)
63 for(uint32_t i{0}; i < len; i++)
6564 {
6665 out << std::setw(2) << val[i];
6766 }
7574
7675 void print_hex(std::ostream& out, const char* const val, const uint32_t len)
7776 {
78 if (len)
77 if(len)
7978 {
8079 out << std::hex << std::setfill('0') << "0x";
81 for (uint32_t i {0}; i < len; i++)
80 for(uint32_t i{0}; i < len; i++)
8281 {
8382 out << std::setw(2)
8483 << ((static_cast<int32_t>(val[i])) & 0xFF);
9190 }
9291 }
9392
94 void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len)
93 extern "C" NST_PUBLIC void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len)
9594 {
96 if (len)
95 if(len)
9796 {
9897 out << std::hex << std::setfill('0');
99 if (len <= 8 || out_all())
98 if(len <= 8 || out_all())
10099 {
101 for (uint32_t i {0}; i < len; i++)
100 for(uint32_t i{0}; i < len; i++)
102101 {
103102 out << std::setw(2)
104103 << ((static_cast<int32_t>(val[i])) & 0xFF);
106105 }
107106 else // truncate binary data to: 00112233...CCDDEEFF
108107 {
109 for (uint32_t i {0}; i < 4; i++)
108 for(uint32_t i{0}; i < 4; i++)
110109 {
111110 out << std::setw(2)
112111 << ((static_cast<int32_t>(val[i])) & 0xFF);
113112 }
114113 out << "...";
115 for (uint32_t i {len - 4}; i < len; i++)
114 for(uint32_t i{len - 4}; i < len; i++)
116115 {
117116 out << std::setw(2)
118117 << ((static_cast<int32_t>(val[i])) & 0xFF);
2121 #ifndef NFS_UTILS_H
2222 #define NFS_UTILS_H
2323 //------------------------------------------------------------------------------
24 #include <cstring>
25 #include <iomanip>
2426 #include <ostream>
25 #include <iomanip>
26 #include <cstring>
2727
2828 #include "utils/out.h"
2929 //------------------------------------------------------------------------------
30 #define NST_PUBLIC __attribute__ ((visibility("default")))
3130 //------------------------------------------------------------------------------
3231 namespace NST
3332 {
3534 {
3635 namespace NFS
3736 {
38
3937 inline bool out_all()
4038 {
4139 using Out = NST::utils::Out;
4341 return Out::Global::get_level() == Out::Level::All;
4442 }
4543
46 namespace
44 namespace
4745 {
4846 template <typename T>
4947 struct Helper
50 {
48 {
5149 static void print_hex(std::ostream& out, T val)
5250 {
53 out << "0x" << std::setfill('0') << std::setw(sizeof(T)/4) << std::hex << val
51 out << "0x" << std::setfill('0') << std::setw(sizeof(T) / 4) << std::hex << val
5452 << std::dec << std::setfill(' ');
5553 }
5654 };
5755 template <>
5856 struct Helper<uint8_t>
59 {
57 {
6058 static void print_hex(std::ostream& out, char val)
6159 {
62 out << "0x" << std::setfill('0') << std::setw(4) << std::hex <<
63 static_cast<uint16_t>(val) << std::dec << std::setfill(' ');
60 out << "0x" << std::setfill('0') << std::setw(4) << std::hex << static_cast<uint16_t>(val) << std::dec << std::setfill(' ');
6461 }
6562 };
6663 }
6966 void print_hex(std::ostream& out, T val)
7067 {
7168 Helper<T>::print_hex(out, val);
72 }
69 }
7370
7471 void print_hex64(std::ostream& out, uint64_t val);
7572
7774
7875 void print_hex16(std::ostream& out, uint16_t val);
7976
80 void print_hex8(std::ostream& out, uint8_t val);
77 void print_hex8(std::ostream& out, uint8_t val);
8178
82 void print_hex(std::ostream& out,
83 const uint32_t* const val,
84 const uint32_t len);
79 void print_hex(std::ostream& out,
80 const uint32_t* const val,
81 const uint32_t len);
8582
86 void print_hex(std::ostream& out,
87 const char* const val,
88 const uint32_t len);
89
90 extern "C"
91 NST_PUBLIC
92 void print_nfs_fh(std::ostream& out,
93 const char* const val,
94 const uint32_t len);
83 void print_hex(std::ostream& out,
84 const char* const val,
85 const uint32_t len);
9586
9687 } // namespace NFS
9788 } // namespace protocols
9889 } // namespace NST
9990 //------------------------------------------------------------------------------
100 #endif//NFS_UTILS_H
91 #endif // NFS_UTILS_H
10192 //------------------------------------------------------------------------------
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include "protocols/nfs3/nfs3_utils.h"
22 #include "api/plugin_api.h" // for NST_PUBLIC
2123 #include "protocols/nfs/nfs_utils.h"
22 #include "protocols/nfs3/nfs3_utils.h"
2324 //------------------------------------------------------------------------------
2425 using namespace NST::API::NFS3;
2526 using namespace NST::protocols::NFS;
3132 {
3233 namespace NFS3
3334 {
34
35 const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc)
36 {
35 extern "C" NST_PUBLIC const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc)
36 {
37 // clang-format off
3738 static const char* const NFS3ProcedureTitles[ProcEnumNFS3::count] =
3839 {
3940 "NULL", "GETATTR", "SETATTR", "LOOKUP",
4344 "READDIR", "READDIRPLUS", "FSSTAT", "FSINFO",
4445 "PATHCONF", "COMMIT"
4546 };
47 // clang-format on
4648
4749 return NFS3ProcedureTitles[proc];
4850 }
6062 S_IXGRP = 0x00008, // Search in directory
6163 S_IROTH = 0x00004,
6264 S_IWOTH = 0x00002,
63 S_IXOTH = 0x00001 // Search in directory
65 S_IXOTH = 0x00001 // Search in directory
6466 };
6567
6668 void print_mode3(std::ostream& out, const uint32 val)
6769 {
68 if (val & S_ISUID) out << "USER_ID_EXEC ";
69 if (val & S_ISGID) out << "GROUP_ID_EXEC ";
70 if (val & S_ISVTX) out << "SAVE_SWAPPED_TEXT ";
71 if (val & S_IRUSR) out << "OWNER_READ ";
72 if (val & S_IWUSR) out << "OWNER_WRITE ";
73 if (val & S_IXUSR) out << "OWNER_EXEC ";
74 if (val & S_IRGRP) out << "GROUP_READ ";
75 if (val & S_IWGRP) out << "GROUP_WRITE ";
76 if (val & S_IXGRP) out << "GROUP_EXEC ";
77 if (val & S_IROTH) out << "OTHER_READ ";
78 if (val & S_IWOTH) out << "OTHER_WRITE ";
79 if (val & S_IXOTH) out << "OTHER_EXEC";
70 if(val & S_ISUID) out << "USER_ID_EXEC ";
71 if(val & S_ISGID) out << "GROUP_ID_EXEC ";
72 if(val & S_ISVTX) out << "SAVE_SWAPPED_TEXT ";
73 if(val & S_IRUSR) out << "OWNER_READ ";
74 if(val & S_IWUSR) out << "OWNER_WRITE ";
75 if(val & S_IXUSR) out << "OWNER_EXEC ";
76 if(val & S_IRGRP) out << "GROUP_READ ";
77 if(val & S_IWGRP) out << "GROUP_WRITE ";
78 if(val & S_IXGRP) out << "GROUP_EXEC ";
79 if(val & S_IROTH) out << "OTHER_READ ";
80 if(val & S_IWOTH) out << "OTHER_WRITE ";
81 if(val & S_IXOTH) out << "OTHER_EXEC";
8082 }
8183
8284 void print_access3(std::ostream& out, const uint32 val)
8385 {
84 if (val & ACCESS3_READ) out << "READ ";
85 if (val & ACCESS3_LOOKUP) out << "LOOKUP ";
86 if (val & ACCESS3_MODIFY) out << "MODIFY ";
87 if (val & ACCESS3_EXTEND) out << "EXTEND ";
88 if (val & ACCESS3_DELETE) out << "DELETE ";
89 if (val & ACCESS3_EXECUTE) out << "EXECUTE ";
86 if(val & ACCESS3_READ) out << "READ ";
87 if(val & ACCESS3_LOOKUP) out << "LOOKUP ";
88 if(val & ACCESS3_MODIFY) out << "MODIFY ";
89 if(val & ACCESS3_EXTEND) out << "EXTEND ";
90 if(val & ACCESS3_DELETE) out << "DELETE ";
91 if(val & ACCESS3_EXECUTE) out << "EXECUTE ";
9092 }
9193
9294 std::ostream& operator<<(std::ostream& out, const nfsstat3& obj)
159161 {
160162 switch(obj)
161163 {
162 case ftype3::NF3REG: return out << "REG";
163 case ftype3::NF3DIR: return out << "DIR";
164 case ftype3::NF3BLK: return out << "BLK";
165 case ftype3::NF3CHR: return out << "CHR";
166 case ftype3::NF3LNK: return out << "LNK";
167 case ftype3::NF3SOCK: return out << "SOCK";
168 case ftype3::NF3FIFO: return out << "FIFO";
164 case ftype3::NF3REG:
165 return out << "REG";
166 case ftype3::NF3DIR:
167 return out << "DIR";
168 case ftype3::NF3BLK:
169 return out << "BLK";
170 case ftype3::NF3CHR:
171 return out << "CHR";
172 case ftype3::NF3LNK:
173 return out << "LNK";
174 case ftype3::NF3SOCK:
175 return out << "SOCK";
176 case ftype3::NF3FIFO:
177 return out << "FIFO";
169178 }
170179 return out;
171180 }
178187
179188 std::ostream& operator<<(std::ostream& out, const nfs_fh3& obj)
180189 {
181 NFS::print_nfs_fh(out, obj.data.data_val, obj.data.data_len);
190 print_nfs_fh(out, obj.data.data_val, obj.data.data_len);
182191 return out;
183192 }
184193
185194 std::ostream& operator<<(std::ostream& out, const nfstime3& obj)
186195 {
187 return out << "seconds: " << obj.seconds
196 return out << "seconds: " << obj.seconds
188197 << " nseconds: " << obj.nseconds << ' ';
189198 }
190199
193202 out << " type: " << obj.type
194203 << " mode: ";
195204
196 print_mode3(out,obj.mode);
197
198 out << " nlink: " << obj.nlink
199 << " uid: " << obj.uid
200 << " gid: " << obj.gid
201 << " size: " << obj.size
202 << " used: " << obj.used
203 << " rdev: " << obj.rdev
204 << " fsid: " << obj.fsid
205 print_mode3(out, obj.mode);
206
207 out << " nlink: " << obj.nlink
208 << " uid: " << obj.uid
209 << " gid: " << obj.gid
210 << " size: " << obj.size
211 << " used: " << obj.used
212 << " rdev: " << obj.rdev
213 << " fsid: " << obj.fsid
205214 << " fileid: " << obj.fileid
206 << " atime: " << obj.atime
207 << " mtime: " << obj.mtime
208 << " ctime: " << obj.ctime;
215 << " atime: " << obj.atime
216 << " mtime: " << obj.mtime
217 << " ctime: " << obj.ctime;
209218 return out;
210219 }
211220
212221 std::ostream& operator<<(std::ostream& out, const post_op_attr& obj)
213222 {
214 if(obj.attributes_follow) return out << obj.post_op_attr_u.attributes;
215 else return out << " void ";
223 if(obj.attributes_follow)
224 return out << obj.post_op_attr_u.attributes;
225 else
226 return out << " void ";
216227 }
217228
218229 std::ostream& operator<<(std::ostream& out, const wcc_attr& obj)
219230 {
220 return out << " size: " << obj.size
231 return out << " size: " << obj.size
221232 << " mtime: " << obj.mtime
222233 << " ctime: " << obj.ctime;
223234 }
224235
225236 std::ostream& operator<<(std::ostream& out, const pre_op_attr& obj)
226237 {
227 if(obj.attributes_follow) return out << obj.pre_op_attr_u.attributes;
228 else return out << " void ";
238 if(obj.attributes_follow)
239 return out << obj.pre_op_attr_u.attributes;
240 else
241 return out << " void ";
229242 }
230243
231244 std::ostream& operator<<(std::ostream& out, const wcc_data& obj)
235248
236249 std::ostream& operator<<(std::ostream& out, const post_op_fh3& obj)
237250 {
238 if(obj.handle_follows) return out << " handle: "
239 << obj.post_op_fh3_u.handle;
240 else return out << " void ";
251 if(obj.handle_follows)
252 return out << " handle: "
253 << obj.post_op_fh3_u.handle;
254 else
255 return out << " void ";
241256 }
242257
243258 std::ostream& operator<<(std::ostream& out, const time_how& obj)
256271
257272 std::ostream& operator<<(std::ostream& out, const set_mode3& obj)
258273 {
259 if(obj.set_it) return out << obj.set_mode3_u.mode;
260 else return out << " void ";
274 if(obj.set_it)
275 return out << obj.set_mode3_u.mode;
276 else
277 return out << " void ";
261278 }
262279
263280 std::ostream& operator<<(std::ostream& out, const set_uid3& obj)
264281 {
265 if(obj.set_it) return out << obj.set_uid3_u.uid;
266 else return out << " void ";
282 if(obj.set_it)
283 return out << obj.set_uid3_u.uid;
284 else
285 return out << " void ";
267286 }
268287
269288 std::ostream& operator<<(std::ostream& out, const set_gid3& obj)
270289 {
271 if(obj.set_it) return out << obj.set_gid3_u.gid;
272 else return out << " void ";
290 if(obj.set_it)
291 return out << obj.set_gid3_u.gid;
292 else
293 return out << " void ";
273294 }
274295
275296 std::ostream& operator<<(std::ostream& out, const set_size3& obj)
276297 {
277 if(obj.set_it) return out << obj.set_size3_u.size;
278 else return out << " void ";
298 if(obj.set_it)
299 return out << obj.set_size3_u.size;
300 else
301 return out << " void ";
279302 }
280303
281304 std::ostream& operator<<(std::ostream& out, const set_atime& obj)
282305 {
283306 if(obj.set_it == time_how::SET_TO_CLIENT_TIME)
284 return out << obj.set_it << " " << obj.set_atime_u.atime;
285 else return out << obj.set_it;
307 return out << obj.set_it << " " << obj.set_atime_u.atime;
308 else
309 return out << obj.set_it;
286310 }
287311
288312 std::ostream& operator<<(std::ostream& out, const set_mtime& obj)
289313 {
290314 if(obj.set_it == time_how::SET_TO_CLIENT_TIME)
291 return out << obj.set_it << " " << obj.set_mtime_u.mtime;
292 else return out << obj.set_it;
315 return out << obj.set_it << " " << obj.set_mtime_u.mtime;
316 else
317 return out << obj.set_it;
293318 }
294319
295320 std::ostream& operator<<(std::ostream& out, const sattr3& obj)
300325 print_mode3(out, obj.mode.set_mode3_u.mode);
301326 }
302327
303 if(obj.uid.set_it) out << " uid: " << obj.uid.set_uid3_u.uid;
304 if(obj.gid.set_it) out << " gid: " << obj.gid.set_gid3_u.gid;
305 if(obj.size.set_it) out << " size: " << obj.size.set_size3_u.size;
328 if(obj.uid.set_it) out << " uid: " << obj.uid.set_uid3_u.uid;
329 if(obj.gid.set_it) out << " gid: " << obj.gid.set_gid3_u.gid;
330 if(obj.size.set_it) out << " size: " << obj.size.set_size3_u.size;
306331 if(obj.atime.set_it == time_how::SET_TO_CLIENT_TIME)
307332 out << " atime: " << obj.atime.set_atime_u.atime;
308333 if(obj.mtime.set_it == time_how::SET_TO_CLIENT_TIME)
313338
314339 std::ostream& operator<<(std::ostream& out, const diropargs3& obj)
315340 {
316 return out << " dir: " << obj.dir
341 return out << " dir: " << obj.dir
317342 << " name: " << obj.name;
318343 }
319344
320345 std::ostream& operator<<(std::ostream& out, const sattrguard3& obj)
321346 {
322 if(obj.check) return out << " obj_ctime: " << obj.sattrguard3_u.obj_ctime;
323 else return out << " void ";
347 if(obj.check)
348 return out << " obj_ctime: " << obj.sattrguard3_u.obj_ctime;
349 else
350 return out << " void ";
324351 }
325352
326353 std::ostream& operator<<(std::ostream& out, const stable_how& obj)
327354 {
328355 switch(obj)
329356 {
330 case stable_how::UNSTABLE: return out << "UNSTABLE";
331 case stable_how::DATA_SYNC: return out << "DATA_SYNC";
332 case stable_how::FILE_SYNC: return out << "FILE_SYNC";
357 case stable_how::UNSTABLE:
358 return out << "UNSTABLE";
359 case stable_how::DATA_SYNC:
360 return out << "DATA_SYNC";
361 case stable_how::FILE_SYNC:
362 return out << "FILE_SYNC";
333363 }
334364 return out;
335365 }
338368 {
339369 switch(obj)
340370 {
341 case createmode3::UNCHECKED: return out << "UNCHECKED";
342 case createmode3::GUARDED: return out << "GUARDED";
343 case createmode3::EXCLUSIVE: return out << "EXCLUSIVE";
371 case createmode3::UNCHECKED:
372 return out << "UNCHECKED";
373 case createmode3::GUARDED:
374 return out << "GUARDED";
375 case createmode3::EXCLUSIVE:
376 return out << "EXCLUSIVE";
344377 }
345378 return out;
346379 }
364397 std::ostream& operator<<(std::ostream& out, const symlinkdata3& obj)
365398 {
366399 return out << " symlink_attributes: " << obj.symlink_attributes
367 << " symlink_data: " << obj.symlink_data;
400 << " symlink_data: " << obj.symlink_data;
368401 }
369402
370403 std::ostream& operator<<(std::ostream& out, const devicedata3& obj)
371404 {
372405 return out << " dev_attributes: " << obj.dev_attributes
373 << " spec: " << obj.spec;
374 }
375
406 << " spec: " << obj.spec;
407 }
376408
377409 std::ostream& operator<<(std::ostream& out, const mknoddata3& obj)
378410 {
381413 {
382414 case ftype3::NF3CHR:
383415 case ftype3::NF3BLK:
384 return out << " device: " << obj.mknoddata3_u.device;
416 return out << " device: " << obj.mknoddata3_u.device;
385417 case ftype3::NF3SOCK:
386418 case ftype3::NF3FIFO:
387419 return out << " pipe_attributes: " << obj.mknoddata3_u.pipe_attributes;
388 default: break;
389 }
390 return out;
420 default:
421 break;
422 }
423 return out;
391424 }
392425
393426 std::ostream& operator<<(std::ostream& out, const entry3& obj)
394427 {
395 out << " file id: " << obj.fileid
396 << " name: " << obj.name
397 << " cookie: " << obj.cookie << '\n';
428 out << " file id: " << obj.fileid
429 << " name: " << obj.name
430 << " cookie: " << obj.cookie << '\n';
398431 if(obj.nextentry) out << *obj.nextentry;
399432 return out;
400433 }
401434
402435 std::ostream& operator<<(std::ostream& out, const dirlist3& obj)
403 {
404 out << " eof: " << obj.eof;
405 if(obj.entries) out << *obj.entries;
406 return out;
407 }
408
409 std::ostream& operator<<(std::ostream& out, const entryplus3& obj)
410 {
411 out << " file id: " << obj.fileid
412 << " name: " << obj.name
413 << " name attributes: " << obj.name_attributes
414 << " name handle: " << obj.name_handle
415 << " cookie: " << obj.cookie << '\n';
416 if(obj.nextentry) out << *obj.nextentry;
417 return out;
418 }
419
420 std::ostream& operator<<(std::ostream& out, const dirlistplus3& obj)
421436 {
422437 out << " eof: " << obj.eof;
423438 if(obj.entries) out << *obj.entries;
424439 return out;
425440 }
441
442 std::ostream& operator<<(std::ostream& out, const entryplus3& obj)
443 {
444 out << " file id: " << obj.fileid
445 << " name: " << obj.name
446 << " name attributes: " << obj.name_attributes
447 << " name handle: " << obj.name_handle
448 << " cookie: " << obj.cookie << '\n';
449 if(obj.nextentry) out << *obj.nextentry;
450 return out;
451 }
452
453 std::ostream& operator<<(std::ostream& out, const dirlistplus3& obj)
454 {
455 out << " eof: " << obj.eof;
456 if(obj.entries) out << *obj.entries;
457 return out;
458 }
459
460 // clang-format off
426461
427462 bool_t
428463 xdr_uint64 (XDR* xdrs, uint64* objp)
28612896 return TRUE;
28622897 }
28632898
2899 // clang-format on
2900
28642901 } // namespace NFS3
28652902 } // namespace protocols
28662903 } // namespace NST
2424 #include <cassert>
2525 #include <ostream>
2626
27 #include "api/nfs3_types_rpcgen.h"
2728 #include "api/nfs_types.h"
28 #include "api/nfs3_types_rpcgen.h"
29
29
30 #include "protocols/rpc/rpc_header.h"
3031 #include "protocols/xdr/xdr_decoder.h"
31 #include "protocols/rpc/rpc_header.h"
32 //------------------------------------------------------------------------------
33 #define NST_PUBLIC __attribute__ ((visibility("default")))
32 //------------------------------------------------------------------------------
3433 //------------------------------------------------------------------------------
3534 namespace NST
3635 {
3837 {
3938 namespace NFS3
4039 {
41
4240 namespace NFS3 = NST::API::NFS3;
4341
4442 using ProcEnumNFS3 = API::ProcEnumNFS3;
4543
46 using Validator = rpc::RPCProgramValidator
47 <
48 100003, // SunRPC/NFS program
49 3, // v3
50 ProcEnumNFS3::NFS_NULL, // NFSPROC3_NULL
51 ProcEnumNFS3::COMMIT // NFSPROC3_COMMIT
52 >;
53
44 using Validator = rpc::RPCProgramValidator<
45 100003, // SunRPC/NFS program
46 3, // v3
47 ProcEnumNFS3::NFS_NULL, // NFSPROC3_NULL
48 ProcEnumNFS3::COMMIT // NFSPROC3_COMMIT
49 >;
50
51 // clang-format off
5452 bool_t xdr_uint64 (XDR *, NFS3::uint64*);
5553 bool_t xdr_uint32 (XDR *, NFS3::uint32*);
5654 bool_t xdr_int64 (XDR *, NFS3::int64*);
184182 bool_t xdr_COMMIT3resok (XDR *, NFS3::COMMIT3resok*);
185183 bool_t xdr_COMMIT3resfail (XDR *, NFS3::COMMIT3resfail*);
186184 bool_t xdr_COMMIT3res (XDR *, NFS3::COMMIT3res*);
185 // clang-format on
187186
188187 // Procedure 0: NULL - Do nothing
189 inline auto proc_t_of(NFS3::NULL3args&)->decltype(&xdr_NULL3args)
188 inline auto proc_t_of(NFS3::NULL3args&) -> decltype(&xdr_NULL3args)
190189 {
191190 return &xdr_NULL3args;
192191 }
193192
194 inline auto proc_t_of(NFS3::NULL3res&)->decltype(&xdr_NULL3res)
193 inline auto proc_t_of(NFS3::NULL3res&) -> decltype(&xdr_NULL3res)
195194 {
196195 return &xdr_NULL3res;
197196 }
198197
199198 // Procedure 1: GETATTR - Get file attributes
200 inline auto proc_t_of(NFS3::GETATTR3args&)->decltype(&xdr_GETATTR3args)
199 inline auto proc_t_of(NFS3::GETATTR3args&) -> decltype(&xdr_GETATTR3args)
201200 {
202201 return &xdr_GETATTR3args;
203202 }
204203
205 inline auto proc_t_of(NFS3::GETATTR3res&)->decltype(&xdr_GETATTR3res)
204 inline auto proc_t_of(NFS3::GETATTR3res&) -> decltype(&xdr_GETATTR3res)
206205 {
207206 return &xdr_GETATTR3res;
208207 }
209208
210209 // Procedure 2: SETATTR - Set file attributes
211 inline auto proc_t_of(NFS3::SETATTR3args&)->decltype(&xdr_SETATTR3args)
210 inline auto proc_t_of(NFS3::SETATTR3args&) -> decltype(&xdr_SETATTR3args)
212211 {
213212 return &xdr_SETATTR3args;
214213 }
215214
216 inline auto proc_t_of(NFS3::SETATTR3res&)->decltype(&xdr_SETATTR3res)
215 inline auto proc_t_of(NFS3::SETATTR3res&) -> decltype(&xdr_SETATTR3res)
217216 {
218217 return &xdr_SETATTR3res;
219218 }
220219
221220 // Procedure 3: LOOKUP - Lookup filename
222 inline auto proc_t_of(NFS3::LOOKUP3args&)->decltype(&xdr_LOOKUP3args)
221 inline auto proc_t_of(NFS3::LOOKUP3args&) -> decltype(&xdr_LOOKUP3args)
223222 {
224223 return &xdr_LOOKUP3args;
225224 }
226225
227 inline auto proc_t_of(NFS3::LOOKUP3res&)->decltype(&xdr_LOOKUP3res)
226 inline auto proc_t_of(NFS3::LOOKUP3res&) -> decltype(&xdr_LOOKUP3res)
228227 {
229228 return &xdr_LOOKUP3res;
230229 }
231230
232231 // Procedure 4: ACCESS - Check Access Permission
233 inline auto proc_t_of(NFS3::ACCESS3args&)->decltype(&xdr_ACCESS3args)
232 inline auto proc_t_of(NFS3::ACCESS3args&) -> decltype(&xdr_ACCESS3args)
234233 {
235234 return &xdr_ACCESS3args;
236235 }
237236
238 inline auto proc_t_of(NFS3::ACCESS3res&)->decltype(&xdr_ACCESS3res)
237 inline auto proc_t_of(NFS3::ACCESS3res&) -> decltype(&xdr_ACCESS3res)
239238 {
240239 return &xdr_ACCESS3res;
241240 }
242241
243242 // Procedure 5: READLINK - Read from symbolic link
244 inline auto proc_t_of(NFS3::READLINK3args&)->decltype(&xdr_READLINK3args)
243 inline auto proc_t_of(NFS3::READLINK3args&) -> decltype(&xdr_READLINK3args)
245244 {
246245 return &xdr_READLINK3args;
247246 }
248247
249 inline auto proc_t_of(NFS3::READLINK3res&)->decltype(&xdr_READLINK3res)
248 inline auto proc_t_of(NFS3::READLINK3res&) -> decltype(&xdr_READLINK3res)
250249 {
251250 return &xdr_READLINK3res;
252251 }
253252
254253 // Procedure 6: READ - Read From file
255 inline auto proc_t_of(NFS3::READ3args&)->decltype(&xdr_READ3args)
254 inline auto proc_t_of(NFS3::READ3args&) -> decltype(&xdr_READ3args)
256255 {
257256 return &xdr_READ3args;
258257 }
259258
260 inline auto proc_t_of(NFS3::READ3res&)->decltype(&xdr_READ3res)
259 inline auto proc_t_of(NFS3::READ3res&) -> decltype(&xdr_READ3res)
261260 {
262261 return &xdr_READ3res;
263262 }
264263
265264 // Procedure 7: WRITE - Write to file
266 inline auto proc_t_of(NFS3::WRITE3args&)->decltype(&xdr_WRITE3args)
265 inline auto proc_t_of(NFS3::WRITE3args&) -> decltype(&xdr_WRITE3args)
267266 {
268267 return &xdr_WRITE3args;
269268 }
270269
271 inline auto proc_t_of(NFS3::WRITE3res&)->decltype(&xdr_WRITE3res)
270 inline auto proc_t_of(NFS3::WRITE3res&) -> decltype(&xdr_WRITE3res)
272271 {
273272 return &xdr_WRITE3res;
274273 }
275274
276275 // Procedure 8: CREATE - Create a file
277 inline auto proc_t_of(NFS3::CREATE3args&)->decltype(&xdr_CREATE3args)
276 inline auto proc_t_of(NFS3::CREATE3args&) -> decltype(&xdr_CREATE3args)
278277 {
279278 return &xdr_CREATE3args;
280279 }
281280
282 inline auto proc_t_of(NFS3::CREATE3res&)->decltype(&xdr_CREATE3res)
281 inline auto proc_t_of(NFS3::CREATE3res&) -> decltype(&xdr_CREATE3res)
283282 {
284283 return &xdr_CREATE3res;
285284 }
286285
287286 // Procedure 9: MKDIR - Create a directory
288 inline auto proc_t_of(NFS3::MKDIR3args&)->decltype(&xdr_MKDIR3args)
287 inline auto proc_t_of(NFS3::MKDIR3args&) -> decltype(&xdr_MKDIR3args)
289288 {
290289 return &xdr_MKDIR3args;
291290 }
292291
293 inline auto proc_t_of(NFS3::MKDIR3res&)->decltype(&xdr_MKDIR3res)
292 inline auto proc_t_of(NFS3::MKDIR3res&) -> decltype(&xdr_MKDIR3res)
294293 {
295294 return &xdr_MKDIR3res;
296295 }
297296
298297 // Procedure 10: SYMLINK - Create a symbolic link
299 inline auto proc_t_of(NFS3::SYMLINK3args&)->decltype(&xdr_SYMLINK3args)
298 inline auto proc_t_of(NFS3::SYMLINK3args&) -> decltype(&xdr_SYMLINK3args)
300299 {
301300 return &xdr_SYMLINK3args;
302301 }
303302
304 inline auto proc_t_of(NFS3::SYMLINK3res&)->decltype(&xdr_SYMLINK3res)
303 inline auto proc_t_of(NFS3::SYMLINK3res&) -> decltype(&xdr_SYMLINK3res)
305304 {
306305 return &xdr_SYMLINK3res;
307306 }
308307
309308 // Procedure 11: MKNOD - Create a special device
310 inline auto proc_t_of(NFS3::MKNOD3args&)->decltype(&xdr_MKNOD3args)
309 inline auto proc_t_of(NFS3::MKNOD3args&) -> decltype(&xdr_MKNOD3args)
311310 {
312311 return &xdr_MKNOD3args;
313312 }
314313
315 inline auto proc_t_of(NFS3::MKNOD3res&)->decltype(&xdr_MKNOD3res)
314 inline auto proc_t_of(NFS3::MKNOD3res&) -> decltype(&xdr_MKNOD3res)
316315 {
317316 return &xdr_MKNOD3res;
318317 }
319318
320319 // Procedure 12: REMOVE - Remove a File
321 inline auto proc_t_of(NFS3::REMOVE3args&)->decltype(&xdr_REMOVE3args)
320 inline auto proc_t_of(NFS3::REMOVE3args&) -> decltype(&xdr_REMOVE3args)
322321 {
323322 return &xdr_REMOVE3args;
324323 }
325324
326 inline auto proc_t_of(NFS3::REMOVE3res&)->decltype(&xdr_REMOVE3res)
325 inline auto proc_t_of(NFS3::REMOVE3res&) -> decltype(&xdr_REMOVE3res)
327326 {
328327 return &xdr_REMOVE3res;
329328 }
330329
331330 // Procedure 13: RMDIR - Remove a Directory
332 inline auto proc_t_of(NFS3::RMDIR3args&)->decltype(&xdr_RMDIR3args)
331 inline auto proc_t_of(NFS3::RMDIR3args&) -> decltype(&xdr_RMDIR3args)
333332 {
334333 return &xdr_RMDIR3args;
335334 }
336335
337 inline auto proc_t_of(NFS3::RMDIR3res&)->decltype(&xdr_RMDIR3res)
336 inline auto proc_t_of(NFS3::RMDIR3res&) -> decltype(&xdr_RMDIR3res)
338337 {
339338 return &xdr_RMDIR3res;
340339 }
341340
342341 // Procedure 14: RENAME - Rename a File or Directory
343 inline auto proc_t_of(NFS3::RENAME3args&)->decltype(&xdr_RENAME3args)
342 inline auto proc_t_of(NFS3::RENAME3args&) -> decltype(&xdr_RENAME3args)
344343 {
345344 return &xdr_RENAME3args;
346345 }
347346
348 inline auto proc_t_of(NFS3::RENAME3res&)->decltype(&xdr_RENAME3res)
347 inline auto proc_t_of(NFS3::RENAME3res&) -> decltype(&xdr_RENAME3res)
349348 {
350349 return &xdr_RENAME3res;
351350 }
352351
353352 // Procedure 15: LINK - Create Link to an object
354 inline auto proc_t_of(NFS3::LINK3args&)->decltype(&xdr_LINK3args)
353 inline auto proc_t_of(NFS3::LINK3args&) -> decltype(&xdr_LINK3args)
355354 {
356355 return &xdr_LINK3args;
357356 }
358357
359 inline auto proc_t_of(NFS3::LINK3res&)->decltype(&xdr_LINK3res)
358 inline auto proc_t_of(NFS3::LINK3res&) -> decltype(&xdr_LINK3res)
360359 {
361360 return &xdr_LINK3res;
362361 }
363362
364363 // Procedure 16: READDIR - Read From Directory
365 inline auto proc_t_of(NFS3::READDIR3args&)->decltype(&xdr_READDIR3args)
364 inline auto proc_t_of(NFS3::READDIR3args&) -> decltype(&xdr_READDIR3args)
366365 {
367366 return &xdr_READDIR3args;
368367 }
369368
370 inline auto proc_t_of(NFS3::READDIR3res&)->decltype(&xdr_READDIR3res)
369 inline auto proc_t_of(NFS3::READDIR3res&) -> decltype(&xdr_READDIR3res)
371370 {
372371 return &xdr_READDIR3res;
373372 }
374373
375374 // Procedure 17: READDIRPLUS - Extended read from directory
376 inline auto proc_t_of(NFS3::READDIRPLUS3args&)->decltype(&xdr_READDIRPLUS3args)
375 inline auto proc_t_of(NFS3::READDIRPLUS3args&) -> decltype(&xdr_READDIRPLUS3args)
377376 {
378377 return &xdr_READDIRPLUS3args;
379378 }
380379
381 inline auto proc_t_of(NFS3::READDIRPLUS3res&)->decltype(&xdr_READDIRPLUS3res)
380 inline auto proc_t_of(NFS3::READDIRPLUS3res&) -> decltype(&xdr_READDIRPLUS3res)
382381 {
383382 return &xdr_READDIRPLUS3res;
384383 }
385384
386385 // Procedure 18: FSSTAT - Get dynamic file system information
387 inline auto proc_t_of(NFS3::FSSTAT3args&)->decltype(&xdr_FSSTAT3args)
386 inline auto proc_t_of(NFS3::FSSTAT3args&) -> decltype(&xdr_FSSTAT3args)
388387 {
389388 return &xdr_FSSTAT3args;
390389 }
391390
392 inline auto proc_t_of(NFS3::FSSTAT3res&)->decltype(&xdr_FSSTAT3res)
391 inline auto proc_t_of(NFS3::FSSTAT3res&) -> decltype(&xdr_FSSTAT3res)
393392 {
394393 return &xdr_FSSTAT3res;
395394 }
396395
397396 // Procedure 19: FSINFO - Get static file system Information
398 inline auto proc_t_of(NFS3::FSINFO3args&)->decltype(&xdr_FSINFO3args)
397 inline auto proc_t_of(NFS3::FSINFO3args&) -> decltype(&xdr_FSINFO3args)
399398 {
400399 return &xdr_FSINFO3args;
401400 }
402401
403 inline auto proc_t_of(NFS3::FSINFO3res&)->decltype(&xdr_FSINFO3res)
402 inline auto proc_t_of(NFS3::FSINFO3res&) -> decltype(&xdr_FSINFO3res)
404403 {
405404 return &xdr_FSINFO3res;
406405 }
407406
408407 // Procedure 20: PATHCONF - Retrieve POSIX information
409 inline auto proc_t_of(NFS3::PATHCONF3args&)->decltype(&xdr_PATHCONF3args)
408 inline auto proc_t_of(NFS3::PATHCONF3args&) -> decltype(&xdr_PATHCONF3args)
410409 {
411410 return &xdr_PATHCONF3args;
412411 }
413412
414 inline auto proc_t_of(NFS3::PATHCONF3res&)->decltype(&xdr_PATHCONF3res)
413 inline auto proc_t_of(NFS3::PATHCONF3res&) -> decltype(&xdr_PATHCONF3res)
415414 {
416415 return &xdr_PATHCONF3res;
417416 }
418417
419418 // Procedure 21: COMMIT - Commit cached data on a server to stable storage
420 inline auto proc_t_of(NFS3::COMMIT3args&)->decltype(&xdr_COMMIT3args)
419 inline auto proc_t_of(NFS3::COMMIT3args&) -> decltype(&xdr_COMMIT3args)
421420 {
422421 return &xdr_COMMIT3args;
423422 }
424423
425 inline auto proc_t_of(NFS3::COMMIT3res&)->decltype(&xdr_COMMIT3res)
424 inline auto proc_t_of(NFS3::COMMIT3res&) -> decltype(&xdr_COMMIT3res)
426425 {
427426 return &xdr_COMMIT3res;
428427 }
429
430 extern "C"
431 NST_PUBLIC
432 const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc);
433428
434429 std::ostream& operator<<(std::ostream& out, const ProcEnumNFS3::NFSProcedure proc);
435430
471466 } // namespace protocols
472467 } // namespace NST
473468 //------------------------------------------------------------------------------
474 #endif//NFS3_UTILS_H
475 //------------------------------------------------------------------------------
469 #endif // NFS3_UTILS_H
470 //------------------------------------------------------------------------------
00 //------------------------------------------------------------------------------
1 // Author: Alexey Costroma
1 // Author: Alexey Costroma
22 // Description: Helpers for parsing NFS structures.
33 // Copyright (c) 2014 EPAM Systems
44 //------------------------------------------------------------------------------
2020 //------------------------------------------------------------------------------
2121 #include <iomanip>
2222
23 #include "api/plugin_api.h" // for NST_PUBLIC
2324 #include "protocols/nfs/nfs_utils.h"
2425 #include "protocols/nfs4/nfs41_utils.h"
2526 //------------------------------------------------------------------------------
2627 using namespace NST::API::NFS41;
27 using namespace NST::protocols::NFS; // NFS helpers
28 using namespace NST::protocols::NFS; // NFS helpers
2829 //------------------------------------------------------------------------------
2930 namespace NST
3031 {
3233 {
3334 namespace NFS41
3435 {
36 // clang-format off
3537
3638 std::ostream& operator<<(std::ostream& out, const ProcEnumNFS41::NFSProcedure proc)
3739 {
3840 return out << print_nfs41_procedures(proc);
3941 }
4042
41 const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc)
43 extern "C" NST_PUBLIC const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc)
4244 {
4345 // In all cases we suppose, that NFSv4 operation ILLEGAL(10044)
4446 // has the second position in ProcEnumNFS41
345347
346348 std::ostream& operator<<(std::ostream& out, const nfs_fh4& obj)
347349 {
348 NFS::print_nfs_fh(out,
349 obj.nfs_fh4_val,
350 obj.nfs_fh4_len);
350 print_nfs_fh(out,
351 obj.nfs_fh4_val,
352 obj.nfs_fh4_len);
351353 return out;
352354 }
353355
86848686 return TRUE;
86858687 }
86868688
8689 // clang-format on
8690
86878691 } // namespace NFS41
86888692 } // namespace protocols
86898693 } // namespace NST
2323 //------------------------------------------------------------------------------
2424 #include <ostream>
2525
26 #include "api/nfs41_types_rpcgen.h"
2627 #include "api/nfs_types.h"
27 #include "api/nfs41_types_rpcgen.h"
2828 #include "protocols/nfs/nfs_utils.h"
2929 #include "protocols/rpc/rpc_header.h"
3030 //------------------------------------------------------------------------------
3434 {
3535 namespace NFS41
3636 {
37
3837 namespace NFS41 = NST::API::NFS41;
3938
4039 using ProcEnumNFS41 = API::ProcEnumNFS41;
4140
42 using Validator = rpc::RPCProgramValidator
43 <
44 100003, // SunRPC/NFS program
45 4, // v4
46 ProcEnumNFS41::NFS_NULL, // NFSPROC41RPCGEN_NULL (0)
47 ProcEnumNFS41::COMPOUND // NFSPROC41RPCGEN_COMPOUND (1)
48 >;
49
41 using Validator = rpc::RPCProgramValidator<
42 100003, // SunRPC/NFS program
43 4, // v4
44 ProcEnumNFS41::NFS_NULL, // NFSPROC41RPCGEN_NULL (0)
45 ProcEnumNFS41::COMPOUND // NFSPROC41RPCGEN_COMPOUND (1)
46 >;
47
48 // clang-format off
5049 bool_t xdr_nfs_ftype4 (XDR *, NFS41::nfs_ftype4*);
5150 bool_t xdr_nfsstat4 (XDR *, NFS41::nfsstat4*);
5251 bool_t xdr_attrlist4 (XDR *, NFS41::attrlist4*);
459458 bool_t xdr_nfs_cb_resop4 (XDR *, NFS41::nfs_cb_resop4*);
460459 bool_t xdr_CB_COMPOUND4args (XDR *, NFS41::CB_COMPOUND4args*);
461460 bool_t xdr_CB_COMPOUND4res (XDR *, NFS41::CB_COMPOUND4res*);
461 // clang-format on
462462
463463 // Procedure 0: NULL - Do nothing
464 inline auto proc_t_of(NFS41::NULL4args&)->decltype(&xdr_NULL4args)
464 inline auto proc_t_of(NFS41::NULL4args&) -> decltype(&xdr_NULL4args)
465465 {
466466 return xdr_NULL4args;
467467 }
468468
469 inline auto proc_t_of(NFS41::NULL4res&)->decltype(&xdr_NULL4res)
469 inline auto proc_t_of(NFS41::NULL4res&) -> decltype(&xdr_NULL4res)
470470 {
471471 return &xdr_NULL4res;
472472 }
473473
474474 // Procedure 1: COMPOUND
475 inline auto proc_t_of(NFS41::COMPOUND4args&)->decltype(&xdr_COMPOUND4args)
475 inline auto proc_t_of(NFS41::COMPOUND4args&) -> decltype(&xdr_COMPOUND4args)
476476 {
477477 return &xdr_COMPOUND4args;
478478 }
479479
480 inline auto proc_t_of(NFS41::COMPOUND4res&)->decltype(&xdr_COMPOUND4res)
480 inline auto proc_t_of(NFS41::COMPOUND4res&) -> decltype(&xdr_COMPOUND4res)
481481 {
482482 return &xdr_COMPOUND4res;
483483 }
484
485 #define NST_PUBLIC __attribute__ ((visibility("default")))
486
487 extern"C"
488 NST_PUBLIC
489 const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc);
490484
491485 std::ostream& operator<<(std::ostream& out, const ProcEnumNFS41::NFSProcedure proc);
492486 std::ostream& operator<<(std::ostream& out, const NFS41::nfs_ftype4& obj);
624618 } // namespace protocols
625619 } // namespace NST
626620 //------------------------------------------------------------------------------
627 #endif//NFS41_UTILS_H
621 #endif // NFS41_UTILS_H
628622 //------------------------------------------------------------------------------
00 //------------------------------------------------------------------------------
1 // Author: Alexey Costroma
1 // Author: Alexey Costroma
22 // Description: Helpers for parsing NFS structures.
33 // Copyright (c) 2014-2015 EPAM Systems
44 //------------------------------------------------------------------------------
2020 //------------------------------------------------------------------------------
2121 #include <iomanip>
2222
23 #include "api/plugin_api.h" // for NST_PUBLIC
2324 #include "protocols/nfs/nfs_utils.h"
2425 #include "protocols/nfs4/nfs4_utils.h"
2526 //------------------------------------------------------------------------------
2627 using namespace NST::API::NFS4;
27 using namespace NST::protocols::NFS; // NFS helpers
28 using namespace NST::protocols::NFS; // NFS helpers
2829 //------------------------------------------------------------------------------
2930 namespace NST
3031 {
3233 {
3334 namespace NFS4
3435 {
35
3636 std::ostream& operator<<(std::ostream& out, const ProcEnumNFS4::NFSProcedure proc)
3737 {
3838 return out << print_nfs4_procedures(proc);
3939 }
4040
41 const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc)
41 // clang-format off
42
43 extern "C" NST_PUBLIC const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc)
4244 {
4345 // In all cases we suppose, that NFSv4 operation ILLEGAL(10044)
4446 // has the second position in ProcEnumNFS4
315317
316318 std::ostream& operator<<(std::ostream& out, const nfs_fh4& obj)
317319 {
318 NFS::print_nfs_fh(out,
319 obj.nfs_fh4_val,
320 obj.nfs_fh4_len);
320 print_nfs_fh(out,
321 obj.nfs_fh4_val,
322 obj.nfs_fh4_len);
321323 return out;
322324 }
323325
44354437 return TRUE;
44364438 }
44374439
4440 // clang-format on
4441
44384442 } // namespace NFS4
44394443 } // namespace protocols
44404444 } // namespace NST
2323 //------------------------------------------------------------------------------
2424 #include <ostream>
2525
26 #include "api/nfs4_types_rpcgen.h"
2627 #include "api/nfs_types.h"
27 #include "api/nfs4_types_rpcgen.h"
2828 #include "protocols/nfs/nfs_utils.h"
2929 #include "protocols/rpc/rpc_header.h"
3030 //------------------------------------------------------------------------------
3434 {
3535 namespace NFS4
3636 {
37
3837 namespace NFS4 = NST::API::NFS4;
3938
4039 using ProcEnumNFS4 = API::ProcEnumNFS4;
4140
42 using Validator = rpc::RPCProgramValidator
43 <
44 100003, // SunRPC/NFS program
45 4, // v4
46 ProcEnumNFS4::NFS_NULL, // NFSPROC4RPCGEN_NULL (0)
47 ProcEnumNFS4::COMPOUND // NFSPROC4RPCGEN_COMPOUND (1)
48 >;
49
41 using Validator = rpc::RPCProgramValidator<
42 100003, // SunRPC/NFS program
43 4, // v4
44 ProcEnumNFS4::NFS_NULL, // NFSPROC4RPCGEN_NULL (0)
45 ProcEnumNFS4::COMPOUND // NFSPROC4RPCGEN_COMPOUND (1)
46 >;
47
48 // clang-format off
5049 bool_t xdr_nfs_ftype4 (XDR *, NFS4::nfs_ftype4*);
5150 bool_t xdr_nfsstat4 (XDR *, NFS4::nfsstat4*);
5251 bool_t xdr_bitmap4 (XDR *, NFS4::bitmap4*);
282281 bool_t xdr_nfs_cb_resop4 (XDR *, NFS4::nfs_cb_resop4*);
283282 bool_t xdr_CB_COMPOUND4args (XDR *, NFS4::CB_COMPOUND4args*);
284283 bool_t xdr_CB_COMPOUND4res (XDR *, NFS4::CB_COMPOUND4res*);
285
284 // clang-format on
286285
287286 // Procedure 0: NULL - Do nothing
288 inline auto proc_t_of(NFS4::NULL4args&)->decltype(&xdr_NULL4args)
287 inline auto proc_t_of(NFS4::NULL4args&) -> decltype(&xdr_NULL4args)
289288 {
290289 return &xdr_NULL4args;
291290 }
292291
293 inline auto proc_t_of(NFS4::NULL4res&)->decltype(&xdr_NULL4res)
292 inline auto proc_t_of(NFS4::NULL4res&) -> decltype(&xdr_NULL4res)
294293 {
295294 return &xdr_NULL4res;
296295 }
297296
298297 // Procedure 1: COMPOUND
299 inline auto proc_t_of(NFS4::COMPOUND4args&)->decltype(&xdr_COMPOUND4args)
298 inline auto proc_t_of(NFS4::COMPOUND4args&) -> decltype(&xdr_COMPOUND4args)
300299 {
301300 return &xdr_COMPOUND4args;
302301 }
303302
304 inline auto proc_t_of(NFS4::COMPOUND4res&)->decltype(&xdr_COMPOUND4res)
303 inline auto proc_t_of(NFS4::COMPOUND4res&) -> decltype(&xdr_COMPOUND4res)
305304 {
306305 return &xdr_COMPOUND4res;
307306 }
308
309 #define NST_PUBLIC __attribute__ ((visibility("default")))
310
311 extern"C"
312 NST_PUBLIC
313 const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc);
314307
315308 std::ostream& operator<<(std::ostream& out, const ProcEnumNFS4::NFSProcedure proc);
316309 std::ostream& operator<<(std::ostream& out, const NFS4::nfs_ftype4& obj);
369362 } // namespace protocols
370363 } // namespace NST
371364 //------------------------------------------------------------------------------
372 #endif//NFS4_UTILS_H
373 //------------------------------------------------------------------------------
365 #endif // NFS4_UTILS_H
366 //------------------------------------------------------------------------------
3333 {
3434 namespace rpc
3535 {
36
3736 using namespace NST::API;
3837
3938 struct MessageHeader
4039 {
41 inline uint32_t xid () const { return ntohl(m_xid); }
40 inline uint32_t xid() const { return ntohl(m_xid); }
4241 inline MsgType type() const { return MsgType(ntohl(m_type)); }
4342 private:
4443 MessageHeader() = delete;
4746 uint32_t m_type;
4847 };
4948
50 struct CallHeader: public MessageHeader
49 struct CallHeader : public MessageHeader
5150 {
52 inline uint32_t rpcvers() const { return ntohl(m_rpcvers); }
53 inline uint32_t prog() const { return ntohl(m_prog); }
54 inline uint32_t vers() const { return ntohl(m_vers); }
55 inline uint32_t proc() const { return ntohl(m_proc); }
56
51 inline uint32_t rpcvers() const { return ntohl(m_rpcvers); }
52 inline uint32_t prog() const { return ntohl(m_prog); }
53 inline uint32_t vers() const { return ntohl(m_vers); }
54 inline uint32_t proc() const { return ntohl(m_proc); }
5755 // OpaqueAuth cred - skipped
5856 // OpaqueAuth verf - skipped
5957 private:
6058 CallHeader() = delete;
6159
62 uint32_t m_rpcvers; // must be equal to two (2)
60 uint32_t m_rpcvers; // must be equal to two (2)
6361 uint32_t m_prog;
6462 uint32_t m_vers;
6563 uint32_t m_proc;
6664 };
6765
68 struct ReplyHeader: public MessageHeader
66 struct ReplyHeader : public MessageHeader
6967 {
7068 inline ReplyStat stat() const { return ReplyStat(ntohl(m_stat)); }
71
7269 // accepted_reply areply - skipped
7370 // rejected_reply rreply - skipped
7471 private:
7774 uint32_t m_stat;
7875 };
7976
80 struct RecordMark // RFC 5531 section 11 Record Marking Standard
77 struct RecordMark // RFC 5531 section 11 Record Marking Standard
8178 {
82 inline bool is_last() const { return ntohl(mark) & 0x80000000; /*1st bit*/ }
83 inline uint32_t fragment_len() const { return ntohl(mark) & 0x7FFFFFFF; /*31 bits*/ }
84 inline MessageHeader* fragment() const { return (MessageHeader*)(this+1); }
79 inline bool is_last() const { return ntohl(mark) & 0x80000000; /*1st bit*/ }
80 inline uint32_t fragment_len() const { return ntohl(mark) & 0x7FFFFFFF; /*31 bits*/ }
81 inline MessageHeader* fragment() const { return (MessageHeader*)(this + 1); }
8582 private:
8683 RecordMark() = delete;
8784
8885 uint32_t mark;
8986 };
9087
91
9288 class RPCValidator
9389 {
9490 public:
95 static inline bool check(const MessageHeader*const msg)
91 static inline bool check(const MessageHeader* const msg)
9692 {
9793 const MsgType type = msg->type();
9894
10096 type == MsgType::REPLY;
10197 }
10298
103 static inline bool check(const CallHeader*const call)
99 static inline bool check(const CallHeader* const call)
104100 {
105101 return call->rpcvers() == SUNRPC_MSG_VERSION;
106102 }
107103
108 static inline bool check(const ReplyHeader*const reply)
104 static inline bool check(const ReplyHeader* const reply)
109105 {
110106 const ReplyStat stat = reply->stat();
111107
112108 return stat == ReplyStat::MSG_ACCEPTED ||
113109 stat == ReplyStat::MSG_DENIED;
114110 }
111
115112 private:
116113 RPCValidator() = delete;
117114 };
118115
119
120 template
121 <
122 uint32_t Program, // remote program number
123 uint32_t Version, // remote program version number
124 uint32_t MinProc, // min remote procedure number
125 uint32_t MaxProc // max remote procedure number
126 >
116 template <
117 uint32_t Program, // remote program number
118 uint32_t Version, // remote program version number
119 uint32_t MinProc, // min remote procedure number
120 uint32_t MaxProc // max remote procedure number
121 >
127122 class RPCProgramValidator
128123 {
129124 public:
130 static inline bool check(const CallHeader*const call)
125 static inline bool check(const CallHeader* const call)
131126 {
132127 const uint32_t proc = call->proc();
133128
134 return proc <= MaxProc &&
135 proc >= MinProc &&
136 call->prog() == Program &&
137 call->vers() == Version ;
129 return proc <= MaxProc &&
130 proc >= MinProc &&
131 call->prog() == Program &&
132 call->vers() == Version;
138133 }
134
139135 private:
140136 RPCProgramValidator() = delete;
141137 };
142138
143139 //This template specialization for remove warning to compare unsigned with zero
144 template
145 <
140 template <
146141 uint32_t Program,
147142 uint32_t Version,
148 uint32_t MaxProc
149 >
143 uint32_t MaxProc>
150144 class RPCProgramValidator<Program, Version, 0, MaxProc>
151145 {
152146 public:
153 static inline bool check(const CallHeader*const call)
147 static inline bool check(const CallHeader* const call)
154148 {
155149 const uint32_t proc = call->proc();
156150
157151 // do not compare uint32_t with 0 (MinProc)
158 return proc <= MaxProc &&
159 call->prog() == Program &&
160 call->vers() == Version ;
152 return proc <= MaxProc &&
153 call->prog() == Program &&
154 call->vers() == Version;
161155 }
156
162157 private:
163158 RPCProgramValidator() = delete;
164159 };
167162 } // namespace protocols
168163 } // namespace NST
169164 //------------------------------------------------------------------------------
170 #endif//RPC_HEADER_H
165 #endif // RPC_HEADER_H
171166 //------------------------------------------------------------------------------
3232 {
3333 namespace tcp
3434 {
35
3635 // Transmission Control Protocol
3736 struct tcp_header
3837 {
3938 enum Flag // bit masks for flags
4039 {
41 FIN = 0x01, // finished send data
42 SYN = 0x02, // synchronize sequence numbers
43 RST = 0x04, // reset the connection
44 PSH = 0x08, // push data to the app layer
45 ACK = 0x10, // acknowledge
46 URG = 0x20, // urgent
47 ECE = 0x40, // ECN-echo
48 CWR = 0x80 // congestion window reduced
40 FIN = 0x01, // finished send data
41 SYN = 0x02, // synchronize sequence numbers
42 RST = 0x04, // reset the connection
43 PSH = 0x08, // push data to the app layer
44 ACK = 0x10, // acknowledge
45 URG = 0x20, // urgent
46 ECE = 0x40, // ECN-echo
47 CWR = 0x80 // congestion window reduced
4948 };
5049
51 in_port_t tcp_sport; // source port
52 in_port_t tcp_dport; // destination port
53 uint32_t tcp_seq; // sequence number
54 uint32_t tcp_ack; // acknowledgement number
55 uint8_t tcp_rsrvd_off; // (unused) and data offset
56 uint8_t tcp_flags; // control flags
57 uint16_t tcp_win; // window
58 uint16_t tcp_sum; // checksum
59 uint16_t tcp_urp; // urgent pointer
60 } __attribute__ ((__packed__));
50 in_port_t tcp_sport; // source port
51 in_port_t tcp_dport; // destination port
52 uint32_t tcp_seq; // sequence number
53 uint32_t tcp_ack; // acknowledgement number
54 uint8_t tcp_rsrvd_off; // (unused) and data offset
55 uint8_t tcp_flags; // control flags
56 uint16_t tcp_win; // window
57 uint16_t tcp_sum; // checksum
58 uint16_t tcp_urp; // urgent pointer
59 } __attribute__((__packed__));
6160
6261 struct TCPHeader : private tcp_header
6362 {
64 inline in_port_t sport() const { return tcp_sport; }
65 inline in_port_t dport() const { return tcp_dport; }
66 inline uint32_t seq() const { return ntohl(tcp_seq); }
67 inline uint32_t ack() const { return ntohl(tcp_ack); }
68 inline uint8_t offset() const { return (tcp_rsrvd_off & 0xf0) >> 2 /* *4 */; } // return number of bytes
69 inline uint8_t flags() const { return tcp_flags; }
70 inline bool is(tcp_header::Flag flag) const { return tcp_flags & flag; }
71 inline uint16_t window() const { return ntohs(tcp_win); }
72 inline uint16_t checksum() const { return ntohs(tcp_sum); }
73 inline uint16_t urgent() const { return ntohs(tcp_urp); }
74 } __attribute__ ((__packed__));
63 in_port_t sport() const { return tcp_sport; }
64 in_port_t dport() const { return tcp_dport; }
65 uint32_t seq() const { return ntohl(tcp_seq); }
66 uint32_t ack() const { return ntohl(tcp_ack); }
67 uint8_t offset() const { return (tcp_rsrvd_off & 0xf0) >> 2 /* *4 */; } // return number of bytes
68 uint8_t flags() const { return tcp_flags; }
69 bool is(tcp_header::Flag flag) const { return tcp_flags & flag; }
70 uint16_t window() const { return ntohs(tcp_win); }
71 uint16_t checksum() const { return ntohs(tcp_sum); }
72 uint16_t urgent() const { return ntohs(tcp_urp); }
73 } __attribute__((__packed__));
7574
7675 } // namespace tcp
7776 } // namespace protocols
7877 } // namespace NST
7978 //------------------------------------------------------------------------------
80 #endif//TCP_HEADER_H
79 #endif // TCP_HEADER_H
8180 //------------------------------------------------------------------------------
3232 {
3333 namespace udp
3434 {
35
3635 // User Datagram Protocol RFC 768
3736 struct udp_header
3837 {
39 in_port_t udp_sport; // source port, optional, may be 0
40 in_port_t udp_dport; // destination port
41 uint16_t udp_len; // length of the datagram, minimum value is 8
42 uint16_t udp_sum; // checksum of IP pseudo header, the UDP header, and the data
43 } __attribute__ ((__packed__));
38 in_port_t udp_sport; // source port, optional, may be 0
39 in_port_t udp_dport; // destination port
40 uint16_t udp_len; // length of the datagram, minimum value is 8
41 uint16_t udp_sum; // checksum of IP pseudo header, the UDP header, and the data
42 } __attribute__((__packed__));
4443
4544 struct UDPHeader : private udp_header
4645 {
47 inline in_port_t sport() const { return udp_sport; }
48 inline in_port_t dport() const { return udp_dport; }
49 inline uint16_t length() const { return ntohs(udp_len); }
50 inline uint16_t checksum() const { return ntohs(udp_sum); }
51 } __attribute__ ((__packed__));
46 in_port_t sport() const { return udp_sport; }
47 in_port_t dport() const { return udp_dport; }
48 uint16_t length() const { return ntohs(udp_len); }
49 uint16_t checksum() const { return ntohs(udp_sum); }
50 } __attribute__((__packed__));
5251
5352 } // namespace udp
5453 } // namespace protocols
5554 } // namespace NST
5655 //------------------------------------------------------------------------------
57 #endif//UDP_HEADER_H
56 #endif // UDP_HEADER_H
5857 //------------------------------------------------------------------------------
2424 #include <utility>
2525 #include <rpc/rpc.h>
2626 //------------------------------------------------------------------------------
27 #include "api/nfs3_types_rpcgen.h"
2728 #include "utils/filtered_data.h"
28 #include "api/nfs3_types_rpcgen.h"
2929 //------------------------------------------------------------------------------
3030 using NST::utils::FilteredData;
3131 using NST::utils::FilteredDataQueue;
3636 {
3737 namespace xdr
3838 {
39
4039 class XDRDecoderError : public std::runtime_error
4140 {
4241 public:
43 explicit XDRDecoderError(const std::string& msg) : std::runtime_error{msg} { }
42 explicit XDRDecoderError(const std::string& msg)
43 : std::runtime_error{msg}
44 {
45 }
4446 };
4547
4648 class XDRDecoder
4749 {
4850 public:
4951 XDRDecoder(FilteredDataQueue::Ptr&& p)
50 : ptr{std::move(p)}
52 : ptr{std::move(p)}
5153 {
5254 xdrmem_create(&txdr, (char*)ptr->data, ptr->dlen, XDR_DECODE);
5355 }
5456 ~XDRDecoder()
5557 {
56 xdr_destroy (&txdr);
58 xdr_destroy(&txdr);
5759 }
5860
59 inline XDR* xdr() { return &txdr; }
60
61 inline const FilteredData& data() const { return *ptr; }
62
61 XDR* xdr() { return &txdr; }
62 const FilteredData& data() const { return *ptr; }
6363 private:
64 XDR txdr;
64 XDR txdr;
6565 FilteredDataQueue::Ptr ptr;
6666 };
6767
6969 } // namespace protocols
7070 } // namespace NST
7171 //------------------------------------------------------------------------------
72 #endif//XDR_DECODER_H
72 #endif // XDR_DECODER_H
7373 //------------------------------------------------------------------------------
2121 #ifndef BLOCK_ALLOCATOR_H
2222 #define BLOCK_ALLOCATOR_H
2323 //------------------------------------------------------------------------------
24 #include <cstring> // for memset()
24 #include <algorithm>
25 #include <cassert>
26 #include <cstdint>
27 #include <memory>
28 #include <vector>
2529 //------------------------------------------------------------------------------
2630 namespace NST
2731 {
2832 namespace utils
2933 {
30
31 // May throw std::bad_alloc() when memory is not enough
34 // May throw std::bad_alloc during creation or allocation
3235 class BlockAllocator
3336 {
34 struct Chunk
37 struct Chunk // type for linking free chunks of memory in a list
3538 {
36 Chunk* next; // used only for free chunks in list
39 Chunk* next; // pointer to next chunk in a list
3740 };
41
42 using Chunks = std::unique_ptr<char[]>;
43 using Blocks = std::vector<Chunks>;
44
3845 public:
46 constexpr static std::size_t padding = 16;
3947
40 BlockAllocator() noexcept
41 : chunk {0}
42 , block {0}
43 , limit {0}
44 , nfree {0}
45 , allocated{0}
46 , blocks{nullptr}
47 , list {nullptr}
48 BlockAllocator() = default;
49 ~BlockAllocator() noexcept
4850 {
49 }
50
51 ~BlockAllocator()
52 {
53 for(std::size_t i {0}; i<allocated; i++)
54 {
55 delete[] ((char*)blocks[i]);
56 }
57 delete[] blocks;
51 assert(max_chunks() == free_chunks());
5852 }
5953
6054 void init_allocation(std::size_t chunk_size,
6155 std::size_t block_size,
6256 std::size_t block_limit)
6357 {
64 chunk = chunk_size;
58 chunk = ((chunk_size + padding - 1) / padding) * padding;
59 assert(chunk % padding == 0);
60 assert(chunk >= chunk_size);
61 assert(chunk >= sizeof(Chunk));
6562 block = block_size;
63 assert(block >= 1);
6664 limit = block_limit;
65 assert(limit >= 1);
6766
68 blocks = new Chunk*[limit];
69 memset(blocks, 0, sizeof(Chunk*)*limit);
70 list = new_block();
67 blocks.reserve(limit);
68 list = preallocate_block();
69 assert(list);
7170 }
7271
73 inline void* allocate()
72 void* allocate()
7473 {
7574 if(list == nullptr)
7675 {
77 if(allocated == limit) // all blocks are allocated!
76 if(blocks.size() == limit) // all blocks are allocated!
7877 {
79 increase_blocks_limit();
78 // soft limit of blocks is reached
8079 }
8180
82 list = new_block();
81 list = preallocate_block();
82 ++limit;
8383 }
8484
85 Chunk* c {list};
85 Chunk* chunk = list;
86 assert(chunk);
8687 list = list->next;
8788 --nfree;
88 return c;
89 return chunk;
8990 }
9091
91 inline void deallocate(void* ptr)
92 void deallocate(void* ptr) noexcept
9293 {
93 Chunk* c {(Chunk*) ptr};
94 c->next = list;
95 list = c;
94 assert(ptr);
95 assert(std::any_of(std::begin(blocks), std::end(blocks),
96 [&](const Chunks& chunks) {
97 const auto b = reinterpret_cast<void*>(chunks.get());
98 const auto e = reinterpret_cast<void*>(chunks.get() + block * chunk);
99 return (b <= ptr) && (ptr < e);
100 }));
101 Chunk* chunk = reinterpret_cast<Chunk*>(ptr);
102 chunk->next = list;
103 list = chunk;
96104 ++nfree;
97105 }
98106
99 // limits
100 inline std::size_t max_chunks() const { return block*limit; }
101 inline std::size_t max_memory() const { return block*limit*chunk; }
102 inline std::size_t max_blocks() const { return limit; }
103 inline std::size_t free_chunks()const { return nfree; }
104
107 std::size_t max_chunks() const noexcept { return block * limit; }
108 std::size_t max_memory() const noexcept { return block * limit * chunk; }
109 std::size_t max_blocks() const noexcept { return limit; }
110 std::size_t free_chunks() const noexcept { return nfree; }
105111 private:
106 Chunk* new_block()
112 Chunk* getof(std::size_t i, const Chunks& chunks) const noexcept
107113 {
108 char* ptr {new char[block*chunk]};
109 for(std::size_t i {0}; i<block-1; ++i)
110 {
111 ((Chunk*) &ptr[i * chunk])->next = (Chunk*) &ptr[(i + 1) * chunk];
112 }
113 ((Chunk*) &ptr[(block - 1) * chunk])->next = nullptr;
114 blocks[allocated] = (Chunk*) ptr;
115 ++allocated;
116 nfree += block;
117 return (Chunk*) ptr;
114 assert(i < block);
115 return reinterpret_cast<Chunk*>(&chunks.get()[i * chunk]);
118116 }
119117
120 void increase_blocks_limit()
118 Chunk* preallocate_block()
121119 {
122 const std::size_t new_limit {limit * 2}; // increase soft limit by twice
120 Chunks chunks(std::make_unique<Chunks::element_type[]>(block * chunk));
123121
124 Chunk** new_blocks {new Chunk*[new_limit]}; // allocate new array of blocks pointers
125 limit = new_limit;
126 memcpy(new_blocks, blocks, sizeof(Chunk*)*allocated); // copy pointers of existing blocks
127 memset(&new_blocks[allocated], 0, sizeof(Chunk*)*(limit-allocated)); // fill pointers for new blocks by NULL
128
129 delete[] blocks; // delete old array of blocks pointers
130 blocks = new_blocks; // set new array
122 // link chunks to a list
123 for(std::size_t i = 0; i < block - 1; ++i)
124 {
125 getof(i, chunks)->next = getof(i + 1, chunks);
126 }
127 getof(block - 1, chunks)->next = nullptr;
128 Chunk* first = getof(0, chunks);
129 blocks.emplace_back(std::move(chunks));
130 nfree += block;
131 return first;
131132 }
132133
133 std::size_t chunk; // chunk size
134 std::size_t block; // num chunks in block
135 std::size_t limit; // max blocks, soft limit
136 std::size_t nfree; // num of avaliable chunks
137 std::size_t allocated;// num of allocated blocks, up to limit
138 Chunk** blocks; // array of blocks
139 Chunk* list; // list of free chunks
134 Chunk* list = nullptr; // head of list of free chunks
135 std::size_t chunk = 0; // size of chunk
136 std::size_t block = 0; // num chunks in block
137 std::size_t limit = 0; // max blocks, soft limit
138 std::size_t nfree = 0; // num of avaliable chunks
139 Blocks blocks; // array of blocks
140140 };
141141
142142 } // namespace utils
143143 } // namespace NST
144144 //------------------------------------------------------------------------------
145 #endif//BLOCK_ALLOCATOR_H
145 #endif // BLOCK_ALLOCATOR_H
146146 //------------------------------------------------------------------------------
2727 using namespace NST::utils;
2828 //------------------------------------------------------------------------------
2929
30 DynamicLoad::DynamicLoad(const std::string &file)
30 DynamicLoad::DynamicLoad(const std::string& file)
3131 {
3232 handle = dlopen(file.c_str(), RTLD_LAZY);
3333 if(handle == nullptr)
4141 dlclose(handle);
4242 }
4343
44 void* DynamicLoad::get_symbol(const std::string &name)
44 void* DynamicLoad::get_symbol(const std::string& name)
4545 {
4646 void* address = (dlsym)(handle, name.c_str());
4747 if(address == nullptr)
2727 {
2828 namespace utils
2929 {
30
3130 class DynamicLoad
3231 {
3332 public:
3433 class DLException : public std::runtime_error
3534 {
3635 public:
37 explicit DLException(const std::string& msg) : std::runtime_error{msg} { }
36 explicit DLException(const std::string& msg)
37 : std::runtime_error{msg}
38 {
39 }
3840 };
3941
4042 protected:
4143 explicit DynamicLoad(const std::string& file);
4244 ~DynamicLoad();
4345
44 template<typename SymbolPtr>
46 template <typename SymbolPtr>
4547 void load_address_of(const std::string& name, SymbolPtr& address)
4648 {
4749 static_assert(sizeof(void*) == sizeof(SymbolPtr), "object pointer and function pointer sizes must be equal");
5052 using hook_dlsym_t = SymbolPtr (DynamicLoad::*)(const std::string&);
5153
5254 hook_dlsym_t get_symbol_func = reinterpret_cast<hook_dlsym_t>(&DynamicLoad::get_symbol);
53 address = (*this.*get_symbol_func)(name);
54 }
55 address = (*this.*get_symbol_func)(name);
56 }
5557
5658 /*!
5759 * Gets symbol by name from DLL
6870 } // namespace utils
6971 } // namespace NST
7072 //------------------------------------------------------------------------------
71 #endif//DYNAMIC_LOAD_H
73 #endif // DYNAMIC_LOAD_H
7274 //------------------------------------------------------------------------------
2121 #ifndef FILTERED_DATA_H
2222 #define FILTERED_DATA_H
2323 //------------------------------------------------------------------------------
24 #include <cassert>
2425 #include <cstdint>
25 #include <cassert>
2626
2727 #include <sys/time.h>
2828
29 #include "utils/queue.h"
2930 #include "utils/sessions.h"
30 #include "utils/queue.h"
3131 //------------------------------------------------------------------------------
3232 namespace NST
3333 {
3434 namespace utils
3535 {
36
3736 struct FilteredData
3837 {
3938 using Direction = NST::utils::Session::Direction;
39
4040 public:
4141 NetworkSession* session{nullptr}; // pointer to immutable session in Filtration
42 struct timeval timestamp; // timestamp of last collected packet
43 Direction direction; // direction of data transmission
42 struct timeval timestamp; // timestamp of last collected packet
43 Direction direction; // direction of data transmission
4444
45 uint32_t dlen{0}; // length of filtered data
46 uint8_t* data{cache}; // pointer to data in memory. {Readonly. Always points to proper memory buffer}
45 uint32_t dlen{0}; // length of filtered data
46 uint8_t* data{cache}; // pointer to data in memory. {Readonly. Always points to proper memory buffer}
4747
4848 private:
49 const static int CACHE_SIZE {4000};
50 uint8_t cache[CACHE_SIZE];
51 uint8_t* memory{nullptr};
52 uint32_t memsize{0};
49 const static int CACHE_SIZE{4000};
50
51 uint8_t cache[CACHE_SIZE];
52 uint8_t* memory{nullptr};
53 uint32_t memsize{0};
5354
5455 public:
5556 // disable copying
56 FilteredData(const FilteredData&) = delete;
57 FilteredData(const FilteredData&) = delete;
5758 FilteredData& operator=(const FilteredData&) = delete;
5859
59 inline FilteredData() noexcept : data{cache}
60 FilteredData() noexcept
61 : data{cache}
6062 {
6163 }
6264
63 inline ~FilteredData() {
65 ~FilteredData()
66 {
6467 delete[] memory;
6568 }
6669
67 inline uint32_t capacity() const
70 uint32_t capacity() const
6871 {
69 if (nullptr == memory)
72 if(nullptr == memory)
7073 {
7174 assert(data == cache);
7275 return CACHE_SIZE;
7780 // Resize capacity with data safety
7881 void resize(uint32_t newsize)
7982 {
80 if (capacity() >= newsize) return; // not resize less
83 if(capacity() >= newsize) return; // not resize less
8184
82 if (nullptr == memory)
85 if(nullptr == memory)
8386 {
8487 memory = new uint8_t[newsize];
85 if (dlen)
88 if(dlen)
8689 {
8790 memcpy(memory, cache, dlen);
8891 }
8992 memsize = newsize;
90 data = memory;
93 data = memory;
9194 }
9295 else // have some filled memory
9396 {
94 uint8_t* mem {new uint8_t[newsize]};
95 if (dlen)
97 uint8_t* mem{new uint8_t[newsize]};
98 if(dlen)
9699 {
97100 memcpy(mem, memory, dlen);
98101 }
104107 }
105108
106109 // Reset data. Release free memory if allocated
107 inline void reset()
110 void reset()
108111 {
109 if (nullptr != memory)
112 if(nullptr != memory)
110113 {
111114 delete[] memory;
112115 memory = nullptr;
113116 }
114117 memsize = 0;
115 dlen = 0;
116 data = cache;
118 dlen = 0;
119 data = cache;
117120 }
118121 };
119122
122125 } // namespace utils
123126 } // namespace NST
124127 //------------------------------------------------------------------------------
125 #endif//FILTERED_DATA_H
128 #endif // FILTERED_DATA_H
126129 //------------------------------------------------------------------------------
4747 {
4848 namespace utils
4949 {
50
51 static FILE* log_file {::stderr};
52 static bool own_file {false};
50 static FILE* log_file{::stderr};
51 static bool own_file{false};
5352
5453 namespace // unnanmed
5554 {
56
5755 static FILE* try_open(const std::string& file_name)
5856 {
5957 FILE* file = fopen(file_name.c_str(), "a+");
6058 if(file == nullptr)
6159 {
62 throw std::system_error{errno, std::system_category(),
63 {"Error in opening file: " + file_name}};
60 throw std::system_error{errno, std::system_category(), {"Error in opening file: " + file_name}};
6461 }
65 chmod(file_name.c_str(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
62 chmod(file_name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
6663 if(flock(fileno(file), LOCK_EX | LOCK_NB))
6764 {
6865 fclose(file);
69 throw std::system_error{errno, std::system_category(),
70 {"Log file already locked: " + file_name}};
66 throw std::system_error{errno, std::system_category(), {"Log file already locked: " + file_name}};
7167 }
7268 time_t now = time(NULL);
7369 fprintf(file, "--------------------------------------------------------------------------\n");
8076 } // namespace unnamed
8177
8278 Log::Global::Global(const std::string& path)
83 : log_file_path {path}
79 : log_file_path{path}
8480 {
8581 if(own_file)
8682 {
9086 if(!log_file_path.empty())
9187 {
9288 struct stat st;
93 bool exists = stat(log_file_path.c_str(), &st) == 0 ? true : false;
89
90 bool exists = (stat(log_file_path.c_str(), &st) == 0);
9491
9592 if(!exists && log_file_path.back() == '/')
9693 {
97 throw std::system_error{errno, std::system_category(),
98 {"Error accessing directory: " + log_file_path}};
94 throw std::system_error{errno, std::system_category(), {"Error accessing directory: " + log_file_path}};
9995 }
10096
10197 if(exists && S_ISDIR(st.st_mode))
10298 {
103 throw std::system_error{errno, std::system_category(),
104 {"Incorrect log file path: " + log_file_path + " - it is a directory! Please set correct path to log."}};
99 throw std::system_error{errno, std::system_category(), {"Incorrect log file path: " + log_file_path + " - it is a directory! Please set correct path to log."}};
105100 }
106101 }
107102 else
136131 FILE* temp = freopen(log_file_path.c_str(), "a+", log_file);
137132 if(temp == nullptr)
138133 {
139 throw std::system_error{errno, std::system_category(),
140 {std::string{"Can't reopen file: "} + log_file_path}};
134 throw std::system_error{errno, std::system_category(), {std::string{"Can't reopen file: "} + log_file_path}};
141135 }
142136 log_file = temp;
143137 }
144138
145139 Log::Log()
146 : std::stringbuf {ios_base::out}
147 , std::ostream {nullptr}
140 : std::stringbuf{ios_base::out}
141 , std::ostream{nullptr}
148142 {
149 std::stringbuf::setp(buffer, buffer+sizeof(buffer));
143 std::stringbuf::setp(buffer, buffer + sizeof(buffer));
150144 std::ostream::init(static_cast<std::stringbuf*>(this));
151145 std::ostream::put('\n');
152146 }
3030 #define DO_STRINGIZE(x) #x
3131 // TODO: DANGEROUS MACRO ! Passing custom client string as format to printf().
3232 // May be cause of SIGSEGV
33 #define TRACE(...) {\
34 NST::utils::Log::message(__FILE__ ":" STRINGIZE(__LINE__) ": " __VA_ARGS__);\
35 NST::utils::Log::message("\n");\
36 NST::utils::Log::flush();\
37 }
33 #define TRACE(...) \
34 { \
35 NST::utils::Log::message(__FILE__ ":" STRINGIZE(__LINE__) ": " __VA_ARGS__); \
36 NST::utils::Log::message("\n"); \
37 NST::utils::Log::flush(); \
38 }
3839 #endif
3940
40 #define LOG(...) {\
41 NST::utils::Log::message(__VA_ARGS__);\
42 NST::utils::Log::message("\n");\
43 }
41 #define LOG(...) \
42 { \
43 NST::utils::Log::message(__VA_ARGS__); \
44 NST::utils::Log::message("\n"); \
45 }
4446
45 #define LOGONCE(...) {\
46 static bool notyet = true; \
47 if(notyet) { LOG(__VA_ARGS__); notyet = false; }\
48 }
47 #define LOGONCE(...) \
48 { \
49 static bool notyet = true; \
50 if(notyet) { \
51 LOG(__VA_ARGS__); \
52 notyet = false; \
53 } \
54 }
4955 //------------------------------------------------------------------------------
5056 namespace NST
5157 {
5258 namespace utils
5359 {
54
5560 class Log : private std::stringbuf, public std::ostream
5661 {
5762 public:
6166 {
6267 explicit Global(const std::string& file_path);
6368 ~Global();
64 Global(const Global&) = delete;
69 Global(const Global&) = delete;
6570 Global& operator=(const Global&) = delete;
66 void reopen();
71 void reopen();
72
6773 private:
6874 std::string log_file_path;
6975 };
7076
7177 Log();
7278 ~Log();
73 Log(const Log&) = delete;
79 Log(const Log&) = delete;
7480 Log& operator=(const Log&) = delete;
7581
7682 // lightweight logging
7783 static void message(const char* format, ...);
7884 static void flush();
85
7986 private:
8087 char buffer[256];
8188 };
8390 } // namespace utils
8491 } // namespace NST
8592 //------------------------------------------------------------------------------
86 #endif//LOG_H
93 #endif // LOG_H
8794 //------------------------------------------------------------------------------
2424 {
2525 namespace utils
2626 {
27
2827 static Out::Level global = Out::Level::Info;
2928
3029 Out::Global::Global(const Level verbose_level)
4645 }
4746
4847 Out::Out(Level level)
49 : std::ostream{ (global >= level) ? std::cout.rdbuf() : nullptr }
48 : std::ostream{(global >= level) ? std::cout.rdbuf() : nullptr}
5049 {
5150 }
5251 Out::~Out()
2727 {
2828 namespace utils
2929 {
30
3130 class Out : public std::ostream
3231 {
3332 public:
4342 {
4443 explicit Global(const Level verbose_level);
4544 ~Global();
46 Global(const Global&) = delete;
45 Global(const Global&) = delete;
4746 Global& operator=(const Global&) = delete;
4847
49 static Level get_level(); // return global level of verbosity
50 static void set_level(Level); // set global level of verbosity
48 static Level get_level(); // return global level of verbosity
49 static void set_level(Level); // set global level of verbosity
5150 };
5251
53 explicit Out(Level level=Level::Info); // verbose level of message
52 explicit Out(Level level = Level::Info); // verbose level of message
5453 ~Out();
55 Out(const Out&) = delete;
54 Out(const Out&) = delete;
5655 Out& operator=(const Out&) = delete;
5756 };
5857
59 inline bool operator >=(const Out::Level a, const Out::Level b)
58 inline bool operator>=(const Out::Level a, const Out::Level b)
6059 {
6160 return (int)a >= (int)b;
6261 }
6463 } // namespace utils
6564 } // namespace NST
6665 //------------------------------------------------------------------------------
67 #endif//OUT_H
66 #endif // OUT_H
6867 //------------------------------------------------------------------------------
4444 * PROF;
4545 * ...
4646 */
47 template<int id>
47 template <int id>
4848 class Profiler
4949 {
50 const char* name = "";//!< Name of function
51 const static size_t reservedBytes = 50 * 1000;//!< Reserved - calls count
52 struct timespec startTime;//!< Timestamp of start function
50 const char* name = ""; //!< Name of function
51 const static size_t reservedBytes = 50 * 1000; //!< Reserved - calls count
52 struct timespec startTime; //!< Timestamp of start function
5353
5454 class Local
5555 {
5656 const char* name = "";
57
5758 public:
5859 std::vector<std::uint64_t> values;
5960 Local(const char* name)
6869 std::cout << name << "(" << id << "): calls count=" << values.size() << ", avg time=" << sum / values.size() << " nanosecs" << std::endl;
6970 }
7071 };
72
7173 public:
72
7374 /*! Constructor
7475 * \param name - name of function, which you are going to profile
7576 */
8485 struct timespec stopTime;
8586 clock_gettime(CLOCK_REALTIME, &stopTime);
8687
87 static Local local(name);// Time of vector initialization is not included into statistics
88 static Local local(name); // Time of vector initialization is not included into statistics
8889
89 local.values.push_back(stopTime.tv_nsec - startTime.tv_nsec);// Assume, that time < 1 second!
90 local.values.push_back(stopTime.tv_nsec - startTime.tv_nsec); // Assume, that time < 1 second!
9091 }
91
9292 };
9393 //------------------------------------------------------------------------------
94 #endif//PROFILER_H
94 #endif // PROFILER_H
9595 //------------------------------------------------------------------------------
2121 #ifndef QUEUE_H
2222 #define QUEUE_H
2323 //------------------------------------------------------------------------------
24 #include <cstddef>
2425 #include <memory>
2526 #include <type_traits>
2627
3132 {
3233 namespace utils
3334 {
34
3535 template <typename T>
3636 class Queue
3737 {
3838 struct Element // an element of the queue
3939 {
4040 Element* prev;
41 T data;
41 T data;
4242 };
4343
4444 struct ElementDeleter
4545 {
46 inline explicit ElementDeleter() noexcept : queue{nullptr} {}
47 inline explicit ElementDeleter(Queue* q) noexcept : queue{q} {}
48
49 inline void operator()(T* const pointer) const
46 explicit ElementDeleter(Queue* q = nullptr) noexcept
47 : queue{q}
48 {
49 }
50 void operator()(T* const pointer) const
5051 {
5152 if(pointer /*&& queue - dont check - optimization*/)
5253 {
5859 };
5960
6061 public:
61
6262 using Ptr = std::unique_ptr<T, ElementDeleter>;
6363
64 class List // List of elements for client code
64 class List // List of elements for client code
6565 {
6666 public:
67 inline explicit List(Queue& q) : queue{&q}
67 inline explicit List(Queue& q)
68 : queue{&q}
6869 {
6970 ptr = queue->pop_list();
7071 }
71 List(const List&) = delete;
72 List(const List&) = delete;
7273 List& operator=(const List&) = delete;
73 inline ~List()
74 ~List()
7475 {
7576 while(ptr)
7677 {
7879 }
7980 }
8081
81 inline operator bool() const { return ptr; } // is empty?
82 inline const T& data() const { return ptr->data; } // get data
83 inline Ptr get_current() // return element and switch to next
82 operator bool() const { return ptr; } // is empty?
83 const T& data() const { return ptr->data; } // get data
84 Ptr get_current() // return element and switch to next
8485 {
85 Element* tmp {ptr};
86 Element* tmp{ptr};
8687 ptr = ptr->prev;
8788 return Ptr{&tmp->data, ElementDeleter{queue}};
8889 }
89 inline void free_current() // deallocate element and switch to next
90 void free_current() // deallocate element and switch to next
9091 {
91 Element* tmp {ptr->prev};
92 Element* tmp{ptr->prev};
9293 queue->deallocate(ptr);
9394 ptr = tmp;
9495 }
96
9597 private:
9698 Element* ptr;
97 Queue* queue;
99 Queue* queue;
98100 };
99101
100
101 Queue(uint32_t size, uint32_t limit) : last{nullptr}, first{nullptr}
102 Queue(uint32_t size, uint32_t limit)
103 : last{nullptr}
104 , first{nullptr}
102105 {
103106 allocator.init_allocation(sizeof(Element), size, limit);
104107 }
105108 ~Queue()
106109 {
107 List list{*this}; // deallocate items by destructor of List
110 List list{*this}; // deallocate items by destructor of List
108111 }
109112
110 inline T* allocate()
113 T* allocate()
111114 {
112115 static_assert(std::is_nothrow_constructible<T>::value,
113116 "The construction of T must not to throw any exception");
114117
115118 Spinlock::Lock lock{a_spinlock};
116 Element* e {(Element*)allocator.allocate()}; // may throw std::bad_alloc
117 auto ptr = &(e->data);
118 ::new(ptr)T; // only call constructor of T (placement)
119 return ptr;
119 Element* e{(Element*)allocator.allocate()}; // may throw std::bad_alloc
120 return ::new(&(e->data)) T; // placement construction T
120121 }
121122
122 inline void deallocate(T* ptr)
123 void deallocate(T* ptr)
123124 {
124 ptr->~T(); // placement allocation functions syntax is used
125 Element* e { (Element*)( ((char*)ptr) - sizeof(Element*) ) };
125 ptr->~T(); // placement construction was used
126 Element* e{(Element*)(((char*)ptr) - offsetof(Element, data))};
126127 deallocate(e);
127128 }
128129
129 inline void push(T* ptr)
130 void push(T* ptr)
130131 {
131 Element* e { (Element*)( ((char*)ptr) - sizeof(Element*) ) };
132 Element* e{(Element*)(((char*)ptr) - offsetof(Element, data))};
132133 Spinlock::Lock lock{q_spinlock};
133 if(last)
134 {
135 last->prev = e;
136 last = e;
137 }
138 else // queue is empty
139 {
140 last = first = e;
141 }
134 if(last)
135 {
136 last->prev = e;
137 last = e;
138 }
139 else // queue is empty
140 {
141 last = first = e;
142 }
142143 }
143144
144 inline Element* pop_list() // take out list of all queued elements
145 Element* pop_list() // take out list of all queued elements
145146 {
146 Element* list {nullptr};
147 Element* list{nullptr};
147148 if(last)
148149 {
149150 Spinlock::Lock lock{q_spinlock};
150 if(last)
151 {
152 list = first;
153 last->prev = nullptr; // set end of list
154 last = first = nullptr;
155 }
151 if(last)
152 {
153 list = first;
154 last->prev = nullptr; // set end of list
155 last = first = nullptr;
156 }
156157 }
157158 return list;
158159 }
159160
160161 private:
161162 // accessible from Queue::List and Queue::Ptr
162 inline void deallocate(Element* e)
163 void deallocate(Element* e)
163164 {
164165 Spinlock::Lock lock{a_spinlock};
165 allocator.deallocate(e);
166 allocator.deallocate(e);
166167 }
167168
168169 BlockAllocator allocator;
169 Spinlock a_spinlock; // for allocate/deallocate
170 Spinlock q_spinlock; // for queue push/pop
170 Spinlock a_spinlock; // for allocate/deallocate
171 Spinlock q_spinlock; // for queue push/pop
171172
172173 // queue empty: last->nullptr<-first
173174 // queue filled: last->e<-e<-e<-e<-first
179180 } // namespace utils
180181 } // namespace NST
181182 //------------------------------------------------------------------------------
182 #endif//QUEUE_H
183 #endif // QUEUE_H
183184 //------------------------------------------------------------------------------
2020 //------------------------------------------------------------------------------
2121 #include <sstream>
2222
23 #include <arpa/inet.h> // for inet_ntop(), ntohs()
23 #include <arpa/inet.h> // for inet_ntop(), ntohs()
24 #include <netdb.h>
2425 #include <sys/socket.h> // for AF_INET/AF_INET6
25 #include <netdb.h>
26
26
27 #include "api/plugin_api.h" // for NST_PUBLIC
2728 #include "utils/out.h"
2829 #include "utils/sessions.h"
2930 //------------------------------------------------------------------------------
3132 {
3233 namespace utils
3334 {
34
3535 std::ostream& operator<<(std::ostream& out, const ApplicationSession& session);
3636
3737 ApplicationSession::ApplicationSession(const NetworkSession& s, Direction from_client)
38 : utils::Session (s)
38 : utils::Session(s)
3939 {
4040 if(s.direction != from_client)
4141 {
4343 std::swap(port[0], port[1]);
4444 switch(ip_type)
4545 {
46 case Session::IPType::v4:
47 std::swap(ip.v4.addr[0], ip.v4.addr[1]);
46 case Session::IPType::v4:
47 std::swap(ip.v4.addr[0], ip.v4.addr[1]);
4848 break;
49 case Session::IPType::v6:
50 std::swap(ip.v6.addr[0], ip.v6.addr[1]);
49 case Session::IPType::v6:
50 std::swap(ip.v6.addr[0], ip.v6.addr[1]);
5151 break;
5252 }
5353 }
6363
6464 namespace
6565 {
66
6766 std::ostream& operator<<(std::ostream& out, const Session::Type type)
6867 {
6968 switch(type)
7069 {
71 case Session::Type::TCP: return out << " [TCP]";
72 case Session::Type::UDP: return out << " [UDP]";
70 case Session::Type::TCP:
71 return out << " [TCP]";
72 case Session::Type::UDP:
73 return out << " [UDP]";
7374 }
7475 return out;
7576 }
7980 static_assert(sizeof(ipv4) == sizeof(struct in_addr), "they must be equal");
8081 char buf[INET_ADDRSTRLEN];
8182
82 const char* str {inet_ntop(AF_INET, &ipv4, buf, sizeof(buf))};
83 const char* str{inet_ntop(AF_INET, &ipv4, buf, sizeof(buf))};
8384 out << (str ? str : "Invalid IPv4 address")
8485 << ':' << ntohs(port);
8586 }
8687
8788 void print_ipv6_port(std::ostream& out, const uint8_t (&ipv6)[16], in_port_t port)
8889 {
89 static_assert(sizeof(ipv6) == sizeof(struct in6_addr),"they must be equal");
90 static_assert(sizeof(ipv6) == sizeof(struct in6_addr), "they must be equal");
9091 char buf[INET6_ADDRSTRLEN];
9192
92 const char* str {inet_ntop(AF_INET6, ipv6, buf, sizeof(buf))};
93 const char* str{inet_ntop(AF_INET6, ipv6, buf, sizeof(buf))};
9394 out << (str ? str : "Invalid IPv6 address")
9495 << ':' << ntohs(port);
9596 }
9697
9798 // TODO: getnameinfo call may be expensive
98 template<typename SockAddr>
99 template <typename SockAddr>
99100 void print_sockaddr(std::ostream& out, SockAddr& addr)
100101 {
101 char hostname[1025];
102 char service [65];
103 const int err {getnameinfo((sockaddr*)&addr, sizeof(addr),
104 hostname, sizeof(hostname),
105 service, sizeof(service),
106 NI_NAMEREQD ) };
102 char hostname[1025];
103 char service[65];
104 const int err{getnameinfo((sockaddr*)&addr, sizeof(addr),
105 hostname, sizeof(hostname),
106 service, sizeof(service),
107 NI_NAMEREQD)};
107108 if(err == 0)
108109 {
109110 out << '(' << hostname << ':' << service << ')';
111112 }
112113
113114 void print_ipv4_port_as_hostname_service(std::ostream& out,
114 in_addr_t ipv4,
115 in_port_t port)
115 in_addr_t ipv4,
116 in_port_t port)
116117 {
117118 sockaddr_in addr;
118 addr.sin_family = AF_INET;
119 addr.sin_port = port;
120 addr.sin_addr.s_addr= ipv4;
119 addr.sin_family = AF_INET;
120 addr.sin_port = port;
121 addr.sin_addr.s_addr = ipv4;
121122
122123 print_sockaddr(out, addr);
123124 }
124125
125126 void print_ipv6_port_as_hostname_service(std::ostream& out,
126127 const uint8_t (&ipv6)[16],
127 in_port_t port)
128 in_port_t port)
128129 {
129130 sockaddr_in6 addr;
130 addr.sin6_family = AF_INET6;
131 addr.sin6_port = port;
132 addr.sin6_flowinfo = 0;
133 addr.sin6_addr = (in6_addr&)ipv6;
134 addr.sin6_scope_id = 0;
131 addr.sin6_family = AF_INET6;
132 addr.sin6_port = port;
133 addr.sin6_flowinfo = 0;
134 addr.sin6_addr = (in6_addr&)ipv6;
135 addr.sin6_scope_id = 0;
135136
136137 print_sockaddr(out, addr);
137138 }
144145 return out;
145146 }
146147
147 void print_session(std::ostream& out, const Session& session)
148 extern "C" NST_PUBLIC void print_session(std::ostream& out, const Session& session)
148149 {
149150 switch(session.ip_type)
150151 {
151 case Session::IPType::v4:
152 {
153 print_ipv4_port(out, session.ip.v4.addr[Session::Source],
154 session.port [Session::Source]);
155 out << " --> ";
156 print_ipv4_port(out, session.ip.v4.addr[Session::Destination],
157 session.port [Session::Destination]);
158 }
159 break;
160 case Session::IPType::v6:
161 {
162 print_ipv6_port(out, session.ip.v6.addr[Session::Source],
163 session.port [Session::Source]);
164 out << " --> ";
165 print_ipv6_port(out, session.ip.v6.addr[Session::Destination],
166 session.port [Session::Destination]);
167 }
168 break;
152 case Session::IPType::v4:
153 {
154 print_ipv4_port(out, session.ip.v4.addr[Session::Source],
155 session.port[Session::Source]);
156 out << " --> ";
157 print_ipv4_port(out, session.ip.v4.addr[Session::Destination],
158 session.port[Session::Destination]);
159 }
160 break;
161 case Session::IPType::v6:
162 {
163 print_ipv6_port(out, session.ip.v6.addr[Session::Source],
164 session.port[Session::Source]);
165 out << " --> ";
166 print_ipv6_port(out, session.ip.v6.addr[Session::Destination],
167 session.port[Session::Destination]);
168 }
169 break;
169170 }
170171 out << session.type;
171172 }
172173
173174 std::ostream& operator<<(std::ostream& out, const ApplicationSession& session)
174175 {
175 const bool namelookup {Out::Global::get_level() == Out::Level::All};
176 const bool namelookup{Out::Global::get_level() == Out::Level::All};
176177
177178 switch(session.ip_type)
178179 {
179 case Session::IPType::v4:
180 {
181 {
182 auto& port = session.port [Session::Source];
183 auto& addr = session.ip.v4.addr[Session::Source];
184
185 print_ipv4_port(out, addr, port);
186 if(namelookup)
187 {
188 print_ipv4_port_as_hostname_service(out, addr, port);
189 }
190 }
191 out << " --> ";
192 {
193 auto& port = session.port [Session::Destination];
194 auto& addr = session.ip.v4.addr[Session::Destination];
195
196 print_ipv4_port(out, addr, port);
197 if(namelookup)
198 {
199 print_ipv4_port_as_hostname_service(out, addr, port);
200 }
201 }
202 }
203 break;
204 case Session::IPType::v6:
205 {
206 {
207 auto& port = session.port [Session::Source];
208 auto& addr = session.ip.v6.addr[Session::Source];
209
210 print_ipv6_port(out, addr, port);
211 if(namelookup)
212 {
213 print_ipv6_port_as_hostname_service(out, addr, port);
214 }
215 }
216 out << " --> ";
217 {
218 auto& port = session.port [Session::Destination];
219 auto& addr = session.ip.v6.addr[Session::Destination];
220
221 print_ipv6_port(out, addr, port);
222 if(namelookup)
223 {
224 print_ipv6_port_as_hostname_service(out, addr, port);
225 }
226 }
227 }
228 break;
180 case Session::IPType::v4:
181 {
182 {
183 auto& port = session.port[Session::Source];
184 auto& addr = session.ip.v4.addr[Session::Source];
185
186 print_ipv4_port(out, addr, port);
187 if(namelookup)
188 {
189 print_ipv4_port_as_hostname_service(out, addr, port);
190 }
191 }
192 out << " --> ";
193 {
194 auto& port = session.port[Session::Destination];
195 auto& addr = session.ip.v4.addr[Session::Destination];
196
197 print_ipv4_port(out, addr, port);
198 if(namelookup)
199 {
200 print_ipv4_port_as_hostname_service(out, addr, port);
201 }
202 }
203 }
204 break;
205 case Session::IPType::v6:
206 {
207 {
208 auto& port = session.port[Session::Source];
209 auto& addr = session.ip.v6.addr[Session::Source];
210
211 print_ipv6_port(out, addr, port);
212 if(namelookup)
213 {
214 print_ipv6_port_as_hostname_service(out, addr, port);
215 }
216 }
217 out << " --> ";
218 {
219 auto& port = session.port[Session::Destination];
220 auto& addr = session.ip.v6.addr[Session::Destination];
221
222 print_ipv6_port(out, addr, port);
223 if(namelookup)
224 {
225 print_ipv6_port_as_hostname_service(out, addr, port);
226 }
227 }
228 }
229 break;
229230 }
230231 out << session.type;
231232 return out;
234235 } // namespace utils
235236 } // namespace NST
236237 //------------------------------------------------------------------------------
237
2727
2828 #include "api/session.h"
2929 //------------------------------------------------------------------------------
30 #define NST_PUBLIC __attribute__ ((visibility("default")))
3130 //------------------------------------------------------------------------------
3231 namespace NST
3332 {
3433 namespace utils
3534 {
36
3735 using Session = NST::API::Session;
3836
3937 // Network layer session
4139 {
4240 public:
4341 NetworkSession()
44 : application {nullptr}
45 , direction {Direction::Unknown}
42 : application{nullptr}
43 , direction{Direction::Unknown}
4644 {
4745 }
4846
49 void* application; // pointer to application protocol implementation
47 void* application; // pointer to application protocol implementation
5048 Direction direction;
5149 };
52
5350
5451 // Application layer session
5552 struct ApplicationSession : public Session
6259 std::string session_str;
6360 };
6461
65 extern "C"
66 NST_PUBLIC
67 void print_session(std::ostream& out, const Session& session);
68
6962 std::ostream& operator<<(std::ostream& out, const Session& session);
7063
7164 } // namespace utils
7265 } // namespace NST
7366 //------------------------------------------------------------------------------
74 #endif//SESSIONS_H
67 #endif // SESSIONS_H
7568 //------------------------------------------------------------------------------
2121 #ifndef SPINLOCK_H
2222 #define SPINLOCK_H
2323 //------------------------------------------------------------------------------
24 #include <mutex> // for std::lock_guard
24 #include <mutex> // for std::lock_guard
2525
2626 #include <pthread.h>
2727 //------------------------------------------------------------------------------
2929 {
3030 namespace utils
3131 {
32
3332 class Spinlock
3433 {
3534 public:
3736 {
3837 pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE);
3938 }
40 Spinlock(const Spinlock&) = delete;
39 Spinlock(const Spinlock&) = delete;
4140 Spinlock& operator=(const Spinlock&) = delete;
4241 ~Spinlock() noexcept
4342 {
6867 } // namespace utils
6968 } // namespace NST
7069 //------------------------------------------------------------------------------
71 #endif//SPINLOCK_H
70 #endif // SPINLOCK_H
7271 //------------------------------------------------------------------------------
0 if ("${GMOCK_SOURCE_DIR}" STREQUAL "")
1 message (WARNING "GMOCK_SOURCE_DIR variable not set - unit-tests are not available. Use '-DGMOCK_SOURCE_DIR=<path_to_gmock_sources>' param for CMake")
0 if ("${GTEST_SOURCE_DIR}" STREQUAL "")
1 message (WARNING "GTEST_SOURCE_DIR variable not set - unit-tests are not available. Use
2 '-DGTEST_SOURCE_DIR=<path_to_nfstrace>/third_party/googletest' param for CMake")
23 else ()
34 # Clang and GCC 4.9+ cause errors on GMock/GTest compilation, so we are adding following flags to suppress them
45 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
89 set (gmock_force_shared_crt true CACHE INTERNAL "")
910 set (BUILD_SHARED_LIBS false CACHE INTERNAL "")
1011 add_definitions (-DGTEST_HAS_PTHREAD=1) # It fixes BUG in GTests in BSD
11 add_subdirectory (${GMOCK_SOURCE_DIR} ${CMAKE_BINARY_DIR}/gmock)
12 add_subdirectory (${GTEST_SOURCE_DIR}/googlemock ${CMAKE_BINARY_DIR}/gmock)
1213 set (GMOCK_LIBRARIES gmock gmock_main)
13 set (GMOCK_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/include"
14 "${GMOCK_SOURCE_DIR}/gtest/include"
15 "${GMOCK_SOURCE_DIR}")
14 set (GTEST_INCLUDE_DIRS
15 "${GTEST_SOURCE_DIR}/googletest/include"
16 "${GTEST_SOURCE_DIR}/googlemock/include")
1617
17 include_directories (${CMAKE_SOURCE_DIR}/src ${GMOCK_INCLUDE_DIRS})
18 include_directories (${CMAKE_SOURCE_DIR}/src ${GTEST_INCLUDE_DIRS})
1819
1920 add_subdirectory (utils)
2021 add_subdirectory (analyzers)
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <cstdlib>
22 #include <ctime>
2223 #include <iostream>
23 #include <ctime>
2424
2525 #include <gmock/gmock.h>
2626 #include <gtest/gtest.h>
3535 //------------------------------------------------------------------------------
3636 namespace
3737 {
38
3938 class BreakdownTest : public ::testing::Test
4039 {
4140 protected:
42 size_t count;
41 size_t count;
4342 timeval t;
43
4444 public:
4545 void SetUp()
4646 {
5252 {
5353 }
5454 };
55
5655 }
5756 //------------------------------------------------------------------------------
5857 TEST_F(BreakdownTest, count)
5958 {
60
6159 BreakdownCounter break_down(count);
6260
6361 EXPECT_EQ(0U, break_down.get_total_count());
6765 break_down[0].add(t);
6866
6967 EXPECT_EQ(3U, break_down.get_total_count());
70
7168 }
7269 //------------------------------------------------------------------------------
3535 //------------------------------------------------------------------------------
3636 namespace
3737 {
38
3938 class LatencyTest : public ::testing::Test
4039 {
4140 protected:
42 size_t count;
41 size_t count;
4342 timeval t1;
4443 timeval t2;
44
4545 public:
4646 void SetUp()
4747 {
5959 {
6060 }
6161 };
62
6362 }
6463 //------------------------------------------------------------------------------
6564 TEST_F(LatencyTest, max_min)
6665 {
67
6866 Latencies latency;
6967
7068 EXPECT_EQ(0U, latency.get_count());
7977
8078 EXPECT_EQ(t1.tv_sec, latency.get_max().tv_sec);
8179 EXPECT_EQ(t1.tv_usec, latency.get_max().tv_usec);
82
8380 }
8481
8582 TEST_F(LatencyTest, avg)
113110 */
114111
115112 struct timeval input;
116 input.tv_sec = 0;
113 input.tv_sec = 0;
117114 input.tv_usec = 500;
118115
119116 const auto sec = to_sec(input);
122119
123120 std::stringstream ss;
124121
125 ss.precision(6); ss << std::fixed << sec << ' ';
126 ss.precision(4); ss << std::fixed << sec << ' ';
127 ss.precision(3); ss << std::fixed << sec;
122 ss.precision(6);
123 ss << std::fixed << sec << ' ';
124 ss.precision(4);
125 ss << std::fixed << sec << ' ';
126 ss.precision(3);
127 ss << std::fixed << sec;
128128
129129 EXPECT_EQ("0.000500 0.0005 0.001", ss.str());
130130 }
1919 */
2020 //------------------------------------------------------------------------------
2121 #include <cstdlib>
22 #include <ctime>
2223 #include <iostream>
23 #include <ctime>
2424
2525 #include <gmock/gmock.h>
2626 #include <gtest/gtest.h>
3535 //------------------------------------------------------------------------------
3636 namespace
3737 {
38
3938 class StatisticTest : public ::testing::Test
4039 {
4140 protected:
4241 size_t count;
42
4343 public:
4444 void SetUp()
4545 {
6868 {
6969 }
7070
71 Session _session;
72 timeval _rtimestamp;
73 timeval _ctimestamp;
71 Session _session;
72 timeval _rtimestamp;
73 timeval _ctimestamp;
7474 const Session* session;
7575 const timeval* rtimestamp;
7676 const timeval* ctimestamp;
7777 };
78
7978 }
8079 //------------------------------------------------------------------------------
8180 TEST_F(StatisticTest, statistics)
8281 {
83
8482 Statistics stats(count);
8583
8684 EXPECT_EQ(count, stats.proc_types_count);
8785
8886 Mock each_procedure_mock;
8987 EXPECT_CALL(each_procedure_mock, mock_function())
90 .Times(count);
88 .Times(count);
9189
92 stats.for_each_procedure([&](const BreakdownCounter&, size_t)
93 {
90 stats.for_each_procedure([&](const BreakdownCounter&, size_t) {
9491 each_procedure_mock.mock_function();
9592 });
9693 }
9794
9895 TEST_F(StatisticTest, sessions_statistics)
9996 {
100
10197 Statistics stats(count);
102 Mock each_procedure_mock;
103 Proc proc;
98 Mock each_procedure_mock;
99 Proc proc;
104100
105101 EXPECT_CALL(each_procedure_mock, mock_function())
106 .Times(1);
102 .Times(1);
107103
108104 EXPECT_FALSE(stats.has_session());
109105 stats.account(&proc, 0);
110106 EXPECT_TRUE(stats.has_session());
111107
112 stats.for_each_session([&](const Session&)
113 {
108 stats.for_each_session([&](const Session&) {
114109 each_procedure_mock.mock_function();
115110 });
116111 }
117112
118113 TEST_F(StatisticTest, statistics_per_session)
119114 {
120
121115 Statistics stats(count);
122 Mock each_procedure_mock;
123 Proc proc;
116 Mock each_procedure_mock;
117 Proc proc;
124118
125119 EXPECT_CALL(each_procedure_mock, mock_function())
126 .Times(count);
120 .Times(count);
127121
128 stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t)
129 {
122 stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) {
130123 each_procedure_mock.mock_function();
131124 });
132125
133126 stats.account(&proc, 1);
134127
135 stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t)
136 {
128 stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) {
137129 each_procedure_mock.mock_function();
138130 });
139131 }
2525
2626 #include "analysis/analyzers.h"
2727 #include "analysis/cifs_parser.h"
28 #include "api/cifs2_commands.h"
29 #include "api/cifs_pc_to_net.h"
2830 #include "api/cifs_types.h"
29 #include "api/cifs_pc_to_net.h"
30 #include "api/cifs2_commands.h"
3131 //------------------------------------------------------------------------------
3232 using namespace NST::filtration;
3333 using namespace NST::analysis;
4141
4242 namespace
4343 {
44
4544 class PluginMock : public IAnalyzer
4645 {
4746 public:
4847 // ISMBv2 interface
49 MOCK_METHOD3(readSMBv2, void(const SMBv2::ReadCommand *, const NST::API::SMBv2::ReadRequest *, const NST::API::SMBv2::ReadResponse *));
48 MOCK_METHOD3(readSMBv2, void(const SMBv2::ReadCommand*, const NST::API::SMBv2::ReadRequest*, const NST::API::SMBv2::ReadResponse*));
5049
5150 // IAnalyzer interface
5251 void flush_statistics() {}
5352 };
5453
55
56 PluginMock* pluginMock;// pointer to mock
54 PluginMock* pluginMock; // pointer to mock
5755 }
5856 //------------------------------------------------------------------------------
5957 Analyzers::Analyzers(const controller::Parameters& /*params*/)
6159 this->modules.push_back(pluginMock);
6260 }
6361 //------------------------------------------------------------------------------
64 Parameters::Parameters(int /*argc*/, char** /*argv*/) {}
65
66 Parameters::~Parameters() {}
62 Parameters::Parameters(int /*argc*/, char** /*argv*/)
63 {
64 }
65
66 Parameters::~Parameters()
67 {
68 }
6769
6870 bool Parameters::show_help() const
6971 {
141143 return "";
142144 }
143145
144 DynamicLoad::DynamicLoad(const std::string &/*file*/) {}
145
146 DynamicLoad::~DynamicLoad() {}
147
148 template<typename plugin_get_entry_points_func>
146 DynamicLoad::DynamicLoad(const std::string& /*file*/)
147 {
148 }
149
150 DynamicLoad::~DynamicLoad()
151 {
152 }
153
154 template <typename plugin_get_entry_points_func>
149155 void load_address_of(const std::string& /*name*/, plugin_get_entry_points_func& /*address*/)
150 {}
151
152 Plugin::Plugin(const std::string& path) : DynamicLoad(path) {}
153
154 PluginInstance::PluginInstance(const std::string& path, const std::string& /*args*/) : Plugin(path) {}
155
156 PluginInstance::~PluginInstance() {}
156 {
157 }
158
159 Plugin::Plugin(const std::string& path)
160 : DynamicLoad(path)
161 {
162 }
163
164 PluginInstance::PluginInstance(const std::string& path, const std::string& /*args*/)
165 : Plugin(path)
166 {
167 }
168
169 PluginInstance::~PluginInstance()
170 {
171 }
157172
158173 //------------------------------------------------------------------------------
159174 TEST(Parser, CIFSAsyncParser)
161176 pluginMock = new PluginMock;
162177
163178 NST::controller::Parameters params(0, nullptr);
164 Analyzers analyzers(params);
179 Analyzers analyzers(params);
165180
166181 NST::utils::FilteredDataQueue queue(1, 1);
167 NST::utils::FilteredData* data = queue.allocate();
168 NetworkSession s;
182 NST::utils::FilteredData* data = queue.allocate();
183 NetworkSession s;
169184 data->session = &s;
170185 queue.push(data);
171186 NST::utils::FilteredDataQueue::List list(queue);
172 NST::utils::FilteredDataQueue::Ptr el = list.get_current();
187 NST::utils::FilteredDataQueue::Ptr el = list.get_current();
173188
174189 CIFSv2::MessageHeader header;
175 header.head_code = NST::API::SMBv2::pc_to_net<uint32_t>(0x424d53fe);// Protocol's marker
176 header.cmd_code = NST::API::SMBv2::SMBv2Commands::READ;
177 header.flags = static_cast<uint32_t>(CIFSv2::Flags::ASYNC_COMMAND);
190 header.head_code = NST::API::SMBv2::pc_to_net<uint32_t>(0x424d53fe); // Protocol's marker
191 header.cmd_code = NST::API::SMBv2::SMBv2Commands::READ;
192 header.flags = static_cast<uint32_t>(CIFSv2::Flags::ASYNC_COMMAND);
178193
179194 el->data = reinterpret_cast<uint8_t*>(&header);
180195 el->dlen = sizeof(header);
183198
184199 // Set conditions
185200 EXPECT_CALL(*pluginMock, readSMBv2(_, _, _))
186 .Times(1);
201 .Times(1);
187202
188203 // Do
189204 parser.parse_data(el);
191206 delete pluginMock;
192207 }
193208 //------------------------------------------------------------------------------
194
2222 #include <gtest/gtest.h>
2323
2424 #include "controller/running_status.h"
25 #include "filtration/cifs_filtrator.h"
2526 #include "filtration/filtration_processor.h"
26 #include "filtration/cifs_filtrator.h"
2727 #include "filtration/filtrators.h"
2828 #include "filtration/packet.h"
2929 //------------------------------------------------------------------------------
3535
3636 namespace
3737 {
38
3938 class Writer
4039 {
4140 public:
42
4341 class Collection
4442 {
4543 Collection* pImpl = nullptr;
44
4645 public:
4746 void set(Writer& w, NST::utils::NetworkSession* /*session_ptr*/)
4847 {
5150
5251 virtual void reset()
5352 {
54 if (pImpl)
53 if(pImpl)
5554 {
5655 pImpl->reset();
5756 }
5958
6059 virtual void push(PacketInfo& info, size_t size)
6160 {
62 if (pImpl)
61 if(pImpl)
6362 {
6463 pImpl->push(info, size);
6564 }
6766
6867 virtual void skip_first(size_t size)
6968 {
70 if (pImpl)
69 if(pImpl)
7170 {
7271 pImpl->skip_first(size);
7372 }
7574
7675 virtual void complete(PacketInfo& info)
7776 {
78 if (pImpl)
77 if(pImpl)
7978 {
8079 pImpl->complete(info);
8180 }
8887
8988 virtual const uint8_t* data()
9089 {
91 if (pImpl)
90 if(pImpl)
9291 {
9392 return pImpl->data();
9493 }
9796
9897 virtual size_t data_size()
9998 {
100 if (pImpl)
99 if(pImpl)
101100 {
102101 return pImpl->data_size();
103102 }
106105
107106 virtual size_t capacity()
108107 {
109 if (pImpl)
108 if(pImpl)
110109 {
111110 return pImpl->capacity();
112111 }
115114
116115 virtual void allocate()
117116 {
118 if (pImpl)
117 if(pImpl)
119118 {
120119 pImpl->allocate();
121120 }
126125 public:
127126 MOCK_METHOD0(reset, void());
128127 MOCK_METHOD2(push, void(PacketInfo&, size_t));
129 MOCK_METHOD0(data, const uint8_t* ());
128 MOCK_METHOD0(data, const uint8_t*());
130129 MOCK_METHOD0(data_size, size_t());
131130 MOCK_METHOD0(capacity, size_t());
132131 MOCK_METHOD0(allocate, void());
133132 MOCK_METHOD1(skip_first, void(size_t));
134133 MOCK_METHOD1(complete, void(PacketInfo&));
135
136134 };
137135
138136 CollectionMock collection;
139137 };
140
141138 }
142139
143140 TEST(Filtration, CIFSFiltratorReset)
145142 // Set conditions
146143 Writer mock;
147144 EXPECT_CALL(mock.collection, reset())
148 .Times(1);
145 .Times(1);
149146
150147 CIFSFiltrator<Writer> f;
151148 f.set_writer(nullptr, &mock, 0);
158155 // Set conditions
159156 Writer mock;
160157 EXPECT_CALL(mock.collection, reset())
161 .Times(2);
158 .Times(2);
162159
163160 Filtrators<Writer> f;
164161 f.set_writer(nullptr, &mock, 0);
171168 // Prepare data
172169 struct pcap_pkthdr header;
173170 header.caplen = header.len = 16;
174 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x84,
171 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x84,
175172 0xec, 0x8a, 0x42, 0xcb,
176173 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x02
178 };
174 0x00, 0x00, 0x00, 0x02};
179175 PacketInfo info(&header, packet, 0);
180176
181177 Writer mock;
182178 EXPECT_CALL(mock.collection, data())
183 .WillRepeatedly(Return(packet));
179 .WillRepeatedly(Return(packet));
184180 EXPECT_CALL(mock.collection, data_size())
185 .WillOnce(Return(0))
186 .WillOnce(Return(0))
187 .WillRepeatedly(Return(sizeof(packet)));
181 .WillOnce(Return(0))
182 .WillOnce(Return(0))
183 .WillRepeatedly(Return(sizeof(packet)));
188184 EXPECT_CALL(mock.collection, capacity())
189 .WillRepeatedly(Return(1000000));
185 .WillRepeatedly(Return(1000000));
190186 // Set conditions
191187 EXPECT_CALL(mock.collection, push(_, _))
192 .Times(AtLeast(1));
188 .Times(AtLeast(1));
193189
194190 Filtrators<Writer> f;
195191 f.set_writer(nullptr, &mock, 0);
202198 // Prepare data
203199 struct pcap_pkthdr header;
204200 header.caplen = header.len = 16;
205 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x68,
201 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x68,
206202 0xfe, 0x53, 0x4d, 0x42,
207203 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00
209 };
204 0x00, 0x00, 0x00, 0x00};
210205 PacketInfo info(&header, packet, 0);
211206
212207 Writer mock;
213208 EXPECT_CALL(mock.collection, data())
214 .WillRepeatedly(Return(packet));
209 .WillRepeatedly(Return(packet));
215210 EXPECT_CALL(mock.collection, data_size())
216 .WillOnce(Return(0))
217 .WillOnce(Return(0))
218 .WillRepeatedly(Return(sizeof(packet)));
211 .WillOnce(Return(0))
212 .WillOnce(Return(0))
213 .WillRepeatedly(Return(sizeof(packet)));
219214 EXPECT_CALL(mock.collection, capacity())
220 .WillRepeatedly(Return(1000000));
215 .WillRepeatedly(Return(1000000));
221216 // Set conditions
222217 EXPECT_CALL(mock.collection, push(_, _))
223 .Times(AtLeast(1));
218 .Times(AtLeast(1));
224219
225220 Filtrators<Writer> f;
226221 f.set_writer(nullptr, &mock, 0);
2424 #include <gtest/gtest.h>
2525
2626 #include "controller/running_status.h"
27 #include "filtration/cifs_filtrator.h"
2728 #include "filtration/filtration_processor.h"
28 #include "filtration/cifs_filtrator.h"
2929 #include "filtration/filtrators.h"
3030 #include "filtration/packet.h"
3131 //------------------------------------------------------------------------------
3434 using ::testing::AtLeast;
3535 using ::testing::_;
3636 //------------------------------------------------------------------------------
37 namespace {
38
37 namespace
38 {
3939 class Writer
4040 {
4141 public:
42
4342 class Collection
4443 {
4544 std::vector<uint8_t> packet;
46 Collection *pImpl = nullptr;
45 Collection* pImpl = nullptr;
46
4747 public:
4848 void set(Writer& w, NST::utils::NetworkSession* /*session_ptr*/)
4949 {
6666
6767 virtual void complete(PacketInfo& info)
6868 {
69 if (pImpl)
69 if(pImpl)
7070 {
7171 pImpl->complete(info);
7272 }
7777 return true;
7878 }
7979
80 virtual const uint8_t * data()
80 virtual const uint8_t* data()
8181 {
8282 return packet.data();
8383 }
101101 public:
102102 MOCK_METHOD0(reset, void());
103103 MOCK_METHOD2(push, void(PacketInfo&, size_t));
104 MOCK_METHOD0(data, const uint8_t *());
104 MOCK_METHOD0(data, const uint8_t*());
105105 MOCK_METHOD0(data_size, size_t());
106106 MOCK_METHOD1(complete, void(PacketInfo&));
107
108107 };
109108
110109 CollectionMock collection;
111110 };
112
113111 }
114112
115113 TEST(Filtration, pushCIFSbyTCPStream)
117115 // Prepare data
118116 struct pcap_pkthdr header;
119117 header.caplen = header.len = 132;
120 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80,
118 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80,
121119 0xfe, 0x53, 0x4d, 0x42,
122120 0x00, 0x00, 0x00, 0x00,
123121 0x00, 0x00, 0x00, 0x00,
157155 0x00, 0x00, 0x00, 0x00,
158156 0x00, 0x00, 0x00, 0x00,
159157
160 0x00, 0x00, 0x00, 0x00
161 };
158 0x00, 0x00, 0x00, 0x00};
162159 PacketInfo info(&header, packet, 0);
163 Writer mock;
160 Writer mock;
164161 // Set conditions
165162 EXPECT_CALL(mock.collection, complete(_))
166163 .Times(AtLeast(1));
176173 // Prepare data
177174 struct pcap_pkthdr header1;
178175 header1.caplen = header1.len = 3;
179 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80,
176 const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80,
180177 0xfe, 0x53, 0x4d, 0x42,
181178 0x00, 0x00, 0x00, 0x00,
182179 0x00, 0x00, 0x00, 0x00,
216213 0x00, 0x00, 0x00, 0x00,
217214 0x00, 0x00, 0x00, 0x00,
218215
219 0x00, 0x00, 0x00, 0x00
220 };
216 0x00, 0x00, 0x00, 0x00};
221217 PacketInfo info1(&header1, packet, 0);
222218
223219 struct pcap_pkthdr header2;
224220 header2.caplen = header2.len = sizeof(packet) - header1.len;
225221 PacketInfo info2(&header2, packet + header1.len, 0);
226 Writer mock;
222 Writer mock;
227223
228224 // Set conditions
229225 EXPECT_CALL(mock.collection, complete(_))
241237 // Prepare data
242238 struct pcap_pkthdr header;
243239 header.caplen = header.len = 132;
244 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80,
240 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80,
245241 0xec, 0x8a, 0x42, 0xcb,
246 0x00, 0x00, 0x00, 0x00,// msg type - call
247 0x00, 0x00, 0x00, 0x02,// RPC version
248
249 0x00, 0x00, 0x00, 0x00,
250 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x00, 0x00,
253
254 0x00, 0x00, 0x00, 0x00,
255 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00,
257 0x00, 0x00, 0x00, 0x00,
258
259 0x00, 0x00, 0x00, 0x00,
260 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00,
262 0x00, 0x00, 0x00, 0x00,
263
264 0x00, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00,
268
269 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00,
273
274 0x00, 0x00, 0x00, 0x00,
275 0x00, 0x00, 0x00, 0x00,
276 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00,
278
279 0x00, 0x00, 0x00, 0x00,
280 0x00, 0x00, 0x00, 0x00,
281 0x00, 0x00, 0x00, 0x00,
282 0x00, 0x00, 0x00, 0x00,
283
284 0x00, 0x00, 0x00, 0x00
285 };
242 0x00, 0x00, 0x00, 0x00, // msg type - call
243 0x00, 0x00, 0x00, 0x02, // RPC version
244
245 0x00, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00,
247 0x00, 0x00, 0x00, 0x00,
248 0x00, 0x00, 0x00, 0x00,
249
250 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x00, 0x00,
253 0x00, 0x00, 0x00, 0x00,
254
255 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00,
257 0x00, 0x00, 0x00, 0x00,
258 0x00, 0x00, 0x00, 0x00,
259
260 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00,
262 0x00, 0x00, 0x00, 0x00,
263 0x00, 0x00, 0x00, 0x00,
264
265 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00,
269
270 0x00, 0x00, 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00,
273 0x00, 0x00, 0x00, 0x00,
274
275 0x00, 0x00, 0x00, 0x00,
276 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 0x00, 0x00,
279
280 0x00, 0x00, 0x00, 0x00};
286281 PacketInfo info(&header, packet, 0);
287 Writer mock;
282 Writer mock;
288283 // Set conditions
289284 EXPECT_CALL(mock.collection, complete(_))
290285 .Times(AtLeast(1));
300295 // Prepare data
301296 struct pcap_pkthdr header1;
302297 header1.caplen = header1.len = 3;
303 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80,
298 const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80,
304299 0xec, 0x8a, 0x42, 0xcb,
305 0x00, 0x00, 0x00, 0x00,// msg type - call
306 0x00, 0x00, 0x00, 0x02,// RPC version
307
308 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00,
312
313 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00,
317
318 0x00, 0x00, 0x00, 0x00,
319 0x00, 0x00, 0x00, 0x00,
320 0x00, 0x00, 0x00, 0x00,
321 0x00, 0x00, 0x00, 0x00,
322
323 0x00, 0x00, 0x00, 0x00,
324 0x00, 0x00, 0x00, 0x00,
325 0x00, 0x00, 0x00, 0x00,
326 0x00, 0x00, 0x00, 0x00,
327
328 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x00, 0x00,
332
333 0x00, 0x00, 0x00, 0x00,
334 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00,
336 0x00, 0x00, 0x00, 0x00,
337
338 0x00, 0x00, 0x00, 0x00,
339 0x00, 0x00, 0x00, 0x00,
340 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x00, 0x00, 0x00,
342
343 0x00, 0x00, 0x00, 0x00
344 };
300 0x00, 0x00, 0x00, 0x00, // msg type - call
301 0x00, 0x00, 0x00, 0x02, // RPC version
302
303 0x00, 0x00, 0x00, 0x00,
304 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00,
306 0x00, 0x00, 0x00, 0x00,
307
308 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00,
312
313 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00,
317
318 0x00, 0x00, 0x00, 0x00,
319 0x00, 0x00, 0x00, 0x00,
320 0x00, 0x00, 0x00, 0x00,
321 0x00, 0x00, 0x00, 0x00,
322
323 0x00, 0x00, 0x00, 0x00,
324 0x00, 0x00, 0x00, 0x00,
325 0x00, 0x00, 0x00, 0x00,
326 0x00, 0x00, 0x00, 0x00,
327
328 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x00, 0x00,
332
333 0x00, 0x00, 0x00, 0x00,
334 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00,
336 0x00, 0x00, 0x00, 0x00,
337
338 0x00, 0x00, 0x00, 0x00};
345339 PacketInfo info1(&header1, packet, 0);
346340
347341 struct pcap_pkthdr header2;
348342 header2.caplen = header2.len = sizeof(packet) - header1.len;
349343 PacketInfo info2(&header2, packet + header1.len, 0);
350 Writer mock;
344 Writer mock;
351345
352346 // Set conditions
353347 EXPECT_CALL(mock.collection, complete(_))
361355 }
362356
363357 //------------------------------------------------------------------------------
364
1818 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020 //------------------------------------------------------------------------------
21 #include <arpa/inet.h>
2122 #include <gmock/gmock.h>
2223 #include <gtest/gtest.h>
23 #include <arpa/inet.h>
2424
2525 #include "api/cifs2_commands.h"
2626 #include "api/cifs_commands.h"
3737 // UseCase: CIFSv1/CIFSv2 uses LE byteorder for encoding fields of messages
3838 // in network traffic. These messages may be read on BE platform and should
3939 // be compared with constants with corresponded BE byte order.
40 union TestData
41 {
40 union TestData {
4241 std::uint64_t ui64;
4342 std::uint32_t ui32;
4443 std::uint16_t ui16;
7271 EXPECT_EQ(data.bytes[1], 0xEE);
7372 }
7473
75
7674 TEST(CIFSv2, bodies)
7775 {
7876 EXPECT_EQ(36u, sizeof(struct NegotiateRequest) - sizeof(Dialects));
7977 EXPECT_EQ(65u, sizeof(struct NegotiateResponse));
8078
8179 EXPECT_EQ(25u, sizeof(struct SessionSetupRequest));
82 EXPECT_EQ(9u, sizeof(struct SessionSetupResponse));
80 EXPECT_EQ(9u, sizeof(struct SessionSetupResponse));
8381
84 EXPECT_EQ(4u, sizeof(struct LogOffRequest));
85 EXPECT_EQ(4u, sizeof(struct LogOffResponse));
82 EXPECT_EQ(4u, sizeof(struct LogOffRequest));
83 EXPECT_EQ(4u, sizeof(struct LogOffResponse));
8684
87 EXPECT_EQ(4u, sizeof(struct EchoRequest));
88 EXPECT_EQ(4u, sizeof(struct EchoResponse));
85 EXPECT_EQ(4u, sizeof(struct EchoRequest));
86 EXPECT_EQ(4u, sizeof(struct EchoResponse));
8987
90 EXPECT_EQ(9u, sizeof(struct TreeConnectRequest));
88 EXPECT_EQ(9u, sizeof(struct TreeConnectRequest));
9189 EXPECT_EQ(16u, sizeof(struct TreeConnectResponse));
9290
93 EXPECT_EQ(4u, sizeof(struct TreeDisconnectRequest));
94 EXPECT_EQ(4u, sizeof(struct TreeDisconnectResponse));
91 EXPECT_EQ(4u, sizeof(struct TreeDisconnectRequest));
92 EXPECT_EQ(4u, sizeof(struct TreeDisconnectResponse));
9593
9694 EXPECT_EQ(57u, sizeof(struct CreateRequest));
9795 EXPECT_EQ(89u, sizeof(struct CreateResponse));
10098 EXPECT_EQ(60u, sizeof(struct CloseResponse));
10199
102100 EXPECT_EQ(41u, sizeof(struct QueryInfoRequest));
103 EXPECT_EQ(9u, sizeof(struct QueryInfoResponse));
101 EXPECT_EQ(9u, sizeof(struct QueryInfoResponse));
104102
105103 EXPECT_EQ(33u, sizeof(struct QueryDirRequest));
106 EXPECT_EQ(9u, sizeof(struct QueryDirResponse));
104 EXPECT_EQ(9u, sizeof(struct QueryDirResponse));
107105
108106 EXPECT_EQ(24u, sizeof(struct FlushRequest));
109 EXPECT_EQ(4u, sizeof(struct FlushResponse));
107 EXPECT_EQ(4u, sizeof(struct FlushResponse));
110108
111109 EXPECT_EQ(49u, sizeof(struct ReadRequest));
112110 EXPECT_EQ(17u, sizeof(struct ReadResponse));
118116 EXPECT_EQ(16u, sizeof(struct WriteResponse));
119117
120118 EXPECT_EQ(48u, sizeof(struct LockRequest));
121 EXPECT_EQ(4u, sizeof(struct LockResponse));
119 EXPECT_EQ(4u, sizeof(struct LockResponse));
122120
123 EXPECT_EQ(4u, sizeof(struct CancelRequest));
121 EXPECT_EQ(4u, sizeof(struct CancelRequest));
124122
125123 EXPECT_EQ(32u, sizeof(struct ChangeNotifyRequest));
126 EXPECT_EQ(8u + sizeof(struct FileNotifyInformation), sizeof(struct ChangeNotifyResponse));
124 EXPECT_EQ(8u + sizeof(struct FileNotifyInformation), sizeof(struct ChangeNotifyResponse));
127125
128126 EXPECT_EQ(57u, sizeof(struct IoCtlRequest));
129127 EXPECT_EQ(49u, sizeof(struct IoCtlResponse));
130128
131129 EXPECT_EQ(33u, sizeof(struct SetInfoRequest));
132 EXPECT_EQ(2u, sizeof(struct SetInfoResponse));
130 EXPECT_EQ(2u, sizeof(struct SetInfoResponse));
133131 }
134132 //------------------------------------------------------------------------------
0 //------------------------------------------------------------------------------
1 // Author: Pavel Karneliuk
2 // Description: Unit tests for BlockAllocator
3 // Copyright (c) 2016 Pavel Karneliuk
4 //------------------------------------------------------------------------------
5 /*
6 This file is part of Nfstrace.
7
8 Nfstrace is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, version 2 of the License.
11
12 Nfstrace is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
19 */
20 //------------------------------------------------------------------------------
21 #include <vector>
22
23 #include <gtest/gtest.h>
24
25 #include <utils/block_allocator.h>
26 //------------------------------------------------------------------------------
27 using namespace NST::utils;
28 //------------------------------------------------------------------------------
29 //------------------------------------------------------------------------------
30 TEST(BlockAllocator, testBasicOperations)
31 {
32 BlockAllocator allocator;
33
34 using Item = char[64];
35 const std::size_t nperblocks = 1024;
36 const std::size_t lim_blocks = 1;
37
38 EXPECT_NO_THROW(
39 allocator.init_allocation(sizeof(Item), nperblocks, lim_blocks));
40
41 ASSERT_EQ(lim_blocks, allocator.max_blocks());
42 ASSERT_EQ(nperblocks, allocator.free_chunks());
43 ASSERT_EQ(nperblocks * lim_blocks, allocator.max_chunks());
44
45 std::vector<void*> allocated;
46 allocated.reserve(nperblocks + 1);
47
48 { // get all memory chunks from preallocated block
49 for(std::size_t i = 0; i < nperblocks; ++i)
50 {
51 allocated.emplace_back(allocator.allocate());
52 }
53 ASSERT_EQ(0u, allocator.free_chunks());
54 }
55
56 { // increase soft limit implicitly during allocation one new item
57 const auto old = allocator.max_blocks();
58 allocated.emplace_back(allocator.allocate());
59 ASSERT_EQ(old + 1, allocator.max_blocks());
60 ASSERT_EQ(nperblocks - 1, allocator.free_chunks());
61 }
62
63 { // get last recently deallocated during new allocation
64 const auto old = allocator.allocate();
65 allocator.deallocate(old);
66 const auto same = allocator.allocate();
67 ASSERT_EQ(old, same);
68 allocated.emplace_back(same);
69 }
70
71 for(auto& a : allocated)
72 {
73 allocator.deallocate(a);
74 }
75 }
76 //------------------------------------------------------------------------------
0 #include <gmock/gmock.h>
01 #include <gtest/gtest.h>
1 #include <gmock/gmock.h>
22 #include <utils/filtered_data.h>
33
44 TEST(FilteredData, construct)
0 Here are third party libraries with necessary components for nfstrace.
1
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
101 NFS v3 protocol
102 Total operations: 0. Per operation:
103 NULL 0 0.00%
104 GETATTR 0 0.00%
105 SETATTR 0 0.00%
106 LOOKUP 0 0.00%
107 ACCESS 0 0.00%
108 READLINK 0 0.00%
109 READ 0 0.00%
110 WRITE 0 0.00%
111 CREATE 0 0.00%
112 MKDIR 0 0.00%
113 SYMLINK 0 0.00%
114 MKNOD 0 0.00%
115 REMOVE 0 0.00%
116 RMDIR 0 0.00%
117 RENAME 0 0.00%
118 LINK 0 0.00%
119 READDIR 0 0.00%
120 READDIRPLUS 0 0.00%
121 FSSTAT 0 0.00%
122 FSINFO 0 0.00%
123 PATHCONF 0 0.00%
124 COMMIT 0 0.00%
5 NFS v3 protocol: Data transmission has not been detected.
1256 ### Breakdown analyzer ###
126 NFS v4.0 protocol
127 Total procedures: 0. Per procedure:
128 NULL 0 0.00%
129 COMPOUND 0 0.00%
130 Total operations: 0. Per operation:
131 ILLEGAL 0 0.00%
132 ACCESS 0 0.00%
133 CLOSE 0 0.00%
134 COMMIT 0 0.00%
135 CREATE 0 0.00%
136 DELEGPURGE 0 0.00%
137 DELEGRETURN 0 0.00%
138 GETATTR 0 0.00%
139 GETFH 0 0.00%
140 LINK 0 0.00%
141 LOCK 0 0.00%
142 LOCKT 0 0.00%
143 LOCKU 0 0.00%
144 LOOKUP 0 0.00%
145 LOOKUPP 0 0.00%
146 NVERIFY 0 0.00%
147 OPEN 0 0.00%
148 OPENATTR 0 0.00%
149 OPEN_CONFIRM 0 0.00%
150 OPEN_DOWNGRADE 0 0.00%
151 PUTFH 0 0.00%
152 PUTPUBFH 0 0.00%
153 PUTROOTFH 0 0.00%
154 READ 0 0.00%
155 READDIR 0 0.00%
156 READLINK 0 0.00%
157 REMOVE 0 0.00%
158 RENAME 0 0.00%
159 RENEW 0 0.00%
160 RESTOREFH 0 0.00%
161 SAVEFH 0 0.00%
162 SECINFO 0 0.00%
163 SETATTR 0 0.00%
164 SETCLIENTID 0 0.00%
165 SETCLIENTID_CONFIRM 0 0.00%
166 VERIFY 0 0.00%
167 WRITE 0 0.00%
168 RELEASE_LOCKOWNER 0 0.00%
169 GET_DIR_DELEGATION 0 0.00%
7 NFS v4.0 protocol: Data transmission has not been detected.
1708 ### Breakdown analyzer ###
171 NFS v4.1 protocol
172 Total procedures: 0. Per procedure:
173 NULL 0 0.00%
174 COMPOUND 0 0.00%
175 Total operations: 0. Per operation:
176 ILLEGAL 0 0.00%
177 ACCESS 0 0.00%
178 CLOSE 0 0.00%
179 COMMIT 0 0.00%
180 CREATE 0 0.00%
181 DELEGPURGE 0 0.00%
182 DELEGRETURN 0 0.00%
183 GETATTR 0 0.00%
184 GETFH 0 0.00%
185 LINK 0 0.00%
186 LOCK 0 0.00%
187 LOCKT 0 0.00%
188 LOCKU 0 0.00%
189 LOOKUP 0 0.00%
190 LOOKUPP 0 0.00%
191 NVERIFY 0 0.00%
192 OPEN 0 0.00%
193 OPENATTR 0 0.00%
194 OPEN_CONFIRM 0 0.00%
195 OPEN_DOWNGRADE 0 0.00%
196 PUTFH 0 0.00%
197 PUTPUBFH 0 0.00%
198 PUTROOTFH 0 0.00%
199 READ 0 0.00%
200 READDIR 0 0.00%
201 READLINK 0 0.00%
202 REMOVE 0 0.00%
203 RENAME 0 0.00%
204 RENEW 0 0.00%
205 RESTOREFH 0 0.00%
206 SAVEFH 0 0.00%
207 SECINFO 0 0.00%
208 SETATTR 0 0.00%
209 SETCLIENTID 0 0.00%
210 SETCLIENTID_CONFIRM 0 0.00%
211 VERIFY 0 0.00%
212 WRITE 0 0.00%
213 RELEASE_LOCKOWNER 0 0.00%
214 BACKCHANNEL_CTL 0 0.00%
215 BIND_CONN_TO_SESSION 0 0.00%
216 EXCHANGE_ID 0 0.00%
217 CREATE_SESSION 0 0.00%
218 DESTROY_SESSION 0 0.00%
219 FREE_STATEID 0 0.00%
220 GET_DIR_DELEGATION 0 0.00%
221 GETDEVICEINFO 0 0.00%
222 GETDEVICELIST 0 0.00%
223 LAYOUTCOMMIT 0 0.00%
224 LAYOUTGET 0 0.00%
225 LAYOUTRETURN 0 0.00%
226 SECINFO_NO_NAME 0 0.00%
227 SEQUENCE 0 0.00%
228 SET_SSV 0 0.00%
229 TEST_STATEID 0 0.00%
230 WANT_DELEGATION 0 0.00%
231 DESTROY_CLIENTID 0 0.00%
232 RECLAIM_COMPLETE 0 0.00%
9 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 413. Per operation:
220124 PATHCONF Count: 1 ( 2.17%) Min: 0.001 Max: 0.001 Avg: 0.001 StDev: 0.00000000
221125 COMMIT Count: 1 ( 2.17%) Min: 0.148 Max: 0.148 Avg: 0.148 StDev: 0.00000000
222126 ### Breakdown analyzer ###
223 NFS v4.0 protocol
224 Total procedures: 0. Per procedure:
225 NULL 0 0.00%
226 COMPOUND 0 0.00%
227 Total operations: 0. Per operation:
228 ILLEGAL 0 0.00%
229 ACCESS 0 0.00%
230 CLOSE 0 0.00%
231 COMMIT 0 0.00%
232 CREATE 0 0.00%
233 DELEGPURGE 0 0.00%
234 DELEGRETURN 0 0.00%
235 GETATTR 0 0.00%
236 GETFH 0 0.00%
237 LINK 0 0.00%
238 LOCK 0 0.00%
239 LOCKT 0 0.00%
240 LOCKU 0 0.00%
241 LOOKUP 0 0.00%
242 LOOKUPP 0 0.00%
243 NVERIFY 0 0.00%
244 OPEN 0 0.00%
245 OPENATTR 0 0.00%
246 OPEN_CONFIRM 0 0.00%
247 OPEN_DOWNGRADE 0 0.00%
248 PUTFH 0 0.00%
249 PUTPUBFH 0 0.00%
250 PUTROOTFH 0 0.00%
251 READ 0 0.00%
252 READDIR 0 0.00%
253 READLINK 0 0.00%
254 REMOVE 0 0.00%
255 RENAME 0 0.00%
256 RENEW 0 0.00%
257 RESTOREFH 0 0.00%
258 SAVEFH 0 0.00%
259 SECINFO 0 0.00%
260 SETATTR 0 0.00%
261 SETCLIENTID 0 0.00%
262 SETCLIENTID_CONFIRM 0 0.00%
263 VERIFY 0 0.00%
264 WRITE 0 0.00%
265 RELEASE_LOCKOWNER 0 0.00%
266 GET_DIR_DELEGATION 0 0.00%
127 NFS v4.0 protocol: Data transmission has not been detected.
267128 ### Breakdown analyzer ###
268 NFS v4.1 protocol
269 Total procedures: 0. Per procedure:
270 NULL 0 0.00%
271 COMPOUND 0 0.00%
272 Total operations: 0. Per operation:
273 ILLEGAL 0 0.00%
274 ACCESS 0 0.00%
275 CLOSE 0 0.00%
276 COMMIT 0 0.00%
277 CREATE 0 0.00%
278 DELEGPURGE 0 0.00%
279 DELEGRETURN 0 0.00%
280 GETATTR 0 0.00%
281 GETFH 0 0.00%
282 LINK 0 0.00%
283 LOCK 0 0.00%
284 LOCKT 0 0.00%
285 LOCKU 0 0.00%
286 LOOKUP 0 0.00%
287 LOOKUPP 0 0.00%
288 NVERIFY 0 0.00%
289 OPEN 0 0.00%
290 OPENATTR 0 0.00%
291 OPEN_CONFIRM 0 0.00%
292 OPEN_DOWNGRADE 0 0.00%
293 PUTFH 0 0.00%
294 PUTPUBFH 0 0.00%
295 PUTROOTFH 0 0.00%
296 READ 0 0.00%
297 READDIR 0 0.00%
298 READLINK 0 0.00%
299 REMOVE 0 0.00%
300 RENAME 0 0.00%
301 RENEW 0 0.00%
302 RESTOREFH 0 0.00%
303 SAVEFH 0 0.00%
304 SECINFO 0 0.00%
305 SETATTR 0 0.00%
306 SETCLIENTID 0 0.00%
307 SETCLIENTID_CONFIRM 0 0.00%
308 VERIFY 0 0.00%
309 WRITE 0 0.00%
310 RELEASE_LOCKOWNER 0 0.00%
311 BACKCHANNEL_CTL 0 0.00%
312 BIND_CONN_TO_SESSION 0 0.00%
313 EXCHANGE_ID 0 0.00%
314 CREATE_SESSION 0 0.00%
315 DESTROY_SESSION 0 0.00%
316 FREE_STATEID 0 0.00%
317 GET_DIR_DELEGATION 0 0.00%
318 GETDEVICEINFO 0 0.00%
319 GETDEVICELIST 0 0.00%
320 LAYOUTCOMMIT 0 0.00%
321 LAYOUTGET 0 0.00%
322 LAYOUTRETURN 0 0.00%
323 SECINFO_NO_NAME 0 0.00%
324 SEQUENCE 0 0.00%
325 SET_SSV 0 0.00%
326 TEST_STATEID 0 0.00%
327 WANT_DELEGATION 0 0.00%
328 DESTROY_CLIENTID 0 0.00%
329 RECLAIM_COMPLETE 0 0.00%
129 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
793 CIFS v2 protocol
804 Total operations: 30. Per operation:
12044 SET INFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
12145 OPLOCK BREAK Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
12246 ### Breakdown analyzer ###
123 NFS v3 protocol
124 Total operations: 0. Per operation:
125 NULL 0 0.00%
126 GETATTR 0 0.00%
127 SETATTR 0 0.00%
128 LOOKUP 0 0.00%
129 ACCESS 0 0.00%
130 READLINK 0 0.00%
131 READ 0 0.00%
132 WRITE 0 0.00%
133 CREATE 0 0.00%
134 MKDIR 0 0.00%
135 SYMLINK 0 0.00%
136 MKNOD 0 0.00%
137 REMOVE 0 0.00%
138 RMDIR 0 0.00%
139 RENAME 0 0.00%
140 LINK 0 0.00%
141 READDIR 0 0.00%
142 READDIRPLUS 0 0.00%
143 FSSTAT 0 0.00%
144 FSINFO 0 0.00%
145 PATHCONF 0 0.00%
146 COMMIT 0 0.00%
47 NFS v3 protocol: Data transmission has not been detected.
14748 ### Breakdown analyzer ###
148 NFS v4.0 protocol
149 Total procedures: 0. Per procedure:
150 NULL 0 0.00%
151 COMPOUND 0 0.00%
152 Total operations: 0. Per operation:
153 ILLEGAL 0 0.00%
154 ACCESS 0 0.00%
155 CLOSE 0 0.00%
156 COMMIT 0 0.00%
157 CREATE 0 0.00%
158 DELEGPURGE 0 0.00%
159 DELEGRETURN 0 0.00%
160 GETATTR 0 0.00%
161 GETFH 0 0.00%
162 LINK 0 0.00%
163 LOCK 0 0.00%
164 LOCKT 0 0.00%
165 LOCKU 0 0.00%
166 LOOKUP 0 0.00%
167 LOOKUPP 0 0.00%
168 NVERIFY 0 0.00%
169 OPEN 0 0.00%
170 OPENATTR 0 0.00%
171 OPEN_CONFIRM 0 0.00%
172 OPEN_DOWNGRADE 0 0.00%
173 PUTFH 0 0.00%
174 PUTPUBFH 0 0.00%
175 PUTROOTFH 0 0.00%
176 READ 0 0.00%
177 READDIR 0 0.00%
178 READLINK 0 0.00%
179 REMOVE 0 0.00%
180 RENAME 0 0.00%
181 RENEW 0 0.00%
182 RESTOREFH 0 0.00%
183 SAVEFH 0 0.00%
184 SECINFO 0 0.00%
185 SETATTR 0 0.00%
186 SETCLIENTID 0 0.00%
187 SETCLIENTID_CONFIRM 0 0.00%
188 VERIFY 0 0.00%
189 WRITE 0 0.00%
190 RELEASE_LOCKOWNER 0 0.00%
191 GET_DIR_DELEGATION 0 0.00%
49 NFS v4.0 protocol: Data transmission has not been detected.
19250 ### Breakdown analyzer ###
193 NFS v4.1 protocol
194 Total procedures: 0. Per procedure:
195 NULL 0 0.00%
196 COMPOUND 0 0.00%
197 Total operations: 0. Per operation:
198 ILLEGAL 0 0.00%
199 ACCESS 0 0.00%
200 CLOSE 0 0.00%
201 COMMIT 0 0.00%
202 CREATE 0 0.00%
203 DELEGPURGE 0 0.00%
204 DELEGRETURN 0 0.00%
205 GETATTR 0 0.00%
206 GETFH 0 0.00%
207 LINK 0 0.00%
208 LOCK 0 0.00%
209 LOCKT 0 0.00%
210 LOCKU 0 0.00%
211 LOOKUP 0 0.00%
212 LOOKUPP 0 0.00%
213 NVERIFY 0 0.00%
214 OPEN 0 0.00%
215 OPENATTR 0 0.00%
216 OPEN_CONFIRM 0 0.00%
217 OPEN_DOWNGRADE 0 0.00%
218 PUTFH 0 0.00%
219 PUTPUBFH 0 0.00%
220 PUTROOTFH 0 0.00%
221 READ 0 0.00%
222 READDIR 0 0.00%
223 READLINK 0 0.00%
224 REMOVE 0 0.00%
225 RENAME 0 0.00%
226 RENEW 0 0.00%
227 RESTOREFH 0 0.00%
228 SAVEFH 0 0.00%
229 SECINFO 0 0.00%
230 SETATTR 0 0.00%
231 SETCLIENTID 0 0.00%
232 SETCLIENTID_CONFIRM 0 0.00%
233 VERIFY 0 0.00%
234 WRITE 0 0.00%
235 RELEASE_LOCKOWNER 0 0.00%
236 BACKCHANNEL_CTL 0 0.00%
237 BIND_CONN_TO_SESSION 0 0.00%
238 EXCHANGE_ID 0 0.00%
239 CREATE_SESSION 0 0.00%
240 DESTROY_SESSION 0 0.00%
241 FREE_STATEID 0 0.00%
242 GET_DIR_DELEGATION 0 0.00%
243 GETDEVICEINFO 0 0.00%
244 GETDEVICELIST 0 0.00%
245 LAYOUTCOMMIT 0 0.00%
246 LAYOUTGET 0 0.00%
247 LAYOUTRETURN 0 0.00%
248 SECINFO_NO_NAME 0 0.00%
249 SEQUENCE 0 0.00%
250 SET_SSV 0 0.00%
251 TEST_STATEID 0 0.00%
252 WANT_DELEGATION 0 0.00%
253 DESTROY_CLIENTID 0 0.00%
254 RECLAIM_COMPLETE 0 0.00%
51 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 3892. Per operation:
262166 RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
263167 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
264168 ### Breakdown analyzer ###
265 NFS v4.1 protocol
266 Total procedures: 0. Per procedure:
267 NULL 0 0.00%
268 COMPOUND 0 0.00%
269 Total operations: 0. Per operation:
270 ILLEGAL 0 0.00%
271 ACCESS 0 0.00%
272 CLOSE 0 0.00%
273 COMMIT 0 0.00%
274 CREATE 0 0.00%
275 DELEGPURGE 0 0.00%
276 DELEGRETURN 0 0.00%
277 GETATTR 0 0.00%
278 GETFH 0 0.00%
279 LINK 0 0.00%
280 LOCK 0 0.00%
281 LOCKT 0 0.00%
282 LOCKU 0 0.00%
283 LOOKUP 0 0.00%
284 LOOKUPP 0 0.00%
285 NVERIFY 0 0.00%
286 OPEN 0 0.00%
287 OPENATTR 0 0.00%
288 OPEN_CONFIRM 0 0.00%
289 OPEN_DOWNGRADE 0 0.00%
290 PUTFH 0 0.00%
291 PUTPUBFH 0 0.00%
292 PUTROOTFH 0 0.00%
293 READ 0 0.00%
294 READDIR 0 0.00%
295 READLINK 0 0.00%
296 REMOVE 0 0.00%
297 RENAME 0 0.00%
298 RENEW 0 0.00%
299 RESTOREFH 0 0.00%
300 SAVEFH 0 0.00%
301 SECINFO 0 0.00%
302 SETATTR 0 0.00%
303 SETCLIENTID 0 0.00%
304 SETCLIENTID_CONFIRM 0 0.00%
305 VERIFY 0 0.00%
306 WRITE 0 0.00%
307 RELEASE_LOCKOWNER 0 0.00%
308 BACKCHANNEL_CTL 0 0.00%
309 BIND_CONN_TO_SESSION 0 0.00%
310 EXCHANGE_ID 0 0.00%
311 CREATE_SESSION 0 0.00%
312 DESTROY_SESSION 0 0.00%
313 FREE_STATEID 0 0.00%
314 GET_DIR_DELEGATION 0 0.00%
315 GETDEVICEINFO 0 0.00%
316 GETDEVICELIST 0 0.00%
317 LAYOUTCOMMIT 0 0.00%
318 LAYOUTGET 0 0.00%
319 LAYOUTRETURN 0 0.00%
320 SECINFO_NO_NAME 0 0.00%
321 SEQUENCE 0 0.00%
322 SET_SSV 0 0.00%
323 TEST_STATEID 0 0.00%
324 WANT_DELEGATION 0 0.00%
325 DESTROY_CLIENTID 0 0.00%
326 RECLAIM_COMPLETE 0 0.00%
169 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 3331. Per operation:
14852 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
14953 COMMIT Count: 10 ( 0.30%) Min: 0.001 Max: 0.001 Avg: 0.001 StDev: 0.00019761
15054 ### Breakdown analyzer ###
151 NFS v4.0 protocol
152 Total procedures: 0. Per procedure:
153 NULL 0 0.00%
154 COMPOUND 0 0.00%
155 Total operations: 0. Per operation:
156 ILLEGAL 0 0.00%
157 ACCESS 0 0.00%
158 CLOSE 0 0.00%
159 COMMIT 0 0.00%
160 CREATE 0 0.00%
161 DELEGPURGE 0 0.00%
162 DELEGRETURN 0 0.00%
163 GETATTR 0 0.00%
164 GETFH 0 0.00%
165 LINK 0 0.00%
166 LOCK 0 0.00%
167 LOCKT 0 0.00%
168 LOCKU 0 0.00%
169 LOOKUP 0 0.00%
170 LOOKUPP 0 0.00%
171 NVERIFY 0 0.00%
172 OPEN 0 0.00%
173 OPENATTR 0 0.00%
174 OPEN_CONFIRM 0 0.00%
175 OPEN_DOWNGRADE 0 0.00%
176 PUTFH 0 0.00%
177 PUTPUBFH 0 0.00%
178 PUTROOTFH 0 0.00%
179 READ 0 0.00%
180 READDIR 0 0.00%
181 READLINK 0 0.00%
182 REMOVE 0 0.00%
183 RENAME 0 0.00%
184 RENEW 0 0.00%
185 RESTOREFH 0 0.00%
186 SAVEFH 0 0.00%
187 SECINFO 0 0.00%
188 SETATTR 0 0.00%
189 SETCLIENTID 0 0.00%
190 SETCLIENTID_CONFIRM 0 0.00%
191 VERIFY 0 0.00%
192 WRITE 0 0.00%
193 RELEASE_LOCKOWNER 0 0.00%
194 GET_DIR_DELEGATION 0 0.00%
55 NFS v4.0 protocol: Data transmission has not been detected.
19556 ### Breakdown analyzer ###
196 NFS v4.1 protocol
197 Total procedures: 0. Per procedure:
198 NULL 0 0.00%
199 COMPOUND 0 0.00%
200 Total operations: 0. Per operation:
201 ILLEGAL 0 0.00%
202 ACCESS 0 0.00%
203 CLOSE 0 0.00%
204 COMMIT 0 0.00%
205 CREATE 0 0.00%
206 DELEGPURGE 0 0.00%
207 DELEGRETURN 0 0.00%
208 GETATTR 0 0.00%
209 GETFH 0 0.00%
210 LINK 0 0.00%
211 LOCK 0 0.00%
212 LOCKT 0 0.00%
213 LOCKU 0 0.00%
214 LOOKUP 0 0.00%
215 LOOKUPP 0 0.00%
216 NVERIFY 0 0.00%
217 OPEN 0 0.00%
218 OPENATTR 0 0.00%
219 OPEN_CONFIRM 0 0.00%
220 OPEN_DOWNGRADE 0 0.00%
221 PUTFH 0 0.00%
222 PUTPUBFH 0 0.00%
223 PUTROOTFH 0 0.00%
224 READ 0 0.00%
225 READDIR 0 0.00%
226 READLINK 0 0.00%
227 REMOVE 0 0.00%
228 RENAME 0 0.00%
229 RENEW 0 0.00%
230 RESTOREFH 0 0.00%
231 SAVEFH 0 0.00%
232 SECINFO 0 0.00%
233 SETATTR 0 0.00%
234 SETCLIENTID 0 0.00%
235 SETCLIENTID_CONFIRM 0 0.00%
236 VERIFY 0 0.00%
237 WRITE 0 0.00%
238 RELEASE_LOCKOWNER 0 0.00%
239 BACKCHANNEL_CTL 0 0.00%
240 BIND_CONN_TO_SESSION 0 0.00%
241 EXCHANGE_ID 0 0.00%
242 CREATE_SESSION 0 0.00%
243 DESTROY_SESSION 0 0.00%
244 FREE_STATEID 0 0.00%
245 GET_DIR_DELEGATION 0 0.00%
246 GETDEVICEINFO 0 0.00%
247 GETDEVICELIST 0 0.00%
248 LAYOUTCOMMIT 0 0.00%
249 LAYOUTGET 0 0.00%
250 LAYOUTRETURN 0 0.00%
251 SECINFO_NO_NAME 0 0.00%
252 SEQUENCE 0 0.00%
253 SET_SSV 0 0.00%
254 TEST_STATEID 0 0.00%
255 WANT_DELEGATION 0 0.00%
256 DESTROY_CLIENTID 0 0.00%
257 RECLAIM_COMPLETE 0 0.00%
57 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
101 NFS v3 protocol
102 Total operations: 0. Per operation:
103 NULL 0 0.00%
104 GETATTR 0 0.00%
105 SETATTR 0 0.00%
106 LOOKUP 0 0.00%
107 ACCESS 0 0.00%
108 READLINK 0 0.00%
109 READ 0 0.00%
110 WRITE 0 0.00%
111 CREATE 0 0.00%
112 MKDIR 0 0.00%
113 SYMLINK 0 0.00%
114 MKNOD 0 0.00%
115 REMOVE 0 0.00%
116 RMDIR 0 0.00%
117 RENAME 0 0.00%
118 LINK 0 0.00%
119 READDIR 0 0.00%
120 READDIRPLUS 0 0.00%
121 FSSTAT 0 0.00%
122 FSINFO 0 0.00%
123 PATHCONF 0 0.00%
124 COMMIT 0 0.00%
5 NFS v3 protocol: Data transmission has not been detected.
1256 ### Breakdown analyzer ###
1267 NFS v4.0 protocol
1278 Total procedures: 3. Per procedure:
21394 RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
21495 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
21596 ### Breakdown analyzer ###
216 NFS v4.1 protocol
217 Total procedures: 0. Per procedure:
218 NULL 0 0.00%
219 COMPOUND 0 0.00%
220 Total operations: 0. Per operation:
221 ILLEGAL 0 0.00%
222 ACCESS 0 0.00%
223 CLOSE 0 0.00%
224 COMMIT 0 0.00%
225 CREATE 0 0.00%
226 DELEGPURGE 0 0.00%
227 DELEGRETURN 0 0.00%
228 GETATTR 0 0.00%
229 GETFH 0 0.00%
230 LINK 0 0.00%
231 LOCK 0 0.00%
232 LOCKT 0 0.00%
233 LOCKU 0 0.00%
234 LOOKUP 0 0.00%
235 LOOKUPP 0 0.00%
236 NVERIFY 0 0.00%
237 OPEN 0 0.00%
238 OPENATTR 0 0.00%
239 OPEN_CONFIRM 0 0.00%
240 OPEN_DOWNGRADE 0 0.00%
241 PUTFH 0 0.00%
242 PUTPUBFH 0 0.00%
243 PUTROOTFH 0 0.00%
244 READ 0 0.00%
245 READDIR 0 0.00%
246 READLINK 0 0.00%
247 REMOVE 0 0.00%
248 RENAME 0 0.00%
249 RENEW 0 0.00%
250 RESTOREFH 0 0.00%
251 SAVEFH 0 0.00%
252 SECINFO 0 0.00%
253 SETATTR 0 0.00%
254 SETCLIENTID 0 0.00%
255 SETCLIENTID_CONFIRM 0 0.00%
256 VERIFY 0 0.00%
257 WRITE 0 0.00%
258 RELEASE_LOCKOWNER 0 0.00%
259 BACKCHANNEL_CTL 0 0.00%
260 BIND_CONN_TO_SESSION 0 0.00%
261 EXCHANGE_ID 0 0.00%
262 CREATE_SESSION 0 0.00%
263 DESTROY_SESSION 0 0.00%
264 FREE_STATEID 0 0.00%
265 GET_DIR_DELEGATION 0 0.00%
266 GETDEVICEINFO 0 0.00%
267 GETDEVICELIST 0 0.00%
268 LAYOUTCOMMIT 0 0.00%
269 LAYOUTGET 0 0.00%
270 LAYOUTRETURN 0 0.00%
271 SECINFO_NO_NAME 0 0.00%
272 SEQUENCE 0 0.00%
273 SET_SSV 0 0.00%
274 TEST_STATEID 0 0.00%
275 WANT_DELEGATION 0 0.00%
276 DESTROY_CLIENTID 0 0.00%
277 RECLAIM_COMPLETE 0 0.00%
97 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
101 NFS v3 protocol
102 Total operations: 0. Per operation:
103 NULL 0 0.00%
104 GETATTR 0 0.00%
105 SETATTR 0 0.00%
106 LOOKUP 0 0.00%
107 ACCESS 0 0.00%
108 READLINK 0 0.00%
109 READ 0 0.00%
110 WRITE 0 0.00%
111 CREATE 0 0.00%
112 MKDIR 0 0.00%
113 SYMLINK 0 0.00%
114 MKNOD 0 0.00%
115 REMOVE 0 0.00%
116 RMDIR 0 0.00%
117 RENAME 0 0.00%
118 LINK 0 0.00%
119 READDIR 0 0.00%
120 READDIRPLUS 0 0.00%
121 FSSTAT 0 0.00%
122 FSINFO 0 0.00%
123 PATHCONF 0 0.00%
124 COMMIT 0 0.00%
5 NFS v3 protocol: Data transmission has not been detected.
1256 ### Breakdown analyzer ###
1267 NFS v4.0 protocol
1278 Total procedures: 100671. Per procedure:
521402 RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
522403 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
523404 ### Breakdown analyzer ###
524 NFS v4.1 protocol
525 Total procedures: 0. Per procedure:
526 NULL 0 0.00%
527 COMPOUND 0 0.00%
528 Total operations: 0. Per operation:
529 ILLEGAL 0 0.00%
530 ACCESS 0 0.00%
531 CLOSE 0 0.00%
532 COMMIT 0 0.00%
533 CREATE 0 0.00%
534 DELEGPURGE 0 0.00%
535 DELEGRETURN 0 0.00%
536 GETATTR 0 0.00%
537 GETFH 0 0.00%
538 LINK 0 0.00%
539 LOCK 0 0.00%
540 LOCKT 0 0.00%
541 LOCKU 0 0.00%
542 LOOKUP 0 0.00%
543 LOOKUPP 0 0.00%
544 NVERIFY 0 0.00%
545 OPEN 0 0.00%
546 OPENATTR 0 0.00%
547 OPEN_CONFIRM 0 0.00%
548 OPEN_DOWNGRADE 0 0.00%
549 PUTFH 0 0.00%
550 PUTPUBFH 0 0.00%
551 PUTROOTFH 0 0.00%
552 READ 0 0.00%
553 READDIR 0 0.00%
554 READLINK 0 0.00%
555 REMOVE 0 0.00%
556 RENAME 0 0.00%
557 RENEW 0 0.00%
558 RESTOREFH 0 0.00%
559 SAVEFH 0 0.00%
560 SECINFO 0 0.00%
561 SETATTR 0 0.00%
562 SETCLIENTID 0 0.00%
563 SETCLIENTID_CONFIRM 0 0.00%
564 VERIFY 0 0.00%
565 WRITE 0 0.00%
566 RELEASE_LOCKOWNER 0 0.00%
567 BACKCHANNEL_CTL 0 0.00%
568 BIND_CONN_TO_SESSION 0 0.00%
569 EXCHANGE_ID 0 0.00%
570 CREATE_SESSION 0 0.00%
571 DESTROY_SESSION 0 0.00%
572 FREE_STATEID 0 0.00%
573 GET_DIR_DELEGATION 0 0.00%
574 GETDEVICEINFO 0 0.00%
575 GETDEVICELIST 0 0.00%
576 LAYOUTCOMMIT 0 0.00%
577 LAYOUTGET 0 0.00%
578 LAYOUTRETURN 0 0.00%
579 SECINFO_NO_NAME 0 0.00%
580 SEQUENCE 0 0.00%
581 SET_SSV 0 0.00%
582 TEST_STATEID 0 0.00%
583 WANT_DELEGATION 0 0.00%
584 DESTROY_CLIENTID 0 0.00%
585 RECLAIM_COMPLETE 0 0.00%
405 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
101 NFS v3 protocol
102 Total operations: 0. Per operation:
103 NULL 0 0.00%
104 GETATTR 0 0.00%
105 SETATTR 0 0.00%
106 LOOKUP 0 0.00%
107 ACCESS 0 0.00%
108 READLINK 0 0.00%
109 READ 0 0.00%
110 WRITE 0 0.00%
111 CREATE 0 0.00%
112 MKDIR 0 0.00%
113 SYMLINK 0 0.00%
114 MKNOD 0 0.00%
115 REMOVE 0 0.00%
116 RMDIR 0 0.00%
117 RENAME 0 0.00%
118 LINK 0 0.00%
119 READDIR 0 0.00%
120 READDIRPLUS 0 0.00%
121 FSSTAT 0 0.00%
122 FSINFO 0 0.00%
123 PATHCONF 0 0.00%
124 COMMIT 0 0.00%
5 NFS v3 protocol: Data transmission has not been detected.
1256 ### Breakdown analyzer ###
1267 NFS v4.0 protocol
1278 Total procedures: 1607. Per procedure:
21394 RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
21495 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
21596 ### Breakdown analyzer ###
216 NFS v4.1 protocol
217 Total procedures: 0. Per procedure:
218 NULL 0 0.00%
219 COMPOUND 0 0.00%
220 Total operations: 0. Per operation:
221 ILLEGAL 0 0.00%
222 ACCESS 0 0.00%
223 CLOSE 0 0.00%
224 COMMIT 0 0.00%
225 CREATE 0 0.00%
226 DELEGPURGE 0 0.00%
227 DELEGRETURN 0 0.00%
228 GETATTR 0 0.00%
229 GETFH 0 0.00%
230 LINK 0 0.00%
231 LOCK 0 0.00%
232 LOCKT 0 0.00%
233 LOCKU 0 0.00%
234 LOOKUP 0 0.00%
235 LOOKUPP 0 0.00%
236 NVERIFY 0 0.00%
237 OPEN 0 0.00%
238 OPENATTR 0 0.00%
239 OPEN_CONFIRM 0 0.00%
240 OPEN_DOWNGRADE 0 0.00%
241 PUTFH 0 0.00%
242 PUTPUBFH 0 0.00%
243 PUTROOTFH 0 0.00%
244 READ 0 0.00%
245 READDIR 0 0.00%
246 READLINK 0 0.00%
247 REMOVE 0 0.00%
248 RENAME 0 0.00%
249 RENEW 0 0.00%
250 RESTOREFH 0 0.00%
251 SAVEFH 0 0.00%
252 SECINFO 0 0.00%
253 SETATTR 0 0.00%
254 SETCLIENTID 0 0.00%
255 SETCLIENTID_CONFIRM 0 0.00%
256 VERIFY 0 0.00%
257 WRITE 0 0.00%
258 RELEASE_LOCKOWNER 0 0.00%
259 BACKCHANNEL_CTL 0 0.00%
260 BIND_CONN_TO_SESSION 0 0.00%
261 EXCHANGE_ID 0 0.00%
262 CREATE_SESSION 0 0.00%
263 DESTROY_SESSION 0 0.00%
264 FREE_STATEID 0 0.00%
265 GET_DIR_DELEGATION 0 0.00%
266 GETDEVICEINFO 0 0.00%
267 GETDEVICELIST 0 0.00%
268 LAYOUTCOMMIT 0 0.00%
269 LAYOUTGET 0 0.00%
270 LAYOUTRETURN 0 0.00%
271 SECINFO_NO_NAME 0 0.00%
272 SEQUENCE 0 0.00%
273 SET_SSV 0 0.00%
274 TEST_STATEID 0 0.00%
275 WANT_DELEGATION 0 0.00%
276 DESTROY_CLIENTID 0 0.00%
277 RECLAIM_COMPLETE 0 0.00%
97 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
78 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
100 ### Breakdown analyzer ###
101 NFS v3 protocol
102 Total operations: 0. Per operation:
103 NULL 0 0.00%
104 GETATTR 0 0.00%
105 SETATTR 0 0.00%
106 LOOKUP 0 0.00%
107 ACCESS 0 0.00%
108 READLINK 0 0.00%
109 READ 0 0.00%
110 WRITE 0 0.00%
111 CREATE 0 0.00%
112 MKDIR 0 0.00%
113 SYMLINK 0 0.00%
114 MKNOD 0 0.00%
115 REMOVE 0 0.00%
116 RMDIR 0 0.00%
117 RENAME 0 0.00%
118 LINK 0 0.00%
119 READDIR 0 0.00%
120 READDIRPLUS 0 0.00%
121 FSSTAT 0 0.00%
122 FSINFO 0 0.00%
123 PATHCONF 0 0.00%
124 COMMIT 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
2 ### Breakdown analyzer ###
3 CIFS v2 protocol: Data transmission has not been detected.
4 ### Breakdown analyzer ###
5 NFS v3 protocol: Data transmission has not been detected.
1256 ### Breakdown analyzer ###
1267 NFS v4.0 protocol
1278 Total procedures: 1. Per procedure:
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
793 CIFS v2 protocol
804 Total operations: 35. Per operation:
12044 SET INFO Count: 2 ( 5.71%) Min: 0.000 Max: 0.001 Avg: 0.001 StDev: 0.00039244
12145 OPLOCK BREAK Count: 1 ( 2.86%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
12246 ### Breakdown analyzer ###
123 NFS v3 protocol
124 Total operations: 0. Per operation:
125 NULL 0 0.00%
126 GETATTR 0 0.00%
127 SETATTR 0 0.00%
128 LOOKUP 0 0.00%
129 ACCESS 0 0.00%
130 READLINK 0 0.00%
131 READ 0 0.00%
132 WRITE 0 0.00%
133 CREATE 0 0.00%
134 MKDIR 0 0.00%
135 SYMLINK 0 0.00%
136 MKNOD 0 0.00%
137 REMOVE 0 0.00%
138 RMDIR 0 0.00%
139 RENAME 0 0.00%
140 LINK 0 0.00%
141 READDIR 0 0.00%
142 READDIRPLUS 0 0.00%
143 FSSTAT 0 0.00%
144 FSINFO 0 0.00%
145 PATHCONF 0 0.00%
146 COMMIT 0 0.00%
47 NFS v3 protocol: Data transmission has not been detected.
14748 ### Breakdown analyzer ###
148 NFS v4.0 protocol
149 Total procedures: 0. Per procedure:
150 NULL 0 0.00%
151 COMPOUND 0 0.00%
152 Total operations: 0. Per operation:
153 ILLEGAL 0 0.00%
154 ACCESS 0 0.00%
155 CLOSE 0 0.00%
156 COMMIT 0 0.00%
157 CREATE 0 0.00%
158 DELEGPURGE 0 0.00%
159 DELEGRETURN 0 0.00%
160 GETATTR 0 0.00%
161 GETFH 0 0.00%
162 LINK 0 0.00%
163 LOCK 0 0.00%
164 LOCKT 0 0.00%
165 LOCKU 0 0.00%
166 LOOKUP 0 0.00%
167 LOOKUPP 0 0.00%
168 NVERIFY 0 0.00%
169 OPEN 0 0.00%
170 OPENATTR 0 0.00%
171 OPEN_CONFIRM 0 0.00%
172 OPEN_DOWNGRADE 0 0.00%
173 PUTFH 0 0.00%
174 PUTPUBFH 0 0.00%
175 PUTROOTFH 0 0.00%
176 READ 0 0.00%
177 READDIR 0 0.00%
178 READLINK 0 0.00%
179 REMOVE 0 0.00%
180 RENAME 0 0.00%
181 RENEW 0 0.00%
182 RESTOREFH 0 0.00%
183 SAVEFH 0 0.00%
184 SECINFO 0 0.00%
185 SETATTR 0 0.00%
186 SETCLIENTID 0 0.00%
187 SETCLIENTID_CONFIRM 0 0.00%
188 VERIFY 0 0.00%
189 WRITE 0 0.00%
190 RELEASE_LOCKOWNER 0 0.00%
191 GET_DIR_DELEGATION 0 0.00%
49 NFS v4.0 protocol: Data transmission has not been detected.
19250 ### Breakdown analyzer ###
193 NFS v4.1 protocol
194 Total procedures: 0. Per procedure:
195 NULL 0 0.00%
196 COMPOUND 0 0.00%
197 Total operations: 0. Per operation:
198 ILLEGAL 0 0.00%
199 ACCESS 0 0.00%
200 CLOSE 0 0.00%
201 COMMIT 0 0.00%
202 CREATE 0 0.00%
203 DELEGPURGE 0 0.00%
204 DELEGRETURN 0 0.00%
205 GETATTR 0 0.00%
206 GETFH 0 0.00%
207 LINK 0 0.00%
208 LOCK 0 0.00%
209 LOCKT 0 0.00%
210 LOCKU 0 0.00%
211 LOOKUP 0 0.00%
212 LOOKUPP 0 0.00%
213 NVERIFY 0 0.00%
214 OPEN 0 0.00%
215 OPENATTR 0 0.00%
216 OPEN_CONFIRM 0 0.00%
217 OPEN_DOWNGRADE 0 0.00%
218 PUTFH 0 0.00%
219 PUTPUBFH 0 0.00%
220 PUTROOTFH 0 0.00%
221 READ 0 0.00%
222 READDIR 0 0.00%
223 READLINK 0 0.00%
224 REMOVE 0 0.00%
225 RENAME 0 0.00%
226 RENEW 0 0.00%
227 RESTOREFH 0 0.00%
228 SAVEFH 0 0.00%
229 SECINFO 0 0.00%
230 SETATTR 0 0.00%
231 SETCLIENTID 0 0.00%
232 SETCLIENTID_CONFIRM 0 0.00%
233 VERIFY 0 0.00%
234 WRITE 0 0.00%
235 RELEASE_LOCKOWNER 0 0.00%
236 BACKCHANNEL_CTL 0 0.00%
237 BIND_CONN_TO_SESSION 0 0.00%
238 EXCHANGE_ID 0 0.00%
239 CREATE_SESSION 0 0.00%
240 DESTROY_SESSION 0 0.00%
241 FREE_STATEID 0 0.00%
242 GET_DIR_DELEGATION 0 0.00%
243 GETDEVICEINFO 0 0.00%
244 GETDEVICELIST 0 0.00%
245 LAYOUTCOMMIT 0 0.00%
246 LAYOUTGET 0 0.00%
247 LAYOUTRETURN 0 0.00%
248 SECINFO_NO_NAME 0 0.00%
249 SEQUENCE 0 0.00%
250 SET_SSV 0 0.00%
251 TEST_STATEID 0 0.00%
252 WANT_DELEGATION 0 0.00%
253 DESTROY_CLIENTID 0 0.00%
254 RECLAIM_COMPLETE 0 0.00%
51 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
793 CIFS v2 protocol
804 Total operations: 928. Per operation:
12044 SET INFO Count: 6 ( 0.65%) Min: 0.000 Max: 0.001 Avg: 0.000 StDev: 0.00009635
12145 OPLOCK BREAK Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
12246 ### Breakdown analyzer ###
123 NFS v3 protocol
124 Total operations: 0. Per operation:
125 NULL 0 0.00%
126 GETATTR 0 0.00%
127 SETATTR 0 0.00%
128 LOOKUP 0 0.00%
129 ACCESS 0 0.00%
130 READLINK 0 0.00%
131 READ 0 0.00%
132 WRITE 0 0.00%
133 CREATE 0 0.00%
134 MKDIR 0 0.00%
135 SYMLINK 0 0.00%
136 MKNOD 0 0.00%
137 REMOVE 0 0.00%
138 RMDIR 0 0.00%
139 RENAME 0 0.00%
140 LINK 0 0.00%
141 READDIR 0 0.00%
142 READDIRPLUS 0 0.00%
143 FSSTAT 0 0.00%
144 FSINFO 0 0.00%
145 PATHCONF 0 0.00%
146 COMMIT 0 0.00%
47 NFS v3 protocol: Data transmission has not been detected.
14748 ### Breakdown analyzer ###
148 NFS v4.0 protocol
149 Total procedures: 0. Per procedure:
150 NULL 0 0.00%
151 COMPOUND 0 0.00%
152 Total operations: 0. Per operation:
153 ILLEGAL 0 0.00%
154 ACCESS 0 0.00%
155 CLOSE 0 0.00%
156 COMMIT 0 0.00%
157 CREATE 0 0.00%
158 DELEGPURGE 0 0.00%
159 DELEGRETURN 0 0.00%
160 GETATTR 0 0.00%
161 GETFH 0 0.00%
162 LINK 0 0.00%
163 LOCK 0 0.00%
164 LOCKT 0 0.00%
165 LOCKU 0 0.00%
166 LOOKUP 0 0.00%
167 LOOKUPP 0 0.00%
168 NVERIFY 0 0.00%
169 OPEN 0 0.00%
170 OPENATTR 0 0.00%
171 OPEN_CONFIRM 0 0.00%
172 OPEN_DOWNGRADE 0 0.00%
173 PUTFH 0 0.00%
174 PUTPUBFH 0 0.00%
175 PUTROOTFH 0 0.00%
176 READ 0 0.00%
177 READDIR 0 0.00%
178 READLINK 0 0.00%
179 REMOVE 0 0.00%
180 RENAME 0 0.00%
181 RENEW 0 0.00%
182 RESTOREFH 0 0.00%
183 SAVEFH 0 0.00%
184 SECINFO 0 0.00%
185 SETATTR 0 0.00%
186 SETCLIENTID 0 0.00%
187 SETCLIENTID_CONFIRM 0 0.00%
188 VERIFY 0 0.00%
189 WRITE 0 0.00%
190 RELEASE_LOCKOWNER 0 0.00%
191 GET_DIR_DELEGATION 0 0.00%
49 NFS v4.0 protocol: Data transmission has not been detected.
19250 ### Breakdown analyzer ###
193 NFS v4.1 protocol
194 Total procedures: 0. Per procedure:
195 NULL 0 0.00%
196 COMPOUND 0 0.00%
197 Total operations: 0. Per operation:
198 ILLEGAL 0 0.00%
199 ACCESS 0 0.00%
200 CLOSE 0 0.00%
201 COMMIT 0 0.00%
202 CREATE 0 0.00%
203 DELEGPURGE 0 0.00%
204 DELEGRETURN 0 0.00%
205 GETATTR 0 0.00%
206 GETFH 0 0.00%
207 LINK 0 0.00%
208 LOCK 0 0.00%
209 LOCKT 0 0.00%
210 LOCKU 0 0.00%
211 LOOKUP 0 0.00%
212 LOOKUPP 0 0.00%
213 NVERIFY 0 0.00%
214 OPEN 0 0.00%
215 OPENATTR 0 0.00%
216 OPEN_CONFIRM 0 0.00%
217 OPEN_DOWNGRADE 0 0.00%
218 PUTFH 0 0.00%
219 PUTPUBFH 0 0.00%
220 PUTROOTFH 0 0.00%
221 READ 0 0.00%
222 READDIR 0 0.00%
223 READLINK 0 0.00%
224 REMOVE 0 0.00%
225 RENAME 0 0.00%
226 RENEW 0 0.00%
227 RESTOREFH 0 0.00%
228 SAVEFH 0 0.00%
229 SECINFO 0 0.00%
230 SETATTR 0 0.00%
231 SETCLIENTID 0 0.00%
232 SETCLIENTID_CONFIRM 0 0.00%
233 VERIFY 0 0.00%
234 WRITE 0 0.00%
235 RELEASE_LOCKOWNER 0 0.00%
236 BACKCHANNEL_CTL 0 0.00%
237 BIND_CONN_TO_SESSION 0 0.00%
238 EXCHANGE_ID 0 0.00%
239 CREATE_SESSION 0 0.00%
240 DESTROY_SESSION 0 0.00%
241 FREE_STATEID 0 0.00%
242 GET_DIR_DELEGATION 0 0.00%
243 GETDEVICEINFO 0 0.00%
244 GETDEVICELIST 0 0.00%
245 LAYOUTCOMMIT 0 0.00%
246 LAYOUTGET 0 0.00%
247 LAYOUTRETURN 0 0.00%
248 SECINFO_NO_NAME 0 0.00%
249 SEQUENCE 0 0.00%
250 SET_SSV 0 0.00%
251 TEST_STATEID 0 0.00%
252 WANT_DELEGATION 0 0.00%
253 DESTROY_CLIENTID 0 0.00%
254 RECLAIM_COMPLETE 0 0.00%
51 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 11. Per operation:
14852 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
14953 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
15054 ### Breakdown analyzer ###
151 NFS v4.0 protocol
152 Total procedures: 0. Per procedure:
153 NULL 0 0.00%
154 COMPOUND 0 0.00%
155 Total operations: 0. Per operation:
156 ILLEGAL 0 0.00%
157 ACCESS 0 0.00%
158 CLOSE 0 0.00%
159 COMMIT 0 0.00%
160 CREATE 0 0.00%
161 DELEGPURGE 0 0.00%
162 DELEGRETURN 0 0.00%
163 GETATTR 0 0.00%
164 GETFH 0 0.00%
165 LINK 0 0.00%
166 LOCK 0 0.00%
167 LOCKT 0 0.00%
168 LOCKU 0 0.00%
169 LOOKUP 0 0.00%
170 LOOKUPP 0 0.00%
171 NVERIFY 0 0.00%
172 OPEN 0 0.00%
173 OPENATTR 0 0.00%
174 OPEN_CONFIRM 0 0.00%
175 OPEN_DOWNGRADE 0 0.00%
176 PUTFH 0 0.00%
177 PUTPUBFH 0 0.00%
178 PUTROOTFH 0 0.00%
179 READ 0 0.00%
180 READDIR 0 0.00%
181 READLINK 0 0.00%
182 REMOVE 0 0.00%
183 RENAME 0 0.00%
184 RENEW 0 0.00%
185 RESTOREFH 0 0.00%
186 SAVEFH 0 0.00%
187 SECINFO 0 0.00%
188 SETATTR 0 0.00%
189 SETCLIENTID 0 0.00%
190 SETCLIENTID_CONFIRM 0 0.00%
191 VERIFY 0 0.00%
192 WRITE 0 0.00%
193 RELEASE_LOCKOWNER 0 0.00%
194 GET_DIR_DELEGATION 0 0.00%
55 NFS v4.0 protocol: Data transmission has not been detected.
19556 ### Breakdown analyzer ###
196 NFS v4.1 protocol
197 Total procedures: 0. Per procedure:
198 NULL 0 0.00%
199 COMPOUND 0 0.00%
200 Total operations: 0. Per operation:
201 ILLEGAL 0 0.00%
202 ACCESS 0 0.00%
203 CLOSE 0 0.00%
204 COMMIT 0 0.00%
205 CREATE 0 0.00%
206 DELEGPURGE 0 0.00%
207 DELEGRETURN 0 0.00%
208 GETATTR 0 0.00%
209 GETFH 0 0.00%
210 LINK 0 0.00%
211 LOCK 0 0.00%
212 LOCKT 0 0.00%
213 LOCKU 0 0.00%
214 LOOKUP 0 0.00%
215 LOOKUPP 0 0.00%
216 NVERIFY 0 0.00%
217 OPEN 0 0.00%
218 OPENATTR 0 0.00%
219 OPEN_CONFIRM 0 0.00%
220 OPEN_DOWNGRADE 0 0.00%
221 PUTFH 0 0.00%
222 PUTPUBFH 0 0.00%
223 PUTROOTFH 0 0.00%
224 READ 0 0.00%
225 READDIR 0 0.00%
226 READLINK 0 0.00%
227 REMOVE 0 0.00%
228 RENAME 0 0.00%
229 RENEW 0 0.00%
230 RESTOREFH 0 0.00%
231 SAVEFH 0 0.00%
232 SECINFO 0 0.00%
233 SETATTR 0 0.00%
234 SETCLIENTID 0 0.00%
235 SETCLIENTID_CONFIRM 0 0.00%
236 VERIFY 0 0.00%
237 WRITE 0 0.00%
238 RELEASE_LOCKOWNER 0 0.00%
239 BACKCHANNEL_CTL 0 0.00%
240 BIND_CONN_TO_SESSION 0 0.00%
241 EXCHANGE_ID 0 0.00%
242 CREATE_SESSION 0 0.00%
243 DESTROY_SESSION 0 0.00%
244 FREE_STATEID 0 0.00%
245 GET_DIR_DELEGATION 0 0.00%
246 GETDEVICEINFO 0 0.00%
247 GETDEVICELIST 0 0.00%
248 LAYOUTCOMMIT 0 0.00%
249 LAYOUTGET 0 0.00%
250 LAYOUTRETURN 0 0.00%
251 SECINFO_NO_NAME 0 0.00%
252 SEQUENCE 0 0.00%
253 SET_SSV 0 0.00%
254 TEST_STATEID 0 0.00%
255 WANT_DELEGATION 0 0.00%
256 DESTROY_CLIENTID 0 0.00%
257 RECLAIM_COMPLETE 0 0.00%
57 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 57. Per operation:
17276 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17377 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17478 ### Breakdown analyzer ###
175 NFS v4.0 protocol
176 Total procedures: 0. Per procedure:
177 NULL 0 0.00%
178 COMPOUND 0 0.00%
179 Total operations: 0. Per operation:
180 ILLEGAL 0 0.00%
181 ACCESS 0 0.00%
182 CLOSE 0 0.00%
183 COMMIT 0 0.00%
184 CREATE 0 0.00%
185 DELEGPURGE 0 0.00%
186 DELEGRETURN 0 0.00%
187 GETATTR 0 0.00%
188 GETFH 0 0.00%
189 LINK 0 0.00%
190 LOCK 0 0.00%
191 LOCKT 0 0.00%
192 LOCKU 0 0.00%
193 LOOKUP 0 0.00%
194 LOOKUPP 0 0.00%
195 NVERIFY 0 0.00%
196 OPEN 0 0.00%
197 OPENATTR 0 0.00%
198 OPEN_CONFIRM 0 0.00%
199 OPEN_DOWNGRADE 0 0.00%
200 PUTFH 0 0.00%
201 PUTPUBFH 0 0.00%
202 PUTROOTFH 0 0.00%
203 READ 0 0.00%
204 READDIR 0 0.00%
205 READLINK 0 0.00%
206 REMOVE 0 0.00%
207 RENAME 0 0.00%
208 RENEW 0 0.00%
209 RESTOREFH 0 0.00%
210 SAVEFH 0 0.00%
211 SECINFO 0 0.00%
212 SETATTR 0 0.00%
213 SETCLIENTID 0 0.00%
214 SETCLIENTID_CONFIRM 0 0.00%
215 VERIFY 0 0.00%
216 WRITE 0 0.00%
217 RELEASE_LOCKOWNER 0 0.00%
218 GET_DIR_DELEGATION 0 0.00%
79 NFS v4.0 protocol: Data transmission has not been detected.
21980 ### Breakdown analyzer ###
220 NFS v4.1 protocol
221 Total procedures: 0. Per procedure:
222 NULL 0 0.00%
223 COMPOUND 0 0.00%
224 Total operations: 0. Per operation:
225 ILLEGAL 0 0.00%
226 ACCESS 0 0.00%
227 CLOSE 0 0.00%
228 COMMIT 0 0.00%
229 CREATE 0 0.00%
230 DELEGPURGE 0 0.00%
231 DELEGRETURN 0 0.00%
232 GETATTR 0 0.00%
233 GETFH 0 0.00%
234 LINK 0 0.00%
235 LOCK 0 0.00%
236 LOCKT 0 0.00%
237 LOCKU 0 0.00%
238 LOOKUP 0 0.00%
239 LOOKUPP 0 0.00%
240 NVERIFY 0 0.00%
241 OPEN 0 0.00%
242 OPENATTR 0 0.00%
243 OPEN_CONFIRM 0 0.00%
244 OPEN_DOWNGRADE 0 0.00%
245 PUTFH 0 0.00%
246 PUTPUBFH 0 0.00%
247 PUTROOTFH 0 0.00%
248 READ 0 0.00%
249 READDIR 0 0.00%
250 READLINK 0 0.00%
251 REMOVE 0 0.00%
252 RENAME 0 0.00%
253 RENEW 0 0.00%
254 RESTOREFH 0 0.00%
255 SAVEFH 0 0.00%
256 SECINFO 0 0.00%
257 SETATTR 0 0.00%
258 SETCLIENTID 0 0.00%
259 SETCLIENTID_CONFIRM 0 0.00%
260 VERIFY 0 0.00%
261 WRITE 0 0.00%
262 RELEASE_LOCKOWNER 0 0.00%
263 BACKCHANNEL_CTL 0 0.00%
264 BIND_CONN_TO_SESSION 0 0.00%
265 EXCHANGE_ID 0 0.00%
266 CREATE_SESSION 0 0.00%
267 DESTROY_SESSION 0 0.00%
268 FREE_STATEID 0 0.00%
269 GET_DIR_DELEGATION 0 0.00%
270 GETDEVICEINFO 0 0.00%
271 GETDEVICELIST 0 0.00%
272 LAYOUTCOMMIT 0 0.00%
273 LAYOUTGET 0 0.00%
274 LAYOUTRETURN 0 0.00%
275 SECINFO_NO_NAME 0 0.00%
276 SEQUENCE 0 0.00%
277 SET_SSV 0 0.00%
278 TEST_STATEID 0 0.00%
279 WANT_DELEGATION 0 0.00%
280 DESTROY_CLIENTID 0 0.00%
281 RECLAIM_COMPLETE 0 0.00%
81 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 58. Per operation:
17276 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17377 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17478 ### Breakdown analyzer ###
175 NFS v4.0 protocol
176 Total procedures: 0. Per procedure:
177 NULL 0 0.00%
178 COMPOUND 0 0.00%
179 Total operations: 0. Per operation:
180 ILLEGAL 0 0.00%
181 ACCESS 0 0.00%
182 CLOSE 0 0.00%
183 COMMIT 0 0.00%
184 CREATE 0 0.00%
185 DELEGPURGE 0 0.00%
186 DELEGRETURN 0 0.00%
187 GETATTR 0 0.00%
188 GETFH 0 0.00%
189 LINK 0 0.00%
190 LOCK 0 0.00%
191 LOCKT 0 0.00%
192 LOCKU 0 0.00%
193 LOOKUP 0 0.00%
194 LOOKUPP 0 0.00%
195 NVERIFY 0 0.00%
196 OPEN 0 0.00%
197 OPENATTR 0 0.00%
198 OPEN_CONFIRM 0 0.00%
199 OPEN_DOWNGRADE 0 0.00%
200 PUTFH 0 0.00%
201 PUTPUBFH 0 0.00%
202 PUTROOTFH 0 0.00%
203 READ 0 0.00%
204 READDIR 0 0.00%
205 READLINK 0 0.00%
206 REMOVE 0 0.00%
207 RENAME 0 0.00%
208 RENEW 0 0.00%
209 RESTOREFH 0 0.00%
210 SAVEFH 0 0.00%
211 SECINFO 0 0.00%
212 SETATTR 0 0.00%
213 SETCLIENTID 0 0.00%
214 SETCLIENTID_CONFIRM 0 0.00%
215 VERIFY 0 0.00%
216 WRITE 0 0.00%
217 RELEASE_LOCKOWNER 0 0.00%
218 GET_DIR_DELEGATION 0 0.00%
79 NFS v4.0 protocol: Data transmission has not been detected.
21980 ### Breakdown analyzer ###
220 NFS v4.1 protocol
221 Total procedures: 0. Per procedure:
222 NULL 0 0.00%
223 COMPOUND 0 0.00%
224 Total operations: 0. Per operation:
225 ILLEGAL 0 0.00%
226 ACCESS 0 0.00%
227 CLOSE 0 0.00%
228 COMMIT 0 0.00%
229 CREATE 0 0.00%
230 DELEGPURGE 0 0.00%
231 DELEGRETURN 0 0.00%
232 GETATTR 0 0.00%
233 GETFH 0 0.00%
234 LINK 0 0.00%
235 LOCK 0 0.00%
236 LOCKT 0 0.00%
237 LOCKU 0 0.00%
238 LOOKUP 0 0.00%
239 LOOKUPP 0 0.00%
240 NVERIFY 0 0.00%
241 OPEN 0 0.00%
242 OPENATTR 0 0.00%
243 OPEN_CONFIRM 0 0.00%
244 OPEN_DOWNGRADE 0 0.00%
245 PUTFH 0 0.00%
246 PUTPUBFH 0 0.00%
247 PUTROOTFH 0 0.00%
248 READ 0 0.00%
249 READDIR 0 0.00%
250 READLINK 0 0.00%
251 REMOVE 0 0.00%
252 RENAME 0 0.00%
253 RENEW 0 0.00%
254 RESTOREFH 0 0.00%
255 SAVEFH 0 0.00%
256 SECINFO 0 0.00%
257 SETATTR 0 0.00%
258 SETCLIENTID 0 0.00%
259 SETCLIENTID_CONFIRM 0 0.00%
260 VERIFY 0 0.00%
261 WRITE 0 0.00%
262 RELEASE_LOCKOWNER 0 0.00%
263 BACKCHANNEL_CTL 0 0.00%
264 BIND_CONN_TO_SESSION 0 0.00%
265 EXCHANGE_ID 0 0.00%
266 CREATE_SESSION 0 0.00%
267 DESTROY_SESSION 0 0.00%
268 FREE_STATEID 0 0.00%
269 GET_DIR_DELEGATION 0 0.00%
270 GETDEVICEINFO 0 0.00%
271 GETDEVICELIST 0 0.00%
272 LAYOUTCOMMIT 0 0.00%
273 LAYOUTGET 0 0.00%
274 LAYOUTRETURN 0 0.00%
275 SECINFO_NO_NAME 0 0.00%
276 SEQUENCE 0 0.00%
277 SET_SSV 0 0.00%
278 TEST_STATEID 0 0.00%
279 WANT_DELEGATION 0 0.00%
280 DESTROY_CLIENTID 0 0.00%
281 RECLAIM_COMPLETE 0 0.00%
81 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 28179. Per operation:
14852 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
14953 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
15054 ### Breakdown analyzer ###
151 NFS v4.0 protocol
152 Total procedures: 0. Per procedure:
153 NULL 0 0.00%
154 COMPOUND 0 0.00%
155 Total operations: 0. Per operation:
156 ILLEGAL 0 0.00%
157 ACCESS 0 0.00%
158 CLOSE 0 0.00%
159 COMMIT 0 0.00%
160 CREATE 0 0.00%
161 DELEGPURGE 0 0.00%
162 DELEGRETURN 0 0.00%
163 GETATTR 0 0.00%
164 GETFH 0 0.00%
165 LINK 0 0.00%
166 LOCK 0 0.00%
167 LOCKT 0 0.00%
168 LOCKU 0 0.00%
169 LOOKUP 0 0.00%
170 LOOKUPP 0 0.00%
171 NVERIFY 0 0.00%
172 OPEN 0 0.00%
173 OPENATTR 0 0.00%
174 OPEN_CONFIRM 0 0.00%
175 OPEN_DOWNGRADE 0 0.00%
176 PUTFH 0 0.00%
177 PUTPUBFH 0 0.00%
178 PUTROOTFH 0 0.00%
179 READ 0 0.00%
180 READDIR 0 0.00%
181 READLINK 0 0.00%
182 REMOVE 0 0.00%
183 RENAME 0 0.00%
184 RENEW 0 0.00%
185 RESTOREFH 0 0.00%
186 SAVEFH 0 0.00%
187 SECINFO 0 0.00%
188 SETATTR 0 0.00%
189 SETCLIENTID 0 0.00%
190 SETCLIENTID_CONFIRM 0 0.00%
191 VERIFY 0 0.00%
192 WRITE 0 0.00%
193 RELEASE_LOCKOWNER 0 0.00%
194 GET_DIR_DELEGATION 0 0.00%
55 NFS v4.0 protocol: Data transmission has not been detected.
19556 ### Breakdown analyzer ###
196 NFS v4.1 protocol
197 Total procedures: 0. Per procedure:
198 NULL 0 0.00%
199 COMPOUND 0 0.00%
200 Total operations: 0. Per operation:
201 ILLEGAL 0 0.00%
202 ACCESS 0 0.00%
203 CLOSE 0 0.00%
204 COMMIT 0 0.00%
205 CREATE 0 0.00%
206 DELEGPURGE 0 0.00%
207 DELEGRETURN 0 0.00%
208 GETATTR 0 0.00%
209 GETFH 0 0.00%
210 LINK 0 0.00%
211 LOCK 0 0.00%
212 LOCKT 0 0.00%
213 LOCKU 0 0.00%
214 LOOKUP 0 0.00%
215 LOOKUPP 0 0.00%
216 NVERIFY 0 0.00%
217 OPEN 0 0.00%
218 OPENATTR 0 0.00%
219 OPEN_CONFIRM 0 0.00%
220 OPEN_DOWNGRADE 0 0.00%
221 PUTFH 0 0.00%
222 PUTPUBFH 0 0.00%
223 PUTROOTFH 0 0.00%
224 READ 0 0.00%
225 READDIR 0 0.00%
226 READLINK 0 0.00%
227 REMOVE 0 0.00%
228 RENAME 0 0.00%
229 RENEW 0 0.00%
230 RESTOREFH 0 0.00%
231 SAVEFH 0 0.00%
232 SECINFO 0 0.00%
233 SETATTR 0 0.00%
234 SETCLIENTID 0 0.00%
235 SETCLIENTID_CONFIRM 0 0.00%
236 VERIFY 0 0.00%
237 WRITE 0 0.00%
238 RELEASE_LOCKOWNER 0 0.00%
239 BACKCHANNEL_CTL 0 0.00%
240 BIND_CONN_TO_SESSION 0 0.00%
241 EXCHANGE_ID 0 0.00%
242 CREATE_SESSION 0 0.00%
243 DESTROY_SESSION 0 0.00%
244 FREE_STATEID 0 0.00%
245 GET_DIR_DELEGATION 0 0.00%
246 GETDEVICEINFO 0 0.00%
247 GETDEVICELIST 0 0.00%
248 LAYOUTCOMMIT 0 0.00%
249 LAYOUTGET 0 0.00%
250 LAYOUTRETURN 0 0.00%
251 SECINFO_NO_NAME 0 0.00%
252 SEQUENCE 0 0.00%
253 SET_SSV 0 0.00%
254 TEST_STATEID 0 0.00%
255 WANT_DELEGATION 0 0.00%
256 DESTROY_CLIENTID 0 0.00%
257 RECLAIM_COMPLETE 0 0.00%
57 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 1605. Per operation:
14852 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
14953 COMMIT Count: 1 ( 0.06%) Min: 0.854 Max: 0.854 Avg: 0.854 StDev: 0.00000000
15054 ### Breakdown analyzer ###
151 NFS v4.0 protocol
152 Total procedures: 0. Per procedure:
153 NULL 0 0.00%
154 COMPOUND 0 0.00%
155 Total operations: 0. Per operation:
156 ILLEGAL 0 0.00%
157 ACCESS 0 0.00%
158 CLOSE 0 0.00%
159 COMMIT 0 0.00%
160 CREATE 0 0.00%
161 DELEGPURGE 0 0.00%
162 DELEGRETURN 0 0.00%
163 GETATTR 0 0.00%
164 GETFH 0 0.00%
165 LINK 0 0.00%
166 LOCK 0 0.00%
167 LOCKT 0 0.00%
168 LOCKU 0 0.00%
169 LOOKUP 0 0.00%
170 LOOKUPP 0 0.00%
171 NVERIFY 0 0.00%
172 OPEN 0 0.00%
173 OPENATTR 0 0.00%
174 OPEN_CONFIRM 0 0.00%
175 OPEN_DOWNGRADE 0 0.00%
176 PUTFH 0 0.00%
177 PUTPUBFH 0 0.00%
178 PUTROOTFH 0 0.00%
179 READ 0 0.00%
180 READDIR 0 0.00%
181 READLINK 0 0.00%
182 REMOVE 0 0.00%
183 RENAME 0 0.00%
184 RENEW 0 0.00%
185 RESTOREFH 0 0.00%
186 SAVEFH 0 0.00%
187 SECINFO 0 0.00%
188 SETATTR 0 0.00%
189 SETCLIENTID 0 0.00%
190 SETCLIENTID_CONFIRM 0 0.00%
191 VERIFY 0 0.00%
192 WRITE 0 0.00%
193 RELEASE_LOCKOWNER 0 0.00%
194 GET_DIR_DELEGATION 0 0.00%
55 NFS v4.0 protocol: Data transmission has not been detected.
19556 ### Breakdown analyzer ###
196 NFS v4.1 protocol
197 Total procedures: 0. Per procedure:
198 NULL 0 0.00%
199 COMPOUND 0 0.00%
200 Total operations: 0. Per operation:
201 ILLEGAL 0 0.00%
202 ACCESS 0 0.00%
203 CLOSE 0 0.00%
204 COMMIT 0 0.00%
205 CREATE 0 0.00%
206 DELEGPURGE 0 0.00%
207 DELEGRETURN 0 0.00%
208 GETATTR 0 0.00%
209 GETFH 0 0.00%
210 LINK 0 0.00%
211 LOCK 0 0.00%
212 LOCKT 0 0.00%
213 LOCKU 0 0.00%
214 LOOKUP 0 0.00%
215 LOOKUPP 0 0.00%
216 NVERIFY 0 0.00%
217 OPEN 0 0.00%
218 OPENATTR 0 0.00%
219 OPEN_CONFIRM 0 0.00%
220 OPEN_DOWNGRADE 0 0.00%
221 PUTFH 0 0.00%
222 PUTPUBFH 0 0.00%
223 PUTROOTFH 0 0.00%
224 READ 0 0.00%
225 READDIR 0 0.00%
226 READLINK 0 0.00%
227 REMOVE 0 0.00%
228 RENAME 0 0.00%
229 RENEW 0 0.00%
230 RESTOREFH 0 0.00%
231 SAVEFH 0 0.00%
232 SECINFO 0 0.00%
233 SETATTR 0 0.00%
234 SETCLIENTID 0 0.00%
235 SETCLIENTID_CONFIRM 0 0.00%
236 VERIFY 0 0.00%
237 WRITE 0 0.00%
238 RELEASE_LOCKOWNER 0 0.00%
239 BACKCHANNEL_CTL 0 0.00%
240 BIND_CONN_TO_SESSION 0 0.00%
241 EXCHANGE_ID 0 0.00%
242 CREATE_SESSION 0 0.00%
243 DESTROY_SESSION 0 0.00%
244 FREE_STATEID 0 0.00%
245 GET_DIR_DELEGATION 0 0.00%
246 GETDEVICEINFO 0 0.00%
247 GETDEVICELIST 0 0.00%
248 LAYOUTCOMMIT 0 0.00%
249 LAYOUTGET 0 0.00%
250 LAYOUTRETURN 0 0.00%
251 SECINFO_NO_NAME 0 0.00%
252 SEQUENCE 0 0.00%
253 SET_SSV 0 0.00%
254 TEST_STATEID 0 0.00%
255 WANT_DELEGATION 0 0.00%
256 DESTROY_CLIENTID 0 0.00%
257 RECLAIM_COMPLETE 0 0.00%
57 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 7. Per operation:
17276 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17377 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
17478 ### Breakdown analyzer ###
175 NFS v4.0 protocol
176 Total procedures: 0. Per procedure:
177 NULL 0 0.00%
178 COMPOUND 0 0.00%
179 Total operations: 0. Per operation:
180 ILLEGAL 0 0.00%
181 ACCESS 0 0.00%
182 CLOSE 0 0.00%
183 COMMIT 0 0.00%
184 CREATE 0 0.00%
185 DELEGPURGE 0 0.00%
186 DELEGRETURN 0 0.00%
187 GETATTR 0 0.00%
188 GETFH 0 0.00%
189 LINK 0 0.00%
190 LOCK 0 0.00%
191 LOCKT 0 0.00%
192 LOCKU 0 0.00%
193 LOOKUP 0 0.00%
194 LOOKUPP 0 0.00%
195 NVERIFY 0 0.00%
196 OPEN 0 0.00%
197 OPENATTR 0 0.00%
198 OPEN_CONFIRM 0 0.00%
199 OPEN_DOWNGRADE 0 0.00%
200 PUTFH 0 0.00%
201 PUTPUBFH 0 0.00%
202 PUTROOTFH 0 0.00%
203 READ 0 0.00%
204 READDIR 0 0.00%
205 READLINK 0 0.00%
206 REMOVE 0 0.00%
207 RENAME 0 0.00%
208 RENEW 0 0.00%
209 RESTOREFH 0 0.00%
210 SAVEFH 0 0.00%
211 SECINFO 0 0.00%
212 SETATTR 0 0.00%
213 SETCLIENTID 0 0.00%
214 SETCLIENTID_CONFIRM 0 0.00%
215 VERIFY 0 0.00%
216 WRITE 0 0.00%
217 RELEASE_LOCKOWNER 0 0.00%
218 GET_DIR_DELEGATION 0 0.00%
79 NFS v4.0 protocol: Data transmission has not been detected.
21980 ### Breakdown analyzer ###
220 NFS v4.1 protocol
221 Total procedures: 0. Per procedure:
222 NULL 0 0.00%
223 COMPOUND 0 0.00%
224 Total operations: 0. Per operation:
225 ILLEGAL 0 0.00%
226 ACCESS 0 0.00%
227 CLOSE 0 0.00%
228 COMMIT 0 0.00%
229 CREATE 0 0.00%
230 DELEGPURGE 0 0.00%
231 DELEGRETURN 0 0.00%
232 GETATTR 0 0.00%
233 GETFH 0 0.00%
234 LINK 0 0.00%
235 LOCK 0 0.00%
236 LOCKT 0 0.00%
237 LOCKU 0 0.00%
238 LOOKUP 0 0.00%
239 LOOKUPP 0 0.00%
240 NVERIFY 0 0.00%
241 OPEN 0 0.00%
242 OPENATTR 0 0.00%
243 OPEN_CONFIRM 0 0.00%
244 OPEN_DOWNGRADE 0 0.00%
245 PUTFH 0 0.00%
246 PUTPUBFH 0 0.00%
247 PUTROOTFH 0 0.00%
248 READ 0 0.00%
249 READDIR 0 0.00%
250 READLINK 0 0.00%
251 REMOVE 0 0.00%
252 RENAME 0 0.00%
253 RENEW 0 0.00%
254 RESTOREFH 0 0.00%
255 SAVEFH 0 0.00%
256 SECINFO 0 0.00%
257 SETATTR 0 0.00%
258 SETCLIENTID 0 0.00%
259 SETCLIENTID_CONFIRM 0 0.00%
260 VERIFY 0 0.00%
261 WRITE 0 0.00%
262 RELEASE_LOCKOWNER 0 0.00%
263 BACKCHANNEL_CTL 0 0.00%
264 BIND_CONN_TO_SESSION 0 0.00%
265 EXCHANGE_ID 0 0.00%
266 CREATE_SESSION 0 0.00%
267 DESTROY_SESSION 0 0.00%
268 FREE_STATEID 0 0.00%
269 GET_DIR_DELEGATION 0 0.00%
270 GETDEVICEINFO 0 0.00%
271 GETDEVICELIST 0 0.00%
272 LAYOUTCOMMIT 0 0.00%
273 LAYOUTGET 0 0.00%
274 LAYOUTRETURN 0 0.00%
275 SECINFO_NO_NAME 0 0.00%
276 SEQUENCE 0 0.00%
277 SET_SSV 0 0.00%
278 TEST_STATEID 0 0.00%
279 WANT_DELEGATION 0 0.00%
280 DESTROY_CLIENTID 0 0.00%
281 RECLAIM_COMPLETE 0 0.00%
81 NFS v4.1 protocol: Data transmission has not been detected.
00 ### Breakdown analyzer ###
1 CIFS v1 protocol
2 Total operations: 0. Per operation:
3 CREATE_DIRECTORY 0 0.00%
4 DELETE_DIRECTORY 0 0.00%
5 OPEN 0 0.00%
6 CREATE 0 0.00%
7 CLOSE 0 0.00%
8 FLUSH 0 0.00%
9 DELETE 0 0.00%
10 RENAME 0 0.00%
11 QUERY_INFORMATION 0 0.00%
12 SET_INFORMATION 0 0.00%
13 READ 0 0.00%
14 WRITE 0 0.00%
15 LOCK_BYTE_RANGE 0 0.00%
16 UNLOCK_BYTE_RANGE 0 0.00%
17 CREATE_TEMPORARY 0 0.00%
18 CREATE_NEW 0 0.00%
19 CHECK_DIRECTORY 0 0.00%
20 PROCESS_EXIT 0 0.00%
21 SEEK 0 0.00%
22 LOCK_AND_READ 0 0.00%
23 WRITE_AND_UNLOCK 0 0.00%
24 READ_RAW 0 0.00%
25 READ_MPX 0 0.00%
26 READ_MPX_SECONDARY 0 0.00%
27 WRITE_RAW 0 0.00%
28 WRITE_MPX 0 0.00%
29 WRITE_MPX_SECONDARY 0 0.00%
30 WRITE_COMPLETE 0 0.00%
31 QUERY_SERVER 0 0.00%
32 SET_INFORMATION2 0 0.00%
33 QUERY_INFORMATION2 0 0.00%
34 LOCKING_ANDX 0 0.00%
35 TRANSACTION 0 0.00%
36 TRANSACTION_SECONDARY 0 0.00%
37 IOCTL 0 0.00%
38 IOCTL_SECONDARY 0 0.00%
39 COPY 0 0.00%
40 MOVE 0 0.00%
41 ECHO 0 0.00%
42 WRITE_AND_CLOSE 0 0.00%
43 OPEN_ANDX 0 0.00%
44 READ_ANDX 0 0.00%
45 WRITE_ANDX 0 0.00%
46 NEW_FILE_SIZE 0 0.00%
47 CLOSE_AND_TREE_DISC 0 0.00%
48 TRANSACTION2 0 0.00%
49 TRANSACTION2_SECONDARY 0 0.00%
50 FIND_CLOSE2 0 0.00%
51 FIND_NOTIFY_CLOSE 0 0.00%
52 TREE_CONNECT 0 0.00%
53 TREE_DISCONNECT 0 0.00%
54 NEGOTIATE 0 0.00%
55 SESSION_SETUP_ANDX 0 0.00%
56 LOGOFF_ANDX 0 0.00%
57 TREE_CONNECT_ANDX 0 0.00%
58 SECURITY_PACKAGE_ANDX 0 0.00%
59 QUERY_INFORMATION_DISK 0 0.00%
60 SEARCH 0 0.00%
61 FIND 0 0.00%
62 FIND_UNIQUE 0 0.00%
63 FIND_CLOSE 0 0.00%
64 NT_TRANSACT 0 0.00%
65 NT_TRANSACT_SECONDARY 0 0.00%
66 NT_CREATE_ANDX 0 0.00%
67 NT_CANCEL 0 0.00%
68 NT_RENAME 0 0.00%
69 OPEN_PRINT_FILE 0 0.00%
70 WRITE_PRINT_FILE 0 0.00%
71 CLOSE_PRINT_FILE 0 0.00%
72 GET_PRINT_QUEUE 0 0.00%
73 READ_BULK 0 0.00%
74 WRITE_BULK 0 0.00%
75 WRITE_BULK_DATA 0 0.00%
76 INVALID 0 0.00%
77 NO_ANDX_COMMAND 0 0.00%
1 CIFS v1 protocol: Data transmission has not been detected.
782 ### Breakdown analyzer ###
79 CIFS v2 protocol
80 Total operations: 0. Per operation:
81 NEGOTIATE 0 0.00%
82 SESSION SETUP 0 0.00%
83 LOGOFF 0 0.00%
84 TREE CONNECT 0 0.00%
85 TREE DISCONNECT 0 0.00%
86 CREATE 0 0.00%
87 CLOSE 0 0.00%
88 FLUSH 0 0.00%
89 READ 0 0.00%
90 WRITE 0 0.00%
91 LOCK 0 0.00%
92 IOCTL 0 0.00%
93 CANCEL 0 0.00%
94 ECHO 0 0.00%
95 QUERY DIRECTORY 0 0.00%
96 CHANGE NOTIFY 0 0.00%
97 QUERY INFO 0 0.00%
98 SET INFO 0 0.00%
99 OPLOCK BREAK 0 0.00%
3 CIFS v2 protocol: Data transmission has not been detected.
1004 ### Breakdown analyzer ###
1015 NFS v3 protocol
1026 Total operations: 6171. Per operation:
14852 PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
14953 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000
15054 ### Breakdown analyzer ###
151 NFS v4.0 protocol
152 Total procedures: 0. Per procedure:
153 NULL 0 0.00%
154 COMPOUND 0 0.00%
155 Total operations: 0. Per operation:
156 ILLEGAL 0 0.00%
157 ACCESS 0 0.00%
158 CLOSE 0 0.00%
159 COMMIT 0 0.00%
160 CREATE 0 0.00%
161 DELEGPURGE 0 0.00%
162 DELEGRETURN 0 0.00%
163 GETATTR 0 0.00%
164 GETFH 0 0.00%
165 LINK 0 0.00%
166 LOCK 0 0.00%
167 LOCKT 0 0.00%
168 LOCKU 0 0.00%
169 LOOKUP 0 0.00%
170 LOOKUPP 0 0.00%
171 NVERIFY 0 0.00%
172 OPEN 0 0.00%
173 OPENATTR 0 0.00%
174 OPEN_CONFIRM 0 0.00%
175 OPEN_DOWNGRADE 0 0.00%
176 PUTFH 0 0.00%
177 PUTPUBFH 0 0.00%
178 PUTROOTFH 0 0.00%
179 READ 0 0.00%
180 READDIR 0 0.00%
181 READLINK 0 0.00%
182 REMOVE 0 0.00%
183 RENAME 0 0.00%
184 RENEW 0 0.00%
185 RESTOREFH 0 0.00%
186 SAVEFH 0 0.00%
187 SECINFO 0 0.00%
188 SETATTR 0 0.00%
189 SETCLIENTID 0 0.00%
190 SETCLIENTID_CONFIRM 0 0.00%
191 VERIFY 0 0.00%
192 WRITE 0 0.00%
193 RELEASE_LOCKOWNER 0 0.00%
194 GET_DIR_DELEGATION 0 0.00%
55 NFS v4.0 protocol: Data transmission has not been detected.
19556 ### Breakdown analyzer ###
196 NFS v4.1 protocol
197 Total procedures: 0. Per procedure:
198 NULL 0 0.00%
199 COMPOUND 0 0.00%
200 Total operations: 0. Per operation:
201 ILLEGAL 0 0.00%
202 ACCESS 0 0.00%
203 CLOSE 0 0.00%
204 COMMIT 0 0.00%
205 CREATE 0 0.00%
206 DELEGPURGE 0 0.00%
207 DELEGRETURN 0 0.00%
208 GETATTR 0 0.00%
209 GETFH 0 0.00%
210 LINK 0 0.00%
211 LOCK 0 0.00%
212 LOCKT 0 0.00%
213 LOCKU 0 0.00%
214 LOOKUP 0 0.00%
215 LOOKUPP 0 0.00%
216 NVERIFY 0 0.00%
217 OPEN 0 0.00%
218 OPENATTR 0 0.00%
219 OPEN_CONFIRM 0 0.00%
220 OPEN_DOWNGRADE 0 0.00%
221 PUTFH 0 0.00%
222 PUTPUBFH 0 0.00%
223 PUTROOTFH 0 0.00%
224 READ 0 0.00%
225 READDIR 0 0.00%
226 READLINK 0 0.00%
227 REMOVE 0 0.00%
228 RENAME 0 0.00%
229 RENEW 0 0.00%
230 RESTOREFH 0 0.00%
231 SAVEFH 0 0.00%
232 SECINFO 0 0.00%
233 SETATTR 0 0.00%
234 SETCLIENTID 0 0.00%
235 SETCLIENTID_CONFIRM 0 0.00%
236 VERIFY 0 0.00%
237 WRITE 0 0.00%
238 RELEASE_LOCKOWNER 0 0.00%
239 BACKCHANNEL_CTL 0 0.00%
240 BIND_CONN_TO_SESSION 0 0.00%
241 EXCHANGE_ID 0 0.00%
242 CREATE_SESSION 0 0.00%
243 DESTROY_SESSION 0 0.00%
244 FREE_STATEID 0 0.00%
245 GET_DIR_DELEGATION 0 0.00%
246 GETDEVICEINFO 0 0.00%
247 GETDEVICELIST 0 0.00%
248 LAYOUTCOMMIT 0 0.00%
249 LAYOUTGET 0 0.00%
250 LAYOUTRETURN 0 0.00%
251 SECINFO_NO_NAME 0 0.00%
252 SEQUENCE 0 0.00%
253 SET_SSV 0 0.00%
254 TEST_STATEID 0 0.00%
255 WANT_DELEGATION 0 0.00%
256 DESTROY_CLIENTID 0 0.00%
257 RECLAIM_COMPLETE 0 0.00%
57 NFS v4.1 protocol: Data transmission has not been detected.