diff options
author | Andrew Shadura <andrewsh@debian.org> | 2016-12-15 11:12:46 +0100 |
---|---|---|
committer | Andrew Shadura <andrewsh@debian.org> | 2016-12-15 11:14:48 +0100 |
commit | ccc154b9b1c7682a86f8372070095e5e4218e7be (patch) | |
tree | 7b29d1db2daba9400ba6f55e660bd41da3c848e2 | |
parent | f60c749375b9518e01cff9b0458234c65194df80 (diff) | |
parent | 50a11af5bddcda9160d84f2ae3577df7451a7a95 (diff) |
Merge tag 'upstream/0.4.3.1'
Upstream version 0.4.3.1
207 files changed, 4683 insertions, 7786 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8e44659 --- /dev/null +++ b/.clang-format @@ -0,0 +1,94 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^<[a-z]*>' # language headers like <algorithm> + Priority: 1 + - Regex: '^<.*\.h>' # platform headers like <unistd.h> + Priority: 2 + - Regex: '^<.*' # other external headers + Priority: 3 + - Regex: '.*' # any other files + Priority: 4 +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Never +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5a4e85a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "third_party/googletest"] + path = third_party/googletest + url = https://github.com/google/googletest.git diff --git a/.travis.yml b/.travis.yml index c55db71..2de7ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: cpp addons: apt: packages: - - ccache + - ccache cache: apt: true directories: @@ -15,29 +15,39 @@ cache: env: global: - DEPS_DIR="$HOME/install" - - CMAKE_DIR="$DEPS_DIR/cmake-3.3.2-Linux-x86_64" - - CMAKE="$CMAKE_DIR/bin/cmake" + - CMAKE_DIR="$DEPS_DIR/cmake-3.5.2-Linux-x86_64" + - CMAKE="$CMAKE_DIR/bin/cmake" - JSON_DIR="$DEPS_DIR/json-c-0.11" - - JSON_LIB="$JSON_DIR/install" + - JSON_LIB="$JSON_DIR/install" - JSON_INCLUDE_DIR="$JSON_DIR" - LCOV_DIR="$DEPS_DIR/lcov-1.11" - LCOV="$LCOV_DIR/bin/lcov" - - GMOCK_DIR="$DEPS_DIR/gmock-1.7.0" + - GTEST_DIR="$TRAVIS_BUILD_DIR/third_party/googletest" matrix: include: - os: linux - compiler: gcc-4.9 + compiler: gcc-6 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['texlive-latex-base','gcc-4.9','g++-4.9','libpcap-dev','valgrind'] - env: + packages: ['texlive-latex-base','gcc-6','g++-6','libpcap-dev','valgrind'] + env: # You can not set CXX directly as Travis CI will overwrite it. You need an intermediate variable like COMPILER - - 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" + - 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" + fast_finish: true + - os: linux + compiler: clang-3.8 + addons: + apt: + sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8'] + packages: ['texlive-latex-base','clang-3.8','llvm-3.8-dev','libpcap-dev','valgrind'] + env: + - COMPILER=/usr/bin/clang++-3.8 gcov="/usr/bin/gcov-6" fast_finish: true before_install: + - git submodule update --init --recursive - uname -a - pwd - export @@ -48,16 +58,11 @@ install: - gem install coveralls-lcov - | if [ ! -f "$CMAKE" ]; then - 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 - else + 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 + else echo "Using cached cmake" fi - | - if [ ! -f "$GMOCK_DIR/CMakeLists.txt" ]; then - wget -q https://googlemock.googlecode.com/files/gmock-1.7.0.zip && unzip gmock-1.7.0.zip -d $DEPS_DIR - else - echo "Using cached gmock" - fi # installing libjson-c from source because #'ondrej/php5-5.6' is disallowed source in travis-ci - | @@ -74,21 +79,25 @@ install: else echo "Using cached lcov" fi + before_script: - $CMAKE --version - gcov --version - - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --directory . --zerocounters + - $LCOV --gcov-tool "/usr/bin/gcov-6" --directory . --zerocounters script: - mkdir debug && cd debug - - $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" ../ + - $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" ../ - make - make test - make documentation-pdflatex - ccache -s after_success: - - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --compat-libtool --directory . --capture --output-file coverage.info # capture coverage info - - $LCOV --gcov-tool "/usr/bin/gcov-4.9" --remove coverage.info 'tests/*' '/usr/*' '*gmock*' --output-file coverage.info # filter out system and test code - - coveralls-lcov coverage.info + - | + if [[ "$COMPILER" == "g++"* ]]; then + $LCOV --gcov-tool "/usr/bin/gcov-6" --compat-libtool --directory . --capture --output-file coverage.info # capture coverage info + $LCOV --gcov-tool "/usr/bin/gcov-6" --remove coverage.info 'tests/*' '/usr/*' '*gmock*' --output-file coverage.info # filter out system and test code + coveralls-lcov coverage.info + fi # - coveralls --gcov "$(which "${GCOV}")" --encoding iso-8859-1 || echo 'coveralls upload failed.' diff --git a/CHANGELOG.md b/CHANGELOG.md index eb1ec08..2671fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +0.4.3 +===== + - Switched to C++14 + - GCC updated to version 6; Clang updated to version 3.8 + - Fixed calculation of struct's member offset on x32 platform (https://github.com/epam/nfstrace/issues/19) + - Fix unaligned access in buffer copies. + +0.4.2 +===== + - documentation converted to LaTeX format + - repository was cleaned up via BFG Repo-Cleaner tool (https://rtyley.github.io/bfg-repo-cleaner/) to reduce the size. + 0.4.1 ===== - minor bug fixes for Debian platforms; diff --git a/CMakeLists.txt b/CMakeLists.txt index 5865779..60c2c30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,12 @@ project (nfstrace) # check compiler and packages ================================================== if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - message (FATAL_ERROR "GCC version must be at least 4.8") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) + message (FATAL_ERROR "GCC version must be at least 5.1") endif () elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) - message (FATAL_ERROR "Clang version must be at least 3.3") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) + message (FATAL_ERROR "Clang version must be at least 3.5") endif () else () message (WARNING "Compilation by ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} isn't tested") @@ -30,7 +30,7 @@ if ("${PCAP_LIBRARY}" STREQUAL "PCAP_LIBRARY-NOTFOUND") endif () # build application ============================================================ -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall -Werror -Wextra -fPIC -fvisibility=hidden") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pedantic -Wall -Werror -Wextra -Wno-invalid-offsetof -Wno-braced-scalar-init -fPIC -fvisibility=hidden") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${INCLUDE_COVERAGE_INFO}") @@ -48,15 +48,12 @@ list (GET VERSION_LIST 2 NST_V_PATCH) set (NST_VERSION_FULL "${PROJECT_NAME} ${NST_VERSION} (${CMAKE_BUILD_TYPE})") if (DEFINED ENV{SOURCE_DATE_EPOCH}) - execute_process( - COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d" - OUTPUT_VARIABLE COMPILATION_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process( + COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d" + OUTPUT_VARIABLE COMPILATION_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE) else () - execute_process( - COMMAND "date" "+%Y-%m-%d" - OUTPUT_VARIABLE TIMESTAMP - OUTPUT_STRIP_TRAILING_WHITESPACE) + string (TIMESTAMP COMPILATION_DATE "%Y-%m-%d") endif () include_directories (src) @@ -115,14 +112,7 @@ endif () add_subdirectory (docs) # code style =================================================================== -find_program (ASTYLE_PATH astyle) - -if (ASTYLE_PATH) - add_custom_target (codestyle - COMMAND find analyzers src tests -name '*.h' -o -name '*.cpp' | - xargs ${ASTYLE_PATH} --options=${CMAKE_SOURCE_DIR}/astyle.cfg - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -endif () +include ("cmake/codeformat.cmake") # valgrind reports ============================================================= include ("cmake/valgrind.cmake") @@ -14,18 +14,18 @@ determine NFS/CIFS procedures in raw network traffic. Furthermore, it performs filtration, dumping, compression, statistical analysis, visualization and provides the API for custom pluggable analysis modules. -`nfstrace` is written in C++11 programming language and currently supports the +`nfstrace` is written in C++ programming language and supports the following protocols: - Ethernet - IPv4 | IPv6 -- UPD | TCP +- UDP | TCP - NFSv3 | NFSv4 | NFSv4.1 | CIFSv1 | CIFSv2 `nfstrace` has been tested on the following GNU/Linux and FreeBSD systems: - Debian Sid [packages](https://packages.debian.org/unstable/main/nfstrace) [build-logs](https://buildd.debian.org/status/logs.php?pkg=nfstrace) -- Fedora 20 +- Fedora 23 - OpenSUSE 13.2 - Ubuntu 14.04/14.10 - CentOS 7 @@ -49,11 +49,11 @@ External Dependencies Building -------- -Since `nfstrace` is written in C++11 you have to use `gcc` >= 4.8 or -`clang` >= 3.3. Additionally, you need to install development version of +Since `nfstrace` is written in C++ you have to use `gcc` >= 6 or +`clang` >= 3.8. Additionally, you need to install development version of `libpcap` (version 1.3 or newer). -You can build `nfstrace` using [CMake](http://cmake.org) (version 2.8.12 or +You can build `nfstrace` using [CMake](https://cmake.org/cmake/help/v3.5/index.html) (version 2.8.12 or newer). From the top level project's directory run: $ mkdir release @@ -70,12 +70,17 @@ If you want to specify different installation prefix: $ cmake -DCMAKE_INSTALL_PREFIX=/your/path ../ +You can use different build tools, compilers, packaging systems with required parameters. +Please refer to +[CMake](https://cmake.org/cmake/help/v3.3/manual/cmake.1.html), +[CPack](https://cmake.org/cmake/help/v3.3/manual/cpack.1.html) and +[Reference Manuals](https://cmake.org/cmake/help/v3.3/index.html). + Installation ------------ -By default `nfstrace` will be installed to `/usr/`. -After you build `nfstrace` simply run: +You can install `nfstrace` to default location. After you build `nfstrace` simply run: $ sudo make install @@ -1 +1 @@ -0.4.2 +0.4.3 diff --git a/analyzers/src/breakdown/analyzer.cpp b/analyzers/src/breakdown/analyzer.cpp index de60cf0..5f46cb6 100644 --- a/analyzers/src/breakdown/analyzer.cpp +++ b/analyzers/src/breakdown/analyzer.cpp @@ -45,25 +45,23 @@ public: } }; -extern "C" +extern "C" { +const char* usage() { + return "No options"; +} - const char* usage() - { - return "No options"; - } - - IAnalyzer* create(const char*) - { - return new Analyzer(); - } +IAnalyzer* create(const char*) +{ + return new Analyzer(); +} - void destroy(IAnalyzer* instance) - { - delete instance; - } +void destroy(IAnalyzer* instance) +{ + delete instance; +} - NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr) +NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr) -}//extern "C" +} //extern "C" //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/breakdowncounter.cpp b/analyzers/src/breakdown/breakdowncounter.cpp index 5d3df3c..7a7ab5a 100644 --- a/analyzers/src/breakdown/breakdowncounter.cpp +++ b/analyzers/src/breakdown/breakdowncounter.cpp @@ -26,7 +26,8 @@ //------------------------------------------------------------------------------ using namespace NST::breakdown; //------------------------------------------------------------------------------ -BreakdownCounter::BreakdownCounter(size_t count) : latencies(count, NST::breakdown::Latencies()) +BreakdownCounter::BreakdownCounter(size_t count) + : latencies(count, NST::breakdown::Latencies()) { } @@ -41,8 +42,7 @@ Latencies& BreakdownCounter::operator[](int index) uint64_t BreakdownCounter::get_total_count() const { - return std::accumulate(std::begin(latencies), std::end(latencies), 0, [](int sum, const NST::breakdown::Latencies & latency) - { + return std::accumulate(std::begin(latencies), std::end(latencies), 0, [](int sum, const NST::breakdown::Latencies& latency) { return sum + latency.get_count(); }); } diff --git a/analyzers/src/breakdown/breakdowncounter.h b/analyzers/src/breakdown/breakdowncounter.h index 2d9a86c..66a9443 100644 --- a/analyzers/src/breakdown/breakdowncounter.h +++ b/analyzers/src/breakdown/breakdowncounter.h @@ -53,12 +53,12 @@ public: * \brief get_total_count returns total amount of commands * \return commands count */ - uint64_t get_total_count () const; + uint64_t get_total_count() const; private: - void operator= (const BreakdownCounter&) = delete; + void operator=(const BreakdownCounter&) = delete; std::vector<NST::breakdown::Latencies> latencies; }; //------------------------------------------------------------------------------ -#endif//BREAKDOWNCOUNTER_H +#endif //BREAKDOWNCOUNTER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/cifsv1breakdownanalyzer.cpp b/analyzers/src/breakdown/cifsv1breakdownanalyzer.cpp index e8977e8..751664e 100644 --- a/analyzers/src/breakdown/cifsv1breakdownanalyzer.cpp +++ b/analyzers/src/breakdown/cifsv1breakdownanalyzer.cpp @@ -19,8 +19,8 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#include "cifsv1commands.h" #include "cifsv1breakdownanalyzer.h" +#include "cifsv1commands.h" //------------------------------------------------------------------------------ using namespace NST::breakdown; //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/cifsv1breakdownanalyzer.h b/analyzers/src/breakdown/cifsv1breakdownanalyzer.h index 335b0fd..cb19df2 100644 --- a/analyzers/src/breakdown/cifsv1breakdownanalyzer.h +++ b/analyzers/src/breakdown/cifsv1breakdownanalyzer.h @@ -31,13 +31,12 @@ namespace NST { namespace breakdown { - /*! \class Analyzer for CIFS v1 * Handles CIFS v1 commands */ class CIFSBreakdownAnalyzer : virtual public IAnalyzer { - Statistics statistics; //!< Statistics + Statistics statistics; //!< Statistics Representer representer; //!< Class for statistics representation public: CIFSBreakdownAnalyzer(std::ostream& o = std::cout); @@ -117,6 +116,7 @@ public: void writeBulkDataSMBv1(const SMBv1::WriteBulkDataCommand* cmd, const SMBv1::WriteBulkDataArgumentType*, const SMBv1::WriteBulkDataResultType*) override final; void invalidSMBv1(const SMBv1::InvalidCommand* cmd, const SMBv1::InvalidArgumentType*, const SMBv1::InvalidResultType*) override final; void noAndxCommandSMBv1(const SMBv1::NoAndxCommand* cmd, const SMBv1::NoAndxCmdArgumentType*, const SMBv1::NoAndxCmdResultType*) override final; + protected: void flush_statistics() override; }; @@ -124,5 +124,5 @@ protected: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFSBREAKDOWNANALYZER_H +#endif //CIFSBREAKDOWNANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/cifsv1commands.h b/analyzers/src/breakdown/cifsv1commands.h index 3e0aeb7..e039b6a 100644 --- a/analyzers/src/breakdown/cifsv1commands.h +++ b/analyzers/src/breakdown/cifsv1commands.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * Represents CIFS v1 commands * Converts commands to string @@ -37,11 +36,11 @@ struct SMBv1Commands : public CommandRepresenter { const char* command_description(int cmd_code) override final; const char* command_name(int cmd_code) override final; - size_t commands_count(); - const char* protocol_name(); + size_t commands_count() override final; + const char* protocol_name() override final; }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS_COMMANDS_H +#endif //CIFS_COMMANDS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/cifsv2breakdownanalyzer.h b/analyzers/src/breakdown/cifsv2breakdownanalyzer.h index 73f1fad..1bdb72d 100644 --- a/analyzers/src/breakdown/cifsv2breakdownanalyzer.h +++ b/analyzers/src/breakdown/cifsv2breakdownanalyzer.h @@ -31,13 +31,12 @@ namespace NST { namespace breakdown { - /*! \class Analyzer for CIFS v2 * Handles CIFS v2 commands */ class CIFSv2BreakdownAnalyzer : virtual public IAnalyzer { - Statistics stats; //!< Statistics + Statistics stats; //!< Statistics Representer cifs2Representer; //!< Class for statistics representation public: CIFSv2BreakdownAnalyzer(std::ostream& o = std::cout); @@ -60,6 +59,7 @@ public: void queryInfoSMBv2(const SMBv2::QueryInfoCommand* cmd, const SMBv2::QueryInfoRequest*, const SMBv2::QueryInfoResponse*) override final; void setInfoSMBv2(const SMBv2::SetInfoCommand* cmd, const SMBv2::SetInfoRequest*, const SMBv2::SetInfoResponse*) override final; void breakOplockSMBv2(const SMBv2::BreakOpLockCommand* cmd, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) override final; + protected: void flush_statistics() override; }; @@ -67,5 +67,5 @@ protected: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFSV2BREAKDOWNANALYZER_H +#endif //CIFSV2BREAKDOWNANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/cifsv2commands.cpp b/analyzers/src/breakdown/cifsv2commands.cpp index e00e244..c64acd7 100644 --- a/analyzers/src/breakdown/cifsv2commands.cpp +++ b/analyzers/src/breakdown/cifsv2commands.cpp @@ -29,27 +29,27 @@ using namespace NST::breakdown; const char* NST::breakdown::SMBv2Commands::command_name(int cmd_code) { static std::map<Commands, const char*> cmdNames; - if (cmdNames.empty()) + if(cmdNames.empty()) { - cmdNames[Commands::NEGOTIATE] = "NEGOTIATE"; - cmdNames[Commands::SESSION_SETUP] = "SESSION SETUP"; - cmdNames[Commands::LOGOFF] = "LOGOFF"; - cmdNames[Commands::TREE_CONNECT] = "TREE CONNECT"; - cmdNames[Commands::TREE_DISCONNECT] = "TREE DISCONNECT"; - cmdNames[Commands::CREATE] = "CREATE"; - cmdNames[Commands::CLOSE] = "CLOSE"; - cmdNames[Commands::FLUSH] = "FLUSH"; - cmdNames[Commands::READ] = "READ"; - cmdNames[Commands::WRITE] = "WRITE"; - cmdNames[Commands::LOCK] = "LOCK"; - cmdNames[Commands::IOCTL] = "IOCTL"; - cmdNames[Commands::CANCEL] = "CANCEL"; - cmdNames[Commands::ECHO] = "ECHO"; - cmdNames[Commands::QUERY_DIRECTORY] = "QUERY DIRECTORY"; - cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE NOTIFY"; - cmdNames[Commands::QUERY_INFO] = "QUERY INFO"; - cmdNames[Commands::SET_INFO] = "SET INFO"; - cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK BREAK"; + cmdNames[Commands::NEGOTIATE] = "NEGOTIATE"; + cmdNames[Commands::SESSION_SETUP] = "SESSION SETUP"; + cmdNames[Commands::LOGOFF] = "LOGOFF"; + cmdNames[Commands::TREE_CONNECT] = "TREE CONNECT"; + cmdNames[Commands::TREE_DISCONNECT] = "TREE DISCONNECT"; + cmdNames[Commands::CREATE] = "CREATE"; + cmdNames[Commands::CLOSE] = "CLOSE"; + cmdNames[Commands::FLUSH] = "FLUSH"; + cmdNames[Commands::READ] = "READ"; + cmdNames[Commands::WRITE] = "WRITE"; + cmdNames[Commands::LOCK] = "LOCK"; + cmdNames[Commands::IOCTL] = "IOCTL"; + cmdNames[Commands::CANCEL] = "CANCEL"; + cmdNames[Commands::ECHO] = "ECHO"; + cmdNames[Commands::QUERY_DIRECTORY] = "QUERY DIRECTORY"; + cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE NOTIFY"; + cmdNames[Commands::QUERY_INFO] = "QUERY INFO"; + cmdNames[Commands::SET_INFO] = "SET INFO"; + cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK BREAK"; } return cmdNames[static_cast<Commands>(cmd_code)]; } @@ -62,27 +62,27 @@ size_t SMBv2Commands::commands_count() const char* NST::breakdown::SMBv2Commands::command_description(int cmd_code) { static std::map<Commands, const char*> cmdNames; - if (cmdNames.empty()) + if(cmdNames.empty()) { - cmdNames[Commands::NEGOTIATE] = "NEGOTIATE"; - cmdNames[Commands::SESSION_SETUP] = "SESSION_SETUP"; - cmdNames[Commands::LOGOFF] = "LOGOFF"; - cmdNames[Commands::TREE_CONNECT] = "TREE_CONNECT"; - cmdNames[Commands::TREE_DISCONNECT] = "TREE_DISCONNECT"; - cmdNames[Commands::CREATE] = "CREATE"; - cmdNames[Commands::CLOSE] = "CLOSE"; - cmdNames[Commands::FLUSH] = "FLUSH"; - cmdNames[Commands::READ] = "READ"; - cmdNames[Commands::WRITE] = "WRITE"; - cmdNames[Commands::LOCK] = "LOCK"; - cmdNames[Commands::IOCTL] = "IOCTL"; - cmdNames[Commands::CANCEL] = "CANCEL"; - cmdNames[Commands::ECHO] = "ECHO"; - cmdNames[Commands::QUERY_DIRECTORY] = "QUERY_DIRECTORY"; - cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE_NOTIFY"; - cmdNames[Commands::QUERY_INFO] = "QUERY_INFO"; - cmdNames[Commands::SET_INFO] = "SET_INFO"; - cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK_BREAK"; + cmdNames[Commands::NEGOTIATE] = "NEGOTIATE"; + cmdNames[Commands::SESSION_SETUP] = "SESSION_SETUP"; + cmdNames[Commands::LOGOFF] = "LOGOFF"; + cmdNames[Commands::TREE_CONNECT] = "TREE_CONNECT"; + cmdNames[Commands::TREE_DISCONNECT] = "TREE_DISCONNECT"; + cmdNames[Commands::CREATE] = "CREATE"; + cmdNames[Commands::CLOSE] = "CLOSE"; + cmdNames[Commands::FLUSH] = "FLUSH"; + cmdNames[Commands::READ] = "READ"; + cmdNames[Commands::WRITE] = "WRITE"; + cmdNames[Commands::LOCK] = "LOCK"; + cmdNames[Commands::IOCTL] = "IOCTL"; + cmdNames[Commands::CANCEL] = "CANCEL"; + cmdNames[Commands::ECHO] = "ECHO"; + cmdNames[Commands::QUERY_DIRECTORY] = "QUERY_DIRECTORY"; + cmdNames[Commands::CHANGE_NOTIFY] = "CHANGE_NOTIFY"; + cmdNames[Commands::QUERY_INFO] = "QUERY_INFO"; + cmdNames[Commands::SET_INFO] = "SET_INFO"; + cmdNames[Commands::OPLOCK_BREAK] = "OPLOCK_BREAK"; } return cmdNames[static_cast<Commands>(cmd_code)]; } diff --git a/analyzers/src/breakdown/cifsv2commands.h b/analyzers/src/breakdown/cifsv2commands.h index 306f18a..3a166ae 100644 --- a/analyzers/src/breakdown/cifsv2commands.h +++ b/analyzers/src/breakdown/cifsv2commands.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * Represents CIFS v2 commands * Converts commands to string @@ -66,13 +65,13 @@ struct SMBv2Commands : CommandRepresenter const char* command_name(int cmd_code) override final; - size_t commands_count(); + size_t commands_count() override final; - const char* protocol_name(); + const char* protocol_name() override final; }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS2_COMMANDS_H +#endif //CIFS2_COMMANDS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/commandrepresenter.h b/analyzers/src/breakdown/commandrepresenter.h index 2e1a61a..4847199 100644 --- a/analyzers/src/breakdown/commandrepresenter.h +++ b/analyzers/src/breakdown/commandrepresenter.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * \brief The CommandRepresenter struct represents interface for command representers * Commands representer should be able to convert commands to string @@ -67,5 +66,5 @@ struct CommandRepresenter } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//COMMANDREPRESENTER_H +#endif //COMMANDREPRESENTER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/latencies.cpp b/analyzers/src/breakdown/latencies.cpp index bc342e5..b6bbc83 100644 --- a/analyzers/src/breakdown/latencies.cpp +++ b/analyzers/src/breakdown/latencies.cpp @@ -26,7 +26,10 @@ using namespace NST::breakdown; //------------------------------------------------------------------------------ -Latencies::Latencies() : count {0}, avg {0}, m2 {0} +Latencies::Latencies() + : count{0} + , avg{0} + , m2{0} { timerclear(&min); timerclear(&max); @@ -34,7 +37,7 @@ Latencies::Latencies() : count {0}, avg {0}, m2 {0} void Latencies::add(const timeval& t) { - long double x = to_sec(t); + long double x = to_sec(t); long double delta = x - avg; avg += delta / (++count); m2 += delta * (x - avg); @@ -54,7 +57,7 @@ long double Latencies::get_avg() const long double Latencies::get_st_dev() const { - if (count < 2) + if(count < 2) { return 0; } @@ -73,15 +76,15 @@ const timeval& Latencies::get_max() const void Latencies::set_range(const timeval& t) { - if (timercmp(&t, &min, < )) + if(timercmp(&t, &min, <)) { min = t; } - if (min.tv_sec == 0 && min.tv_usec == 0) + if(min.tv_sec == 0 && min.tv_usec == 0) { min = t; } - if (timercmp(&t, &max, > )) + if(timercmp(&t, &max, >)) { max = t; } diff --git a/analyzers/src/breakdown/latencies.h b/analyzers/src/breakdown/latencies.h index b206e52..bb4a073 100644 --- a/analyzers/src/breakdown/latencies.h +++ b/analyzers/src/breakdown/latencies.h @@ -30,7 +30,6 @@ namespace NST { namespace breakdown { - /*! * \brief Latencies calculates latencies */ @@ -82,7 +81,7 @@ private: timeval min; timeval max; - uint64_t count; + uint64_t count; long double avg; long double m2; }; @@ -97,5 +96,5 @@ double to_sec(const timeval& val); } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//LATENCIES_H +#endif //LATENCIES_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv3breakdownanalyzer.cpp b/analyzers/src/breakdown/nfsv3breakdownanalyzer.cpp index e12409a..006556d 100644 --- a/analyzers/src/breakdown/nfsv3breakdownanalyzer.cpp +++ b/analyzers/src/breakdown/nfsv3breakdownanalyzer.cpp @@ -19,8 +19,8 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#include "breakdowncounter.h" #include "nfsv3breakdownanalyzer.h" +#include "breakdowncounter.h" #include "nfsv3commands.h" //------------------------------------------------------------------------------ using namespace NST::breakdown; @@ -101,7 +101,6 @@ void NFSv3BreakdownAnalyzer::rmdir3(const RPCProcedure* proc, const NFS3::RMDIR3 stats.account(proc, proc->call.ru.RM_cmb.cb_proc); } - void NFSv3BreakdownAnalyzer::rename3(const RPCProcedure* proc, const NFS3::RENAME3args*, const NFS3::RENAME3res*) { stats.account(proc, proc->call.ru.RM_cmb.cb_proc); diff --git a/analyzers/src/breakdown/nfsv3breakdownanalyzer.h b/analyzers/src/breakdown/nfsv3breakdownanalyzer.h index 943a453..7e8a8c6 100644 --- a/analyzers/src/breakdown/nfsv3breakdownanalyzer.h +++ b/analyzers/src/breakdown/nfsv3breakdownanalyzer.h @@ -31,13 +31,12 @@ namespace NST { namespace breakdown { - /*! \brief NFSv3BreakdownAnalyzer Analyzer for NFS v3 * Handles NFS v3 commands */ class NFSv3BreakdownAnalyzer : virtual public IAnalyzer { - Statistics stats; //!< Statistics + Statistics stats; //!< Statistics Representer representer; //!< Class for statistics representation public: NFSv3BreakdownAnalyzer(std::ostream& o = std::cout); @@ -115,5 +114,5 @@ public: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV3BREAKDOWNANALYZER_H +#endif //NFSV3BREAKDOWNANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv3commands.h b/analyzers/src/breakdown/nfsv3commands.h index 19f035d..1b7dcc9 100644 --- a/analyzers/src/breakdown/nfsv3commands.h +++ b/analyzers/src/breakdown/nfsv3commands.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * Represents NFS v3 commands * Converts commands to string @@ -38,12 +37,12 @@ class NFSv3Commands : public CommandRepresenter public: const char* command_description(int cmd_code) override final; const char* command_name(int cmd_code) override final; - size_t commands_count() override final; - const char* protocol_name(); + size_t commands_count() override final; + const char* protocol_name() override final; }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV3COMMANDS_H +#endif //NFSV3COMMANDS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv41breakdownanalyzer.cpp b/analyzers/src/breakdown/nfsv41breakdownanalyzer.cpp index ba95f08..d785875 100644 --- a/analyzers/src/breakdown/nfsv41breakdownanalyzer.cpp +++ b/analyzers/src/breakdown/nfsv41breakdownanalyzer.cpp @@ -42,7 +42,7 @@ void NFSv41BreakdownAnalyzer::compound41(const RPCProcedure* proc, const NFS41:: void NFSv41BreakdownAnalyzer::access41(const RPCProcedure* proc, const NFS41::ACCESS4args*, const NFS41::ACCESS4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::ACCESS); } @@ -50,7 +50,7 @@ void NFSv41BreakdownAnalyzer::access41(const RPCProcedure* proc, const NFS41::AC void NFSv41BreakdownAnalyzer::close41(const RPCProcedure* proc, const NFS41::CLOSE4args*, const NFS41::CLOSE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::CLOSE); } @@ -58,7 +58,7 @@ void NFSv41BreakdownAnalyzer::close41(const RPCProcedure* proc, const NFS41::CLO void NFSv41BreakdownAnalyzer::commit41(const RPCProcedure* proc, const NFS41::COMMIT4args*, const NFS41::COMMIT4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::COMMIT); } @@ -66,7 +66,7 @@ void NFSv41BreakdownAnalyzer::commit41(const RPCProcedure* proc, const NFS41::CO void NFSv41BreakdownAnalyzer::create41(const RPCProcedure* proc, const NFS41::CREATE4args*, const NFS41::CREATE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::CREATE); } @@ -74,7 +74,7 @@ void NFSv41BreakdownAnalyzer::create41(const RPCProcedure* proc, const NFS41::CR void NFSv41BreakdownAnalyzer::delegpurge41(const RPCProcedure* proc, const NFS41::DELEGPURGE4args*, const NFS41::DELEGPURGE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::DELEGPURGE); } @@ -82,7 +82,7 @@ void NFSv41BreakdownAnalyzer::delegpurge41(const RPCProcedure* proc, const NFS41 void NFSv41BreakdownAnalyzer::delegreturn41(const RPCProcedure* proc, const NFS41::DELEGRETURN4args*, const NFS41::DELEGRETURN4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::DELEGRETURN); } @@ -90,7 +90,7 @@ void NFSv41BreakdownAnalyzer::delegreturn41(const RPCProcedure* proc, const NFS4 void NFSv41BreakdownAnalyzer::getattr41(const RPCProcedure* proc, const NFS41::GETATTR4args*, const NFS41::GETATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::GETATTR); } @@ -98,7 +98,7 @@ void NFSv41BreakdownAnalyzer::getattr41(const RPCProcedure* proc, const NFS41::G void NFSv41BreakdownAnalyzer::getfh41(const RPCProcedure* proc, const NFS41::GETFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::GETFH); } @@ -106,7 +106,7 @@ void NFSv41BreakdownAnalyzer::getfh41(const RPCProcedure* proc, const NFS41::GET void NFSv41BreakdownAnalyzer::link41(const RPCProcedure* proc, const NFS41::LINK4args*, const NFS41::LINK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LINK); } @@ -114,7 +114,7 @@ void NFSv41BreakdownAnalyzer::link41(const RPCProcedure* proc, const NFS41::LINK void NFSv41BreakdownAnalyzer::lock41(const RPCProcedure* proc, const NFS41::LOCK4args*, const NFS41::LOCK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCK); } @@ -122,7 +122,7 @@ void NFSv41BreakdownAnalyzer::lock41(const RPCProcedure* proc, const NFS41::LOCK void NFSv41BreakdownAnalyzer::lockt41(const RPCProcedure* proc, const NFS41::LOCKT4args*, const NFS41::LOCKT4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCKT); } @@ -130,7 +130,7 @@ void NFSv41BreakdownAnalyzer::lockt41(const RPCProcedure* proc, const NFS41::LOC void NFSv41BreakdownAnalyzer::locku41(const RPCProcedure* proc, const NFS41::LOCKU4args*, const NFS41::LOCKU4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LOCKU); } @@ -138,7 +138,7 @@ void NFSv41BreakdownAnalyzer::locku41(const RPCProcedure* proc, const NFS41::LOC void NFSv41BreakdownAnalyzer::lookup41(const RPCProcedure* proc, const NFS41::LOOKUP4args*, const NFS41::LOOKUP4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LOOKUP); } @@ -146,7 +146,7 @@ void NFSv41BreakdownAnalyzer::lookup41(const RPCProcedure* proc, const NFS41::LO void NFSv41BreakdownAnalyzer::lookupp41(const RPCProcedure* proc, const NFS41::LOOKUPP4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LOOKUPP); } @@ -154,7 +154,7 @@ void NFSv41BreakdownAnalyzer::lookupp41(const RPCProcedure* proc, const NFS41::L void NFSv41BreakdownAnalyzer::nverify41(const RPCProcedure* proc, const NFS41::NVERIFY4args*, const NFS41::NVERIFY4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::NVERIFY); } @@ -162,7 +162,7 @@ void NFSv41BreakdownAnalyzer::nverify41(const RPCProcedure* proc, const NFS41::N void NFSv41BreakdownAnalyzer::open41(const RPCProcedure* proc, const NFS41::OPEN4args*, const NFS41::OPEN4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN); } @@ -170,7 +170,7 @@ void NFSv41BreakdownAnalyzer::open41(const RPCProcedure* proc, const NFS41::OPEN void NFSv41BreakdownAnalyzer::openattr41(const RPCProcedure* proc, const NFS41::OPENATTR4args*, const NFS41::OPENATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::OPENATTR); } @@ -178,7 +178,7 @@ void NFSv41BreakdownAnalyzer::openattr41(const RPCProcedure* proc, const NFS41:: void NFSv41BreakdownAnalyzer::open_confirm41(const RPCProcedure* proc, const NFS41::OPEN_CONFIRM4args*, const NFS41::OPEN_CONFIRM4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN_CONFIRM); } @@ -186,7 +186,7 @@ void NFSv41BreakdownAnalyzer::open_confirm41(const RPCProcedure* proc, const NFS void NFSv41BreakdownAnalyzer::open_downgrade41(const RPCProcedure* proc, const NFS41::OPEN_DOWNGRADE4args*, const NFS41::OPEN_DOWNGRADE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::OPEN_DOWNGRADE); } @@ -194,7 +194,7 @@ void NFSv41BreakdownAnalyzer::open_downgrade41(const RPCProcedure* proc, const N void NFSv41BreakdownAnalyzer::putfh41(const RPCProcedure* proc, const NFS41::PUTFH4args*, const NFS41::PUTFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTFH); } @@ -202,7 +202,7 @@ void NFSv41BreakdownAnalyzer::putfh41(const RPCProcedure* proc, const NFS41::PUT void NFSv41BreakdownAnalyzer::putpubfh41(const RPCProcedure* proc, const NFS41::PUTPUBFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTPUBFH); } @@ -210,7 +210,7 @@ void NFSv41BreakdownAnalyzer::putpubfh41(const RPCProcedure* proc, const NFS41:: void NFSv41BreakdownAnalyzer::putrootfh41(const RPCProcedure* proc, const NFS41::PUTROOTFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::PUTROOTFH); } @@ -218,7 +218,7 @@ void NFSv41BreakdownAnalyzer::putrootfh41(const RPCProcedure* proc, const NFS41: void NFSv41BreakdownAnalyzer::read41(const RPCProcedure* proc, const NFS41::READ4args*, const NFS41::READ4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::READ); } @@ -226,7 +226,7 @@ void NFSv41BreakdownAnalyzer::read41(const RPCProcedure* proc, const NFS41::READ void NFSv41BreakdownAnalyzer::readdir41(const RPCProcedure* proc, const NFS41::READDIR4args*, const NFS41::READDIR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::READDIR); } @@ -234,7 +234,7 @@ void NFSv41BreakdownAnalyzer::readdir41(const RPCProcedure* proc, const NFS41::R void NFSv41BreakdownAnalyzer::readlink41(const RPCProcedure* proc, const NFS41::READLINK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::READLINK); } @@ -242,7 +242,7 @@ void NFSv41BreakdownAnalyzer::readlink41(const RPCProcedure* proc, const NFS41:: void NFSv41BreakdownAnalyzer::remove41(const RPCProcedure* proc, const NFS41::REMOVE4args*, const NFS41::REMOVE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::REMOVE); } @@ -250,7 +250,7 @@ void NFSv41BreakdownAnalyzer::remove41(const RPCProcedure* proc, const NFS41::RE void NFSv41BreakdownAnalyzer::rename41(const RPCProcedure* proc, const NFS41::RENAME4args*, const NFS41::RENAME4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::RENAME); } @@ -258,7 +258,7 @@ void NFSv41BreakdownAnalyzer::rename41(const RPCProcedure* proc, const NFS41::RE void NFSv41BreakdownAnalyzer::renew41(const RPCProcedure* proc, const NFS41::RENEW4args*, const NFS41::RENEW4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::RENEW); } @@ -266,7 +266,7 @@ void NFSv41BreakdownAnalyzer::renew41(const RPCProcedure* proc, const NFS41::REN void NFSv41BreakdownAnalyzer::restorefh41(const RPCProcedure* proc, const NFS41::RESTOREFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::RESTOREFH); } @@ -274,7 +274,7 @@ void NFSv41BreakdownAnalyzer::restorefh41(const RPCProcedure* proc, const NFS41: void NFSv41BreakdownAnalyzer::savefh41(const RPCProcedure* proc, const NFS41::SAVEFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SAVEFH); } @@ -282,7 +282,7 @@ void NFSv41BreakdownAnalyzer::savefh41(const RPCProcedure* proc, const NFS41::SA void NFSv41BreakdownAnalyzer::secinfo41(const RPCProcedure* proc, const NFS41::SECINFO4args*, const NFS41::SECINFO4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SECINFO); } @@ -290,7 +290,7 @@ void NFSv41BreakdownAnalyzer::secinfo41(const RPCProcedure* proc, const NFS41::S void NFSv41BreakdownAnalyzer::setattr41(const RPCProcedure* proc, const NFS41::SETATTR4args*, const NFS41::SETATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SETATTR); } @@ -298,7 +298,7 @@ void NFSv41BreakdownAnalyzer::setattr41(const RPCProcedure* proc, const NFS41::S void NFSv41BreakdownAnalyzer::setclientid41(const RPCProcedure* proc, const NFS41::SETCLIENTID4args*, const NFS41::SETCLIENTID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SETCLIENTID); } @@ -306,7 +306,7 @@ void NFSv41BreakdownAnalyzer::setclientid41(const RPCProcedure* proc, const NFS4 void NFSv41BreakdownAnalyzer::setclientid_confirm41(const RPCProcedure* proc, const NFS41::SETCLIENTID_CONFIRM4args*, const NFS41::SETCLIENTID_CONFIRM4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SETCLIENTID_CONFIRM); } @@ -314,7 +314,7 @@ void NFSv41BreakdownAnalyzer::setclientid_confirm41(const RPCProcedure* proc, co void NFSv41BreakdownAnalyzer::verify41(const RPCProcedure* proc, const NFS41::VERIFY4args*, const NFS41::VERIFY4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::VERIFY); } @@ -322,7 +322,7 @@ void NFSv41BreakdownAnalyzer::verify41(const RPCProcedure* proc, const NFS41::VE void NFSv41BreakdownAnalyzer::write41(const RPCProcedure* proc, const NFS41::WRITE4args*, const NFS41::WRITE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::WRITE); } @@ -330,7 +330,7 @@ void NFSv41BreakdownAnalyzer::write41(const RPCProcedure* proc, const NFS41::WRI void NFSv41BreakdownAnalyzer::release_lockowner41(const RPCProcedure* proc, const NFS41::RELEASE_LOCKOWNER4args*, const NFS41::RELEASE_LOCKOWNER4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::RELEASE_LOCKOWNER); } @@ -338,7 +338,7 @@ void NFSv41BreakdownAnalyzer::release_lockowner41(const RPCProcedure* proc, cons void NFSv41BreakdownAnalyzer::backchannel_ctl41(const RPCProcedure* proc, const NFS41::BACKCHANNEL_CTL4args*, const NFS41::BACKCHANNEL_CTL4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::BACKCHANNEL_CTL); } @@ -346,7 +346,7 @@ void NFSv41BreakdownAnalyzer::backchannel_ctl41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::bind_conn_to_session41(const RPCProcedure* proc, const NFS41::BIND_CONN_TO_SESSION4args*, const NFS41::BIND_CONN_TO_SESSION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::BIND_CONN_TO_SESSION); } @@ -354,7 +354,7 @@ void NFSv41BreakdownAnalyzer::bind_conn_to_session41(const RPCProcedure* proc, c void NFSv41BreakdownAnalyzer::exchange_id41(const RPCProcedure* proc, const NFS41::EXCHANGE_ID4args*, const NFS41::EXCHANGE_ID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::EXCHANGE_ID); } @@ -362,7 +362,7 @@ void NFSv41BreakdownAnalyzer::exchange_id41(const RPCProcedure* proc, const NFS4 void NFSv41BreakdownAnalyzer::create_session41(const RPCProcedure* proc, const NFS41::CREATE_SESSION4args*, const NFS41::CREATE_SESSION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::CREATE_SESSION); } @@ -370,7 +370,7 @@ void NFSv41BreakdownAnalyzer::create_session41(const RPCProcedure* proc, const N void NFSv41BreakdownAnalyzer::destroy_session41(const RPCProcedure* proc, const NFS41::DESTROY_SESSION4args*, const NFS41::DESTROY_SESSION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::DESTROY_SESSION); } @@ -378,7 +378,7 @@ void NFSv41BreakdownAnalyzer::destroy_session41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::free_stateid41(const RPCProcedure* proc, const NFS41::FREE_STATEID4args*, const NFS41::FREE_STATEID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::FREE_STATEID); } @@ -386,7 +386,7 @@ void NFSv41BreakdownAnalyzer::free_stateid41(const RPCProcedure* proc, const NFS void NFSv41BreakdownAnalyzer::get_dir_delegation41(const RPCProcedure* proc, const NFS41::GET_DIR_DELEGATION4args*, const NFS41::GET_DIR_DELEGATION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::GET_DIR_DELEGATION); } @@ -394,7 +394,7 @@ void NFSv41BreakdownAnalyzer::get_dir_delegation41(const RPCProcedure* proc, con void NFSv41BreakdownAnalyzer::getdeviceinfo41(const RPCProcedure* proc, const NFS41::GETDEVICEINFO4args*, const NFS41::GETDEVICEINFO4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::GETDEVICEINFO); } @@ -402,7 +402,7 @@ void NFSv41BreakdownAnalyzer::getdeviceinfo41(const RPCProcedure* proc, const NF void NFSv41BreakdownAnalyzer::getdevicelist41(const RPCProcedure* proc, const NFS41::GETDEVICELIST4args*, const NFS41::GETDEVICELIST4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::GETDEVICELIST); } @@ -410,7 +410,7 @@ void NFSv41BreakdownAnalyzer::getdevicelist41(const RPCProcedure* proc, const NF void NFSv41BreakdownAnalyzer::layoutcommit41(const RPCProcedure* proc, const NFS41::LAYOUTCOMMIT4args*, const NFS41::LAYOUTCOMMIT4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTCOMMIT); } @@ -418,7 +418,7 @@ void NFSv41BreakdownAnalyzer::layoutcommit41(const RPCProcedure* proc, const NFS void NFSv41BreakdownAnalyzer::layoutget41(const RPCProcedure* proc, const NFS41::LAYOUTGET4args*, const NFS41::LAYOUTGET4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTGET); } @@ -426,7 +426,7 @@ void NFSv41BreakdownAnalyzer::layoutget41(const RPCProcedure* proc, const NFS41: void NFSv41BreakdownAnalyzer::layoutreturn41(const RPCProcedure* proc, const NFS41::LAYOUTRETURN4args*, const NFS41::LAYOUTRETURN4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::LAYOUTRETURN); } @@ -434,7 +434,7 @@ void NFSv41BreakdownAnalyzer::layoutreturn41(const RPCProcedure* proc, const NFS void NFSv41BreakdownAnalyzer::secinfo_no_name41(const RPCProcedure* proc, const NFS41::SECINFO_NO_NAME4args*, const NFS41::SECINFO_NO_NAME4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SECINFO_NO_NAME); } @@ -442,7 +442,7 @@ void NFSv41BreakdownAnalyzer::secinfo_no_name41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::sequence41(const RPCProcedure* proc, const NFS41::SEQUENCE4args*, const NFS41::SEQUENCE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SEQUENCE); } @@ -450,7 +450,7 @@ void NFSv41BreakdownAnalyzer::sequence41(const RPCProcedure* proc, const NFS41:: void NFSv41BreakdownAnalyzer::set_ssv41(const RPCProcedure* proc, const NFS41::SET_SSV4args*, const NFS41::SET_SSV4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::SET_SSV); } @@ -458,7 +458,7 @@ void NFSv41BreakdownAnalyzer::set_ssv41(const RPCProcedure* proc, const NFS41::S void NFSv41BreakdownAnalyzer::test_stateid41(const RPCProcedure* proc, const NFS41::TEST_STATEID4args*, const NFS41::TEST_STATEID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::TEST_STATEID); } @@ -466,7 +466,7 @@ void NFSv41BreakdownAnalyzer::test_stateid41(const RPCProcedure* proc, const NFS void NFSv41BreakdownAnalyzer::want_delegation41(const RPCProcedure* proc, const NFS41::WANT_DELEGATION4args*, const NFS41::WANT_DELEGATION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::WANT_DELEGATION); } @@ -474,7 +474,7 @@ void NFSv41BreakdownAnalyzer::want_delegation41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::destroy_clientid41(const RPCProcedure* proc, const NFS41::DESTROY_CLIENTID4args*, const NFS41::DESTROY_CLIENTID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::DESTROY_CLIENTID); } @@ -482,7 +482,7 @@ void NFSv41BreakdownAnalyzer::destroy_clientid41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::reclaim_complete41(const RPCProcedure* proc, const NFS41::RECLAIM_COMPLETE4args*, const NFS41::RECLAIM_COMPLETE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::RECLAIM_COMPLETE); } @@ -490,7 +490,7 @@ void NFSv41BreakdownAnalyzer::reclaim_complete41(const RPCProcedure* proc, const void NFSv41BreakdownAnalyzer::illegal41(const RPCProcedure* proc, const NFS41::ILLEGAL4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS41::NFSProcedure::ILLEGAL); } diff --git a/analyzers/src/breakdown/nfsv41breakdownanalyzer.h b/analyzers/src/breakdown/nfsv41breakdownanalyzer.h index f5f1f9b..2221db6 100644 --- a/analyzers/src/breakdown/nfsv41breakdownanalyzer.h +++ b/analyzers/src/breakdown/nfsv41breakdownanalyzer.h @@ -31,19 +31,18 @@ namespace NST { namespace breakdown { - /*! \brief Analyzer for NFS v4.1 * Handles NFS v4.1 commands */ class NFSv41BreakdownAnalyzer : virtual public IAnalyzer { - Statistics compound_stats; //!< Statistics - Statistics stats; //!< Statistics - NFSv4Representer representer; //!< Class for statistics representation + Statistics compound_stats; //!< Statistics + Statistics stats; //!< Statistics + NFSv4Representer representer; //!< Class for statistics representation public: NFSv41BreakdownAnalyzer(std::ostream& o = std::cout); // NFSv4.1 procedures - void compound41(const RPCProcedure* proc, + void compound41(const RPCProcedure* proc, const struct NFS41::COMPOUND4args*, const struct NFS41::COMPOUND4res*) override final; // NFSv4.1 operations @@ -69,7 +68,7 @@ public: void getattr41(const RPCProcedure* proc, const struct NFS41::GETATTR4args*, const struct NFS41::GETATTR4res* res) override final; - void getfh41(const RPCProcedure* proc, + void getfh41(const RPCProcedure* proc, const struct NFS41::GETFH4res* res) override final; void link41(const RPCProcedure* proc, const struct NFS41::LINK4args*, @@ -86,7 +85,7 @@ public: void lookup41(const RPCProcedure* proc, const struct NFS41::LOOKUP4args*, const struct NFS41::LOOKUP4res* res) override final; - void lookupp41(const RPCProcedure* proc, + void lookupp41(const RPCProcedure* proc, const struct NFS41::LOOKUPP4res* res) override final; void nverify41(const RPCProcedure* proc, const struct NFS41::NVERIFY4args*, @@ -106,9 +105,9 @@ public: void putfh41(const RPCProcedure* proc, const struct NFS41::PUTFH4args*, const struct NFS41::PUTFH4res* res) override final; - void putpubfh41(const RPCProcedure* proc, + void putpubfh41(const RPCProcedure* proc, const struct NFS41::PUTPUBFH4res* res) override final; - void putrootfh41(const RPCProcedure* proc, + void putrootfh41(const RPCProcedure* proc, const struct NFS41::PUTROOTFH4res* res) override final; void read41(const RPCProcedure* proc, const struct NFS41::READ4args*, @@ -116,7 +115,7 @@ public: void readdir41(const RPCProcedure* proc, const struct NFS41::READDIR4args*, const struct NFS41::READDIR4res* res) override final; - void readlink41(const RPCProcedure* proc, + void readlink41(const RPCProcedure* proc, const struct NFS41::READLINK4res* res) override final; void remove41(const RPCProcedure* proc, const struct NFS41::REMOVE4args*, @@ -127,9 +126,9 @@ public: void renew41(const RPCProcedure* proc, const struct NFS41::RENEW4args*, const struct NFS41::RENEW4res* res) override final; - void restorefh41(const RPCProcedure* proc, + void restorefh41(const RPCProcedure* proc, const struct NFS41::RESTOREFH4res* res) override final; - void savefh41(const RPCProcedure* proc, + void savefh41(const RPCProcedure* proc, const struct NFS41::SAVEFH4res* res) override final; void secinfo41(const RPCProcedure* proc, const struct NFS41::SECINFO4args*, @@ -209,7 +208,7 @@ public: void reclaim_complete41(const RPCProcedure* proc, const struct NFS41::RECLAIM_COMPLETE4args*, const struct NFS41::RECLAIM_COMPLETE4res* res) override final; - void illegal41(const RPCProcedure* proc, + void illegal41(const RPCProcedure* proc, const struct NFS41::ILLEGAL4res* res) override final; void flush_statistics() override; @@ -218,5 +217,5 @@ public: } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV41BREAKDOWNANALYZER_H +#endif //NFSV41BREAKDOWNANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv41commands.h b/analyzers/src/breakdown/nfsv41commands.h index 97c7c9c..fce94fd 100644 --- a/analyzers/src/breakdown/nfsv41commands.h +++ b/analyzers/src/breakdown/nfsv41commands.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * Represents NFS v 4.0 commands * Converts commands to string @@ -39,11 +38,11 @@ public: const char* command_description(int cmd_code); const char* command_name(int cmd_code); const char* protocol_name(); - size_t commands_count(); + size_t commands_count(); }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV41COMMANDS_H +#endif //NFSV41COMMANDS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv4breakdownanalyzer.cpp b/analyzers/src/breakdown/nfsv4breakdownanalyzer.cpp index b9f37af..5ac6641 100644 --- a/analyzers/src/breakdown/nfsv4breakdownanalyzer.cpp +++ b/analyzers/src/breakdown/nfsv4breakdownanalyzer.cpp @@ -49,7 +49,7 @@ void NFSv4BreakdownAnalyzer::compound4(const RPCProcedure* proc, const NFS4::COM void NFSv4BreakdownAnalyzer::access40(const RPCProcedure* proc, const NFS4::ACCESS4args*, const NFS4::ACCESS4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::ACCESS); } @@ -57,7 +57,7 @@ void NFSv4BreakdownAnalyzer::access40(const RPCProcedure* proc, const NFS4::ACCE void NFSv4BreakdownAnalyzer::close40(const RPCProcedure* proc, const NFS4::CLOSE4args*, const NFS4::CLOSE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::CLOSE); } @@ -65,7 +65,7 @@ void NFSv4BreakdownAnalyzer::close40(const RPCProcedure* proc, const NFS4::CLOSE void NFSv4BreakdownAnalyzer::commit40(const RPCProcedure* proc, const NFS4::COMMIT4args*, const NFS4::COMMIT4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::COMMIT); } @@ -73,7 +73,7 @@ void NFSv4BreakdownAnalyzer::commit40(const RPCProcedure* proc, const NFS4::COMM void NFSv4BreakdownAnalyzer::create40(const RPCProcedure* proc, const NFS4::CREATE4args*, const NFS4::CREATE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::CREATE); } @@ -81,7 +81,7 @@ void NFSv4BreakdownAnalyzer::create40(const RPCProcedure* proc, const NFS4::CREA void NFSv4BreakdownAnalyzer::delegpurge40(const RPCProcedure* proc, const NFS4::DELEGPURGE4args*, const NFS4::DELEGPURGE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::DELEGPURGE); } @@ -89,7 +89,7 @@ void NFSv4BreakdownAnalyzer::delegpurge40(const RPCProcedure* proc, const NFS4:: void NFSv4BreakdownAnalyzer::delegreturn40(const RPCProcedure* proc, const NFS4::DELEGRETURN4args*, const NFS4::DELEGRETURN4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::DELEGRETURN); } @@ -97,7 +97,7 @@ void NFSv4BreakdownAnalyzer::delegreturn40(const RPCProcedure* proc, const NFS4: void NFSv4BreakdownAnalyzer::getattr40(const RPCProcedure* proc, const NFS4::GETATTR4args*, const NFS4::GETATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::GETATTR); } @@ -105,7 +105,7 @@ void NFSv4BreakdownAnalyzer::getattr40(const RPCProcedure* proc, const NFS4::GET void NFSv4BreakdownAnalyzer::getfh40(const RPCProcedure* proc, const NFS4::GETFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::GETFH); } @@ -113,7 +113,7 @@ void NFSv4BreakdownAnalyzer::getfh40(const RPCProcedure* proc, const NFS4::GETFH void NFSv4BreakdownAnalyzer::link40(const RPCProcedure* proc, const NFS4::LINK4args*, const NFS4::LINK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LINK); } @@ -121,7 +121,7 @@ void NFSv4BreakdownAnalyzer::link40(const RPCProcedure* proc, const NFS4::LINK4a void NFSv4BreakdownAnalyzer::lock40(const RPCProcedure* proc, const NFS4::LOCK4args*, const NFS4::LOCK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCK); } @@ -129,7 +129,7 @@ void NFSv4BreakdownAnalyzer::lock40(const RPCProcedure* proc, const NFS4::LOCK4a void NFSv4BreakdownAnalyzer::lockt40(const RPCProcedure* proc, const NFS4::LOCKT4args*, const NFS4::LOCKT4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCKT); } @@ -137,7 +137,7 @@ void NFSv4BreakdownAnalyzer::lockt40(const RPCProcedure* proc, const NFS4::LOCKT void NFSv4BreakdownAnalyzer::locku40(const RPCProcedure* proc, const NFS4::LOCKU4args*, const NFS4::LOCKU4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LOCKU); } @@ -145,7 +145,7 @@ void NFSv4BreakdownAnalyzer::locku40(const RPCProcedure* proc, const NFS4::LOCKU void NFSv4BreakdownAnalyzer::lookup40(const RPCProcedure* proc, const NFS4::LOOKUP4args*, const NFS4::LOOKUP4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LOOKUP); } @@ -153,7 +153,7 @@ void NFSv4BreakdownAnalyzer::lookup40(const RPCProcedure* proc, const NFS4::LOOK void NFSv4BreakdownAnalyzer::lookupp40(const RPCProcedure* proc, const NFS4::LOOKUPP4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::LOOKUPP); } @@ -161,7 +161,7 @@ void NFSv4BreakdownAnalyzer::lookupp40(const RPCProcedure* proc, const NFS4::LOO void NFSv4BreakdownAnalyzer::nverify40(const RPCProcedure* proc, const NFS4::NVERIFY4args*, const NFS4::NVERIFY4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::NVERIFY); } @@ -169,7 +169,7 @@ void NFSv4BreakdownAnalyzer::nverify40(const RPCProcedure* proc, const NFS4::NVE void NFSv4BreakdownAnalyzer::open40(const RPCProcedure* proc, const NFS4::OPEN4args*, const NFS4::OPEN4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN); } @@ -177,7 +177,7 @@ void NFSv4BreakdownAnalyzer::open40(const RPCProcedure* proc, const NFS4::OPEN4a void NFSv4BreakdownAnalyzer::openattr40(const RPCProcedure* proc, const NFS4::OPENATTR4args*, const NFS4::OPENATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::OPENATTR); } @@ -185,7 +185,7 @@ void NFSv4BreakdownAnalyzer::openattr40(const RPCProcedure* proc, const NFS4::OP void NFSv4BreakdownAnalyzer::open_confirm40(const RPCProcedure* proc, const NFS4::OPEN_CONFIRM4args*, const NFS4::OPEN_CONFIRM4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN_CONFIRM); } @@ -193,7 +193,7 @@ void NFSv4BreakdownAnalyzer::open_confirm40(const RPCProcedure* proc, const NFS4 void NFSv4BreakdownAnalyzer::open_downgrade40(const RPCProcedure* proc, const NFS4::OPEN_DOWNGRADE4args*, const NFS4::OPEN_DOWNGRADE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::OPEN_DOWNGRADE); } @@ -201,7 +201,7 @@ void NFSv4BreakdownAnalyzer::open_downgrade40(const RPCProcedure* proc, const NF void NFSv4BreakdownAnalyzer::putfh40(const RPCProcedure* proc, const NFS4::PUTFH4args*, const NFS4::PUTFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTFH); } @@ -209,7 +209,7 @@ void NFSv4BreakdownAnalyzer::putfh40(const RPCProcedure* proc, const NFS4::PUTFH void NFSv4BreakdownAnalyzer::putpubfh40(const RPCProcedure* proc, const NFS4::PUTPUBFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTPUBFH); } @@ -217,7 +217,7 @@ void NFSv4BreakdownAnalyzer::putpubfh40(const RPCProcedure* proc, const NFS4::PU void NFSv4BreakdownAnalyzer::putrootfh40(const RPCProcedure* proc, const NFS4::PUTROOTFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::PUTROOTFH); } @@ -225,7 +225,7 @@ void NFSv4BreakdownAnalyzer::putrootfh40(const RPCProcedure* proc, const NFS4::P void NFSv4BreakdownAnalyzer::read40(const RPCProcedure* proc, const NFS4::READ4args*, const NFS4::READ4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::READ); } @@ -233,7 +233,7 @@ void NFSv4BreakdownAnalyzer::read40(const RPCProcedure* proc, const NFS4::READ4a void NFSv4BreakdownAnalyzer::readdir40(const RPCProcedure* proc, const NFS4::READDIR4args*, const NFS4::READDIR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::READDIR); } @@ -241,7 +241,7 @@ void NFSv4BreakdownAnalyzer::readdir40(const RPCProcedure* proc, const NFS4::REA void NFSv4BreakdownAnalyzer::readlink40(const RPCProcedure* proc, const NFS4::READLINK4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::READLINK); } @@ -249,7 +249,7 @@ void NFSv4BreakdownAnalyzer::readlink40(const RPCProcedure* proc, const NFS4::RE void NFSv4BreakdownAnalyzer::remove40(const RPCProcedure* proc, const NFS4::REMOVE4args*, const NFS4::REMOVE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::REMOVE); } @@ -257,7 +257,7 @@ void NFSv4BreakdownAnalyzer::remove40(const RPCProcedure* proc, const NFS4::REMO void NFSv4BreakdownAnalyzer::rename40(const RPCProcedure* proc, const NFS4::RENAME4args*, const NFS4::RENAME4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::RENAME); } @@ -265,7 +265,7 @@ void NFSv4BreakdownAnalyzer::rename40(const RPCProcedure* proc, const NFS4::RENA void NFSv4BreakdownAnalyzer::renew40(const RPCProcedure* proc, const NFS4::RENEW4args*, const NFS4::RENEW4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::RENEW); } @@ -273,7 +273,7 @@ void NFSv4BreakdownAnalyzer::renew40(const RPCProcedure* proc, const NFS4::RENEW void NFSv4BreakdownAnalyzer::restorefh40(const RPCProcedure* proc, const NFS4::RESTOREFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::RESTOREFH); } @@ -281,7 +281,7 @@ void NFSv4BreakdownAnalyzer::restorefh40(const RPCProcedure* proc, const NFS4::R void NFSv4BreakdownAnalyzer::savefh40(const RPCProcedure* proc, const NFS4::SAVEFH4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::SAVEFH); } @@ -289,7 +289,7 @@ void NFSv4BreakdownAnalyzer::savefh40(const RPCProcedure* proc, const NFS4::SAVE void NFSv4BreakdownAnalyzer::secinfo40(const RPCProcedure* proc, const NFS4::SECINFO4args*, const NFS4::SECINFO4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::SECINFO); } @@ -297,7 +297,7 @@ void NFSv4BreakdownAnalyzer::secinfo40(const RPCProcedure* proc, const NFS4::SEC void NFSv4BreakdownAnalyzer::setattr40(const RPCProcedure* proc, const NFS4::SETATTR4args*, const NFS4::SETATTR4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::SETATTR); } @@ -305,7 +305,7 @@ void NFSv4BreakdownAnalyzer::setattr40(const RPCProcedure* proc, const NFS4::SET void NFSv4BreakdownAnalyzer::setclientid40(const RPCProcedure* proc, const NFS4::SETCLIENTID4args*, const NFS4::SETCLIENTID4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::SETCLIENTID); } @@ -313,7 +313,7 @@ void NFSv4BreakdownAnalyzer::setclientid40(const RPCProcedure* proc, const NFS4: void NFSv4BreakdownAnalyzer::setclientid_confirm40(const RPCProcedure* proc, const NFS4::SETCLIENTID_CONFIRM4args*, const NFS4::SETCLIENTID_CONFIRM4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::SETCLIENTID_CONFIRM); } @@ -321,7 +321,7 @@ void NFSv4BreakdownAnalyzer::setclientid_confirm40(const RPCProcedure* proc, con void NFSv4BreakdownAnalyzer::verify40(const RPCProcedure* proc, const NFS4::VERIFY4args*, const NFS4::VERIFY4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::VERIFY); } @@ -329,7 +329,7 @@ void NFSv4BreakdownAnalyzer::verify40(const RPCProcedure* proc, const NFS4::VERI void NFSv4BreakdownAnalyzer::write40(const RPCProcedure* proc, const NFS4::WRITE4args*, const NFS4::WRITE4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::WRITE); } @@ -337,7 +337,7 @@ void NFSv4BreakdownAnalyzer::write40(const RPCProcedure* proc, const NFS4::WRITE void NFSv4BreakdownAnalyzer::release_lockowner40(const RPCProcedure* proc, const NFS4::RELEASE_LOCKOWNER4args*, const NFS4::RELEASE_LOCKOWNER4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::RELEASE_LOCKOWNER); } @@ -345,7 +345,7 @@ void NFSv4BreakdownAnalyzer::release_lockowner40(const RPCProcedure* proc, const void NFSv4BreakdownAnalyzer::get_dir_delegation40(const RPCProcedure* proc, const NFS4::GET_DIR_DELEGATION4args*, const NFS4::GET_DIR_DELEGATION4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::GET_DIR_DELEGATION); } @@ -353,7 +353,7 @@ void NFSv4BreakdownAnalyzer::get_dir_delegation40(const RPCProcedure* proc, cons void NFSv4BreakdownAnalyzer::illegal40(const RPCProcedure* proc, const NFS4::ILLEGAL4res* res) { - if (res) + if(res) { stats.account(proc, ProcEnumNFS4::NFSProcedure::ILLEGAL); } diff --git a/analyzers/src/breakdown/nfsv4breakdownanalyzer.h b/analyzers/src/breakdown/nfsv4breakdownanalyzer.h index 14275e6..c74cdc4 100644 --- a/analyzers/src/breakdown/nfsv4breakdownanalyzer.h +++ b/analyzers/src/breakdown/nfsv4breakdownanalyzer.h @@ -31,7 +31,6 @@ namespace NST { namespace breakdown { - /*! \brief Analyzer for NFS v4 * Handles NFS v4 commands */ @@ -39,9 +38,9 @@ class NFSv4BreakdownAnalyzer : virtual public IAnalyzer { protected: private: - Statistics compound_stats; //!< Statistics - Statistics stats; //!< Statistics - NFSv4Representer representer; //!< stream to output + Statistics compound_stats; //!< Statistics + Statistics stats; //!< Statistics + NFSv4Representer representer; //!< stream to output public: NFSv4BreakdownAnalyzer(std::ostream& o = std::cout); @@ -50,7 +49,7 @@ public: void null4(const RPCProcedure* proc, const struct NFS4::NULL4args*, const struct NFS4::NULL4res*) override final; - void compound4(const RPCProcedure* proc, + void compound4(const RPCProcedure* proc, const struct NFS4::COMPOUND4args*, const struct NFS4::COMPOUND4res*) override final; @@ -78,7 +77,7 @@ public: void getattr40(const RPCProcedure* proc, const struct NFS4::GETATTR4args*, const struct NFS4::GETATTR4res* res) override final; - void getfh40(const RPCProcedure* proc, + void getfh40(const RPCProcedure* proc, const struct NFS4::GETFH4res* res) override final; void link40(const RPCProcedure* proc, const struct NFS4::LINK4args*, @@ -95,7 +94,7 @@ public: void lookup40(const RPCProcedure* proc, const struct NFS4::LOOKUP4args*, const struct NFS4::LOOKUP4res* res) override final; - void lookupp40(const RPCProcedure* proc, + void lookupp40(const RPCProcedure* proc, const struct NFS4::LOOKUPP4res* res) override final; void nverify40(const RPCProcedure* proc, const struct NFS4::NVERIFY4args*, @@ -115,9 +114,9 @@ public: void putfh40(const RPCProcedure* proc, const struct NFS4::PUTFH4args*, const struct NFS4::PUTFH4res* res) override final; - void putpubfh40(const RPCProcedure* proc, + void putpubfh40(const RPCProcedure* proc, const struct NFS4::PUTPUBFH4res* res) override final; - void putrootfh40(const RPCProcedure* proc, + void putrootfh40(const RPCProcedure* proc, const struct NFS4::PUTROOTFH4res* res) override final; void read40(const RPCProcedure* proc, const struct NFS4::READ4args*, @@ -125,7 +124,7 @@ public: void readdir40(const RPCProcedure* proc, const struct NFS4::READDIR4args*, const struct NFS4::READDIR4res* res) override final; - void readlink40(const RPCProcedure* proc, + void readlink40(const RPCProcedure* proc, const struct NFS4::READLINK4res* res) override final; void remove40(const RPCProcedure* proc, const struct NFS4::REMOVE4args*, @@ -136,9 +135,9 @@ public: void renew40(const RPCProcedure* proc, const struct NFS4::RENEW4args*, const struct NFS4::RENEW4res* res) override final; - void restorefh40(const RPCProcedure* proc, + void restorefh40(const RPCProcedure* proc, const struct NFS4::RESTOREFH4res* res) override final; - void savefh40(const RPCProcedure* proc, + void savefh40(const RPCProcedure* proc, const struct NFS4::SAVEFH4res* res) override final; void secinfo40(const RPCProcedure* proc, const struct NFS4::SECINFO4args*, @@ -164,7 +163,7 @@ public: void get_dir_delegation40(const RPCProcedure* proc, const struct NFS4::GET_DIR_DELEGATION4args*, const struct NFS4::GET_DIR_DELEGATION4res* res) override final; - void illegal40(const RPCProcedure* proc, + void illegal40(const RPCProcedure* proc, const struct NFS4::ILLEGAL4res* res) override final; void flush_statistics() override; }; @@ -172,5 +171,5 @@ public: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV4BREAKDOWNANALYZER_H +#endif //NFSV4BREAKDOWNANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv4commands.h b/analyzers/src/breakdown/nfsv4commands.h index 2fcfa0e..ac2789e 100644 --- a/analyzers/src/breakdown/nfsv4commands.h +++ b/analyzers/src/breakdown/nfsv4commands.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /*! * Represents NFS v 4.0 commands * Converts commands to string @@ -38,12 +37,12 @@ class NFSv4Commands : public CommandRepresenter public: const char* command_description(int cmd_code) override final; const char* command_name(int cmd_code) override final; - size_t commands_count() override final; - const char* protocol_name(); + size_t commands_count() override final; + const char* protocol_name() override final; }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV4COMMANDS_H +#endif //NFSV4COMMANDS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/nfsv4representer.cpp b/analyzers/src/breakdown/nfsv4representer.cpp index e6410b6..beac005 100644 --- a/analyzers/src/breakdown/nfsv4representer.cpp +++ b/analyzers/src/breakdown/nfsv4representer.cpp @@ -24,20 +24,21 @@ using namespace NST::breakdown; //------------------------------------------------------------------------------ NFSv4Representer::NFSv4Representer(std::ostream& o, CommandRepresenter* cmdRep, size_t space_for_cmd_name, size_t count_of_compounds) - : Representer(o, cmdRep, space_for_cmd_name), count_of_compounds(count_of_compounds) + : Representer(o, cmdRep, space_for_cmd_name) + , count_of_compounds(count_of_compounds) { } void NFSv4Representer::onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const { - if (procedure == 0) + if(procedure == 0) { o << "Total procedures: " << breakdown.get_total_count() - << ". Per procedure:" << std::endl; + << ". Per procedure:" << std::endl; } - if (procedure == count_of_compounds) + if(procedure == count_of_compounds) { o << "Total operations: " << breakdown.get_total_count() - << ". Per operation:" << std::endl; + << ". Per operation:" << std::endl; } } diff --git a/analyzers/src/breakdown/nfsv4representer.h b/analyzers/src/breakdown/nfsv4representer.h index 5bda9b1..105aaa7 100644 --- a/analyzers/src/breakdown/nfsv4representer.h +++ b/analyzers/src/breakdown/nfsv4representer.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /** * @brief The NFSv4Representer class * Splits output into commands/operations lists for NFS v4.* protocols @@ -36,6 +35,7 @@ namespace breakdown class NFSv4Representer : public Representer { const size_t count_of_compounds; + public: NFSv4Representer(std::ostream& o, CommandRepresenter* cmdRep, size_t space_for_cmd_name, size_t count_of_compounds); void onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const override final; @@ -44,5 +44,5 @@ public: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//NFSV4REPRESENTER_H +#endif //NFSV4REPRESENTER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/representer.cpp b/analyzers/src/breakdown/representer.cpp index ca33062..9f402a5 100644 --- a/analyzers/src/breakdown/representer.cpp +++ b/analyzers/src/breakdown/representer.cpp @@ -36,36 +36,33 @@ NST::breakdown::Representer::Representer(std::ostream& o, NST::breakdown::Comman void Representer::flush_statistics(const Statistics& statistics) { - out << "### Breakdown analyzer ###" - << std::endl - << cmd_representer->protocol_name() - << " protocol" - << std::endl; + out << "### Breakdown analyzer ###" << std::endl + << cmd_representer->protocol_name() << " protocol"; - statistics.for_each_procedure([&](const BreakdownCounter& breakdown, size_t procedure) + if(statistics.has_session()) { - onProcedureInfoPrinted(out, breakdown, procedure); - size_t procedure_count = breakdown[procedure].get_count(); - out.width(space_for_cmd_name); - out << std::left - << cmd_representer->command_name(procedure); - out.width(5); - out << std::right - << procedure_count; - out.width(7); - out.setf(std::ios::fixed, std::ios::floatfield); - out.precision(2); - out << (breakdown.get_total_count() ? ((1.0 * procedure_count / breakdown.get_total_count()) * 100.0) : 0); - out.setf(std::ios::fixed | std::ios::scientific , std::ios::floatfield); - out << '%' << std::endl; - }); + out << std::endl; + + statistics.for_each_procedure([&](const BreakdownCounter& breakdown, size_t procedure) { + onProcedureInfoPrinted(out, breakdown, procedure); + size_t procedure_count = breakdown[procedure].get_count(); + out.width(space_for_cmd_name); + out << std::left + << cmd_representer->command_name(procedure); + out.width(5); + out << std::right + << procedure_count; + out.width(7); + out.setf(std::ios::fixed, std::ios::floatfield); + out.precision(2); + out << (breakdown.get_total_count() ? ((1.0 * procedure_count / breakdown.get_total_count()) * 100.0) : 0); + out.setf(std::ios::fixed | std::ios::scientific, std::ios::floatfield); + out << '%' << std::endl; + }); - if (statistics.has_session()) // is not empty? - { out << "Per connection info: " << std::endl; - statistics.for_each_session([&](const Session& session) - { + statistics.for_each_session([&](const Session& session) { std::stringstream ssession; print_session(ssession, session); print_per_session(statistics, session, ssession.str()); @@ -73,6 +70,10 @@ void Representer::flush_statistics(const Statistics& statistics) store_per_session(file, statistics, session, ssession.str()); }); } + else + { + out << ": Data transmission has not been detected." << std::endl; + } } void Representer::store_per_session(std::ostream& file, const Statistics& statistics, const Session& session, const std::string& ssession) const @@ -80,8 +81,7 @@ void Representer::store_per_session(std::ostream& file, const Statistics& statis //TODO: does it make sense to join store_per_session & print_per_session? file << "Session: " << ssession << std::endl; - statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) - { + statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) { uint64_t s_total_proc = breakdown.get_total_count(); file << cmd_representer->command_name(procedure); file << ' ' << breakdown[procedure].get_count() << ' '; @@ -98,8 +98,7 @@ void Representer::print_per_session(const Statistics& statistics, const Session& { out << "Session: " << ssession << std::endl; - statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) - { + statistics.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t procedure) { uint64_t s_total_proc = breakdown.get_total_count(); onProcedureInfoPrinted(out, breakdown, procedure); out.width(22); @@ -136,10 +135,10 @@ void Representer::print_per_session(const Statistics& statistics, const Session& void Representer::onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const { - if (procedure == 0) + if(procedure == 0) { o << "Total operations: " << breakdown.get_total_count() - << ". Per operation:" << std::endl; + << ". Per operation:" << std::endl; } } //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/representer.h b/analyzers/src/breakdown/representer.h index 3a216ca..edde03d 100644 --- a/analyzers/src/breakdown/representer.h +++ b/analyzers/src/breakdown/representer.h @@ -25,29 +25,29 @@ #include <memory> #include <ostream> -#include "commandrepresenter.h" #include "breakdowncounter.h" +#include "commandrepresenter.h" #include "statistics.h" //------------------------------------------------------------------------------ namespace NST { namespace breakdown { - /*! \class Represents statistics and sends it to screen */ class Representer { - std::ostream& out; + std::ostream& out; std::unique_ptr<CommandRepresenter> cmd_representer; - size_t space_for_cmd_name; + size_t space_for_cmd_name; - void store_per_session(std::ostream& file, - const Statistics& statistics, - const Session& session, + void store_per_session(std::ostream& file, + const Statistics& statistics, + const Session& session, const std::string& ssession) const; void print_per_session(const Statistics& statistics, const Session& session, const std::string& ssession) const; + protected: /** * @brief handler of one procedure output event @@ -56,6 +56,7 @@ protected: * @param procedure - procedure ID */ virtual void onProcedureInfoPrinted(std::ostream& o, const BreakdownCounter& breakdown, unsigned procedure) const; + public: /** * @brief Representer's constructor @@ -75,5 +76,5 @@ public: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//REPRESENTER_H +#endif //REPRESENTER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/statistics.cpp b/analyzers/src/breakdown/statistics.cpp index 5cbf51b..c392ac1 100644 --- a/analyzers/src/breakdown/statistics.cpp +++ b/analyzers/src/breakdown/statistics.cpp @@ -25,15 +25,13 @@ using namespace NST::breakdown; //------------------------------------------------------------------------------ bool Less::operator()(const Session& a, const Session& b) const { - return ( (std::uint16_t)(a.ip_type) < (std::uint16_t)(b.ip_type) ) || // compare versions of IP address - ( ntohs(a.port[0]) < ntohs(b.port[0]) ) || // compare Source(client) ports - ( ntohs(a.port[1]) < ntohs(b.port[1]) ) || // compare Destination(server) ports + return ((std::uint16_t)(a.ip_type) < (std::uint16_t)(b.ip_type)) || // compare versions of IP address + (ntohs(a.port[0]) < ntohs(b.port[0])) || // compare Source(client) ports + (ntohs(a.port[1]) < ntohs(b.port[1])) || // compare Destination(server) ports - ( (a.ip_type == Session::IPType::v4) ? // compare IPv4 - ((ntohl(a.ip.v4.addr[0]) < ntohl(b.ip.v4.addr[0])) || (ntohl(a.ip.v4.addr[1]) < ntohl(b.ip.v4.addr[1]))) - : - (memcmp(&a.ip.v6, &b.ip.v6, sizeof(a.ip.v6)) < 0 ) - ); + ((a.ip_type == Session::IPType::v4) ? // compare IPv4 + ((ntohl(a.ip.v4.addr[0]) < ntohl(b.ip.v4.addr[0])) || (ntohl(a.ip.v4.addr[1]) < ntohl(b.ip.v4.addr[1]))) + : (memcmp(&a.ip.v6, &b.ip.v6, sizeof(a.ip.v6)) < 0)); } Statistics::Statistics(size_t proc_types_count) @@ -42,31 +40,31 @@ Statistics::Statistics(size_t proc_types_count) { } -void Statistics::for_each_procedure(std::function<void (const BreakdownCounter&, size_t)> on_procedure) const +void Statistics::for_each_procedure(std::function<void(const BreakdownCounter&, size_t)> on_procedure) const { - for (size_t procedure = 0; procedure < proc_types_count; ++procedure) + for(size_t procedure = 0; procedure < proc_types_count; ++procedure) { on_procedure(counter, procedure); } } -void Statistics::for_each_session(std::function<void (const Session&)> on_session) const +void Statistics::for_each_session(std::function<void(const Session&)> on_session) const { - for (auto& it : per_session_statistics) + for(auto& it : per_session_statistics) { on_session(it.first); } } -void Statistics::for_each_procedure_in_session(const Session& session, std::function<void (const BreakdownCounter&, size_t)> on_procedure) const +void Statistics::for_each_procedure_in_session(const Session& session, std::function<void(const BreakdownCounter&, size_t)> on_procedure) const { - if (per_session_statistics.find(session) == per_session_statistics.end()) + if(per_session_statistics.find(session) == per_session_statistics.end()) { return; } const BreakdownCounter& current = per_session_statistics.at(session); - for (size_t procedure = 0; procedure < proc_types_count; ++procedure) + for(size_t procedure = 0; procedure < proc_types_count; ++procedure) { on_procedure(current, procedure); } @@ -82,10 +80,10 @@ void Statistics::account(const int cmd_index, const Session& session, const time counter[cmd_index].add(latency); auto i = per_session_statistics.find(session); - if (i == per_session_statistics.end()) + if(i == per_session_statistics.end()) { - auto session_res = per_session_statistics.emplace(session, BreakdownCounter {proc_types_count}); - if (session_res.second == false) + auto session_res = per_session_statistics.emplace(session, BreakdownCounter{proc_types_count}); + if(session_res.second == false) { return; } @@ -93,6 +91,5 @@ void Statistics::account(const int cmd_index, const Session& session, const time } (i->second)[cmd_index].add(latency); - } //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/statistics.h b/analyzers/src/breakdown/statistics.h index 6202386..aac0a99 100644 --- a/analyzers/src/breakdown/statistics.h +++ b/analyzers/src/breakdown/statistics.h @@ -33,12 +33,11 @@ namespace NST { namespace breakdown { - /*! \brief Comparator for sessions */ struct Less { - bool operator() (const Session& a, const Session& b) const; + bool operator()(const Session& a, const Session& b) const; }; /*! \brief All statistics data's container @@ -46,7 +45,7 @@ struct Less struct Statistics { using PerSessionStatistics = std::map<Session, BreakdownCounter, Less>; - using ProceduresCount = std::vector<int>; + using ProceduresCount = std::vector<int>; const size_t proc_types_count; //!< Count of types of procedures @@ -86,27 +85,28 @@ struct Statistics * @param cmd_code - commands code * @param stats - statistics */ - template<typename Cmd, typename Code> + template <typename Cmd, typename Code> void account(const Cmd* proc, Code cmd_code) { - timeval latency {0, 0}; - const int cmd_index = static_cast<int>(cmd_code); - const Session& session = *proc->session; + timeval latency{0, 0}; + const int cmd_index = static_cast<int>(cmd_code); + const Session& session = *proc->session; // diff between 'reply' and 'call' timestamps timersub(proc->rtimestamp, proc->ctimestamp, &latency); account(cmd_index, session, latency); } + protected: void account(const int cmd_index, const Session& session, const timeval latency); - BreakdownCounter counter; //!< Statistics for all sessions + BreakdownCounter counter; //!< Statistics for all sessions PerSessionStatistics per_session_statistics; //!< Statistics for each session }; } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//STATISTICS_H +#endif //STATISTICS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/breakdown/statisticscompositor.cpp b/analyzers/src/breakdown/statisticscompositor.cpp index 653c1df..c322bac 100644 --- a/analyzers/src/breakdown/statisticscompositor.cpp +++ b/analyzers/src/breakdown/statisticscompositor.cpp @@ -29,12 +29,11 @@ StatisticsCompositor::StatisticsCompositor(Statistics& procedures_stats, Statist : Statistics(operations_stats) , procedures_stats(procedures_stats) { - procedures_stats.for_each_session([&](const Session& session) - { + procedures_stats.for_each_session([&](const Session& session) { auto i = per_session_statistics.find(session); - if (i == per_session_statistics.end()) + if(i == per_session_statistics.end()) { - per_session_statistics.emplace(session, BreakdownCounter {proc_types_count}); + per_session_statistics.emplace(session, BreakdownCounter{proc_types_count}); } }); } @@ -45,33 +44,32 @@ void StatisticsCompositor::for_each_procedure(std::function<void(const Breakdown procedures_stats.for_each_procedure(on_procedure); - for (size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure) + for(size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure) { on_procedure(counter, procedure); } } -void StatisticsCompositor::for_each_procedure_in_session(const Session& session, std::function<void (const BreakdownCounter&, size_t)> on_procedure) const +void StatisticsCompositor::for_each_procedure_in_session(const Session& session, std::function<void(const BreakdownCounter&, size_t)> on_procedure) const { bool has_procedures_in_session = false; - procedures_stats.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t proc) - { + procedures_stats.for_each_procedure_in_session(session, [&](const BreakdownCounter& breakdown, size_t proc) { on_procedure(breakdown, proc); has_procedures_in_session = true; }); - if (!has_procedures_in_session) + if(!has_procedures_in_session) { BreakdownCounter empty(procedures_stats.proc_types_count); - for (size_t procedure = 0; procedure < procedures_stats.proc_types_count; ++procedure) + for(size_t procedure = 0; procedure < procedures_stats.proc_types_count; ++procedure) { on_procedure(empty, procedure); } } const BreakdownCounter& current = per_session_statistics.at(session); - for (size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure) + for(size_t procedure = procedures_stats.proc_types_count; procedure < proc_types_count; ++procedure) { on_procedure(current, procedure); } diff --git a/analyzers/src/breakdown/statisticscompositor.h b/analyzers/src/breakdown/statisticscompositor.h index 3b73182..908c4d0 100644 --- a/analyzers/src/breakdown/statisticscompositor.h +++ b/analyzers/src/breakdown/statisticscompositor.h @@ -28,7 +28,6 @@ namespace NST { namespace breakdown { - /** * @brief Composes 2 statistics: for procedures and functions * It is useful for NFS v4.* protocols @@ -36,6 +35,7 @@ namespace breakdown class StatisticsCompositor : public Statistics { Statistics& procedures_stats; + public: StatisticsCompositor(Statistics& procedures_stats, Statistics& operations_stats); void for_each_procedure(std::function<void(const BreakdownCounter&, size_t)> on_procedure) const override; @@ -46,5 +46,5 @@ public: } // namespace breakdown } // namespace NST //------------------------------------------------------------------------------ -#endif//STATISTICSCOMPOSITOR_H +#endif //STATISTICSCOMPOSITOR_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/json/abstract_tcp_service.cpp b/analyzers/src/json/abstract_tcp_service.cpp index 15cd7e1..c04d20f 100644 --- a/analyzers/src/json/abstract_tcp_service.cpp +++ b/analyzers/src/json/abstract_tcp_service.cpp @@ -23,32 +23,32 @@ #include <functional> #include <system_error> -#include <sys/types.h> #include <sys/socket.h> +#include <sys/types.h> #include <unistd.h> #include "abstract_tcp_service.h" #include "utils/log.h" //------------------------------------------------------------------------------ -AbstractTcpService::AbstractTcpService(std::size_t workersAmount, int port, const std::string& host, int backlog) : - _port{port}, - _host{host}, - _backlog{backlog}, - _isRunning{true}, - _threadPool{workersAmount}, - _listenerThread{}, - _serverSocket{0}, - _tasksQueue{}, - _tasksQueueMutex{}, - _tasksQueueCond{} +AbstractTcpService::AbstractTcpService(std::size_t workersAmount, int port, const std::string& host, int backlog) + : _port{port} + , _host{host} + , _backlog{backlog} + , _isRunning{true} + , _threadPool{workersAmount} + , _listenerThread{} + , _serverSocket{0} + , _tasksQueue{} + , _tasksQueueMutex{} + , _tasksQueueCond{} { } AbstractTcpService::~AbstractTcpService() { // Disposing tasks which are still in queue - while (!_tasksQueue.empty()) + while(!_tasksQueue.empty()) { delete _tasksQueue.front(); _tasksQueue.pop(); @@ -60,29 +60,29 @@ void AbstractTcpService::start() _isRunning = true; // Setting up server TCP-socket _serverSocket = socket(PF_INET, SOCK_STREAM, 0); - if (_serverSocket < 0) + if(_serverSocket < 0) { throw std::system_error{errno, std::system_category(), "Opening server socket error"}; } // Setting SO_REUSEADDR to true int reuseAddr = 1; - if (setsockopt(_serverSocket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) < 0) + if(setsockopt(_serverSocket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) < 0) { throw std::system_error{errno, std::system_category(), "Setting SO_REUSEADDR socket option error"}; } // Binding server socket to endpoint IpEndpoint endpoint{_host.c_str(), _port}; - if (bind(_serverSocket, endpoint.addrinfo()->ai_addr, endpoint.addrinfo()->ai_addrlen) != 0) + if(bind(_serverSocket, endpoint.addrinfo()->ai_addr, endpoint.addrinfo()->ai_addrlen) != 0) { throw std::system_error{errno, std::system_category(), "Binding server socket error"}; } // Converting socket to listening state - if (listen(_serverSocket, _backlog) != 0) + if(listen(_serverSocket, _backlog) != 0) { throw std::system_error{errno, std::system_category(), "Converting socket to listening state error"}; } // Creating threads for thread-pool - for (auto & thr : _threadPool) + for(auto& thr : _threadPool) { thr = std::thread{&AbstractTcpService::runWorker, this}; } @@ -98,7 +98,7 @@ void AbstractTcpService::stop() _tasksQueueCond.notify_all(); } // Joining to thread-pool threads and disposing them - for (auto & thr : _threadPool) + for(auto& thr : _threadPool) { thr.join(); } @@ -109,18 +109,18 @@ void AbstractTcpService::stop() void AbstractTcpService::runWorker() { - while (true) + while(true) { std::unique_ptr<AbstractTask> pendingTask; { std::unique_lock<std::mutex> lock{_tasksQueueMutex}; - while (!pendingTask) + while(!pendingTask) { - if (!_isRunning.load()) + if(!_isRunning.load()) { return; } - if (!_tasksQueue.empty()) + if(!_tasksQueue.empty()) { pendingTask.reset(_tasksQueue.front()); _tasksQueue.pop(); @@ -137,7 +137,7 @@ void AbstractTcpService::runWorker() void AbstractTcpService::runListener() { - while (_isRunning.load()) + while(_isRunning.load()) { // Accepting incoming connection on socket struct timespec acceptDuration; @@ -146,19 +146,19 @@ void AbstractTcpService::runListener() FD_ZERO(&readDescriptorsSet); FD_SET(_serverSocket, &readDescriptorsSet); int descriptorsCount = pselect(_serverSocket + 1, &readDescriptorsSet, NULL, NULL, &acceptDuration, NULL); - if (descriptorsCount == 0) + if(descriptorsCount == 0) { // Timeout expired continue; } - else if (descriptorsCount < 0) + else if(descriptorsCount < 0) { std::system_error e{errno, std::system_category(), "Awaiting for incoming connection on server socket error"}; LOG("ERROR: %s", e.what()); #ifdef __gnu_linux__ // Several first pselect(2) calls cause "Interrupted system call" error (errno == EINTR) // if drop privileges option is used on Linux (see https://access.redhat.com/solutions/165483) - if (errno == EINTR) + if(errno == EINTR) { continue; } @@ -167,7 +167,7 @@ void AbstractTcpService::runListener() } // Extracting and returning pending connection int pendingSocketDescriptor = accept(_serverSocket, NULL, NULL); - if (pendingSocketDescriptor < 0) + if(pendingSocketDescriptor < 0) { std::system_error e{errno, std::system_category(), "Accepting incoming connection on server socket error"}; LOG("ERROR: %s", e.what()); @@ -177,7 +177,7 @@ void AbstractTcpService::runListener() std::unique_ptr<AbstractTask> newTask{createTask(pendingSocketDescriptor)}; { std::unique_lock<std::mutex> lock(_tasksQueueMutex); - if (_tasksQueue.size() < MaxTasksQueueSize) + if(_tasksQueue.size() < MaxTasksQueueSize) { _tasksQueue.push(newTask.get()); newTask.release(); @@ -193,9 +193,10 @@ void AbstractTcpService::runListener() //------------------------------------------------------------------------------ -AbstractTcpService::AbstractTask::AbstractTask(int socket) : - _socket{socket} -{} +AbstractTcpService::AbstractTask::AbstractTask(int socket) + : _socket{socket} +{ +} AbstractTcpService::AbstractTask::~AbstractTask() { diff --git a/analyzers/src/json/abstract_tcp_service.h b/analyzers/src/json/abstract_tcp_service.h index 8ef0e00..ef43648 100644 --- a/analyzers/src/json/abstract_tcp_service.h +++ b/analyzers/src/json/abstract_tcp_service.h @@ -23,11 +23,11 @@ #define ABSTRACT_TCP_SERVICE_H //------------------------------------------------------------------------------ #include <atomic> -#include <condition_variable> #include <mutex> #include <queue> #include <thread> #include <vector> +#include <condition_variable> #include "ip_endpoint.h" //------------------------------------------------------------------------------ @@ -64,7 +64,7 @@ public: //! Fills 'struct timespec' value using clock timeout inline static void fillDuration(struct timespec& ts) { - ts.tv_sec = ClockTimeoutMs / 1000; + ts.tv_sec = ClockTimeoutMs / 1000; ts.tv_nsec = ClockTimeoutMs % 1000 * 1000000; } @@ -72,6 +72,7 @@ public: virtual void start(); //! Stops TCP-service virtual void stop(); + protected: //! Asbtract TCP-service task class AbstractTask @@ -94,34 +95,36 @@ protected: //! Task execution pure virtual method to override virtual void execute() = 0; + private: int _socket; }; virtual AbstractTask* createTask(int socket) = 0; + private: using ThreadPool = std::vector<std::thread>; - static constexpr int ClockTimeoutMs = 100; - static constexpr std::size_t ReadBufferSize = 1024; - static constexpr std::size_t WriteBufferSize = 4096; - static constexpr std::size_t HeaderPartSize = 1024; - static constexpr int MaxTasksQueueSize = 128; + static constexpr int ClockTimeoutMs = 100; + static constexpr std::size_t ReadBufferSize = 1024; + static constexpr std::size_t WriteBufferSize = 4096; + static constexpr std::size_t HeaderPartSize = 1024; + static constexpr int MaxTasksQueueSize = 128; void runWorker(); void runListener(); - const int _port; - const std::string _host; - const int _backlog; - std::atomic_bool _isRunning; - ThreadPool _threadPool; - std::thread _listenerThread; - int _serverSocket; + const int _port; + const std::string _host; + const int _backlog; + std::atomic_bool _isRunning; + ThreadPool _threadPool; + std::thread _listenerThread; + int _serverSocket; std::queue<AbstractTask*> _tasksQueue; - std::mutex _tasksQueueMutex; - std::condition_variable _tasksQueueCond; + std::mutex _tasksQueueMutex; + std::condition_variable _tasksQueueCond; }; //------------------------------------------------------------------------------ -#endif//ABSTRACT_TCP_SERVICE_H +#endif //ABSTRACT_TCP_SERVICE_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/json/ip_endpoint.cpp b/analyzers/src/json/ip_endpoint.cpp index 777d16b..85f5d81 100644 --- a/analyzers/src/json/ip_endpoint.cpp +++ b/analyzers/src/json/ip_endpoint.cpp @@ -27,30 +27,30 @@ #include "ip_endpoint.h" //------------------------------------------------------------------------------ -IpEndpoint::IpEndpoint(const std::string& host, int port, bool hostAsAddress) : - _addrinfo{} +IpEndpoint::IpEndpoint(const std::string& host, int port, bool hostAsAddress) + : _addrinfo{} { struct addrinfo hints; memset(&hints, 0, sizeof hints); - hints.ai_family = AF_INET; + hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags |= AI_NUMERICSERV; std::string serviceStr{std::to_string(port)}; - if (host == WildcardAddress) + if(host == WildcardAddress) { hints.ai_flags |= AI_PASSIVE; } - if ((host != WildcardAddress) && (host != LoopbackAddress)) + if((host != WildcardAddress) && (host != LoopbackAddress)) { hints.ai_flags |= AI_CANONNAME; - if (hostAsAddress) + if(hostAsAddress) { hints.ai_flags |= AI_NUMERICHOST; } } int status = getaddrinfo((host == LoopbackAddress) || (host == WildcardAddress) ? nullptr : host.c_str(), serviceStr.c_str(), &hints, &_addrinfo); - if (status != 0) + if(status != 0) { throw std::runtime_error{gai_strerror(status)}; } diff --git a/analyzers/src/json/ip_endpoint.h b/analyzers/src/json/ip_endpoint.h index a45c5f2..a64f114 100644 --- a/analyzers/src/json/ip_endpoint.h +++ b/analyzers/src/json/ip_endpoint.h @@ -51,9 +51,10 @@ public: { return _addrinfo; } + private: struct addrinfo* _addrinfo; }; //------------------------------------------------------------------------------ -#endif//IP_ENDPOINT_H +#endif //IP_ENDPOINT_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/json/json_analyzer.cpp b/analyzers/src/json/json_analyzer.cpp index de6a1ab..657a783 100644 --- a/analyzers/src/json/json_analyzer.cpp +++ b/analyzers/src/json/json_analyzer.cpp @@ -22,11 +22,11 @@ #include "json_analyzer.h" //------------------------------------------------------------------------------ -JsonAnalyzer::JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog) : - _jsonTcpService{*this, workersAmount, port, host, maxServingDurationMs, backlog}, - _nfsV3Stat{}, - _nfsV40Stat{}, - _nfsV41Stat{} +JsonAnalyzer::JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog) + : _jsonTcpService{*this, workersAmount, port, host, maxServingDurationMs, backlog} + , _nfsV3Stat{} + , _nfsV40Stat{} + , _nfsV41Stat{} { _jsonTcpService.start(); } @@ -37,7 +37,7 @@ JsonAnalyzer::~JsonAnalyzer() } // NFS3 -// Procedures: +// Procedures: void JsonAnalyzer::null(const RPCProcedure* /*proc*/, const struct NFS3::NULL3args* /*args*/, @@ -194,7 +194,7 @@ void JsonAnalyzer::commit3(const RPCProcedure* /*proc*/, } // NFS4.0 -// Procedures: +// Procedures: void JsonAnalyzer::null4(const RPCProcedure* /*proc*/, const struct NFS4::NULL4args* /*args*/, @@ -477,8 +477,8 @@ void JsonAnalyzer::illegal40(const RPCProcedure* /* proc */, } // NFS4.1 -// Procedures: - +// Procedures: + void JsonAnalyzer::compound41(const RPCProcedure* /*proc*/, const struct NFS41::COMPOUND4args* /*args*/, const struct NFS41::COMPOUND4res* /*res*/) @@ -748,7 +748,7 @@ void JsonAnalyzer::backchannel_ctl41(const RPCProcedure* /* proc */, } void JsonAnalyzer::bind_conn_to_session41(const RPCProcedure* /* proc */, - const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, + const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, const struct NFS41::BIND_CONN_TO_SESSION4res* res) { if(res) _nfsV41Stat.bind_conn_to_sessionOpsAmount++; diff --git a/analyzers/src/json/json_analyzer.h b/analyzers/src/json/json_analyzer.h index ca7eed3..ea161c0 100644 --- a/analyzers/src/json/json_analyzer.h +++ b/analyzers/src/json/json_analyzer.h @@ -35,140 +35,140 @@ public: struct NfsV3Stat { // Procedures: - std::atomic_int nullProcsAmount = {0}; - std::atomic_int getattrProcsAmount = {0}; - std::atomic_int setattrProcsAmount = {0}; - std::atomic_int lookupProcsAmount = {0}; - std::atomic_int accessProcsAmount = {0}; - std::atomic_int readlinkProcsAmount = {0}; - std::atomic_int readProcsAmount = {0}; - std::atomic_int writeProcsAmount = {0}; - std::atomic_int createProcsAmount = {0}; - std::atomic_int mkdirProcsAmount = {0}; - std::atomic_int symlinkProcsAmount = {0}; - std::atomic_int mknodProcsAmount = {0}; - std::atomic_int removeProcsAmount = {0}; - std::atomic_int rmdirProcsAmount = {0}; - std::atomic_int renameProcsAmount = {0}; - std::atomic_int linkProcsAmount = {0}; - std::atomic_int readdirProcsAmount = {0}; + std::atomic_int nullProcsAmount = {0}; + std::atomic_int getattrProcsAmount = {0}; + std::atomic_int setattrProcsAmount = {0}; + std::atomic_int lookupProcsAmount = {0}; + std::atomic_int accessProcsAmount = {0}; + std::atomic_int readlinkProcsAmount = {0}; + std::atomic_int readProcsAmount = {0}; + std::atomic_int writeProcsAmount = {0}; + std::atomic_int createProcsAmount = {0}; + std::atomic_int mkdirProcsAmount = {0}; + std::atomic_int symlinkProcsAmount = {0}; + std::atomic_int mknodProcsAmount = {0}; + std::atomic_int removeProcsAmount = {0}; + std::atomic_int rmdirProcsAmount = {0}; + std::atomic_int renameProcsAmount = {0}; + std::atomic_int linkProcsAmount = {0}; + std::atomic_int readdirProcsAmount = {0}; std::atomic_int readdirplusProcsAmount = {0}; - std::atomic_int fsstatProcsAmount = {0}; - std::atomic_int fsinfoProcsAmount = {0}; - std::atomic_int pathconfProcsAmount = {0}; - std::atomic_int commitProcsAmount = {0}; + std::atomic_int fsstatProcsAmount = {0}; + std::atomic_int fsinfoProcsAmount = {0}; + std::atomic_int pathconfProcsAmount = {0}; + std::atomic_int commitProcsAmount = {0}; }; struct NfsV40Stat { // Procedures: - std::atomic_int nullProcsAmount = {0}; + std::atomic_int nullProcsAmount = {0}; std::atomic_int compoundProcsAmount = {0}; // Operations: - std::atomic_int accessOpsAmount = {0}; - std::atomic_int closeOpsAmount = {0}; - std::atomic_int commitOpsAmount = {0}; - std::atomic_int createOpsAmount = {0}; - std::atomic_int delegpurgeOpsAmount = {0}; - std::atomic_int delegreturnOpsAmount = {0}; - std::atomic_int getattrOpsAmount = {0}; - std::atomic_int getfhOpsAmount = {0}; - std::atomic_int linkOpsAmount = {0}; - std::atomic_int lockOpsAmount = {0}; - std::atomic_int locktOpsAmount = {0}; - std::atomic_int lockuOpsAmount = {0}; - std::atomic_int lookupOpsAmount = {0}; - std::atomic_int lookuppOpsAmount = {0}; - std::atomic_int nverifyOpsAmount = {0}; - std::atomic_int openOpsAmount = {0}; - std::atomic_int openattrOpsAmount = {0}; - std::atomic_int open_confirmOpsAmount = {0}; - std::atomic_int open_downgradeOpsAmount = {0}; - std::atomic_int putfhOpsAmount = {0}; - std::atomic_int putpubfhOpsAmount = {0}; - std::atomic_int putrootfhOpsAmount = {0}; - std::atomic_int readOpsAmount = {0}; - std::atomic_int readdirOpsAmount = {0}; - std::atomic_int readlinkOpsAmount = {0}; - std::atomic_int removeOpsAmount = {0}; - std::atomic_int renameOpsAmount = {0}; - std::atomic_int renewOpsAmount = {0}; - std::atomic_int restorefhOpsAmount = {0}; - std::atomic_int savefhOpsAmount = {0}; - std::atomic_int secinfoOpsAmount = {0}; - std::atomic_int setattrOpsAmount = {0}; - std::atomic_int setclientidOpsAmount = {0}; + std::atomic_int accessOpsAmount = {0}; + std::atomic_int closeOpsAmount = {0}; + std::atomic_int commitOpsAmount = {0}; + std::atomic_int createOpsAmount = {0}; + std::atomic_int delegpurgeOpsAmount = {0}; + std::atomic_int delegreturnOpsAmount = {0}; + std::atomic_int getattrOpsAmount = {0}; + std::atomic_int getfhOpsAmount = {0}; + std::atomic_int linkOpsAmount = {0}; + std::atomic_int lockOpsAmount = {0}; + std::atomic_int locktOpsAmount = {0}; + std::atomic_int lockuOpsAmount = {0}; + std::atomic_int lookupOpsAmount = {0}; + std::atomic_int lookuppOpsAmount = {0}; + std::atomic_int nverifyOpsAmount = {0}; + std::atomic_int openOpsAmount = {0}; + std::atomic_int openattrOpsAmount = {0}; + std::atomic_int open_confirmOpsAmount = {0}; + std::atomic_int open_downgradeOpsAmount = {0}; + std::atomic_int putfhOpsAmount = {0}; + std::atomic_int putpubfhOpsAmount = {0}; + std::atomic_int putrootfhOpsAmount = {0}; + std::atomic_int readOpsAmount = {0}; + std::atomic_int readdirOpsAmount = {0}; + std::atomic_int readlinkOpsAmount = {0}; + std::atomic_int removeOpsAmount = {0}; + std::atomic_int renameOpsAmount = {0}; + std::atomic_int renewOpsAmount = {0}; + std::atomic_int restorefhOpsAmount = {0}; + std::atomic_int savefhOpsAmount = {0}; + std::atomic_int secinfoOpsAmount = {0}; + std::atomic_int setattrOpsAmount = {0}; + std::atomic_int setclientidOpsAmount = {0}; std::atomic_int setclientid_confirmOpsAmount = {0}; - std::atomic_int verifyOpsAmount = {0}; - std::atomic_int writeOpsAmount = {0}; - std::atomic_int release_lockownerOpsAmount = {0}; - std::atomic_int get_dir_delegationOpsAmount = {0}; - std::atomic_int illegalOpsAmount = {0}; + std::atomic_int verifyOpsAmount = {0}; + std::atomic_int writeOpsAmount = {0}; + std::atomic_int release_lockownerOpsAmount = {0}; + std::atomic_int get_dir_delegationOpsAmount = {0}; + std::atomic_int illegalOpsAmount = {0}; }; struct NfsV41Stat { // Procedures: - std::atomic_int nullProcsAmount = {0}; + std::atomic_int nullProcsAmount = {0}; std::atomic_int compoundProcsAmount = {0}; // Operations: - std::atomic_int accessOpsAmount = {0}; - std::atomic_int closeOpsAmount = {0}; - std::atomic_int commitOpsAmount = {0}; - std::atomic_int createOpsAmount = {0}; - std::atomic_int delegpurgeOpsAmount = {0}; - std::atomic_int delegreturnOpsAmount = {0}; - std::atomic_int getattrOpsAmount = {0}; - std::atomic_int getfhOpsAmount = {0}; - std::atomic_int linkOpsAmount = {0}; - std::atomic_int lockOpsAmount = {0}; - std::atomic_int locktOpsAmount = {0}; - std::atomic_int lockuOpsAmount = {0}; - std::atomic_int lookupOpsAmount = {0}; - std::atomic_int lookuppOpsAmount = {0}; - std::atomic_int nverifyOpsAmount = {0}; - std::atomic_int openOpsAmount = {0}; - std::atomic_int openattrOpsAmount = {0}; - std::atomic_int open_confirmOpsAmount = {0}; - std::atomic_int open_downgradeOpsAmount = {0}; - std::atomic_int putfhOpsAmount = {0}; - std::atomic_int putpubfhOpsAmount = {0}; - std::atomic_int putrootfhOpsAmount = {0}; - std::atomic_int readOpsAmount = {0}; - std::atomic_int readdirOpsAmount = {0}; - std::atomic_int readlinkOpsAmount = {0}; - std::atomic_int removeOpsAmount = {0}; - std::atomic_int renameOpsAmount = {0}; - std::atomic_int renewOpsAmount = {0}; - std::atomic_int restorefhOpsAmount = {0}; - std::atomic_int savefhOpsAmount = {0}; - std::atomic_int secinfoOpsAmount = {0}; - std::atomic_int setattrOpsAmount = {0}; - std::atomic_int setclientidOpsAmount = {0}; - std::atomic_int setclientid_confirmOpsAmount = {0}; - std::atomic_int verifyOpsAmount = {0}; - std::atomic_int writeOpsAmount = {0}; - std::atomic_int release_lockownerOpsAmount = {0}; - std::atomic_int backchannel_ctlOpsAmount = {0}; + std::atomic_int accessOpsAmount = {0}; + std::atomic_int closeOpsAmount = {0}; + std::atomic_int commitOpsAmount = {0}; + std::atomic_int createOpsAmount = {0}; + std::atomic_int delegpurgeOpsAmount = {0}; + std::atomic_int delegreturnOpsAmount = {0}; + std::atomic_int getattrOpsAmount = {0}; + std::atomic_int getfhOpsAmount = {0}; + std::atomic_int linkOpsAmount = {0}; + std::atomic_int lockOpsAmount = {0}; + std::atomic_int locktOpsAmount = {0}; + std::atomic_int lockuOpsAmount = {0}; + std::atomic_int lookupOpsAmount = {0}; + std::atomic_int lookuppOpsAmount = {0}; + std::atomic_int nverifyOpsAmount = {0}; + std::atomic_int openOpsAmount = {0}; + std::atomic_int openattrOpsAmount = {0}; + std::atomic_int open_confirmOpsAmount = {0}; + std::atomic_int open_downgradeOpsAmount = {0}; + std::atomic_int putfhOpsAmount = {0}; + std::atomic_int putpubfhOpsAmount = {0}; + std::atomic_int putrootfhOpsAmount = {0}; + std::atomic_int readOpsAmount = {0}; + std::atomic_int readdirOpsAmount = {0}; + std::atomic_int readlinkOpsAmount = {0}; + std::atomic_int removeOpsAmount = {0}; + std::atomic_int renameOpsAmount = {0}; + std::atomic_int renewOpsAmount = {0}; + std::atomic_int restorefhOpsAmount = {0}; + std::atomic_int savefhOpsAmount = {0}; + std::atomic_int secinfoOpsAmount = {0}; + std::atomic_int setattrOpsAmount = {0}; + std::atomic_int setclientidOpsAmount = {0}; + std::atomic_int setclientid_confirmOpsAmount = {0}; + std::atomic_int verifyOpsAmount = {0}; + std::atomic_int writeOpsAmount = {0}; + std::atomic_int release_lockownerOpsAmount = {0}; + std::atomic_int backchannel_ctlOpsAmount = {0}; std::atomic_int bind_conn_to_sessionOpsAmount = {0}; - std::atomic_int exchange_idOpsAmount = {0}; - std::atomic_int create_sessionOpsAmount = {0}; - std::atomic_int destroy_sessionOpsAmount = {0}; - std::atomic_int free_stateidOpsAmount = {0}; - std::atomic_int get_dir_delegationOpsAmount = {0}; - std::atomic_int getdeviceinfoOpsAmount = {0}; - std::atomic_int getdevicelistOpsAmount = {0}; - std::atomic_int layoutcommitOpsAmount = {0}; - std::atomic_int layoutgetOpsAmount = {0}; - std::atomic_int layoutreturnOpsAmount = {0}; - std::atomic_int secinfo_no_nameOpsAmount = {0}; - std::atomic_int sequenceOpsAmount = {0}; - std::atomic_int set_ssvOpsAmount = {0}; - std::atomic_int test_stateidOpsAmount = {0}; - std::atomic_int want_delegationOpsAmount = {0}; - std::atomic_int destroy_clientidOpsAmount = {0}; - std::atomic_int reclaim_completeOpsAmount = {0}; - std::atomic_int illegalOpsAmount = {0}; + std::atomic_int exchange_idOpsAmount = {0}; + std::atomic_int create_sessionOpsAmount = {0}; + std::atomic_int destroy_sessionOpsAmount = {0}; + std::atomic_int free_stateidOpsAmount = {0}; + std::atomic_int get_dir_delegationOpsAmount = {0}; + std::atomic_int getdeviceinfoOpsAmount = {0}; + std::atomic_int getdevicelistOpsAmount = {0}; + std::atomic_int layoutcommitOpsAmount = {0}; + std::atomic_int layoutgetOpsAmount = {0}; + std::atomic_int layoutreturnOpsAmount = {0}; + std::atomic_int secinfo_no_nameOpsAmount = {0}; + std::atomic_int sequenceOpsAmount = {0}; + std::atomic_int set_ssvOpsAmount = {0}; + std::atomic_int test_stateidOpsAmount = {0}; + std::atomic_int want_delegationOpsAmount = {0}; + std::atomic_int destroy_clientidOpsAmount = {0}; + std::atomic_int reclaim_completeOpsAmount = {0}; + std::atomic_int illegalOpsAmount = {0}; }; JsonAnalyzer(std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog); @@ -265,7 +265,7 @@ public: const struct NFS3::COMMIT3res* /*res*/) override final; // NFS4.0 procedures - + void null4(const RPCProcedure* /*proc*/, const struct NFS4::NULL4args* /*args*/, const struct NFS4::NULL4res* /*res*/) override final; @@ -280,8 +280,8 @@ public: const struct NFS4::ACCESS4args* /* args */, const struct NFS4::ACCESS4res* res) override final; void close40(const RPCProcedure* /* proc */, - const struct NFS4::CLOSE4args* /* args */, - const struct NFS4::CLOSE4res* res) override final; + const struct NFS4::CLOSE4args* /* args */, + const struct NFS4::CLOSE4res* res) override final; void commit40(const RPCProcedure* /* proc */, const struct NFS4::COMMIT4args* /* args */, const struct NFS4::COMMIT4res* res) override final; @@ -387,7 +387,7 @@ public: const struct NFS4::ILLEGAL4res* res) override final; // NFSv4.1 procedures - + void compound41(const RPCProcedure* /*proc*/, const struct NFS41::COMPOUND4args* /*args*/, const struct NFS41::COMPOUND4res* /*res*/) override final; @@ -398,8 +398,8 @@ public: const struct NFS41::ACCESS4args* /* args */, const struct NFS41::ACCESS4res* res) override final; void close41(const RPCProcedure* /* proc */, - const struct NFS41::CLOSE4args* /* args */, - const struct NFS41::CLOSE4res* res) override final; + const struct NFS41::CLOSE4args* /* args */, + const struct NFS41::CLOSE4res* res) override final; void commit41(const RPCProcedure* /* proc */, const struct NFS41::COMMIT4args* /* args */, const struct NFS41::COMMIT4res* res) override final; @@ -502,7 +502,7 @@ public: const struct NFS41::BACKCHANNEL_CTL4args* /* args */, const struct NFS41::BACKCHANNEL_CTL4res* res) override final; void bind_conn_to_session41(const RPCProcedure* /* proc */, - const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, + const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, const struct NFS41::BIND_CONN_TO_SESSION4res* res) override final; void exchange_id41(const RPCProcedure* /* proc */, const struct NFS41::EXCHANGE_ID4args* /* args */, @@ -535,8 +535,8 @@ public: const struct NFS41::LAYOUTRETURN4args* /* args */, const struct NFS41::LAYOUTRETURN4res* res) override final; void secinfo_no_name41(const RPCProcedure* /* proc */, - const NFS41::SECINFO_NO_NAME4args* /* args */, - const NFS41::SECINFO_NO_NAME4res* res) override final; + const NFS41::SECINFO_NO_NAME4args* /* args */, + const NFS41::SECINFO_NO_NAME4res* res) override final; void sequence41(const RPCProcedure* /* proc */, const struct NFS41::SEQUENCE4args* /* args */, const struct NFS41::SEQUENCE4res* res) override final; @@ -577,10 +577,10 @@ public: private: JsonTcpService _jsonTcpService; - NfsV3Stat _nfsV3Stat; - NfsV40Stat _nfsV40Stat; - NfsV41Stat _nfsV41Stat; + NfsV3Stat _nfsV3Stat; + NfsV40Stat _nfsV40Stat; + NfsV41Stat _nfsV41Stat; }; //------------------------------------------------------------------------------ -#endif//JSON_ANALYZER_H +#endif //JSON_ANALYZER_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/json/json_plugin.cpp b/analyzers/src/json/json_plugin.cpp index 8eace3c..b7394c0 100644 --- a/analyzers/src/json/json_plugin.cpp +++ b/analyzers/src/json/json_plugin.cpp @@ -23,100 +23,98 @@ #include "json_analyzer.h" //------------------------------------------------------------------------------ -static constexpr int DefaultPort = 8888; -static constexpr const char * DefaultHost = IpEndpoint::WildcardAddress; -static constexpr std::size_t DefaultWorkersAmount = 10U; -static constexpr int DefaultBacklog = 15; +static constexpr int DefaultPort = 8888; +static constexpr const char* DefaultHost = IpEndpoint::WildcardAddress; +static constexpr std::size_t DefaultWorkersAmount = 10U; +static constexpr int DefaultBacklog = 15; static constexpr std::size_t DefaultMaxServingDurationMs = 500U; -extern "C" -{ +extern "C" { - const char* usage() - { - return "host - Network interface to listen (default is to listen all interfaces)\n" - "port - IP-port to bind to (default is 8888)\n" - "workers - Amount of worker threads (default is 10)\n" - "duration - Max serving duration in milliseconds (default is 500 ms)\n" - "backlog - Listen backlog (default is 15)"; - } +const char* usage() +{ + return "host - Network interface to listen (default is to listen all interfaces)\n" + "port - IP-port to bind to (default is 8888)\n" + "workers - Amount of worker threads (default is 10)\n" + "duration - Max serving duration in milliseconds (default is 500 ms)\n" + "backlog - Listen backlog (default is 15)"; +} - IAnalyzer* create(const char* opts) +IAnalyzer* create(const char* opts) +{ + // Initializing plugin options with default values + int backlog = DefaultBacklog; + std::size_t maxServingDurationMs = DefaultMaxServingDurationMs; + std::string host{DefaultHost}; + int port = DefaultPort; + std::size_t workersAmount = DefaultWorkersAmount; + // Parising plugin options + enum { - // Initializing plugin options with default values - int backlog = DefaultBacklog; - std::size_t maxServingDurationMs = DefaultMaxServingDurationMs; - std::string host{DefaultHost}; - int port = DefaultPort; - std::size_t workersAmount = DefaultWorkersAmount; - // Parising plugin options - enum - { - BACKLOG_SUBOPT_INDEX = 0, - DURATION_SUBOPT_INDEX, - HOST_SUBOPT_INDEX, - PORT_SUBOPT_INDEX, - WORKERS_SUBOPT_INDEX - }; - char backlogSubOptName[] = "backlog"; - char durationSubOptName[] = "duration"; - char hostSubOptName[] = "host"; - char portSubOptName[] = "port"; - char workersSubOptName[] = "workers"; - char* const tokens[] = + BACKLOG_SUBOPT_INDEX = 0, + DURATION_SUBOPT_INDEX, + HOST_SUBOPT_INDEX, + PORT_SUBOPT_INDEX, + WORKERS_SUBOPT_INDEX + }; + char backlogSubOptName[] = "backlog"; + char durationSubOptName[] = "duration"; + char hostSubOptName[] = "host"; + char portSubOptName[] = "port"; + char workersSubOptName[] = "workers"; + char* const tokens[] = { backlogSubOptName, durationSubOptName, hostSubOptName, portSubOptName, workersSubOptName, - NULL - }; - std::size_t optsLen = strlen(opts); - std::vector<char> optsBuf{opts, opts + optsLen + 2}; - char* optionp = &optsBuf[0]; - char* valuep; - int optIndex; - while ((optIndex = getsubopt(&optionp, tokens, &valuep)) >= 0) + NULL}; + std::size_t optsLen = strlen(opts); + std::vector<char> optsBuf{opts, opts + optsLen + 2}; + char* optionp = &optsBuf[0]; + char* valuep; + int optIndex; + while((optIndex = getsubopt(&optionp, tokens, &valuep)) >= 0) + { + try { - try + switch(optIndex) { - switch (optIndex) - { - case BACKLOG_SUBOPT_INDEX: - backlog = std::stoi(valuep); - break; - case DURATION_SUBOPT_INDEX: - maxServingDurationMs = std::stoul(valuep); - break; - case HOST_SUBOPT_INDEX: - host = valuep; - break; - case PORT_SUBOPT_INDEX: - port = std::stoi(valuep); - break; - case WORKERS_SUBOPT_INDEX: - workersAmount = std::stoul(valuep); - break; - default: - throw std::runtime_error{std::string{"Invalid suboption index: "} + std::to_string(optIndex)}; - } - } - catch (std::logic_error& e) - { - throw std::runtime_error{std::string{"Invalid value provided for '"} + tokens[optIndex] + "' suboption"}; + case BACKLOG_SUBOPT_INDEX: + backlog = std::stoi(valuep); + break; + case DURATION_SUBOPT_INDEX: + maxServingDurationMs = std::stoul(valuep); + break; + case HOST_SUBOPT_INDEX: + host = valuep; + break; + case PORT_SUBOPT_INDEX: + port = std::stoi(valuep); + break; + case WORKERS_SUBOPT_INDEX: + workersAmount = std::stoul(valuep); + break; + default: + throw std::runtime_error{std::string{"Invalid suboption index: "} + std::to_string(optIndex)}; } } - // Creating and returning plugin - return new JsonAnalyzer{workersAmount, port, host, maxServingDurationMs, backlog}; + catch(std::logic_error& e) + { + throw std::runtime_error{std::string{"Invalid value provided for '"} + tokens[optIndex] + "' suboption"}; + } } + // Creating and returning plugin + return new JsonAnalyzer{workersAmount, port, host, maxServingDurationMs, backlog}; +} - void destroy(IAnalyzer* instance) - { - delete instance; - } +void destroy(IAnalyzer* instance) +{ + delete instance; +} - NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr) +NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr) } //extern "C" diff --git a/analyzers/src/json/json_tcp_service.cpp b/analyzers/src/json/json_tcp_service.cpp index 2e4cc30..b8852bf 100644 --- a/analyzers/src/json/json_tcp_service.cpp +++ b/analyzers/src/json/json_tcp_service.cpp @@ -29,11 +29,12 @@ //------------------------------------------------------------------------------ JsonTcpService::JsonTcpService(JsonAnalyzer& analyzer, std::size_t workersAmount, int port, const std::string& host, - std::size_t maxServingDurationMs, int backlog) : - AbstractTcpService{workersAmount, port, host, backlog}, - _analyzer(analyzer), - _maxServingDurationMs{maxServingDurationMs} -{} + std::size_t maxServingDurationMs, int backlog) + : AbstractTcpService{workersAmount, port, host, backlog} + , _analyzer(analyzer) + , _maxServingDurationMs{maxServingDurationMs} +{ +} AbstractTcpService::AbstractTask* JsonTcpService::createTask(int socket) { @@ -42,16 +43,17 @@ AbstractTcpService::AbstractTask* JsonTcpService::createTask(int socket) //------------------------------------------------------------------------------ -JsonTcpService::Task::Task(JsonTcpService& service, int socket) : - AbstractTask{socket}, - _service(service) -{} +JsonTcpService::Task::Task(JsonTcpService& service, int socket) + : AbstractTask{socket} + , _service(service) +{ +} void JsonTcpService::Task::execute() { std::chrono::system_clock::time_point servingStarted = std::chrono::system_clock::now(); // Composing JSON with statistics - struct json_object* root = json_object_new_object(); + struct json_object* root = json_object_new_object(); struct json_object* nfsV3Stat = json_object_new_object(); // NFS3 procedures: json_object_object_add(nfsV3Stat, "null", json_object_new_int64(_service._analyzer.getNfsV3Stat().nullProcsAmount.load())); @@ -190,15 +192,15 @@ void JsonTcpService::Task::execute() // Sending JSON to the client std::size_t totalBytesSent = 0U; - while (totalBytesSent < json.length()) + while(totalBytesSent < json.length()) { - if (!_service.isRunning()) + if(!_service.isRunning()) { LOG("WARNING: Service shutdown detected - terminating task execution"); return; } - if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - servingStarted).count() > - static_cast<std::chrono::milliseconds::rep>(_service._maxServingDurationMs)) + if(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - servingStarted).count() > + static_cast<std::chrono::milliseconds::rep>(_service._maxServingDurationMs)) { // TODO: Use general logging LOG("WARNING: A client is too slow - terminating task execution"); @@ -210,23 +212,23 @@ void JsonTcpService::Task::execute() FD_ZERO(&writeDescriptorsSet); FD_SET(socket(), &writeDescriptorsSet); int descriptorsCount = pselect(socket() + 1, NULL, &writeDescriptorsSet, NULL, &writeDuration, NULL); - if (descriptorsCount < 0) + if(descriptorsCount < 0) { throw std::system_error{errno, std::system_category(), "Error awaiting for sending data availability on socket"}; } - else if (descriptorsCount == 0) + else if(descriptorsCount == 0) { // Timeout expired continue; } ssize_t bytesSent = send(socket(), json.data() + totalBytesSent, json.length() - totalBytesSent, MSG_NOSIGNAL); - if (bytesSent < 0) + if(bytesSent < 0) { std::system_error e{errno, std::system_category(), "Sending data to client error"}; LOG("WARNING: %s", e.what()); return; } - else if (bytesSent == 0) + else if(bytesSent == 0) { LOG("WARNING: Connection has been aborted by client while sending data"); return; diff --git a/analyzers/src/json/json_tcp_service.h b/analyzers/src/json/json_tcp_service.h index 1403a6f..d631d9b 100644 --- a/analyzers/src/json/json_tcp_service.h +++ b/analyzers/src/json/json_tcp_service.h @@ -30,6 +30,7 @@ public: JsonTcpService() = delete; JsonTcpService(class JsonAnalyzer& analyzer, std::size_t workersAmount, int port, const std::string& host, std::size_t maxServingDurationMs, int backlog); + private: class Task : public AbstractTask { @@ -38,6 +39,7 @@ private: Task() = delete; void execute() override final; + private: JsonTcpService& _service; }; @@ -45,8 +47,8 @@ private: AbstractTask* createTask(int socket) override final; JsonAnalyzer& _analyzer; - std::size_t _maxServingDurationMs; + std::size_t _maxServingDurationMs; }; //------------------------------------------------------------------------------ -#endif//JSON_TCP_SERVICE_H +#endif //JSON_TCP_SERVICE_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/test/test_analyzer.cpp b/analyzers/src/test/test_analyzer.cpp index 7d7bb06..e6cea6e 100644 --- a/analyzers/src/test/test_analyzer.cpp +++ b/analyzers/src/test/test_analyzer.cpp @@ -27,7 +27,8 @@ class TestAnalyzer : public IAnalyzer { public: - TestAnalyzer(const char* opts):options(opts) + TestAnalyzer(const char* opts) + : options(opts) { std::cout << "TestAnalyzer::TestAnalyzer(" << options << ')' << std::endl; } @@ -40,155 +41,155 @@ public: // NFSv3 procedures void null(const RPCProcedure* /*proc*/, - const struct NFS3::NULL3args* /*args*/, - const struct NFS3::NULL3res* /*res*/) override final + const struct NFS3::NULL3args* /*args*/, + const struct NFS3::NULL3res* /*res*/) override final { std::cout << "TestAnalyzer::null()" << std::endl; } void getattr3(const RPCProcedure* /*proc*/, - const struct NFS3::GETATTR3args* /*args*/, - const struct NFS3::GETATTR3res* /*res*/) override final + const struct NFS3::GETATTR3args* /*args*/, + const struct NFS3::GETATTR3res* /*res*/) override final { std::cout << "TestAnalyzer::getattr3()" << std::endl; } void setattr3(const RPCProcedure* /*proc*/, - const struct NFS3::SETATTR3args* /*args*/, - const struct NFS3::SETATTR3res* /*res*/) override final + const struct NFS3::SETATTR3args* /*args*/, + const struct NFS3::SETATTR3res* /*res*/) override final { std::cout << "TestAnalyzer::setattr3()" << std::endl; } void lookup3(const RPCProcedure* /*proc*/, - const struct NFS3::LOOKUP3args* /*args*/, - const struct NFS3::LOOKUP3res* /*res*/) override final + const struct NFS3::LOOKUP3args* /*args*/, + const struct NFS3::LOOKUP3res* /*res*/) override final { std::cout << "TestAnalyzer::lookup3()" << std::endl; } void access3(const RPCProcedure* /*proc*/, - const struct NFS3::ACCESS3args* /*args*/, - const struct NFS3::ACCESS3res* /*res*/) override final + const struct NFS3::ACCESS3args* /*args*/, + const struct NFS3::ACCESS3res* /*res*/) override final { std::cout << "TestAnalyzer::access3()" << std::endl; } void readlink3(const RPCProcedure* /*proc*/, - const struct NFS3::READLINK3args* /*args*/, - const struct NFS3::READLINK3res* /*res*/) override final + const struct NFS3::READLINK3args* /*args*/, + const struct NFS3::READLINK3res* /*res*/) override final { std::cout << "TestAnalyzer::readlink3()" << std::endl; } void read3(const RPCProcedure* /*proc*/, - const struct NFS3::READ3args* /*args*/, - const struct NFS3::READ3res* /*res*/) override final + const struct NFS3::READ3args* /*args*/, + const struct NFS3::READ3res* /*res*/) override final { std::cout << "TestAnalyzer::read3()" << std::endl; } void write3(const RPCProcedure* /*proc*/, - const struct NFS3::WRITE3args* /*args*/, - const struct NFS3::WRITE3res* /*res*/) override final + const struct NFS3::WRITE3args* /*args*/, + const struct NFS3::WRITE3res* /*res*/) override final { std::cout << "TestAnalyzer::write3()" << std::endl; } void create3(const RPCProcedure* /*proc*/, - const struct NFS3::CREATE3args* /*args*/, - const struct NFS3::CREATE3res* /*res*/) override final + const struct NFS3::CREATE3args* /*args*/, + const struct NFS3::CREATE3res* /*res*/) override final { std::cout << "TestAnalyzer::create3()" << std::endl; } void mkdir3(const RPCProcedure* /*proc*/, - const struct NFS3::MKDIR3args* /*args*/, - const struct NFS3::MKDIR3res* /*res*/) override final + const struct NFS3::MKDIR3args* /*args*/, + const struct NFS3::MKDIR3res* /*res*/) override final { std::cout << "TestAnalyzer::mkdir3()" << std::endl; } void symlink3(const RPCProcedure* /*proc*/, - const struct NFS3::SYMLINK3args* /*args*/, - const struct NFS3::SYMLINK3res* /*res*/) override final + const struct NFS3::SYMLINK3args* /*args*/, + const struct NFS3::SYMLINK3res* /*res*/) override final { std::cout << "TestAnalyzer::symlink3()" << std::endl; } void mknod3(const RPCProcedure* /*proc*/, - const struct NFS3::MKNOD3args* /*args*/, - const struct NFS3::MKNOD3res* /*res*/) override final + const struct NFS3::MKNOD3args* /*args*/, + const struct NFS3::MKNOD3res* /*res*/) override final { std::cout << "TestAnalyzer::mknod3()" << std::endl; } void remove3(const RPCProcedure* /*proc*/, - const struct NFS3::REMOVE3args* /*args*/, - const struct NFS3::REMOVE3res* /*res*/) override final + const struct NFS3::REMOVE3args* /*args*/, + const struct NFS3::REMOVE3res* /*res*/) override final { std::cout << "TestAnalyzer::remove3()" << std::endl; } void rmdir3(const RPCProcedure* /*proc*/, - const struct NFS3::RMDIR3args* /*args*/, - const struct NFS3::RMDIR3res* /*res*/) override final + const struct NFS3::RMDIR3args* /*args*/, + const struct NFS3::RMDIR3res* /*res*/) override final { std::cout << "TestAnalyzer::rmdir3()" << std::endl; } void rename3(const RPCProcedure* /*proc*/, - const struct NFS3::RENAME3args* /*args*/, - const struct NFS3::RENAME3res* /*res*/) override final + const struct NFS3::RENAME3args* /*args*/, + const struct NFS3::RENAME3res* /*res*/) override final { std::cout << "TestAnalyzer::rename3()" << std::endl; } void link3(const RPCProcedure* /*proc*/, - const struct NFS3::LINK3args* /*args*/, - const struct NFS3::LINK3res* /*res*/) override final + const struct NFS3::LINK3args* /*args*/, + const struct NFS3::LINK3res* /*res*/) override final { std::cout << "TestAnalyzer::link3()" << std::endl; } void readdir3(const RPCProcedure* /*proc*/, - const struct NFS3::READDIR3args* /*args*/, - const struct NFS3::READDIR3res* /*res*/) override final + const struct NFS3::READDIR3args* /*args*/, + const struct NFS3::READDIR3res* /*res*/) override final { std::cout << "TestAnalyzer::readdir3()" << std::endl; } void readdirplus3(const RPCProcedure* /*proc*/, - const struct NFS3::READDIRPLUS3args* /*args*/, - const struct NFS3::READDIRPLUS3res* /*res*/) override final + const struct NFS3::READDIRPLUS3args* /*args*/, + const struct NFS3::READDIRPLUS3res* /*res*/) override final { std::cout << "TestAnalyzer::readdirplus3()" << std::endl; } void fsstat3(const RPCProcedure* /*proc*/, - const struct NFS3::FSSTAT3args* /*args*/, - const struct NFS3::FSSTAT3res* /*res*/) override final + const struct NFS3::FSSTAT3args* /*args*/, + const struct NFS3::FSSTAT3res* /*res*/) override final { std::cout << "TestAnalyzer::fsstat3()" << std::endl; } void fsinfo3(const RPCProcedure* /*proc*/, - const struct NFS3::FSINFO3args* /*args*/, - const struct NFS3::FSINFO3res* /*res*/) override final + const struct NFS3::FSINFO3args* /*args*/, + const struct NFS3::FSINFO3res* /*res*/) override final { std::cout << "TestAnalyzer::fsinfo3()" << std::endl; } void pathconf3(const RPCProcedure* /*proc*/, - const struct NFS3::PATHCONF3args* /*args*/, - const struct NFS3::PATHCONF3res* /*res*/) override final + const struct NFS3::PATHCONF3args* /*args*/, + const struct NFS3::PATHCONF3res* /*res*/) override final { std::cout << "TestAnalyzer::pathconf3()" << std::endl; } void commit3(const RPCProcedure* /*proc*/, - const struct NFS3::COMMIT3args* /*args*/, - const struct NFS3::COMMIT3res* /*res*/) override final + const struct NFS3::COMMIT3args* /*args*/, + const struct NFS3::COMMIT3res* /*res*/) override final { std::cout << "TestAnalyzer::commit3()" << std::endl; } @@ -202,8 +203,8 @@ public: std::cout << "TestAnalyzer::null4()" << std::endl; } void compound4(const RPCProcedure* /*proc*/, - const struct NFS4::COMPOUND4args* /*args*/, - const struct NFS4::COMPOUND4res* /*res*/) override final + const struct NFS4::COMPOUND4args* /*args*/, + const struct NFS4::COMPOUND4res* /*res*/) override final { std::cout << "TestAnalyzer::compound4()" << std::endl; } @@ -217,8 +218,8 @@ public: std::cout << "TestAnalyzer" << std::endl; } void close40(const RPCProcedure* /* proc */, - const struct NFS4::CLOSE4args* /* args */, - const struct NFS4::CLOSE4res* /* res */) override final + const struct NFS4::CLOSE4args* /* args */, + const struct NFS4::CLOSE4res* /* res */) override final { std::cout << "TestAnalyzer" << std::endl; } @@ -440,8 +441,8 @@ public: // NFSv4.1 procedures void compound41(const RPCProcedure* /*proc*/, - const struct NFS41::COMPOUND4args* /*args*/, - const struct NFS41::COMPOUND4res* /*res*/) override final + const struct NFS41::COMPOUND4args* /*args*/, + const struct NFS41::COMPOUND4res* /*res*/) override final { std::cout << "TestAnalyzer::compound4()" << std::endl; } @@ -455,8 +456,8 @@ public: std::cout << "TestAnalyzer" << std::endl; } void close41(const RPCProcedure* /* proc */, - const struct NFS41::CLOSE4args* /* args */, - const struct NFS41::CLOSE4res* /* res */) override final + const struct NFS41::CLOSE4args* /* args */, + const struct NFS41::CLOSE4res* /* res */) override final { std::cout << "TestAnalyzer" << std::endl; } @@ -670,7 +671,7 @@ public: std::cout << "TestAnalyzer" << std::endl; } void bind_conn_to_session41(const RPCProcedure* /* proc */, - const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, + const struct NFS41::BIND_CONN_TO_SESSION4args* /* args */, const struct NFS41::BIND_CONN_TO_SESSION4res* /* res */) override final { std::cout << "TestAnalyzer" << std::endl; @@ -736,8 +737,8 @@ public: std::cout << "TestAnalyzer" << std::endl; } void secinfo_no_name41(const RPCProcedure* /* proc */, - const NFS41::SECINFO_NO_NAME4args* /* args */, - const NFS41::SECINFO_NO_NAME4res* /* res */) override final + const NFS41::SECINFO_NO_NAME4args* /* args */, + const NFS41::SECINFO_NO_NAME4res* /* res */) override final { std::cout << "TestAnalyzer" << std::endl; } @@ -783,16 +784,16 @@ public: std::cout << "TestAnalyzer" << std::endl; } - virtual void flush_statistics() + virtual void flush_statistics() override { std::cout << "TestAnalyzer::flush_statistics()" << std::endl; } + private: std::string options; }; -extern "C" -{ +extern "C" { const char* usage() { @@ -815,7 +816,7 @@ const AnalyzerRequirements* requirements() return &requirements; } -NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, nullptr) +NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, nullptr) -}//extern "C" +} //extern "C" //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/nc_windows/header_window.cpp b/analyzers/src/watch/nc_windows/header_window.cpp index 368d6cd..8e04818 100644 --- a/analyzers/src/watch/nc_windows/header_window.cpp +++ b/analyzers/src/watch/nc_windows/header_window.cpp @@ -30,16 +30,16 @@ //------------------------------------------------------------------------------ namespace HEADER { -const int MEMO_LINE = 1; -const int HOST_LINE = 2; -const int DATE_LINE = 3; +const int MEMO_LINE = 1; +const int HOST_LINE = 2; +const int DATE_LINE = 3; const int ELAPSED_LINE = 4; -const int HOST_SIZE = 128; +const int HOST_SIZE = 128; } void HeaderWindow::destroy() { - if (_window == nullptr) + if(_window == nullptr) { return; } @@ -50,9 +50,9 @@ void HeaderWindow::destroy() } HeaderWindow::HeaderWindow(MainWindow& w) -: _start_time {time(NULL)} + : _start_time{time(NULL)} { - if (w._window == nullptr) + if(w._window == nullptr) { throw std::runtime_error("Initialization of Header window failed."); } @@ -65,34 +65,34 @@ HeaderWindow::~HeaderWindow() void HeaderWindow::update() { - if (_window == nullptr) + if(_window == nullptr) { return; } time_t actual_time = time(nullptr); - tm* t = localtime(&actual_time); - time_t shift_time = actual_time - _start_time; + tm* t = localtime(&actual_time); + time_t shift_time = actual_time - _start_time; /* tm starts with 0 month and 1900 year*/ 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); mvwprintw(_window, HEADER::ELAPSED_LINE, FIRST_CHAR_POS, "Elapsed time: \t %d days; %d:%d:%d times", shift_time / SECINDAY, shift_time % SECINDAY / SECINHOUR, shift_time % SECINHOUR / SECINMIN, shift_time % SECINMIN); - wrefresh (_window); + wrefresh(_window); } void HeaderWindow::resize(MainWindow& m) { - if (_window != nullptr) + if(_window != nullptr) { destroy(); } - if (m._window != nullptr) + if(m._window != nullptr) { _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); } - if (_window != nullptr) + if(_window != nullptr) { werase(_window); - wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER , ACS_LLCORNER, ACS_LRCORNER); + wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER); char HOST_NAME[HEADER::HOST_SIZE]; gethostname(HOST_NAME, HEADER::HOST_SIZE); mvwprintw(_window, HEADER::MEMO_LINE, FIRST_CHAR_POS, "%s", "Nfstrace watch plugin. To scroll press up or down keys. Ctrl + c to exit."); diff --git a/analyzers/src/watch/nc_windows/header_window.h b/analyzers/src/watch/nc_windows/header_window.h index 5ced588..5a72b62 100644 --- a/analyzers/src/watch/nc_windows/header_window.h +++ b/analyzers/src/watch/nc_windows/header_window.h @@ -29,8 +29,8 @@ class HeaderWindow { WINDOW* _window; - time_t _start_time; - void destroy(); + time_t _start_time; + void destroy(); public: HeaderWindow() = delete; @@ -46,5 +46,5 @@ public: void resize(MainWindow&); }; //------------------------------------------------------------------------------ -#endif//HEADER_WINDOWS_H +#endif //HEADER_WINDOWS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/nc_windows/main_window.cpp b/analyzers/src/watch/nc_windows/main_window.cpp index 3c992c3..1e0bba6 100644 --- a/analyzers/src/watch/nc_windows/main_window.cpp +++ b/analyzers/src/watch/nc_windows/main_window.cpp @@ -27,25 +27,23 @@ //------------------------------------------------------------------------------ void MainWindow::init() { - if (_window != nullptr) + if(_window != nullptr) { destroy(); } _window = initscr(); - if (_window == nullptr) + if(_window == nullptr) { throw std::runtime_error("Initialization of Main window failed."); } noecho(); cbreak(); - intrflush(stdscr, false); // flush main window - curs_set(0); // disable blinking cursore - - keypad(_window, true); // init keyboard - timeout(200); // set keyboard timeout - - start_color(); // set background color - if (_window != nullptr) + intrflush(stdscr, false); // flush main window + curs_set(0); // disable blinking cursore + keypad(_window, true); // init keyboard + timeout(200); // set keyboard timeout + start_color(); // set background color + if(_window != nullptr) { werase(_window); } @@ -63,14 +61,14 @@ void MainWindow::destroy() void MainWindow::cleanStdin(int key) { - while ((key != EOF) && (key != '\n') && (key != ' ')) + while((key != EOF) && (key != '\n') && (key != ' ')) { key = getch(); } } MainWindow::MainWindow() -: _window {nullptr} + : _window{nullptr} { init(); } @@ -84,7 +82,7 @@ int MainWindow::inputKeys() { int key = wgetch(_window); - if (key != KEY_UP && key != KEY_DOWN && key != KEY_LEFT && key != KEY_RIGHT) + if(key != KEY_UP && key != KEY_DOWN && key != KEY_LEFT && key != KEY_RIGHT) { key = 0; } @@ -94,7 +92,7 @@ int MainWindow::inputKeys() void MainWindow::resize() { - if (_window != nullptr) + if(_window != nullptr) { destroy(); } @@ -103,9 +101,9 @@ void MainWindow::resize() void MainWindow::update() const { - if (_window != nullptr) + if(_window != nullptr) { refresh(); } } -//------------------------------------------------------------------------------
\ No newline at end of file +//------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/nc_windows/main_window.h b/analyzers/src/watch/nc_windows/main_window.h index 4c1afc5..6fed7b3 100644 --- a/analyzers/src/watch/nc_windows/main_window.h +++ b/analyzers/src/watch/nc_windows/main_window.h @@ -32,10 +32,10 @@ class MainWindow void init(); void destroy(); + static void cleanStdin(int); public: - MainWindow(); ~MainWindow(); @@ -52,5 +52,5 @@ public: void update() const; }; //------------------------------------------------------------------------------ -#endif//MAIN_WINDOW_H +#endif //MAIN_WINDOW_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/nc_windows/nc_window_const.h b/analyzers/src/watch/nc_windows/nc_window_const.h index 124436d..bacbb0b 100644 --- a/analyzers/src/watch/nc_windows/nc_window_const.h +++ b/analyzers/src/watch/nc_windows/nc_window_const.h @@ -24,7 +24,6 @@ //------------------------------------------------------------------------------ namespace { - const unsigned int SECINMIN = 60; const unsigned int SECINHOUR = 60 * 60; const unsigned int SECINDAY = 60 * 60 * 24; @@ -41,8 +40,7 @@ const int COUNTERS_POS = 22; const int FIRST_CHAR_POS = 1; const int EMPTY_LINE = 1; - } //------------------------------------------------------------------------------ -#endif//NC_WINDOW_CONST_H +#endif //NC_WINDOW_CONST_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/nc_windows/statistics_window.cpp b/analyzers/src/watch/nc_windows/statistics_window.cpp index d4496c2..e9ec65b 100644 --- a/analyzers/src/watch/nc_windows/statistics_window.cpp +++ b/analyzers/src/watch/nc_windows/statistics_window.cpp @@ -29,15 +29,15 @@ //------------------------------------------------------------------------------ namespace STATISTICS { -const int PROTOCOLS_LINE = 1; +const int PROTOCOLS_LINE = 1; const int FIRST_OPERATION_LINE = 3; -const int DEFAULT_LINES = 10; -const int DEFAULT_GROUP = 1; +const int DEFAULT_LINES = 10; +const int DEFAULT_GROUP = 1; } void StatisticsWindow::destroy() { - if (_window == nullptr) + if(_window == nullptr) { return; } @@ -49,24 +49,24 @@ void StatisticsWindow::destroy() bool StatisticsWindow::canWrite(unsigned int i) { - return (i >= _scrollOffset.at(_activeProtocol) + STATISTICS::FIRST_OPERATION_LINE && i - _scrollOffset.at(_activeProtocol) + BORDER_SIZE < static_cast<unsigned int>(_window->_maxy)); + return (i >= _scrollOffset.at(_activeProtocol) + STATISTICS::FIRST_OPERATION_LINE && i - _scrollOffset.at(_activeProtocol) + BORDER_SIZE < static_cast<unsigned int>(_window->_maxy)); } StatisticsWindow::StatisticsWindow(MainWindow& w, StatisticsContainers& c) -: _window {nullptr} -, _activeProtocol {nullptr} + : _window{nullptr} + , _activeProtocol{nullptr} { - if (w._window == nullptr) + if(w._window == nullptr) { throw std::runtime_error("Initialization of Header window failed."); } - for (auto i : c) + for(auto i : c) { _allProtocols.push_back((i.first)->getProtocolName()); _scrollOffset.insert(std::make_pair<AbstractProtocol*, std::size_t>(reinterpret_cast<AbstractProtocol*>(i.first), 0)); }; _activeProtocol = (c.begin())->first; - _statistic = c.at(_activeProtocol); + _statistic = c.at(_activeProtocol); resize(w); } @@ -76,12 +76,12 @@ StatisticsWindow::~StatisticsWindow() void StatisticsWindow::scrollContent(int i) { - if (i > 0 && _scrollOffset.at(_activeProtocol) <= MAXSHIFT - SHIFTCU) + if(i > 0 && _scrollOffset.at(_activeProtocol) <= MAXSHIFT - SHIFTCU) { _scrollOffset.at(_activeProtocol) += SHIFTCU; updateProtocol(_activeProtocol); } - else if (i < 0 && _scrollOffset.at(_activeProtocol) >= SHIFTCU) + else if(i < 0 && _scrollOffset.at(_activeProtocol) >= SHIFTCU) { _scrollOffset.at(_activeProtocol) -= SHIFTCU; updateProtocol(_activeProtocol); @@ -92,17 +92,16 @@ void StatisticsWindow::updateProtocol(AbstractProtocol* p) { if(p != nullptr) _activeProtocol = p; - if (_window == nullptr) + if(_window == nullptr) { return; } werase(_window); - wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER , ACS_LLCORNER, ACS_LRCORNER); + wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER); std::string tmp(" "); - for_each (_allProtocols.begin(), _allProtocols.end(), [&](std::string& s) - { - if (!s.compare(_activeProtocol->getProtocolName())) + for_each(_allProtocols.begin(), _allProtocols.end(), [&](std::string& s) { + if(!s.compare(_activeProtocol->getProtocolName())) { tmp += std::string(" < ") + s + std::string(" > "); } @@ -112,19 +111,19 @@ void StatisticsWindow::updateProtocol(AbstractProtocol* p) } }); - mvwprintw(_window, STATISTICS::PROTOCOLS_LINE , FIRST_CHAR_POS, "%s", tmp.c_str()); + mvwprintw(_window, STATISTICS::PROTOCOLS_LINE, FIRST_CHAR_POS, "%s", tmp.c_str()); unsigned int line = STATISTICS::FIRST_OPERATION_LINE; for(unsigned int i = STATISTICS::DEFAULT_GROUP; i <= _activeProtocol->getGroups(); i++) { - if ( canWrite(line)) + if(canWrite(line)) { mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", "Total:"); } line++; - for (unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++) + for(unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++) { - if ( canWrite(line)) + if(canWrite(line)) { mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", p->printProcedure(j)); } @@ -132,13 +131,12 @@ void StatisticsWindow::updateProtocol(AbstractProtocol* p) } line++; } - } void StatisticsWindow::update(const ProtocolStatistic& d) { _statistic = d; - if (_statistic.empty() || _window == nullptr) + if(_statistic.empty() || _window == nullptr) { return; } @@ -152,14 +150,14 @@ void StatisticsWindow::update(const ProtocolStatistic& d) { m += _statistic[tmp]; } - if ( canWrite(line)) + if(canWrite(line)) { mvwprintw(_window, line - (_scrollOffset.at(_activeProtocol)), FIRST_CHAR_POS + 25, "%d", m); } line++; - for (unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++) + for(unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++) { - if ( canWrite(line)) + if(canWrite(line)) { mvwprintw(_window, line - _scrollOffset.at(_activeProtocol), COUNTERS_POS, "%lu ", _statistic[j]); mvwprintw(_window, line - _scrollOffset.at(_activeProtocol), PERSENT_POS, "%-3.2f%% ", @@ -174,16 +172,16 @@ void StatisticsWindow::update(const ProtocolStatistic& d) void StatisticsWindow::resize(MainWindow& m) { - if (_window != nullptr) + if(_window != nullptr) { destroy(); } int tmp_size = STATISTICS::DEFAULT_LINES; - if (_activeProtocol != nullptr) + if(_activeProtocol != nullptr) { tmp_size = _activeProtocol->getAmount() + 2 * BORDER_SIZE + 2 * EMPTY_LINE + STATISTICS::PROTOCOLS_LINE + _activeProtocol->getGroups() * EMPTY_LINE * _activeProtocol->getGroups(); } - if (m._window != nullptr && m._window->_maxy > GUI_HEADER_HEIGHT) + if(m._window != nullptr && m._window->_maxy > GUI_HEADER_HEIGHT) { _window = subwin(m._window, std::min(static_cast<int>(m._window->_maxy - GUI_HEADER_HEIGHT), tmp_size), std::min(static_cast<int>(m._window->_maxx), GUI_LENGTH), GUI_HEADER_HEIGHT - BORDER_SIZE, 0); diff --git a/analyzers/src/watch/nc_windows/statistics_window.h b/analyzers/src/watch/nc_windows/statistics_window.h index e95bd85..15002f1 100644 --- a/analyzers/src/watch/nc_windows/statistics_window.h +++ b/analyzers/src/watch/nc_windows/statistics_window.h @@ -22,28 +22,18 @@ #ifndef STATISTICS_WINDOW_H #define STATISTICS_WINDOW_H //------------------------------------------------------------------------------ -#include <unordered_map> #include <vector> +#include <unordered_map> #include "../protocols/abstract_protocol.h" #include "main_window.h" //------------------------------------------------------------------------------ class StatisticsWindow { - using ProtocolStatistic = std::vector<std::size_t>; + using ProtocolStatistic = std::vector<std::size_t>; using StatisticsContainers = std::unordered_map<AbstractProtocol*, ProtocolStatistic>; -private: - WINDOW* _window; - AbstractProtocol* _activeProtocol; - std::vector<std::string> _allProtocols; - std::unordered_map<AbstractProtocol*, unsigned int> _scrollOffset; - ProtocolStatistic _statistic; - void destroy(); - bool canWrite(unsigned int); - public: - StatisticsWindow() = delete; StatisticsWindow(MainWindow&, StatisticsContainers&); ~StatisticsWindow(); @@ -66,7 +56,17 @@ public: /*! Only set active protocol, do not update new protocol's commands. */ void setProtocol(AbstractProtocol*); + +private: + void destroy(); + bool canWrite(unsigned int); + + WINDOW* _window; + AbstractProtocol* _activeProtocol; + std::vector<std::string> _allProtocols; + std::unordered_map<AbstractProtocol*, unsigned int> _scrollOffset; + ProtocolStatistic _statistic; }; //------------------------------------------------------------------------------ -#endif//STATISTICS_WINDOWS_H +#endif //STATISTICS_WINDOWS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/abstract_protocol.cpp b/analyzers/src/watch/protocols/abstract_protocol.cpp index 48a4cd8..c52945a 100644 --- a/analyzers/src/watch/protocols/abstract_protocol.cpp +++ b/analyzers/src/watch/protocols/abstract_protocol.cpp @@ -24,12 +24,12 @@ //------------------------------------------------------------------------------ namespace { - const int EMPTY_GROUP = 1; +const int EMPTY_GROUP = 1; } AbstractProtocol::AbstractProtocol(const char* n, std::size_t i) -: name {n} -, amount {i} + : name{n} + , amount{i} { } @@ -59,7 +59,7 @@ std::size_t AbstractProtocol::getGroups() std::size_t AbstractProtocol::getGroupBegin(std::size_t i) { - if( i == EMPTY_GROUP) + if(i == EMPTY_GROUP) return 0; else return amount; diff --git a/analyzers/src/watch/protocols/abstract_protocol.h b/analyzers/src/watch/protocols/abstract_protocol.h index 4e0649b..a194864 100644 --- a/analyzers/src/watch/protocols/abstract_protocol.h +++ b/analyzers/src/watch/protocols/abstract_protocol.h @@ -62,5 +62,5 @@ private: std::size_t amount; }; //------------------------------------------------------------------------------ -#endif//ABSTRACT_PROTOCOL_H +#endif //ABSTRACT_PROTOCOL_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/cifsv1_protocol.cpp b/analyzers/src/watch/protocols/cifsv1_protocol.cpp index ac456ee..fb130e1 100644 --- a/analyzers/src/watch/protocols/cifsv1_protocol.cpp +++ b/analyzers/src/watch/protocols/cifsv1_protocol.cpp @@ -20,11 +20,12 @@ */ //------------------------------------------------------------------------------ #include <api/plugin_api.h> // include plugin development definitions + #include "cifsv1_protocol.h" //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ CIFSv1Protocol::CIFSv1Protocol() -: AbstractProtocol {"CIFS v1", static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)} + : AbstractProtocol{"CIFS v1", static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)} { } @@ -34,7 +35,10 @@ CIFSv1Protocol::~CIFSv1Protocol() const char* CIFSv1Protocol::printProcedure(std::size_t i) { - if ( i >= static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)) { return nullptr; } + if(i >= static_cast<std::size_t>(SMBv1::SMBv1Commands::CMD_COUNT)) + { + return nullptr; + } return print_cifs1_procedures(static_cast<SMBv1::SMBv1Commands>(i)); } //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/cifsv1_protocol.h b/analyzers/src/watch/protocols/cifsv1_protocol.h index 6176318..6fd6248 100644 --- a/analyzers/src/watch/protocols/cifsv1_protocol.h +++ b/analyzers/src/watch/protocols/cifsv1_protocol.h @@ -32,5 +32,5 @@ public: virtual const char* printProcedure(std::size_t); }; //------------------------------------------------------------------------------ -#endif//CIFSV1_PROTOCOL_H +#endif //CIFSV1_PROTOCOL_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/cifsv2_protocol.cpp b/analyzers/src/watch/protocols/cifsv2_protocol.cpp index 39a3f6a..dbe24dc 100644 --- a/analyzers/src/watch/protocols/cifsv2_protocol.cpp +++ b/analyzers/src/watch/protocols/cifsv2_protocol.cpp @@ -20,10 +20,11 @@ */ //------------------------------------------------------------------------------ #include <api/plugin_api.h> // include plugin development definitions + #include "cifsv2_protocol.h" //------------------------------------------------------------------------------ CIFSv2Protocol::CIFSv2Protocol() -: AbstractProtocol {"CIFS v2", static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)} + : AbstractProtocol{"CIFS v2", static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)} { } @@ -33,7 +34,10 @@ CIFSv2Protocol::~CIFSv2Protocol() const char* CIFSv2Protocol::printProcedure(std::size_t i) { - if ( i >= static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)) { return nullptr; } + if(i >= static_cast<std::size_t>(SMBv2::SMBv2Commands::CMD_COUNT)) + { + return nullptr; + } return print_cifs2_procedures(static_cast<SMBv2::SMBv2Commands>(i)); } //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/cifsv2_protocol.h b/analyzers/src/watch/protocols/cifsv2_protocol.h index b95a740..a90aa21 100644 --- a/analyzers/src/watch/protocols/cifsv2_protocol.h +++ b/analyzers/src/watch/protocols/cifsv2_protocol.h @@ -32,5 +32,5 @@ public: virtual const char* printProcedure(std::size_t); }; //------------------------------------------------------------------------------ -#endif//CIFSV2_PROTOCOL_H +#endif //CIFSV2_PROTOCOL_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/nfsv3_protocol.cpp b/analyzers/src/watch/protocols/nfsv3_protocol.cpp index 39de02b..a5c4324 100644 --- a/analyzers/src/watch/protocols/nfsv3_protocol.cpp +++ b/analyzers/src/watch/protocols/nfsv3_protocol.cpp @@ -20,10 +20,11 @@ */ //------------------------------------------------------------------------------ #include <api/plugin_api.h> // include plugin development definitions + #include "nfsv3_protocol.h" //------------------------------------------------------------------------------ NFSv3Protocol::NFSv3Protocol() -: AbstractProtocol {"NFS v3", ProcEnumNFS3::count} + : AbstractProtocol{"NFS v3", ProcEnumNFS3::count} { } @@ -33,7 +34,10 @@ NFSv3Protocol::~NFSv3Protocol() const char* NFSv3Protocol::printProcedure(std::size_t i) { - if ( i > ProcEnumNFS3::count) { return nullptr; } - return print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(i)); + if(i > ProcEnumNFS3::count) + { + return nullptr; + } + return print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(i)); } //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/nfsv3_protocol.h b/analyzers/src/watch/protocols/nfsv3_protocol.h index d4e5119..e94f4a5 100644 --- a/analyzers/src/watch/protocols/nfsv3_protocol.h +++ b/analyzers/src/watch/protocols/nfsv3_protocol.h @@ -32,5 +32,5 @@ public: virtual const char* printProcedure(std::size_t); }; //------------------------------------------------------------------------------ -#endif//NFSV3_PROTOCOL_H +#endif //NFSV3_PROTOCOL_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/nfsv41_protocol.cpp b/analyzers/src/watch/protocols/nfsv41_protocol.cpp index fbc7251..f48b03e 100644 --- a/analyzers/src/watch/protocols/nfsv41_protocol.cpp +++ b/analyzers/src/watch/protocols/nfsv41_protocol.cpp @@ -20,17 +20,18 @@ */ //------------------------------------------------------------------------------ #include <api/plugin_api.h> // include plugin development definitions + #include "nfsv41_protocol.h" //------------------------------------------------------------------------------ namespace { const int NFSV41_NUMBEROFGROUPS = 2; -const int PROCEDURES_GROUP = 1; -const int OPERATIONS_GROUP = 2; +const int PROCEDURES_GROUP = 1; +const int OPERATIONS_GROUP = 2; } NFSv41Protocol::NFSv41Protocol() -: AbstractProtocol {"NFS v41", ProcEnumNFS41::count} + : AbstractProtocol{"NFS v41", ProcEnumNFS41::count} { } @@ -40,8 +41,11 @@ NFSv41Protocol::~NFSv41Protocol() const char* NFSv41Protocol::printProcedure(std::size_t i) { - if ( i > ProcEnumNFS41::count) { return nullptr; } - return print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(i)); + if(i > ProcEnumNFS41::count) + { + return nullptr; + } + return print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(i)); } std::size_t NFSv41Protocol::getGroups() diff --git a/analyzers/src/watch/protocols/nfsv41_protocol.h b/analyzers/src/watch/protocols/nfsv41_protocol.h index 8b74ab4..218247e 100644 --- a/analyzers/src/watch/protocols/nfsv41_protocol.h +++ b/analyzers/src/watch/protocols/nfsv41_protocol.h @@ -34,5 +34,5 @@ public: virtual std::size_t getGroupBegin(std::size_t); }; //------------------------------------------------------------------------------ -#endif//NFSV41_PROTOCOL_H +#endif //NFSV41_PROTOCOL_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/protocols/nfsv4_protocol.cpp b/analyzers/src/watch/protocols/nfsv4_protocol.cpp index d22bcfc..dfe7ce8 100644 --- a/analyzers/src/watch/protocols/nfsv4_protocol.cpp +++ b/analyzers/src/watch/protocols/nfsv4_protocol.cpp @@ -20,17 +20,18 @@ */ //------------------------------------------------------------------------------ #include <api/plugin_api.h> // include plugin development definitions + #include "nfsv4_protocol.h" //------------------------------------------------------------------------------ namespace { const int NFSV4_NUMBER_OF_GROUPS = 2; -const int PROCEDURES_GROUP = 1; -const int OPERATIONS_GROUP = 2; +const int PROCEDURES_GROUP = 1; +const int OPERATIONS_GROUP = 2; } NFSv4Protocol::NFSv4Protocol() -: AbstractProtocol {"NFS v4", ProcEnumNFS4::count} + : AbstractProtocol{"NFS v4", ProcEnumNFS4::count} { } @@ -40,8 +41,11 @@ NFSv4Protocol::~NFSv4Protocol() const char* NFSv4Protocol::printProcedure(std::size_t i) { - if ( i > ProcEnumNFS4::count) { return nullptr; } - return print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(i)); + if(i > ProcEnumNFS4::count) + { + return nullptr; + } + return print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(i)); } std::size_t NFSv4Protocol::getGroups() diff --git a/analyzers/src/watch/protocols/nfsv4_protocol.h b/analyzers/src/watch/protocols/nfsv4_protocol.h index bc39391..cbd6093 100644 --- a/analyzers/src/watch/protocols/nfsv4_protocol.h +++ b/analyzers/src/watch/protocols/nfsv4_protocol.h @@ -34,5 +34,5 @@ public: virtual std::size_t getGroupBegin(std::size_t); }; //------------------------------------------------------------------------------ -#endif//PROTOCOLS_H +#endif //PROTOCOLS_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/user_gui.cpp b/analyzers/src/watch/user_gui.cpp index 6e7d6de..9f8e9da 100644 --- a/analyzers/src/watch/user_gui.cpp +++ b/analyzers/src/watch/user_gui.cpp @@ -46,7 +46,7 @@ void UserGUI::run() // prepare for select fd_set rfds; - MainWindow mainWindow; + MainWindow mainWindow; HeaderWindow headerWindow(mainWindow); StatisticsWindow statisticsWindow(mainWindow, _statisticsContainers); @@ -63,9 +63,9 @@ void UserGUI::run() statisticsWindow.updateProtocol(_activeProtocol); - while (_running.test_and_set()) + while(_running.test_and_set()) { - if (_shouldResize) + if(_shouldResize) { mainWindow.resize(); headerWindow.resize(mainWindow); @@ -74,67 +74,65 @@ void UserGUI::run() _shouldResize = false; } - if (_running.test_and_set()) + if(_running.test_and_set()) { - std::unique_lock<std::mutex>lck(_statisticsDeltaMutex); + std::unique_lock<std::mutex> lck(_statisticsDeltaMutex); tmp = _statisticsContainers.at(_activeProtocol); } headerWindow.update(); statisticsWindow.update(tmp); mainWindow.update(); - if( select(STDIN_FILENO + 1, &rfds, nullptr, nullptr, &tv) == -1) + if(select(STDIN_FILENO + 1, &rfds, nullptr, nullptr, &tv) == -1) { break; } else { key = mainWindow.inputKeys(); - if (key == KEY_LEFT || key == KEY_RIGHT) + if(key == KEY_LEFT || key == KEY_RIGHT) { - auto it = find_if (_allProtocols.begin(), _allProtocols.end(), [&](std::string s) - { + auto it = find_if(_allProtocols.begin(), _allProtocols.end(), [&](std::string s) { return !(s.compare(_activeProtocol->getProtocolName())); }); - if (it != _allProtocols.end()) + if(it != _allProtocols.end()) { - if (key == KEY_LEFT) + if(key == KEY_LEFT) { - if (it + 1 == _allProtocols.end()) + if(it + 1 == _allProtocols.end()) it = _allProtocols.begin(); else ++it; } - else if (key == KEY_RIGHT) + else if(key == KEY_RIGHT) { - if (it == _allProtocols.begin()) + if(it == _allProtocols.begin()) it = _allProtocols.end() - 1; else --it; } - auto a = find_if ( _statisticsContainers.begin(), _statisticsContainers.end(),[&](std::pair<AbstractProtocol*, std::vector<std::size_t> > p) - { + auto a = find_if(_statisticsContainers.begin(), _statisticsContainers.end(), [&](std::pair<AbstractProtocol*, std::vector<std::size_t>> p) { return !(p.first->getProtocolName().compare(*it)); }); - if (a != _statisticsContainers.end()) + if(a != _statisticsContainers.end()) { _activeProtocol = a->first; statisticsWindow.setProtocol(_activeProtocol); statisticsWindow.resize(mainWindow); { - std::unique_lock<std::mutex>lck(_statisticsDeltaMutex); + std::unique_lock<std::mutex> lck(_statisticsDeltaMutex); tmp = a->second; } statisticsWindow.update(tmp); } } } - else if (key == KEY_UP) + else if(key == KEY_UP) { statisticsWindow.scrollContent(SCROLL_UP); statisticsWindow.update(tmp); } - else if (key == KEY_DOWN) + else if(key == KEY_DOWN) { statisticsWindow.scrollContent(SCROLL_DOWN); statisticsWindow.update(tmp); @@ -143,7 +141,7 @@ void UserGUI::run() tv = getTimeval(); } } - catch (std::runtime_error& e) + catch(std::runtime_error& e) { std::cerr << "Watch plugin error: " << e.what(); } @@ -152,36 +150,36 @@ void UserGUI::run() timeval UserGUI::getTimeval() const { struct timeval tv; - tv.tv_sec = _refresh_delta / MSEC; + tv.tv_sec = _refresh_delta / MSEC; tv.tv_usec = _refresh_delta % MSEC; return tv; } -UserGUI::UserGUI(const char* opts, std::vector<AbstractProtocol* >& data) -: _refresh_delta {900000} -, _shouldResize {false} -, _running {ATOMIC_FLAG_INIT} -, _activeProtocol(nullptr) +UserGUI::UserGUI(const char* opts, std::vector<AbstractProtocol*>& data) + : _refresh_delta{900000} + , _shouldResize{false} + , _running{ATOMIC_FLAG_INIT} + , _activeProtocol(nullptr) { try { - if (opts != nullptr && *opts != '\0' ) + if(opts != nullptr && *opts != '\0') { _refresh_delta = std::stoul(opts); } - for (auto it = data.begin(); it != data.end(); ++it) + for(auto it = data.begin(); it != data.end(); ++it) { _allProtocols.push_back((*it)->getProtocolName()); - _statisticsContainers.insert(std::make_pair<AbstractProtocol*, std::vector<std::size_t> >((AbstractProtocol*&&)(*it), std::vector<std::size_t>((*it)->getAmount(), 0))); + _statisticsContainers.insert(std::make_pair<AbstractProtocol*, std::vector<std::size_t>>((AbstractProtocol * &&)(*it), std::vector<std::size_t>((*it)->getAmount(), 0))); } - if (_activeProtocol == nullptr && ! data.empty()) + if(_activeProtocol == nullptr && !data.empty()) { _activeProtocol = data.back(); } } - catch (std::exception& e) + catch(std::exception& e) { - throw std::runtime_error {std::string{"Error in plugin options processing. OPTS: "} + opts + std::string(" Error: ") + e.what()}; + throw std::runtime_error{std::string{"Error in plugin options processing. OPTS: "} + opts + std::string(" Error: ") + e.what()}; } _running.test_and_set(); _guiThread = std::thread(&UserGUI::run, this); @@ -197,8 +195,8 @@ void UserGUI::update(AbstractProtocol* p, std::vector<std::size_t>& d) { std::vector<std::size_t>::iterator it; std::vector<std::size_t>::iterator st; - std::unique_lock<std::mutex>lck(_statisticsDeltaMutex); - for (it = (_statisticsContainers.at(p)).begin(), st = d.begin(); it != (_statisticsContainers.at(p)).end() && st != d.end(); ++it, ++st) + std::unique_lock<std::mutex> lck(_statisticsDeltaMutex); + for(it = (_statisticsContainers.at(p)).begin(), st = d.begin(); it != (_statisticsContainers.at(p)).end() && st != d.end(); ++it, ++st) { (*it) += (*st); } diff --git a/analyzers/src/watch/user_gui.h b/analyzers/src/watch/user_gui.h index b40dd52..20e881c 100644 --- a/analyzers/src/watch/user_gui.h +++ b/analyzers/src/watch/user_gui.h @@ -29,32 +29,17 @@ #include <vector> #include <ncurses.h> + #include "protocols/abstract_protocol.h" //------------------------------------------------------------------------------ class UserGUI { public: - using ProtocolStatistic = std::vector<std::size_t>; + using ProtocolStatistic = std::vector<std::size_t>; using StatisticsContainers = std::unordered_map<AbstractProtocol*, ProtocolStatistic>; -private: - unsigned long _refresh_delta; // in microseconds - - std::atomic<bool> _shouldResize; - std::mutex _statisticsDeltaMutex; - std::atomic_flag _running; - - StatisticsContainers _statisticsContainers; - - AbstractProtocol* _activeProtocol; - std::thread _guiThread; - std::vector<std::string> _allProtocols; - void run(); - timeval getTimeval() const; -public: - UserGUI() = delete; - UserGUI(const char*, std::vector<AbstractProtocol* >&); + UserGUI(const char*, std::vector<AbstractProtocol*>&); ~UserGUI(); /*! Update Protocol's data. @@ -64,7 +49,20 @@ public: /*! Enable screen full update. Use for resize main window. */ void enableUpdate(); + +private: + void run(); + timeval getTimeval() const; + + unsigned long _refresh_delta; // in microseconds + std::atomic<bool> _shouldResize; + std::mutex _statisticsDeltaMutex; + std::atomic_flag _running; + StatisticsContainers _statisticsContainers; + AbstractProtocol* _activeProtocol; + std::thread _guiThread; + std::vector<std::string> _allProtocols; }; //------------------------------------------------------------------------------ -#endif//USERGUI_H +#endif //USERGUI_H //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/watch_analyzer.cpp b/analyzers/src/watch/watch_analyzer.cpp index 26dd4f9..5bb4b35 100644 --- a/analyzers/src/watch/watch_analyzer.cpp +++ b/analyzers/src/watch/watch_analyzer.cpp @@ -24,21 +24,21 @@ #include <string> #include <unordered_map> -#include <unistd.h> #include <signal.h> #include <sys/time.h> #include <sys/types.h> +#include <unistd.h> #include "watch_analyzer.h" //------------------------------------------------------------------------------ WatchAnalyzer::WatchAnalyzer(const char* opts) -: _cifsv2 {} -, _cifsv1 {} -, _nfsv41 {} -, _nfsv4 {} -, _nfsv3 {} -, protocols {&_cifsv2, &_cifsv1, &_nfsv41, &_nfsv4, &_nfsv3} -, gui {opts, protocols} + : _cifsv2{} + , _cifsv1{} + , _nfsv41{} + , _nfsv4{} + , _nfsv3{} + , protocols{&_cifsv2, &_cifsv1, &_nfsv41, &_nfsv4, &_nfsv3} + , gui{opts, protocols} { } @@ -46,6 +46,7 @@ WatchAnalyzer::~WatchAnalyzer() { } +// clang-format off void WatchAnalyzer::null(const RPCProcedure* proc, const struct NFS3::NULL3args*, const struct NFS3::NULL3res*) { nfs_account(proc); } @@ -878,6 +879,7 @@ void WatchAnalyzer::breakOplockSMBv2(const SMBv2::BreakOpLockCommand* /*cmd*/, c { cifs_account(_cifsv2, static_cast<int>(SMBv2::SMBv2Commands::OPLOCK_BREAK)); } +// clang-format on void WatchAnalyzer::flush_statistics() { @@ -885,15 +887,15 @@ void WatchAnalyzer::flush_statistics() void WatchAnalyzer::on_unix_signal(int signo) { - if (signo == SIGWINCH) + if(signo == SIGWINCH) { gui.enableUpdate(); } } -void WatchAnalyzer::cifs_account(AbstractProtocol &protocol, int cmd_code) +void WatchAnalyzer::cifs_account(AbstractProtocol& protocol, int cmd_code) { - std::vector<std::size_t> cifs_proc_count (static_cast<std::size_t>(protocol.getAmount()), 0); + std::vector<std::size_t> cifs_proc_count(static_cast<std::size_t>(protocol.getAmount()), 0); ++cifs_proc_count[cmd_code]; gui.update(&protocol, cifs_proc_count); } @@ -903,25 +905,25 @@ void WatchAnalyzer::nfs_account(const RPCProcedure* proc, const unsigned int nfs const u_int nfs_proc = proc->call.ru.RM_cmb.cb_proc; const u_int nfs_vers = proc->call.ru.RM_cmb.cb_vers; - if (nfs_vers == NFS_V4) + if(nfs_vers == NFS_V4) { - if (nfs_minor_vers == NFS_V40) + if(nfs_minor_vers == NFS_V40) { - std::vector<std::size_t> nfs4_proc_count (ProcEnumNFS4::count, 0); + std::vector<std::size_t> nfs4_proc_count(ProcEnumNFS4::count, 0); ++nfs4_proc_count[nfs_proc]; gui.update(&_nfsv4, nfs4_proc_count); } - if (nfs_minor_vers == NFS_V41 || nfs_proc == ProcEnumNFS4::NFS_NULL) + if(nfs_minor_vers == NFS_V41 || nfs_proc == ProcEnumNFS4::NFS_NULL) { - std::vector<std::size_t> nfs41_proc_count (ProcEnumNFS41::count, 0); + std::vector<std::size_t> nfs41_proc_count(ProcEnumNFS41::count, 0); ++nfs41_proc_count[nfs_proc]; gui.update(&_nfsv41, nfs41_proc_count); } } - else if (nfs_vers == NFS_V3) + else if(nfs_vers == NFS_V3) { - std::vector<std::size_t> nfs3_proc_count (ProcEnumNFS3::count, 0); + std::vector<std::size_t> nfs3_proc_count(ProcEnumNFS3::count, 0); ++nfs3_proc_count[nfs_proc]; gui.update(&_nfsv3, nfs3_proc_count); } @@ -929,51 +931,50 @@ void WatchAnalyzer::nfs_account(const RPCProcedure* proc, const unsigned int nfs void WatchAnalyzer::account40_op(const RPCProcedure* /*proc*/, const ProcEnumNFS4::NFSProcedure operation) { - std::vector<std::size_t> nfs4_proc_count (ProcEnumNFS4::count, 0); + std::vector<std::size_t> nfs4_proc_count(ProcEnumNFS4::count, 0); ++nfs4_proc_count[operation]; gui.update(&_nfsv4, nfs4_proc_count); } void WatchAnalyzer::account41_op(const RPCProcedure* /*proc*/, const ProcEnumNFS41::NFSProcedure operation) { - std::vector<std::size_t> nfs41_proc_count (ProcEnumNFS41::count, 0); + std::vector<std::size_t> nfs41_proc_count(ProcEnumNFS41::count, 0); ++nfs41_proc_count[operation]; gui.update(&_nfsv41, nfs41_proc_count); } //------------------------------------------------------------------------------ -extern "C" +extern "C" { + +const char* usage() { + return "User can set chrono output timeout in msec.\n" + "You have to run nfstrace with verbosity level set to 0 (nfstrace -v 0 ...)"; +} - const char* usage() +IAnalyzer* create(const char* opts) +{ + try { - return "User can set chrono output timeout in msec.\n" - "You have to run nfstrace with verbosity level set to 0 (nfstrace -v 0 ...)"; + return new WatchAnalyzer(opts); } - - IAnalyzer* create(const char* opts) + catch(std::exception& e) { - try - { - return new WatchAnalyzer(opts); - } - catch (std::exception& e) - { - std::cerr << "Can't initalize plugin: " << e.what() << std::endl; - return nullptr; - } + std::cerr << "Can't initalize plugin: " << e.what() << std::endl; + return nullptr; } +} - void destroy(IAnalyzer* instance) - { - delete instance; - } +void destroy(IAnalyzer* instance) +{ + delete instance; +} - const AnalyzerRequirements* requirements() - { - static const AnalyzerRequirements requirements{true}; - return &requirements; - } +const AnalyzerRequirements* requirements() +{ + static const AnalyzerRequirements requirements{true}; + return &requirements; +} - NST_PLUGIN_ENTRY_POINTS (&usage, &create, &destroy, &requirements) +NST_PLUGIN_ENTRY_POINTS(&usage, &create, &destroy, &requirements) } //------------------------------------------------------------------------------ diff --git a/analyzers/src/watch/watch_analyzer.h b/analyzers/src/watch/watch_analyzer.h index 9635f7c..cb8a4a4 100644 --- a/analyzers/src/watch/watch_analyzer.h +++ b/analyzers/src/watch/watch_analyzer.h @@ -26,11 +26,12 @@ #include <condition_variable> #include <api/plugin_api.h> // include plugin development definitions -#include "protocols/nfsv3_protocol.h" -#include "protocols/nfsv4_protocol.h" -#include "protocols/nfsv41_protocol.h" + #include "protocols/cifsv1_protocol.h" #include "protocols/cifsv2_protocol.h" +#include "protocols/nfsv3_protocol.h" +#include "protocols/nfsv41_protocol.h" +#include "protocols/nfsv4_protocol.h" #include "user_gui.h" //------------------------------------------------------------------------------ class WatchAnalyzer : public IAnalyzer @@ -110,8 +111,8 @@ public: const struct NFS3::COMMIT3res*) override final; // NFS v4 virtual void null4(const RPCProcedure*, - const struct NFS4::NULL4args*, - const struct NFS4::NULL4res*) override final; + const struct NFS4::NULL4args*, + const struct NFS4::NULL4res*) override final; virtual void compound4(const RPCProcedure*, const struct NFS4::COMPOUND4args*, const struct NFS4::COMPOUND4res*) override final; @@ -492,9 +493,8 @@ public: virtual void breakOplockSMBv2(const SMBv2::BreakOpLockCommand*, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) override final; private: - void count_proc(const RPCProcedure* proc); - void cifs_account(AbstractProtocol &protocol, int cmd_code); + void cifs_account(AbstractProtocol& protocol, int cmd_code); void nfs_account(const RPCProcedure*, const unsigned int nfs_minor_vers = NFS_V41); void account40_op(const RPCProcedure*, const ProcEnumNFS4::NFSProcedure); @@ -506,9 +506,9 @@ private: NFSv4Protocol _nfsv4; NFSv3Protocol _nfsv3; - std::vector<AbstractProtocol* > protocols; - UserGUI gui; + std::vector<AbstractProtocol*> protocols; + UserGUI gui; }; //------------------------------------------------------------------------------ -#endif//WATCH_ANALYZER_H +#endif //WATCH_ANALYZER_H //------------------------------------------------------------------------------ diff --git a/astyle.cfg b/astyle.cfg deleted file mode 100644 index f33bce3..0000000 --- a/astyle.cfg +++ /dev/null @@ -1,23 +0,0 @@ -# Bracket style ---style=ansi - -# Tab ---indent=spaces=4 - -# Indentation ---indent-preprocessor ---max-instatement-indent=80 - -# Padding ---pad-oper ---pad-header ---align-pointer=type ---align-reference=type - -# Formatting ---add-brackets ---keep-one-line-blocks ---convert-tabs - -# Other ---lineend=linux diff --git a/cmake/FindJSON.cmake b/cmake/FindJSON.cmake index 955564f..2b80dbc 100644 --- a/cmake/FindJSON.cmake +++ b/cmake/FindJSON.cmake @@ -17,23 +17,26 @@ # in sid: # $ sudo apt-get install libjson-c-dev -find_path(JSON_INCLUDE_DIR NAMES json-c/json.h json/json.h) + +#[[ +Debian and Ubuntu have json-c in /usr/include/json-c and jsoncpp in /usr/include/jsoncpp/json +Arch and Fedora have json-c in /usr/include/json-c and jsoncpp in /usr/include/json +Searching for json_c_version.h avoids finding json.h of jsoncpp. +]] +find_path(JSON_INCLUDE_DIR NAMES json_c_version.h json.h PATHS /usr/include/json-c /usr/include/json) find_library(JSON_LIBRARY NAMES json-c json) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(JSON DEFAULT_MSG - JSON_LIBRARY - JSON_INCLUDE_DIR -) + JSON_LIBRARY JSON_INCLUDE_DIR + ) if(JSON_FOUND) - set(JSON_LIBRARIES ${JSON_LIBRARY}) - # hack to get old and new layout working: - set(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR}/json-c - ${JSON_INCLUDE_DIR}/json) + set(JSON_LIBRARIES ${JSON_LIBRARY}) + set(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR}) endif() mark_as_advanced( - JSON_LIBRARY - JSON_INCLUDE_DIR + JSON_LIBRARY + JSON_INCLUDE_DIRS ) diff --git a/cmake/codeformat.cmake b/cmake/codeformat.cmake new file mode 100644 index 0000000..8f8dfe4 --- /dev/null +++ b/cmake/codeformat.cmake @@ -0,0 +1,14 @@ +find_program (clangformat clang-format) +if (clangformat) + execute_process (COMMAND ${clangformat} -version OUTPUT_VARIABLE version_string) + string (REGEX MATCH "([0-9]\\.[0-9]\\.?[0-9]?)" version "${version_string}") + if (${version} VERSION_LESS "3.9") + message (STATUS "Found ${version_string} less that required clang-format 3.9") + else() + add_custom_target (clang-format + COMMAND find analyzers src tests docs -name '*.h' -o -name '*.cpp' | xargs ${clangformat} -i -style=file + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Reformat sources by clang-format" + SOURCES ${CMAKE_SOURCE_DIR}/.clang-format) + endif() +endif() diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake index 4d0fc96..a79ce34 100644 --- a/cmake/packaging.cmake +++ b/cmake/packaging.cmake @@ -1,3 +1,4 @@ +set (CPACK_PACKAGE_VENDOR "EPAM Systems") set (CPACK_PACKAGE_VERSION ${NST_VERSION}) set (CPACK_PACKAGING_INSTALL_PREFIX "/usr") set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "NFS tracing/monitoring/capturing/statistic tool") @@ -5,7 +6,6 @@ set (CPACK_PACKAGE_CONTACT "Nfstrace developers <nfstrace@epam.com>") set (CPACK_RPM_PACKAGE_GROUP "Applications/Internet") set (CPACK_RPM_PACKAGE_LICENSE "GPLv2") -set (CPACK_RPM_PACKAGE_VENDOR "EPAM Systems") set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man /usr/share/man/man8) set (CPACK_RPM_PACKAGE_REQUIRES "libpcap >= 1.3.0-1") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND EXISTS "/etc/os-release") diff --git a/debian/patches/gcc6-ftbfs.patch b/debian/patches/gcc6-ftbfs.patch deleted file mode 100644 index f99c16e..0000000 --- a/debian/patches/gcc6-ftbfs.patch +++ /dev/null @@ -1,33 +0,0 @@ -Author: Steve Langasek <steve.langasek@canonical.com> -Description: Fix FTBFS with gcc6. - GCC 6 has gotten extraordinarily pedantic, to the point that -Wall -Werror - will fail if indentation is inconsistent. Straighten out our indentation - to let GCC 6 pass. -Bug-Debian: http://bugs.debian.org/835644 - ---- a/src/protocols/nfs/nfs_procedure.h -+++ b/src/protocols/nfs/nfs_procedure.h -@@ -109,9 +109,9 @@ - inline ~NFSProcedure() - { - if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res ); -- xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); -- xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg ); -- xdr_free((xdrproc_t)xdr_callmsg, (char*)&call ); -+ xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); -+ xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg ); -+ xdr_free((xdrproc_t)xdr_callmsg, (char*)&call ); - } - - // pointers to procedure specific argument and result ---- a/src/filtration/sessions_hash.h -+++ b/src/filtration/sessions_hash.h -@@ -100,7 +100,7 @@ - if(s[1] != d[1]) return (s[1] < d[1]) ? Session::Source : Session::Destination; - if(s[2] != d[2]) return (s[2] < d[2]) ? Session::Source : Session::Destination; - -- return (s[3] < d[3]) ? Session::Source : Session::Destination; -+ return (s[3] < d[3]) ? Session::Source : Session::Destination; - } - - static inline void copy_ipv6(uint32_t dst[4], const uint8_t src[16]) diff --git a/debian/patches/no-unaligned-access.patch b/debian/patches/no-unaligned-access.patch deleted file mode 100644 index 9bec4c3..0000000 --- a/debian/patches/no-unaligned-access.patch +++ /dev/null @@ -1,27 +0,0 @@ -Author: Steve Langasek <steve.langasek@ubuntu.com> -Description: Fix unaligned access in buffer copies - There's a TODO in the source about fixing alignment of the address being - copied. This unaligned access is a problem on armhf with some kernel - configurations, and is generally slower even on other architectures due - to the fixups. Just use memcpy instead which is bound to do the right - thing. - -Index: nfstrace-0.4.2/src/filtration/sessions_hash.h -=================================================================== ---- nfstrace-0.4.2.orig/src/filtration/sessions_hash.h -+++ nfstrace-0.4.2/src/filtration/sessions_hash.h -@@ -105,12 +105,8 @@ - - static inline void copy_ipv6(uint32_t dst[4], const uint8_t src[16]) - { -- // TODO:: fix alignment of src! -- const uint32_t* s { reinterpret_cast<const uint32_t*>(src) }; -- dst[0] = s[0]; -- dst[1] = s[1]; -- dst[2] = s[2]; -- dst[3] = s[3]; -+ uint8_t* d { reinterpret_cast<uint8_t*>(dst) }; -+ memcpy(d, src, sizeof(uint32_t) * 4); - } - - struct IPv6PortsKeyHash diff --git a/debian/patches/reproducible_build.patch b/debian/patches/reproducible_build.patch index bb3f9c7..c3fc094 100644 --- a/debian/patches/reproducible_build.patch +++ b/debian/patches/reproducible_build.patch @@ -2,27 +2,6 @@ From: Chris Lamb <lamby@debian.org> Date: 2016-07-17 13:48:59.441176704 +0200 Subject: Build reproducibly. ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -47,7 +47,17 @@ - - set (NST_VERSION_FULL "${PROJECT_NAME} ${NST_VERSION} (${CMAKE_BUILD_TYPE})") - --string (TIMESTAMP COMPILATION_DATE "%Y-%m-%d") -+if (DEFINED ENV{SOURCE_DATE_EPOCH}) -+ execute_process( -+ COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d" -+ OUTPUT_VARIABLE COMPILATION_DATE -+ OUTPUT_STRIP_TRAILING_WHITESPACE) -+else () -+ execute_process( -+ COMMAND "date" "+%Y-%m-%d" -+ OUTPUT_VARIABLE TIMESTAMP -+ OUTPUT_STRIP_TRAILING_WHITESPACE) -+endif () - - include_directories (src) - --- a/src/controller/build_info.h.in +++ b/src/controller/build_info.h.in @@ -29,9 +29,7 @@ @@ -31,7 +10,7 @@ Subject: Build reproducibly. constexpr char PROGRAM_BUILD_INFO[]= - "@NST_VERSION_FULL@\n" - "built on @CMAKE_SYSTEM@\n" -- "by C++ compiler @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"; +- "by C++ compiler @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@ on @COMPILATION_DATE@"; + "@NST_VERSION_FULL@"; constexpr char MODULES_DIRECTORY_PATH[] = "@CMAKE_INSTALL_PREFIX@/lib/nfstrace/"; diff --git a/debian/patches/series b/debian/patches/series index 30db1ba..b2026fe 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1 @@ reproducible_build.patch -gcc6-ftbfs.patch -no-unaligned-access.patch diff --git a/docs/template.cpp b/docs/template.cpp index 18158b2..70553bf 100644 --- a/docs/template.cpp +++ b/docs/template.cpp @@ -31,8 +31,9 @@ const unsigned int SayHello::BAD_COFFEE = 0xBADC0FFE; //------------------------------------------------------------------------------ namespace hello { - -SayHello::SayHello() : text{"Hello, World!"}, value{0} +SayHello::SayHello() + : text{"Hello, World!"} + , value{0} { } SayHello::~SayHello() @@ -61,14 +62,16 @@ int main(int argc, char** argv) assert(42 == hello.get()); // FizzBuzz - for(std::size_t i=1; i<=100; i++) + for(std::size_t i = 1; i <= 100; i++) { if((i % 15) == 0) { std::cout << "FizzBuzz\n"; } - else if(i % 3 == 0) std::cout << "Fizz\n"; - else if(i % 5 == 0) std::cout << "Buzz\n"; + else if(i % 3 == 0) + std::cout << "Fizz\n"; + else if(i % 5 == 0) + std::cout << "Buzz\n"; else { std::cout << i << '\n'; diff --git a/docs/template.h b/docs/template.h index edb2ddc..e6463ed 100644 --- a/docs/template.h +++ b/docs/template.h @@ -22,30 +22,28 @@ #ifndef TEMPLATE_H #define TEMPLATE_H //------------------------------------------------------------------------------ -#include <cstdint> // include language headers in alphabetical order +#include <cstdint> // include language headers in alphabetical order #include <string> //------------------------------------------------------------------------------ -#define MY_MIN(a,b) (((a) < (b)) ? (a) : (b)) //!< This is example of preprocessor usage +#define MY_MIN(a, b) (((a) < (b)) ? (a) : (b)) //!< This is example of preprocessor usage //------------------------------------------------------------------------------ namespace hello { - /*! \class Represents some entity */ class SayHello { public: - SayHello();// May be uncommented - ~SayHello();// May be uncommented + SayHello(); // May be uncommented + ~SayHello(); // May be uncommented - SayHello(const SayHello&) = delete; + SayHello(const SayHello&) = delete; SayHello& operator=(const SayHello&) = delete; /*! small functions may be implemented in-place * \return hello string */ inline const std::string& say() const { return text; } - /*! Sets some value * \param v - new value */ @@ -57,13 +55,13 @@ public: std::uint32_t get_value() const; private: - std::string text;//!< Hello phrase + std::string text; //!< Hello phrase std::uint32_t value; //!< just a value for get/set methods - static const unsigned int BAD_COFFEE;//!< Some constant + static const unsigned int BAD_COFFEE; //!< Some constant }; } // namespace hello //------------------------------------------------------------------------------ -#endif//TEMPLATE_H +#endif //TEMPLATE_H //------------------------------------------------------------------------------ diff --git a/src/analysis/analysis_manager.cpp b/src/analysis/analysis_manager.cpp index f2ad42c..396d866 100644 --- a/src/analysis/analysis_manager.cpp +++ b/src/analysis/analysis_manager.cpp @@ -25,11 +25,10 @@ namespace NST { namespace analysis { - AnalysisManager::AnalysisManager(RunningStatus& status, const Parameters& params) - : analysiss {nullptr} - , queue {nullptr} - , parser_thread{nullptr} + : analysiss{nullptr} + , queue{nullptr} + , parser_thread{nullptr} { analysiss.reset(new Analyzers(params)); diff --git a/src/analysis/analysis_manager.h b/src/analysis/analysis_manager.h index 4bdc8fc..9a29deb 100644 --- a/src/analysis/analysis_manager.h +++ b/src/analysis/analysis_manager.h @@ -26,31 +26,30 @@ #include "analysis/analyzers.h" #include "analysis/parser_thread.h" +#include "analysis/parsers.h" #include "controller/parameters.h" #include "controller/running_status.h" #include "utils/filtered_data.h" -#include "analysis/parsers.h" //------------------------------------------------------------------------------ namespace NST { namespace analysis { - class AnalysisManager { using Parameters = NST::controller::Parameters; using RunningStatus = NST::controller::RunningStatus; using FilteredDataQueue = NST::utils::FilteredDataQueue; + public: AnalysisManager(RunningStatus& status, const Parameters& params); - AnalysisManager(const AnalysisManager&) = delete; + AnalysisManager(const AnalysisManager&) = delete; AnalysisManager& operator=(const AnalysisManager&) = delete; - ~AnalysisManager() = default; + ~AnalysisManager() = default; FilteredDataQueue& get_queue() { return *queue; } - - void start(); - void stop(); + void start(); + void stop(); inline void on_unix_signal(int signo) { @@ -61,14 +60,15 @@ public: { return analysiss->isSilent(); } + private: - std::unique_ptr<Analyzers> analysiss; - std::unique_ptr<FilteredDataQueue> queue; + std::unique_ptr<Analyzers> analysiss; + std::unique_ptr<FilteredDataQueue> queue; std::unique_ptr<ParserThread<Parsers>> parser_thread; }; } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//ANALYSIS_MANAGER_H +#endif //ANALYSIS_MANAGER_H //------------------------------------------------------------------------------ diff --git a/src/analysis/analyzers.cpp b/src/analysis/analyzers.cpp index e6232a4..a4344fe 100644 --- a/src/analysis/analyzers.cpp +++ b/src/analysis/analyzers.cpp @@ -27,9 +27,8 @@ namespace NST { namespace analysis { - Analyzers::Analyzers(const controller::Parameters& params) -: _silent{false} + : _silent{false} { for(const auto& a : params.analysis_modules()) { diff --git a/src/analysis/analyzers.h b/src/analysis/analyzers.h index f8a1c4a..4a33336 100644 --- a/src/analysis/analyzers.h +++ b/src/analysis/analyzers.h @@ -33,24 +33,21 @@ namespace NST { namespace analysis { - class Analyzers { - using Storage = std::vector<IAnalyzer*>; - using Plugins = std::vector< std::unique_ptr<PluginInstance> >; - using BuiltIns= std::vector< std::unique_ptr<IAnalyzer> >; + using Storage = std::vector<IAnalyzer*>; + using Plugins = std::vector<std::unique_ptr<PluginInstance>>; + using BuiltIns = std::vector<std::unique_ptr<IAnalyzer>>; public: Analyzers(const controller::Parameters& params); - Analyzers(const Analyzers&) = delete; + Analyzers(const Analyzers&) = delete; Analyzers& operator=(const Analyzers&) = delete; //! This function is used for passing ALL possible procedures to analyzers - template - < + template < typename Handle, - typename Procedure - > + typename Procedure> inline void operator()(Handle handle, const Procedure& proc) { for(const auto a : modules) @@ -60,11 +57,9 @@ public: } //! This function is used for passing args- or res-only NFS4.x operations (ex. NFSv4 ILLEGAL) to analyzers - template - < + template < typename Handle, - typename ArgOrResType - > + typename ArgOrResType> inline void operator()(Handle handle, const RPCProcedure* rpc, ArgOrResType* arg_or_res) { for(const auto a : modules) @@ -74,12 +69,10 @@ public: } //! This function is used for passing args + res NFS4.x operations (ex. NFSv4.x ACCESS) to analyzers - template - < + template < typename Handle, typename ArgopType, - typename ResopType - > + typename ResopType> inline void operator()(Handle handle, const RPCProcedure* rpc, ArgopType* arg, ResopType* res) { for(const auto a : modules) @@ -107,15 +100,16 @@ public: { return _silent; } + private: Storage modules; // pointers to all modules (plugins and builtins) Plugins plugins; BuiltIns builtin; - bool _silent; + bool _silent; }; } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//ANALYZERS_H +#endif //ANALYZERS_H //------------------------------------------------------------------------------ diff --git a/src/analysis/cifs_parser.cpp b/src/analysis/cifs_parser.cpp index 033615f..c667010 100644 --- a/src/analysis/cifs_parser.cpp +++ b/src/analysis/cifs_parser.cpp @@ -27,18 +27,18 @@ using namespace NST::protocols; using namespace NST::analysis; CIFSParser::CIFSParser(Analyzers& a) -: analyzers(a) + : analyzers(a) { } bool CIFSParser::parse_data(FilteredDataQueue::Ptr& data) { - if (const CIFSv1::MessageHeader* header = CIFSv1::get_header(data->data)) + if(const CIFSv1::MessageHeader* header = CIFSv1::get_header(data->data)) { parse_packet(header, std::move(data)); return true; } - else if (const CIFSv2::MessageHeader* header = CIFSv2::get_header(data->data)) + else if(const CIFSv2::MessageHeader* header = CIFSv2::get_header(data->data)) { parse_packet(header, std::move(data)); return true; @@ -55,15 +55,15 @@ void CIFSParser::parse_packet(const CIFSv1::MessageHeader* header, NST::utils::F using namespace NST::API::SMBv1; using namespace NST::protocols::CIFSv1; - if (header->isFlag(Flags::REPLY)) + if(header->isFlag(Flags::REPLY)) { // It is response - if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY)) + if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY)) { FilteredDataQueue::Ptr&& requestData = session->get_call_data(header->sec.sequenceNumber); - if (requestData) + if(requestData) { - if (const MessageHeader* request = get_header(requestData->data)) + if(const MessageHeader* request = get_header(requestData->data)) { return analyse_operation(session, request, header, std::move(requestData), std::move(ptr)); } @@ -75,7 +75,7 @@ void CIFSParser::parse_packet(const CIFSv1::MessageHeader* header, NST::utils::F else { // It is request - if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL)) + if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL)) { return session->save_call_data(header->sec.sequenceNumber, std::move(ptr)); } @@ -88,15 +88,15 @@ void CIFSParser::parse_packet(const CIFSv2::MessageHeader* header, utils::Filter using namespace NST::API::SMBv2; using namespace NST::protocols::CIFSv2; - if (header->isFlag(Flags::SERVER_TO_REDIR)) + if(header->isFlag(Flags::SERVER_TO_REDIR)) { // It is response - if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY)) + if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY)) { FilteredDataQueue::Ptr&& requestData = session->get_call_data(header->messageId); - if (requestData) + if(requestData) { - if (const MessageHeader* request = get_header(requestData->data)) + if(const MessageHeader* request = get_header(requestData->data)) { return analyse_operation(session, request, header, std::move(requestData), std::move(ptr)); } @@ -108,10 +108,10 @@ void CIFSParser::parse_packet(const CIFSv2::MessageHeader* header, utils::Filter else { // It is request - if (Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL)) + if(Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL)) { // It is async request - if (header->isFlag(Flags::ASYNC_COMMAND)) + if(header->isFlag(Flags::ASYNC_COMMAND)) { return analyse_operation(session, header, nullptr, std::move(ptr), std::move(nullptr)); } @@ -121,7 +121,7 @@ void CIFSParser::parse_packet(const CIFSv2::MessageHeader* header, utils::Filter } } -void CIFSParser::analyse_operation(Session* session, +void CIFSParser::analyse_operation(Session* session, const CIFSv1::MessageHeader* request, const CIFSv1::MessageHeader* /*response*/, NST::utils::FilteredDataQueue::Ptr&& requestData, @@ -130,166 +130,164 @@ void CIFSParser::analyse_operation(Session* session, using namespace NST::API::SMBv1; using namespace NST::protocols::CIFSv1; - //FIXME: code smells. Too much code - switch (request->cmd_code) + switch(request->cmd_code) { case Commands::CREATE_DIRECTORY: - return analyzers(&IAnalyzer::ISMBv1::createDirectorySMBv1, command<CreateDirectoryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::createDirectorySMBv1, command<CreateDirectoryCommand>(requestData, responseData, session)); case Commands::DELETE_DIRECTORY: - return analyzers(&IAnalyzer::ISMBv1::deleteDirectorySMBv1, command<DeleteDirectoryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::deleteDirectorySMBv1, command<DeleteDirectoryCommand>(requestData, responseData, session)); case Commands::OPEN: - return analyzers(&IAnalyzer::ISMBv1::openSMBv1, command<OpenCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::openSMBv1, command<OpenCommand>(requestData, responseData, session)); case Commands::CREATE: - return analyzers(&IAnalyzer::ISMBv1::createSMBv1, command<CreateCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::createSMBv1, command<CreateCommand>(requestData, responseData, session)); case Commands::CLOSE: - return analyzers(&IAnalyzer::ISMBv1::closeSMBv1, command<CloseCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::closeSMBv1, command<CloseCommand>(requestData, responseData, session)); case Commands::FLUSH: - return analyzers(&IAnalyzer::ISMBv1::flushSMBv1, command<FlushCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::flushSMBv1, command<FlushCommand>(requestData, responseData, session)); case Commands::DELETE: - return analyzers(&IAnalyzer::ISMBv1::deleteSMBv1, command<DeleteCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::deleteSMBv1, command<DeleteCommand>(requestData, responseData, session)); case Commands::RENAME: - return analyzers(&IAnalyzer::ISMBv1::renameSMBv1, command<RenameCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::renameSMBv1, command<RenameCommand>(requestData, responseData, session)); case Commands::QUERY_INFORMATION: - return analyzers(&IAnalyzer::ISMBv1::queryInfoSMBv1, command<QueryInformationCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::queryInfoSMBv1, command<QueryInformationCommand>(requestData, responseData, session)); case Commands::SET_INFORMATION: - return analyzers(&IAnalyzer::ISMBv1::setInfoSMBv1, command<SetInformationCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::setInfoSMBv1, command<SetInformationCommand>(requestData, responseData, session)); case Commands::READ: - return analyzers(&IAnalyzer::ISMBv1::readSMBv1, command<ReadCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readSMBv1, command<ReadCommand>(requestData, responseData, session)); case Commands::WRITE: - return analyzers(&IAnalyzer::ISMBv1::writeSMBv1, command<WriteCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeSMBv1, command<WriteCommand>(requestData, responseData, session)); case Commands::LOCK_BYTE_RANGE: - return analyzers(&IAnalyzer::ISMBv1::lockByteRangeSMBv1, command<LockByteRangeCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::lockByteRangeSMBv1, command<LockByteRangeCommand>(requestData, responseData, session)); case Commands::UNLOCK_BYTE_RANGE: - return analyzers(&IAnalyzer::ISMBv1::unlockByteRangeSMBv1, command<UnlockByteRangeCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::unlockByteRangeSMBv1, command<UnlockByteRangeCommand>(requestData, responseData, session)); case Commands::CREATE_TEMPORARY: - return analyzers(&IAnalyzer::ISMBv1::createTmpSMBv1, command<CreateTemporaryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::createTmpSMBv1, command<CreateTemporaryCommand>(requestData, responseData, session)); case Commands::CREATE_NEW: - return analyzers(&IAnalyzer::ISMBv1::createNewSMBv1, command<CreateNewCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::createNewSMBv1, command<CreateNewCommand>(requestData, responseData, session)); case Commands::CHECK_DIRECTORY: - return analyzers(&IAnalyzer::ISMBv1::checkDirectorySMBv1, command<CheckDirectoryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::checkDirectorySMBv1, command<CheckDirectoryCommand>(requestData, responseData, session)); case Commands::PROCESS_EXIT: - return analyzers(&IAnalyzer::ISMBv1::processExitSMBv1, command<ProcessExitCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::processExitSMBv1, command<ProcessExitCommand>(requestData, responseData, session)); case Commands::SEEK: - return analyzers(&IAnalyzer::ISMBv1::seekSMBv1, command<SeekCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::seekSMBv1, command<SeekCommand>(requestData, responseData, session)); case Commands::LOCK_AND_READ: - return analyzers(&IAnalyzer::ISMBv1::lockAndReadSMBv1, command<LockAndReadCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::lockAndReadSMBv1, command<LockAndReadCommand>(requestData, responseData, session)); case Commands::WRITE_AND_UNLOCK: - return analyzers(&IAnalyzer::ISMBv1::writeAndUnlockSMBv1, command<WriteAndUnlockCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeAndUnlockSMBv1, command<WriteAndUnlockCommand>(requestData, responseData, session)); case Commands::READ_RAW: - return analyzers(&IAnalyzer::ISMBv1::readRawSMBv1, command<ReadRawCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readRawSMBv1, command<ReadRawCommand>(requestData, responseData, session)); case Commands::READ_MPX: - return analyzers(&IAnalyzer::ISMBv1::readMpxSMBv1, command<ReadMpxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readMpxSMBv1, command<ReadMpxCommand>(requestData, responseData, session)); case Commands::READ_MPX_SECONDARY: - return analyzers(&IAnalyzer::ISMBv1::readMpxSecondarySMBv1, command<ReadMpxSecondaryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readMpxSecondarySMBv1, command<ReadMpxSecondaryCommand>(requestData, responseData, session)); case Commands::WRITE_RAW: - return analyzers(&IAnalyzer::ISMBv1::writeRawSMBv1, command<WriteRawCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeRawSMBv1, command<WriteRawCommand>(requestData, responseData, session)); case Commands::WRITE_MPX: - return analyzers(&IAnalyzer::ISMBv1::writeMpxSMBv1, command<WriteMpxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeMpxSMBv1, command<WriteMpxCommand>(requestData, responseData, session)); case Commands::WRITE_MPX_SECONDARY: - return analyzers(&IAnalyzer::ISMBv1::writeMpxSecondarySMBv1, command<WriteMpxSecondaryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeMpxSecondarySMBv1, command<WriteMpxSecondaryCommand>(requestData, responseData, session)); case Commands::WRITE_COMPLETE: - return analyzers(&IAnalyzer::ISMBv1::writeCompleteSMBv1, command<WriteCompleteCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeCompleteSMBv1, command<WriteCompleteCommand>(requestData, responseData, session)); case Commands::QUERY_SERVER: - return analyzers(&IAnalyzer::ISMBv1::queryServerSMBv1, command<QueryServerCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::queryServerSMBv1, command<QueryServerCommand>(requestData, responseData, session)); case Commands::SET_INFORMATION2: - return analyzers(&IAnalyzer::ISMBv1::setInfo2SMBv1, command<SetInformation2Command>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::setInfo2SMBv1, command<SetInformation2Command>(requestData, responseData, session)); case Commands::QUERY_INFORMATION2: - return analyzers(&IAnalyzer::ISMBv1::queryInfo2SMBv1, command<QueryInformation2Command>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::queryInfo2SMBv1, command<QueryInformation2Command>(requestData, responseData, session)); case Commands::LOCKING_ANDX: - return analyzers(&IAnalyzer::ISMBv1::lockingAndxSMBv1, command<LockingAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::lockingAndxSMBv1, command<LockingAndxCommand>(requestData, responseData, session)); case Commands::TRANSACTION: - return analyzers(&IAnalyzer::ISMBv1::transactionSMBv1, command<TransactionCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::transactionSMBv1, command<TransactionCommand>(requestData, responseData, session)); case Commands::TRANSACTION_SECONDARY: return analyzers(&IAnalyzer::ISMBv1::transactionSecondarySMBv1, command<TransactionSecondaryCommand>(requestData, responseData, session)); case Commands::IOCTL: - return analyzers(&IAnalyzer::ISMBv1::ioctlSMBv1, command<IoctlCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ioctlSMBv1, command<IoctlCommand>(requestData, responseData, session)); case Commands::IOCTL_SECONDARY: - return analyzers(&IAnalyzer::ISMBv1::ioctlSecondarySMBv1, command<IoctlSecondaryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ioctlSecondarySMBv1, command<IoctlSecondaryCommand>(requestData, responseData, session)); case Commands::COPY: - return analyzers(&IAnalyzer::ISMBv1::copySMBv1, command<CopyCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::copySMBv1, command<CopyCommand>(requestData, responseData, session)); case Commands::MOVE: - return analyzers(&IAnalyzer::ISMBv1::moveSMBv1, command<MoveCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::moveSMBv1, command<MoveCommand>(requestData, responseData, session)); case Commands::ECHO: - return analyzers(&IAnalyzer::ISMBv1::echoSMBv1, command<EchoCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::echoSMBv1, command<EchoCommand>(requestData, responseData, session)); case Commands::WRITE_AND_CLOSE: - return analyzers(&IAnalyzer::ISMBv1::writeAndCloseSMBv1, command<WriteAndCloseCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeAndCloseSMBv1, command<WriteAndCloseCommand>(requestData, responseData, session)); case Commands::OPEN_ANDX: - return analyzers(&IAnalyzer::ISMBv1::openAndxSMBv1, command<OpenAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::openAndxSMBv1, command<OpenAndxCommand>(requestData, responseData, session)); case Commands::READ_ANDX: - return analyzers(&IAnalyzer::ISMBv1::readAndxSMBv1, command<ReadAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readAndxSMBv1, command<ReadAndxCommand>(requestData, responseData, session)); case Commands::WRITE_ANDX: - return analyzers(&IAnalyzer::ISMBv1::writeAndxSMBv1, command<WriteAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeAndxSMBv1, command<WriteAndxCommand>(requestData, responseData, session)); case Commands::NEW_FILE_SIZE: - return analyzers(&IAnalyzer::ISMBv1::newFileSizeSMBv1, command<NewFileSizeCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::newFileSizeSMBv1, command<NewFileSizeCommand>(requestData, responseData, session)); case Commands::CLOSE_AND_TREE_DISC: - return analyzers(&IAnalyzer::ISMBv1::closeAndTreeDiscSMBv1, command<CloseAndTreeDiscCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::closeAndTreeDiscSMBv1, command<CloseAndTreeDiscCommand>(requestData, responseData, session)); case Commands::TRANSACTION2: - return analyzers(&IAnalyzer::ISMBv1::transaction2SMBv1, command<Transaction2Command>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::transaction2SMBv1, command<Transaction2Command>(requestData, responseData, session)); case Commands::TRANSACTION2_SECONDARY: return analyzers(&IAnalyzer::ISMBv1::transaction2SecondarySMBv1, command<Transaction2SecondaryCommand>(requestData, responseData, session)); case Commands::FIND_CLOSE2: - return analyzers(&IAnalyzer::ISMBv1::findClose2SMBv1, command<FindClose2Command>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::findClose2SMBv1, command<FindClose2Command>(requestData, responseData, session)); case Commands::FIND_NOTIFY_CLOSE: - return analyzers(&IAnalyzer::ISMBv1::findNotifyCloseSMBv1, command<FindNotifyCloseCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::findNotifyCloseSMBv1, command<FindNotifyCloseCommand>(requestData, responseData, session)); case Commands::TREE_CONNECT: - return analyzers(&IAnalyzer::ISMBv1::treeConnectSMBv1, command<TreeConnectCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::treeConnectSMBv1, command<TreeConnectCommand>(requestData, responseData, session)); case Commands::TREE_DISCONNECT: - return analyzers(&IAnalyzer::ISMBv1::treeDisconnectSMBv1, command<TreeDisconnectCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::treeDisconnectSMBv1, command<TreeDisconnectCommand>(requestData, responseData, session)); case Commands::NEGOTIATE: - return analyzers(&IAnalyzer::ISMBv1::negotiateSMBv1, command<NegotiateCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::negotiateSMBv1, command<NegotiateCommand>(requestData, responseData, session)); case Commands::SESSION_SETUP_ANDX: - return analyzers(&IAnalyzer::ISMBv1::sessionSetupAndxSMBv1, command<SessionSetupAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::sessionSetupAndxSMBv1, command<SessionSetupAndxCommand>(requestData, responseData, session)); case Commands::LOGOFF_ANDX: - return analyzers(&IAnalyzer::ISMBv1::logoffAndxSMBv1, command<LogoffAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::logoffAndxSMBv1, command<LogoffAndxCommand>(requestData, responseData, session)); case Commands::TREE_CONNECT_ANDX: - return analyzers(&IAnalyzer::ISMBv1::treeConnectAndxSMBv1, command<TreeConnectAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::treeConnectAndxSMBv1, command<TreeConnectAndxCommand>(requestData, responseData, session)); case Commands::SECURITY_PACKAGE_ANDX: - return analyzers(&IAnalyzer::ISMBv1::securityPackageAndxSMBv1, command<SecurityPackageAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::securityPackageAndxSMBv1, command<SecurityPackageAndxCommand>(requestData, responseData, session)); case Commands::QUERY_INFORMATION_DISK: return analyzers(&IAnalyzer::ISMBv1::queryInformationDiskSMBv1, command<QueryInformationDiskCommand>(requestData, responseData, session)); case Commands::SEARCH: - return analyzers(&IAnalyzer::ISMBv1::searchSMBv1, command<SearchCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::searchSMBv1, command<SearchCommand>(requestData, responseData, session)); case Commands::FIND: - return analyzers(&IAnalyzer::ISMBv1::findSMBv1, command<FindCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::findSMBv1, command<FindCommand>(requestData, responseData, session)); case Commands::FIND_UNIQUE: - return analyzers(&IAnalyzer::ISMBv1::findUniqueSMBv1, command<FindUniqueCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::findUniqueSMBv1, command<FindUniqueCommand>(requestData, responseData, session)); case Commands::FIND_CLOSE: - return analyzers(&IAnalyzer::ISMBv1::findCloseSMBv1, command<FindCloseCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::findCloseSMBv1, command<FindCloseCommand>(requestData, responseData, session)); case Commands::NT_TRANSACT: - return analyzers(&IAnalyzer::ISMBv1::ntTransactSMBv1, command<NtTransactCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ntTransactSMBv1, command<NtTransactCommand>(requestData, responseData, session)); case Commands::NT_TRANSACT_SECONDARY: - return analyzers(&IAnalyzer::ISMBv1::ntTransactSecondarySMBv1, command<NtTransactSecondaryCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ntTransactSecondarySMBv1, command<NtTransactSecondaryCommand>(requestData, responseData, session)); case Commands::NT_CREATE_ANDX: - return analyzers(&IAnalyzer::ISMBv1::ntCreateAndxSMBv1, command<NtCreateAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ntCreateAndxSMBv1, command<NtCreateAndxCommand>(requestData, responseData, session)); case Commands::NT_CANCEL: - return analyzers(&IAnalyzer::ISMBv1::ntCancelSMBv1, command<NtCancelCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ntCancelSMBv1, command<NtCancelCommand>(requestData, responseData, session)); case Commands::NT_RENAME: - return analyzers(&IAnalyzer::ISMBv1::ntRenameSMBv1, command<NtRenameCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::ntRenameSMBv1, command<NtRenameCommand>(requestData, responseData, session)); case Commands::OPEN_PRINT_FILE: - return analyzers(&IAnalyzer::ISMBv1::openPrintFileSMBv1, command<OpenPrintFileCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::openPrintFileSMBv1, command<OpenPrintFileCommand>(requestData, responseData, session)); case Commands::WRITE_PRINT_FILE: - return analyzers(&IAnalyzer::ISMBv1::writePrintFileSMBv1, command<WritePrintFileCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writePrintFileSMBv1, command<WritePrintFileCommand>(requestData, responseData, session)); case Commands::CLOSE_PRINT_FILE: - return analyzers(&IAnalyzer::ISMBv1::closePrintFileSMBv1, command<ClosePrintFileCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::closePrintFileSMBv1, command<ClosePrintFileCommand>(requestData, responseData, session)); case Commands::GET_PRINT_QUEUE: - return analyzers(&IAnalyzer::ISMBv1::getPrintQueueSMBv1, command<GetPrintQueueCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::getPrintQueueSMBv1, command<GetPrintQueueCommand>(requestData, responseData, session)); case Commands::READ_BULK: - return analyzers(&IAnalyzer::ISMBv1::readBulkSMBv1, command<ReadBulkCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::readBulkSMBv1, command<ReadBulkCommand>(requestData, responseData, session)); case Commands::WRITE_BULK: - return analyzers(&IAnalyzer::ISMBv1::writeBulkSMBv1, command<WriteBulkCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeBulkSMBv1, command<WriteBulkCommand>(requestData, responseData, session)); case Commands::WRITE_BULK_DATA: - return analyzers(&IAnalyzer::ISMBv1::writeBulkDataSMBv1, command<WriteBulkDataCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::writeBulkDataSMBv1, command<WriteBulkDataCommand>(requestData, responseData, session)); case Commands::INVALID: - return analyzers(&IAnalyzer::ISMBv1::invalidSMBv1, command<InvalidCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::invalidSMBv1, command<InvalidCommand>(requestData, responseData, session)); case Commands::NO_ANDX_COMMAND: - return analyzers(&IAnalyzer::ISMBv1::noAndxCommandSMBv1, command<NoAndxCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv1::noAndxCommandSMBv1, command<NoAndxCommand>(requestData, responseData, session)); default: LOG("Usupported command"); } } - -void CIFSParser::analyse_operation(Session* session, +void CIFSParser::analyse_operation(Session* session, const CIFSv2::MessageHeader* request, const CIFSv2::MessageHeader* /*response*/, NST::utils::FilteredDataQueue::Ptr&& requestData, @@ -298,46 +296,46 @@ void CIFSParser::analyse_operation(Session* session, using namespace NST::API::SMBv2; using namespace NST::protocols::CIFSv2; - switch (request->cmd_code) + switch(request->cmd_code) { case SMBv2Commands::CLOSE: - return analyzers(&IAnalyzer::ISMBv2::closeFileSMBv2, command<CloseFileCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::closeFileSMBv2, command<CloseFileCommand>(requestData, responseData, session)); case SMBv2Commands::NEGOTIATE: - return analyzers(&IAnalyzer::ISMBv2::negotiateSMBv2, command<NegotiateCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::negotiateSMBv2, command<NegotiateCommand>(requestData, responseData, session)); case SMBv2Commands::SESSION_SETUP: - return analyzers(&IAnalyzer::ISMBv2::sessionSetupSMBv2, command<SessionSetupCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::sessionSetupSMBv2, command<SessionSetupCommand>(requestData, responseData, session)); case SMBv2Commands::LOGOFF: - return analyzers(&IAnalyzer::ISMBv2::logOffSMBv2, command<LogOffCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::logOffSMBv2, command<LogOffCommand>(requestData, responseData, session)); case SMBv2Commands::TREE_CONNECT: - return analyzers(&IAnalyzer::ISMBv2::treeConnectSMBv2, command<TreeConnectCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::treeConnectSMBv2, command<TreeConnectCommand>(requestData, responseData, session)); case SMBv2Commands::TREE_DISCONNECT: - return analyzers(&IAnalyzer::ISMBv2::treeDisconnectSMBv2, command<TreeDisconnectCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::treeDisconnectSMBv2, command<TreeDisconnectCommand>(requestData, responseData, session)); case SMBv2Commands::CREATE: - return analyzers(&IAnalyzer::ISMBv2::createSMBv2, command<CreateCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::createSMBv2, command<CreateCommand>(requestData, responseData, session)); case SMBv2Commands::FLUSH: - return analyzers(&IAnalyzer::ISMBv2::flushSMBv2, command<FlushCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::flushSMBv2, command<FlushCommand>(requestData, responseData, session)); case SMBv2Commands::READ: - return analyzers(&IAnalyzer::ISMBv2::readSMBv2, command<ReadCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::readSMBv2, command<ReadCommand>(requestData, responseData, session)); case SMBv2Commands::WRITE: - return analyzers(&IAnalyzer::ISMBv2::writeSMBv2, command<WriteCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::writeSMBv2, command<WriteCommand>(requestData, responseData, session)); case SMBv2Commands::LOCK: - return analyzers(&IAnalyzer::ISMBv2::lockSMBv2, command<LockCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::lockSMBv2, command<LockCommand>(requestData, responseData, session)); case SMBv2Commands::IOCTL: - return analyzers(&IAnalyzer::ISMBv2::ioctlSMBv2, command<IoctlCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::ioctlSMBv2, command<IoctlCommand>(requestData, responseData, session)); case SMBv2Commands::CANCEL: - return analyzers(&IAnalyzer::ISMBv2::cancelSMBv2, command<CancelCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::cancelSMBv2, command<CancelCommand>(requestData, responseData, session)); case SMBv2Commands::ECHO: - return analyzers(&IAnalyzer::ISMBv2::echoSMBv2, command<EchoCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::echoSMBv2, command<EchoCommand>(requestData, responseData, session)); case SMBv2Commands::QUERY_DIRECTORY: - return analyzers(&IAnalyzer::ISMBv2::queryDirSMBv2, command<QueryDirCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::queryDirSMBv2, command<QueryDirCommand>(requestData, responseData, session)); case SMBv2Commands::CHANGE_NOTIFY: - return analyzers(&IAnalyzer::ISMBv2::changeNotifySMBv2, command<ChangeNotifyCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::changeNotifySMBv2, command<ChangeNotifyCommand>(requestData, responseData, session)); case SMBv2Commands::QUERY_INFO: - return analyzers(&IAnalyzer::ISMBv2::queryInfoSMBv2, command<QueryInfoCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::queryInfoSMBv2, command<QueryInfoCommand>(requestData, responseData, session)); case SMBv2Commands::SET_INFO: - return analyzers(&IAnalyzer::ISMBv2::setInfoSMBv2, command<SetInfoCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::setInfoSMBv2, command<SetInfoCommand>(requestData, responseData, session)); case SMBv2Commands::OPLOCK_BREAK: - return analyzers(&IAnalyzer::ISMBv2::breakOplockSMBv2, command<BreakOpLockCommand>(requestData, responseData, session)); + return analyzers(&IAnalyzer::ISMBv2::breakOplockSMBv2, command<BreakOpLockCommand>(requestData, responseData, session)); default: LOG("Usupported command"); } diff --git a/src/analysis/cifs_parser.h b/src/analysis/cifs_parser.h index de81ade..581e9fa 100644 --- a/src/analysis/cifs_parser.h +++ b/src/analysis/cifs_parser.h @@ -32,15 +32,14 @@ namespace NST { namespace analysis { - /*! \class It is class which can parse CIFS messages and it called by ParserThread */ class CIFSParser { - using FilteredDataQueue = NST::utils::FilteredDataQueue;//!< Packets queue + using FilteredDataQueue = NST::utils::FilteredDataQueue; //!< Packets queue - Analyzers& analyzers;//!< Plugins manager - Sessions<Session> sessions;//!< Sessions list + Analyzers& analyzers; //!< Plugins manager + Sessions<Session> sessions; //!< Sessions list /*! Parses SMBv1 packet * \param header - Message's header @@ -55,11 +54,11 @@ class CIFSParser * \param requestData - Call's data * \param responseData - Reply's data */ - inline void analyse_operation(Session* session, + inline void analyse_operation(Session* session, const protocols::CIFSv1::MessageHeader* request, const protocols::CIFSv1::MessageHeader* response, - FilteredDataQueue::Ptr&& requestData, - FilteredDataQueue::Ptr&& responseData); + FilteredDataQueue::Ptr&& requestData, + FilteredDataQueue::Ptr&& responseData); /*! Parses SMB v2 packet * \param header - Message's header @@ -74,15 +73,18 @@ class CIFSParser * \param requestData - Call's data * \param responseData - Reply's data */ - inline void analyse_operation(Session* session, + inline void analyse_operation(Session* session, const protocols::CIFSv2::MessageHeader* request, const protocols::CIFSv2::MessageHeader* response, - FilteredDataQueue::Ptr&& requestData, - FilteredDataQueue::Ptr&& responseData); -public: + FilteredDataQueue::Ptr&& requestData, + FilteredDataQueue::Ptr&& responseData); +public: CIFSParser(Analyzers& a); - CIFSParser(CIFSParser& c) : analyzers(c.analyzers) {} + CIFSParser(CIFSParser& c) + : analyzers(c.analyzers) + { + } /*! Function which will be called by ParserThread class * \param data - raw packet @@ -94,5 +96,5 @@ public: } // analysis } // NST //------------------------------------------------------------------------------ -#endif//CIFS_PARSER_H +#endif //CIFS_PARSER_H //------------------------------------------------------------------------------ diff --git a/src/analysis/nfs_parser.cpp b/src/analysis/nfs_parser.cpp index 9bff62a..0f3505a 100644 --- a/src/analysis/nfs_parser.cpp +++ b/src/analysis/nfs_parser.cpp @@ -31,34 +31,32 @@ namespace NST { namespace analysis { - - bool NFSParser::parse_data(FilteredDataQueue::Ptr& ptr) { using namespace NST::protocols::rpc; // TODO: refactor and generalize this code - if (ptr->dlen < sizeof(MessageHeader)) + if(ptr->dlen < sizeof(MessageHeader)) { return false; } auto msg = reinterpret_cast<const MessageHeader*>(ptr->data); - switch (msg->type()) + switch(msg->type()) { case MsgType::CALL: { - if (ptr->dlen < sizeof(CallHeader)) + if(ptr->dlen < sizeof(CallHeader)) { return false; } auto call = static_cast<const CallHeader*>(msg); - if (RPCValidator::check(call) && (protocols::NFS4::Validator::check(call) || - protocols::NFS3::Validator::check(call))) + if(RPCValidator::check(call) && (protocols::NFS4::Validator::check(call) || + protocols::NFS3::Validator::check(call))) { Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::CALL); - if (session) + if(session) { session->save_call_data(call->xid(), std::move(ptr)); } @@ -68,22 +66,22 @@ bool NFSParser::parse_data(FilteredDataQueue::Ptr& ptr) break; case MsgType::REPLY: { - if (ptr->dlen < sizeof(ReplyHeader)) + if(ptr->dlen < sizeof(ReplyHeader)) { return false; } auto reply = static_cast<const ReplyHeader*>(msg); - if (!RPCValidator::check(reply)) + if(!RPCValidator::check(reply)) { return false; } Session* session = sessions.get_session(ptr->session, ptr->direction, MsgType::REPLY); - if (session) + if(session) { FilteredDataQueue::Ptr&& call_data = session->get_call_data(reply->xid()); - if (call_data) + if(call_data) { analyze_nfs_procedure(std::move(call_data), std::move(ptr), session); } @@ -104,35 +102,33 @@ static uint32_t get_nfs4_compound_minor_version(const uint32_t procedure, const using NFS40CompoundType = NST::protocols::NFS4::NFSPROC4RPCGEN_COMPOUND; using NFS41CompoundType = NST::protocols::NFS41::NFSPROC41RPCGEN_COMPOUND; -template -< -typename ArgOpType, - typename ResOpType, - typename NFS4CompoundType - > +template < + typename ArgOpType, + typename ResOpType, + typename NFS4CompoundType> void analyze_nfs4_operations(Analyzers& analyzers, NFS4CompoundType& nfs4_compound_procedure); inline void analyze_nfs40_operations(Analyzers& analyzers, NFS40CompoundType& nfs40_compound_procedure) { - analyze_nfs4_operations < NST::API::NFS4::nfs_argop4, + analyze_nfs4_operations<NST::API::NFS4::nfs_argop4, NST::API::NFS4::nfs_resop4, - NFS40CompoundType > (analyzers, nfs40_compound_procedure); + NFS40CompoundType>(analyzers, nfs40_compound_procedure); } inline void analyze_nfs41_operations(Analyzers& analyzers, NFS41CompoundType& nfs41_compound_procedure) { - analyze_nfs4_operations < NST::API::NFS41::nfs_argop4, + analyze_nfs4_operations<NST::API::NFS41::nfs_argop4, NST::API::NFS41::nfs_resop4, - NFS41CompoundType > (analyzers, nfs41_compound_procedure); + NFS41CompoundType>(analyzers, nfs41_compound_procedure); } -void nfs4_ops_switch(Analyzers& analyzers, - const RPCProcedure* rpc_procedure, +void nfs4_ops_switch(Analyzers& analyzers, + const RPCProcedure* rpc_procedure, const NST::API::NFS4::nfs_argop4* arg, const NST::API::NFS4::nfs_resop4* res); -void nfs4_ops_switch(Analyzers& analyzers, - const RPCProcedure* rpc_procedure, +void nfs4_ops_switch(Analyzers& analyzers, + const RPCProcedure* rpc_procedure, const NST::API::NFS41::nfs_argop4* arg, const NST::API::NFS41::nfs_resop4* res); @@ -141,73 +137,73 @@ void nfs4_ops_switch(Analyzers& analyzers, static inline void analyze_nfsv3_procedure(const uint32_t procedure, XDRDecoder&& c, XDRDecoder&& r, const Session* s, Analyzers& analyzers) { using namespace NST::protocols::NFS3; - switch (procedure) + switch(procedure) { case ProcEnumNFS3::NFS_NULL: - analyzers(&IAnalyzer::INFSv3rpcgen::null, NFSPROC3RPCGEN_NULL {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::null, NFSPROC3RPCGEN_NULL{c, r, s}); break; case ProcEnumNFS3::GETATTR: - analyzers(&IAnalyzer::INFSv3rpcgen::getattr3, NFSPROC3RPCGEN_GETATTR {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::getattr3, NFSPROC3RPCGEN_GETATTR{c, r, s}); break; case ProcEnumNFS3::SETATTR: - analyzers(&IAnalyzer::INFSv3rpcgen::setattr3, NFSPROC3RPCGEN_SETATTR {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::setattr3, NFSPROC3RPCGEN_SETATTR{c, r, s}); break; case ProcEnumNFS3::LOOKUP: - analyzers(&IAnalyzer::INFSv3rpcgen::lookup3, NFSPROC3RPCGEN_LOOKUP {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::lookup3, NFSPROC3RPCGEN_LOOKUP{c, r, s}); break; case ProcEnumNFS3::ACCESS: - analyzers(&IAnalyzer::INFSv3rpcgen::access3, NFSPROC3RPCGEN_ACCESS {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::access3, NFSPROC3RPCGEN_ACCESS{c, r, s}); break; case ProcEnumNFS3::READLINK: - analyzers(&IAnalyzer::INFSv3rpcgen::readlink3, NFSPROC3RPCGEN_READLINK {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::readlink3, NFSPROC3RPCGEN_READLINK{c, r, s}); break; case ProcEnumNFS3::READ: - analyzers(&IAnalyzer::INFSv3rpcgen::read3, NFSPROC3RPCGEN_READ {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::read3, NFSPROC3RPCGEN_READ{c, r, s}); break; case ProcEnumNFS3::WRITE: - analyzers(&IAnalyzer::INFSv3rpcgen::write3, NFSPROC3RPCGEN_WRITE {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::write3, NFSPROC3RPCGEN_WRITE{c, r, s}); break; case ProcEnumNFS3::CREATE: - analyzers(&IAnalyzer::INFSv3rpcgen::create3, NFSPROC3RPCGEN_CREATE {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::create3, NFSPROC3RPCGEN_CREATE{c, r, s}); break; case ProcEnumNFS3::MKDIR: - analyzers(&IAnalyzer::INFSv3rpcgen::mkdir3, NFSPROC3RPCGEN_MKDIR {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::mkdir3, NFSPROC3RPCGEN_MKDIR{c, r, s}); break; case ProcEnumNFS3::SYMLINK: - analyzers(&IAnalyzer::INFSv3rpcgen::symlink3, NFSPROC3RPCGEN_SYMLINK {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::symlink3, NFSPROC3RPCGEN_SYMLINK{c, r, s}); break; case ProcEnumNFS3::MKNOD: - analyzers(&IAnalyzer::INFSv3rpcgen::mknod3, NFSPROC3RPCGEN_MKNOD {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::mknod3, NFSPROC3RPCGEN_MKNOD{c, r, s}); break; case ProcEnumNFS3::REMOVE: - analyzers(&IAnalyzer::INFSv3rpcgen::remove3, NFSPROC3RPCGEN_REMOVE {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::remove3, NFSPROC3RPCGEN_REMOVE{c, r, s}); break; case ProcEnumNFS3::RMDIR: - analyzers(&IAnalyzer::INFSv3rpcgen::rmdir3, NFSPROC3RPCGEN_RMDIR {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::rmdir3, NFSPROC3RPCGEN_RMDIR{c, r, s}); break; case ProcEnumNFS3::RENAME: - analyzers(&IAnalyzer::INFSv3rpcgen::rename3, NFSPROC3RPCGEN_RENAME {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::rename3, NFSPROC3RPCGEN_RENAME{c, r, s}); break; case ProcEnumNFS3::LINK: - analyzers(&IAnalyzer::INFSv3rpcgen::link3, NFSPROC3RPCGEN_LINK {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::link3, NFSPROC3RPCGEN_LINK{c, r, s}); break; case ProcEnumNFS3::READDIR: - analyzers(&IAnalyzer::INFSv3rpcgen::readdir3, NFSPROC3RPCGEN_READDIR {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::readdir3, NFSPROC3RPCGEN_READDIR{c, r, s}); break; case ProcEnumNFS3::READDIRPLUS: - analyzers(&IAnalyzer::INFSv3rpcgen::readdirplus3, NFSPROC3RPCGEN_READDIRPLUS {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::readdirplus3, NFSPROC3RPCGEN_READDIRPLUS{c, r, s}); break; case ProcEnumNFS3::FSSTAT: - analyzers(&IAnalyzer::INFSv3rpcgen::fsstat3, NFSPROC3RPCGEN_FSSTAT {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::fsstat3, NFSPROC3RPCGEN_FSSTAT{c, r, s}); break; case ProcEnumNFS3::FSINFO: - analyzers(&IAnalyzer::INFSv3rpcgen::fsinfo3, NFSPROC3RPCGEN_FSINFO {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::fsinfo3, NFSPROC3RPCGEN_FSINFO{c, r, s}); break; case ProcEnumNFS3::PATHCONF: - analyzers(&IAnalyzer::INFSv3rpcgen::pathconf3, NFSPROC3RPCGEN_PATHCONF {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::pathconf3, NFSPROC3RPCGEN_PATHCONF{c, r, s}); break; case ProcEnumNFS3::COMMIT: - analyzers(&IAnalyzer::INFSv3rpcgen::commit3, NFSPROC3RPCGEN_COMMIT {c, r, s}); + analyzers(&IAnalyzer::INFSv3rpcgen::commit3, NFSPROC3RPCGEN_COMMIT{c, r, s}); break; } } @@ -217,25 +213,25 @@ static inline void analyze_nfsv4_procedure(const uint32_t procedure, XDRDecoder& using namespace NST::protocols::NFS4; using namespace NST::protocols::NFS41; - switch (get_nfs4_compound_minor_version(procedure, c.data().data)) + switch(get_nfs4_compound_minor_version(procedure, c.data().data)) { case NFS_V40: - switch (procedure) + switch(procedure) { case ProcEnumNFS4::NFS_NULL: - analyzers(&IAnalyzer::INFSv4rpcgen::null4, NFSPROC4RPCGEN_NULL { c, r, s }); + analyzers(&IAnalyzer::INFSv4rpcgen::null4, NFSPROC4RPCGEN_NULL{c, r, s}); break; case ProcEnumNFS4::COMPOUND: - NFSPROC4RPCGEN_COMPOUND compound { c, r, s }; + NFSPROC4RPCGEN_COMPOUND compound{c, r, s}; analyzers(&IAnalyzer::INFSv4rpcgen::compound4, compound); analyze_nfs40_operations(analyzers, compound); break; } break; case NFS_V41: - if (ProcEnumNFS41::COMPOUND == procedure) + if(ProcEnumNFS41::COMPOUND == procedure) { - NFSPROC41RPCGEN_COMPOUND compound { c, r, s }; + NFSPROC41RPCGEN_COMPOUND compound{c, r, s}; analyzers(&IAnalyzer::INFSv41rpcgen::compound41, compound); analyze_nfs41_operations(analyzers, compound); } @@ -243,21 +239,21 @@ static inline void analyze_nfsv4_procedure(const uint32_t procedure, XDRDecoder& } } -void NFSParser::analyze_nfs_procedure( FilteredDataQueue::Ptr&& call, - FilteredDataQueue::Ptr&& reply, - Session* session) +void NFSParser::analyze_nfs_procedure(FilteredDataQueue::Ptr&& call, + FilteredDataQueue::Ptr&& reply, + Session* session) { using namespace NST::protocols::rpc; - auto header = reinterpret_cast<const CallHeader*>(call->data); - const uint32_t major_version {header->vers()}; - const uint32_t procedure {header->proc()}; + auto header = reinterpret_cast<const CallHeader*>(call->data); + const uint32_t major_version{header->vers()}; + const uint32_t procedure{header->proc()}; try { - const Session* s { session->get_session() }; + const Session* s{session->get_session()}; - switch (major_version) + switch(major_version) { case NFS_V4: analyze_nfsv4_procedure(procedure, std::move(call), std::move(reply), s, this->analyzers); @@ -267,10 +263,10 @@ void NFSParser::analyze_nfs_procedure( FilteredDataQueue::Ptr&& call, break; } } - catch (XDRDecoderError& e) + catch(XDRDecoderError& e) { - const char* procedure_name {"Unknown procedure"}; - switch (major_version) + const char* procedure_name{"Unknown procedure"}; + switch(major_version) { case NFS_V4: procedure_name = print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(procedure)); @@ -294,7 +290,7 @@ void NFSParser::analyze_nfs_procedure( FilteredDataQueue::Ptr&& call, */ static uint32_t get_nfs4_compound_minor_version(const uint32_t procedure, const std::uint8_t* rpc_nfs4_call) { - if (ProcEnumNFS4::COMPOUND != procedure) + if(ProcEnumNFS4::COMPOUND != procedure) { return 0; } @@ -321,40 +317,39 @@ static uint32_t get_nfs4_compound_minor_version(const uint32_t procedure, const //! Common internal function for parsing NFSv4.x's COMPOUND procedure //! It's supposed to be used inside analyze_nfs_procedure only -template -< -typename ArgOpType, // Type of arguments(call part of nfs's procedure) - typename ResOpType, // Type of results(reply part of nfs's procedure) - typename NFS4CompoundType // Type of NFSv4.x COMPOUND procedure. Can be 4.0 or 4.1 - > +template < + typename ArgOpType, // Type of arguments(call part of nfs's procedure) + typename ResOpType, // Type of results(reply part of nfs's procedure) + typename NFS4CompoundType // Type of NFSv4.x COMPOUND procedure. Can be 4.0 or 4.1 + > void analyze_nfs4_operations(Analyzers& analyzers, NFS4CompoundType& nfs4_compound_procedure) { - ArgOpType* arg {nullptr}; - ResOpType* res {nullptr}; + ArgOpType* arg{nullptr}; + ResOpType* res{nullptr}; - uint32_t arg_ops_count {0}; // Amount of NFS operations (call part) - uint32_t res_ops_count {0}; // Amount of NFS operations (reply part) - uint32_t total_ops_count {0}; + uint32_t arg_ops_count{0}; // Amount of NFS operations (call part) + uint32_t res_ops_count{0}; // Amount of NFS operations (reply part) + uint32_t total_ops_count{0}; - if (nfs4_compound_procedure.parg) // Checking if COMPOUND procedure has valid arg + if(nfs4_compound_procedure.parg) // Checking if COMPOUND procedure has valid arg { arg_ops_count = nfs4_compound_procedure.parg->argarray.argarray_len; - arg = nfs4_compound_procedure.parg->argarray.argarray_val; + arg = nfs4_compound_procedure.parg->argarray.argarray_val; } - if (nfs4_compound_procedure.pres) // Checking if COMPOUND procedure has valid res + if(nfs4_compound_procedure.pres) // Checking if COMPOUND procedure has valid res { res_ops_count = nfs4_compound_procedure.pres->resarray.resarray_len; - res = nfs4_compound_procedure.pres->resarray.resarray_val; + res = nfs4_compound_procedure.pres->resarray.resarray_val; } // Determing which part of COMPOUND has the biggest amount of operations. total_ops_count = arg_ops_count > res_ops_count ? arg_ops_count : res_ops_count; // Traversing through ALL COMPOUND procedure's operations - for (uint32_t i {0}; i < total_ops_count; i++) + for(uint32_t i{0}; i < total_ops_count; i++) { - if ((arg && res) && (arg->argop != res->resop)) + if((arg && res) && (arg->argop != res->resop)) { // Passing each operation to analyzers using the helper's function nfs4_ops_switch(analyzers, &nfs4_compound_procedure, arg, nullptr); @@ -365,58 +360,66 @@ void analyze_nfs4_operations(Analyzers& analyzers, NFS4CompoundType& nfs4_compou nfs4_ops_switch(analyzers, &nfs4_compound_procedure, arg, res); } - if (arg && i < (arg_ops_count - 1)) { arg++; } - else { arg = nullptr; } - if (res && i < (res_ops_count - 1)) { res++; } - else { res = nullptr; } + if(arg && i < (arg_ops_count - 1)) + { + arg++; + } + else + { + arg = nullptr; + } + if(res && i < (res_ops_count - 1)) + { + res++; + } + else + { + res = nullptr; + } } } //! Internal function for proper passing NFSv4.x's arg + res operations to analyzers //! It's supposed to be used inside nfs4_ops_switch only -template -< -typename nfs_argop4_t, - typename nfs_resop4_t, - typename IAnalyzer_func_t, - typename nfs_argop_member_t, - typename nfs_resop_member_t - > -inline void analyze(Analyzers& analyzers, +template < + typename nfs_argop4_t, + typename nfs_resop4_t, + typename IAnalyzer_func_t, + typename nfs_argop_member_t, + typename nfs_resop_member_t> +inline void analyze(Analyzers& analyzers, const RPCProcedure* rpc_procedure, const nfs_argop4_t* arg, const nfs_resop4_t* res, - IAnalyzer_func_t&& IAnalyzer_function, - nfs_argop_member_t arg_operation, - nfs_resop_member_t res_operation) + IAnalyzer_func_t&& IAnalyzer_function, + nfs_argop_member_t arg_operation, + nfs_resop_member_t res_operation) { analyzers(IAnalyzer_function, rpc_procedure, - arg == nullptr ? nullptr : & (arg->nfs_argop4_u.*arg_operation), - res == nullptr ? nullptr : & (res->nfs_resop4_u.*res_operation)); + arg == nullptr ? nullptr : &(arg->nfs_argop4_u.*arg_operation), + res == nullptr ? nullptr : &(res->nfs_resop4_u.*res_operation)); } //! Internal function for proper passing NFSv4.x's res-only operations to analyzers //! It's supposed to be used inside nfs4_ops_switch only -template -< -typename nfs_resop4_t, - typename IAnalyzer_func_t, - typename nfs_resop_member_t - > -inline void analyze(Analyzers& analyzers, +template < + typename nfs_resop4_t, + typename IAnalyzer_func_t, + typename nfs_resop_member_t> +inline void analyze(Analyzers& analyzers, const RPCProcedure* rpc_procedure, const nfs_resop4_t* res, - IAnalyzer_func_t&& IAnalyzer_function, - nfs_resop_member_t res_operation) + IAnalyzer_func_t&& IAnalyzer_function, + nfs_resop_member_t res_operation) { analyzers(IAnalyzer_function, rpc_procedure, - res == nullptr ? nullptr : & (res->nfs_resop4_u.*res_operation)); + res == nullptr ? nullptr : &(res->nfs_resop4_u.*res_operation)); } //! Internal function for proper passing NFSv4.0's operations to analyzers //! It's supposed to be used inside analyze_nfs4_operations only -void nfs4_ops_switch(Analyzers& analyzers, - const RPCProcedure* rpc_procedure, +void nfs4_ops_switch(Analyzers& analyzers, + const RPCProcedure* rpc_procedure, const NST::API::NFS4::nfs_argop4* arg, const NST::API::NFS4::nfs_resop4* res) { @@ -425,7 +428,7 @@ void nfs4_ops_switch(Analyzers& analyzers, using res_t = NST::API::NFS4::nfs_resop4_u_t; uint32_t nfs_op_num = arg ? arg->argop : res->resop; - switch (nfs_op_num) + switch(nfs_op_num) { case ProcEnumNFS4::ACCESS: analyze(analyzers, rpc_procedure, arg, res, @@ -660,8 +663,8 @@ void nfs4_ops_switch(Analyzers& analyzers, //! Internal function for proper passing NFSv4.1's operations to analyzers //! It's supposed to be used inside analyze_nfs4_operations only -void nfs4_ops_switch(Analyzers& analyzers, - const RPCProcedure* rpc_procedure, +void nfs4_ops_switch(Analyzers& analyzers, + const RPCProcedure* rpc_procedure, const NST::API::NFS41::nfs_argop4* arg, const NST::API::NFS41::nfs_resop4* res) { @@ -670,7 +673,7 @@ void nfs4_ops_switch(Analyzers& analyzers, using res_t = NST::API::NFS41::nfs_resop4_u_t; uint32_t nfs_op_num = arg ? arg->argop : res->resop; - switch (nfs_op_num) + switch(nfs_op_num) { case ProcEnumNFS41::ACCESS: analyze(analyzers, rpc_procedure, arg, res, diff --git a/src/analysis/nfs_parser.h b/src/analysis/nfs_parser.h index 4ef6666..2e74ac3 100644 --- a/src/analysis/nfs_parser.h +++ b/src/analysis/nfs_parser.h @@ -32,19 +32,24 @@ namespace NST { namespace analysis { - /*! \class It is class which can parse NFS messages and it called by ParserThread */ class NFSParser { using FilteredDataQueue = NST::utils::FilteredDataQueue; - Analyzers& analyzers; + Analyzers& analyzers; Sessions<Session> sessions; -public: - NFSParser(Analyzers& a) : analyzers(a) {} - NFSParser(NFSParser& c) : analyzers(c.analyzers) {} +public: + NFSParser(Analyzers& a) + : analyzers(a) + { + } + NFSParser(NFSParser& c) + : analyzers(c.analyzers) + { + } /*! Function which will be called by ParserThread class * \param data - RPC packet @@ -55,11 +60,11 @@ public: void parse_data(FilteredDataQueue::Ptr&& data); void analyze_nfs_procedure(FilteredDataQueue::Ptr&& call, FilteredDataQueue::Ptr&& reply, - Session* session); + Session* session); }; } // analysis } // NST //------------------------------------------------------------------------------ -#endif//NFS_PARSER_H +#endif //NFS_PARSER_H //------------------------------------------------------------------------------ diff --git a/src/analysis/parser_thread.h b/src/analysis/parser_thread.h index 66f6ec7..250bec1 100644 --- a/src/analysis/parser_thread.h +++ b/src/analysis/parser_thread.h @@ -33,24 +33,24 @@ namespace NST { namespace analysis { - template <typename Parser> class ParserThread { using RunningStatus = NST::controller::RunningStatus; using FilteredDataQueue = NST::utils::FilteredDataQueue; + public: ParserThread(Parser p, FilteredDataQueue& q, RunningStatus& s) - : status (s) - , queue (q) - , running {ATOMIC_FLAG_INIT} // false - , parser(p) + : status(s) + , queue(q) + , running{ATOMIC_FLAG_INIT} // false + , parser(p) { } ~ParserThread() { - if (parsing.joinable()) stop(); + if(parsing.joinable()) stop(); } void start() @@ -65,9 +65,7 @@ public: parsing.join(); } - private: - inline void thread() { try @@ -103,21 +101,20 @@ private: { FilteredDataQueue::Ptr data = list.get_current(); parser.parse_data(data); - } - while(list); + } while(list); } } - RunningStatus& status; + RunningStatus& status; FilteredDataQueue& queue; - std::thread parsing; + std::thread parsing; std::atomic_flag running; - Parser parser; + Parser parser; }; } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS_PARSER_THREAD_H +#endif //NFS_PARSER_THREAD_H //------------------------------------------------------------------------------ diff --git a/src/analysis/parsers.h b/src/analysis/parsers.h index b60fdbb..293e6dd 100644 --- a/src/analysis/parsers.h +++ b/src/analysis/parsers.h @@ -30,41 +30,40 @@ namespace NST { namespace analysis { - /*! * Composite parser which parses both CIFS&NFS */ class Parsers { using FilteredDataQueue = NST::utils::FilteredDataQueue; - CIFSParser parser_cifs;//!< CIFS parser - NFSParser parser_nfs;//!< NFS parser + CIFSParser parser_cifs; //!< CIFS parser + NFSParser parser_nfs; //!< NFS parser public: - Parsers(Analyzers& a) : parser_cifs(a) , parser_nfs(a) - {} + { + } Parsers(Parsers& c) : parser_cifs(c.parser_cifs) , parser_nfs(c.parser_nfs) - {} + { + } /*! Function which will be called by ParserThread class * \param data - packet */ inline void parse_data(FilteredDataQueue::Ptr& data) { - if (!parser_nfs.parse_data(data)) + if(!parser_nfs.parse_data(data)) { - if (!parser_cifs.parse_data(data)) + if(!parser_cifs.parse_data(data)) { LOG("Unknown packet to analysis"); } } } - }; } // analysis diff --git a/src/analysis/plugin.cpp b/src/analysis/plugin.cpp index 90adba7..cb09594 100644 --- a/src/analysis/plugin.cpp +++ b/src/analysis/plugin.cpp @@ -27,14 +27,13 @@ namespace NST { namespace analysis { - bool Plugin::isSilent() { - if (requirements != nullptr) + if(requirements != nullptr) { // Processing analyzer requirements const AnalyzerRequirements* r = requirements(); - if (r != nullptr) + if(r != nullptr) { return r->silence; } @@ -44,8 +43,8 @@ bool Plugin::isSilent() Plugin::Plugin(const std::string& path) : DynamicLoad{path} - , usage {nullptr} - , create {nullptr} + , usage{nullptr} + , create{nullptr} , destroy{nullptr} , requirements{nullptr} { @@ -65,13 +64,13 @@ Plugin::Plugin(const std::string& path) // Add 2.0 specific initialization here case NST_PLUGIN_API_VERSION: default: - usage = entry_points->usage; - create = entry_points->create; - destroy = entry_points->destroy; + usage = entry_points->usage; + create = entry_points->create; + destroy = entry_points->destroy; requirements = entry_points->requirements; } - if(!usage || !create || !destroy) + if(!usage || !create || !destroy) { throw std::runtime_error{path + ": can't load entry point for some plugin function(s)"}; } @@ -84,7 +83,7 @@ const std::string Plugin::usage_of(const std::string& path) } PluginInstance::PluginInstance(const std::string& path, const std::string& args) -: Plugin{path} + : Plugin{path} { analysis = create(args.c_str()); if(!analysis) throw std::runtime_error{path + ": create call returns NULL-pointer"}; diff --git a/src/analysis/plugin.h b/src/analysis/plugin.h index 0f259bd..9dbdc15 100644 --- a/src/analysis/plugin.h +++ b/src/analysis/plugin.h @@ -31,7 +31,6 @@ namespace NST { namespace analysis { - class Plugin : private NST::utils::DynamicLoad { public: @@ -40,12 +39,12 @@ public: protected: explicit Plugin(const std::string& path); - Plugin(const Plugin&) = delete; + Plugin(const Plugin&) = delete; Plugin& operator=(const Plugin&) = delete; - plugin_usage_func usage; - plugin_create_func create; - plugin_destroy_func destroy; + plugin_usage_func usage; + plugin_create_func create; + plugin_destroy_func destroy; plugin_requirements_func requirements; }; @@ -53,12 +52,12 @@ class PluginInstance : private Plugin { public: PluginInstance(const std::string& path, const std::string& args); - PluginInstance(const PluginInstance&) = delete; + PluginInstance(const PluginInstance&) = delete; PluginInstance& operator=(const PluginInstance&) = delete; ~PluginInstance(); inline IAnalyzer* instance() const { return analysis; } - inline bool silent(){ return isSilent(); } + inline bool silent() { return isSilent(); } private: IAnalyzer* analysis; }; @@ -66,5 +65,5 @@ private: } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//PLUGIN_H +#endif //PLUGIN_H //------------------------------------------------------------------------------ diff --git a/src/analysis/print_analyzer.cpp b/src/analysis/print_analyzer.cpp index 1d68420..37b64aa 100644 --- a/src/analysis/print_analyzer.cpp +++ b/src/analysis/print_analyzer.cpp @@ -19,27 +19,26 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#include <iomanip> -#include <time.h> #include <algorithm> -#include <utility> +#include <ctime> +#include <iomanip> #include <sstream> +#include <utility> #include "analysis/print_analyzer.h" #include "protocols/cifs/cifs.h" #include "protocols/cifs2/cifs2.h" +#include "protocols/cifs2/cifs2_utils.h" #include "protocols/nfs/nfs_utils.h" #include "protocols/nfs3/nfs3_utils.h" -#include "protocols/nfs4/nfs4_utils.h" #include "protocols/nfs4/nfs41_utils.h" -#include "protocols/cifs2/cifs2_utils.h" +#include "protocols/nfs4/nfs4_utils.h" #include "utils/sessions.h" //------------------------------------------------------------------------------ namespace NST { namespace analysis { - using SMBv1Commands = NST::API::SMBv1::SMBv1Commands; using SMBv2Commands = NST::API::SMBv2::SMBv2Commands; using namespace NST::protocols::CIFSv2; @@ -52,23 +51,23 @@ namespace NFS4 = NST::API::NFS4; namespace NFS41 = NST::API::NFS41; namespace -{ +{ bool print_procedure(std::ostream& out, const RPCProcedure* proc) { using namespace NST::utils; - bool result {false}; + bool result{false}; out << *(proc->session); - auto& call = proc->call; - const unsigned long nfs_version {call.ru.RM_cmb.cb_vers}; - if (out_all()) + auto& call = proc->call; + const unsigned long nfs_version{call.ru.RM_cmb.cb_vers}; + if(out_all()) { - out << " XID: " << call.rm_xid + out << " XID: " << call.rm_xid << " RPC version: " << call.ru.RM_cmb.cb_rpcvers << " RPC program: " << call.ru.RM_cmb.cb_prog - << " version: " << nfs_version << ' '; + << " version: " << nfs_version << ' '; } - switch (nfs_version) + switch(nfs_version) { case NFS_V3: out << print_nfs3_procedures(static_cast<ProcEnumNFS3::NFSProcedure>(call.ru.RM_cmb.cb_proc)); @@ -80,16 +79,16 @@ bool print_procedure(std::ostream& out, const RPCProcedure* proc) // check procedure reply auto& reply = proc->reply; - if (reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED) + if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED) { - switch (reply.ru.RM_rmb.ru.RP_ar.ar_stat) + switch(reply.ru.RM_rmb.ru.RP_ar.ar_stat) { case accept_stat::SUCCESS: - result = true; // Ok, reply is correct + result = true; // Ok, reply is correct break; case accept_stat::PROG_MISMATCH: out << " Program mismatch: " - << " low: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.low + << " low: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.low << " high: " << reply.ru.RM_rmb.ru.RP_ar.ru.AR_versions.high; break; case accept_stat::PROG_UNAVAIL: @@ -106,10 +105,10 @@ bool print_procedure(std::ostream& out, const RPCProcedure* proc) break; } } - else if (reply.ru.RM_rmb.rp_stat == reply_stat::MSG_DENIED) + else if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_DENIED) { out << " RPC Call rejected: "; - switch (reply.ru.RM_rmb.ru.RP_dr.rj_stat) + switch(reply.ru.RM_rmb.ru.RP_dr.rj_stat) { case reject_stat::RPC_MISMATCH: out << "RPC version number mismatch, " @@ -121,7 +120,7 @@ bool print_procedure(std::ostream& out, const RPCProcedure* proc) case reject_stat::AUTH_ERROR: { out << " Authentication check: "; - switch (reply.ru.RM_rmb.ru.RP_dr.ru.RJ_why) + switch(reply.ru.RM_rmb.ru.RP_dr.ru.RJ_why) { case auth_stat::AUTH_OK: out << "OK"; @@ -166,13 +165,13 @@ bool print_procedure(std::ostream& out, const RPCProcedure* proc) std::ostream& print_time(std::ostream& out, uint64_t time) { // TODO: Replace with C++ 11 functions - if (time != 0) + if(time != 0) { const auto EPOCH_DIFF = 0x019DB1DED53E8000LL; /* 116444736000000000 nsecs */ - const auto RATE_DIFF = 10000000; /* 100 nsecs */ + const auto RATE_DIFF = 10000000; /* 100 nsecs */ uint64_t unixTimestamp = (time - EPOCH_DIFF) / RATE_DIFF; - time_t t = static_cast<time_t>(unixTimestamp); + time_t t = static_cast<time_t>(unixTimestamp); // NOTE: If you ever want to print the year/day/month separately like this: // @@ -181,8 +180,8 @@ std::ostream& print_time(std::ostream& out, uint64_t time) // do not forget adding 1900 to tm_year field, just to get current year // lt->tm_year + 1900 - const char *pTime = ctime(&t); - if (pTime != nullptr) + const char* pTime = ctime(&t); + if(pTime != nullptr) { // ctime adds "\n" at the end - remove it. size_t len = std::strlen(pTime); @@ -197,7 +196,7 @@ std::ostream& print_time(std::ostream& out, uint64_t time) return out; } -std::ostream& print_buffer(std::ostream& out, const uint8_t *buffer, uint16_t len) +std::ostream& print_buffer(std::ostream& out, const uint8_t* buffer, uint16_t len) { // TODO: Add unicode support const char* char_buffer = reinterpret_cast<const char*>(buffer); @@ -211,7 +210,7 @@ std::ostream& print_buffer(std::ostream& out, const uint8_t *buffer, uint16_t le return out; } -std::ostream& print_buffer_hex(std::ostream& out, const uint8_t *buffer, uint16_t len) +std::ostream& print_buffer_hex(std::ostream& out, const uint8_t* buffer, uint16_t len) { for(uint16_t i = 0; i < len; i++) { @@ -229,16 +228,15 @@ void print_guid(std::ostream& out, const uint8_t (&guid)[16]) // print hex value with preceding 0 (zeros) if necessary // ( e.g: 0x01 will be printed as 01 or 0x00 as 00 ) - auto print_hex = [&out](uint32_t value, uint8_t bitShift) - { + auto print_hex = [&out](uint32_t value, uint8_t bitShift) { out << std::hex << std::setfill('0') << std::setw(2) << (static_cast<uint32_t>(value >> bitShift) & 0xFF) << std::dec; }; print_hex(refGuid.Data1, 24); print_hex(refGuid.Data1, 16); - print_hex(refGuid.Data1, 8); - print_hex(refGuid.Data1, 0); + print_hex(refGuid.Data1, 8); + print_hex(refGuid.Data1, 0); out << "-"; print_hex(refGuid.Data2, 8); print_hex(refGuid.Data2, 0); @@ -256,7 +254,7 @@ void print_guid(std::ostream& out, const uint8_t (&guid)[16]) } } -template<typename CommandType> +template <typename CommandType> std::ostream& print_session(std::ostream& out, CommandType* cmd) { using namespace NST::utils; @@ -265,7 +263,7 @@ std::ostream& print_session(std::ostream& out, CommandType* cmd) return out; } -template<typename CommandType> +template <typename CommandType> std::ostream& print_smbv2_common_info_req(std::ostream& out, SMBv2Commands, CommandType* cmd) { out << " Structure size = "; @@ -273,17 +271,17 @@ std::ostream& print_smbv2_common_info_req(std::ostream& out, SMBv2Commands, Comm return out; } -template<typename CommandType> +template <typename CommandType> std::ostream& print_smbv2_common_info_resp(std::ostream& out, SMBv2Commands, CommandType* cmd) { out << " Structure size = "; print_hex16(out, cmd->pres->structureSize); return out; -} +} std::ostream& print_smbv2_header(std::ostream& out, const RawMessageHeader* header) { - if (header == nullptr) + if(header == nullptr) { return out; } @@ -309,7 +307,7 @@ std::ostream& print_smbv2_header(std::ostream& out, const RawMessageHeader* head out << " Credit Charge = " << header->CreditCharge << "\n"; bool isResponse = header->flags & static_cast<uint32_t>(Flags::SERVER_TO_REDIR); - if (isResponse) + if(isResponse) { SMBv2::NTStatus status = static_cast<SMBv2::NTStatus>(header->status); print_enum(out, "NT Status", status); @@ -322,7 +320,7 @@ std::ostream& print_smbv2_header(std::ostream& out, const RawMessageHeader* head out << "\n"; print_enum(out, "Command", header->cmd_code) << "\n"; - if (isResponse) + if(isResponse) { out << " Credits granted = " << header->Credit << "\n"; } @@ -409,7 +407,7 @@ void PrintAnalyzer::negotiateSMBv2(const SMBv2::NegotiateCommand* cmd, << "\n"; print_enum(out, "Security mode", cmd->parg->securityMode) << "\n"; - print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n"; + print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n"; out << " Client Guid = "; print_guid(out, cmd->parg->clientGUID); @@ -428,7 +426,7 @@ void PrintAnalyzer::negotiateSMBv2(const SMBv2::NegotiateCommand* cmd, print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Security mode", res->securityMode) << "\n"; + print_enum(out, "Security mode", res->securityMode) << "\n"; out << " Dialect = "; print_hex16(out, res->dialectRevision); @@ -457,7 +455,6 @@ void PrintAnalyzer::negotiateSMBv2(const SMBv2::NegotiateCommand* cmd, out << "\n Boot Time = "; print_time(out, res->serverStartTime); - } void PrintAnalyzer::sessionSetupSMBv2(const SMBv2::SessionSetupCommand* cmd, @@ -469,9 +466,9 @@ void PrintAnalyzer::sessionSetupSMBv2(const SMBv2::SessionSetupCommand* cmd, print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Flags", cmd->parg->VcNumber) << "\n"; - print_enum(out, "Security mode", cmd->parg->securityMode) << "\n"; - print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n"; + print_enum(out, "Flags", cmd->parg->VcNumber) << "\n"; + print_enum(out, "Security mode", cmd->parg->securityMode) << "\n"; + print_enum(out, "Capabilities", cmd->parg->capabilities) << "\n"; out << " Channel = " << cmd->parg->Channel << "\n" << " Previous session id = " << cmd->parg->PreviousSessionId << "\n"; print_smbv2_header(out, cmd->res_header) << "\n"; @@ -507,14 +504,14 @@ void PrintAnalyzer::treeConnectSMBv2(const SMBv2::TreeConnectCommand* cmd, if(plen > 0) { out << " Tree ="; - print_buffer(out,cmd->parg->Buffer, plen) << "\n"; + print_buffer(out, cmd->parg->Buffer, plen) << "\n"; } print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; print_enum(out, "Share types", res->ShareType) << "\n"; print_enum(out, "Capabilities", res->capabilities) << "\n"; print_enum(out, "Share flags", res->shareFlags) << "\n"; - print_enum(out, "Access mask", static_cast<SMBv2::AccessMask>(res->MaximalAccess)); + print_enum(out, "Access mask", static_cast<SMBv2::AccessMask>(res->MaximalAccess)); } void PrintAnalyzer::treeDisconnectSMBv2(const SMBv2::TreeDisconnectCommand* cmd, @@ -538,16 +535,16 @@ void PrintAnalyzer::createSMBv2(const SMBv2::CreateCommand* cmd, print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Oplock", cmd->parg->RequestedOplockLevel) << "\n"; - print_enum(out, "Impersonation", cmd->parg->ImpersonationLevel) << "\n"; - out << " Create Flags = "; + print_enum(out, "Oplock", cmd->parg->RequestedOplockLevel) << "\n"; + print_enum(out, "Impersonation", cmd->parg->ImpersonationLevel) << "\n"; + out << " Create Flags = "; print_hex64(out, cmd->parg->SmbCreateFlags); out << "\n"; - print_enum(out, "Access Mask", cmd->parg->desiredAccess) << "\n"; - print_enum(out, "File Attributes", cmd->parg->attributes) << "\n"; - print_enum(out, "Share Access", cmd->parg->shareAccess) << "\n"; - print_enum(out, "Disposition", cmd->parg->createDisposition) << "\n"; - print_enum(out, "Create Options", cmd->parg->createOptions) << "\n"; + print_enum(out, "Access Mask", cmd->parg->desiredAccess) << "\n"; + print_enum(out, "File Attributes", cmd->parg->attributes) << "\n"; + print_enum(out, "Share Access", cmd->parg->shareAccess) << "\n"; + print_enum(out, "Disposition", cmd->parg->createDisposition) << "\n"; + print_enum(out, "Create Options", cmd->parg->createOptions) << "\n"; const auto len = NST::API::SMBv2::pc_to_net(cmd->parg->NameLength); if(len > 0) @@ -560,13 +557,13 @@ void PrintAnalyzer::createSMBv2(const SMBv2::CreateCommand* cmd, print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Oplock", res->oplockLevel) << "\n"; + print_enum(out, "Oplock", res->oplockLevel) << "\n"; out << " Response Flags = "; print_hex8(out, res->flag); out << "\n"; - print_enum(out, "Create Action", res->CreateAction) << "\n"; + print_enum(out, "Create Action", res->CreateAction) << "\n"; - if (cmd->res_header && cmd->res_header->status == to_integral(SMBv2::NTStatus::STATUS_SUCCESS)) + if(cmd->res_header && cmd->res_header->status == to_integral(SMBv2::NTStatus::STATUS_SUCCESS)) { out << " Create = "; print_time(out, res->CreationTime); @@ -586,7 +583,7 @@ void PrintAnalyzer::createSMBv2(const SMBv2::CreateCommand* cmd, out << "\n End Of File = "; out << res->EndofFile << "\n"; - print_enum(out, "File Attributes", res->attributes); + print_enum(out, "File Attributes", res->attributes); } } @@ -643,13 +640,13 @@ void PrintAnalyzer::writeSMBv2(const SMBv2::WriteCommand* cmd, print_hex16(out, cmd->parg->dataOffset); out << "\n" - << " Write Length = " << cmd->parg->Length << "\n" - << " File Offset = " << cmd->parg->Offset << "\n" - << " Channel = " << to_integral(cmd->parg->Channel) << "\n" - << " Remaining Bytes = " << cmd->parg->RemainingBytes << "\n" - << " Channel Info Offset = " << cmd->parg->WriteChannelInfoOffset << "\n" - << " Channel Info Length = " << cmd->parg->WriteChannelInfoLength << "\n"; - print_enum(out, "Write Flags", cmd->parg->Flags) << "\n"; + << " Write Length = " << cmd->parg->Length << "\n" + << " File Offset = " << cmd->parg->Offset << "\n" + << " Channel = " << to_integral(cmd->parg->Channel) << "\n" + << " Remaining Bytes = " << cmd->parg->RemainingBytes << "\n" + << " Channel Info Offset = " << cmd->parg->WriteChannelInfoOffset << "\n" + << " Channel Info Length = " << cmd->parg->WriteChannelInfoLength << "\n"; + print_enum(out, "Write Flags", cmd->parg->Flags) << "\n"; print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; @@ -681,8 +678,8 @@ void PrintAnalyzer::ioctlSMBv2(const SMBv2::IoctlCommand* cmd, SMBv2Commands cmdEnum = SMBv2Commands::IOCTL; print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; - print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Control Code", cmd->parg->CtlCode) << "\n"; + print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; + print_enum(out, "Control Code", cmd->parg->CtlCode) << "\n"; out << " Input offset = " << cmd->parg->InputOffset << "\n" << " Input count = " << cmd->parg->InputCount << "\n" << " Max input response = " << cmd->parg->MaxInputResponse << "\n" @@ -691,7 +688,7 @@ void PrintAnalyzer::ioctlSMBv2(const SMBv2::IoctlCommand* cmd, << " Max output response = " << cmd->parg->MaxOutputResponse << "\n"; print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Control Code", res->CtlCode) << "\n"; + print_enum(out, "Control Code", res->CtlCode) << "\n"; out << " Input offset = " << res->InputOffset << "\n" << " Input count = " << res->InputCount << "\n" << " Output offset = " << res->OutputOffset << "\n" @@ -726,7 +723,7 @@ void PrintAnalyzer::queryDirSMBv2(const SMBv2::QueryDirCommand* cmd, print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Info level", cmd->parg->infoType) << "\n"; + print_enum(out, "Info level", cmd->parg->infoType) << "\n"; out << " File index = " << cmd->parg->FileIndex << "\n" << " Output buffer length = " << cmd->parg->OutputBufferLength << "\n" << " Search pattern ="; @@ -749,7 +746,7 @@ void PrintAnalyzer::changeNotifySMBv2(const SMBv2::ChangeNotifyCommand* cmd, print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; out << " Offset = "; - print_hex32(out, res->OutputBufferOffset); + print_hex32(out, res->OutputBufferOffset); out << "\n"; out << " Length = "; print_hex32(out, res->OutputBufferLength); @@ -762,13 +759,13 @@ void PrintAnalyzer::queryInfoSMBv2(const SMBv2::QueryInfoCommand* cmd, print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Class", cmd->parg->infoType) << "\n"; + print_enum(out, "Class", cmd->parg->infoType) << "\n"; print_info_levels(out, cmd->parg->infoType, cmd->parg->FileInfoClass) << "\n"; //TODO: Print GUID handle file print_smbv2_header(out, cmd->res_header) << "\n"; print_smbv2_common_info_resp(out, cmdEnum, cmd) << "\n"; out << " Offset = "; - print_hex32(out, res->OutputBufferOffset); + print_hex32(out, res->OutputBufferOffset); out << "\n Length = "; print_hex32(out, res->OutputBufferLength); } @@ -780,10 +777,10 @@ void PrintAnalyzer::setInfoSMBv2(const SMBv2::SetInfoCommand* cmd, print_session(out, cmd) << "\n"; print_smbv2_header(out, cmd->req_header) << "\n"; print_smbv2_common_info_req(out, cmdEnum, cmd) << "\n"; - print_enum(out, "Class", cmd->parg->infoType) << "\n"; + print_enum(out, "Class", cmd->parg->infoType) << "\n"; print_info_levels(out, cmd->parg->infoType, cmd->parg->FileInfoClass) << "\n"; out << " Setinfo Size = "; - print_hex32(out, cmd->parg->BufferLength); + print_hex32(out, cmd->parg->BufferLength); out << "\n Setinfo Offset = "; print_hex16(out, cmd->parg->BufferOffset); out << "\n"; @@ -792,8 +789,8 @@ void PrintAnalyzer::setInfoSMBv2(const SMBv2::SetInfoCommand* cmd, } void PrintAnalyzer::breakOplockSMBv2(const SMBv2::BreakOpLockCommand* cmd, - const SMBv2::OplockAcknowledgment*, - const SMBv2::OplockResponse* res) + const SMBv2::OplockAcknowledgment*, + const SMBv2::OplockResponse* res) { SMBv2Commands cmdEnum = SMBv2Commands::OPLOCK_BREAK; @@ -818,7 +815,9 @@ void PrintAnalyzer::null(const RPCProcedure* proc, const struct NFS3::NULL3args*, const struct NFS3::NULL3res*) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } out << "\tCALL []\n\tREPLY []\n"; } @@ -826,18 +825,20 @@ void PrintAnalyzer::getattr3(const RPCProcedure* proc, const struct NFS3::GETATTR3args* args, const struct NFS3::GETATTR3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [" << " object: " << args->object << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all() && res->status == NFS3::nfsstat3::NFS3_OK) + if(out_all() && res->status == NFS3::nfsstat3::NFS3_OK) out << " obj attributes: " << res->GETATTR3res_u.resok.obj_attributes; out << " ]\n"; @@ -848,21 +849,23 @@ void PrintAnalyzer::setattr3(const RPCProcedure* proc, const struct NFS3::SETATTR3args* args, const struct NFS3::SETATTR3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ object: " << args->object - << " new attributes: " << args->new_attributes - << " guard: " << args->guard + << " new attributes: " << args->new_attributes + << " guard: " << args->guard << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj_wcc: " << res->SETATTR3res_u.resok.obj_wcc; else @@ -877,15 +880,19 @@ void PrintAnalyzer::lookup3(const RPCProcedure* proc, const struct NFS3::LOOKUP3args* args, const struct NFS3::LOOKUP3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) { out << "\tCALL [ what: " << args->what << " ]\n"; } - if (res) + if(args) { + out << "\tCALL [ what: " << args->what << " ]\n"; + } + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " object: " << res->LOOKUP3res_u.resok.object << " object attributes: " @@ -904,9 +911,11 @@ void PrintAnalyzer::access3(const RPCProcedure* proc, const struct NFS3::ACCESS3args* args, const struct NFS3::ACCESS3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ object: "; print_nfs_fh(out, @@ -917,12 +926,12 @@ void PrintAnalyzer::access3(const RPCProcedure* proc, out << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " object attributes: " << res->ACCESS3res_u.resok.obj_attributes @@ -943,15 +952,19 @@ void PrintAnalyzer::readlink3(const RPCProcedure* proc, const struct NFS3::READLINK3args* args, const struct NFS3::READLINK3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) { out << "\tCALL [ symlink: " << args->symlink << " ]\n"; } - if (res) + if(args) { + out << "\tCALL [ symlink: " << args->symlink << " ]\n"; + } + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " symlink attributes: " << res->READLINK3res_u.resok.symlink_attributes << " data: " @@ -968,21 +981,23 @@ void PrintAnalyzer::read3(const RPCProcedure* proc, const struct NFS3::READ3args* args, const struct NFS3::READ3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ file: " << args->file << " offset: " << args->offset - << " count: " << args->count + << " count: " << args->count << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " file attributes: " << res->READ3res_u.resok.file_attributes @@ -1005,22 +1020,24 @@ void PrintAnalyzer::write3(const RPCProcedure* proc, const struct NFS3::WRITE3args* args, const struct NFS3::WRITE3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ file: " << args->file << " offset: " << args->offset - << " count: " << args->count + << " count: " << args->count << " stable: " << args->stable << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " file_wcc: " << res->WRITE3res_u.resok.file_wcc @@ -1047,18 +1064,20 @@ void PrintAnalyzer::create3(const RPCProcedure* proc, const struct NFS3::CREATE3args* args, const struct NFS3::CREATE3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ where: " << args->where << " how: " << args->how << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj: " << res->CREATE3res_u.resok.obj << " obj attributes: " @@ -1077,18 +1096,20 @@ void PrintAnalyzer::mkdir3(const RPCProcedure* proc, const struct NFS3::MKDIR3args* args, const struct NFS3::MKDIR3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ where: " << args->where - << " attributes: " << args->attributes + << " attributes: " << args->attributes << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj: " << res->MKDIR3res_u.resok.obj << " obj attributes: " @@ -1107,18 +1128,20 @@ void PrintAnalyzer::symlink3(const RPCProcedure* proc, const struct NFS3::SYMLINK3args* args, const struct NFS3::SYMLINK3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ where: " << args->where - << " symlink: " << args->symlink + << " symlink: " << args->symlink << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj: " << res->SYMLINK3res_u.resok.obj << " obj attributes: " @@ -1137,20 +1160,22 @@ void PrintAnalyzer::mknod3(const RPCProcedure* proc, const struct NFS3::MKNOD3args* args, const struct NFS3::MKNOD3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ where: " << args->where - << " what: " << args->what + << " what: " << args->what << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj: " << res->MKNOD3res_u.resok.obj << " obj attributes: " @@ -1169,18 +1194,20 @@ void PrintAnalyzer::remove3(const RPCProcedure* proc, const struct NFS3::REMOVE3args* args, const struct NFS3::REMOVE3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ object: " << args->object << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " dir_wcc: " << res->REMOVE3res_u.resok.dir_wcc; else @@ -1195,18 +1222,20 @@ void PrintAnalyzer::rmdir3(const RPCProcedure* proc, const struct NFS3::RMDIR3args* args, const struct NFS3::RMDIR3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ object: " << args->object << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " dir_wcc: " << res->RMDIR3res_u.resok.dir_wcc; else @@ -1221,18 +1250,20 @@ void PrintAnalyzer::rename3(const RPCProcedure* proc, const struct NFS3::RENAME3args* args, const struct NFS3::RENAME3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ from: " << args->from - << " to: " << args->to + << " to: " << args->to << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " from dir_wcc: " << res->RENAME3res_u.resok.fromdir_wcc << " to dir_wcc: " @@ -1251,18 +1282,20 @@ void PrintAnalyzer::link3(const RPCProcedure* proc, const struct NFS3::LINK3args* args, const struct NFS3::LINK3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ file: " << args->file - << " link: " << args->link + << " link: " << args->link << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " file attributes: " << res->LINK3res_u.resok.file_attributes << " link dir_wcc: " @@ -1281,12 +1314,14 @@ void PrintAnalyzer::readdir3(const RPCProcedure* proc, const struct NFS3::READDIR3args* args, const struct NFS3::READDIR3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ dir: " << args->dir - << " cookie: " << args->cookie + << " cookie: " << args->cookie << " cookieverf: "; print_hex(out, args->cookieverf, @@ -1294,12 +1329,12 @@ void PrintAnalyzer::readdir3(const RPCProcedure* proc, out << " count: " << args->count << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " dir attributes: " << res->READDIR3res_u.resok.dir_attributes @@ -1324,12 +1359,14 @@ void PrintAnalyzer::readdirplus3(const RPCProcedure* proc, const struct NFS3::READDIRPLUS3args* args, const struct NFS3::READDIRPLUS3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ dir: " << args->dir - << " cookie: " << args->cookie + << " cookie: " << args->cookie << " cookieverf: "; print_hex(out, args->cookieverf, @@ -1338,12 +1375,12 @@ void PrintAnalyzer::readdirplus3(const RPCProcedure* proc, << " max count: " << args->maxcount << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " dir attributes: " << res->READDIRPLUS3res_u.resok.dir_attributes @@ -1368,18 +1405,20 @@ void PrintAnalyzer::fsstat3(const RPCProcedure* proc, const struct NFS3::FSSTAT3args* args, const struct NFS3::FSSTAT3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ fsroot: " << args->fsroot << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj attributes: " << res->FSSTAT3res_u.resok.obj_attributes << " tbytes: " @@ -1408,18 +1447,20 @@ void PrintAnalyzer::fsinfo3(const RPCProcedure* proc, const struct NFS3::FSINFO3args* args, const struct NFS3::FSINFO3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ fsroot: " << args->fsroot << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj attributes: " << res->FSINFO3res_u.resok.obj_attributes << " rtmax: " @@ -1466,18 +1507,20 @@ void PrintAnalyzer::pathconf3(const RPCProcedure* proc, const struct NFS3::PATHCONF3args* args, const struct NFS3::PATHCONF3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) { out << "\tCALL [ object: " << args->object << " ]\n"; } - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) out << " obj attributes: " << res->PATHCONF3res_u.resok.obj_attributes << " link max: " @@ -1504,19 +1547,21 @@ void PrintAnalyzer::commit3(const RPCProcedure* proc, const struct NFS3::COMMIT3args* args, const struct NFS3::COMMIT3res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - if (args) + if(args) out << "\tCALL [ file: " << args->file - << " offset: " << args->offset - << " count: " << args->count + << " offset: " << args->offset + << " count: " << args->count << " ]\n"; - if (res) + if(res) { out << "\tREPLY [ status: " << res->status; - if (out_all()) + if(out_all()) { - if (res->status == NFS3::nfsstat3::NFS3_OK) + if(res->status == NFS3::nfsstat3::NFS3_OK) { out << " file_wcc: " << res->COMMIT3res_u.resok.file_wcc @@ -1535,7 +1580,6 @@ void PrintAnalyzer::commit3(const RPCProcedure* proc, } } - // Print NFSv4 procedures // 1st line - PRC information: src and dst hosts, status of RPC procedure // 2nd line - <tabulation>related RPC procedure-specific arguments @@ -1547,7 +1591,9 @@ void PrintAnalyzer::null4(const RPCProcedure* proc, const struct NFS4::NULL4args*, const struct NFS4::NULL4res*) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } out << "\tCALL []\n\tREPLY []\n"; } @@ -1556,19 +1602,21 @@ void PrintAnalyzer::compound4(const RPCProcedure* proc, const struct NFS4::COMPOUND4args* args, const struct NFS4::COMPOUND4res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - const u_int* array_len {}; - if (args) + const u_int* array_len{}; + if(args) { array_len = &args->argarray.argarray_len; out << "\tCALL [ operations: " << *array_len - << " tag: " << args->tag - << " minor version: " << args->minorversion; - if (*array_len) + << " tag: " << args->tag + << " minor version: " << args->minorversion; + if(*array_len) { - NFS4::nfs_argop4* current_el {args->argarray.argarray_val}; - for (u_int i = 0; i < *array_len; i++, current_el++) + NFS4::nfs_argop4* current_el{args->argarray.argarray_val}; + for(u_int i = 0; i < *array_len; i++, current_el++) { out << "\n\t\t[ "; nfs4_operation(current_el); @@ -1577,14 +1625,14 @@ void PrintAnalyzer::compound4(const RPCProcedure* proc, out << " ]\n"; } } - if (res) + if(res) { array_len = &res->resarray.resarray_len; out << "\tREPLY [ operations: " << *array_len; - if (*array_len) + if(*array_len) { - NFS4::nfs_resop4* current_el {res->resarray.resarray_val}; - for (u_int i = 0; i < *array_len; i++, current_el++) + NFS4::nfs_resop4* current_el{res->resarray.resarray_val}; + for(u_int i = 0; i < *array_len; i++, current_el++) { out << "\n\t\t[ "; nfs4_operation(current_el); @@ -1597,11 +1645,11 @@ void PrintAnalyzer::compound4(const RPCProcedure* proc, void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_argop4* op) { - if (op) + if(op) { out << print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(op->argop)) << '(' << op->argop << ") [ "; - switch (op->argop) + switch(op->argop) { case NFS4::OP_ACCESS: return nfs4_operation(&op->nfs_argop4_u.opaccess); @@ -1688,11 +1736,11 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_argop4* op) void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_resop4* op) { - if (op) + if(op) { out << print_nfs4_procedures(static_cast<ProcEnumNFS4::NFSProcedure>(op->resop)) << '(' << op->resop << ") [ "; - switch (op->resop) + switch(op->resop) { case NFS4::OP_ACCESS: return nfs4_operation(&op->nfs_resop4_u.opaccess); @@ -1779,71 +1827,83 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::nfs_resop4* op) void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4args* args) { - if (args) + if(args) { - if ((args->access) & NFS4::ACCESS4_READ) { out << "READ "; } - if ((args->access) & NFS4::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((args->access) & NFS4::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((args->access) & NFS4::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((args->access) & NFS4::ACCESS4_DELETE) { out << "DELETE "; } - if ((args->access) & NFS4::ACCESS4_EXECUTE) { out << "EXECUTE "; } + if((args->access) & NFS4::ACCESS4_READ) { + out << "READ "; + } + if((args->access) & NFS4::ACCESS4_LOOKUP) { + out << "LOOKUP "; + } + if((args->access) & NFS4::ACCESS4_MODIFY) { + out << "MODIFY "; + } + if((args->access) & NFS4::ACCESS4_EXTEND) { + out << "EXTEND "; + } + if((args->access) & NFS4::ACCESS4_DELETE) { + out << "DELETE "; + } + if((args->access) & NFS4::ACCESS4_EXECUTE) { + out << "EXECUTE "; + } } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " supported: "; - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_READ) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_READ) { out << "READ "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_LOOKUP) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_MODIFY) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXTEND) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_DELETE) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_DELETE) { out << "DELETE "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXECUTE) + if((res->ACCESS4res_u.resok4.supported) & NFS4::ACCESS4_EXECUTE) { out << "EXECUTE "; } out << " access: "; - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_READ) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_READ) { out << "READ "; } - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_LOOKUP) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_MODIFY) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXTEND) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_DELETE) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_DELETE) { out << "DELETE "; } - if ((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXECUTE) + if((res->ACCESS4res_u.resok4.access) & NFS4::ACCESS4_EXECUTE) { out << "EXECUTE "; } @@ -1853,19 +1913,19 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::ACCESS4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4args* args) { - if (args) + if(args) { - out << "seqid: " << std::hex << args->seqid << std::dec + out << "seqid: " << std::hex << args->seqid << std::dec << " open state id:" << args->open_stateid; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " open state id:" << res->CLOSE4res_u.open_stateid; } @@ -1874,19 +1934,19 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::CLOSE4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4args* args) { - if (args) + if(args) { - out << "offset: " << args->offset - << " count: " << args->count; + out << "offset: " << args->offset + << " count: " << args->count; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " write verifier: "; print_hex(out, @@ -1898,20 +1958,20 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::COMMIT4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4args* args) { - if (args) + if(args) { - out << "object type: " << args->objtype - << " object name: " << args->objname + out << "object type: " << args->objtype + << " object name: " << args->objname << " create attributes: " << args->createattrs; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) out << res->CREATE4res_u.resok4.cinfo << ' ' << res->CREATE4res_u.resok4.attrset; } @@ -1919,35 +1979,45 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::CREATE4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4args* args) { - if (args) { out << "client id: " << std::hex << args->clientid << std::dec; } + if(args) { + out << "client id: " << std::hex << args->clientid << std::dec; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGPURGE4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4args* args) { - if (args) { out << args->deleg_stateid; } + if(args) { + out << args->deleg_stateid; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::DELEGRETURN4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4args* args) { - if (args) { out << args->attr_request; } + if(args) { + out << args->attr_request; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << ' ' << res->GETATTR4res_u.resok4.obj_attributes; } @@ -1956,15 +2026,17 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::GETATTR4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4args* args) { - if (args) { out << "new name: " << args->newname; } + if(args) { + out << "new name: " << args->newname; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << ' ' << res->LINK4res_u.resok4.cinfo; } @@ -1973,34 +2045,34 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::LINK4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " reclaim: " << args->reclaim - << " offset: " << args->offset - << " length: " << args->length - << " locker: " << args->locker; + out << "lock type: " << args->locktype + << " reclaim: " << args->reclaim + << " offset: " << args->offset + << " length: " << args->length + << " locker: " << args->locker; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all()) + if(out_all()) { - switch (res->status) + switch(res->status) { case NFS4::nfsstat4::NFS4_OK: out << " lock stat id: " << res->LOCK4res_u.resok4.lock_stateid; break; case NFS4::nfsstat4::NFS4ERR_DENIED: - out << " offset: " << res->LOCK4res_u.denied.offset - << " length: " << res->LOCK4res_u.denied.length + out << " offset: " << res->LOCK4res_u.denied.offset + << " length: " << res->LOCK4res_u.denied.length << " lock type: " << res->LOCK4res_u.denied.locktype - << " owner: " << res->LOCK4res_u.denied.owner; + << " owner: " << res->LOCK4res_u.denied.owner; break; default: break; @@ -2011,46 +2083,46 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCK4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " offset: " << args->offset - << " length: " << args->length - << " owner: " << args->owner; + out << "lock type: " << args->locktype + << " offset: " << args->offset + << " length: " << args->length + << " owner: " << args->owner; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKT4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4ERR_DENIED) - out << " offset: " << res->LOCKT4res_u.denied.offset - << " length: " << res->LOCKT4res_u.denied.length + if(out_all() && res->status == NFS4::nfsstat4::NFS4ERR_DENIED) + out << " offset: " << res->LOCKT4res_u.denied.offset + << " length: " << res->LOCKT4res_u.denied.length << " lock type: " << res->LOCKT4res_u.denied.locktype - << " owner: " << res->LOCKT4res_u.denied.owner; + << " owner: " << res->LOCKT4res_u.denied.owner; } } void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " seqid: " << std::hex << args->seqid << std::dec + out << "lock type: " << args->locktype + << " seqid: " << std::hex << args->seqid << std::dec << " lock state id: " << args->lock_stateid - << " offset: " << args->offset - << " length: " << args->length; + << " offset: " << args->offset + << " length: " << args->length; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " lock state id: " << res->LOCKU4res_u.lock_stateid; } @@ -2059,46 +2131,54 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::LOCKU4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4args* args) { - if (args) { out << "object name: " << args->objname; } + if(args) { + out << "object name: " << args->objname; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUP4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4args* args) { - if (args) { out << "object attributes: " << args->obj_attributes; } + if(args) { + out << "object attributes: " << args->obj_attributes; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::NVERIFY4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4args* args) { - static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"}; + static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"}; static const char* const open4_share_deny[4] = {"NONE", "READ", "WRITE", "BOTH"}; - if (args) + if(args) { - out << "seqid: " << std::hex << args->seqid << std::dec + out << "seqid: " << std::hex << args->seqid << std::dec << " share access: " << open4_share_access[args->share_access] - << " share deny: " << open4_share_deny[args->share_deny] + << " share deny: " << open4_share_deny[args->share_deny] << ' ' << args->owner << ' ' << args->openhow << ' ' << args->claim; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) out << res->OPEN4res_u.resok4.stateid << res->OPEN4res_u.resok4.cinfo << " results flags: " @@ -2110,29 +2190,33 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4args* args) { - if (args) { out << "create directory: " << args->createdir; } + if(args) { + out << "create directory: " << args->createdir; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::OPENATTR4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4args* args) { - if (args) + if(args) { - out << "open state id:" << args->open_stateid - << " seqid: " << std::hex << args->seqid << std::dec; + out << "open state id:" << args->open_stateid + << " seqid: " << std::hex << args->seqid << std::dec; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " open state id:" << res->OPEN_CONFIRM4res_u.resok4.open_stateid; } @@ -2141,21 +2225,21 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_CONFIRM4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4args* args) { - if (args) + if(args) { out << " open state id: " << args->open_stateid - << " seqid: " << std::hex << args->seqid << std::dec - << " share access: " << args->share_access - << " share deny: " << args->share_deny; + << " seqid: " << std::hex << args->seqid << std::dec + << " share access: " << args->share_access + << " share deny: " << args->share_deny; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << ' ' << res->OPEN_DOWNGRADE4res_u.resok4.open_stateid; } @@ -2164,37 +2248,39 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::OPEN_DOWNGRADE4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4args* args) { - if (args) + if(args) { out << "object: "; print_nfs_fh(out, args->object.nfs_fh4_val, args->object.nfs_fh4_len); } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4args* args) { - if (args) + if(args) { out << args->stateid - << " offset: " << args->offset - << " count: " << args->count; + << " offset: " << args->offset + << " count: " << args->count; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " eof: " << res->READ4res_u.resok4.eof; - if (res->READ4res_u.resok4.data.data_len) + if(res->READ4res_u.resok4.data.data_len) { out << " data : " << *res->READ4res_u.resok4.data.data_val; } @@ -2204,38 +2290,40 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::READ4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4args* args) { - if (args) + if(args) { - out << "cookie: " << args->cookie - << " cookieverf: " << args->cookieverf - << " dir count: " << args->dircount - << " max count: " << args->maxcount + out << "cookie: " << args->cookie + << " cookieverf: " << args->cookieverf + << " dir count: " << args->dircount + << " max count: " << args->maxcount << " attributes request: " << args->attr_request; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::READDIR4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) out << " cookie verifier: " << res->READDIR4res_u.resok4.cookieverf - << " reply: " << res->READDIR4res_u.resok4.reply; + << " reply: " << res->READDIR4res_u.resok4.reply; } } void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4args* args) { - if (args) { out << "target: " << args->target; } + if(args) { + out << "target: " << args->target; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << ' ' << res->REMOVE4res_u.resok4.cinfo; } @@ -2244,19 +2332,19 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::REMOVE4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4args* args) { - if (args) + if(args) { - out << "old name: " << args->oldname + out << "old name: " << args->oldname << " new name: " << args->newname; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) out << " source: " << res->RENAME4res_u.resok4.source_cinfo << " target: " @@ -2266,31 +2354,35 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::RENAME4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4args* args) { - if (args) + if(args) { out << "client id: " << std::hex << args->clientid << std::dec; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::RENEW4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4args* args) { - if (args) { out << "name: " << args->name; } + if(args) { + out << "name: " << args->name; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { - if (res->SECINFO4res_u.resok4.SECINFO4resok_len) + if(res->SECINFO4res_u.resok4.SECINFO4resok_len) out << " data : " << *res->SECINFO4res_u.resok4.SECINFO4resok_val; } @@ -2299,25 +2391,27 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::SECINFO4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4args* args) { - if (args) + if(args) { out << "state id:" << args->stateid << ' ' << args->obj_attributes; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::SETATTR4res* res) { - if (res) + if(res) { - out << "status: " << res->status; - if (out_all()) { out << ' ' << res->attrsset; } + out << "status: " << res->status; + if(out_all()) { + out << ' ' << res->attrsset; + } } } void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4args* args) { - if (args) + if(args) { out << args->client << " callback: " @@ -2327,14 +2421,14 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4args* args) } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all()) + if(out_all()) { - switch (res->status) + switch(res->status) { case NFS4::nfsstat4::NFS4_OK: out << " client id: " @@ -2356,7 +2450,7 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4args* args) { - if (args) + if(args) { out << " client id: " << std::hex << args->clientid << std::dec << " verifier: "; @@ -2364,41 +2458,47 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4args* } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::SETCLIENTID_CONFIRM4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4args* args) { - if (args) { out << "object attributes: " << args->obj_attributes; } + if(args) { + out << "object attributes: " << args->obj_attributes; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::VERIFY4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4args* args) { - if (args) + if(args) { out << args->stateid - << " offset: " << args->offset - << " stable: " << args->stable + << " offset: " << args->offset + << " stable: " << args->stable << " data length: " << args->data.data_len; } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { - out << " count: " << res->WRITE4res_u.resok4.count - << " committed: " << res->WRITE4res_u.resok4.committed + out << " count: " << res->WRITE4res_u.resok4.count + << " committed: " << res->WRITE4res_u.resok4.committed << " write verifier: "; print_hex(out, res->WRITE4res_u.resok4.writeverf, @@ -2409,29 +2509,33 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::WRITE4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4args* args) { - if (args) { out << "lock owner: " << args->lock_owner; } + if(args) { + out << "lock owner: " << args->lock_owner; + } } -void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::RELEASE_LOCKOWNER4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4args* args) { - if (args) - out << "client id: " << args->clientid - << " notification types: " << args->notif_types - << " dir notification delay: " << args->dir_notif_delay + if(args) + out << "client id: " << args->clientid + << " notification types: " << args->notif_types + << " dir notification delay: " << args->dir_notif_delay << " dir entry notification delay: " << args->dir_entry_notif_delay; } -void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4res* res) +void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) out << ' ' << res->GET_DIR_DELEGATION4res_u.resok4.stateid << " status: " << res->GET_DIR_DELEGATION4res_u.resok4.status @@ -2446,10 +2550,10 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::GET_DIR_DELEGATION4res* r void PrintAnalyzer::nfs4_operation(const struct NFS4::GETFH4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " object: " << res->GETFH4res_u.resok4.object; } @@ -2458,25 +2562,31 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::GETFH4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::LOOKUPP4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTPUBFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::PUTROOTFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::READLINK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS4::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS4::nfsstat4::NFS4_OK) { out << " link: " << res->READLINK4res_u.resok4.link; } @@ -2485,17 +2595,23 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::READLINK4res* res) void PrintAnalyzer::nfs4_operation(const struct NFS4::RESTOREFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::SAVEFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs4_operation(const struct NFS4::ILLEGAL4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } // Print NFSv4.1 procedures @@ -2505,25 +2621,26 @@ void PrintAnalyzer::nfs4_operation(const struct NFS4::ILLEGAL4res* res) // 4th line - <tabulation>related RPC procedure-specific results // 5rd line - <tabulation>related NFSv4-operations - void PrintAnalyzer::compound41(const RPCProcedure* proc, const struct NFS41::COMPOUND4args* args, const struct NFS41::COMPOUND4res* res) { - if (!print_procedure(out, proc)) { return; } + if(!print_procedure(out, proc)) { + return; + } - const u_int* array_len {}; - if (args) + const u_int* array_len{}; + if(args) { array_len = &args->argarray.argarray_len; out << "\tCALL [ operations: " << *array_len - << " tag: " << args->tag - << " minor version: " << args->minorversion; + << " tag: " << args->tag + << " minor version: " << args->minorversion; - if (*array_len) + if(*array_len) { - NFS41::nfs_argop4* current_el {args->argarray.argarray_val}; - for (u_int i {0}; i < *array_len; i++, current_el++) + NFS41::nfs_argop4* current_el{args->argarray.argarray_val}; + for(u_int i{0}; i < *array_len; i++, current_el++) { out << "\n\t\t[ "; nfs41_operation(current_el); @@ -2532,16 +2649,16 @@ void PrintAnalyzer::compound41(const RPCProcedure* proc, out << " ]\n"; } } - if (res) + if(res) { array_len = &res->resarray.resarray_len; out << "\tREPLY [ operations: " << *array_len - << " status: " << res->status - << " tag: " << res->tag; - if (*array_len) + << " status: " << res->status + << " tag: " << res->tag; + if(*array_len) { - NFS41::nfs_resop4* current_el {res->resarray.resarray_val}; - for (u_int i {0}; i < *array_len; i++, current_el++) + NFS41::nfs_resop4* current_el{res->resarray.resarray_val}; + for(u_int i{0}; i < *array_len; i++, current_el++) { out << "\n\t\t[ "; nfs41_operation(current_el); @@ -2554,11 +2671,11 @@ void PrintAnalyzer::compound41(const RPCProcedure* proc, void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_argop4* op) { - if (op) + if(op) { out << print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(op->argop)) << '(' << op->argop << ") [ "; - switch (op->argop) + switch(op->argop) { case NFS41::OP_ACCESS: return nfs41_operation(&op->nfs_argop4_u.opaccess); @@ -2683,11 +2800,11 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_argop4* op) void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_resop4* op) { - if (op) + if(op) { out << print_nfs41_procedures(static_cast<ProcEnumNFS41::NFSProcedure>(op->resop)) << '(' << op->resop << ") [ "; - switch (op->resop) + switch(op->resop) { case NFS41::OP_ACCESS: return nfs41_operation(&op->nfs_resop4_u.opaccess); @@ -2812,71 +2929,83 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::nfs_resop4* op) void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4args* args) { - if (args) + if(args) { - if ((args->access) & NFS41::ACCESS4_READ) { out << "READ "; } - if ((args->access) & NFS41::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((args->access) & NFS41::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((args->access) & NFS41::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((args->access) & NFS41::ACCESS4_DELETE) { out << "DELETE "; } - if ((args->access) & NFS41::ACCESS4_EXECUTE) { out << "EXECUTE "; } + if((args->access) & NFS41::ACCESS4_READ) { + out << "READ "; + } + if((args->access) & NFS41::ACCESS4_LOOKUP) { + out << "LOOKUP "; + } + if((args->access) & NFS41::ACCESS4_MODIFY) { + out << "MODIFY "; + } + if((args->access) & NFS41::ACCESS4_EXTEND) { + out << "EXTEND "; + } + if((args->access) & NFS41::ACCESS4_DELETE) { + out << "DELETE "; + } + if((args->access) & NFS41::ACCESS4_EXECUTE) { + out << "EXECUTE "; + } } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " supported: "; - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_READ) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_READ) { out << "READ "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_LOOKUP) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_MODIFY) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXTEND) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_DELETE) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_DELETE) { out << "DELETE "; } - if ((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXECUTE) + if((res->ACCESS4res_u.resok4.supported) & NFS41::ACCESS4_EXECUTE) { out << "EXECUTE "; } out << " access: "; - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_READ) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_READ) { out << "READ "; } - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_LOOKUP) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_LOOKUP) { out << "LOOKUP "; } - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_MODIFY) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_MODIFY) { out << "MODIFY "; } - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXTEND) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXTEND) { out << "EXTEND "; } - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_DELETE) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_DELETE) { out << "DELETE "; } - if ((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXECUTE) + if((res->ACCESS4res_u.resok4.access) & NFS41::ACCESS4_EXECUTE) { out << "EXECUTE "; } @@ -2886,19 +3015,19 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::ACCESS4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4args* args) { - if (args) + if(args) { - out << "seqid: " << std::hex << args->seqid << std::dec + out << "seqid: " << std::hex << args->seqid << std::dec << " open state id:" << args->open_stateid; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " open state id:" << res->CLOSE4res_u.open_stateid; } @@ -2907,19 +3036,19 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::CLOSE4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4args* args) { - if (args) + if(args) { - out << "offset: " << args->offset - << " count: " << args->count; + out << "offset: " << args->offset + << " count: " << args->count; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " write verifier: "; print_hex(out, @@ -2931,20 +3060,20 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::COMMIT4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4args* args) { - if (args) + if(args) { - out << "object type: " << args->objtype - << " object name: " << args->objname + out << "object type: " << args->objtype + << " object name: " << args->objname << " create attributes: " << args->createattrs; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) out << res->CREATE4res_u.resok4.cinfo << ' ' << res->CREATE4res_u.resok4.attrset; } @@ -2952,35 +3081,45 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4args* args) { - if (args) { out << "client id: " << std::hex << args->clientid << std::dec; } + if(args) { + out << "client id: " << std::hex << args->clientid << std::dec; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGPURGE4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4args* args) { - if (args) { out << args->deleg_stateid; } + if(args) { + out << args->deleg_stateid; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::DELEGRETURN4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4args* args) { - if (args) { out << args->attr_request; } + if(args) { + out << args->attr_request; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << ' ' << res->GETATTR4res_u.resok4.obj_attributes; } @@ -2989,15 +3128,17 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::GETATTR4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4args* args) { - if (args) { out << "new name: " << args->newname; } + if(args) { + out << "new name: " << args->newname; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << ' ' << res->LINK4res_u.resok4.cinfo; } @@ -3006,34 +3147,34 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LINK4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " reclaim: " << args->reclaim - << " offset: " << args->offset - << " length: " << args->length - << " locker: " << args->locker; + out << "lock type: " << args->locktype + << " reclaim: " << args->reclaim + << " offset: " << args->offset + << " length: " << args->length + << " locker: " << args->locker; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all()) + if(out_all()) { - switch (res->status) + switch(res->status) { case NFS41::nfsstat4::NFS4_OK: out << " lock stat id: " << res->LOCK4res_u.resok4.lock_stateid; break; case NFS41::nfsstat4::NFS4ERR_DENIED: - out << " offset: " << res->LOCK4res_u.denied.offset - << " length: " << res->LOCK4res_u.denied.length + out << " offset: " << res->LOCK4res_u.denied.offset + << " length: " << res->LOCK4res_u.denied.length << " lock type: " << res->LOCK4res_u.denied.locktype - << " owner: " << res->LOCK4res_u.denied.owner; + << " owner: " << res->LOCK4res_u.denied.owner; break; default: break; @@ -3044,46 +3185,46 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCK4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " offset: " << args->offset - << " length: " << args->length - << " owner: " << args->owner; + out << "lock type: " << args->locktype + << " offset: " << args->offset + << " length: " << args->length + << " owner: " << args->owner; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKT4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4ERR_DENIED) - out << " offset: " << res->LOCKT4res_u.denied.offset - << " length: " << res->LOCKT4res_u.denied.length + if(out_all() && res->status == NFS41::nfsstat4::NFS4ERR_DENIED) + out << " offset: " << res->LOCKT4res_u.denied.offset + << " length: " << res->LOCKT4res_u.denied.length << " lock type: " << res->LOCKT4res_u.denied.locktype - << " owner: " << res->LOCKT4res_u.denied.owner; + << " owner: " << res->LOCKT4res_u.denied.owner; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4args* args) { - if (args) + if(args) { - out << "lock type: " << args->locktype - << " seqid: " << std::hex << args->seqid << std::dec + out << "lock type: " << args->locktype + << " seqid: " << std::hex << args->seqid << std::dec << " lock state id: " << args->lock_stateid - << " offset: " << args->offset - << " length: " << args->length; + << " offset: " << args->offset + << " length: " << args->length; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " lock state id: " << res->LOCKU4res_u.lock_stateid; } @@ -3092,46 +3233,54 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LOCKU4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4args* args) { - if (args) { out << "object name: " << args->objname; } + if(args) { + out << "object name: " << args->objname; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUP4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4args* args) { - if (args) { out << "object attributes: " << args->obj_attributes; } + if(args) { + out << "object attributes: " << args->obj_attributes; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::NVERIFY4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4args* args) { - static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"}; + static const char* const open4_share_access[4] = {"", "READ", "WRITE", "BOTH"}; static const char* const open4_share_deny[4] = {"NONE", "READ", "WRITE", "BOTH"}; - if (args) + if(args) { - out << "seqid: " << std::hex << args->seqid << std::dec + out << "seqid: " << std::hex << args->seqid << std::dec << " share access: " << open4_share_access[args->share_access] - << " share deny: " << open4_share_deny[args->share_deny] + << " share deny: " << open4_share_deny[args->share_deny] << ' ' << args->owner << ' ' << args->openhow << ' ' << args->claim; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) out << res->OPEN4res_u.resok4.stateid << res->OPEN4res_u.resok4.cinfo << " results flags: " @@ -3143,29 +3292,33 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4args* args) { - if (args) { out << "create directory: " << args->createdir; } + if(args) { + out << "create directory: " << args->createdir; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::OPENATTR4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4args* args) { - if (args) + if(args) { - out << "open state id:" << args->open_stateid - << " seqid: " << std::hex << args->seqid << std::dec; + out << "open state id:" << args->open_stateid + << " seqid: " << std::hex << args->seqid << std::dec; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " open state id:" << res->OPEN_CONFIRM4res_u.resok4.open_stateid; } @@ -3174,21 +3327,21 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_CONFIRM4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4args* args) { - if (args) + if(args) { out << " open state id: " << args->open_stateid - << " seqid: " << std::hex << args->seqid << std::dec - << " share access: " << args->share_access - << " share deny: " << args->share_deny; + << " seqid: " << std::hex << args->seqid << std::dec + << " share access: " << args->share_access + << " share deny: " << args->share_deny; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << ' ' << res->OPEN_DOWNGRADE4res_u.resok4.open_stateid; } @@ -3197,37 +3350,39 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::OPEN_DOWNGRADE4res* res void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4args* args) { - if (args) + if(args) { out << "object: "; print_nfs_fh(out, args->object.nfs_fh4_val, args->object.nfs_fh4_len); } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4args* args) { - if (args) + if(args) { out << args->stateid - << " offset: " << args->offset - << " count: " << args->count; + << " offset: " << args->offset + << " count: " << args->count; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " eof: " << res->READ4res_u.resok4.eof; - if (res->READ4res_u.resok4.data.data_len) + if(res->READ4res_u.resok4.data.data_len) { out << " data: " << *res->READ4res_u.resok4.data.data_val; } @@ -3237,38 +3392,40 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::READ4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4args* args) { - if (args) + if(args) { - out << "cookie: " << args->cookie - << " cookieverf: " << args->cookieverf - << " dir count: " << args->dircount - << " max count: " << args->maxcount + out << "cookie: " << args->cookie + << " cookieverf: " << args->cookieverf + << " dir count: " << args->dircount + << " max count: " << args->maxcount << " attributes request: " << args->attr_request; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::READDIR4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) out << " cookie verifier: " << res->READDIR4res_u.resok4.cookieverf - << " reply: " << res->READDIR4res_u.resok4.reply; + << " reply: " << res->READDIR4res_u.resok4.reply; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4args* args) { - if (args) { out << "target: " << args->target; } + if(args) { + out << "target: " << args->target; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << ' ' << res->REMOVE4res_u.resok4.cinfo; } @@ -3277,19 +3434,19 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::REMOVE4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4args* args) { - if (args) + if(args) { - out << "old name: " << args->oldname + out << "old name: " << args->oldname << " new name: " << args->newname; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) out << " source: " << res->RENAME4res_u.resok4.source_cinfo << " target: " @@ -3299,31 +3456,35 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::RENAME4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4args* args) { - if (args) + if(args) { out << "client id: " << std::hex << args->clientid << std::dec; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::RENEW4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4args* args) { - if (args) { out << "name: " << args->name; } + if(args) { + out << "name: " << args->name; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { - if (res->SECINFO4res_u.resok4.SECINFO4resok_len) + if(res->SECINFO4res_u.resok4.SECINFO4resok_len) { out << *res->SECINFO4res_u.resok4.SECINFO4resok_val; } @@ -3333,25 +3494,27 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SECINFO4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4args* args) { - if (args) + if(args) { out << "state id:" << args->stateid << ' ' << args->obj_attributes; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::SETATTR4res* res) { - if (res) + if(res) { - out << "status: " << res->status; - if (out_all()) { out << ' ' << res->attrsset; } + out << "status: " << res->status; + if(out_all()) { + out << ' ' << res->attrsset; + } } } void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4args* args) { - if (args) + if(args) { out << args->client << " callback: " @@ -3361,14 +3524,14 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4args* args) } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all()) + if(out_all()) { - switch (res->status) + switch(res->status) { case NFS41::nfsstat4::NFS4_OK: out << " client id: " @@ -3390,7 +3553,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4args* args) { - if (args) + if(args) { out << " client id: " << std::hex << args->clientid << std::dec << " verifier: "; @@ -3398,41 +3561,47 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4args } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::SETCLIENTID_CONFIRM4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4args* args) { - if (args) { out << "object attributes: " << args->obj_attributes; } + if(args) { + out << "object attributes: " << args->obj_attributes; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::VERIFY4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4args* args) { - if (args) + if(args) { out << args->stateid - << " offset: " << args->offset - << " stable: " << args->stable + << " offset: " << args->offset + << " stable: " << args->stable << " data length: " << args->data.data_len; } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { - out << " count: " << res->WRITE4res_u.resok4.count - << " committed: " << res->WRITE4res_u.resok4.committed + out << " count: " << res->WRITE4res_u.resok4.count + << " committed: " << res->WRITE4res_u.resok4.committed << " write verifier: "; print_hex(out, res->WRITE4res_u.resok4.writeverf, @@ -3443,20 +3612,24 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::WRITE4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4args* args) { - if (args) { out << "lock owner: " << args->lock_owner; } + if(args) { + out << "lock owner: " << args->lock_owner; + } } -void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::RELEASE_LOCKOWNER4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::GETFH4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " object: " << res->GETFH4res_u.resok4.object; } @@ -3465,25 +3638,31 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::GETFH4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LOOKUPP4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTPUBFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::PUTROOTFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::READLINK4res* res) { - if (res) + if(res) { out << "status: " << res->status; - if (out_all() && res->status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->status == NFS41::nfsstat4::NFS4_OK) { out << " link: " << res->READLINK4res_u.resok4.link; } @@ -3492,47 +3671,51 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::READLINK4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::RESTOREFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::SAVEFH4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4args* args) { - if (args) - out << "signal delegation available: " << args->gdda_signal_deleg_avail - << " notification types: " << args->gdda_notification_types - << " child attr delay: " << args->gdda_child_attr_delay - << " dir attr delay: " << args->gdda_dir_attr_delay - << " child child attributes: " << args->gdda_child_attributes - << " child dir attributes: " << args->gdda_dir_attributes; + if(args) + out << "signal delegation available: " << args->gdda_signal_deleg_avail + << " notification types: " << args->gdda_notification_types + << " child attr delay: " << args->gdda_child_attr_delay + << " dir attr delay: " << args->gdda_dir_attr_delay + << " child child attributes: " << args->gdda_child_attributes + << " child dir attributes: " << args->gdda_dir_attributes; } -void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4res* res) +void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4res* res) { - if (res) + if(res) { out << "status: " << res->gddr_status; - if (out_all() && res->gddr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->gddr_status == NFS41::nfsstat4::NFS4_OK) { out << " status: " << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status; - if (out_all() && res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status == NFS41::gddrnf4_status::GDD4_OK) + if(out_all() && res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.gddrnf_status == NFS41::gddrnf4_status::GDD4_OK) { - out << " cookieverf: "; + out << " cookieverf: "; print_hex(out, res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_cookieverf, NFS41::NFS4_VERIFIER_SIZE); out << " stateid: " - << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_stateid + << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_stateid << " notification: " - << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_notification + << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_notification << " child attributes: " - << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_child_attributes + << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_child_attributes << " dir attributes: " - << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_dir_attributes; + << res->GET_DIR_DELEGATION4res_u.gddr_res_non_fatal4.GET_DIR_DELEGATION4res_non_fatal_u.gddrnf_resok4.gddr_dir_attributes; } else { @@ -3545,12 +3728,12 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::GET_DIR_DELEGATION4res* void PrintAnalyzer::nfs41_operation(const struct NFS41::BACKCHANNEL_CTL4args* args) { - if (args) + if(args) { - out << "program: " << args->bca_cb_program + out << "program: " << args->bca_cb_program << " sec parms: "; - NFS41::callback_sec_parms4* current_el {args->bca_sec_parms.bca_sec_parms_val}; - for (u_int i {0}; i < args->bca_sec_parms.bca_sec_parms_len; i++, current_el++) + NFS41::callback_sec_parms4* current_el{args->bca_sec_parms.bca_sec_parms_val}; + for(u_int i{0}; i < args->bca_sec_parms.bca_sec_parms_len; i++, current_el++) { out << ' ' << current_el; } @@ -3559,28 +3742,30 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::BACKCHANNEL_CTL4args* ar void PrintAnalyzer::nfs41_operation(const struct NFS41::BACKCHANNEL_CTL4res* res) { - if (res) { out << "status: " << res->bcr_status; } + if(res) { + out << "status: " << res->bcr_status; + } } void PrintAnalyzer::nfs41_operation(const struct NFS41::BIND_CONN_TO_SESSION4args* args) { - if (args) + if(args) { - out << "sessid: "; + out << "sessid: "; print_hex(out, args->bctsa_sessid, NFS41::NFS4_SESSIONID_SIZE); - out << " dir: " << args->bctsa_dir + out << " dir: " << args->bctsa_dir << " use conn in rdma mode: " << args->bctsa_use_conn_in_rdma_mode; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::BIND_CONN_TO_SESSION4res* res) { - if (res) + if(res) { out << "status: " << res->bctsr_status; - if (out_all() && res->bctsr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->bctsr_status == NFS41::nfsstat4::NFS4_OK) { out << " sessid: "; print_hex(out, @@ -3596,14 +3781,14 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::BIND_CONN_TO_SESSION4res void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4args* args) { - if (args) + if(args) { - out << "client owner: " << args->eia_clientowner - << " flags: " << args->eia_flags + out << "client owner: " << args->eia_clientowner + << " flags: " << args->eia_flags << " state protect: " << args->eia_state_protect << " client impl id: "; - NFS41::nfs_impl_id4* current_el {args->eia_client_impl_id.eia_client_impl_id_val}; - for (u_int i {0}; i < args->eia_client_impl_id.eia_client_impl_id_len; i++, current_el++) + NFS41::nfs_impl_id4* current_el{args->eia_client_impl_id.eia_client_impl_id_val}; + for(u_int i{0}; i < args->eia_client_impl_id.eia_client_impl_id_len; i++, current_el++) { out << ' ' << current_el; } @@ -3612,23 +3797,23 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4args* args) void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4res* res) { - if (res) + if(res) { out << "status: " << res->eir_status; - if (out_all() && res->eir_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->eir_status == NFS41::nfsstat4::NFS4_OK) { - out << " clientid: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_clientid + out << " clientid: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_clientid << " sequenceid: 0x" << std::hex << res->EXCHANGE_ID4res_u.eir_resok4.eir_sequenceid << std::dec - << " flags: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_flags - << " state protect: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_state_protect - << " server owner: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner + << " flags: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_flags + << " state protect: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_state_protect + << " server owner: " << res->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner << " server scope: "; print_hex(out, res->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_val, res->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_len); out << " server impl id:"; - NFS41::nfs_impl_id4* current_el {res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val}; - for (u_int i {0}; i < res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_len; i++, current_el++) + NFS41::nfs_impl_id4* current_el{res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val}; + for(u_int i{0}; i < res->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_len; i++, current_el++) { out << ' ' << current_el; } @@ -3638,17 +3823,17 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::EXCHANGE_ID4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE_SESSION4args* args) { - if (args) + if(args) { - out << "clientid: 0x" << std::hex << args->csa_clientid - << "; seqid: 0x" << std::hex << args->csa_sequence << std::dec - << "; flags: " << args->csa_flags - << "; fore chan attrs: [ " << args->csa_fore_chan_attrs << " ] " - << "; fore back attrs: [ " << args->csa_back_chan_attrs << " ] " - << "; cb program: 0x" << std::hex << args->csa_cb_program << std::dec + out << "clientid: 0x" << std::hex << args->csa_clientid + << "; seqid: 0x" << std::hex << args->csa_sequence << std::dec + << "; flags: " << args->csa_flags + << "; fore chan attrs: [ " << args->csa_fore_chan_attrs << " ] " + << "; fore back attrs: [ " << args->csa_back_chan_attrs << " ] " + << "; cb program: 0x" << std::hex << args->csa_cb_program << std::dec << "; callback sec parms:"; - NFS41::callback_sec_parms4* current_el {args->csa_sec_parms.csa_sec_parms_val}; - for (u_int i {0}; i < args->csa_sec_parms.csa_sec_parms_len; i++, current_el++) + NFS41::callback_sec_parms4* current_el{args->csa_sec_parms.csa_sec_parms_val}; + for(u_int i{0}; i < args->csa_sec_parms.csa_sec_parms_len; i++, current_el++) { out << ' ' << current_el; } @@ -3657,26 +3842,26 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE_SESSION4args* arg void PrintAnalyzer::nfs41_operation(const struct NFS41::CREATE_SESSION4res* res) { - if (res) + if(res) { out << "status: " << res->csr_status; - if (out_all() && res->csr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->csr_status == NFS41::nfsstat4::NFS4_OK) { out << " session id: "; print_hex(out, res->CREATE_SESSION4res_u.csr_resok4.csr_sessionid, NFS41::NFS4_SESSIONID_SIZE); out << " sequenceid: 0x" << std::hex << res->CREATE_SESSION4res_u.csr_resok4.csr_sequence << std::dec - << " flags: " << res->CREATE_SESSION4res_u.csr_resok4.csr_flags - << " fore chan attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_fore_chan_attrs - << " fore back attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_back_chan_attrs; + << " flags: " << res->CREATE_SESSION4res_u.csr_resok4.csr_flags + << " fore chan attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_fore_chan_attrs + << " fore back attrs: " << res->CREATE_SESSION4res_u.csr_resok4.csr_back_chan_attrs; } } } void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4args* args) { - if (args) + if(args) { out << "session id: "; print_hex(out, @@ -3687,7 +3872,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4args* ar void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4res* res) { - if (res) + if(res) { out << "status: " << res->dsr_status; } @@ -3695,7 +3880,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_SESSION4res* res void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4args* args) { - if (args) + if(args) { out << "stateid: " << args->fsa_stateid; } @@ -3703,7 +3888,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4args* args) void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4res* res) { - if (res) + if(res) { out << "status: " << res->fsr_status; } @@ -3711,28 +3896,28 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::FREE_STATEID4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICEINFO4args* args) { - if (args) + if(args) { - out << "device id: " << args->gdia_device_id - << " layout type: " << args->gdia_layout_type - << " maxcount: " << args->gdia_maxcount + out << "device id: " << args->gdia_device_id + << " layout type: " << args->gdia_layout_type + << " maxcount: " << args->gdia_maxcount << " notify types: " << args->gdia_notify_types; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICEINFO4res* res) { - if (res) + if(res) { out << "status: " << res->gdir_status; - if (out_all()) + if(out_all()) { - if (res->gdir_status == NFS41::nfsstat4::NFS4_OK) + if(res->gdir_status == NFS41::nfsstat4::NFS4_OK) { - out << " device addr: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_device_addr + out << " device addr: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_device_addr << " notification: " << res->GETDEVICEINFO4res_u.gdir_resok4.gdir_notification; } - if (res->gdir_status == NFS41::nfsstat4::NFS4ERR_TOOSMALL) + if(res->gdir_status == NFS41::nfsstat4::NFS4ERR_TOOSMALL) { out << " min count: " << res->GETDEVICEINFO4res_u.gdir_mincount; } @@ -3742,55 +3927,55 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICEINFO4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICELIST4args* args) { - if (args) + if(args) { - out << "layout type: " << args->gdla_layout_type + out << "layout type: " << args->gdla_layout_type << " max devices: " << args->gdla_maxdevices - << " cookie: " << args->gdla_cookie - << " cookieverf: " << args->gdla_cookieverf; + << " cookie: " << args->gdla_cookie + << " cookieverf: " << args->gdla_cookieverf; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::GETDEVICELIST4res* res) { - if (res) + if(res) { out << "status: " << res->gdlr_status; - if (out_all() && res->gdlr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->gdlr_status == NFS41::nfsstat4::NFS4_OK) { - out << " cookie: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookie - << " cookieverf: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookieverf + out << " cookie: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookie + << " cookieverf: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_cookieverf << " device id list: "; - NFS41::deviceid4* current_el {res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_val}; - for (u_int i {0}; i < res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_len; i++, current_el++) + NFS41::deviceid4* current_el{res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_val}; + for(u_int i{0}; i < res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_deviceid_list.gdlr_deviceid_list_len; i++, current_el++) { out << ' ' << current_el; } - out << " eof: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_eof; + out << " eof: " << res->GETDEVICELIST4res_u.gdlr_resok4.gdlr_eof; } } } void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTCOMMIT4args* args) { - if (args) + if(args) { - out << "offset: " << args->loca_offset - << " length: " << args->loca_length - << " reclaim: " << args->loca_reclaim - << " stateid: " << args->loca_stateid - << " last write offset: " << args->loca_last_write_offset - << " time modify: " << args->loca_time_modify - << " tayout update: " << args->loca_layoutupdate; + out << "offset: " << args->loca_offset + << " length: " << args->loca_length + << " reclaim: " << args->loca_reclaim + << " stateid: " << args->loca_stateid + << " last write offset: " << args->loca_last_write_offset + << " time modify: " << args->loca_time_modify + << " tayout update: " << args->loca_layoutupdate; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTCOMMIT4res* res) { - if (res) + if(res) { out << "status: " << res->locr_status; - if (out_all() && res->locr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->locr_status == NFS41::nfsstat4::NFS4_OK) { out << " new size: " << res->LAYOUTCOMMIT4res_u.locr_resok4.locr_newsize; } @@ -3799,27 +3984,27 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTCOMMIT4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4args* args) { - if (args) + if(args) { - out << "signal layout avail: " << args->loga_signal_layout_avail - << " layout type: " << args->loga_layout_type - << " iomode: " << args->loga_iomode - << " offset: " << args->loga_offset - << " length: " << args->loga_length - << " minlength: " << args->loga_minlength - << " stateid: " << args->loga_stateid - << " maxcount: " << args->loga_maxcount; + out << "signal layout avail: " << args->loga_signal_layout_avail + << " layout type: " << args->loga_layout_type + << " iomode: " << args->loga_iomode + << " offset: " << args->loga_offset + << " length: " << args->loga_length + << " minlength: " << args->loga_minlength + << " stateid: " << args->loga_stateid + << " maxcount: " << args->loga_maxcount; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4res* res) { - if (res) + if(res) { out << "status: " << res->logr_status; - if (out_all()) + if(out_all()) { - if (res->logr_status == NFS41::nfsstat4::NFS4_OK) + if(res->logr_status == NFS41::nfsstat4::NFS4_OK) { out << " return on close: " << res->LAYOUTGET4res_u.logr_resok4.logr_return_on_close @@ -3827,13 +4012,13 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4res* res) << res->LAYOUTGET4res_u.logr_resok4.logr_stateid << " layout:x "; NFS41::layout4* current_el = res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_val; - for (u_int i {0}; i < res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_len; i++, current_el++) + for(u_int i{0}; i < res->LAYOUTGET4res_u.logr_resok4.logr_layout.logr_layout_len; i++, current_el++) { out << ' ' << current_el; } } } - if (res->logr_status == NFS41::nfsstat4::NFS4ERR_LAYOUTTRYLATER) + if(res->logr_status == NFS41::nfsstat4::NFS4ERR_LAYOUTTRYLATER) { out << "will signal layout avail: " << res->LAYOUTGET4res_u.logr_will_signal_layout_avail; @@ -3843,21 +4028,21 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTGET4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTRETURN4args* args) { - if (args) + if(args) { - out << "reclaim: " << args->lora_reclaim - << " layout type: " << args->lora_layout_type - << " iomode: " << args->lora_iomode + out << "reclaim: " << args->lora_reclaim + << " layout type: " << args->lora_layout_type + << " iomode: " << args->lora_iomode << " layout return: " << args->lora_layoutreturn; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTRETURN4res* res) { - if (res) + if(res) { out << "status: " << res->lorr_status; - if (out_all() && res->lorr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->lorr_status == NFS41::nfsstat4::NFS4_OK) { out << " stateid: " << res->LAYOUTRETURN4res_u.lorr_stateid; } @@ -3866,34 +4051,34 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::LAYOUTRETURN4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::SEQUENCE4args* args) { - if (args) + if(args) { - out << "sessionid: "; + out << "sessionid: "; print_hex(out, args->sa_sessionid, NFS41::NFS4_SESSIONID_SIZE); out << " sequenceid: 0x" << std::hex << args->sa_sequenceid << std::dec - << " slotid: " << args->sa_slotid - << " cache this: " << args->sa_cachethis; + << " slotid: " << args->sa_slotid + << " cache this: " << args->sa_cachethis; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::SEQUENCE4res* res) { - if (res) + if(res) { out << "status: " << res->sr_status; - if (out_all() && res->sr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->sr_status == NFS41::nfsstat4::NFS4_OK) { out << " session: "; print_hex(out, res->SEQUENCE4res_u.sr_resok4.sr_sessionid, NFS41::NFS4_SESSIONID_SIZE); out << " sequenceid: 0x" << std::hex << res->SEQUENCE4res_u.sr_resok4.sr_sequenceid << std::dec - << " slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_slotid - << " highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_highest_slotid - << " target highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_target_highest_slotid - << " status flags: " << res->SEQUENCE4res_u.sr_resok4.sr_status_flags; + << " slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_slotid + << " highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_highest_slotid + << " target highest slotid: " << res->SEQUENCE4res_u.sr_resok4.sr_target_highest_slotid + << " status flags: " << res->SEQUENCE4res_u.sr_resok4.sr_status_flags; } } } @@ -3901,7 +4086,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SEQUENCE4res* res) //SECINFO_NO_NAME4args void PrintAnalyzer::nfs41_operation(const enum NFS41::secinfo_style4* args) { - if (args) + if(args) { out << ' ' << *args; } @@ -3909,7 +4094,7 @@ void PrintAnalyzer::nfs41_operation(const enum NFS41::secinfo_style4* args) void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4args* args) { - if (args) + if(args) { out << "ssv: "; out.write(args->ssa_ssv.ssa_ssv_val, @@ -3922,10 +4107,10 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4args* args) void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4res* res) { - if (res) + if(res) { out << "status: " << res->ssr_status; - if (out_all() && res->ssr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->ssr_status == NFS41::nfsstat4::NFS4_OK) { out << " digest: "; out.write(res->SET_SSV4res_u.ssr_resok4.ssr_digest.ssr_digest_val, @@ -3936,11 +4121,11 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::SET_SSV4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4args* args) { - if (args) + if(args) { out << "stateids:"; NFS41::stateid4* current_el = args->ts_stateids.ts_stateids_val; - for (u_int i {0}; i < args->ts_stateids.ts_stateids_len; i++, current_el++) + for(u_int i{0}; i < args->ts_stateids.ts_stateids_len; i++, current_el++) { out << ' ' << current_el; } @@ -3949,14 +4134,14 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4args* args) void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4res* res) { - if (res) + if(res) { out << "status: " << res->tsr_status; - if (out_all() && res->tsr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->tsr_status == NFS41::nfsstat4::NFS4_OK) { out << " status codes: "; NFS41::nfsstat4* current_el = res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_val; - for (u_int i {0}; i < res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_len; i++, current_el++) + for(u_int i{0}; i < res->TEST_STATEID4res_u.tsr_resok4.tsr_status_codes.tsr_status_codes_len; i++, current_el++) { out << ' ' << current_el; } @@ -3966,19 +4151,19 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::TEST_STATEID4res* res) void PrintAnalyzer::nfs41_operation(const struct NFS41::WANT_DELEGATION4args* args) { - if (args) + if(args) { - out << "want: " << args->wda_want + out << "want: " << args->wda_want << " claim: " << args->wda_claim; } } void PrintAnalyzer::nfs41_operation(const struct NFS41::WANT_DELEGATION4res* res) { - if (res) + if(res) { out << "status: " << res->wdr_status; - if (out_all() && res->wdr_status == NFS41::nfsstat4::NFS4_OK) + if(out_all() && res->wdr_status == NFS41::nfsstat4::NFS4_OK) { out << res->WANT_DELEGATION4res_u.wdr_resok4; } @@ -3987,7 +4172,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::WANT_DELEGATION4res* res void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4args* args) { - if (args) + if(args) { out << "clientid: " << args->dca_clientid; } @@ -3995,7 +4180,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4args* a void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4res* res) { - if (res) + if(res) { out << "status: " << res->dcr_status; } @@ -4003,7 +4188,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::DESTROY_CLIENTID4res* re void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4args* args) { - if (args) + if(args) { out << "one fs: " << args->rca_one_fs; } @@ -4011,7 +4196,7 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4args* a void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4res* res) { - if (res) + if(res) { out << "status: " << res->rcr_status; } @@ -4019,10 +4204,11 @@ void PrintAnalyzer::nfs41_operation(const struct NFS41::RECLAIM_COMPLETE4res* re void PrintAnalyzer::nfs41_operation(const struct NFS41::ILLEGAL4res* res) { - if (res) { out << "status: " << res->status; } + if(res) { + out << "status: " << res->status; + } } - void PrintAnalyzer::flush_statistics() { // flush is in each handler diff --git a/src/analysis/print_analyzer.h b/src/analysis/print_analyzer.h index ba7e613..fc658b9 100644 --- a/src/analysis/print_analyzer.h +++ b/src/analysis/print_analyzer.h @@ -30,7 +30,6 @@ namespace NST { namespace analysis { - namespace NFS3 = NST::API::NFS3; namespace NFS4 = NST::API::NFS4; namespace NFS41 = NST::API::NFS41; @@ -38,13 +37,15 @@ namespace NFS41 = NST::API::NFS41; class PrintAnalyzer : public IAnalyzer { public: - PrintAnalyzer(std::ostream& o) : out(o) + PrintAnalyzer(std::ostream& o) + : out(o) { } ~PrintAnalyzer() { } + // clang-format off void closeFileSMBv2(const SMBv2::CloseFileCommand*, const SMBv2::CloseRequest*, const SMBv2::CloseResponse*) override final; @@ -456,11 +457,11 @@ public: void nfs41_operation(const struct NFS41::SAVEFH4res* res); void nfs41_operation(const struct NFS41::ILLEGAL4res* res); - + // clang-format on void flush_statistics() override final; private: - PrintAnalyzer(const PrintAnalyzer&) = delete; + PrintAnalyzer(const PrintAnalyzer&) = delete; PrintAnalyzer& operator=(const PrintAnalyzer&) = delete; std::ostream& out; @@ -469,5 +470,5 @@ private: } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//PRINT_ANALYZER_H +#endif //PRINT_ANALYZER_H //------------------------------------------------------------------------------ diff --git a/src/analysis/rpc_sessions.h b/src/analysis/rpc_sessions.h index bd2c23a..cf4db14 100644 --- a/src/analysis/rpc_sessions.h +++ b/src/analysis/rpc_sessions.h @@ -25,9 +25,9 @@ #include <cinttypes> #include <memory> #include <string> +#include <utility> #include <vector> #include <unordered_map> -#include <utility> #include "protocols/rpc/rpc_header.h" #include "utils/filtered_data.h" @@ -39,31 +39,30 @@ namespace NST { namespace analysis { - class Session : public utils::ApplicationSession { using FilteredDataQueue = NST::utils::FilteredDataQueue; -public: +public: Session(const utils::NetworkSession& s, utils::Session::Direction call_direction) - : utils::ApplicationSession{s, call_direction} + : utils::ApplicationSession{s, call_direction} { utils::Out message; message << "Detect session " << str(); } - ~Session() = default; - Session(const Session&) = delete; + ~Session() = default; + Session(const Session&) = delete; Session& operator=(const Session&) = delete; - + void save_call_data(const std::uint64_t xid, FilteredDataQueue::Ptr&& data) { FilteredDataQueue::Ptr& e = operations[xid]; - if(e) // xid call already exists + if(e) // xid call already exists { LOG("replace RPC Call XID:%" PRIu64 " for %s", xid, str().c_str()); } - e = std::move(data); // replace existing or set new + e = std::move(data); // replace existing or set new } inline FilteredDataQueue::Ptr get_call_data(const std::uint64_t xid) { @@ -84,7 +83,6 @@ public: inline const Session* get_session() const { return this; } private: - // TODO: add custom allocator based on BlockAllocator // to decrease cost of expensive insert/erase operations std::unordered_map<std::uint64_t, FilteredDataQueue::Ptr> operations; @@ -96,9 +94,9 @@ class Sessions public: using MsgType = NST::protocols::rpc::MsgType; - Sessions() = default; - ~Sessions()= default; - Sessions(const Sessions&) = delete; + Sessions() = default; + ~Sessions() = default; + Sessions(const Sessions&) = delete; Sessions& operator=(const Sessions&) = delete; Session* get_session(utils::NetworkSession* app, NST::utils::Session::Direction dir, MsgType type) @@ -107,7 +105,7 @@ public: { if(type == MsgType::CALL) // add new session only for Call { - std::unique_ptr<Session> ptr{ new Session{*app, dir} }; + std::unique_ptr<Session> ptr{new Session{*app, dir}}; sessions.emplace_back(std::move(ptr)); app->application = sessions.back().get(); // set reference @@ -118,11 +116,11 @@ public: } private: - std::vector< std::unique_ptr<Session> > sessions; + std::vector<std::unique_ptr<Session>> sessions; }; } // namespace analysis } // namespace NST //------------------------------------------------------------------------------ -#endif//RPC_SESSIONS_H +#endif //RPC_SESSIONS_H //------------------------------------------------------------------------------ diff --git a/src/api/cifs2_commands.h b/src/api/cifs2_commands.h index c5ca14c..9628ef3 100644 --- a/src/api/cifs2_commands.h +++ b/src/api/cifs2_commands.h @@ -32,6 +32,7 @@ namespace API */ namespace SMBv2 { +// clang-format off /*! CIFS v2 commands */ @@ -1252,8 +1253,11 @@ struct SetInfoResponse } __attribute__ ((__packed__)); } // namespace SMBv2 + +// clang-format on + } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//API_CIFS2_COMMANDS_H +#endif // API_CIFS2_COMMANDS_H //------------------------------------------------------------------------------ diff --git a/src/api/cifs_commands.h b/src/api/cifs_commands.h index c11e1f7..16605d3 100644 --- a/src/api/cifs_commands.h +++ b/src/api/cifs_commands.h @@ -34,6 +34,7 @@ namespace API */ namespace SMBv1 { +// clang-format off /*! CIFS v1 commands list */ @@ -344,9 +345,11 @@ struct InvalidResultType{} __attribute__ ((__packed__)); struct NoAndxCmdArgumentType{} __attribute__ ((__packed__)); //!< No command's arguments struct NoAndxCmdResultType{} __attribute__ ((__packed__)); //!< No command's results +// clang-format om + } // namespace SMBv1 } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//API_CIFS_COMMANDS_H +#endif// API_CIFS_COMMANDS_H //------------------------------------------------------------------------------ diff --git a/src/api/cifs_pc_to_net.h b/src/api/cifs_pc_to_net.h index 2587bd2..0363781 100644 --- a/src/api/cifs_pc_to_net.h +++ b/src/api/cifs_pc_to_net.h @@ -30,8 +30,8 @@ #define NFSTRACE_BIG_ENDIAN __BIG_ENDIAN #define NFSTRACE_LITTLE_ENDIAN __LITTLE_ENDIAN #else -#include <sys/param.h> #include <machine/endian.h> +#include <sys/param.h> #define NFSTRACE_BYTE_ORDER BYTE_ORDER #define NFSTRACE_BIG_ENDIAN BIG_ENDIAN #define NFSTRACE_LITTLE_ENDIAN LITTLE_ENDIAN @@ -43,19 +43,20 @@ namespace API { namespace SMBv2 { - -# if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN +#if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN // TODO: rename this function template to LEconstant2host -template<class T> +template <class T> constexpr T pc_to_net(T t) { static_assert(t == T{}, "try to not use pc_to_net w/o specialization"); return t; } -template<> +// clang-format off + +template <> constexpr std::uint64_t pc_to_net(std::uint64_t t) { return ((t & 0xFF00000000000000) >> 56) @@ -68,7 +69,7 @@ constexpr std::uint64_t pc_to_net(std::uint64_t t) | ((t & 0x00000000000000FF) << 56); } -template<> +template <> constexpr uint32_t pc_to_net(uint32_t t) { return ((t & 0xFF000000) >> 24) @@ -77,61 +78,63 @@ constexpr uint32_t pc_to_net(uint32_t t) | ((t & 0x000000FF) << 24); } -template<> +template <> constexpr uint16_t pc_to_net(uint16_t t) { return ((t & 0xFF00) >> 8) | ((t & 0x00FF) << 8); } -template<> +// clang-format on + +template <> constexpr std::uint8_t pc_to_net(std::uint8_t v) { return v; } -template<> +template <> constexpr std::int64_t pc_to_net(std::int64_t v) { return pc_to_net((std::uint64_t)v); } -template<> +template <> constexpr std::int32_t pc_to_net(std::int32_t v) { return pc_to_net((std::uint32_t)v); } -template<> +template <> constexpr std::int16_t pc_to_net(std::int16_t v) { return pc_to_net((std::uint16_t)v); } -template<> +template <> constexpr std::int8_t pc_to_net(std::int8_t v) { return pc_to_net((std::uint8_t)v); } -# else -# if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN +#else +#if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN /*! * Does nothing for Intel */ -template<class T> +template <class T> constexpr T pc_to_net(T t) { return t; } -# endif +#endif #endif } // SMBv2 } // API } // NST //------------------------------------------------------------------------------ -#endif//PC_TO_NET_H +#endif // PC_TO_NET_H //------------------------------------------------------------------------------ diff --git a/src/api/cifs_types.h b/src/api/cifs_types.h index 88691ae..6c4e473 100644 --- a/src/api/cifs_types.h +++ b/src/api/cifs_types.h @@ -24,8 +24,8 @@ //------------------------------------------------------------------------------ #include <sys/time.h> -#include "cifs_commands.h" #include "cifs2_commands.h" +#include "cifs_commands.h" #include "procedure.h" //------------------------------------------------------------------------------ namespace NST @@ -34,148 +34,144 @@ namespace protocols { namespace CIFSv1 { - struct RawMessageHeader; +struct RawMessageHeader; } namespace CIFSv2 { - struct RawMessageHeader; +struct RawMessageHeader; } } // namespace protocols namespace API { - /*! SMB 1 version */ namespace SMBv1 { - -using Session = u_int16_t;//!< Session IDentifier +using Session = u_int16_t; //!< Session IDentifier /*! Represents one SMB command */ template < typename Header, typename Request, - typename Response - > + typename Response> class Command : public Procedure<int> { public: - using RequestType = Request; - using ResponseType = Response; - using HeaderType = Header; - const HeaderType* req_header = nullptr; - const HeaderType* res_header = nullptr; - const RequestType* parg = nullptr;//!< Arguments of specified command - const ResponseType* pres = nullptr;//!< Results of specified command + using RequestType = Request; + using ResponseType = Response; + using HeaderType = Header; + const HeaderType* req_header = nullptr; + const HeaderType* res_header = nullptr; + const RequestType* parg = nullptr; //!< Arguments of specified command + const ResponseType* pres = nullptr; //!< Results of specified command }; -using CreateDirectoryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateDirectoryArgumentType, CreateDirectoryResultType>; //!< CreateDirectory command -using DeleteDirectoryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, DeleteDirectoryArgumentType, DeleteDirectoryResultType>; //!< DeleteDirectory command -using OpenCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenArgumentType, OpenResultType>; //!< Open command -using CreateCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CreateArgumentType, CreateResultType>; //!< Create command -using CloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CloseArgumentType, CloseResultType>; //!< Close command -using FlushCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FlushArgumentType, FlushResultType>; //!< Flush command -using DeleteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, DeleteArgumentType, DeleteResultType>; //!< Delete command -using RenameCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, RenameArgumentType, RenameResultType>; //!< Rename command -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. -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. -using ReadCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadArgumentType, ReadResultType>; //!< Read command -using WriteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteArgumentType, WriteResultType>; //!< Write command -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. -using UnlockByteRangeCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, UnlockByteRangeArgumentType, UnlockByteRangeResultType>; //!< UnLock Byte Range command -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. -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. -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. -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. -using SeekCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SeekArgumentType, SeekResultType>; //!< Seek command -using LockAndReadCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LockAndReadArgumentType, LockAndReadResultType>; //!< Lock And Read command -using WriteAndUnlockCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndUnlockArgumentType, WriteAndUnlockResultType>; //!< Write And Unlock command -using ReadRawCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadRawArgumentType, ReadRawResultType>; //!< Read raw command -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. -using ReadMpxSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadMpxSecondaryArgumentType, ReadMpxSecondaryResultType>; //!< Read Read Mpx Secondary command -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 -using WriteMpxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteMpxArgumentType, WriteMpxResultType>; //!< Write Mpx command -using WriteMpxSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteMpxSecondaryArgumentType, WriteMpxSecondaryResultType>; //!< Write Mpx 2 command -using WriteCompleteCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteCompleteArgumentType, WriteCompleteResultType>; //!< Write Complete command -using QueryServerCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryServerArgumentType, QueryServerResultType>; //!< Query Server (reserved) command -using SetInformation2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SetInformation2ArgumentType, SetInformation2ResultType>; //!< Set Information 2 command -using QueryInformation2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryInformation2ArgumentType, QueryInformation2ResultType>; //!< Query Information 2 command -using LockingAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LockingAndxArgumentType, LockingAndxResultType>; //!< Lock some bytes of the file command -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 -using TransactionSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TransactionSecondaryArgumentType, TransactionSecondaryResultType>; //!< Transaction 2 command -using IoctlCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, IoctlArgumentType, IoctlResultType>; //!< Ioctl command -using IoctlSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, IoctlSecondaryArgumentType, IoctlSecondaryResultType>; //!< Ioctl 2 command -using CopyCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CopyArgumentType, CopyResultType>; //!< Copy command -using MoveCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, MoveArgumentType, MoveResultType>; //!< Move command -using EchoCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, EchoArgumentType, EchoResultType>; //!< Echo command -using WriteAndCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndCloseArgumentType, WriteAndCloseResultType>; //!< Write And Close command -using OpenAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenAndxArgumentType, OpenAndxResultType>; //!< Open 2 command -using ReadAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadAndxArgumentType, ReadAndxResultType>; //!< Read 2 command -using WriteAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteAndxArgumentType, WriteAndxResultType>; //!< Write 2 command -using NewFileSizeCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NewFileSizeArgumentType, NewFileSizeResultType>; //!< New File Size command. Reserved but not implemented -using CloseAndTreeDiscCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, CloseAndTreeDiscArgumentType, CloseAndTreeDiscResultType>; //!< Reserved command -using Transaction2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, Transaction2ArgumentType, Transaction2ResultType>; //!< Transaction 2 command -using Transaction2SecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, Transaction2SecondaryArgumentType, Transaction2SecondaryResultType>; //!< Transaction 3 command -using FindClose2Command = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindClose2ArgumentType, FindClose2ResultType>; //!< Search handle close command -using FindNotifyCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindNotifyCloseArgumentType, FindNotifyCloseResultType>; //!< Search handle close command -using TreeConnectCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeConnectArgumentType, TreeConnectResultType>; //!< establish a client connection to a server share command -using TreeDisconnectCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeDisconnectArgumentType, TreeDisconnectResultType>; //!< Disconnect command -using NegotiateCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NegotiateArgumentType, NegotiateResultType>; //!< Negotiate command -using SessionSetupAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SessionSetupAndxArgumentType, SessionSetupAndxResultType>; //!< Session setup command -using LogoffAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, LogoffAndxArgumentType, LogoffAndxResultType>; //!< Log off command -using TreeConnectAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, TreeConnectAndxArgumentType, TreeConnectAndxResultType>; //!< Tree Connect command -using SecurityPackageAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SecurityPackageAndxArgumentType, SecurityPackageAndxResultType>; //!< Security Package command -using QueryInformationDiskCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, QueryInformationDiskArgumentType, QueryInformationDiskResultType>; //!< Query Disk Information command -using SearchCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, SearchArgumentType, SearchResultType>; //!< Search command -using FindCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindArgumentType, FindResultType>; //!< Find command -using FindUniqueCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindUniqueArgumentType, FindUniqueResultType>; //!< Find unique command -using FindCloseCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, FindCloseArgumentType, FindCloseResultType>; //!< Find close command -using NtTransactCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtTransactArgumentType, NtTransactResultType>; //!< Transact command -using NtTransactSecondaryCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtTransactSecondaryArgumentType, NtTransactSecondaryResultType>; //!< Transact 2 command -using NtCreateAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtCreateAndxArgumentType, NtCreateAndxResultType>; //!< Create command -using NtCancelCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtCancelArgumentType, NtCancelResultType>; //!< Cancel command -using NtRenameCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NtRenameArgumentType, NtRenameResultType>; //!< Rename command -using OpenPrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, OpenPrintFileArgumentType, OpenPrintFileResultType>; //!< Open Print File command -using WritePrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WritePrintFileArgumentType, WritePrintFileResultType>; //!< Write Print File command -using ClosePrintFileCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ClosePrintFileArgumentType, ClosePrintFileResultType>; //!< Close Print File command -using GetPrintQueueCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, GetPrintQueueArgumentType, GetPrintQueueResultType>; //!< Get Print Queue command -using ReadBulkCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, ReadBulkArgumentType, ReadBulkResultType>; //!< Read Bulk command -using WriteBulkCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteBulkArgumentType, WriteBulkResultType>; //!< Write Bulk command -using WriteBulkDataCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, WriteBulkDataArgumentType, WriteBulkDataResultType>; //!< Write Bulk command -using InvalidCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, InvalidArgumentType, InvalidResultType>; //!< Invalid command -using NoAndxCommand = SMBv1::Command< NST::protocols::CIFSv1::RawMessageHeader, NoAndxCmdArgumentType, NoAndxCmdResultType>; //!< No command +using CreateDirectoryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateDirectoryArgumentType, CreateDirectoryResultType>; //!< CreateDirectory command +using DeleteDirectoryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, DeleteDirectoryArgumentType, DeleteDirectoryResultType>; //!< DeleteDirectory command +using OpenCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenArgumentType, OpenResultType>; //!< Open command +using CreateCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CreateArgumentType, CreateResultType>; //!< Create command +using CloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CloseArgumentType, CloseResultType>; //!< Close command +using FlushCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FlushArgumentType, FlushResultType>; //!< Flush command +using DeleteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, DeleteArgumentType, DeleteResultType>; //!< Delete command +using RenameCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, RenameArgumentType, RenameResultType>; //!< Rename command +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. +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. +using ReadCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadArgumentType, ReadResultType>; //!< Read command +using WriteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteArgumentType, WriteResultType>; //!< Write command +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. +using UnlockByteRangeCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, UnlockByteRangeArgumentType, UnlockByteRangeResultType>; //!< UnLock Byte Range command +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. +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. +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. +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. +using SeekCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SeekArgumentType, SeekResultType>; //!< Seek command +using LockAndReadCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LockAndReadArgumentType, LockAndReadResultType>; //!< Lock And Read command +using WriteAndUnlockCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndUnlockArgumentType, WriteAndUnlockResultType>; //!< Write And Unlock command +using ReadRawCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadRawArgumentType, ReadRawResultType>; //!< Read raw command +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. +using ReadMpxSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadMpxSecondaryArgumentType, ReadMpxSecondaryResultType>; //!< Read Read Mpx Secondary command +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 +using WriteMpxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteMpxArgumentType, WriteMpxResultType>; //!< Write Mpx command +using WriteMpxSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteMpxSecondaryArgumentType, WriteMpxSecondaryResultType>; //!< Write Mpx 2 command +using WriteCompleteCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteCompleteArgumentType, WriteCompleteResultType>; //!< Write Complete command +using QueryServerCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryServerArgumentType, QueryServerResultType>; //!< Query Server (reserved) command +using SetInformation2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SetInformation2ArgumentType, SetInformation2ResultType>; //!< Set Information 2 command +using QueryInformation2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryInformation2ArgumentType, QueryInformation2ResultType>; //!< Query Information 2 command +using LockingAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LockingAndxArgumentType, LockingAndxResultType>; //!< Lock some bytes of the file command +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 +using TransactionSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TransactionSecondaryArgumentType, TransactionSecondaryResultType>; //!< Transaction 2 command +using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, IoctlArgumentType, IoctlResultType>; //!< Ioctl command +using IoctlSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, IoctlSecondaryArgumentType, IoctlSecondaryResultType>; //!< Ioctl 2 command +using CopyCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CopyArgumentType, CopyResultType>; //!< Copy command +using MoveCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, MoveArgumentType, MoveResultType>; //!< Move command +using EchoCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, EchoArgumentType, EchoResultType>; //!< Echo command +using WriteAndCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndCloseArgumentType, WriteAndCloseResultType>; //!< Write And Close command +using OpenAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenAndxArgumentType, OpenAndxResultType>; //!< Open 2 command +using ReadAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadAndxArgumentType, ReadAndxResultType>; //!< Read 2 command +using WriteAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteAndxArgumentType, WriteAndxResultType>; //!< Write 2 command +using NewFileSizeCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NewFileSizeArgumentType, NewFileSizeResultType>; //!< New File Size command. Reserved but not implemented +using CloseAndTreeDiscCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, CloseAndTreeDiscArgumentType, CloseAndTreeDiscResultType>; //!< Reserved command +using Transaction2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, Transaction2ArgumentType, Transaction2ResultType>; //!< Transaction 2 command +using Transaction2SecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, Transaction2SecondaryArgumentType, Transaction2SecondaryResultType>; //!< Transaction 3 command +using FindClose2Command = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindClose2ArgumentType, FindClose2ResultType>; //!< Search handle close command +using FindNotifyCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindNotifyCloseArgumentType, FindNotifyCloseResultType>; //!< Search handle close command +using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeConnectArgumentType, TreeConnectResultType>; //!< establish a client connection to a server share command +using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeDisconnectArgumentType, TreeDisconnectResultType>; //!< Disconnect command +using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NegotiateArgumentType, NegotiateResultType>; //!< Negotiate command +using SessionSetupAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SessionSetupAndxArgumentType, SessionSetupAndxResultType>; //!< Session setup command +using LogoffAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, LogoffAndxArgumentType, LogoffAndxResultType>; //!< Log off command +using TreeConnectAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, TreeConnectAndxArgumentType, TreeConnectAndxResultType>; //!< Tree Connect command +using SecurityPackageAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SecurityPackageAndxArgumentType, SecurityPackageAndxResultType>; //!< Security Package command +using QueryInformationDiskCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, QueryInformationDiskArgumentType, QueryInformationDiskResultType>; //!< Query Disk Information command +using SearchCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, SearchArgumentType, SearchResultType>; //!< Search command +using FindCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindArgumentType, FindResultType>; //!< Find command +using FindUniqueCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindUniqueArgumentType, FindUniqueResultType>; //!< Find unique command +using FindCloseCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, FindCloseArgumentType, FindCloseResultType>; //!< Find close command +using NtTransactCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtTransactArgumentType, NtTransactResultType>; //!< Transact command +using NtTransactSecondaryCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtTransactSecondaryArgumentType, NtTransactSecondaryResultType>; //!< Transact 2 command +using NtCreateAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtCreateAndxArgumentType, NtCreateAndxResultType>; //!< Create command +using NtCancelCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtCancelArgumentType, NtCancelResultType>; //!< Cancel command +using NtRenameCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NtRenameArgumentType, NtRenameResultType>; //!< Rename command +using OpenPrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, OpenPrintFileArgumentType, OpenPrintFileResultType>; //!< Open Print File command +using WritePrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WritePrintFileArgumentType, WritePrintFileResultType>; //!< Write Print File command +using ClosePrintFileCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ClosePrintFileArgumentType, ClosePrintFileResultType>; //!< Close Print File command +using GetPrintQueueCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, GetPrintQueueArgumentType, GetPrintQueueResultType>; //!< Get Print Queue command +using ReadBulkCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, ReadBulkArgumentType, ReadBulkResultType>; //!< Read Bulk command +using WriteBulkCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteBulkArgumentType, WriteBulkResultType>; //!< Write Bulk command +using WriteBulkDataCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, WriteBulkDataArgumentType, WriteBulkDataResultType>; //!< Write Bulk command +using InvalidCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, InvalidArgumentType, InvalidResultType>; //!< Invalid command +using NoAndxCommand = SMBv1::Command<NST::protocols::CIFSv1::RawMessageHeader, NoAndxCmdArgumentType, NoAndxCmdResultType>; //!< No command -}//SMBv1 +} //SMBv1 /*! SMB 2 version */ namespace SMBv2 { - -using CloseFileCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CloseRequest, CloseResponse>; //!< Close file command -using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, NegotiateRequest, NegotiateResponse>; //!< Negotiate command -using SessionSetupCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SessionSetupRequest, SessionSetupResponse>; //!< Session setup command -using EchoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, EchoRequest, EchoResponse>; //!< Echo command -using LogOffCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LogOffRequest, LogOffResponse>; //!< Log off command -using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeConnectRequest, TreeConnectResponse>; //!< Tree connect command -using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeDisconnectRequest, TreeDisconnectResponse>; //!< Tree disconnect command -using CreateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CreateRequest, CreateResponse>; //!< Create command -using QueryInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryInfoRequest, QueryInfoResponse>; //!< Query Info command -using QueryDirCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryDirRequest, QueryDirResponse>; //!< Query directory command -using FlushCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, FlushRequest, FlushResponse>; //!< Flush command -using ReadCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ReadRequest, ReadResponse>; //!< Read command -using WriteCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, WriteRequest, WriteResponse>; //!< Write command -using LockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LockRequest, LockResponse>; //!< Lock command -using CancelCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CancelRequest, CancelResponce>; //!< Cancel command -using ChangeNotifyCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ChangeNotifyRequest, ChangeNotifyResponse>; //!< Change Notify command -using BreakOpLockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, OplockAcknowledgment, OplockResponse>; //!< Break opportunistic lock command -using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, IoCtlRequest, IoCtlResponse>; //!< Ioctl command -using SetInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SetInfoRequest, SetInfoResponse>; //!< Set Info command +using CloseFileCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CloseRequest, CloseResponse>; //!< Close file command +using NegotiateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, NegotiateRequest, NegotiateResponse>; //!< Negotiate command +using SessionSetupCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SessionSetupRequest, SessionSetupResponse>; //!< Session setup command +using EchoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, EchoRequest, EchoResponse>; //!< Echo command +using LogOffCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LogOffRequest, LogOffResponse>; //!< Log off command +using TreeConnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeConnectRequest, TreeConnectResponse>; //!< Tree connect command +using TreeDisconnectCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, TreeDisconnectRequest, TreeDisconnectResponse>; //!< Tree disconnect command +using CreateCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CreateRequest, CreateResponse>; //!< Create command +using QueryInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryInfoRequest, QueryInfoResponse>; //!< Query Info command +using QueryDirCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, QueryDirRequest, QueryDirResponse>; //!< Query directory command +using FlushCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, FlushRequest, FlushResponse>; //!< Flush command +using ReadCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ReadRequest, ReadResponse>; //!< Read command +using WriteCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, WriteRequest, WriteResponse>; //!< Write command +using LockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, LockRequest, LockResponse>; //!< Lock command +using CancelCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, CancelRequest, CancelResponce>; //!< Cancel command +using ChangeNotifyCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, ChangeNotifyRequest, ChangeNotifyResponse>; //!< Change Notify command +using BreakOpLockCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, OplockAcknowledgment, OplockResponse>; //!< Break opportunistic lock command +using IoctlCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, IoCtlRequest, IoCtlResponse>; //!< Ioctl command +using SetInfoCommand = SMBv1::Command<NST::protocols::CIFSv2::RawMessageHeader, SetInfoRequest, SetInfoResponse>; //!< Set Info command } // namespace SMBv2 } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS_TYPES_H +#endif // CIFS_TYPES_H //------------------------------------------------------------------------------ diff --git a/src/api/ianalyzer.h b/src/api/ianalyzer.h index b9d7f06..001b4bf 100644 --- a/src/api/ianalyzer.h +++ b/src/api/ianalyzer.h @@ -25,24 +25,23 @@ #define IANALYZER_TYPE_H //------------------------------------------------------------------------------ #include "cifs_types.h" -#include "nfs_types.h" #include "nfs3_types_rpcgen.h" -#include "nfs4_types_rpcgen.h" #include "nfs41_types_rpcgen.h" +#include "nfs4_types_rpcgen.h" +#include "nfs_types.h" #include "rpc_types.h" //------------------------------------------------------------------------------ namespace NST { namespace API { - /*! Abstract interface for plugins that collect NFS3 statistics */ class INFSv3rpcgen { public: virtual ~INFSv3rpcgen() {} - + // clang-format off /*! NFSv3 "NULL" procedure * \param RPCProcedure - Specified procedure * \param NULL3args - procedure arguments @@ -1791,6 +1790,7 @@ public: * \param res - result of the command */ virtual void breakOplockSMBv2(const SMBv2::BreakOpLockCommand*, const SMBv2::OplockAcknowledgment*, const SMBv2::OplockResponse*) {} + // clang-format on }; /*! Base interface for all nfstrace plugins. @@ -1807,5 +1807,5 @@ public: } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//IANALYZER_TYPE_H +#endif // IANALYZER_TYPE_H //------------------------------------------------------------------------------ diff --git a/src/api/nfs3_types_rpcgen.h b/src/api/nfs3_types_rpcgen.h index db0ba56..cac35a2 100644 --- a/src/api/nfs3_types_rpcgen.h +++ b/src/api/nfs3_types_rpcgen.h @@ -30,6 +30,7 @@ namespace API { namespace NFS3 { +// clang-format off const uint32_t NFS3_FHSIZE {64}; const uint32_t NFS3_COOKIEVERFSIZE {8}; @@ -951,9 +952,11 @@ typedef struct COMMIT3res COMMIT3res; #define NFS_V3 3 +// clang-format on + } // namespace NFS3 } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS3_TYPES_RPCGEN_H +#endif // NFS3_TYPES_RPCGEN_H //------------------------------------------------------------------------------ diff --git a/src/api/nfs41_types_rpcgen.h b/src/api/nfs41_types_rpcgen.h index 74ae8be..fa4ee0e 100644 --- a/src/api/nfs41_types_rpcgen.h +++ b/src/api/nfs41_types_rpcgen.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // Author: Alexey Costroma -// Generated by rpcgen with minor compatibility fixes +// Generated by rpcgen with minor compatibility fixes // Description: All RFC5661 declared structures. // Copyright (c) 2015 EPAM Systems //------------------------------------------------------------------------------ @@ -31,6 +31,7 @@ namespace API { namespace NFS41 { +// clang-format off using authsys_parms = authunix_parms; @@ -3121,9 +3122,11 @@ const uint32_t NFS_CB {1}; const uint32_t CB_NULL {0}; const uint32_t CB_COMPOUND {1}; +// clang-format on + } // namespace NFS41 } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS41_TYPES_RPCGEN_H +#endif // NFS41_TYPES_RPCGEN_H //------------------------------------------------------------------------------ diff --git a/src/api/nfs4_types_rpcgen.h b/src/api/nfs4_types_rpcgen.h index ef700a3..5a98a2a 100644 --- a/src/api/nfs4_types_rpcgen.h +++ b/src/api/nfs4_types_rpcgen.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // Author: Alexey Costroma -// Generated by rpcgen with minor compatibility fixes +// Generated by rpcgen with minor compatibility fixes // Description: All RFC3530 declared structures. // Copyright (c) 2014 EPAM Systems //------------------------------------------------------------------------------ @@ -31,6 +31,7 @@ namespace API { namespace NFS4 { +// clang-format off #ifndef RPCSEC_GSS #define RPCSEC_GSS 6 @@ -1611,9 +1612,11 @@ const uint32_t NFS_CB {1}; const uint32_t CB_NULL {0}; const uint32_t CB_COMPOUND {1}; +// clang-format on + } // namespace NFS4 } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS4_TYPES_RPCGEN_H +#endif //NFS4_TYPES_RPCGEN_H //------------------------------------------------------------------------------ diff --git a/src/api/nfs_types.h b/src/api/nfs_types.h index 49c7719..f4009a8 100644 --- a/src/api/nfs_types.h +++ b/src/api/nfs_types.h @@ -26,9 +26,8 @@ namespace NST { namespace API { - -static const unsigned int NFS_V40 {0}; -static const unsigned int NFS_V41 {1}; +static const unsigned int NFS_V40{0}; +static const unsigned int NFS_V41{1}; //! struct ProcEnumNFS3 - containts all NFSv3 procedures struct ProcEnumNFS3 @@ -58,7 +57,7 @@ struct ProcEnumNFS3 PATHCONF = 20, COMMIT = 21 }; - static const unsigned int count {22}; //!< amount of procedures + static const unsigned int count{22}; //!< amount of procedures }; //! struct ProcEnumNFS4 - containts all NFSv4.0 procedures and operations @@ -110,8 +109,8 @@ struct ProcEnumNFS4 // Pleause, keep in mind that in all cases we suppose that NFSv4.0 // operation ILLEGAL(10044) has the second position in ProcEnumNFS4 }; - static const unsigned int count {41}; //!< amount of procedures & operations together - static const unsigned int count_proc {2}; //!< amount of procedures + static const unsigned int count{41}; //!< amount of procedures & operations together + static const unsigned int count_proc{2}; //!< amount of procedures }; //! struct ProcEnumNFS41 - containts all NFSv4.1 procedures and operations @@ -181,12 +180,12 @@ struct ProcEnumNFS41 // Pleause, keep in mind that in all cases we suppose that NFSv4.1 // operation ILLEGAL(10044) has the second position in ProcEnumNFS41 }; - static const unsigned int count {59}; //!< amount of procedures & operations together - static const unsigned int count_proc {2}; //!< amount of procedures + static const unsigned int count{59}; //!< amount of procedures & operations together + static const unsigned int count_proc{2}; //!< amount of procedures }; } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS_TYPES_H +#endif // NFS_TYPES_H //------------------------------------------------------------------------------ diff --git a/src/api/procedure.h b/src/api/procedure.h index 4401658..5059189 100644 --- a/src/api/procedure.h +++ b/src/api/procedure.h @@ -30,8 +30,7 @@ namespace NST { namespace API { - -template<typename ProcedureType> +template <typename ProcedureType> struct Procedure { ProcedureType call; @@ -45,5 +44,5 @@ struct Procedure } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//PROCEDURE_H +#endif // PROCEDURE_H //------------------------------------------------------------------------------ diff --git a/src/api/rpc_types.h b/src/api/rpc_types.h index 7d2e1a9..2aa7321 100644 --- a/src/api/rpc_types.h +++ b/src/api/rpc_types.h @@ -30,69 +30,68 @@ namespace NST { namespace API { - using RPCProcedure = Procedure<struct rpc_msg>; const uint32_t SUNRPC_MSG_VERSION = 2; enum MsgType : int32_t { - CALL =0, - REPLY=1 + CALL = 0, + REPLY = 1 }; enum ReplyStat : int32_t { - MSG_ACCEPTED=0, - MSG_DENIED =1 + MSG_ACCEPTED = 0, + MSG_DENIED = 1 }; enum AcceptStat : int32_t { - SUCCESS =0, /* RPC executed successfully */ - PROG_UNAVAIL =1, /* remote hasn't exported program */ - PROG_MISMATCH=2, /* remote can't support version # */ - PROC_UNAVAIL =3, /* program can't support procedure */ - GARBAGE_ARGS =4, /* procedure can't decode params */ - SYSTEM_ERR =5 /* errors like memory allocation failure */ + SUCCESS = 0, /* RPC executed successfully */ + PROG_UNAVAIL = 1, /* remote hasn't exported program */ + PROG_MISMATCH = 2, /* remote can't support version # */ + PROC_UNAVAIL = 3, /* program can't support procedure */ + GARBAGE_ARGS = 4, /* procedure can't decode params */ + SYSTEM_ERR = 5 /* errors like memory allocation failure */ }; enum RejectStat : int32_t { - RPC_MISMATCH =0, /* RPC version number != 2 */ - AUTH_ERROR =1 /* remote can't authenticate caller */ + RPC_MISMATCH = 0, /* RPC version number != 2 */ + AUTH_ERROR = 1 /* remote can't authenticate caller */ }; // Status returned from authentication check enum AuthStat : int32_t { - AUTH_OK =0, /* success */ + AUTH_OK = 0, /* success */ /* * failed at remote end */ - AUTH_BADCRED =1, /* bad credential (seal broken) */ - AUTH_REJECTEDCRED =2, /* client must begin new session */ - AUTH_BADVERF =3, /* bad verifier (seal broken) */ - AUTH_REJECTEDVERF =4, /* verifier expired or replayed */ - AUTH_TOOWEAK =5, /* rejected for security reasons */ + AUTH_BADCRED = 1, /* bad credential (seal broken) */ + AUTH_REJECTEDCRED = 2, /* client must begin new session */ + AUTH_BADVERF = 3, /* bad verifier (seal broken) */ + AUTH_REJECTEDVERF = 4, /* verifier expired or replayed */ + AUTH_TOOWEAK = 5, /* rejected for security reasons */ /* * failed locally */ - SUNRPC_AUTH_INVALIDRESP =6, /* bogus response verifier */ - SUNRPC_AUTH_FAILED =7, /* reason unknown */ + SUNRPC_AUTH_INVALIDRESP = 6, /* bogus response verifier */ + SUNRPC_AUTH_FAILED = 7, /* reason unknown */ /* * AUTH_KERB errors; deprecated. See [RFC2695] */ - AUTH_KERB_GENERIC = 8, /* kerberos generic error */ - AUTH_TIMEEXPIRE = 9, /* time of credential expired */ - AUTH_TKT_FILE = 10,/* problem with ticket file */ - AUTH_DECODE = 11,/* can't decode authenticator */ - AUTH_NET_ADDR = 12,/* wrong net address in ticket */ + AUTH_KERB_GENERIC = 8, /* kerberos generic error */ + AUTH_TIMEEXPIRE = 9, /* time of credential expired */ + AUTH_TKT_FILE = 10, /* problem with ticket file */ + AUTH_DECODE = 11, /* can't decode authenticator */ + AUTH_NET_ADDR = 12, /* wrong net address in ticket */ /* * RPCSEC_GSS GSS related errors */ - RPCSEC_GSS_CREDPROBLEM = 13,/* no credentials for user */ - RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */ + RPCSEC_GSS_CREDPROBLEM = 13, /* no credentials for user */ + RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */ }; struct OpaqueAuth @@ -109,32 +108,31 @@ struct MismatchInfo struct RPCMessage { - uint32_t xid; + uint32_t xid; uint32_t type; }; struct RPCCall : public RPCMessage { - uint32_t rpcvers; - uint32_t prog; - uint32_t vers; - uint32_t proc; + uint32_t rpcvers; + uint32_t prog; + uint32_t vers; + uint32_t proc; OpaqueAuth cred; OpaqueAuth verf; }; struct AcceptedReply { - OpaqueAuth verf; - uint32_t stat; - MismatchInfo mismatch_info; + OpaqueAuth verf; + uint32_t stat; + MismatchInfo mismatch_info; }; struct RejectedReply { - uint32_t stat; - union U - { + uint32_t stat; + union U { MismatchInfo mismatch_info; OpaqueAuth auth_stat; } u; @@ -142,9 +140,8 @@ struct RejectedReply struct RPCReply : public RPCMessage { - uint32_t stat; - union U - { + uint32_t stat; + union U { AcceptedReply accepted; RejectedReply rejected; } u; @@ -153,5 +150,5 @@ struct RPCReply : public RPCMessage } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//RPC_TYPES_H +#endif // RPC_TYPES_H //------------------------------------------------------------------------------ diff --git a/src/api/session.h b/src/api/session.h index 80d05ee..20ad6cd 100644 --- a/src/api/session.h +++ b/src/api/session.h @@ -30,46 +30,44 @@ namespace NST { namespace API { - struct Session { enum Direction { - Source =0, - Destination =1, - Unknown =0xBAD + Source = 0, + Destination = 1, + Unknown = 0xBAD }; enum Type { - TCP=0, - UDP=1 - } type :16; // 16 bit for alignment following integers + TCP = 0, + UDP = 1 + } type : 16; // 16 bit for alignment following integers enum IPType { - v4=0, - v6=1 - } ip_type:16; // 16 bit for alignment following integers + v4 = 0, + v6 = 1 + } ip_type : 16; // 16 bit for alignment following integers - in_port_t port[2]; // 2 ports in network byte order + in_port_t port[2]; // 2 ports in network byte order - union IPAddress - { - struct // 2 IPv4 addresses in network byte order + union IPAddress { + struct // 2 IPv4 addresses in network byte order { in_addr_t addr[2]; } v4; - union // 2 IPv6 addresses in network byte order + union // 2 IPv6 addresses in network byte order { - uint8_t addr [2][16]; + uint8_t addr[2][16]; uint32_t addr_uint32[2][4]; - } __attribute__ ((__packed__)) v6; + } __attribute__((__packed__)) v6; } ip; }; } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//SESSION_H +#endif // SESSION_H //------------------------------------------------------------------------------ diff --git a/src/api/xdr_types.h b/src/api/xdr_types.h index c113e5f..052dbae 100644 --- a/src/api/xdr_types.h +++ b/src/api/xdr_types.h @@ -22,14 +22,13 @@ #ifndef XDR_TYPES_H #define XDR_TYPES_H //------------------------------------------------------------------------------ -#include <cstdint> #include <cstddef> +#include <cstdint> //------------------------------------------------------------------------------ namespace NST { namespace API { - struct Opaque { inline void set(const uint8_t* p, uint32_t n) @@ -39,15 +38,14 @@ struct Opaque } inline uint8_t operator[](size_t i) const { return ptr[i]; } - inline const uint8_t* data() const { return ptr; } - inline uint32_t size() const { return len; } - - const uint8_t* ptr; - uint32_t len; + inline const uint8_t* data() const { return ptr; } + inline uint32_t size() const { return len; } + const uint8_t* ptr; + uint32_t len; }; } // namespace API } // namespace NST //------------------------------------------------------------------------------ -#endif//XDR_TYPES_H +#endif //XDR_TYPES_H //------------------------------------------------------------------------------ diff --git a/src/controller/build_info.h.in b/src/controller/build_info.h.in index 537d1f2..93dec01 100644 --- a/src/controller/build_info.h.in +++ b/src/controller/build_info.h.in @@ -29,7 +29,9 @@ constexpr unsigned int NST_VERSION = @NST_V_MAJOR@ * 1000 + @NST_V_MINOR@ * 100 + @NST_V_PATCH@; constexpr char PROGRAM_BUILD_INFO[]= - "@NST_VERSION_FULL@"; + "@NST_VERSION_FULL@\n" + "built on @CMAKE_SYSTEM@\n" + "by C++ compiler @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@ on @COMPILATION_DATE@"; constexpr char MODULES_DIRECTORY_PATH[] = "@CMAKE_INSTALL_PREFIX@/lib/nfstrace/"; diff --git a/src/controller/cmdline_args.cpp b/src/controller/cmdline_args.cpp index 91e2122..b41fd19 100644 --- a/src/controller/cmdline_args.cpp +++ b/src/controller/cmdline_args.cpp @@ -21,9 +21,9 @@ //------------------------------------------------------------------------------ #include "controller/cmdline_args.h" //------------------------------------------------------------------------------ -#define LIVE "live" -#define DUMP "dump" -#define STAT "stat" +#define LIVE "live" +#define DUMP "dump" +#define STAT "stat" #define DRAIN "drain" //------------------------------------------------------------------------------ namespace NST @@ -32,6 +32,7 @@ namespace controller { namespace cmdline { +// clang-format off const char* const Args::profiling_mode {LIVE}; const char* const Args::dumping_mode {DUMP}; @@ -64,6 +65,8 @@ Opt Args::options[Args::num] = {'h', "help", Opt::NOA, "false", "print help message and usage for modules passed with -a options, then exit", nullptr, nullptr, false} }; +// clang-format on + } // namespace cmdline } // namespace controller } // namespace NST diff --git a/src/controller/cmdline_args.h b/src/controller/cmdline_args.h index cbedbfc..59adb6a 100644 --- a/src/controller/cmdline_args.h +++ b/src/controller/cmdline_args.h @@ -30,7 +30,6 @@ namespace controller { namespace cmdline { - struct Args { friend class CmdlineParser<Args>; @@ -65,6 +64,7 @@ struct Args static const char* const dumping_mode; static const char* const analysis_mode; static const char* const draining_mode; + private: static Opt options[num]; @@ -75,5 +75,5 @@ private: } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//CMDLINE_PARSER_H +#endif // CMDLINE_PARSER_H //------------------------------------------------------------------------------ diff --git a/src/controller/cmdline_parser.h b/src/controller/cmdline_parser.h index db86e47..6ab374a 100644 --- a/src/controller/cmdline_parser.h +++ b/src/controller/cmdline_parser.h @@ -37,15 +37,18 @@ namespace controller { namespace cmdline { - class CLIError : public std::runtime_error { public: - explicit CLIError(const std::string& msg) : std::runtime_error{msg} { } + explicit CLIError(const std::string& msg) + : std::runtime_error{msg} + { + } }; struct Opt { + // clang-format off class Value { public: @@ -74,17 +77,18 @@ struct Opt const char* value_pattern; const char* value; bool passed; // is option parsed -}; + // clang-format on +}; template <typename CLI> class CmdlineParser { public: - CmdlineParser() = default; - virtual ~CmdlineParser() = default; - CmdlineParser(const CmdlineParser&) = delete; - CmdlineParser& operator=(const CmdlineParser&) = delete; + CmdlineParser() = default; + virtual ~CmdlineParser() = default; + CmdlineParser(const CmdlineParser&) = delete; + CmdlineParser& operator=(const CmdlineParser&) = delete; void parse(int argc, char** argv); void validate(); @@ -102,20 +106,19 @@ public: static bool is_default(typename CLI::Names name) { const Opt& a = CLI::options[name]; - return a.value == a.deflt; // compare pointers + return a.value == a.deflt; // compare pointers } static void print_usage(std::ostream& out, const char* executable); private: - virtual void set_multiple_value(int /*index*/, char *const /*v*/){} - - void set_value(int index, char *const v) + virtual void set_multiple_value(int /*index*/, char* const /*v*/) {} + void set_value(int index, char* const v) { Opt& a = CLI::options[index]; // if option argument specified - set it otherwise // set valid default OR "true" for no-args options - a.value = v ? v : (a.deflt && a.type != Opt::Type::NOA ? a.deflt : "true"); + a.value = v ? v : (a.deflt && a.type != Opt::Type::NOA ? a.deflt : "true"); a.passed = true; if(a.type == Opt::Type::MUL) @@ -128,7 +131,7 @@ private: { if(short_name) { - return { '\'', '-', short_name, '\'' }; + return {'\'', '-', short_name, '\''}; } return std::string{'\''} + long_name + '\''; } @@ -151,12 +154,12 @@ void CmdlineParser<CLI>::parse(int argc, char** argv) { // generate input data for getopt_long() option long_opts[CLI::num + 1]; // +1 for NULL-option - char short_opts[CLI::num * 2 + 2] = {0}; + char short_opts[CLI::num * 2 + 2] = {0}; short_opts[0] = ':'; - char *short_p = &short_opts[1]; - for (int i = 0; i < CLI::num; ++i) + char* short_p = &short_opts[1]; + for(int i = 0; i < CLI::num; ++i) { const Opt& a = CLI::options[i]; @@ -200,13 +203,13 @@ void CmdlineParser<CLI>::parse(int argc, char** argv) case '?': { - std::string unkn{ build_name(optopt, argv[optind-1]) }; + std::string unkn{build_name(optopt, argv[optind - 1])}; throw CLIError{std::string{"Unrecognized option: "} + unkn}; } case ':': { - std::string miss{ build_name(optopt, argv[optind-1]) }; + std::string miss{build_name(optopt, argv[optind - 1])}; throw CLIError{std::string{"Option requires an argument: "} + miss}; } @@ -226,18 +229,17 @@ void CmdlineParser<CLI>::parse(int argc, char** argv) if(optind != argc) { // quote non-option - std::string name{ build_name(0, argv[optind]) }; - throw CLIError{std::string{"Unexpected operand on command line: "} - + name}; + std::string name{build_name(0, argv[optind])}; + throw CLIError{std::string{"Unexpected operand on command line: "} + name}; } // set default values for(Opt& o : CLI::options) { - if(o.value == nullptr // is value still uninitialized? - && o.deflt != nullptr) // try to substitute by default value + if(o.value == nullptr // is value still uninitialized? + && o.deflt != nullptr) // try to substitute by default value { - o.value = o.deflt; + o.value = o.deflt; o.passed = false; } } @@ -251,8 +253,8 @@ void CmdlineParser<CLI>::validate() { if(o.value == nullptr) // is value still uninitialized? { - std::string lopt{ o.long_opt ? std::string("--") + o.long_opt : ""}; - std::string name{ build_name(o.short_opt, lopt) }; + std::string lopt{o.long_opt ? std::string("--") + o.long_opt : ""}; + std::string name{build_name(o.short_opt, lopt)}; throw CLIError{std::string{"Missing required option: "} + name}; } } @@ -271,9 +273,9 @@ void CmdlineParser<CLI>::print_usage(std::ostream& out, const char* name) if(o.short_opt) // print out short key { - char tmp[]{ '-', o.short_opt, ' ', '\0' }; + char tmp[]{'-', o.short_opt, ' ', '\0'}; if(o.long_opt) tmp[2] = ','; - s_opt = std::string{" "} + tmp; //indentation + s_opt = std::string{" "} + tmp; //indentation } if(o.long_opt) // print out long key { @@ -309,5 +311,5 @@ void CmdlineParser<CLI>::print_usage(std::ostream& out, const char* name) } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//CMDLINE_PARSER_H +#endif // CMDLINE_PARSER_H //------------------------------------------------------------------------------ diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 2023889..4b58ebc 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -26,15 +26,15 @@ #include <sys/types.h> #include <unistd.h> -#include "utils/filtered_data.h" #include "controller/controller.h" #include "controller/parameters.h" +#include "utils/filtered_data.h" //------------------------------------------------------------------------------ namespace NST { namespace controller { - +// clang-format off Controller::Running::Running(Controller& i) : controller(i) { @@ -57,7 +57,7 @@ Controller::Running::~Running() controller.analysis->stop(); } } - +// clang-format off Controller::Controller(const Parameters& params) try : gout {utils::Out::Level(params.verbose_level())} , glog {params.log_path()} @@ -65,37 +65,38 @@ Controller::Controller(const Parameters& params) try , analysis {} , filtration {new FiltrationManager{status}} { + // clang-format on switch(params.running_mode()) { - case RunningMode::Profiling: - { - analysis.reset(new AnalysisManager{status, params}); - if(analysis->isSilent()) - utils::Out::Global::set_level(utils::Out::Level::Silent); + case RunningMode::Profiling: + { + analysis.reset(new AnalysisManager{status, params}); + if(analysis->isSilent()) + utils::Out::Global::set_level(utils::Out::Level::Silent); - filtration->add_online_analysis(params, analysis->get_queue()); - } - break; - case RunningMode::Dumping: - { - filtration->add_online_dumping(params); - } - break; - case RunningMode::Analysis: - { - analysis.reset(new AnalysisManager{status, params}); - if(analysis->isSilent()) - utils::Out::Global::set_level(utils::Out::Level::Silent); + filtration->add_online_analysis(params, analysis->get_queue()); + } + break; + case RunningMode::Dumping: + { + filtration->add_online_dumping(params); + } + break; + case RunningMode::Analysis: + { + analysis.reset(new AnalysisManager{status, params}); + if(analysis->isSilent()) + utils::Out::Global::set_level(utils::Out::Level::Silent); - filtration->add_offline_analysis(params.input_file(), - analysis->get_queue()); - } - break; - case RunningMode::Draining: - { - filtration->add_offline_dumping(params); - } - break; + filtration->add_offline_analysis(params.input_file(), + analysis->get_queue()); + } + break; + case RunningMode::Draining: + { + filtration->add_offline_dumping(params); + } + break; } droproot(params.dropuser()); } @@ -188,7 +189,7 @@ void droproot(const std::string& dropuser) } else if(!dropuser.empty()) { - struct passwd *pw = getpwnam(dropuser.c_str()); //get user uid & gid + struct passwd* pw = getpwnam(dropuser.c_str()); //get user uid & gid if(!pw) { diff --git a/src/controller/controller.h b/src/controller/controller.h index 890e4da..95da4ea 100644 --- a/src/controller/controller.h +++ b/src/controller/controller.h @@ -26,10 +26,10 @@ #include <memory> #include "analysis/analysis_manager.h" -#include "filtration/filtration_manager.h" #include "controller/parameters.h" #include "controller/running_status.h" #include "controller/signal_handler.h" +#include "filtration/filtration_manager.h" #include "utils/log.h" #include "utils/out.h" //------------------------------------------------------------------------------ @@ -37,11 +37,13 @@ namespace NST { namespace controller { - class ControllerError : public std::runtime_error { public: - explicit ControllerError(const std::string& msg) : std::runtime_error{msg} { } + explicit ControllerError(const std::string& msg) + : std::runtime_error{msg} + { + } }; class Controller @@ -53,25 +55,24 @@ class Controller { public: inline Running(Controller&); - Running() = delete; - Running(const Running&) = delete; - Running& operator=(const Running&) = delete; + Running() = delete; + Running(const Running&) = delete; + Running& operator=(const Running&) = delete; inline ~Running(); + private: Controller& controller; }; public: - Controller(const Parameters&); - Controller(const Controller&) = delete; + Controller(const Controller&) = delete; Controller& operator=(const Controller&) = delete; ~Controller(); int run(); private: - // initializer for global outptut utils::Out::Global gout; // initializer for global logger @@ -86,7 +87,6 @@ private: // controller subsystems std::unique_ptr<AnalysisManager> analysis; std::unique_ptr<FiltrationManager> filtration; - }; /*! Drop root privileges @@ -101,5 +101,5 @@ void droproot(const std::string& dropuser); } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//CONTROLLER_H +#endif // CONTROLLER_H //------------------------------------------------------------------------------ diff --git a/src/controller/parameters.cpp b/src/controller/parameters.cpp index 809c224..d7cc3e2 100644 --- a/src/controller/parameters.cpp +++ b/src/controller/parameters.cpp @@ -25,20 +25,18 @@ #include <unistd.h> #include "analysis/plugin.h" +#include "controller/build_info.h" #include "controller/cmdline_args.h" #include "controller/cmdline_parser.h" #include "controller/parameters.h" -#include "controller/build_info.h" #include "filtration/pcap/network_interfaces.h" //------------------------------------------------------------------------------ namespace NST { namespace controller { - namespace // implementation { - static const class ParametersImpl* impl = nullptr; using CLI = NST::controller::cmdline::Args; @@ -48,7 +46,7 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> friend class NST::controller::Parameters; ParametersImpl(int argc, char** argv) - : rpc_message_limit{0} + : rpc_message_limit{0} { parse(argc, argv); if(get(CLI::ArgHelp).to_bool()) @@ -58,7 +56,7 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> for(const auto& a : analysis_modules) { - const std::string& path {a.path}; + const std::string& path{a.path}; try { std::cout << "Usage of " << path << ":\n"; @@ -84,27 +82,27 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> std::cout << i << '\n'; for(auto a : i) std::cout << '\t' << a << '\n'; } - std::cout << "[default]: " << interfaces.default_device() << '\n'; + std::cout << "[default]: " << interfaces.default_device() << '\n'; } else { std::cerr << "Note: Reading list of network interfaces may " - "require that you have special privileges." << std::endl; + "require that you have special privileges." + << std::endl; } } if(get(CLI::ArgEnum).is("-") || get(CLI::ArgEnum).is("plugins")) { std::cout << "\nAvailable plugins:" << std::endl; - DIR *dir; + DIR* dir; if((dir = opendir(MODULES_DIRECTORY_PATH)) != nullptr) { - struct dirent *ent; + struct dirent* ent; while((ent = readdir(dir)) != nullptr) { - std::string full_path = std::string{MODULES_DIRECTORY_PATH} - + ent->d_name; + std::string full_path = std::string{MODULES_DIRECTORY_PATH} + ent->d_name; std::string plugin_usage; try { @@ -114,13 +112,15 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> std::cout << plugin_usage << std::endl; std::cout << std::endl; } - catch(std::runtime_error& e) { } + catch(std::runtime_error& e) + { + } } closedir(dir); } else { - std::cerr << "Error: Can't access " << MODULES_DIRECTORY_PATH <<std::endl; + std::cerr << "Error: Can't access " << MODULES_DIRECTORY_PATH << std::endl; } } @@ -128,10 +128,10 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> // cashed values const std::string program_path(argv[0]); - size_t found {program_path.find_last_of("/\\")}; - program = program_path.substr(found+1); + size_t found{program_path.find_last_of("/\\")}; + program = program_path.substr(found + 1); - const int limit {get(CLI::ArgMSize).to_int()}; + const int limit{get(CLI::ArgMSize).to_int()}; if(limit < 1 || limit > 4000) { throw cmdline::CLIError{std::string{"Invalid limit of RPC messages: "} + get(CLI::ArgMSize).to_cstr()}; @@ -139,17 +139,17 @@ class ParametersImpl : public cmdline::CmdlineParser<CLI> rpc_message_limit = limit; } - virtual ~ParametersImpl(){} - ParametersImpl(const ParametersImpl&) = delete; + virtual ~ParametersImpl() {} + ParametersImpl(const ParametersImpl&) = delete; ParametersImpl& operator=(const ParametersImpl&) = delete; protected: - void set_multiple_value(int index, char *const v) override + void set_multiple_value(int index, char* const v) override { if(index == CLI::ArgAnalyzers) // may have multiple values { const std::string arg{v}; - size_t ind {arg.find('#')}; + size_t ind{arg.find('#')}; if(ind == std::string::npos) { analysis_modules.emplace_back(path_to_pam(arg)); @@ -167,7 +167,7 @@ private: std::string default_iofile() const { // create string: PROGRAMNAME-BPF-FILTER.pcap - std::string str { impl->program }; + std::string str{impl->program}; str.push_back('-'); str.append(get(CLI::ArgFilter).to_cstr()); str.append(".pcap"); @@ -191,8 +191,8 @@ private: } // cashed values - unsigned short rpc_message_limit; - std::string program; // name of program in command line + unsigned short rpc_message_limit; + std::string program; // name of program in command line std::vector<AParams> analysis_modules; }; @@ -269,8 +269,7 @@ unsigned short Parameters::queue_capacity() const const int capacity = impl->get(CLI::ArgQSize).to_int(); if(capacity < 1 || capacity > 65535) { - throw cmdline::CLIError(std::string{"Invalid value of queue capacity: "} - + impl->get(CLI::ArgQSize).to_cstr()); + throw cmdline::CLIError(std::string{"Invalid value of queue capacity: "} + impl->get(CLI::ArgQSize).to_cstr()); } return capacity; @@ -290,12 +289,12 @@ int Parameters::verbose_level() const const Parameters::CaptureParams Parameters::capture_params() const { Parameters::CaptureParams params; - params.interface = impl->get(CLI::ArgInterface); - params.filter = impl->get(CLI::ArgFilter); - params.snaplen = impl->get(CLI::ArgSnaplen).to_int(); - params.timeout_ms = impl->get(CLI::ArgTimeout).to_int(); - params.buffer_size = impl->get(CLI::ArgBSize).to_int() * 1024 * 1024; // MBytes - params.promisc = impl->get(CLI::ArgPromisc).to_bool(); + params.interface = impl->get(CLI::ArgInterface); + params.filter = impl->get(CLI::ArgFilter); + params.snaplen = impl->get(CLI::ArgSnaplen).to_int(); + params.timeout_ms = impl->get(CLI::ArgTimeout).to_int(); + params.buffer_size = impl->get(CLI::ArgBSize).to_int() * 1024 * 1024; // MBytes + params.promisc = impl->get(CLI::ArgPromisc).to_bool(); // check interface if(impl->is_default(CLI::ArgInterface)) @@ -306,22 +305,19 @@ const Parameters::CaptureParams Parameters::capture_params() const // check capture buffer size if(params.buffer_size < 1024 * 1024) // less than 1 MBytes { - throw cmdline::CLIError{std::string{"Invalid value of kernel buffer size: "} - + impl->get(CLI::ArgBSize).to_cstr()}; + throw cmdline::CLIError{std::string{"Invalid value of kernel buffer size: "} + impl->get(CLI::ArgBSize).to_cstr()}; } // check max length of raw captured UDP packet if(params.snaplen < 1 || params.snaplen > 65535) { - throw cmdline::CLIError{std::string{"Invalid value of max length of raw captured UDP packet: "} - + impl->get(CLI::ArgSnaplen).to_cstr()}; + throw cmdline::CLIError{std::string{"Invalid value of max length of raw captured UDP packet: "} + impl->get(CLI::ArgSnaplen).to_cstr()}; } // check the read timeout that will be used on a capture if(params.timeout_ms < 1) { - throw cmdline::CLIError{std::string{"Invalid value of read timeout that will be used on a capture: "} - + impl->get(CLI::ArgTimeout).to_cstr()}; + throw cmdline::CLIError{std::string{"Invalid value of read timeout that will be used on a capture: "} + impl->get(CLI::ArgTimeout).to_cstr()}; } // check and set capture direction @@ -340,8 +336,7 @@ const Parameters::CaptureParams Parameters::capture_params() const } else { - throw cmdline::CLIError{std::string{"Unknown capturing direction: "} - + direction.to_cstr()}; + throw cmdline::CLIError{std::string{"Unknown capturing direction: "} + direction.to_cstr()}; } return params; diff --git a/src/controller/parameters.h b/src/controller/parameters.h index 0732a29..98fbaa5 100644 --- a/src/controller/parameters.h +++ b/src/controller/parameters.h @@ -32,7 +32,6 @@ namespace NST { namespace controller { - enum class RunningMode { Profiling, @@ -43,8 +42,16 @@ enum class RunningMode struct AParams { - AParams(const std::string& p) : path{p}, args{} {} - AParams(const std::string& p, const std::string& a) : path{p}, args{a} {} + AParams(const std::string& p) + : path{p} + , args{} + { + } + AParams(const std::string& p, const std::string& a) + : path{p} + , args{a} + { + } const std::string path; const std::string args; @@ -54,8 +61,8 @@ struct AParams */ enum class NetProtocol { - NFS = 0x01, //!< NFS protocol - CIFS = 0x02 //!< CIFS protocol + NFS = 0x01, //!< NFS protocol + CIFS = 0x02 //!< CIFS protocol }; class Parameters @@ -68,29 +75,29 @@ public: Parameters(int argc, char** argv); ~Parameters(); - Parameters(const Parameters&) = delete; + Parameters(const Parameters&) = delete; Parameters& operator=(const Parameters&) = delete; bool show_help() const; bool show_enum() const; // access helpers - const std::string& program_name() const; - RunningMode running_mode() const; - std::string input_file() const; - const std::string dropuser() const; - const std::string log_path() const; - unsigned short queue_capacity() const; - bool trace() const; - int verbose_level() const; - const CaptureParams capture_params() const; - const DumpingParams dumping_params() const; + const std::string& program_name() const; + RunningMode running_mode() const; + std::string input_file() const; + const std::string dropuser() const; + const std::string log_path() const; + unsigned short queue_capacity() const; + bool trace() const; + int verbose_level() const; + const CaptureParams capture_params() const; + const DumpingParams dumping_params() const; const std::vector<AParams>& analysis_modules() const; - static unsigned short rpcmsg_limit(); + static unsigned short rpcmsg_limit(); }; } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//PARAMETERS_H +#endif // PARAMETERS_H //------------------------------------------------------------------------------ diff --git a/src/controller/running_status.h b/src/controller/running_status.h index 2dd928d..b6be5a3 100644 --- a/src/controller/running_status.h +++ b/src/controller/running_status.h @@ -22,29 +22,31 @@ #ifndef RUNNING_STATUS_H #define RUNNING_STATUS_H //------------------------------------------------------------------------------ -#include <condition_variable> #include <exception> #include <iostream> #include <list> #include <mutex> +#include <condition_variable> #include <type_traits> //------------------------------------------------------------------------------ namespace NST { namespace controller { - class ProcessingDone : public std::runtime_error { public: - explicit ProcessingDone(const std::string& in) : std::runtime_error{in} { } + explicit ProcessingDone(const std::string& in) + : std::runtime_error{in} + { + } }; class RunningStatus { public: - RunningStatus() = default; - RunningStatus(const RunningStatus&) = delete; + RunningStatus() = default; + RunningStatus(const RunningStatus&) = delete; RunningStatus& operator=(const RunningStatus&) = delete; template <typename ExceptionType> @@ -63,13 +65,13 @@ public: std::exception_ptr wait_exception() { std::unique_lock<std::mutex> lock(mutex); - while(fifo.empty()) - { - condition.wait(lock); - } - std::exception_ptr e = fifo.front(); - fifo.pop_front(); - return e; + while(fifo.empty()) + { + condition.wait(lock); + } + std::exception_ptr e = fifo.front(); + fifo.pop_front(); + return e; } void wait_and_rethrow_exception() @@ -81,25 +83,25 @@ public: void print(std::ostream& out) { std::unique_lock<std::mutex> lock(mutex); - if(!fifo.empty()) + if(!fifo.empty()) + { + out << "list of unhandled exceptions:" << std::endl; + for(auto& e : fifo) { - out << "list of unhandled exceptions:" << std::endl; - for(auto& e : fifo) + try + { + std::rethrow_exception(e); + } + catch(const std::exception& e) + { + out << '\t' << e.what() << std::endl; + } + catch(...) { - try - { - std::rethrow_exception(e); - } - catch(const std::exception& e) - { - out << '\t' << e.what() << std::endl; - } - catch(...) - { - out << '\t' << "Unknown exception" << std::endl; - } + out << '\t' << "Unknown exception" << std::endl; } } + } } private: @@ -107,17 +109,17 @@ private: { if(e == nullptr) return; std::unique_lock<std::mutex> lock(mutex); - fifo.emplace_front(e); - condition.notify_one(); + fifo.emplace_front(e); + condition.notify_one(); } std::list<std::exception_ptr> fifo; - std::mutex mutex; - std::condition_variable condition; + std::mutex mutex; + std::condition_variable condition; }; } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//RUNNING_STATUS_H +#endif // RUNNING_STATUS_H //------------------------------------------------------------------------------ diff --git a/src/controller/signal_handler.cpp b/src/controller/signal_handler.cpp index f7fdf7a..0fe7ec9 100644 --- a/src/controller/signal_handler.cpp +++ b/src/controller/signal_handler.cpp @@ -20,13 +20,13 @@ */ //------------------------------------------------------------------------------ #include <cerrno> -#include <functional> // std::ref +#include <functional> // std::ref #include <system_error> -#include <unistd.h> #include <pthread.h> #include <signal.h> -#include <string.h> // for strsignal() +#include <string.h> // for strsignal() +#include <unistd.h> #include <sys/wait.h> @@ -36,10 +36,9 @@ namespace NST { namespace controller { - SignalHandler::Signal::Signal(int sig) -: std::runtime_error{::strsignal(sig)} -, signal_number{sig} + : std::runtime_error{::strsignal(sig)} + , signal_number{sig} { } @@ -50,8 +49,8 @@ static void handle_signals(const sigset_t waitmask, { while(running.test_and_set()) { - int signo {0}; - const int err {::sigwait(&waitmask, &signo)}; + int signo{0}; + const int err{::sigwait(&waitmask, &signo)}; if(err != 0) { status.push(std::system_error{err, std::system_category(), @@ -62,7 +61,7 @@ static void handle_signals(const sigset_t waitmask, if(signo == SIGCHLD) { // wait childern(compression in dumping mode may call fork()) - const pid_t pid {::wait(nullptr)}; + const pid_t pid{::wait(nullptr)}; if(pid == -1 && errno != ECHILD) { status.push(std::system_error{errno, std::system_category(), @@ -76,11 +75,13 @@ static void handle_signals(const sigset_t waitmask, } } -static void dummy(int) {} +static void dummy(int) +{ +} SignalHandler::SignalHandler(RunningStatus& s) -: handler{} -, running{ATOMIC_FLAG_INIT} // false + : handler{} + , running{ATOMIC_FLAG_INIT} // false { // set dummy handler for SIGCHLD to prevent ignoring it // in ::sigwait() on FreeBSD by default @@ -95,16 +96,16 @@ SignalHandler::SignalHandler(RunningStatus& s) sigset_t mask; ::sigemptyset(&mask); - ::sigaddset(&mask, SIGINT); // correct exit from program by Ctrl-C - ::sigaddset(&mask, SIGTERM); // correct exit when SIGTERM has been received - ::sigaddset(&mask, SIGCHLD); // stop sigwait-thread and wait children - ::sigaddset(&mask, SIGHUP); // signal for losing terminal - ::sigaddset(&mask, SIGWINCH); // signal for changing terminal size + ::sigaddset(&mask, SIGINT); // correct exit from program by Ctrl-C + ::sigaddset(&mask, SIGTERM); // correct exit when SIGTERM has been received + ::sigaddset(&mask, SIGCHLD); // stop sigwait-thread and wait children + ::sigaddset(&mask, SIGHUP); // signal for losing terminal + ::sigaddset(&mask, SIGWINCH); // signal for changing terminal size const int err = ::pthread_sigmask(SIG_BLOCK, &mask, nullptr); if(err != 0) { throw std::system_error(err, std::system_category(), - "error in SignalHandler pthread_sigmask"); + "error in SignalHandler pthread_sigmask"); } running.test_and_set(); @@ -121,4 +122,3 @@ SignalHandler::~SignalHandler() } // namespace controller } // namespace NST //------------------------------------------------------------------------------ - diff --git a/src/controller/signal_handler.h b/src/controller/signal_handler.h index 2f98ddf..af3e4d4 100644 --- a/src/controller/signal_handler.h +++ b/src/controller/signal_handler.h @@ -32,7 +32,6 @@ namespace NST { namespace controller { - class SignalHandler { public: @@ -44,17 +43,17 @@ public: }; SignalHandler(RunningStatus&); - SignalHandler(const SignalHandler&) = delete; + SignalHandler(const SignalHandler&) = delete; SignalHandler& operator=(const SignalHandler&) = delete; ~SignalHandler(); private: - std::thread handler; + std::thread handler; std::atomic_flag running; }; } // namespace controller } // namespace NST //------------------------------------------------------------------------------ -#endif//SIGNAL_HANDLER_H +#endif // SIGNAL_HANDLER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/cifs_filtrator.h b/src/filtration/cifs_filtrator.h index 4ad0c18..25dd18f 100644 --- a/src/filtration/cifs_filtrator.h +++ b/src/filtration/cifs_filtrator.h @@ -27,28 +27,25 @@ #include <pcap/pcap.h> -#include "filtration/packet.h" +#include "api/cifs2_commands.h" #include "filtration/filtratorimpl.h" #include "protocols/cifs/cifs.h" #include "protocols/cifs2/cifs2.h" #include "protocols/netbios/netbios.h" #include "utils/log.h" -#include "api/cifs2_commands.h" //------------------------------------------------------------------------------ namespace NST { namespace filtration { - using SMBv2Commands = NST::API::SMBv2::SMBv2Commands; -template<typename Writer> +template <typename Writer> class CIFSFiltrator : public FiltratorImpl<CIFSFiltrator<Writer>, Writer> { using BaseImpl = FiltratorImpl<CIFSFiltrator<Writer>, Writer>; - size_t rw_hdr_max {512}; // limit for SMB header to truncate messages + size_t rw_hdr_max{512}; // limit for SMB header to truncate messages public: - CIFSFiltrator() : BaseImpl() { @@ -99,7 +96,7 @@ public: { size_t length = 0; if(collection && collection.data_size() >= lengthOfBaseHeader()) - { //enough data is copied from previous packets to see its type + { //enough data is copied from previous packets to see its type if(isCIFSV1Header(collection.data())) { length = sizeof(NetBIOS::MessageHeader) + sizeof(CIFSv1::RawMessageHeader); @@ -109,29 +106,29 @@ public: length = sizeof(NetBIOS::MessageHeader) + sizeof(CIFSv2::RawMessageHeader); } else - { //got header but it is not CIFS - collection.reset();//dismiss copied data - info.dlen = 0;//skip entire packet + { //got header but it is not CIFS + collection.reset(); //dismiss copied data + info.dlen = 0; //skip entire packet return false; } return BaseImpl::collect_header(info, length, length); } - BaseImpl::collect_header(info, lengthOfBaseHeader(), lengthOfBaseHeader());//try to read base header - return false;//continue to read full header + BaseImpl::collect_header(info, lengthOfBaseHeader(), lengthOfBaseHeader()); //try to read base header + return false; //continue to read full header } inline bool find_and_read_message(PacketInfo& info, typename Writer::Collection& collection) { - if (const NetBIOS::MessageHeader* nb_header = NetBIOS::get_header(collection.data())) + if(const NetBIOS::MessageHeader* nb_header = NetBIOS::get_header(collection.data())) { const size_t length = nb_header->len() + sizeof(NetBIOS::MessageHeader); - if (const CIFSv1::MessageHeader* header = CIFSv1::get_header(collection.data() + sizeof(NetBIOS::MessageHeader))) + if(const CIFSv1::MessageHeader* header = CIFSv1::get_header(collection.data() + sizeof(NetBIOS::MessageHeader))) { BaseImpl::setMsgLen(length); set_msg_size(header, length); return BaseImpl::read_message(info); } - else if (const CIFSv2::MessageHeader* header = CIFSv2::get_header(collection.data() + sizeof(NetBIOS::MessageHeader))) + else if(const CIFSv2::MessageHeader* header = CIFSv2::get_header(collection.data() + sizeof(NetBIOS::MessageHeader))) { BaseImpl::setMsgLen(length); set_msg_size(header, length); @@ -144,7 +141,7 @@ public: private: inline void set_msg_size(const CIFSv1::MessageHeader* header, const size_t length) { - if ((header->cmd_code == CIFSv1::Commands::READ) || (header->cmd_code == CIFSv1::Commands::WRITE)) + if((header->cmd_code == CIFSv1::Commands::READ) || (header->cmd_code == CIFSv1::Commands::WRITE)) { return BaseImpl::setToBeCopied(std::min(length, rw_hdr_max)); } @@ -153,17 +150,16 @@ private: inline void set_msg_size(const CIFSv2::MessageHeader* header, const size_t length) { - if (((header->cmd_code == SMBv2Commands::READ) || (header->cmd_code == SMBv2Commands::WRITE)) && !header->nextCommand) + if(((header->cmd_code == SMBv2Commands::READ) || (header->cmd_code == SMBv2Commands::WRITE)) && !header->nextCommand) { return BaseImpl::setToBeCopied(std::min(length, rw_hdr_max)); } BaseImpl::setToBeCopied(length); } - }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS_FILTRATOR_H +#endif // CIFS_FILTRATOR_H //------------------------------------------------------------------------------ diff --git a/src/filtration/dumping.cpp b/src/filtration/dumping.cpp index 24699c2..bc9fe25 100644 --- a/src/filtration/dumping.cpp +++ b/src/filtration/dumping.cpp @@ -20,7 +20,7 @@ */ //------------------------------------------------------------------------------ #include <cerrno> -#include <exception> // std::terminate() +#include <exception> // std::terminate() #include <vector> #include <unistd.h> @@ -31,15 +31,14 @@ namespace NST { namespace filtration { - -Dumping::Dumping(pcap_t*const h, const Params& params) - : handle {h} - , base {params.output_file} - , name {params.output_file} - , command {params.command} - , limit {params.size_limit} - , part {0} - , size {0} +Dumping::Dumping(pcap_t* const h, const Params& params) + : handle{h} + , base{params.output_file} + , name{params.output_file} + , command{params.command} + , limit{params.size_limit} + , part{0} + , size{0} { open_dumping_file(name); } @@ -50,7 +49,7 @@ Dumping::~Dumping() void Dumping::open_dumping_file(const std::string& file_path) { - const char* path {file_path.c_str()}; + const char* path{file_path.c_str()}; LOG("Dumping packets to file:%s", path); dumper.reset(new pcap::PacketDumper{handle, path}); } @@ -65,30 +64,30 @@ void Dumping::exec_command() const { if(command.empty()) return; - NST::utils::Log::flush(); // flush buffer + NST::utils::Log::flush(); // flush buffer if(pid_t pid = fork()) // spawn child process { // parent process LOG("Try to execute(%s %s) in %u child process", command.c_str(), name.c_str(), pid); - NST::utils::Log::flush(); // flush buffer + NST::utils::Log::flush(); // flush buffer return; } else { // child process - std::istringstream ss(command); + std::istringstream ss(command); std::vector<std::string> tokens; - std::vector<char*> args; + std::vector<char*> args; // TODO: this parser doesn't work with dual quotes, like rm "a file.cpp" for(std::string arg; ss >> arg;) { - tokens.emplace_back(arg); - args .emplace_back(const_cast<char*>(tokens.back().c_str())); + tokens.emplace_back(arg); + args.emplace_back(const_cast<char*>(tokens.back().c_str())); } args.push_back(const_cast<char*>(name.c_str())); - args.push_back(nullptr); // need termination null pointer + args.push_back(nullptr); // need termination null pointer if(execvp(args[0], &args[0]) == -1) { @@ -108,7 +107,6 @@ std::ostream& operator<<(std::ostream& out, const Dumping::Params& params) return out; } - } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ diff --git a/src/filtration/dumping.h b/src/filtration/dumping.h index ef3798b..77a47f6 100644 --- a/src/filtration/dumping.h +++ b/src/filtration/dumping.h @@ -37,29 +37,27 @@ namespace NST { namespace filtration { - class Dumping { public: - class Collection { private: - const static int cache_size {4096}; + const static int cache_size{4096}; public: inline Collection() - : dumper {nullptr} - , buff_size {cache_size} - , payload {cache} - , payload_len {0} + : dumper{nullptr} + , buff_size{cache_size} + , payload{cache} + , payload_len{0} { } inline Collection(Dumping* d, utils::NetworkSession* /*unused*/) - : dumper {d} - , buff_size {cache_size} - , payload {cache} - , payload_len {0} + : dumper{d} + , buff_size{cache_size} + , payload{cache} + , payload_len{0} { } inline ~Collection() @@ -67,8 +65,8 @@ public: if(payload != cache) delete[] payload; } - Collection(Collection&&) = delete; - Collection(const Collection&) = delete; + Collection(Collection&&) = delete; + Collection(const Collection&) = delete; Collection& operator=(const Collection&) = delete; inline void set(Dumping& d, utils::NetworkSession* /*unused*/) @@ -91,7 +89,7 @@ public: inline void resize(uint32_t amount) { buff_size = amount; - uint8_t* buff {new uint8_t[amount]}; + uint8_t* buff{new uint8_t[amount]}; memcpy(buff, payload, payload_len); if(payload != cache) delete[] payload; @@ -100,7 +98,7 @@ public: inline void push(const PacketInfo& info, const uint32_t len) { - if(info.dumped) // if this packet not dumped yet + if(info.dumped) // if this packet not dumped yet { TRACE("The packet was collected before"); } @@ -108,14 +106,14 @@ public: { // direct dumping without waiting completeness of analysis and complete() call dumper->dump(info.header, info.packet); - info.dumped = true; // set marker of damped packet + info.dumped = true; // set marker of damped packet } if((payload_len + len) > capacity()) { resize(payload_len + len); } // copy payload - memcpy(payload+payload_len, info.data, len); + memcpy(payload + payload_len, info.data, len); payload_len += len; } @@ -129,36 +127,35 @@ public: reset(); } - inline uint32_t data_size() const { return payload_len; } - inline uint32_t capacity() const { return buff_size; } - inline const uint8_t* data() const { return payload; } - inline operator bool() const { return dumper != nullptr; } - + inline uint32_t data_size() const { return payload_len; } + inline uint32_t capacity() const { return buff_size; } + inline const uint8_t* data() const { return payload; } + inline operator bool() const { return dumper != nullptr; } private: Dumping* dumper; uint32_t buff_size; uint8_t* payload; - uint8_t cache[cache_size]; + uint8_t cache[cache_size]; uint32_t payload_len; }; struct Params { - std::string output_file{ }; - std::string command { }; - uint32_t size_limit {0}; + std::string output_file{}; + std::string command{}; + uint32_t size_limit{0}; }; - Dumping(pcap_t*const h, const Params& params); + Dumping(pcap_t* const h, const Params& params); ~Dumping(); - Dumping(const Dumping&) = delete; + Dumping(const Dumping&) = delete; Dumping& operator=(const Dumping&) = delete; inline void dump(const pcap_pkthdr* header, const u_char* packet) { if(limit) { - if( (size + sizeof(pcap_pkthdr) + header->caplen) > limit ) + if((size + sizeof(pcap_pkthdr) + header->caplen) > limit) { close_dumping_file(); @@ -184,13 +181,14 @@ private: void exec_command() const; std::unique_ptr<pcap::PacketDumper> dumper; - pcap_t* const handle; - const std::string base; - std::string name; - const std::string command; - const uint32_t limit; - uint32_t part; - uint32_t size; + + pcap_t* const handle; + const std::string base; + std::string name; + const std::string command; + const uint32_t limit; + uint32_t part; + uint32_t size; }; std::ostream& operator<<(std::ostream& out, const Dumping::Params& params); @@ -198,5 +196,5 @@ std::ostream& operator<<(std::ostream& out, const Dumping::Params& params); } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//DUMPING_H +#endif // DUMPING_H //------------------------------------------------------------------------------ diff --git a/src/filtration/filtration_manager.cpp b/src/filtration/filtration_manager.cpp index bb8f805..7a21596 100644 --- a/src/filtration/filtration_manager.cpp +++ b/src/filtration/filtration_manager.cpp @@ -34,7 +34,6 @@ namespace NST { namespace filtration { - using CaptureReader = NST::filtration::pcap::CaptureReader; using FileReader = NST::filtration::pcap::FileReader; @@ -44,35 +43,33 @@ using FilteredDataQueue = NST::utils::FilteredDataQueue; namespace // unnamed { - // FiltrationProcessor in separate processing thread -template -< +template < typename Reader, - typename Writer -> + typename Writer> class FiltrationImpl : public ProcessingThread { - using Processor = FiltrationProcessor<Reader, Writer, Filtrators< Writer >>; + using Processor = FiltrationProcessor<Reader, Writer, Filtrators<Writer>>; + public: explicit FiltrationImpl(std::unique_ptr<Reader>& reader, std::unique_ptr<Writer>& writer, - RunningStatus& status) - : ProcessingThread {status} - , processor{} + RunningStatus& status) + : ProcessingThread{status} + , processor{} { processor.reset(new Processor{reader, writer}); } - ~FiltrationImpl() = default; - FiltrationImpl(const FiltrationImpl&) = delete; + ~FiltrationImpl() = default; + FiltrationImpl(const FiltrationImpl&) = delete; FiltrationImpl& operator=(const FiltrationImpl&) = delete; virtual void stop() override final { processor->stop(); } -private: +private: virtual void run() override final { try @@ -89,32 +86,29 @@ private: }; // create Filtration thread emplaced in unique_ptr -template -< +template < typename Reader, - typename Writer -> + typename Writer> static auto create_thread(std::unique_ptr<Reader>& reader, std::unique_ptr<Writer>& writer, - RunningStatus& status) - -> std::unique_ptr<FiltrationImpl<Reader, Writer>> + RunningStatus& status) + -> std::unique_ptr<FiltrationImpl<Reader, Writer>> { using Thread = FiltrationImpl<Reader, Writer>; return std::unique_ptr<Thread>{new Thread{reader, writer, status}}; } - // create CaptureReader from Parameters emplaced in unique_ptr static auto create_capture_reader(const Parameters& params) - -> std::unique_ptr<CaptureReader> + -> std::unique_ptr<CaptureReader> { auto& capture_params = params.capture_params(); if(utils::Out message{}) // print parameters to user { message << capture_params; } - return std::unique_ptr<CaptureReader>{ new CaptureReader{capture_params} }; + return std::unique_ptr<CaptureReader>{new CaptureReader{capture_params}}; } } // unnamed namespace @@ -122,23 +116,23 @@ static auto create_capture_reader(const Parameters& params) // capture from network interface and dump to file - OnlineDumping(Dumping) void FiltrationManager::add_online_dumping(const Parameters& params) { - std::unique_ptr<CaptureReader> reader { create_capture_reader(params) }; + std::unique_ptr<CaptureReader> reader{create_capture_reader(params)}; auto& dumping_params = params.dumping_params(); if(utils::Out message{}) // print parameters to user { message << dumping_params; } - std::unique_ptr<Dumping> writer { new Dumping{ reader->get_handle(), dumping_params } }; + std::unique_ptr<Dumping> writer{new Dumping{reader->get_handle(), dumping_params}}; threads.emplace_back(create_thread(reader, writer, status)); } //capture data from input file or cin to destination file -void FiltrationManager::add_offline_dumping (const Parameters& params) +void FiltrationManager::add_offline_dumping(const Parameters& params) { auto& dumping_params = params.dumping_params(); - auto& ofile = dumping_params.output_file; - auto ifile = params.input_file(); + auto& ofile = dumping_params.output_file; + auto ifile = params.input_file(); if(ofile.compare("-")) { @@ -152,28 +146,25 @@ void FiltrationManager::add_offline_dumping (const Parameters& params) throw std::runtime_error{"Input and output files are equal. Use the -I and -O options to setup them explicitly."}; } } - } - std::unique_ptr<FileReader> reader { new FileReader{ifile} }; + std::unique_ptr<FileReader> reader{new FileReader{ifile}}; if(utils::Out message{}) // print parameters to user { message << *reader; } - std::unique_ptr<Dumping> writer { new Dumping{ reader->get_handle(), - dumping_params - } - }; + std::unique_ptr<Dumping> writer{new Dumping{reader->get_handle(), + dumping_params}}; threads.emplace_back(create_thread(reader, writer, status)); } // capture from network interface and pass to queue - OnlineAnalysis(Profiling) -void FiltrationManager::add_online_analysis(const Parameters& params, +void FiltrationManager::add_online_analysis(const Parameters& params, FilteredDataQueue& queue) { - std::unique_ptr<CaptureReader> reader { create_capture_reader(params) }; - std::unique_ptr<Queueing> writer { new Queueing{queue} }; + std::unique_ptr<CaptureReader> reader{create_capture_reader(params)}; + std::unique_ptr<Queueing> writer{new Queueing{queue}}; threads.emplace_back(create_thread(reader, writer, status)); } @@ -182,18 +173,18 @@ void FiltrationManager::add_online_analysis(const Parameters& params, void FiltrationManager::add_offline_analysis(const std::string& ifile, FilteredDataQueue& queue) { - std::unique_ptr<FileReader> reader { new FileReader{ifile} }; + std::unique_ptr<FileReader> reader{new FileReader{ifile}}; if(utils::Out message{}) // print parameters to user { message << *reader; } - std::unique_ptr<Queueing> writer { new Queueing{queue} }; + std::unique_ptr<Queueing> writer{new Queueing{queue}}; threads.emplace_back(create_thread(reader, writer, status)); } FiltrationManager::FiltrationManager(RunningStatus& s) -: status(s) + : status(s) { if(utils::Out message{utils::Out::Level::All}) { diff --git a/src/filtration/filtration_manager.h b/src/filtration/filtration_manager.h index 9399f09..3c8bb90 100644 --- a/src/filtration/filtration_manager.h +++ b/src/filtration/filtration_manager.h @@ -33,7 +33,6 @@ namespace NST { namespace filtration { - class FiltrationManager { using Parameters = NST::controller::Parameters; @@ -43,26 +42,25 @@ class FiltrationManager public: FiltrationManager(RunningStatus&); ~FiltrationManager(); - FiltrationManager(const FiltrationManager&) = delete; + FiltrationManager(const FiltrationManager&) = delete; FiltrationManager& operator=(const FiltrationManager&) = delete; - void add_online_dumping (const Parameters& params); // dump to file - void add_offline_dumping (const Parameters& params); // dump to file from input file - void add_online_analysis (const Parameters& params, FilteredDataQueue& queue); // capture to queue - void add_offline_analysis(const std::string& ifile, FilteredDataQueue& queue); // read file to queue + void add_online_dumping(const Parameters& params); // dump to file + void add_offline_dumping(const Parameters& params); // dump to file from input file + void add_online_analysis(const Parameters& params, FilteredDataQueue& queue); // capture to queue + void add_offline_analysis(const std::string& ifile, FilteredDataQueue& queue); // read file to queue void start(); void stop(); private: - RunningStatus& status; - std::vector< std::unique_ptr<class ProcessingThread> > threads; + std::vector<std::unique_ptr<class ProcessingThread>> threads; }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//FILTRATION_MANAGER_H +#endif // FILTRATION_MANAGER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/filtration_processor.h b/src/filtration/filtration_processor.h index 8eea6cf..ef98570 100644 --- a/src/filtration/filtration_processor.h +++ b/src/filtration/filtration_processor.h @@ -32,23 +32,22 @@ #include <pcap/pcap.h> -#include "utils/log.h" -#include "utils/out.h" -#include "utils/sessions.h" -#include "utils/profiler.h" #include "controller/parameters.h" #include "filtration/packet.h" #include "filtration/sessions_hash.h" -#include "protocols/rpc/rpc_header.h" #include "protocols/nfs3/nfs3_utils.h" #include "protocols/nfs4/nfs4_utils.h" +#include "protocols/rpc/rpc_header.h" +#include "utils/log.h" +#include "utils/out.h" +#include "utils/profiler.h" +#include "utils/sessions.h" //------------------------------------------------------------------------------ namespace NST { namespace filtration { - -using namespace NST::protocols::rpc;//FIXME: It is not good to use "using" in headers - should be removed +using namespace NST::protocols::rpc; //FIXME: It is not good to use "using" in headers - should be removed using ProcEnumNFS3 = API::ProcEnumNFS3; using NFS3Validator = NST::protocols::NFS3::Validator; using NFS4Validator = NST::protocols::NFS4::Validator; @@ -67,77 +66,77 @@ struct UDPSession : public utils::NetworkSession { public: UDPSession(Writer* w, uint32_t max_rpc_hdr) - : collection{w, this} - , nfs3_rw_hdr_max{max_rpc_hdr} + : collection{w, this} + , nfs3_rw_hdr_max{max_rpc_hdr} { } - UDPSession(UDPSession&&) = delete; - UDPSession(const UDPSession&) = delete; + UDPSession(UDPSession&&) = delete; + UDPSession(const UDPSession&) = delete; UDPSession& operator=(const UDPSession&) = delete; void collect(PacketInfo& info) { // TODO: this code must be generalized with RPCFiltrator class - uint32_t hdr_len {0}; - auto msg = reinterpret_cast<const MessageHeader*const>(info.data); + uint32_t hdr_len{0}; + auto msg = reinterpret_cast<const MessageHeader* const>(info.data); switch(msg->type()) { - case MsgType::CALL: + case MsgType::CALL: + { + auto call = static_cast<const CallHeader* const>(msg); + if(RPCValidator::check(call)) { - auto call = static_cast<const CallHeader*const>(msg); - if(RPCValidator::check(call)) + if(NFS3Validator::check(call)) { - if (NFS3Validator::check(call)) + uint32_t proc{call->proc()}; + if(ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit { - uint32_t proc {call->proc()}; - if (ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit - { - hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen); - } - else - { - if (ProcEnumNFS3::READ == proc) - nfs3_read_match.insert(call->xid()); - hdr_len = info.dlen; - } - } - else if (NFS4Validator::check(call)) - { - hdr_len = info.dlen; // fully collect NFSv4 messages + hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen); } else { - return; + if(ProcEnumNFS3::READ == proc) + nfs3_read_match.insert(call->xid()); + hdr_len = info.dlen; } } + else if(NFS4Validator::check(call)) + { + hdr_len = info.dlen; // fully collect NFSv4 messages + } else { return; } } - break; - case MsgType::REPLY: + else { - auto reply = static_cast<const ReplyHeader*const>(msg); - if(RPCValidator::check(reply)) - { - // Truncate NFSv3 READ reply message to NFSv3-RW-limit - //* Collect fully if reply received before matching call - if (nfs3_read_match.erase(reply->xid()) > 0) - { - hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen); - } - else - hdr_len = info.dlen; - } - else // isn't RPC reply, stream is corrupt + return; + } + } + break; + case MsgType::REPLY: + { + auto reply = static_cast<const ReplyHeader* const>(msg); + if(RPCValidator::check(reply)) + { + // Truncate NFSv3 READ reply message to NFSv3-RW-limit + //* Collect fully if reply received before matching call + if(nfs3_read_match.erase(reply->xid()) > 0) { - return; + hdr_len = (nfs3_rw_hdr_max < info.dlen ? nfs3_rw_hdr_max : info.dlen); } + else + hdr_len = info.dlen; } - break; - default: + else // isn't RPC reply, stream is corrupt + { return; + } + } + break; + default: + return; } collection.allocate(); @@ -148,8 +147,8 @@ public: } typename Writer::Collection collection; - uint32_t nfs3_rw_hdr_max; - MessageSet nfs3_read_match; + uint32_t nfs3_rw_hdr_max; + MessageSet nfs3_read_match; }; // Represents TCP conversation between node A and node B @@ -157,28 +156,28 @@ template <typename StreamReader> class TCPSession : public utils::NetworkSession { public: - struct Flow { // Helpers for comparison sequence numbers // Idea for gt: either x > y, or y is much bigger (assume wrap) - inline static bool GT_SEQ(uint32_t x, uint32_t y){ return (int32_t)((y) - (x)) < 0; } - inline static bool LT_SEQ(uint32_t x, uint32_t y){ return (int32_t)((x) - (y)) < 0; } - inline static bool GE_SEQ(uint32_t x, uint32_t y){ return (int32_t)((y) - (x)) <= 0; } - inline static bool LE_SEQ(uint32_t x, uint32_t y){ return (int32_t)((x) - (y)) <= 0; } - inline static bool EQ_SEQ(uint32_t x, uint32_t y){ return (x) ==(y); } - + inline static bool GT_SEQ(uint32_t x, uint32_t y) { return (int32_t)((y) - (x)) < 0; } + inline static bool LT_SEQ(uint32_t x, uint32_t y) { return (int32_t)((x) - (y)) < 0; } + inline static bool GE_SEQ(uint32_t x, uint32_t y) { return (int32_t)((y) - (x)) <= 0; } + inline static bool LE_SEQ(uint32_t x, uint32_t y) { return (int32_t)((x) - (y)) <= 0; } + inline static bool EQ_SEQ(uint32_t x, uint32_t y) { return (x) == (y); } friend class TCPSession<StreamReader>; - Flow() : fragments{nullptr}, sequence{0} + Flow() + : fragments{nullptr} + , sequence{0} { } ~Flow() { reset(); } - Flow(Flow&&) = delete; - Flow(const Flow&) = delete; + Flow(Flow&&) = delete; + Flow(const Flow&) = delete; Flow& operator=(const Flow&) = delete; void reset() @@ -196,20 +195,20 @@ public: void reassemble(PacketInfo& info) { - uint32_t seq {info.tcp->seq()}; - uint32_t len {info.dlen}; + uint32_t seq{info.tcp->seq()}; + uint32_t len{info.dlen}; - if( sequence == 0 ) // this is the first time we have seen this src's sequence number + if(sequence == 0) // this is the first time we have seen this src's sequence number { sequence = seq + len; - if( info.tcp->is(tcp_header::SYN) ) + if(info.tcp->is(tcp_header::SYN)) { sequence++; } if(len > 0) { - reader.push(info); // write out the packet data + reader.push(info); // write out the packet data } return; @@ -217,20 +216,19 @@ public: // if we are here, we have already seen this src, let's // try and figure out if this packet is in the right place - if( LT_SEQ(seq, sequence) ) + if(LT_SEQ(seq, sequence)) { // this sequence number seems dated, but // check the end to make sure it has no more // info than we have already seen - uint32_t newseq {seq + len}; - if( GT_SEQ(newseq, sequence) ) + uint32_t newseq{seq + len}; + if(GT_SEQ(newseq, sequence)) { - // this one has more than we have seen. let's get the // payload that we have not seen - uint32_t new_len {sequence - seq}; + uint32_t new_len{sequence - seq}; - if ( info.dlen <= new_len ) + if(info.dlen <= new_len) { info.data = nullptr; info.dlen = 0; @@ -249,21 +247,22 @@ public: } } - if ( EQ_SEQ(seq, sequence) ) // right on time + if(EQ_SEQ(seq, sequence)) // right on time { sequence += len; - if( info.tcp->is(tcp_header::SYN) ) sequence++; + if(info.tcp->is(tcp_header::SYN)) sequence++; - if( info.data && info.dlen > 0) + if(info.data && info.dlen > 0) { reader.push(info); } // done with the packet, see if it caused a fragment to fit - while( check_fragments(0) ); + while(check_fragments(0)) + ; } else // out of order packet { - if(info.dlen > 0 && GT_SEQ(seq, sequence) ) + if(info.dlen > 0 && GT_SEQ(seq, sequence)) { //TRACE("ADD FRAGMENT seq: %u dlen: %u sequence: %u", seq, info.dlen, sequence); fragments = Packet::create(info, fragments); @@ -273,37 +272,37 @@ public: bool check_fragments(const uint32_t acknowledged) { - Packet* current {fragments}; - if( current ) + Packet* current{fragments}; + if(current) { - Packet* prev {nullptr}; - uint32_t lowest_seq {current->tcp->seq()}; - while( current ) + Packet* prev{nullptr}; + uint32_t lowest_seq{current->tcp->seq()}; + while(current) { - const uint32_t current_seq {current->tcp->seq()}; - const uint32_t current_len {current->dlen}; + const uint32_t current_seq{current->tcp->seq()}; + const uint32_t current_len{current->dlen}; - if( GT_SEQ(lowest_seq, current_seq) ) // lowest_seq > current_seq + if(GT_SEQ(lowest_seq, current_seq)) // lowest_seq > current_seq { lowest_seq = current_seq; } - if( LT_SEQ(current_seq, sequence) ) // current_seq < sequence + if(LT_SEQ(current_seq, sequence)) // current_seq < sequence { // this sequence number seems dated, but // check the end to make sure it has no more // info than we have already seen - uint32_t newseq {current_seq + current_len}; - if( GT_SEQ(newseq, sequence) ) + uint32_t newseq{current_seq + current_len}; + if(GT_SEQ(newseq, sequence)) { // this one has more than we have seen. let's get the // payload that we have not seen. This happens when // part of this frame has been retransmitted - uint32_t new_pos {sequence - current_seq}; + uint32_t new_pos{sequence - current_seq}; sequence += (current_len - new_pos); - if ( current->dlen > new_pos ) + if(current->dlen > new_pos) { current->data += new_pos; current->dlen -= new_pos; @@ -312,9 +311,9 @@ public: } // Remove the fragment from the list as the "new" part of it - // has been processed or its data has been seen already in + // has been processed or its data has been seen already in // another packet. - if( prev ) + if(prev) { prev->next = current->next; } @@ -328,11 +327,11 @@ public: return true; } - if( EQ_SEQ(current_seq, sequence) ) + if(EQ_SEQ(current_seq, sequence)) { // this fragment fits the stream sequence += current_len; - if( prev ) + if(prev) { prev->next = current->next; } @@ -346,11 +345,11 @@ public: return true; } - prev = current; + prev = current; current = current->next; - }// end while + } // end while - if( GT_SEQ(acknowledged, lowest_seq) ) // acknowledged > lowest_seq + if(GT_SEQ(acknowledged, lowest_seq)) // acknowledged > lowest_seq { //TRACE("acknowledged(%u) > lowest_seq(%u) seq:%u", acknowledged, lowest_seq, sequence); // There are frames missing in the capture stream that were seen @@ -365,9 +364,9 @@ public: } private: - StreamReader reader; // reader of acknowledged data stream - Packet* fragments; // list of not yet acked fragments - uint32_t sequence; + StreamReader reader; // reader of acknowledged data stream + Packet* fragments; // list of not yet acked fragments + uint32_t sequence; }; template <typename Writer> @@ -376,16 +375,17 @@ public: flows[0].reader.set_writer(this, w, max_rpc_hdr); flows[1].reader.set_writer(this, w, max_rpc_hdr); } - TCPSession(TCPSession&&) = delete; - TCPSession(const TCPSession&) = delete; + TCPSession(TCPSession&&) = delete; + TCPSession(const TCPSession&) = delete; TCPSession& operator=(const TCPSession&) = delete; void collect(PacketInfo& info) { - const uint32_t ack {info.tcp->ack()}; + const uint32_t ack{info.tcp->ack()}; //check whether this frame acks fragments that were already seen. - while( flows[1-info.direction].check_fragments(ack) ); + while(flows[1 - info.direction].check_fragments(ack)) + ; flows[info.direction].reassemble(info); } @@ -393,24 +393,21 @@ public: Flow flows[2]; }; -template -< +template < typename Reader, typename Writer, - typename Filtrator -> + typename Filtrator> class FiltrationProcessor { public: - explicit FiltrationProcessor(std::unique_ptr<Reader>& r, std::unique_ptr<Writer>& w) - : reader{std::move(r)} - , writer{std::move(w)} - , ipv4_tcp_sessions{writer.get()} - , ipv4_udp_sessions{writer.get()} - , ipv6_tcp_sessions{writer.get()} - , ipv6_udp_sessions{writer.get()} + : reader{std::move(r)} + , writer{std::move(w)} + , ipv4_tcp_sessions{writer.get()} + , ipv4_udp_sessions{writer.get()} + , ipv6_tcp_sessions{writer.get()} + , ipv6_udp_sessions{writer.get()} { // check datalink layer datalink = reader->datalink(); @@ -427,7 +424,7 @@ public: void run() { - bool done {reader->loop(this, callback)}; + bool done{reader->loop(this, callback)}; if(done) { throw controller::ProcessingDone("Filtration is done"); @@ -439,9 +436,9 @@ public: reader->break_loop(); } - static void callback(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char* packet) + static void callback(u_char* user, const struct pcap_pkthdr* pkthdr, const u_char* packet) { - PROF;// Calc how much time was spent in this func + PROF; // Calc how much time was spent in this func auto processor = reinterpret_cast<FiltrationProcessor*>(user); PacketInfo info(pkthdr, packet, processor->datalink); @@ -450,46 +447,47 @@ public: { if(pkthdr->caplen != pkthdr->len) { - LOGONCE("pcap packet was truncated by snaplen option this " - "packed won't correclty reassembled to TCP stream"); + LOGONCE( + "pcap packet was truncated by snaplen option this " + "packed won't correclty reassembled to TCP stream"); return; } - if(info.ipv4) // Ethernet:IPv4:TCP + if(info.ipv4) // Ethernet:IPv4:TCP { return processor->ipv4_tcp_sessions.collect_packet(info); } - else if(info.ipv6) // Ethernet:IPv6:TCP + else if(info.ipv6) // Ethernet:IPv6:TCP { return processor->ipv6_tcp_sessions.collect_packet(info); } } else if(info.udp) { - if(info.ipv4) // Ethernet:IPv4:UDP + if(info.ipv4) // Ethernet:IPv4:UDP { return processor->ipv4_udp_sessions.collect_packet(info); } - else if(info.ipv6) // Ethernet:IPv6:UDP + else if(info.ipv6) // Ethernet:IPv6:UDP { return processor->ipv6_udp_sessions.collect_packet(info); } } - LOGONCE("only following stack of protocol is supported: " - "Ethernet II:IPv4|IPv6(except additional fragments):TCP|UDP"); + LOGONCE( + "only following stack of protocol is supported: " + "Ethernet II:IPv4|IPv6(except additional fragments):TCP|UDP"); } private: - std::unique_ptr<Reader> reader; std::unique_ptr<Writer> writer; - SessionsHash< IPv4TCPMapper, TCPSession <Filtrator> , Writer > ipv4_tcp_sessions; - SessionsHash< IPv4UDPMapper, UDPSession < Writer > , Writer > ipv4_udp_sessions; + SessionsHash<IPv4TCPMapper, TCPSession<Filtrator>, Writer> ipv4_tcp_sessions; + SessionsHash<IPv4UDPMapper, UDPSession<Writer>, Writer> ipv4_udp_sessions; - SessionsHash< IPv6TCPMapper, TCPSession < Filtrator> , Writer > ipv6_tcp_sessions; - SessionsHash< IPv6UDPMapper, UDPSession < Writer > , Writer > ipv6_udp_sessions; + SessionsHash<IPv6TCPMapper, TCPSession<Filtrator>, Writer> ipv6_tcp_sessions; + SessionsHash<IPv6UDPMapper, UDPSession<Writer>, Writer> ipv6_udp_sessions; int datalink; }; @@ -497,5 +495,5 @@ private: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//FILTRATION_PROCESSOR_H +#endif // FILTRATION_PROCESSOR_H //------------------------------------------------------------------------------ diff --git a/src/filtration/filtratorimpl.h b/src/filtration/filtratorimpl.h index c25846a..74b5b4e 100644 --- a/src/filtration/filtratorimpl.h +++ b/src/filtration/filtratorimpl.h @@ -23,27 +23,30 @@ #ifndef IFILTRATOR_H #define IFILTRATOR_H //------------------------------------------------------------------------------ +#include "filtration/packet.h" +#include "utils/log.h" +//------------------------------------------------------------------------------ namespace NST { namespace filtration { - /*! * Filtering TCP stream strategy (implementation) * Implemented via CRTP - Curiously recurring template pattern, * (see http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) */ -template<typename Filtrator, typename Writer> +template <typename Filtrator, typename Writer> class FiltratorImpl { - size_t msg_len; //!< length of current message - size_t to_be_copied; //!< length of readable piece of message. Initially msg_len or 0 in case of unknown msg + size_t msg_len; //!< length of current message + size_t to_be_copied; //!< length of readable piece of message. Initially msg_len or 0 in case of unknown msg using Collection = typename Writer::Collection; //!< Type of collection - Collection collection;//!< storage for collection packet data + Collection collection; //!< storage for collection packet data - FiltratorImpl(FiltratorImpl&&) = delete; - FiltratorImpl(const FiltratorImpl&) = delete; + FiltratorImpl(FiltratorImpl&&) = delete; + FiltratorImpl(const FiltratorImpl&) = delete; FiltratorImpl& operator=(const FiltratorImpl&) = delete; + public: FiltratorImpl() { @@ -62,7 +65,7 @@ public: */ inline void reset() { - msg_len = 0; + msg_len = 0; to_be_copied = 0; collection.reset(); } @@ -73,25 +76,25 @@ public: */ inline bool inProgress(PacketInfo& info) { - Filtrator* filtrator = static_cast<Filtrator* >(this); + Filtrator* filtrator = static_cast<Filtrator*>(this); constexpr size_t callHeaderLen = Filtrator::lengthOfBaseHeader(); - if (msg_len || to_be_copied) + if(msg_len || to_be_copied) { return true; } - if (!collection) // collection isn't allocated + if(!collection) // collection isn't allocated { collection.allocate(); // allocate new collection from writer } const size_t data_size = collection.data_size(); - if (data_size + info.dlen > callHeaderLen) + if(data_size + info.dlen > callHeaderLen) { static uint8_t buffer[callHeaderLen]; const uint8_t* header = info.data; - if (data_size > 0) + if(data_size > 0) { // Coping happends only once per TCP-session memcpy(buffer, collection.data(), data_size); @@ -100,7 +103,7 @@ public: } // It is right header - if (filtrator->isRightHeader(header)) + if(filtrator->isRightHeader(header)) { return true; } @@ -121,10 +124,10 @@ public: */ inline void lost(const uint32_t n) // we are lost n bytes in sequence { - Filtrator* filtrator = static_cast<Filtrator* >(this); - if (msg_len != 0) + Filtrator* filtrator = static_cast<Filtrator*>(this); + if(msg_len != 0) { - if (to_be_copied == 0 && msg_len >= n) + if(to_be_copied == 0 && msg_len >= n) { TRACE("We are lost %u bytes of payload marked for discard", n); msg_len -= n; @@ -147,48 +150,48 @@ public: */ inline void push(PacketInfo& info) { - Filtrator* filtrator = static_cast<Filtrator* >(this); + Filtrator* filtrator = static_cast<Filtrator*>(this); assert(info.dlen != 0); - while (info.dlen) // loop over data in packet + while(info.dlen) // loop over data in packet { - if (msg_len) // we are on-stream and we are looking to some message + if(msg_len) // we are on-stream and we are looking to some message { - if (to_be_copied) + if(to_be_copied) { // hdr_len != 0, readout a part of header of current message - if (to_be_copied > info.dlen) // got new part of header (not the all!) + if(to_be_copied > info.dlen) // got new part of header (not the all!) { //TRACE("got new part of header (not the all!)"); collection.push(info, info.dlen); to_be_copied -= info.dlen; msg_len -= info.dlen; - info.dlen = 0; // return from while + info.dlen = 0; // return from while } else // hdr_len <= dlen, current message will be complete, also we have some additional data { //TRACE("current message will be complete, also we have some additional data"); collection.push(info, to_be_copied); - info.dlen -= to_be_copied; - info.data += to_be_copied; + info.dlen -= to_be_copied; + info.data += to_be_copied; msg_len -= to_be_copied; to_be_copied = 0; collection.skip_first(Filtrator::lengthOfFirstSkipedPart()); - collection.complete(info); // push complete message to queue + collection.complete(info); // push complete message to queue } } else { // message header is readout, discard the unused tail of message - if (msg_len >= info.dlen) // discard whole new packet + if(msg_len >= info.dlen) // discard whole new packet { //TRACE("discard whole new packet"); msg_len -= info.dlen; return; //info.dlen = 0; // return from while } - else // discard only a part of packet payload related to current message + else // discard only a part of packet payload related to current message { //TRACE("discard only a part of packet payload related to current message"); info.dlen -= msg_len; @@ -211,24 +214,24 @@ public: */ inline void find_message(PacketInfo& info) { - assert(msg_len == 0); // Message still undetected - Filtrator* filtrator = static_cast<Filtrator* >(this); + assert(msg_len == 0); // Message still undetected + Filtrator* filtrator = static_cast<Filtrator*>(this); - if (!filtrator->collect_header(info, collection)) + if(!filtrator->collect_header(info, collection)) { return; } - assert(collection); // collection must be initialized + assert(collection); // collection must be initialized - if (filtrator->find_and_read_message(info, collection)) + if(filtrator->find_and_read_message(info, collection)) { return; } - assert(msg_len == 0); // message is not found - assert(to_be_copied == 0); // header should be skipped - collection.reset(); // skip collected data + assert(msg_len == 0); // message is not found + assert(to_be_copied == 0); // header should be skipped + collection.reset(); // skip collected data //[ Optimization ] skip data of current packet at all info.dlen = 0; } @@ -244,7 +247,7 @@ protected: to_be_copied = value; } - inline void setWriterImpl(utils::NetworkSession* session_ptr, Writer* w, uint32_t ) + inline void setWriterImpl(utils::NetworkSession* session_ptr, Writer* w, uint32_t) { assert(w); collection.set(*w, session_ptr); @@ -252,15 +255,15 @@ protected: inline bool collect_header(PacketInfo& info, size_t callHeaderLen, size_t replyHeaderLen) { - if (collection && (collection.data_size() > 0)) // collection is allocated + if(collection && (collection.data_size() > 0)) // collection is allocated { assert(collection.capacity() >= callHeaderLen); - const size_t tocopy {callHeaderLen - collection.data_size()}; + const size_t tocopy{callHeaderLen - collection.data_size()}; assert(tocopy != 0); - if (info.dlen < tocopy) + if(info.dlen < tocopy) { collection.push(info, info.dlen); - info.data += info.dlen;// optimization + info.data += info.dlen; // optimization info.dlen = 0; return false; } @@ -273,8 +276,8 @@ protected: } else // collection is empty { - collection.allocate(); // allocate new collection from writer - if (info.dlen >= callHeaderLen) // is data enough to message validation? + collection.allocate(); // allocate new collection from writer + if(info.dlen >= callHeaderLen) // is data enough to message validation? { collection.push(info, callHeaderLen); // probability that message will be rejected / probability of valid message info.data += callHeaderLen; @@ -285,7 +288,7 @@ protected: collection.push(info, info.dlen); //info.data += info.dlen;// optimization size_t copied = info.dlen; - info.dlen = 0; + info.dlen = 0; return copied >= replyHeaderLen; } } @@ -294,27 +297,26 @@ protected: inline bool read_message(PacketInfo& info) { - assert(msg_len != 0); // message is found + assert(msg_len != 0); // message is found assert(msg_len >= collection.data_size()); assert(to_be_copied <= msg_len); - Filtrator* filtrator = static_cast<Filtrator* >(this); + Filtrator* filtrator = static_cast<Filtrator*>(this); - const size_t written {collection.data_size()}; + const size_t written{collection.data_size()}; msg_len -= written; // substract how written (if written) to_be_copied -= std::min(to_be_copied, written); - if (0 == to_be_copied) // Avoid infinity loop when "msg len" == "data size(collection) (max_header)" {msg_len >= hdr_len} - // Next find message call will finding next message + if(0 == to_be_copied) // Avoid infinity loop when "msg len" == "data size(collection) (max_header)" {msg_len >= hdr_len} + // Next find message call will finding next message { collection.skip_first(filtrator->lengthOfFirstSkipedPart()); collection.complete(info); } return true; } - }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//IFILTRATOR_H +#endif // IFILTRATOR_H //------------------------------------------------------------------------------ diff --git a/src/filtration/filtrators.h b/src/filtration/filtrators.h index 6589ed6..87edc8e 100644 --- a/src/filtration/filtrators.h +++ b/src/filtration/filtrators.h @@ -31,11 +31,10 @@ namespace NST { namespace filtration { - /*! * Composite filtrator which composites both CIFS&NFS */ -template<typename Writer> +template <typename Writer> class Filtrators { enum class FiltratorTypes @@ -45,17 +44,17 @@ class Filtrators CIFS }; - CIFSFiltrator<Writer> filtratorCIFS;//!< CIFS filtrator - RPCFiltrator<Writer> filtratorRPC;//!< RPC filtrator - FiltratorTypes currentFiltrator;//!< Indicates which filtrator is currently active? + CIFSFiltrator<Writer> filtratorCIFS; //!< CIFS filtrator + RPCFiltrator<Writer> filtratorRPC; //!< RPC filtrator + FiltratorTypes currentFiltrator; //!< Indicates which filtrator is currently active? public: - Filtrators() : - currentFiltrator(FiltratorTypes::DEFAULT) + Filtrators() + : currentFiltrator(FiltratorTypes::DEFAULT) { } - Filtrators(Filtrators&&) = delete; - Filtrators(const Filtrators&) = delete; + Filtrators(Filtrators&&) = delete; + Filtrators(const Filtrators&) = delete; Filtrators& operator=(const Filtrators&) = delete; /*! @@ -64,7 +63,7 @@ public: inline void reset() { filtratorCIFS.reset(); - filtratorRPC.reset (); + filtratorRPC.reset(); currentFiltrator = FiltratorTypes::DEFAULT; } @@ -77,14 +76,14 @@ public: inline void set_writer(utils::NetworkSession* session_ptr, Writer* w, uint32_t max_rpc_hdr) { assert(w); - filtratorCIFS.set_writer (session_ptr, w, max_rpc_hdr); - filtratorRPC.set_writer (session_ptr, w, max_rpc_hdr); + filtratorCIFS.set_writer(session_ptr, w, max_rpc_hdr); + filtratorRPC.set_writer(session_ptr, w, max_rpc_hdr); } inline void lost(const uint32_t n) // we are lost n bytes in sequence { - filtratorCIFS.lost (n); - filtratorRPC.lost (n); + filtratorCIFS.lost(n); + filtratorRPC.lost(n); } /*! @@ -94,16 +93,16 @@ public: inline void push(PacketInfo& info) { // is it RPC message? - if (currentFiltrator == FiltratorTypes::RPC || filtratorRPC.inProgress(info)) + if(currentFiltrator == FiltratorTypes::RPC || filtratorRPC.inProgress(info)) { currentFiltrator = FiltratorTypes::RPC; - filtratorRPC.push (info); + filtratorRPC.push(info); } // is it CIFS message? - else if (currentFiltrator == FiltratorTypes::CIFS || filtratorCIFS.inProgress(info)) + else if(currentFiltrator == FiltratorTypes::CIFS || filtratorCIFS.inProgress(info)) { currentFiltrator = FiltratorTypes::CIFS; - filtratorCIFS.push (info); + filtratorCIFS.push(info); } // it is Unknown message else @@ -116,5 +115,5 @@ public: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//FILTRATORS_H +#endif // FILTRATORS_H //------------------------------------------------------------------------------ diff --git a/src/filtration/packet.h b/src/filtration/packet.h index 008f582..4a1945e 100644 --- a/src/filtration/packet.h +++ b/src/filtration/packet.h @@ -22,9 +22,9 @@ #ifndef PACKET_H #define PACKET_H //------------------------------------------------------------------------------ -#include <algorithm> // for std::min() +#include <algorithm> // for std::min() #include <cassert> -#include <cstring> // for memcpy() +#include <cstring> // for memcpy() #include <pcap/pcap.h> @@ -38,7 +38,6 @@ namespace NST { namespace filtration { - using namespace NST::protocols; using namespace NST::protocols::ethernet; using namespace NST::protocols::ip; @@ -56,43 +55,48 @@ struct PacketInfo friend struct Packet; public: - Dumped() : flag{false}{}; + Dumped() + : flag{false} {}; Dumped(const Dumped& in) = delete; ~Dumped(){}; private: - inline operator bool() const { return flag; } + inline operator bool() const { return flag; } inline void operator=(const bool stat) { flag = stat; } - bool flag; + bool flag; }; inline PacketInfo(const pcap_pkthdr* h, - const uint8_t* p, - const uint32_t datalink) - : header {h} - , packet {p} - , eth {nullptr} - , ipv4 {nullptr} - , ipv6 {nullptr} - , tcp {nullptr} - , udp {nullptr} - , data {packet} - , dlen {header->caplen} - , direction{Direction::Unknown} - , dumped {} + const uint8_t* p, + const uint32_t datalink) + : header{h} + , packet{p} + , eth{nullptr} + , ipv4{nullptr} + , ipv6{nullptr} + , tcp{nullptr} + , udp{nullptr} + , data{packet} + , dlen{header->caplen} + , direction{Direction::Unknown} + , dumped{} { switch(datalink) { - case DLT_EN10MB: check_eth(); break; - case DLT_LINUX_SLL: check_sll(); break; + case DLT_EN10MB: + check_eth(); + break; + case DLT_LINUX_SLL: + check_sll(); + break; } } - PacketInfo(const PacketInfo&) = delete; + PacketInfo(const PacketInfo&) = delete; PacketInfo& operator=(const PacketInfo&) = delete; - void* operator new (size_t ) = delete; // only on stack - void* operator new[] (size_t ) = delete; // only on stack - void operator delete (void*) = delete; // only on stack - void operator delete[](void*) = delete; // only on stack + void* operator new(size_t) = delete; // only on stack + void* operator new[](size_t) = delete; // only on stack + void operator delete(void*) = delete; // only on stack + void operator delete[](void*) = delete; // only on stack inline void check_eth() { @@ -104,8 +108,12 @@ struct PacketInfo switch(header->type()) { - case ethernet_header::IP: check_ipv4(); break; - case ethernet_header::IPV6: check_ipv6(); break; + case ethernet_header::IP: + check_ipv4(); + break; + case ethernet_header::IPV6: + check_ipv6(); + break; default: return; } @@ -115,7 +123,7 @@ struct PacketInfo inline void check_sll() { - // TODO: add support Linux cooked sockets + // TODO: add support Linux cooked sockets } inline void check_ipv4() __attribute__((always_inline)) @@ -123,7 +131,7 @@ struct PacketInfo if(dlen < sizeof(IPv4Header)) return; auto header = reinterpret_cast<const IPv4Header*>(data); - if(header->version() != 4) return; + if(header->version() != 4) return; /* IP packet may be fragmented by NIC or snaplen parameter of libpcap @@ -139,16 +147,20 @@ struct PacketInfo } const uint32_t ihl = header->ihl(); - if(dlen < ihl) return; // truncated packet + if(dlen < ihl) return; // truncated packet if((header->length()) < ihl) return; // incorrect packet data += ihl; - dlen = (std::min((uint16_t)dlen, header->length())) - ihl; // trunk data to length of IP packet + dlen = (std::min((uint16_t)dlen, header->length())) - ihl; // trunk data to length of IP packet switch(header->protocol()) { - case ip::NextProtocol::TCP: check_tcp(); break; - case ip::NextProtocol::UDP: check_udp(); break; + case ip::NextProtocol::TCP: + check_tcp(); + break; + case ip::NextProtocol::UDP: + check_udp(); + break; default: return; } @@ -161,27 +173,31 @@ struct PacketInfo if(dlen < sizeof(IPv6Header)) return; auto header = reinterpret_cast<const IPv6Header*>(data); - if(header->version() != 6) return; + if(header->version() != 6) return; data += sizeof(IPv6Header); dlen -= sizeof(IPv6Header); const uint32_t payload = header->payload_len(); - if(payload == 0) return; // The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option + if(payload == 0) return; // The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option if(dlen < payload) return; // truncated packet dlen = payload; // skip padding at the end // handling optional headers uint8_t htype = header->nexthdr(); - switch_type: // TODO: remove ugly goto + switch_type: // TODO: remove ugly goto switch(htype) { - case ip::NextProtocol::TCP: check_tcp(); break; - case ip::NextProtocol::UDP: check_udp(); break; + case ip::NextProtocol::TCP: + check_tcp(); + break; + case ip::NextProtocol::UDP: + check_udp(); + break; case ip::NextProtocol::HOPOPTS: { - auto hbh = reinterpret_cast<const ipv6_hbh*>(data); + auto hbh = reinterpret_cast<const ipv6_hbh*>(data); const unsigned int size{1U + hbh->hbh_len}; if(dlen < size) return; // truncated packet @@ -195,7 +211,7 @@ struct PacketInfo case ip::NextProtocol::DSTOPTS: { - auto dest = reinterpret_cast<const ipv6_dest*>(data); + auto dest = reinterpret_cast<const ipv6_dest*>(data); const unsigned int size{1U + dest->dest_len}; if(dlen < size) return; // truncated packet @@ -209,7 +225,7 @@ struct PacketInfo case ip::NextProtocol::ROUTING: { - auto route = reinterpret_cast<const ipv6_route*>(data); + auto route = reinterpret_cast<const ipv6_route*>(data); const unsigned int size{1U + route->route_len}; if(dlen < size) return; // truncated packet @@ -239,7 +255,7 @@ struct PacketInfo goto switch_type; } case ip::NextProtocol::NONE: - default: // unknown header + default: // unknown header return; } @@ -248,10 +264,10 @@ struct PacketInfo inline void check_tcp() __attribute__((always_inline)) { - if(dlen < sizeof(TCPHeader)) return; // truncated TCP header + if(dlen < sizeof(TCPHeader)) return; // truncated TCP header auto header = reinterpret_cast<const TCPHeader*>(data); - uint8_t offset {header->offset()}; + uint8_t offset{header->offset()}; if(offset < 20 || offset > 60) return; // invalid length of TCP header if(dlen < offset) return; // truncated packet @@ -268,8 +284,8 @@ struct PacketInfo inline void check_udp() __attribute__((always_inline)) { - if(dlen < sizeof(UDPHeader)) return; // fragmented UDP header - const UDPHeader* header {reinterpret_cast<const UDPHeader*>(data)}; + if(dlen < sizeof(UDPHeader)) return; // fragmented UDP header + const UDPHeader* header{reinterpret_cast<const UDPHeader*>(data)}; data += sizeof(UDPHeader); dlen -= sizeof(UDPHeader); @@ -278,8 +294,8 @@ struct PacketInfo } // libpcap structures - const pcap_pkthdr* header; - const uint8_t* packet; // real length is in header->caplen + const pcap_pkthdr* header; + const uint8_t* packet; // real length is in header->caplen // all pointers point to packet array @@ -289,33 +305,33 @@ struct PacketInfo // Internet Layer // IP version 4 - const ip::IPv4Header* ipv4; + const ip::IPv4Header* ipv4; // IP version 6 - const ip::IPv6Header* ipv6; + const ip::IPv6Header* ipv6; // Transport Layer // TCP - const tcp::TCPHeader* tcp; + const tcp::TCPHeader* tcp; // UDP - const udp::UDPHeader* udp; + const udp::UDPHeader* udp; - const uint8_t* data; // pointer to packet data - uint32_t dlen; // length of packet data + const uint8_t* data; // pointer to packet data + uint32_t dlen; // length of packet data // Packet transmission direction, set after match packet to session - Direction direction; + Direction direction; - mutable Dumped dumped; // flag for dumped packet + mutable Dumped dumped; // flag for dumped packet }; // PCAP packet in dynamic allocated memory -struct Packet: public PacketInfo +struct Packet : public PacketInfo { - Packet() = delete; - Packet(const Packet&) = delete; + Packet() = delete; + Packet(const Packet&) = delete; Packet& operator=(const Packet&) = delete; - Packet* next; // pointer to next packet or nullptr + Packet* next; // pointer to next packet or nullptr static Packet* create(const PacketInfo& info, Packet* next) { @@ -323,11 +339,11 @@ struct Packet: public PacketInfo // allocate memory for Packet structure and PCAP packet data // TODO: performance drop! improve data alignment! - uint8_t* memory { new uint8_t[sizeof(Packet) + sizeof(pcap_pkthdr) + info.header->caplen]}; + uint8_t* memory{new uint8_t[sizeof(Packet) + sizeof(pcap_pkthdr) + info.header->caplen]}; - Packet* fragment { (Packet*) ((uint8_t*)memory )}; - pcap_pkthdr* header{ (pcap_pkthdr*) ((uint8_t*)memory + sizeof(Packet) )}; - uint8_t* packet { (uint8_t*) ((uint8_t*)memory + sizeof(Packet) + sizeof(pcap_pkthdr))}; + Packet* fragment{(Packet*)((uint8_t*)memory)}; + pcap_pkthdr* header{(pcap_pkthdr*)((uint8_t*)memory + sizeof(Packet))}; + uint8_t* packet{(uint8_t*)((uint8_t*)memory + sizeof(Packet) + sizeof(pcap_pkthdr))}; // copy data *header = *info.header; // copy packet header @@ -337,11 +353,11 @@ struct Packet: public PacketInfo fragment->packet = packet; // fix pointers from PacketInfo to point to owned copy of packet data - fragment->eth = info.eth ? (const ethernet::EthernetHeader*) (packet + ( ((const uint8_t*)info.eth ) - info.packet)) : nullptr; - fragment->ipv4 = info.ipv4 ? (const ip::IPv4Header*) (packet + ( ((const uint8_t*)info.ipv4) - info.packet)) : nullptr; - fragment->ipv6 = info.ipv6 ? (const ip::IPv6Header*) (packet + ( ((const uint8_t*)info.ipv6) - info.packet)) : nullptr; - fragment->tcp = info.tcp ? (const tcp::TCPHeader*) (packet + ( ((const uint8_t*)info.tcp ) - info.packet)) : nullptr; - fragment->udp = info.udp ? (const udp::UDPHeader*) (packet + ( ((const uint8_t*)info.udp ) - info.packet)) : nullptr; + fragment->eth = info.eth ? (const ethernet::EthernetHeader*)(packet + (((const uint8_t*)info.eth) - info.packet)) : nullptr; + fragment->ipv4 = info.ipv4 ? (const ip::IPv4Header*)(packet + (((const uint8_t*)info.ipv4) - info.packet)) : nullptr; + fragment->ipv6 = info.ipv6 ? (const ip::IPv6Header*)(packet + (((const uint8_t*)info.ipv6) - info.packet)) : nullptr; + fragment->tcp = info.tcp ? (const tcp::TCPHeader*)(packet + (((const uint8_t*)info.tcp) - info.packet)) : nullptr; + fragment->udp = info.udp ? (const udp::UDPHeader*)(packet + (((const uint8_t*)info.udp) - info.packet)) : nullptr; fragment->data = packet + (info.data - info.packet); fragment->dlen = info.dlen; @@ -355,7 +371,7 @@ struct Packet: public PacketInfo static void destroy(Packet* fragment) { - uint8_t* ptr { (uint8_t*)fragment }; + uint8_t* ptr{(uint8_t*)fragment}; delete[] ptr; } }; @@ -363,5 +379,5 @@ struct Packet: public PacketInfo } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//PACKET_H +#endif // PACKET_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/base_reader.h b/src/filtration/pcap/base_reader.h index 17f0c81..382e81e 100644 --- a/src/filtration/pcap/base_reader.h +++ b/src/filtration/pcap/base_reader.h @@ -35,15 +35,17 @@ namespace filtration { namespace pcap { - -inline const char* library_version() { return pcap_lib_version(); } +inline const char* library_version() +{ + return pcap_lib_version(); +} class BaseReader { protected: BaseReader(const std::string& input) - : handle{nullptr} - , source{input} + : handle{nullptr} + , source{input} { } @@ -56,25 +58,23 @@ protected: } public: - bool loop(void* user, pcap_handler callback, int count=0) + bool loop(void* user, pcap_handler callback, int count = 0) { - const int err {pcap_loop(handle, count, callback, (u_char*)user)}; + const int err{pcap_loop(handle, count, callback, (u_char*)user)}; if(err == -1) throw PcapError("pcap_loop", pcap_geterr(handle)); return err == 0; // count is exhausted } - inline void break_loop() { pcap_breakloop(handle); } - inline pcap_t*& get_handle() { return handle; } - - inline int datalink () const { return pcap_datalink(handle); } - inline static const char* datalink_name (const int dlt) { return pcap_datalink_val_to_name(dlt); } - inline static const char* datalink_description (const int dlt) { return pcap_datalink_val_to_description(dlt); } - + inline void break_loop() { pcap_breakloop(handle); } + inline pcap_t*& get_handle() { return handle; } + inline int datalink() const { return pcap_datalink(handle); } + inline static const char* datalink_name(const int dlt) { return pcap_datalink_val_to_name(dlt); } + inline static const char* datalink_description(const int dlt) { return pcap_datalink_val_to_description(dlt); } virtual void print_statistic(std::ostream& out) const = 0; protected: - pcap_t* handle; + pcap_t* handle; const std::string source; }; @@ -82,5 +82,5 @@ protected: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//BASE_READER_H +#endif // BASE_READER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/bpf.h b/src/filtration/pcap/bpf.h index b9c73d3..8537b18 100644 --- a/src/filtration/pcap/bpf.h +++ b/src/filtration/pcap/bpf.h @@ -19,8 +19,8 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#ifndef BPF_H -#define BPF_H +#ifndef BPF_HEADER_H +#define BPF_HEADER_H //------------------------------------------------------------------------------ #include <pcap/pcap.h> @@ -32,7 +32,6 @@ namespace filtration { namespace pcap { - class BPF { public: @@ -43,7 +42,7 @@ public: throw PcapError("pcap_compile", pcap_geterr(handle)); } } - BPF(const BPF&) = delete; + BPF(const BPF&) = delete; BPF& operator=(const BPF&) = delete; ~BPF() { @@ -51,7 +50,6 @@ public: } inline operator bpf_program*() { return &bpf; } - private: bpf_program bpf; }; @@ -60,5 +58,5 @@ private: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//BPF_H +#endif // BPF_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/capture_reader.cpp b/src/filtration/pcap/capture_reader.cpp index bc08e2f..c559634 100644 --- a/src/filtration/pcap/capture_reader.cpp +++ b/src/filtration/pcap/capture_reader.cpp @@ -19,8 +19,8 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#include "filtration/pcap/bpf.h" #include "filtration/pcap/capture_reader.h" +#include "filtration/pcap/bpf.h" #include "filtration/pcap/pcap_error.h" //------------------------------------------------------------------------------ namespace NST @@ -29,51 +29,57 @@ namespace filtration { namespace pcap { - -CaptureReader::CaptureReader(const Params& params) : BaseReader{params.interface} +CaptureReader::CaptureReader(const Params& params) + : BaseReader{params.interface} { - char errbuf[PCAP_ERRBUF_SIZE]; // storage of error description - const char* device {source.c_str()}; + char errbuf[PCAP_ERRBUF_SIZE]; // storage of error description + const char* device{source.c_str()}; handle = pcap_create(device, errbuf); if(!handle) { throw PcapError("pcap_create", errbuf); } - if(int status {pcap_set_snaplen(handle, params.snaplen)}) + if(int status{pcap_set_snaplen(handle, params.snaplen)}) { throw PcapError("pcap_set_snaplen", pcap_statustostr(status)); } - if(int status {pcap_set_promisc(handle, params.promisc ? 1 : 0)}) + if(int status{pcap_set_promisc(handle, params.promisc ? 1 : 0)}) { throw PcapError("pcap_set_promisc", pcap_statustostr(status)); } - if(int status {pcap_set_timeout(handle, params.timeout_ms)}) + if(int status{pcap_set_timeout(handle, params.timeout_ms)}) { throw PcapError("pcap_set_timeout", pcap_statustostr(status)); } - if(int status {pcap_set_buffer_size(handle, params.buffer_size)}) + if(int status{pcap_set_buffer_size(handle, params.buffer_size)}) { throw PcapError("pcap_set_buffer_size", pcap_statustostr(status)); } - if(int status {pcap_activate(handle)}) + if(int status{pcap_activate(handle)}) { throw PcapError("pcap_activate", pcap_statustostr(status)); } - pcap_direction_t direction {PCAP_D_INOUT}; + pcap_direction_t direction{PCAP_D_INOUT}; switch(params.direction) { using Direction = CaptureReader::Direction; - case Direction::IN : direction = PCAP_D_IN; break; - case Direction::OUT : direction = PCAP_D_OUT; break; - case Direction::INOUT: direction = PCAP_D_INOUT; break; + case Direction::IN: + direction = PCAP_D_IN; + break; + case Direction::OUT: + direction = PCAP_D_OUT; + break; + case Direction::INOUT: + direction = PCAP_D_INOUT; + break; } - if(int status {pcap_setdirection(handle, direction)}) + if(int status{pcap_setdirection(handle, direction)}) { throw PcapError("pcap_setdirection", pcap_statustostr(status)); } @@ -94,7 +100,7 @@ CaptureReader::CaptureReader(const Params& params) : BaseReader{params.interface void CaptureReader::print_statistic(std::ostream& out) const { - struct pcap_stat stat={0,0,0}; + struct pcap_stat stat = {0, 0, 0}; if(pcap_stats(handle, &stat) == 0) { out << "Statistics from interface: " << source << '\n' @@ -117,13 +123,19 @@ std::ostream& operator<<(std::ostream& out, const CaptureReader::Params& params) << " buffer size : " << params.buffer_size << " bytes\n" << " promiscuous mode: " << (params.promisc ? "on" : "off") << '\n' << " capture traffic : "; - switch(params.direction) - { - using Direction = CaptureReader::Direction; - case Direction::IN : out << "in"; break; - case Direction::OUT : out << "out"; break; - case Direction::INOUT: out << "inout"; break; - } + switch(params.direction) + { + using Direction = CaptureReader::Direction; + case Direction::IN: + out << "in"; + break; + case Direction::OUT: + out << "out"; + break; + case Direction::INOUT: + out << "inout"; + break; + } return out; } diff --git a/src/filtration/pcap/capture_reader.h b/src/filtration/pcap/capture_reader.h index 6d24858..9e81272 100644 --- a/src/filtration/pcap/capture_reader.h +++ b/src/filtration/pcap/capture_reader.h @@ -32,7 +32,6 @@ namespace filtration { namespace pcap { - class CaptureReader : public BaseReader { public: @@ -45,20 +44,19 @@ public: struct Params { - std::string interface { }; - std::string filter { }; - int snaplen {0}; - int timeout_ms {0}; + std::string interface{}; + std::string filter{}; + int snaplen{0}; + int timeout_ms{0}; int buffer_size{0}; - bool promisc {true}; - Direction direction {Direction::INOUT}; + bool promisc{true}; + Direction direction{Direction::INOUT}; }; CaptureReader(const Params& params); ~CaptureReader() = default; void print_statistic(std::ostream& out) const override; - }; std::ostream& operator<<(std::ostream&, const CaptureReader::Params&); @@ -67,5 +65,5 @@ std::ostream& operator<<(std::ostream&, const CaptureReader::Params&); } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//CAPTURE_READER_H +#endif // CAPTURE_READER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/file_reader.cpp b/src/filtration/pcap/file_reader.cpp index ce78947..aeb0d3e 100644 --- a/src/filtration/pcap/file_reader.cpp +++ b/src/filtration/pcap/file_reader.cpp @@ -28,8 +28,8 @@ namespace filtration { namespace pcap { - -FileReader::FileReader(const std::string& file) : BaseReader{file} +FileReader::FileReader(const std::string& file) + : BaseReader{file} { char errbuf[PCAP_ERRBUF_SIZE]; @@ -44,7 +44,7 @@ FileReader::FileReader(const std::string& file) : BaseReader{file} std::ostream& operator<<(std::ostream& out, FileReader& f) { out << "Read packets from: " << f.source << '\n'; - const int dlt {f.datalink()}; + const int dlt{f.datalink()}; out << " datalink: " << f.datalink_name(dlt) << " (" << f.datalink_description(dlt) << ")\n"; out << " version: " << f.major_version() << '.' << f.minor_version(); if(f.is_swapped()) out << "\n Note: file has data in swapped byte-order"; diff --git a/src/filtration/pcap/file_reader.h b/src/filtration/pcap/file_reader.h index d8c8538..c46bd8b 100644 --- a/src/filtration/pcap/file_reader.h +++ b/src/filtration/pcap/file_reader.h @@ -32,21 +32,17 @@ namespace filtration { namespace pcap { - class FileReader : public BaseReader { public: explicit FileReader(const std::string& file); ~FileReader() = default; - inline FILE* get_file() { return pcap_file(handle); } - - void print_statistic(std::ostream& /*out*/) const override { /*dummy method*/ } - - inline int major_version() { return pcap_major_version(handle); } - inline int minor_version() { return pcap_minor_version(handle); } - inline bool is_swapped() { return pcap_is_swapped(handle); } - + inline FILE* get_file() { return pcap_file(handle); } + void print_statistic(std::ostream& /*out*/) const override {} + inline int major_version() { return pcap_major_version(handle); } + inline int minor_version() { return pcap_minor_version(handle); } + inline bool is_swapped() { return pcap_is_swapped(handle); } friend std::ostream& operator<<(std::ostream& out, FileReader& f); }; @@ -54,5 +50,5 @@ public: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//FILE_READER_H +#endif // FILE_READER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/network_interfaces.h b/src/filtration/pcap/network_interfaces.h index 2d9335d..854898b 100644 --- a/src/filtration/pcap/network_interfaces.h +++ b/src/filtration/pcap/network_interfaces.h @@ -22,9 +22,9 @@ #ifndef NETWORK_INTERFACES_H #define NETWORK_INTERFACES_H //------------------------------------------------------------------------------ -#include <pcap/pcap.h> #include <arpa/inet.h> #include <netinet/in.h> +#include <pcap/pcap.h> #include <sys/socket.h> #include "filtration/pcap/pcap_error.h" @@ -35,7 +35,6 @@ namespace filtration { namespace pcap { - class NetworkInterfaces { public: @@ -43,59 +42,68 @@ public: class Address { friend class Interface; + public: - inline sockaddr* address() const noexcept { return addr->addr; } - inline sockaddr* netmask() const noexcept { return addr->netmask; } + inline sockaddr* address() const noexcept { return addr->addr; } + inline sockaddr* netmask() const noexcept { return addr->netmask; } inline sockaddr* broadaddr() const noexcept { return addr->broadaddr; } - inline sockaddr* destaddr() const noexcept { return addr->dstaddr; } - - Address& operator= (const Address&) = delete; - void operator& () = delete; - void* operator new (size_t) = delete; - void operator delete (void*) = delete; - - inline operator bool() const noexcept { return addr != nullptr; } - inline void operator ++() noexcept { addr = addr->next; } - inline bool operator !=(const Address& a) const noexcept { return addr != a.addr; } + inline sockaddr* destaddr() const noexcept { return addr->dstaddr; } + Address& operator=(const Address&) = delete; + void operator&() = delete; + void* operator new(size_t) = delete; + void operator delete(void*) = delete; + + inline operator bool() const noexcept { return addr != nullptr; } + inline void operator++() noexcept { addr = addr->next; } + inline bool operator!=(const Address& a) const noexcept { return addr != a.addr; } inline const Address operator*() const noexcept { return *this; } + Address(const Address& a) + : addr{a.addr} + { + } - Address(const Address& a) : addr{a.addr}{} - private: - Address(pcap_addr_t* a) : addr{a}{} + Address(pcap_addr_t* a) + : addr{a} + { + } pcap_addr_t* addr; }; class Interface { friend class NetworkInterfaces; - public: - inline const char* name() const noexcept { return ptr->name; } - inline const char* dscr() const noexcept { return ptr->description; } - inline bool is_loopback() const noexcept { return ptr->flags & PCAP_IF_LOOPBACK; } - - Interface& operator= (const Interface&) = delete; - void operator& () = delete; - void* operator new (size_t) = delete; - void operator delete (void*) = delete; - - inline operator bool() const noexcept { return ptr != nullptr; } - inline void operator ++() noexcept { ptr = ptr->next; } - inline bool operator !=(const Interface& i) const noexcept { return ptr != i.ptr; } + public: + inline const char* name() const noexcept { return ptr->name; } + inline const char* dscr() const noexcept { return ptr->description; } + inline bool is_loopback() const noexcept { return ptr->flags & PCAP_IF_LOOPBACK; } + Interface& operator=(const Interface&) = delete; + void operator&() = delete; + void* operator new(size_t) = delete; + void operator delete(void*) = delete; + + inline operator bool() const noexcept { return ptr != nullptr; } + inline void operator++() noexcept { ptr = ptr->next; } + inline bool operator!=(const Interface& i) const noexcept { return ptr != i.ptr; } inline const Interface operator*() const noexcept { return *this; } - - Interface(const Interface& i) : ptr{i.ptr}{} + Interface(const Interface& i) + : ptr{i.ptr} + { + } const Address begin() const noexcept { return Address{ptr->addresses}; } - const Address end() const noexcept { return Address{nullptr}; } - + const Address end() const noexcept { return Address{nullptr}; } private: - Interface(pcap_if_t* p) : ptr{p}{} + Interface(pcap_if_t* p) + : ptr{p} + { + } pcap_if_t* ptr; }; - inline NetworkInterfaces() : interfaces{nullptr} + inline NetworkInterfaces() + : interfaces{nullptr} { char errbuf[PCAP_ERRBUF_SIZE]; if(pcap_findalldevs(&interfaces, errbuf) == -1) @@ -128,24 +136,23 @@ public: throw std::runtime_error{"No suitable device found.\n Note: reading an ip address of a network device may require special privileges."}; } - NetworkInterfaces(const NetworkInterfaces&) = delete; + NetworkInterfaces(const NetworkInterfaces&) = delete; NetworkInterfaces& operator=(const NetworkInterfaces&) = delete; - void operator& () = delete; - void* operator new (size_t) = delete; - void operator delete (void*) = delete; + void operator&() = delete; + void* operator new(size_t) = delete; + void operator delete(void*) = delete; const Interface begin() const noexcept { return Interface{interfaces}; } - const Interface end() const noexcept { return Interface{nullptr}; } - + const Interface end() const noexcept { return Interface{nullptr}; } private: pcap_if_t* interfaces; }; -std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Interface& i) +std::ostream& operator<<(std::ostream& out, const NetworkInterfaces::Interface& i) { out.width(8); out << std::left << i.name(); - const char* dscr {i.dscr()}; + const char* dscr{i.dscr()}; if(dscr) { out << '(' << dscr << ')'; @@ -157,10 +164,10 @@ std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Interface& return out; } -std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Address& a) +std::ostream& operator<<(std::ostream& out, const NetworkInterfaces::Address& a) { - sockaddr* s_address {a.address()}; - sockaddr* s_netmask {a.netmask()}; + sockaddr* s_address{a.address()}; + sockaddr* s_netmask{a.netmask()}; if(s_address) { switch(s_address->sa_family) @@ -181,7 +188,7 @@ std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Address& a sizeof(netmask)); out << " netmask " << netmask; - sockaddr* s_broadaddr {a.broadaddr()}; + sockaddr* s_broadaddr{a.broadaddr()}; if(s_broadaddr) { char broadaddr[INET_ADDRSTRLEN]{}; @@ -192,7 +199,7 @@ std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Address& a out << " broadcast " << broadaddr; } - sockaddr* s_destaddr {a.destaddr()}; + sockaddr* s_destaddr{a.destaddr()}; if(s_destaddr) { char destaddr[INET_ADDRSTRLEN]{}; @@ -238,5 +245,5 @@ std::ostream& operator <<(std::ostream& out, const NetworkInterfaces::Address& a } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//NETWORK_INTERFACES_H +#endif // NETWORK_INTERFACES_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/packet_dumper.h b/src/filtration/pcap/packet_dumper.h index 41f6a2a..aa97cec 100644 --- a/src/filtration/pcap/packet_dumper.h +++ b/src/filtration/pcap/packet_dumper.h @@ -32,38 +32,36 @@ namespace filtration { namespace pcap { - class PacketDumper { public: PacketDumper(pcap_t* handle, const char* path) - : dumper{ pcap_dump_open(handle, path) } + : dumper{pcap_dump_open(handle, path)} { if(dumper == nullptr) { throw PcapError{"pcap_dump_open", pcap_geterr(handle)}; } } - PacketDumper(const PacketDumper&) = delete; + PacketDumper(const PacketDumper&) = delete; PacketDumper& operator=(const PacketDumper&) = delete; ~PacketDumper() { pcap_dump_close(dumper); } - inline void dump(const pcap_pkthdr *h, const u_char *sp) + inline void dump(const pcap_pkthdr* h, const u_char* sp) { pcap_dump((u_char*)dumper, h, sp); } - inline void flush() { pcap_dump_flush(dumper); } + inline void flush() { pcap_dump_flush(dumper); } inline pcap_dumper_t* get_dumper() { return dumper; } inline FILE* get_stream() { return pcap_dump_file(dumper); } - - void truncate_all_pcap_data_and_header() + void truncate_all_pcap_data_and_header() { pcap_dump_flush(dumper); - FILE* stream {pcap_dump_file(dumper)}; + FILE* stream{pcap_dump_file(dumper)}; rewind(stream); // truncate a file to zero pcap_dump_flush(dumper); } @@ -76,5 +74,5 @@ private: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//PACKET_DUMPER_H +#endif // PACKET_DUMPER_H //------------------------------------------------------------------------------ diff --git a/src/filtration/pcap/pcap_error.h b/src/filtration/pcap/pcap_error.h index c7b2be3..8a4d2e0 100644 --- a/src/filtration/pcap/pcap_error.h +++ b/src/filtration/pcap/pcap_error.h @@ -31,17 +31,18 @@ namespace filtration { namespace pcap { - class PcapError : public std::runtime_error { public: explicit PcapError(const char* func, const char* errbuf) - : std::runtime_error{std::string{func}+"():"+std::string{errbuf}} { } + : std::runtime_error{std::string{func} + "():" + std::string{errbuf}} + { + } }; } // namespace pcap } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//PCAP_ERROR_H +#endif // PCAP_ERROR_H //------------------------------------------------------------------------------ diff --git a/src/filtration/processing_thread.h b/src/filtration/processing_thread.h index 89a46c9..334369a 100644 --- a/src/filtration/processing_thread.h +++ b/src/filtration/processing_thread.h @@ -30,15 +30,15 @@ namespace NST { namespace filtration { - class ProcessingThread { protected: ProcessingThread(NST::controller::RunningStatus& s) - : status (s) - , processing {} + : status(s) + , processing{} { } + public: virtual ~ProcessingThread() { @@ -50,12 +50,12 @@ public: void start() { - if(processing.joinable()) return; // already started + if(processing.joinable()) return; // already started processing = std::thread(&ProcessingThread::thread, this); } - virtual void stop()= 0; + virtual void stop() = 0; private: virtual void run() = 0; @@ -64,7 +64,7 @@ private: { try { - this->run(); // virtual call + this->run(); // virtual call } catch(...) { @@ -74,11 +74,11 @@ private: protected: NST::controller::RunningStatus& status; - std::thread processing; + std::thread processing; }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//PROCESSING_THREAD_H +#endif // PROCESSING_THREAD_H //------------------------------------------------------------------------------ diff --git a/src/filtration/queuing.h b/src/filtration/queuing.h index b4c5122..4e84c2c 100644 --- a/src/filtration/queuing.h +++ b/src/filtration/queuing.h @@ -32,27 +32,25 @@ namespace NST { namespace filtration { - class Queueing { using Queue = NST::utils::FilteredDataQueue; using Data = NST::utils::FilteredData; public: - class Collection { public: inline Collection() noexcept - : queue {nullptr} - , ptr {nullptr} - , session {nullptr} + : queue{nullptr} + , ptr{nullptr} + , session{nullptr} { } inline Collection(Queueing* q, utils::NetworkSession* s) noexcept - : queue {&q->queue} - , ptr {nullptr} - , session {s} + : queue{&q->queue} + , ptr{nullptr} + , session{s} { } inline ~Collection() @@ -62,13 +60,13 @@ public: queue->deallocate(ptr); } } - Collection(Collection&&) = delete; - Collection(const Collection&) = delete; + Collection(Collection&&) = delete; + Collection(const Collection&) = delete; Collection& operator=(const Collection&) = delete; inline void set(Queueing& q, utils::NetworkSession* s) { - queue = &q.queue; + queue = &q.queue; session = s; } @@ -78,7 +76,7 @@ public: { // we have a reference to queue, just do allocate and reset ptr = queue->allocate(); - if (!ptr) + if(!ptr) { LOG("free elements of the Queue are exhausted"); } @@ -114,11 +112,11 @@ public: { assert(nullptr != ptr); - uint8_t* offset_ptr { ptr->data + ptr->dlen }; - const uint32_t avail { ptr->capacity() - ptr->dlen}; + uint8_t* offset_ptr{ptr->data + ptr->dlen}; + const uint32_t avail{ptr->capacity() - ptr->dlen}; if(len > avail) // inappropriate case. Must be one resize when get entire message size { - ptr->resize(ptr->dlen + len); // [! unbound extension !] + ptr->resize(ptr->dlen + len); // [! unbound extension !] offset_ptr = ptr->data + ptr->dlen; // update pointer } memcpy(offset_ptr, info.data, len); @@ -148,26 +146,25 @@ public: ptr = nullptr; } - inline uint32_t data_size() const { return ptr->dlen; } - inline uint32_t capacity() const { return ptr->capacity(); } - inline const uint8_t* data() const { return ptr->data; } - inline operator bool() const { return ptr != nullptr; } - + inline uint32_t data_size() const { return ptr->dlen; } + inline uint32_t capacity() const { return ptr->capacity(); } + inline const uint8_t* data() const { return ptr->data; } + inline operator bool() const { return ptr != nullptr; } private: - Queue* queue; - Data* ptr; + Queue* queue; + Data* ptr; utils::NetworkSession* session; }; Queueing(Queue& q) - : queue(q) + : queue(q) { } ~Queueing() { } - Queueing(Queueing&&) = delete; - Queueing(const Queueing&) = delete; + Queueing(Queueing&&) = delete; + Queueing(const Queueing&) = delete; Queueing& operator=(const Queueing&) = delete; private: @@ -177,5 +174,5 @@ private: } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//QUEUING_H +#endif // QUEUING_H //------------------------------------------------------------------------------ diff --git a/src/filtration/rpc_filtrator.h b/src/filtration/rpc_filtrator.h index fc20025..e65fccd 100644 --- a/src/filtration/rpc_filtrator.h +++ b/src/filtration/rpc_filtrator.h @@ -27,11 +27,10 @@ #include <pcap/pcap.h> -#include "filtration/packet.h" #include "filtration/filtratorimpl.h" +#include "protocols/netbios/netbios.h" #include "protocols/nfs3/nfs3_utils.h" #include "protocols/nfs4/nfs4_utils.h" -#include "protocols/netbios/netbios.h" #include "protocols/rpc/rpc_header.h" #include "utils/log.h" //------------------------------------------------------------------------------ @@ -39,17 +38,17 @@ namespace NST { namespace filtration { - /* Stateful reader of Sun RPC messages Reads data from PacketInfo passed via push() method aggregates length of current RPC message and length of RPC message useful for analysis TODO: add matching Calls and replies by XID of message */ -template<typename Writer> +template <typename Writer> class RPCFiltrator : public FiltratorImpl<RPCFiltrator<Writer>, Writer> { using BaseImpl = FiltratorImpl<RPCFiltrator<Writer>, Writer>; + public: RPCFiltrator() : BaseImpl() @@ -65,7 +64,7 @@ public: constexpr static size_t lengthOfBaseHeader() { - return sizeof(RecordMark) + sizeof(ReplyHeader);// Minimum of replay&call headers + return sizeof(RecordMark) + sizeof(ReplyHeader); // Minimum of replay&call headers } constexpr static size_t lengthOfReplyHeader() @@ -80,13 +79,13 @@ public: inline static bool isRightHeader(const uint8_t* header) { - const RecordMark* rm {reinterpret_cast<const RecordMark*>(header)}; + const RecordMark* rm{reinterpret_cast<const RecordMark*>(header)}; const MessageHeader* const msg = rm->fragment(); - if (msg->type() == MsgType::REPLY) + if(msg->type() == MsgType::REPLY) { return RPCValidator::check(static_cast<const ReplyHeader* const>(msg)); } - if (msg->type() == MsgType::CALL) + if(msg->type() == MsgType::CALL) { return RPCValidator::check(static_cast<const CallHeader* const>(msg)); } @@ -105,15 +104,15 @@ public: inline bool find_and_read_message(PacketInfo& info, typename Writer::Collection& collection) { - const RecordMark* rm {reinterpret_cast<const RecordMark*>(collection.data())}; + const RecordMark* rm{reinterpret_cast<const RecordMark*>(collection.data())}; //if(rm->is_last()); // TODO: handle sequence field of record mark - if (collection.data_size() < (sizeof(CallHeader) + sizeof(RecordMark)) && (rm->fragment())->type() != MsgType::REPLY ) // if message not Reply, try collect the rest for Call + if(collection.data_size() < (sizeof(CallHeader) + sizeof(RecordMark)) && (rm->fragment())->type() != MsgType::REPLY) // if message not Reply, try collect the rest for Call { return true; } - if (rm->fragment_len() >= sizeof(ReplyHeader)) // incorrect fragment len, not valid rpc message + if(rm->fragment_len() >= sizeof(ReplyHeader)) // incorrect fragment len, not valid rpc message { - if (validate_header(rm->fragment(), rm->fragment_len() + sizeof(RecordMark) ) ) + if(validate_header(rm->fragment(), rm->fragment_len() + sizeof(RecordMark))) { return BaseImpl::read_message(info); } @@ -123,24 +122,24 @@ public: inline bool validate_header(const MessageHeader* const msg, const size_t len) { - switch (msg->type()) + switch(msg->type()) { case MsgType::CALL: { auto call = static_cast<const CallHeader* const>(msg); - if (RPCValidator::check(call)) + if(RPCValidator::check(call)) { - BaseImpl::setMsgLen(len); // length of current RPC message - if (protocols::NFS3::Validator::check(call)) + BaseImpl::setMsgLen(len); // length of current RPC message + if(protocols::NFS3::Validator::check(call)) { - uint32_t proc {call->proc()}; - if (API::ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit + uint32_t proc{call->proc()}; + if(API::ProcEnumNFS3::WRITE == proc) // truncate NFSv3 WRITE call message to NFSv3-RW-limit { BaseImpl::setToBeCopied(nfs3_rw_hdr_max < len ? nfs3_rw_hdr_max : len); } else { - if (API::ProcEnumNFS3::READ == proc) + if(API::ProcEnumNFS3::READ == proc) { nfs3_read_match.insert(call->xid()); } @@ -148,39 +147,39 @@ public: } //TRACE("%p| MATCH RPC Call xid:%u len: %u procedure: %u", this, call->xid(), msg_len, call->proc()); } - else if (protocols::NFS4::Validator::check(call)) + else if(protocols::NFS4::Validator::check(call)) { BaseImpl::setToBeCopied(len); } else { //* RPC call message must be read out ==> msg_len !=0 - BaseImpl::setToBeCopied(0);// don't collect headers of unknown calls + BaseImpl::setToBeCopied(0); // don't collect headers of unknown calls //TRACE("Unknown RPC call of program: %u version: %u procedure: %u", call->prog(), call->vers(), call->proc()); } return true; } else { - return false; // isn't RPC Call, stream is corrupt + return false; // isn't RPC Call, stream is corrupt } } break; case MsgType::REPLY: { auto reply = static_cast<const ReplyHeader* const>(msg); - if (RPCValidator::check(reply)) + if(RPCValidator::check(reply)) { - BaseImpl::setMsgLen(len); // length of current RPC message + BaseImpl::setMsgLen(len); // length of current RPC message // Truncate NFSv3 READ reply message to NFSv3-RW-limit //* Collect fully if reply received before matching call - if (nfs3_read_match.erase(reply->xid()) > 0) + if(nfs3_read_match.erase(reply->xid()) > 0) { BaseImpl::setToBeCopied(std::min(nfs3_rw_hdr_max, len)); } else { - BaseImpl::setToBeCopied(len);// length of current RPC message + BaseImpl::setToBeCopied(len); // length of current RPC message } //TRACE("%p| MATCH RPC Reply xid:%u len: %u", this, reply->xid(), msg_len); return true; @@ -204,12 +203,12 @@ public: } private: - size_t nfs3_rw_hdr_max {512}; // limit for NFSv3 to truncate WRITE call and READ reply messages + size_t nfs3_rw_hdr_max{512}; // limit for NFSv3 to truncate WRITE call and READ reply messages MessageSet nfs3_read_match; }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//RPC_FILTRATOR_H +#endif // RPC_FILTRATOR_H //------------------------------------------------------------------------------ diff --git a/src/filtration/sessions_hash.h b/src/filtration/sessions_hash.h index 96823a5..8e7b4b6 100644 --- a/src/filtration/sessions_hash.h +++ b/src/filtration/sessions_hash.h @@ -38,7 +38,6 @@ namespace NST { namespace filtration { - struct MapperImpl { using Session = NST::utils::Session; @@ -48,9 +47,10 @@ struct MapperImpl static inline Session::Direction ipv4_direction(const Session& key) { - if(key.port[0] < key.port[1]) return Session::Source; - else - if(key.port[0] > key.port[1]) return Session::Destination; + if(key.port[0] < key.port[1]) + return Session::Source; + else if(key.port[0] > key.port[1]) + return Session::Destination; // Ok, ports are equal, compare addresses return (key.ip.v4.addr[0] < key.ip.v4.addr[1]) ? Session::Source : Session::Destination; @@ -58,7 +58,7 @@ struct MapperImpl struct IPv4PortsKeyHash { - inline std::size_t operator() (const Session& key) const + inline std::size_t operator()(const Session& key) const { return key.port[0] + key.port[1] + @@ -69,7 +69,7 @@ struct MapperImpl struct IPv4PortsKeyEqual { - inline bool operator() (const Session& a, const Session& b) const + inline bool operator()(const Session& a, const Session& b) const { if((a.port[0] == b.port[0]) && (a.port[1] == b.port[1]) && @@ -88,13 +88,14 @@ struct MapperImpl static inline Session::Direction ipv6_direction(const Session& key) { - if(key.port[0] < key.port[1]) return Session::Source; - else - if(key.port[0] > key.port[1]) return Session::Destination; + if(key.port[0] < key.port[1]) + return Session::Source; + else if(key.port[0] > key.port[1]) + return Session::Destination; // Ok, ports are equal, compare addresses - const uint32_t* s { key.ip.v6.addr_uint32[0] }; - const uint32_t* d { key.ip.v6.addr_uint32[1] }; + const uint32_t* s{key.ip.v6.addr_uint32[0]}; + const uint32_t* d{key.ip.v6.addr_uint32[1]}; if(s[0] != d[0]) return (s[0] < d[0]) ? Session::Source : Session::Destination; if(s[1] != d[1]) return (s[1] < d[1]) ? Session::Source : Session::Destination; @@ -105,17 +106,13 @@ struct MapperImpl static inline void copy_ipv6(uint32_t dst[4], const uint8_t src[16]) { - // TODO:: fix alignment of src! - const uint32_t* s { reinterpret_cast<const uint32_t*>(src) }; - dst[0] = s[0]; - dst[1] = s[1]; - dst[2] = s[2]; - dst[3] = s[3]; + uint8_t* d{reinterpret_cast<uint8_t*>(dst)}; + memcpy(d, src, sizeof(uint32_t) * 4); } struct IPv6PortsKeyHash { - std::size_t operator() (const Session& key) const + std::size_t operator()(const Session& key) const { std::size_t ret = key.port[0] + key.port[1]; @@ -143,19 +140,17 @@ struct MapperImpl a[3] == b[3]; } - bool operator() (const Session& a, const Session& b) const + bool operator()(const Session& a, const Session& b) const { if((a.port[0] == b.port[0]) && (a.port[1] == b.port[1])) { - 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] )) + 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])) return true; } if((a.port[1] == b.port[0]) && (a.port[0] == b.port[1])) { - 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] )) + 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])) return true; } return false; @@ -284,12 +279,10 @@ struct IPv6UDPMapper : private MapperImpl }; // SessionsHash creates sessions and stores them in hash -template -< - typename Mapper, // map PacketInfo& to SessionImpl* - typename SessionImpl, // mapped type - typename Writer -> +template < + typename Mapper, // map PacketInfo& to SessionImpl* + typename SessionImpl, // mapped type + typename Writer> class SessionsHash { public: @@ -301,9 +294,9 @@ public: typename Mapper::KeyEqual>; SessionsHash(Writer* w) - : sessions { } - , writer {w} - , max_hdr {0} + : sessions{} + , writer{w} + , max_hdr{0} { max_hdr = controller::Parameters::rpcmsg_limit(); } @@ -323,7 +316,7 @@ public: auto i = sessions.find(key); if(i == sessions.end()) { - std::unique_ptr<SessionImpl> ptr{ new SessionImpl{writer, max_hdr} }; + std::unique_ptr<SessionImpl> ptr{new SessionImpl{writer, max_hdr}}; auto res = sessions.emplace(key, ptr.get()); if(res.second) // add new - success @@ -343,11 +336,11 @@ public: private: Container sessions; Writer* writer; - uint32_t max_hdr; + uint32_t max_hdr; }; } // namespace filtration } // namespace NST //------------------------------------------------------------------------------ -#endif//SESSIONS_HASH_H +#endif // SESSIONS_HASH_H //------------------------------------------------------------------------------ diff --git a/src/main.cpp b/src/main.cpp index 8d05a5e..be753ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) try { Parameters params(argc, argv); // set and validate CLI options - if (params.show_help() || params.show_enum()) + if(params.show_help() || params.show_enum()) { return 0; // -h or -E were passed } @@ -40,12 +40,12 @@ int main(int argc, char* argv[]) try return controller.run(); } -catch (const std::exception& e) +catch(const std::exception& e) { std::cerr << argv[0] << ": " << e.what() << std::endl; return -1; } -catch (...) +catch(...) { std::cerr << argv[0] << ": Unknown exception" << std::endl; return -1; diff --git a/src/protocols/cifs/cifs.cpp b/src/protocols/cifs/cifs.cpp index 348722b..78e02a9 100644 --- a/src/protocols/cifs/cifs.cpp +++ b/src/protocols/cifs/cifs.cpp @@ -21,13 +21,13 @@ //------------------------------------------------------------------------------ #include <cassert> +#include "api/plugin_api.h" // for NST_PUBLIC #include "protocols/cifs/cifs.h" //------------------------------------------------------------------------------ using namespace NST::protocols::CIFSv1; using namespace NST::API; -union SMBCode -{ - uint8_t codes[4]; +union SMBCode { + uint8_t codes[4]; uint32_t code; }; @@ -45,10 +45,10 @@ static inline uint32_t get_code() const NST::protocols::CIFSv1::MessageHeader* NST::protocols::CIFSv1::get_header(const uint8_t* data) { - static uint32_t code = get_code (); + static uint32_t code = get_code(); - const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data)); - if (header->head_code == code) + const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data)); + if(header->head_code == code) { return header; } @@ -60,10 +60,11 @@ bool MessageHeader::isFlag(const Flags flag) const return static_cast<const uint8_t>(flag) & static_cast<const uint8_t>(flags); } -const char* NST::protocols::CIFSv1::print_cifs1_procedures(SMBv1Commands cmd_code) +extern "C" NST_PUBLIC const char* print_cifs1_procedures(SMBv1Commands cmd_code) { assert(cmd_code < SMBv1Commands::CMD_COUNT); + // clang-format off static const char* const commandNames[] = { "CREATE_DIRECTORY", "DELETE_DIRECTORY", "OPEN", "CREATE", @@ -86,6 +87,7 @@ const char* NST::protocols::CIFSv1::print_cifs1_procedures(SMBv1Commands cmd_cod "CLOSE_PRINT_FILE", "GET_PRINT_QUEUE", "READ_BULK", "WRITE_BULK", "WRITE_BULK_DATA", "INVALID", "NO_ANDX_COMMAND" }; + // clang-format on return commandNames[static_cast<int>(cmd_code)]; } diff --git a/src/protocols/cifs/cifs.h b/src/protocols/cifs/cifs.h index 7d6f557..016e83b 100644 --- a/src/protocols/cifs/cifs.h +++ b/src/protocols/cifs/cifs.h @@ -27,7 +27,6 @@ #include "api/cifs_types.h" #include "protocols/netbios/netbios.h" //------------------------------------------------------------------------------ -#define NST_PUBLIC __attribute__ ((visibility("default"))) //------------------------------------------------------------------------------ namespace NST { @@ -35,6 +34,7 @@ namespace protocols { namespace CIFSv1 { +// clang-format off using SMBv1Commands = NST::API::SMBv1::SMBv1Commands; @@ -221,13 +221,11 @@ inline const Cmd command(Data& request, Data& response, Session* session) return cmd; } -extern "C" -NST_PUBLIC -const char* print_cifs1_procedures(SMBv1Commands cmd_code); +// clang-format on } // namespace CIFSv1 } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS_HEADER_H +#endif // CIFS_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/cifs2/cifs2.cpp b/src/protocols/cifs2/cifs2.cpp index 980ecca..e492785 100644 --- a/src/protocols/cifs2/cifs2.cpp +++ b/src/protocols/cifs2/cifs2.cpp @@ -24,13 +24,14 @@ #include <arpa/inet.h> #include <assert.h> -#include "protocols/cifs2/cifs2.h" -#include "protocols/cifs/cifs.h" #include "api/cifs_pc_to_net.h" +#include "api/plugin_api.h" // for NST_PUBLIC +#include "protocols/cifs/cifs.h" +#include "protocols/cifs2/cifs2.h" //------------------------------------------------------------------------------ using namespace NST::protocols::CIFSv2; -# if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN +#if NFSTRACE_BYTE_ORDER == NFSTRACE_BIG_ENDIAN inline uint64_t ntohll(uint64_t input) { @@ -38,19 +39,18 @@ inline uint64_t ntohll(uint64_t input) return input; } -# else -# if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN +#else +#if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN inline uint64_t ntohll(uint64_t input) { return be64toh(input); } -# endif -# endif +#endif +#endif -union SMBCode -{ - uint8_t codes[4]; +union SMBCode { + uint8_t codes[4]; uint32_t code; }; @@ -68,10 +68,10 @@ static inline uint32_t get_code() const NST::protocols::CIFSv2::MessageHeader* NST::protocols::CIFSv2::get_header(const uint8_t* data) { - static uint32_t code = get_code (); + static uint32_t code = get_code(); - const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data)); - if (header->head_code == code) + const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data)); + if(header->head_code == code) { return header; } @@ -85,13 +85,15 @@ bool MessageHeader::isFlag(const Flags flag) const void NST::protocols::CIFSv2::parseGuid(uint8_t (&guid)[16]) { - Guid &p = reinterpret_cast<Guid&>(guid); + Guid& p = reinterpret_cast<Guid&>(guid); p.Data1 = le32toh(p.Data1); p.Data2 = le16toh(p.Data2); p.Data3 = le16toh(p.Data3); } -void NST::protocols::CIFSv2::parse(SMBv2::ErrResponse*&) { } +void NST::protocols::CIFSv2::parse(SMBv2::ErrResponse*&) +{ +} void NST::protocols::CIFSv2::parse(SMBv2::NegotiateRequest*& p) { parseGuid(p->clientGUID); @@ -100,6 +102,8 @@ void NST::protocols::CIFSv2::parse(SMBv2::NegotiateResponse*& p) { parseGuid(p->serverGUID); } + +// clang-format off void NST::protocols::CIFSv2::parse(SMBv2::SessionSetupRequest*&){ } void NST::protocols::CIFSv2::parse(SMBv2::SessionSetupResponse*&) { } void NST::protocols::CIFSv2::parse(SMBv2::LogOffRequest*&) { } @@ -138,16 +142,18 @@ void NST::protocols::CIFSv2::parse(SMBv2::SetInfoRequest*&){ } void NST::protocols::CIFSv2::parse(SMBv2::SetInfoResponse*&){ } void NST::protocols::CIFSv2::parse(SMBv2::CancelResponce*&){ } void NST::protocols::CIFSv2::parse(SMBv2::CancelRequest*&){ } +// clang-format on // TODO: This implementation currently copy of // epm-nfs/analyzers/src/cifs/cifs2_commands.cpp // const std::string NST::breakdown::SMBv2Commands::command_name(int cmd_code) // Futre fix: We need to merege these enums // TODO: Move implementation to some common module -const char* NST::protocols::CIFSv2::print_cifs2_procedures(SMBv2Commands cmd) +extern "C" NST_PUBLIC const char* print_cifs2_procedures(SMBv2Commands cmd) { assert(cmd < SMBv2Commands::CMD_COUNT); + // clang-format off static const char* const commandNames[] = { "NEGOTIATE", "SESSION SETUP", "LOGOFF", "TREE CONNECT", @@ -156,7 +162,7 @@ const char* NST::protocols::CIFSv2::print_cifs2_procedures(SMBv2Commands cmd) "CANCEL", "ECHO", "QUERY DIRECTORY", "CHANGE NOTIFY", "QUERY INFO", "SET INFO", "OPLOCK BREAK" }; + // clang-format on return commandNames[static_cast<int>(cmd)]; } - diff --git a/src/protocols/cifs2/cifs2.h b/src/protocols/cifs2/cifs2.h index a3caa06..5a367c2 100644 --- a/src/protocols/cifs2/cifs2.h +++ b/src/protocols/cifs2/cifs2.h @@ -22,8 +22,8 @@ #ifndef CIFSv2_HEADER_H #define CIFSv2_HEADER_H //------------------------------------------------------------------------------ -#include "api/cifs_commands.h" #include "api/cifs2_commands.h" +#include "api/cifs_commands.h" #include "protocols/cifs/cifs.h" //------------------------------------------------------------------------------ namespace NST @@ -32,9 +32,9 @@ namespace protocols { namespace CIFSv2 { - using SMBv2Commands = NST::API::SMBv2::SMBv2Commands; -namespace SMBv2 = NST::API::SMBv2; +namespace SMBv2 = NST::API::SMBv2; +// clang-format off // https://msdn.microsoft.com/en-us/library/ff718266.aspx struct Guid { @@ -114,6 +114,8 @@ struct MessageHeader : public RawMessageHeader */ const MessageHeader* get_header(const uint8_t* data); +// clang-format on + void parseGuid(uint8_t (&guid)[16]); void parse(SMBv2::ErrResponse*&); void parse(SMBv2::NegotiateRequest*&); @@ -177,7 +179,7 @@ inline const Cmd command(Data& request, Data& response, Session* session) // we have to cast raw data to pointer type ( in contrast to const pointer ) // auto req_header = reinterpret_cast<RawMessageHeader*>(request->data); - auto pargs = reinterpret_cast<typename Cmd::RequestType*>(request->data + sizeof(RawMessageHeader)); + auto pargs = reinterpret_cast<typename Cmd::RequestType*>(request->data + sizeof(RawMessageHeader)); parse(pargs); @@ -185,19 +187,15 @@ inline const Cmd command(Data& request, Data& response, Session* session) if(response) { cmd.res_header = reinterpret_cast<RawMessageHeader*>(response->data); - cmd.pres = reinterpret_cast<typename Cmd::ResponseType*>(response->data + sizeof(RawMessageHeader)); + cmd.pres = reinterpret_cast<typename Cmd::ResponseType*>(response->data + sizeof(RawMessageHeader)); } - cmd.parg = pargs; + cmd.parg = pargs; return cmd; } -extern "C" -NST_PUBLIC -const char* print_cifs2_procedures(SMBv2Commands cmd_code); - } // namespace CIFSv2 } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFSv2_HEADER_H +#endif // CIFSv2_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/cifs2/cifs2_utils.cpp b/src/protocols/cifs2/cifs2_utils.cpp index ec065fc..de0aaa4 100644 --- a/src/protocols/cifs2/cifs2_utils.cpp +++ b/src/protocols/cifs2/cifs2_utils.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Author: Artsem Iliasau +// Author: Artsem Iliasau // Description: Helpers for parsing CIFSv2 structures. // Copyright (c) 2015 EPAM Systems //------------------------------------------------------------------------------ @@ -22,8 +22,9 @@ #include <iostream> #include <type_traits> -#include "cifs2.h" -#include "cifs2_utils.h" +#include "api/plugin_api.h" // for print_cifs2_procedures(value) +#include "protocols/cifs2/cifs2.h" +#include "protocols/cifs2/cifs2_utils.h" #include "protocols/nfs/nfs_utils.h" //------------------------------------------------------------------------------ static const std::string flagDelimiter = " | "; @@ -34,17 +35,15 @@ namespace protocols { namespace CIFSv2 { - using namespace NST::API::SMBv2; namespace { - template <typename T> void print_flag_if_set(std::ostream& out, const std::string& name, typename std::underlying_type<T>::type& value, T flag) { auto int_flag = to_integral(flag); - if (value & int_flag) + if(value & int_flag) { out << name; value = value & ~int_flag; @@ -55,6 +54,7 @@ void print_flag_if_set(std::ostream& out, const std::string& name, typename std: const char* enumToString(OplockLevels value) { + // clang-format off switch (value) { case OplockLevels::NONE: return "NONE"; @@ -63,12 +63,14 @@ const char* enumToString(OplockLevels value) case OplockLevels::BATCH: return "BATCH"; case OplockLevels::LEASE: return "LEASE"; } + // clang-format on return nullptr; } const char* enumToString(ImpersonationLevels value) { + // clang-format off switch (value) { case ImpersonationLevels::ANONYMOUS: return "ANONYMOUS"; @@ -76,12 +78,14 @@ const char* enumToString(ImpersonationLevels value) case ImpersonationLevels::IMPERSONATION: return "IMPERSONATION"; case ImpersonationLevels::DELEGATE: return "DELEGATE"; } + // clang-format on return nullptr; } const char* enumToString(CreateDisposition value) { + // clang-format off switch (value) { case CreateDisposition::SUPERSEDE: return "SUPERSEDE"; @@ -91,12 +95,14 @@ const char* enumToString(CreateDisposition value) case CreateDisposition::OVERWRITE: return "OVERWRITE"; case CreateDisposition::OVERWRITE_IF: return "OVERWRITE_IF"; } + // clang-format on return nullptr; } const char* enumToString(CreateActions value) { + // clang-format off switch (value) { case CreateActions::SUPERSEDED: return "SUPERSEDED"; @@ -104,24 +110,28 @@ const char* enumToString(CreateActions value) case CreateActions::CREATED: return "CREATED"; case CreateActions::FILE_OVERWRITTEN: return "FILE_OVERWRITTEN"; } + // clang-format on return nullptr; } const char* enumToString(ShareTypes value) { + // clang-format off switch (value) { case ShareTypes::DISK: return "SMB2_SHARE_TYPE_DISK"; case ShareTypes::PIPE: return "SMB2_SHARE_TYPE_PIPE"; case ShareTypes::PRINT: return "SMB2_SHARE_TYPE_PRINT"; } + // clang-format on return nullptr; } const char* enumToString(NTStatus value) { + // clang-format off switch (value) { case NTStatus::STATUS_SUCCESS: return "STATUS_SUCCESS"; @@ -151,12 +161,14 @@ const char* enumToString(NTStatus value) case NTStatus::STATUS_NOT_A_DIRECTORY: return "STATUS_NOT_A_DIRECTORY"; case NTStatus::STATUS_CANCELLED: return "STATUS_CANCELLED"; } + // clang-format on return nullptr; } const char* enumToString(FsInfoLevels value) { + // clang-format off switch (value) { case FsInfoLevels::SMB2_FS_INFO_01: return "SMB2_FS_INFO_01"; @@ -167,12 +179,14 @@ const char* enumToString(FsInfoLevels value) case FsInfoLevels::SMB2_FS_INFO_06: return "SMB2_FS_INFO_06"; case FsInfoLevels::SMB2_FS_INFO_07: return "SMB2_FS_INFO_07"; } + // clang-format on return nullptr; } const char* enumToString(QueryInfoLevels value) { + // clang-format off switch (value) { case QueryInfoLevels::DIRECTORY_INFORMATION: return "DIRECTORY_INFORMATION"; @@ -221,12 +235,14 @@ const char* enumToString(QueryInfoLevels value) case QueryInfoLevels::ID_GLOBAL_TX_DIRECTORY_INFORMATION: return "ID_GLOBAL_TX_DIRECTORY_INFORMATION"; case QueryInfoLevels::STANDARD_LINK_INFORMATION: return "STANDARD_LINK_INFORMATION"; } + // clang-format on return nullptr; } const char* enumToString(CtlCodes value) { + // clang-format off switch (value) { case CtlCodes::SCTL_DFS_GET_REFERRALS: return "SCTL_DFS_GET_REFERRALS"; @@ -245,12 +261,14 @@ const char* enumToString(CtlCodes value) case CtlCodes::FSCTL_FILE_LEVEL_TRIM: return "FSCTL_FILE_LEVEL_TRIM"; case CtlCodes::FSCTL_VALIDATE_NEGOTIATE_INFO: return "FSCTL_VALIDATE_NEGOTIATE_INFO"; } + // clang-format on return nullptr; } const char* enumToString(InfoTypes value) { + // clang-format off switch (value) { case InfoTypes::FILE: return "SMB2_0_INFO_FILE"; @@ -258,26 +276,29 @@ const char* enumToString(InfoTypes value) case InfoTypes::SECURITY: return "SMB2_0_INFO_SECURITY"; case InfoTypes::QUOTA: return "SMB2_0_INFO_QUOTA"; } + // clang-format on return nullptr; } const char* enumToString(SessionFlagsBinding value) +{ + // clang-format off + switch (value) { - switch (value) - { - case SessionFlagsBinding::NONE: return "NONE"; - case SessionFlagsBinding::BINDING: return "BINDING"; - } - - return nullptr; + case SessionFlagsBinding::NONE: return "NONE"; + case SessionFlagsBinding::BINDING: return "BINDING"; } + // clang-format on + return nullptr; } +} // namespace <unnamed> + std::ostream& operator<<(std::ostream& out, const SMBv2::SMBv2Commands value) { - const char* strCommand = NST::protocols::CIFSv2::print_cifs2_procedures(value); + const char* strCommand = print_cifs2_procedures(value); out << "(" << strCommand << ")"; @@ -286,8 +307,8 @@ std::ostream& operator<<(std::ostream& out, const SMBv2::SMBv2Commands value) std::ostream& operator<<(std::ostream& out, const OplockLevels value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -297,8 +318,8 @@ std::ostream& operator<<(std::ostream& out, const OplockLevels value) std::ostream& operator<<(std::ostream& out, const ImpersonationLevels value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -308,8 +329,8 @@ std::ostream& operator<<(std::ostream& out, const ImpersonationLevels value) std::ostream& operator<<(std::ostream& out, const CreateDisposition value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -319,8 +340,8 @@ std::ostream& operator<<(std::ostream& out, const CreateDisposition value) std::ostream& operator<<(std::ostream& out, const CreateActions value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -330,8 +351,8 @@ std::ostream& operator<<(std::ostream& out, const CreateActions value) std::ostream& operator<<(std::ostream& out, const ShareTypes value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -340,9 +361,9 @@ std::ostream& operator<<(std::ostream& out, const ShareTypes value) } std::ostream& operator<<(std::ostream& out, const NTStatus value) -{ - const char *strValue = enumToString(value); - if (strValue != nullptr) +{ + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -354,9 +375,10 @@ std::ostream& operator<<(std::ostream& out, const DesiredAccessFlags value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "READ_DATA_LE", int_value, DesiredAccessFlags::READ_DATA_LE); print_flag_if_set(out, "WRITE_DATA_LE", int_value, DesiredAccessFlags::WRITE_DATA_LE); print_flag_if_set(out, "APPEND_DATA_LE", int_value, DesiredAccessFlags::APPEND_DATA_LE); @@ -376,6 +398,7 @@ std::ostream& operator<<(std::ostream& out, const DesiredAccessFlags value) print_flag_if_set(out, "GENERIC_EXECUTE_LE", int_value, DesiredAccessFlags::GENERIC_EXECUTE_LE); print_flag_if_set(out, "GENERIC_WRITE_LE", int_value, DesiredAccessFlags::GENERIC_WRITE_LE); print_flag_if_set(out, "GENERIC_READ_LE", int_value, DesiredAccessFlags::GENERIC_READ_LE); + // clang-format on out << ")"; } return out; @@ -385,9 +408,10 @@ std::ostream& operator<<(std::ostream& out, const FileAttributes value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "READONLY", int_value, FileAttributes::READONLY); print_flag_if_set(out, "HIDDEN", int_value, FileAttributes::HIDDEN); print_flag_if_set(out, "SYSTEM", int_value, FileAttributes::SYSTEM); @@ -401,6 +425,7 @@ std::ostream& operator<<(std::ostream& out, const FileAttributes value) print_flag_if_set(out, "OFFLINE", int_value, FileAttributes::OFFLINE); print_flag_if_set(out, "NOT_CONTENT_INDEXED", int_value, FileAttributes::NOT_CONTENT_INDEXED); print_flag_if_set(out, "ENCRYPTED", int_value, FileAttributes::ENCRYPTED); + // clang-format on out << ")"; } @@ -410,12 +435,14 @@ std::ostream& operator<<(std::ostream& out, const FileAttributes value) std::ostream& operator<<(std::ostream& out, const ShareAccessFlags value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "SHARE_READ_LE", int_value, ShareAccessFlags::SHARE_READ_LE); print_flag_if_set(out, "SHARE_WRITE_LE", int_value, ShareAccessFlags::SHARE_WRITE_LE); print_flag_if_set(out, "SHARE_DELETE_LE", int_value, ShareAccessFlags::SHARE_DELETE_LE); + // clang-format on out << ")"; } @@ -426,9 +453,10 @@ std::ostream& operator<<(std::ostream& out, const CreateOptionsFlags value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "DIRECTORY_FILE_LE", int_value, CreateOptionsFlags::DIRECTORY_FILE_LE); print_flag_if_set(out, "WRITE_THROUGH_LE", int_value, CreateOptionsFlags::WRITE_THROUGH_LE); print_flag_if_set(out, "SEQUENTIAL_ONLY_LE", int_value, CreateOptionsFlags::SEQUENTIAL_ONLY_LE); @@ -447,6 +475,7 @@ std::ostream& operator<<(std::ostream& out, const CreateOptionsFlags value) print_flag_if_set(out, "OPEN_REPARSE_POINT_LE", int_value, CreateOptionsFlags::OPEN_REPARSE_POINT_LE); print_flag_if_set(out, "OPEN_NO_RECALL_LE", int_value, CreateOptionsFlags::OPEN_NO_RECALL_LE); print_flag_if_set(out, "OPEN_FOR_FREE_SPACE_QUERY_LE", int_value, CreateOptionsFlags::OPEN_FOR_FREE_SPACE_QUERY_LE); + // clang-format on out << ")"; } @@ -457,11 +486,13 @@ std::ostream& operator<<(std::ostream& out, const WriteFlags value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "SMB2_WRITEFLAG_WRITE_THROUGH", int_value, WriteFlags::SMB2_WRITEFLAG_WRITE_THROUGH); print_flag_if_set(out, "SMB2_WRITEFLAG_WRITE_UNBUFFERED", int_value, WriteFlags::SMB2_WRITEFLAG_WRITE_UNBUFFERED); + // clang-format on out << ")"; } return out; @@ -472,6 +503,7 @@ std::ostream& operator<<(std::ostream& out, const ShareFlags value) auto int_value = to_integral(value) & ~to_integral(ShareFlags::NO_CACHING); out << "Caching policy = "; + // clang-format off switch(to_integral(value) & to_integral(ShareFlags::NO_CACHING)) { case to_integral(ShareFlags::MANUAL_CACHING): out << "MANUAL_CACHING"; break; @@ -494,6 +526,7 @@ std::ostream& operator<<(std::ostream& out, const ShareFlags value) print_flag_if_set(out, "SMB2_SHAREFLAG_ENABLE_HASH_V2", int_value, ShareFlags::ENABLE_HASH_2); print_flag_if_set(out, "SMB2_SHAREFLAG_ENCRYPT_DATA", int_value, ShareFlags::ENABLE_ENCRYPT_DATA); } + // clang-format on return out; } @@ -503,13 +536,15 @@ std::ostream& operator<<(std::ostream& out, const ShareCapabilities value) auto int_value = to_integral(value); if(int_value > 0) - { + { out << "("; + // clang-format off print_flag_if_set(out, "SMB2_SHARE_CAP_DFS", int_value, ShareCapabilities::DFS); print_flag_if_set(out, "SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY", int_value, ShareCapabilities::CONTINUOUS_AVAILABILITY); print_flag_if_set(out, "SMB2_SHARE_CAP_SCALEOUT", int_value, ShareCapabilities::SCALEOUT); print_flag_if_set(out, "SMB2_SHARE_CAP_CLUSTER", int_value, ShareCapabilities::CLUSTER); print_flag_if_set(out, "SMB2_SHARE_CAP_ASYMMETRIC", int_value, ShareCapabilities::ASYMMETRIC); + // clang-format on out << ")"; } @@ -520,11 +555,13 @@ std::ostream& operator<<(std::ostream& out, const SecurityModeShort value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityModeShort::SIGNING_ENABLED); print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityModeShort::SIGNING_REQUIRED); + // clang-format on out << ")"; } return out; @@ -537,6 +574,7 @@ std::ostream& operator<<(std::ostream& out, const Capabilities value) if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "DFS", int_value, Capabilities::DFS); print_flag_if_set(out, "LEASING", int_value, Capabilities::LEASING); print_flag_if_set(out, "LARGE_MTU", int_value, Capabilities::LARGE_MTU); @@ -544,6 +582,7 @@ std::ostream& operator<<(std::ostream& out, const Capabilities value) print_flag_if_set(out, "PERSISTENT_HANDLES",int_value, Capabilities::PERSISTENT_HANDLES); print_flag_if_set(out, "DIRECTORY_LEASING", int_value, Capabilities::DIRECTORY_LEASING); print_flag_if_set(out, "ENCRYPTION", int_value, Capabilities::ENCRYPTION); + // clang-format on out << ")"; } @@ -553,12 +592,12 @@ std::ostream& operator<<(std::ostream& out, const Capabilities value) std::ostream& operator<<(std::ostream& out, const SessionFlags value) { auto int_value = to_integral(value); - + // clang-format off print_flag_if_set(out, "NONE", int_value, SessionFlags::NONE); print_flag_if_set(out, "SMB2_SESSION_FLAG_IS_GUEST", int_value, SessionFlags::IS_GUEST); print_flag_if_set(out, "SMB2_SESSION_FLAG_IS_NULL", int_value, SessionFlags::IS_NULL); print_flag_if_set(out, "SMB2_SESSION_FLAG_ENCRYPT_DATA",int_value, SessionFlags::IS_ENCRYPT_DATA); - + // clang-format on return out; } @@ -566,9 +605,10 @@ std::ostream& operator<<(std::ostream& out, const AccessMask value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; + // clang-format off print_flag_if_set(out, "FILE_READ_DATA", int_value, AccessMask::FILE_READ_DATA); print_flag_if_set(out, "FILE_WRITE_DATA", int_value, AccessMask::FILE_WRITE_DATA); print_flag_if_set(out, "FILE_APPEND_DATA", int_value, AccessMask::FILE_APPEND_DATA); @@ -589,6 +629,7 @@ std::ostream& operator<<(std::ostream& out, const AccessMask value) print_flag_if_set(out, "GENERIC_EXECUTE", int_value, AccessMask::GENERIC_EXECUTE); print_flag_if_set(out, "GENERIC_WRITE", int_value, AccessMask::GENERIC_WRITE); print_flag_if_set(out, "GENERIC_READ", int_value, AccessMask::GENERIC_READ); + // clang-format on out << ")"; } @@ -602,7 +643,7 @@ std::ostream& operator<<(std::ostream& out, const CloseFlags value) if(int_value > 0) { out << "("; - print_flag_if_set(out, "POSTQUERY_ATTRIB", int_value, CloseFlags::POSTQUERY_ATTRIB); + print_flag_if_set(out, "POSTQUERY_ATTRIB", int_value, CloseFlags::POSTQUERY_ATTRIB); out << ")"; } @@ -613,11 +654,11 @@ std::ostream& operator<<(std::ostream& out, const SecurityMode value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; - print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityMode::SIGNING_ENABLED); - print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityMode::SIGNING_REQUIRED); + print_flag_if_set(out, "SIGNING_ENABLED", int_value, SecurityMode::SIGNING_ENABLED); + print_flag_if_set(out, "SIGNING_REQUIRED", int_value, SecurityMode::SIGNING_REQUIRED); out << ")"; } @@ -626,8 +667,8 @@ std::ostream& operator<<(std::ostream& out, const SecurityMode value) std::ostream& operator<<(std::ostream& out, const FsInfoLevels value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -637,8 +678,8 @@ std::ostream& operator<<(std::ostream& out, const FsInfoLevels value) std::ostream& operator<<(std::ostream& out, const QueryInfoLevels value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -648,8 +689,8 @@ std::ostream& operator<<(std::ostream& out, const QueryInfoLevels value) std::ostream& operator<<(std::ostream& out, const CtlCodes value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -659,8 +700,8 @@ std::ostream& operator<<(std::ostream& out, const CtlCodes value) std::ostream& operator<<(std::ostream& out, const InfoTypes value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -670,8 +711,8 @@ std::ostream& operator<<(std::ostream& out, const InfoTypes value) std::ostream& operator<<(std::ostream& out, const SessionFlagsBinding value) { - const char *strValue = enumToString(value); - if (strValue != nullptr) + const char* strValue = enumToString(value); + if(strValue != nullptr) { out << "(" << strValue << ")"; } @@ -682,7 +723,7 @@ std::ostream& operator<<(std::ostream& out, const SessionFlagsBinding value) std::ostream& operator<<(std::ostream& out, const Flags value) { auto int_value = to_integral(value); - if (int_value > 0) + if(int_value > 0) { out << "("; print_flag_if_set(out, "SERVER_TO_REDIR", int_value, Flags::SERVER_TO_REDIR); @@ -701,15 +742,15 @@ std::ostream& print_info_levels(std::ostream& out, const InfoTypes infoType, con { switch(infoType) { - case InfoTypes::FILE: - print_enum(out, "InfoLevel", static_cast<QueryInfoLevels>(infoClass)); - break; - case InfoTypes::FILESYSTEM: - print_enum(out, "InfoLevel", static_cast<FsInfoLevels>(infoClass)); - break; - default: - //we dont handle other classes - ; + case InfoTypes::FILE: + print_enum(out, "InfoLevel", static_cast<QueryInfoLevels>(infoClass)); + break; + case InfoTypes::FILESYSTEM: + print_enum(out, "InfoLevel", static_cast<FsInfoLevels>(infoClass)); + break; + default: + //we dont handle other classes + ; } return out; } diff --git a/src/protocols/cifs2/cifs2_utils.h b/src/protocols/cifs2/cifs2_utils.h index 800fa1f..36f4d65 100644 --- a/src/protocols/cifs2/cifs2_utils.h +++ b/src/protocols/cifs2/cifs2_utils.h @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Author: Artsem Iliasau +// Author: Artsem Iliasau // Description: Helpers for parsing CIFSv2 structures. // Copyright (c) 2015 EPAM Systems //------------------------------------------------------------------------------ @@ -35,14 +35,13 @@ namespace protocols { namespace CIFSv2 { - namespace SMBv2 = NST::API::SMBv2; /*! Convert enum type to underlying integer type * \param e - instance of enumeration to be converted * \return integer representation of enumeration */ -template<typename E> +template <typename E> inline constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type { return static_cast<typename std::underlying_type<E>::type>(e); @@ -71,7 +70,7 @@ std::ostream& operator<<(std::ostream& out, const SMBv2::SessionFlags value); std::ostream& operator<<(std::ostream& out, const SMBv2::NTStatus value); std::ostream& operator<<(std::ostream& out, const SMBv2::AccessMask value); std::ostream& operator<<(std::ostream& out, const SMBv2::CloseFlags value); -std::ostream& operator<<(std::ostream& out, const SMBv2::SecurityMode value); +std::ostream& operator<<(std::ostream& out, const SMBv2::SecurityMode value); std::ostream& operator<<(std::ostream& out, Flags value); template <typename T> @@ -84,7 +83,7 @@ std::ostream& print_enum(std::ostream& out, const std::string name, T value) print_hex(out, int_value); out << " " << (T)int_value; return out; -} +} std::ostream& print_info_levels(std::ostream& os, const NST::API::SMBv2::InfoTypes infoType, const uint8_t infoClass); @@ -92,5 +91,5 @@ std::ostream& print_info_levels(std::ostream& os, const NST::API::SMBv2::InfoTyp } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//CIFS2_UTILS_H +#endif // CIFS2_UTILS_H //------------------------------------------------------------------------------ diff --git a/src/protocols/ethernet/ethernet_header.h b/src/protocols/ethernet/ethernet_header.h index 8cac36c..5c07a66 100644 --- a/src/protocols/ethernet/ethernet_header.h +++ b/src/protocols/ethernet/ethernet_header.h @@ -24,7 +24,7 @@ //------------------------------------------------------------------------------ #include <cstdint> -#include <arpa/inet.h> // for ntohs() +#include <arpa/inet.h> // for ntohs() //------------------------------------------------------------------------------ namespace NST { @@ -32,42 +32,44 @@ namespace protocols { namespace ethernet { - // Ethernet II (aka DIX v2.0 Ethernet) struct ethernet_header { - enum { ADDR_LEN = 6 }; + enum + { + ADDR_LEN = 6 + }; enum EtherType { - PUP = 0x0200, // Xerox PUP - SPRITE = 0x0500, // Sprite - IP = 0x0800, // IP - ARP = 0x0806, // Address resolution - REVARP = 0x8035, // Reverse ARP - AT = 0x809B, // AppleTalk protocol - AARP = 0x80F3, // AppleTalk ARP - VLAN = 0x8100, // IEEE 802.1Q VLAN tagging - IPX = 0x8137, // IPX - IPV6 = 0x86dd, // IP protocol version 6 - LOOPBACK= 0x9000 // used to test interfaces + PUP = 0x0200, // Xerox PUP + SPRITE = 0x0500, // Sprite + IP = 0x0800, // IP + ARP = 0x0806, // Address resolution + REVARP = 0x8035, // Reverse ARP + AT = 0x809B, // AppleTalk protocol + AARP = 0x80F3, // AppleTalk ARP + VLAN = 0x8100, // IEEE 802.1Q VLAN tagging + IPX = 0x8137, // IPX + IPV6 = 0x86dd, // IP protocol version 6 + LOOPBACK = 0x9000 // used to test interfaces }; - uint8_t eth_dhost[ADDR_LEN]; // destination host address - uint8_t eth_shost[ADDR_LEN]; // source host address - uint16_t eth_type; // protocol (EtherType values) + uint8_t eth_dhost[ADDR_LEN]; // destination host address + uint8_t eth_shost[ADDR_LEN]; // source host address + uint16_t eth_type; // protocol (EtherType values) } __attribute__((packed)); struct EthernetHeader : private ethernet_header { - inline const uint8_t* dst() const { return eth_dhost; } - inline const uint8_t* src() const { return eth_shost; } + inline const uint8_t* dst() const { return eth_dhost; } + inline const uint8_t* src() const { return eth_shost; } inline uint16_t type() const { return ntohs(eth_type); } -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); } // namespace ethernet } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//ETHERNET_HEADER_H +#endif // ETHERNET_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/ip/ip_header.h b/src/protocols/ip/ip_header.h index d558e8d..07582bf 100644 --- a/src/protocols/ip/ip_header.h +++ b/src/protocols/ip/ip_header.h @@ -31,43 +31,42 @@ namespace protocols { namespace ip { - -enum NextProtocol // ID of next protocol header +enum NextProtocol // ID of next protocol header { - IP = 0, // Dummy protocol for TCP - HOPOPTS = 0, // IPv6 Hop-by-Hop options - ICMP = 1, // Internet Control Message Protocol - IGMP = 2, // Internet Group Management Protocol - IPIP = 4, // IPIP tunnels (older KA9Q tunnels use 94) - TCP = 6, // Transmission Control Protocol - EGP = 8, // Exterior Gateway Protocol - PUP = 12, // PUP protocol - UDP = 17, // User Datagram Protocol - IDP = 22, // XNS IDP protocol - TP = 29, // SO Transport Protocol Class 4 - DCCP = 33, // Datagram Congestion Control Protocol - IPV6 = 41, // IPv6 header - ROUTING = 43, // IPv6 routing header - FRAGMENT= 44, // IPv6 fragmentation header - RSVP = 46, // Reservation Protocol - GRE = 47, // General Routing Encapsulation - ESP = 50, // encapsulating security payload - AH = 51, // authentication header - ICMPV6 = 58, // ICMPv6 - NONE = 59, // IPv6 no next header - DSTOPTS = 60, // IPv6 destination options - MTP = 92, // Multicast Transport Protocol - ENCAP = 98, // Encapsulation Header - PIM = 103, // Protocol Independent Multicast - COMP = 108, // Compression Header Protocol - SCTP = 132, // Stream Control Transmission Protocol - UDPLITE = 136, // UDP-Lite protocol - RAW = 255 // Raw IP packets + IP = 0, // Dummy protocol for TCP + HOPOPTS = 0, // IPv6 Hop-by-Hop options + ICMP = 1, // Internet Control Message Protocol + IGMP = 2, // Internet Group Management Protocol + IPIP = 4, // IPIP tunnels (older KA9Q tunnels use 94) + TCP = 6, // Transmission Control Protocol + EGP = 8, // Exterior Gateway Protocol + PUP = 12, // PUP protocol + UDP = 17, // User Datagram Protocol + IDP = 22, // XNS IDP protocol + TP = 29, // SO Transport Protocol Class 4 + DCCP = 33, // Datagram Congestion Control Protocol + IPV6 = 41, // IPv6 header + ROUTING = 43, // IPv6 routing header + FRAGMENT = 44, // IPv6 fragmentation header + RSVP = 46, // Reservation Protocol + GRE = 47, // General Routing Encapsulation + ESP = 50, // encapsulating security payload + AH = 51, // authentication header + ICMPV6 = 58, // ICMPv6 + NONE = 59, // IPv6 no next header + DSTOPTS = 60, // IPv6 destination options + MTP = 92, // Multicast Transport Protocol + ENCAP = 98, // Encapsulation Header + PIM = 103, // Protocol Independent Multicast + COMP = 108, // Compression Header Protocol + SCTP = 132, // Stream Control Transmission Protocol + UDPLITE = 136, // UDP-Lite protocol + RAW = 255 // Raw IP packets }; } // namespace ip } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//IP_HEADER_H +#endif // IP_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/ip/ipv4_header.h b/src/protocols/ip/ipv4_header.h index 8f649ce..4de6fd0 100644 --- a/src/protocols/ip/ipv4_header.h +++ b/src/protocols/ip/ipv4_header.h @@ -33,7 +33,6 @@ namespace protocols { namespace ip { - // Internet Protocol, version 4 struct ipv4_header { @@ -53,20 +52,21 @@ struct ipv4_header OFFMASK = 0x1fff // mask for fragmenting bits }; - uint8_t ipv4_vhl; // header length and version - uint8_t ipv4_tos; // type of service - uint16_t ipv4_len; // total length - uint16_t ipv4_id; // identification - uint16_t ipv4_fragmentation;// fragmentation - uint8_t ipv4_ttl; // time to live - uint8_t ipv4_protocol; // protocol - uint16_t ipv4_checksum; // checksum - in_addr_t ipv4_src; // source address - in_addr_t ipv4_dst; // destination address -} __attribute__ ((__packed__)); + uint8_t ipv4_vhl; // header length and version + uint8_t ipv4_tos; // type of service + uint16_t ipv4_len; // total length + uint16_t ipv4_id; // identification + uint16_t ipv4_fragmentation; // fragmentation + uint8_t ipv4_ttl; // time to live + uint8_t ipv4_protocol; // protocol + uint16_t ipv4_checksum; // checksum + in_addr_t ipv4_src; // source address + in_addr_t ipv4_dst; // destination address +} __attribute__((__packed__)); struct IPv4Header : private ipv4_header { + // clang-format off inline uint8_t version() const { return ipv4_vhl >> 4; } inline uint8_t ihl() const { return (ipv4_vhl & 0x0f) << 2 /* *4 */; } // return number of bytes inline uint16_t length() const { return ntohs(ipv4_len); } @@ -81,11 +81,12 @@ struct IPv4Header : private ipv4_header { return ipv4_fragmentation & htons(OFFMASK) /*offset() != 0*/; } -} __attribute__ ((__packed__)); + // clang-format on +} __attribute__((__packed__)); } // namespace ip } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//IPV4_HEADER_H +#endif // IPV4_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/ip/ipv6_header.h b/src/protocols/ip/ipv6_header.h index 6c96155..af27bbb 100644 --- a/src/protocols/ip/ipv6_header.h +++ b/src/protocols/ip/ipv6_header.h @@ -33,7 +33,6 @@ namespace protocols { namespace ip { - typedef uint8_t in6_addr_t[16]; static_assert(sizeof(in6_addr) == sizeof(in6_addr_t), "sizeof in6_addr should be 16 bytes"); @@ -41,67 +40,70 @@ static_assert(sizeof(in6_addr) == sizeof(in6_addr_t), "sizeof in6_addr should be // Internet Protocol, version 6 struct ipv6_header { - uint32_t ipv6_vtcflow; // version(4), traffic class(8), flow label(20) - uint16_t ipv6_plen; // size of payload, including any extension header - uint8_t ipv6_nexthdr; // next header type - uint8_t ipv6_hlimit; // hop limit - in6_addr_t ipv6_src; // source address - in6_addr_t ipv6_dst; // destination address -} __attribute__ ((__packed__)); + uint32_t ipv6_vtcflow; // version(4), traffic class(8), flow label(20) + uint16_t ipv6_plen; // size of payload, including any extension header + uint8_t ipv6_nexthdr; // next header type + uint8_t ipv6_hlimit; // hop limit + in6_addr_t ipv6_src; // source address + in6_addr_t ipv6_dst; // destination address +} __attribute__((__packed__)); // Hop-by-Hop options header -struct ipv6_hbh { - uint8_t hbh_nexthdr; // next header type - uint8_t hbh_len; // length in units of 8 octets +struct ipv6_hbh +{ + uint8_t hbh_nexthdr; // next header type + uint8_t hbh_len; // length in units of 8 octets // addition data -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); // Destination options header -struct ipv6_dest { - uint8_t dest_nexthdr; // next header type - uint8_t dest_len; // length in units of 8 octets +struct ipv6_dest +{ + uint8_t dest_nexthdr; // next header type + uint8_t dest_len; // length in units of 8 octets // addition data -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); // Routing header -struct ipv6_route { - uint8_t route_nexthdr; // next header - uint8_t route_len; // length in units of 8 octets - uint8_t route_type; // routing type - uint8_t route_segleft; // segments left +struct ipv6_route +{ + uint8_t route_nexthdr; // next header + uint8_t route_len; // length in units of 8 octets + uint8_t route_type; // routing type + uint8_t route_segleft; // segments left // routing type specific data -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); // Fragment header -struct ipv6_frag { - +struct ipv6_frag +{ enum Fragmentation : uint16_t { - MORE = 0x0001, // more-fragments flag - RESERVED= 0x0006, // mask out reserved bits - OFFSET = 0xfff8 // mask out offset from frag_offlg + MORE = 0x0001, // more-fragments flag + RESERVED = 0x0006, // mask out reserved bits + OFFSET = 0xfff8 // mask out offset from frag_offlg }; uint8_t frag_nexthdr; // next header uint8_t frag_reserved; // reserved field uint16_t frag_offlg; // offset, reserved, and flag uint32_t frag_ident; // identification -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct IPv6Header : private ipv6_header { - inline uint8_t version() const { return ntohl(ipv6_vtcflow) >> 28; } - inline uint8_t tclass() const { return (ntohl(ipv6_vtcflow) >> 20) & 0xFF;} - inline uint32_t flowid() const { return ntohl(ipv6_vtcflow) & 0xFFFFF;} - inline uint16_t payload_len() const { return ntohs(ipv6_plen); } - inline uint8_t nexthdr() const { return ipv6_nexthdr; } - inline const in6_addr_t& src() const { return ipv6_src; } - inline const in6_addr_t& dst() const { return ipv6_dst; } -} __attribute__ ((__packed__)); + uint8_t version() const { return ntohl(ipv6_vtcflow) >> 28; } + uint8_t tclass() const { return (ntohl(ipv6_vtcflow) >> 20) & 0xFF; } + uint32_t flowid() const { return ntohl(ipv6_vtcflow) & 0xFFFFF; } + uint16_t payload_len() const { return ntohs(ipv6_plen); } + uint8_t nexthdr() const { return ipv6_nexthdr; } + const in6_addr_t& src() const { return ipv6_src; } + const in6_addr_t& dst() const { return ipv6_dst; } +} __attribute__((__packed__)); } // namespace ip } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//IPV6_HEADER_H +#endif // IPV6_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/netbios/netbios.h b/src/protocols/netbios/netbios.h index 9fd5bd3..c3f40f7 100644 --- a/src/protocols/netbios/netbios.h +++ b/src/protocols/netbios/netbios.h @@ -22,8 +22,8 @@ #ifndef NETBIOS_HEADER_H #define NETBIOS_HEADER_H //------------------------------------------------------------------------------ -#include <stdlib.h> #include <cstdint> +#include <cstdlib> //------------------------------------------------------------------------------ namespace NST { @@ -31,15 +31,14 @@ namespace protocols { namespace NetBIOS { - /*! \class NetBIOS message header in SMB-direct case */ struct RawMessageHeader { - uint8_t _start;//!< In SMB direct always 0x00 - uint8_t _; - uint16_t length;//!< Packet length -} __attribute__ ((__packed__)); + uint8_t _start; //!< In SMB direct always 0x00 + uint8_t _; + uint16_t length; //!< Packet length +} __attribute__((__packed__)); /*! \class NetBIOS message header wrapper */ @@ -55,8 +54,8 @@ struct MessageHeader : private RawMessageHeader */ inline const struct MessageHeader* get_header(const uint8_t* data) { - const MessageHeader* header (reinterpret_cast<const MessageHeader*>(data)); - if (header->start() == 0x00) + const MessageHeader* header(reinterpret_cast<const MessageHeader*>(data)); + if(header->start() == 0x00) { return header; } @@ -67,5 +66,5 @@ inline const struct MessageHeader* get_header(const uint8_t* data) } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NETBIOS_HEADER_H +#endif // NETBIOS_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/nfs/nfs_procedure.h b/src/protocols/nfs/nfs_procedure.h index 2803efd..f7a2028 100644 --- a/src/protocols/nfs/nfs_procedure.h +++ b/src/protocols/nfs/nfs_procedure.h @@ -26,35 +26,33 @@ #include "api/rpc_types.h" #include "protocols/nfs3/nfs3_utils.h" -#include "protocols/nfs4/nfs4_utils.h" #include "protocols/nfs4/nfs41_utils.h" +#include "protocols/nfs4/nfs4_utils.h" #include "utils/sessions.h" //------------------------------------------------------------------------------ namespace NST { namespace protocols { - using NFS3::proc_t_of; using NFS4::proc_t_of; using NFS41::proc_t_of; -template -< +template < typename ArgType, // structure of RPC procedure parameters typename ResType // structure of RPC procedure results -> -class NFSProcedure: public NST::API::RPCProcedure + > +class NFSProcedure : public NST::API::RPCProcedure { public: inline NFSProcedure(xdr::XDRDecoder& c, xdr::XDRDecoder& r, const Session* s) - : parg{&arg} // set pointer to argument - , pres{&res} // set pointer to result + : parg{&arg} // set pointer to argument + , pres{&res} // set pointer to result { - memset(&call, 0,sizeof(call )); - memset(&reply,0,sizeof(reply)); - memset(&arg, 0,sizeof(arg )); - memset(&res, 0,sizeof(res )); + memset(&call, 0, sizeof(call)); + memset(&reply, 0, sizeof(reply)); + memset(&arg, 0, sizeof(arg)); + memset(&res, 0, sizeof(res)); // fill call if(!xdr_callmsg(c.xdr(), &call)) @@ -64,34 +62,34 @@ public: } // fill call arguments - if(!proc_t_of(arg)(c.xdr(),&arg)) + if(!proc_t_of(arg)(c.xdr(), &arg)) { - xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg ); - xdr_free((xdrproc_t)xdr_callmsg, (char*)&call); + xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg); + xdr_free((xdrproc_t)xdr_callmsg, (char*)&call); throw xdr::XDRDecoderError{"XDRDecoder: cann't read call arguments"}; } reply.ru.RM_rmb.ru.RP_ar.ru.AR_results.proc = &return_true; // fill reply - if(!xdr_replymsg (r.xdr(), &reply)) + if(!xdr_replymsg(r.xdr(), &reply)) { - xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); - xdr_free((xdrproc_t)proc_t_of(arg),(char*)&arg ); - xdr_free((xdrproc_t)xdr_callmsg, (char*)&call ); + xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); + xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg); + xdr_free((xdrproc_t)xdr_callmsg, (char*)&call); throw xdr::XDRDecoderError{"XDRDecoder: cann't read reply data"}; } - + if(reply.ru.RM_rmb.rp_stat == reply_stat::MSG_ACCEPTED && reply.ru.RM_rmb.ru.RP_ar.ar_stat == accept_stat::SUCCESS) { // fill reply results - if(!proc_t_of(res)(r.xdr(),&res)) + if(!proc_t_of(res)(r.xdr(), &res)) { - xdr_free((xdrproc_t)proc_t_of(res), (char*)&res ); - xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); - xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg ); - xdr_free((xdrproc_t)xdr_callmsg, (char*)&call ); + xdr_free((xdrproc_t)proc_t_of(res), (char*)&res); + xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); + xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg); + xdr_free((xdrproc_t)xdr_callmsg, (char*)&call); throw xdr::XDRDecoderError{"XDRDecoder: cann't read reply results"}; } } @@ -108,10 +106,10 @@ public: inline ~NFSProcedure() { - if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res ); - xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); - xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg ); - xdr_free((xdrproc_t)xdr_callmsg, (char*)&call ); + if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res); + xdr_free((xdrproc_t)xdr_replymsg, (char*)&reply); + xdr_free((xdrproc_t)proc_t_of(arg), (char*)&arg); + xdr_free((xdrproc_t)xdr_callmsg, (char*)&call); } // pointers to procedure specific argument and result @@ -120,12 +118,13 @@ public: private: inline static bool_t return_true(XDR*, void*, ...) { return 1; } - inline static bool_t return_true(XDR*, ...) { return 1; } - - ArgType arg; - ResType res; + inline static bool_t return_true(XDR*, ...) { return 1; } + ArgType arg; + ResType res; }; +// clang-format off + namespace NFS3 { namespace NFS3 = NST::API::NFS3; @@ -167,8 +166,10 @@ using NFSPROC41RPCGEN_NULL = NFSProcedure <NFS41::NULL4args, NFS41::NULL using NFSPROC41RPCGEN_COMPOUND = NFSProcedure <NFS41::COMPOUND4args, NFS41::COMPOUND4res>; } +// clang-format on + } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS_PROCEDURE_H +#endif // NFS_PROCEDURE_H //------------------------------------------------------------------------------ diff --git a/src/protocols/nfs/nfs_utils.cpp b/src/protocols/nfs/nfs_utils.cpp index a2517b9..466dd25 100644 --- a/src/protocols/nfs/nfs_utils.cpp +++ b/src/protocols/nfs/nfs_utils.cpp @@ -21,6 +21,7 @@ //------------------------------------------------------------------------------ #include <iomanip> +#include "api/plugin_api.h" // for NST_PUBLIC #include "protocols/nfs/nfs_utils.h" //------------------------------------------------------------------------------ namespace NST @@ -29,7 +30,6 @@ namespace protocols { namespace NFS { - void print_hex64(std::ostream& out, uint64_t val) { @@ -52,17 +52,16 @@ void print_hex16(std::ostream& out, uint16_t val) void print_hex8(std::ostream& out, uint8_t val) { out << "0x" << std::setfill('0') << std::setw(2) << std::hex - << static_cast<u_int16_t>(val) // prevent implicit cast to char + << static_cast<u_int16_t>(val) // prevent implicit cast to char << std::dec << std::setfill(' '); } - void print_hex(std::ostream& out, const uint32_t* const val, const uint32_t len) { - if (len) + if(len) { out << std::hex << std::setfill('0') << "0x"; - for (uint32_t i {0}; i < len; i++) + for(uint32_t i{0}; i < len; i++) { out << std::setw(2) << val[i]; } @@ -76,10 +75,10 @@ void print_hex(std::ostream& out, const uint32_t* const val, const uint32_t len) void print_hex(std::ostream& out, const char* const val, const uint32_t len) { - if (len) + if(len) { out << std::hex << std::setfill('0') << "0x"; - for (uint32_t i {0}; i < len; i++) + for(uint32_t i{0}; i < len; i++) { out << std::setw(2) << ((static_cast<int32_t>(val[i])) & 0xFF); @@ -92,14 +91,14 @@ void print_hex(std::ostream& out, const char* const val, const uint32_t len) } } -void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len) +extern "C" NST_PUBLIC void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len) { - if (len) + if(len) { out << std::hex << std::setfill('0'); - if (len <= 8 || out_all()) + if(len <= 8 || out_all()) { - for (uint32_t i {0}; i < len; i++) + for(uint32_t i{0}; i < len; i++) { out << std::setw(2) << ((static_cast<int32_t>(val[i])) & 0xFF); @@ -107,13 +106,13 @@ void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len) } else // truncate binary data to: 00112233...CCDDEEFF { - for (uint32_t i {0}; i < 4; i++) + for(uint32_t i{0}; i < 4; i++) { out << std::setw(2) << ((static_cast<int32_t>(val[i])) & 0xFF); } out << "..."; - for (uint32_t i {len - 4}; i < len; i++) + for(uint32_t i{len - 4}; i < len; i++) { out << std::setw(2) << ((static_cast<int32_t>(val[i])) & 0xFF); diff --git a/src/protocols/nfs/nfs_utils.h b/src/protocols/nfs/nfs_utils.h index f4bedf4..9f395b8 100644 --- a/src/protocols/nfs/nfs_utils.h +++ b/src/protocols/nfs/nfs_utils.h @@ -22,13 +22,12 @@ #ifndef NFS_UTILS_H #define NFS_UTILS_H //------------------------------------------------------------------------------ -#include <ostream> -#include <iomanip> #include <cstring> +#include <iomanip> +#include <ostream> #include "utils/out.h" //------------------------------------------------------------------------------ -#define NST_PUBLIC __attribute__ ((visibility("default"))) //------------------------------------------------------------------------------ namespace NST { @@ -36,7 +35,6 @@ namespace protocols { namespace NFS { - inline bool out_all() { using Out = NST::utils::Out; @@ -44,24 +42,23 @@ inline bool out_all() return Out::Global::get_level() == Out::Level::All; } -namespace +namespace { template <typename T> struct Helper -{ +{ static void print_hex(std::ostream& out, T val) { - out << "0x" << std::setfill('0') << std::setw(sizeof(T)/4) << std::hex << val + out << "0x" << std::setfill('0') << std::setw(sizeof(T) / 4) << std::hex << val << std::dec << std::setfill(' '); } }; template <> struct Helper<uint8_t> -{ +{ static void print_hex(std::ostream& out, char val) { - out << "0x" << std::setfill('0') << std::setw(4) << std::hex << - static_cast<uint16_t>(val) << std::dec << std::setfill(' '); + out << "0x" << std::setfill('0') << std::setw(4) << std::hex << static_cast<uint16_t>(val) << std::dec << std::setfill(' '); } }; } @@ -70,7 +67,7 @@ template <typename T> void print_hex(std::ostream& out, T val) { Helper<T>::print_hex(out, val); -} +} void print_hex64(std::ostream& out, uint64_t val); @@ -78,25 +75,19 @@ void print_hex32(std::ostream& out, uint32_t val); void print_hex16(std::ostream& out, uint16_t val); -void print_hex8(std::ostream& out, uint8_t val); - -void print_hex(std::ostream& out, - const uint32_t* const val, - const uint32_t len); +void print_hex8(std::ostream& out, uint8_t val); -void print_hex(std::ostream& out, - const char* const val, - const uint32_t len); +void print_hex(std::ostream& out, + const uint32_t* const val, + const uint32_t len); -extern "C" -NST_PUBLIC -void print_nfs_fh(std::ostream& out, - const char* const val, - const uint32_t len); +void print_hex(std::ostream& out, + const char* const val, + const uint32_t len); } // namespace NFS } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS_UTILS_H +#endif // NFS_UTILS_H //------------------------------------------------------------------------------ diff --git a/src/protocols/nfs3/nfs3_utils.cpp b/src/protocols/nfs3/nfs3_utils.cpp index 50a0961..89c2473 100644 --- a/src/protocols/nfs3/nfs3_utils.cpp +++ b/src/protocols/nfs3/nfs3_utils.cpp @@ -19,8 +19,9 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ -#include "protocols/nfs/nfs_utils.h" #include "protocols/nfs3/nfs3_utils.h" +#include "api/plugin_api.h" // for NST_PUBLIC +#include "protocols/nfs/nfs_utils.h" //------------------------------------------------------------------------------ using namespace NST::API::NFS3; using namespace NST::protocols::NFS; @@ -32,9 +33,9 @@ namespace protocols { namespace NFS3 { - -const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc) +extern "C" NST_PUBLIC const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc) { + // clang-format off static const char* const NFS3ProcedureTitles[ProcEnumNFS3::count] = { "NULL", "GETATTR", "SETATTR", "LOOKUP", @@ -44,6 +45,7 @@ const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc) "READDIR", "READDIRPLUS", "FSSTAT", "FSINFO", "PATHCONF", "COMMIT" }; + // clang-format on return NFS3ProcedureTitles[proc]; } @@ -61,33 +63,33 @@ enum S_IXGRP = 0x00008, // Search in directory S_IROTH = 0x00004, S_IWOTH = 0x00002, - S_IXOTH = 0x00001 // Search in directory + S_IXOTH = 0x00001 // Search in directory }; void print_mode3(std::ostream& out, const uint32 val) { - if (val & S_ISUID) out << "USER_ID_EXEC "; - if (val & S_ISGID) out << "GROUP_ID_EXEC "; - if (val & S_ISVTX) out << "SAVE_SWAPPED_TEXT "; - if (val & S_IRUSR) out << "OWNER_READ "; - if (val & S_IWUSR) out << "OWNER_WRITE "; - if (val & S_IXUSR) out << "OWNER_EXEC "; - if (val & S_IRGRP) out << "GROUP_READ "; - if (val & S_IWGRP) out << "GROUP_WRITE "; - if (val & S_IXGRP) out << "GROUP_EXEC "; - if (val & S_IROTH) out << "OTHER_READ "; - if (val & S_IWOTH) out << "OTHER_WRITE "; - if (val & S_IXOTH) out << "OTHER_EXEC"; + if(val & S_ISUID) out << "USER_ID_EXEC "; + if(val & S_ISGID) out << "GROUP_ID_EXEC "; + if(val & S_ISVTX) out << "SAVE_SWAPPED_TEXT "; + if(val & S_IRUSR) out << "OWNER_READ "; + if(val & S_IWUSR) out << "OWNER_WRITE "; + if(val & S_IXUSR) out << "OWNER_EXEC "; + if(val & S_IRGRP) out << "GROUP_READ "; + if(val & S_IWGRP) out << "GROUP_WRITE "; + if(val & S_IXGRP) out << "GROUP_EXEC "; + if(val & S_IROTH) out << "OTHER_READ "; + if(val & S_IWOTH) out << "OTHER_WRITE "; + if(val & S_IXOTH) out << "OTHER_EXEC"; } void print_access3(std::ostream& out, const uint32 val) { - if (val & ACCESS3_READ) out << "READ "; - if (val & ACCESS3_LOOKUP) out << "LOOKUP "; - if (val & ACCESS3_MODIFY) out << "MODIFY "; - if (val & ACCESS3_EXTEND) out << "EXTEND "; - if (val & ACCESS3_DELETE) out << "DELETE "; - if (val & ACCESS3_EXECUTE) out << "EXECUTE "; + if(val & ACCESS3_READ) out << "READ "; + if(val & ACCESS3_LOOKUP) out << "LOOKUP "; + if(val & ACCESS3_MODIFY) out << "MODIFY "; + if(val & ACCESS3_EXTEND) out << "EXTEND "; + if(val & ACCESS3_DELETE) out << "DELETE "; + if(val & ACCESS3_EXECUTE) out << "EXECUTE "; } std::ostream& operator<<(std::ostream& out, const nfsstat3& obj) @@ -160,13 +162,20 @@ std::ostream& operator<<(std::ostream& out, const ftype3& obj) { switch(obj) { - case ftype3::NF3REG: return out << "REG"; - case ftype3::NF3DIR: return out << "DIR"; - case ftype3::NF3BLK: return out << "BLK"; - case ftype3::NF3CHR: return out << "CHR"; - case ftype3::NF3LNK: return out << "LNK"; - case ftype3::NF3SOCK: return out << "SOCK"; - case ftype3::NF3FIFO: return out << "FIFO"; + case ftype3::NF3REG: + return out << "REG"; + case ftype3::NF3DIR: + return out << "DIR"; + case ftype3::NF3BLK: + return out << "BLK"; + case ftype3::NF3CHR: + return out << "CHR"; + case ftype3::NF3LNK: + return out << "LNK"; + case ftype3::NF3SOCK: + return out << "SOCK"; + case ftype3::NF3FIFO: + return out << "FIFO"; } return out; } @@ -179,13 +188,13 @@ std::ostream& operator<<(std::ostream& out, const specdata3& obj) std::ostream& operator<<(std::ostream& out, const nfs_fh3& obj) { - NFS::print_nfs_fh(out, obj.data.data_val, obj.data.data_len); + print_nfs_fh(out, obj.data.data_val, obj.data.data_len); return out; } std::ostream& operator<<(std::ostream& out, const nfstime3& obj) { - return out << "seconds: " << obj.seconds + return out << "seconds: " << obj.seconds << " nseconds: " << obj.nseconds << ' '; } @@ -194,39 +203,43 @@ std::ostream& operator<<(std::ostream& out, const fattr3& obj) out << " type: " << obj.type << " mode: "; - print_mode3(out,obj.mode); + print_mode3(out, obj.mode); - out << " nlink: " << obj.nlink - << " uid: " << obj.uid - << " gid: " << obj.gid - << " size: " << obj.size - << " used: " << obj.used - << " rdev: " << obj.rdev - << " fsid: " << obj.fsid + out << " nlink: " << obj.nlink + << " uid: " << obj.uid + << " gid: " << obj.gid + << " size: " << obj.size + << " used: " << obj.used + << " rdev: " << obj.rdev + << " fsid: " << obj.fsid << " fileid: " << obj.fileid - << " atime: " << obj.atime - << " mtime: " << obj.mtime - << " ctime: " << obj.ctime; + << " atime: " << obj.atime + << " mtime: " << obj.mtime + << " ctime: " << obj.ctime; return out; } std::ostream& operator<<(std::ostream& out, const post_op_attr& obj) { - if(obj.attributes_follow) return out << obj.post_op_attr_u.attributes; - else return out << " void "; + if(obj.attributes_follow) + return out << obj.post_op_attr_u.attributes; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const wcc_attr& obj) { - return out << " size: " << obj.size + return out << " size: " << obj.size << " mtime: " << obj.mtime << " ctime: " << obj.ctime; } std::ostream& operator<<(std::ostream& out, const pre_op_attr& obj) { - if(obj.attributes_follow) return out << obj.pre_op_attr_u.attributes; - else return out << " void "; + if(obj.attributes_follow) + return out << obj.pre_op_attr_u.attributes; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const wcc_data& obj) @@ -236,9 +249,11 @@ std::ostream& operator<<(std::ostream& out, const wcc_data& obj) std::ostream& operator<<(std::ostream& out, const post_op_fh3& obj) { - if(obj.handle_follows) return out << " handle: " - << obj.post_op_fh3_u.handle; - else return out << " void "; + if(obj.handle_follows) + return out << " handle: " + << obj.post_op_fh3_u.handle; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const time_how& obj) @@ -257,40 +272,50 @@ std::ostream& operator<<(std::ostream& out, const time_how& obj) std::ostream& operator<<(std::ostream& out, const set_mode3& obj) { - if(obj.set_it) return out << obj.set_mode3_u.mode; - else return out << " void "; + if(obj.set_it) + return out << obj.set_mode3_u.mode; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const set_uid3& obj) { - if(obj.set_it) return out << obj.set_uid3_u.uid; - else return out << " void "; + if(obj.set_it) + return out << obj.set_uid3_u.uid; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const set_gid3& obj) { - if(obj.set_it) return out << obj.set_gid3_u.gid; - else return out << " void "; + if(obj.set_it) + return out << obj.set_gid3_u.gid; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const set_size3& obj) { - if(obj.set_it) return out << obj.set_size3_u.size; - else return out << " void "; + if(obj.set_it) + return out << obj.set_size3_u.size; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const set_atime& obj) { if(obj.set_it == time_how::SET_TO_CLIENT_TIME) - return out << obj.set_it << " " << obj.set_atime_u.atime; - else return out << obj.set_it; + return out << obj.set_it << " " << obj.set_atime_u.atime; + else + return out << obj.set_it; } std::ostream& operator<<(std::ostream& out, const set_mtime& obj) { if(obj.set_it == time_how::SET_TO_CLIENT_TIME) - return out << obj.set_it << " " << obj.set_mtime_u.mtime; - else return out << obj.set_it; + return out << obj.set_it << " " << obj.set_mtime_u.mtime; + else + return out << obj.set_it; } std::ostream& operator<<(std::ostream& out, const sattr3& obj) @@ -301,9 +326,9 @@ std::ostream& operator<<(std::ostream& out, const sattr3& obj) print_mode3(out, obj.mode.set_mode3_u.mode); } - if(obj.uid.set_it) out << " uid: " << obj.uid.set_uid3_u.uid; - if(obj.gid.set_it) out << " gid: " << obj.gid.set_gid3_u.gid; - if(obj.size.set_it) out << " size: " << obj.size.set_size3_u.size; + if(obj.uid.set_it) out << " uid: " << obj.uid.set_uid3_u.uid; + if(obj.gid.set_it) out << " gid: " << obj.gid.set_gid3_u.gid; + if(obj.size.set_it) out << " size: " << obj.size.set_size3_u.size; if(obj.atime.set_it == time_how::SET_TO_CLIENT_TIME) out << " atime: " << obj.atime.set_atime_u.atime; if(obj.mtime.set_it == time_how::SET_TO_CLIENT_TIME) @@ -314,23 +339,28 @@ std::ostream& operator<<(std::ostream& out, const sattr3& obj) std::ostream& operator<<(std::ostream& out, const diropargs3& obj) { - return out << " dir: " << obj.dir + return out << " dir: " << obj.dir << " name: " << obj.name; } std::ostream& operator<<(std::ostream& out, const sattrguard3& obj) { - if(obj.check) return out << " obj_ctime: " << obj.sattrguard3_u.obj_ctime; - else return out << " void "; + if(obj.check) + return out << " obj_ctime: " << obj.sattrguard3_u.obj_ctime; + else + return out << " void "; } std::ostream& operator<<(std::ostream& out, const stable_how& obj) { switch(obj) { - case stable_how::UNSTABLE: return out << "UNSTABLE"; - case stable_how::DATA_SYNC: return out << "DATA_SYNC"; - case stable_how::FILE_SYNC: return out << "FILE_SYNC"; + case stable_how::UNSTABLE: + return out << "UNSTABLE"; + case stable_how::DATA_SYNC: + return out << "DATA_SYNC"; + case stable_how::FILE_SYNC: + return out << "FILE_SYNC"; } return out; } @@ -339,9 +369,12 @@ std::ostream& operator<<(std::ostream& out, const createmode3& obj) { switch(obj) { - case createmode3::UNCHECKED: return out << "UNCHECKED"; - case createmode3::GUARDED: return out << "GUARDED"; - case createmode3::EXCLUSIVE: return out << "EXCLUSIVE"; + case createmode3::UNCHECKED: + return out << "UNCHECKED"; + case createmode3::GUARDED: + return out << "GUARDED"; + case createmode3::EXCLUSIVE: + return out << "EXCLUSIVE"; } return out; } @@ -365,16 +398,15 @@ std::ostream& operator<<(std::ostream& out, const createhow3& obj) std::ostream& operator<<(std::ostream& out, const symlinkdata3& obj) { return out << " symlink_attributes: " << obj.symlink_attributes - << " symlink_data: " << obj.symlink_data; + << " symlink_data: " << obj.symlink_data; } std::ostream& operator<<(std::ostream& out, const devicedata3& obj) { return out << " dev_attributes: " << obj.dev_attributes - << " spec: " << obj.spec; + << " spec: " << obj.spec; } - std::ostream& operator<<(std::ostream& out, const mknoddata3& obj) { out << " type: " << obj.type; @@ -382,38 +414,39 @@ std::ostream& operator<<(std::ostream& out, const mknoddata3& obj) { case ftype3::NF3CHR: case ftype3::NF3BLK: - return out << " device: " << obj.mknoddata3_u.device; + return out << " device: " << obj.mknoddata3_u.device; case ftype3::NF3SOCK: case ftype3::NF3FIFO: return out << " pipe_attributes: " << obj.mknoddata3_u.pipe_attributes; - default: break; + default: + break; } - return out; + return out; } std::ostream& operator<<(std::ostream& out, const entry3& obj) { - out << " file id: " << obj.fileid - << " name: " << obj.name - << " cookie: " << obj.cookie << '\n'; + out << " file id: " << obj.fileid + << " name: " << obj.name + << " cookie: " << obj.cookie << '\n'; if(obj.nextentry) out << *obj.nextentry; return out; } std::ostream& operator<<(std::ostream& out, const dirlist3& obj) { - out << " eof: " << obj.eof; + out << " eof: " << obj.eof; if(obj.entries) out << *obj.entries; return out; } std::ostream& operator<<(std::ostream& out, const entryplus3& obj) { - out << " file id: " << obj.fileid - << " name: " << obj.name + out << " file id: " << obj.fileid + << " name: " << obj.name << " name attributes: " << obj.name_attributes - << " name handle: " << obj.name_handle - << " cookie: " << obj.cookie << '\n'; + << " name handle: " << obj.name_handle + << " cookie: " << obj.cookie << '\n'; if(obj.nextentry) out << *obj.nextentry; return out; } @@ -425,6 +458,8 @@ std::ostream& operator<<(std::ostream& out, const dirlistplus3& obj) return out; } +// clang-format off + bool_t xdr_uint64 (XDR* xdrs, uint64* objp) { @@ -2862,6 +2897,8 @@ xdr_COMMIT3res (XDR* xdrs, COMMIT3res* objp) return TRUE; } +// clang-format on + } // namespace NFS3 } // namespace protocols } // namespace NST diff --git a/src/protocols/nfs3/nfs3_utils.h b/src/protocols/nfs3/nfs3_utils.h index 8b16806..c738c50 100644 --- a/src/protocols/nfs3/nfs3_utils.h +++ b/src/protocols/nfs3/nfs3_utils.h @@ -25,13 +25,12 @@ #include <cassert> #include <ostream> -#include "api/nfs_types.h" #include "api/nfs3_types_rpcgen.h" +#include "api/nfs_types.h" -#include "protocols/xdr/xdr_decoder.h" #include "protocols/rpc/rpc_header.h" +#include "protocols/xdr/xdr_decoder.h" //------------------------------------------------------------------------------ -#define NST_PUBLIC __attribute__ ((visibility("default"))) //------------------------------------------------------------------------------ namespace NST { @@ -39,19 +38,18 @@ namespace protocols { namespace NFS3 { - namespace NFS3 = NST::API::NFS3; using ProcEnumNFS3 = API::ProcEnumNFS3; -using Validator = rpc::RPCProgramValidator - < - 100003, // SunRPC/NFS program - 3, // v3 - ProcEnumNFS3::NFS_NULL, // NFSPROC3_NULL - ProcEnumNFS3::COMMIT // NFSPROC3_COMMIT - >; +using Validator = rpc::RPCProgramValidator< + 100003, // SunRPC/NFS program + 3, // v3 + ProcEnumNFS3::NFS_NULL, // NFSPROC3_NULL + ProcEnumNFS3::COMMIT // NFSPROC3_COMMIT + >; +// clang-format off bool_t xdr_uint64 (XDR *, NFS3::uint64*); bool_t xdr_uint32 (XDR *, NFS3::uint32*); bool_t xdr_int64 (XDR *, NFS3::int64*); @@ -185,253 +183,250 @@ bool_t xdr_COMMIT3args (XDR *, NFS3::COMMIT3args*); bool_t xdr_COMMIT3resok (XDR *, NFS3::COMMIT3resok*); bool_t xdr_COMMIT3resfail (XDR *, NFS3::COMMIT3resfail*); bool_t xdr_COMMIT3res (XDR *, NFS3::COMMIT3res*); +// clang-format on // Procedure 0: NULL - Do nothing -inline auto proc_t_of(NFS3::NULL3args&)->decltype(&xdr_NULL3args) +inline auto proc_t_of(NFS3::NULL3args&) -> decltype(&xdr_NULL3args) { return &xdr_NULL3args; } -inline auto proc_t_of(NFS3::NULL3res&)->decltype(&xdr_NULL3res) +inline auto proc_t_of(NFS3::NULL3res&) -> decltype(&xdr_NULL3res) { return &xdr_NULL3res; } // Procedure 1: GETATTR - Get file attributes -inline auto proc_t_of(NFS3::GETATTR3args&)->decltype(&xdr_GETATTR3args) +inline auto proc_t_of(NFS3::GETATTR3args&) -> decltype(&xdr_GETATTR3args) { return &xdr_GETATTR3args; } -inline auto proc_t_of(NFS3::GETATTR3res&)->decltype(&xdr_GETATTR3res) +inline auto proc_t_of(NFS3::GETATTR3res&) -> decltype(&xdr_GETATTR3res) { return &xdr_GETATTR3res; } // Procedure 2: SETATTR - Set file attributes -inline auto proc_t_of(NFS3::SETATTR3args&)->decltype(&xdr_SETATTR3args) +inline auto proc_t_of(NFS3::SETATTR3args&) -> decltype(&xdr_SETATTR3args) { return &xdr_SETATTR3args; } -inline auto proc_t_of(NFS3::SETATTR3res&)->decltype(&xdr_SETATTR3res) +inline auto proc_t_of(NFS3::SETATTR3res&) -> decltype(&xdr_SETATTR3res) { return &xdr_SETATTR3res; } // Procedure 3: LOOKUP - Lookup filename -inline auto proc_t_of(NFS3::LOOKUP3args&)->decltype(&xdr_LOOKUP3args) +inline auto proc_t_of(NFS3::LOOKUP3args&) -> decltype(&xdr_LOOKUP3args) { return &xdr_LOOKUP3args; } -inline auto proc_t_of(NFS3::LOOKUP3res&)->decltype(&xdr_LOOKUP3res) +inline auto proc_t_of(NFS3::LOOKUP3res&) -> decltype(&xdr_LOOKUP3res) { return &xdr_LOOKUP3res; } // Procedure 4: ACCESS - Check Access Permission -inline auto proc_t_of(NFS3::ACCESS3args&)->decltype(&xdr_ACCESS3args) +inline auto proc_t_of(NFS3::ACCESS3args&) -> decltype(&xdr_ACCESS3args) { return &xdr_ACCESS3args; } -inline auto proc_t_of(NFS3::ACCESS3res&)->decltype(&xdr_ACCESS3res) +inline auto proc_t_of(NFS3::ACCESS3res&) -> decltype(&xdr_ACCESS3res) { return &xdr_ACCESS3res; } // Procedure 5: READLINK - Read from symbolic link -inline auto proc_t_of(NFS3::READLINK3args&)->decltype(&xdr_READLINK3args) +inline auto proc_t_of(NFS3::READLINK3args&) -> decltype(&xdr_READLINK3args) { return &xdr_READLINK3args; } -inline auto proc_t_of(NFS3::READLINK3res&)->decltype(&xdr_READLINK3res) +inline auto proc_t_of(NFS3::READLINK3res&) -> decltype(&xdr_READLINK3res) { return &xdr_READLINK3res; } // Procedure 6: READ - Read From file -inline auto proc_t_of(NFS3::READ3args&)->decltype(&xdr_READ3args) +inline auto proc_t_of(NFS3::READ3args&) -> decltype(&xdr_READ3args) { return &xdr_READ3args; } -inline auto proc_t_of(NFS3::READ3res&)->decltype(&xdr_READ3res) +inline auto proc_t_of(NFS3::READ3res&) -> decltype(&xdr_READ3res) { return &xdr_READ3res; } // Procedure 7: WRITE - Write to file -inline auto proc_t_of(NFS3::WRITE3args&)->decltype(&xdr_WRITE3args) +inline auto proc_t_of(NFS3::WRITE3args&) -> decltype(&xdr_WRITE3args) { return &xdr_WRITE3args; } -inline auto proc_t_of(NFS3::WRITE3res&)->decltype(&xdr_WRITE3res) +inline auto proc_t_of(NFS3::WRITE3res&) -> decltype(&xdr_WRITE3res) { return &xdr_WRITE3res; } // Procedure 8: CREATE - Create a file -inline auto proc_t_of(NFS3::CREATE3args&)->decltype(&xdr_CREATE3args) +inline auto proc_t_of(NFS3::CREATE3args&) -> decltype(&xdr_CREATE3args) { return &xdr_CREATE3args; } -inline auto proc_t_of(NFS3::CREATE3res&)->decltype(&xdr_CREATE3res) +inline auto proc_t_of(NFS3::CREATE3res&) -> decltype(&xdr_CREATE3res) { return &xdr_CREATE3res; } // Procedure 9: MKDIR - Create a directory -inline auto proc_t_of(NFS3::MKDIR3args&)->decltype(&xdr_MKDIR3args) +inline auto proc_t_of(NFS3::MKDIR3args&) -> decltype(&xdr_MKDIR3args) { return &xdr_MKDIR3args; } -inline auto proc_t_of(NFS3::MKDIR3res&)->decltype(&xdr_MKDIR3res) +inline auto proc_t_of(NFS3::MKDIR3res&) -> decltype(&xdr_MKDIR3res) { return &xdr_MKDIR3res; } // Procedure 10: SYMLINK - Create a symbolic link -inline auto proc_t_of(NFS3::SYMLINK3args&)->decltype(&xdr_SYMLINK3args) +inline auto proc_t_of(NFS3::SYMLINK3args&) -> decltype(&xdr_SYMLINK3args) { return &xdr_SYMLINK3args; } -inline auto proc_t_of(NFS3::SYMLINK3res&)->decltype(&xdr_SYMLINK3res) +inline auto proc_t_of(NFS3::SYMLINK3res&) -> decltype(&xdr_SYMLINK3res) { return &xdr_SYMLINK3res; } // Procedure 11: MKNOD - Create a special device -inline auto proc_t_of(NFS3::MKNOD3args&)->decltype(&xdr_MKNOD3args) +inline auto proc_t_of(NFS3::MKNOD3args&) -> decltype(&xdr_MKNOD3args) { return &xdr_MKNOD3args; } -inline auto proc_t_of(NFS3::MKNOD3res&)->decltype(&xdr_MKNOD3res) +inline auto proc_t_of(NFS3::MKNOD3res&) -> decltype(&xdr_MKNOD3res) { return &xdr_MKNOD3res; } // Procedure 12: REMOVE - Remove a File -inline auto proc_t_of(NFS3::REMOVE3args&)->decltype(&xdr_REMOVE3args) +inline auto proc_t_of(NFS3::REMOVE3args&) -> decltype(&xdr_REMOVE3args) { return &xdr_REMOVE3args; } -inline auto proc_t_of(NFS3::REMOVE3res&)->decltype(&xdr_REMOVE3res) +inline auto proc_t_of(NFS3::REMOVE3res&) -> decltype(&xdr_REMOVE3res) { return &xdr_REMOVE3res; } // Procedure 13: RMDIR - Remove a Directory -inline auto proc_t_of(NFS3::RMDIR3args&)->decltype(&xdr_RMDIR3args) +inline auto proc_t_of(NFS3::RMDIR3args&) -> decltype(&xdr_RMDIR3args) { return &xdr_RMDIR3args; } -inline auto proc_t_of(NFS3::RMDIR3res&)->decltype(&xdr_RMDIR3res) +inline auto proc_t_of(NFS3::RMDIR3res&) -> decltype(&xdr_RMDIR3res) { return &xdr_RMDIR3res; } // Procedure 14: RENAME - Rename a File or Directory -inline auto proc_t_of(NFS3::RENAME3args&)->decltype(&xdr_RENAME3args) +inline auto proc_t_of(NFS3::RENAME3args&) -> decltype(&xdr_RENAME3args) { return &xdr_RENAME3args; } -inline auto proc_t_of(NFS3::RENAME3res&)->decltype(&xdr_RENAME3res) +inline auto proc_t_of(NFS3::RENAME3res&) -> decltype(&xdr_RENAME3res) { return &xdr_RENAME3res; } // Procedure 15: LINK - Create Link to an object -inline auto proc_t_of(NFS3::LINK3args&)->decltype(&xdr_LINK3args) +inline auto proc_t_of(NFS3::LINK3args&) -> decltype(&xdr_LINK3args) { return &xdr_LINK3args; } -inline auto proc_t_of(NFS3::LINK3res&)->decltype(&xdr_LINK3res) +inline auto proc_t_of(NFS3::LINK3res&) -> decltype(&xdr_LINK3res) { return &xdr_LINK3res; } // Procedure 16: READDIR - Read From Directory -inline auto proc_t_of(NFS3::READDIR3args&)->decltype(&xdr_READDIR3args) +inline auto proc_t_of(NFS3::READDIR3args&) -> decltype(&xdr_READDIR3args) { return &xdr_READDIR3args; } -inline auto proc_t_of(NFS3::READDIR3res&)->decltype(&xdr_READDIR3res) +inline auto proc_t_of(NFS3::READDIR3res&) -> decltype(&xdr_READDIR3res) { return &xdr_READDIR3res; } // Procedure 17: READDIRPLUS - Extended read from directory -inline auto proc_t_of(NFS3::READDIRPLUS3args&)->decltype(&xdr_READDIRPLUS3args) +inline auto proc_t_of(NFS3::READDIRPLUS3args&) -> decltype(&xdr_READDIRPLUS3args) { return &xdr_READDIRPLUS3args; } -inline auto proc_t_of(NFS3::READDIRPLUS3res&)->decltype(&xdr_READDIRPLUS3res) +inline auto proc_t_of(NFS3::READDIRPLUS3res&) -> decltype(&xdr_READDIRPLUS3res) { return &xdr_READDIRPLUS3res; } // Procedure 18: FSSTAT - Get dynamic file system information -inline auto proc_t_of(NFS3::FSSTAT3args&)->decltype(&xdr_FSSTAT3args) +inline auto proc_t_of(NFS3::FSSTAT3args&) -> decltype(&xdr_FSSTAT3args) { return &xdr_FSSTAT3args; } -inline auto proc_t_of(NFS3::FSSTAT3res&)->decltype(&xdr_FSSTAT3res) +inline auto proc_t_of(NFS3::FSSTAT3res&) -> decltype(&xdr_FSSTAT3res) { return &xdr_FSSTAT3res; } // Procedure 19: FSINFO - Get static file system Information -inline auto proc_t_of(NFS3::FSINFO3args&)->decltype(&xdr_FSINFO3args) +inline auto proc_t_of(NFS3::FSINFO3args&) -> decltype(&xdr_FSINFO3args) { return &xdr_FSINFO3args; } -inline auto proc_t_of(NFS3::FSINFO3res&)->decltype(&xdr_FSINFO3res) +inline auto proc_t_of(NFS3::FSINFO3res&) -> decltype(&xdr_FSINFO3res) { return &xdr_FSINFO3res; } // Procedure 20: PATHCONF - Retrieve POSIX information -inline auto proc_t_of(NFS3::PATHCONF3args&)->decltype(&xdr_PATHCONF3args) +inline auto proc_t_of(NFS3::PATHCONF3args&) -> decltype(&xdr_PATHCONF3args) { return &xdr_PATHCONF3args; } -inline auto proc_t_of(NFS3::PATHCONF3res&)->decltype(&xdr_PATHCONF3res) +inline auto proc_t_of(NFS3::PATHCONF3res&) -> decltype(&xdr_PATHCONF3res) { return &xdr_PATHCONF3res; } // Procedure 21: COMMIT - Commit cached data on a server to stable storage -inline auto proc_t_of(NFS3::COMMIT3args&)->decltype(&xdr_COMMIT3args) +inline auto proc_t_of(NFS3::COMMIT3args&) -> decltype(&xdr_COMMIT3args) { return &xdr_COMMIT3args; } -inline auto proc_t_of(NFS3::COMMIT3res&)->decltype(&xdr_COMMIT3res) +inline auto proc_t_of(NFS3::COMMIT3res&) -> decltype(&xdr_COMMIT3res) { return &xdr_COMMIT3res; } -extern "C" -NST_PUBLIC -const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc); - std::ostream& operator<<(std::ostream& out, const ProcEnumNFS3::NFSProcedure proc); void print_mode3(std::ostream& out, const NFS3::uint32 val); @@ -472,5 +467,5 @@ std::ostream& operator<<(std::ostream& out, const NFS3::dirlistplus3& obj); } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS3_UTILS_H +#endif // NFS3_UTILS_H //------------------------------------------------------------------------------ diff --git a/src/protocols/nfs4/nfs41_utils.cpp b/src/protocols/nfs4/nfs41_utils.cpp index f90c42f..2cd7d56 100644 --- a/src/protocols/nfs4/nfs41_utils.cpp +++ b/src/protocols/nfs4/nfs41_utils.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Author: Alexey Costroma +// Author: Alexey Costroma // Description: Helpers for parsing NFS structures. // Copyright (c) 2014 EPAM Systems //------------------------------------------------------------------------------ @@ -21,11 +21,12 @@ //------------------------------------------------------------------------------ #include <iomanip> +#include "api/plugin_api.h" // for NST_PUBLIC #include "protocols/nfs/nfs_utils.h" #include "protocols/nfs4/nfs41_utils.h" //------------------------------------------------------------------------------ using namespace NST::API::NFS41; -using namespace NST::protocols::NFS; // NFS helpers +using namespace NST::protocols::NFS; // NFS helpers //------------------------------------------------------------------------------ namespace NST { @@ -33,13 +34,14 @@ namespace protocols { namespace NFS41 { +// clang-format off std::ostream& operator<<(std::ostream& out, const ProcEnumNFS41::NFSProcedure proc) { return out << print_nfs41_procedures(proc); } -const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc) +extern "C" NST_PUBLIC const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc) { // In all cases we suppose, that NFSv4 operation ILLEGAL(10044) // has the second position in ProcEnumNFS41 @@ -346,9 +348,9 @@ std::ostream& operator<<(std::ostream& out, const bitmap4& obj) std::ostream& operator<<(std::ostream& out, const nfs_fh4& obj) { - NFS::print_nfs_fh(out, - obj.nfs_fh4_val, - obj.nfs_fh4_len); + print_nfs_fh(out, + obj.nfs_fh4_val, + obj.nfs_fh4_len); return out; } @@ -8685,6 +8687,8 @@ xdr_CB_COMPOUND4res (XDR* xdrs, CB_COMPOUND4res* objp) return TRUE; } +// clang-format on + } // namespace NFS41 } // namespace protocols } // namespace NST diff --git a/src/protocols/nfs4/nfs41_utils.h b/src/protocols/nfs4/nfs41_utils.h index 77c42ea..4cf292f 100644 --- a/src/protocols/nfs4/nfs41_utils.h +++ b/src/protocols/nfs4/nfs41_utils.h @@ -24,8 +24,8 @@ //------------------------------------------------------------------------------ #include <ostream> -#include "api/nfs_types.h" #include "api/nfs41_types_rpcgen.h" +#include "api/nfs_types.h" #include "protocols/nfs/nfs_utils.h" #include "protocols/rpc/rpc_header.h" //------------------------------------------------------------------------------ @@ -35,19 +35,18 @@ namespace protocols { namespace NFS41 { - namespace NFS41 = NST::API::NFS41; using ProcEnumNFS41 = API::ProcEnumNFS41; -using Validator = rpc::RPCProgramValidator - < - 100003, // SunRPC/NFS program - 4, // v4 - ProcEnumNFS41::NFS_NULL, // NFSPROC41RPCGEN_NULL (0) - ProcEnumNFS41::COMPOUND // NFSPROC41RPCGEN_COMPOUND (1) - >; +using Validator = rpc::RPCProgramValidator< + 100003, // SunRPC/NFS program + 4, // v4 + ProcEnumNFS41::NFS_NULL, // NFSPROC41RPCGEN_NULL (0) + ProcEnumNFS41::COMPOUND // NFSPROC41RPCGEN_COMPOUND (1) + >; +// clang-format off bool_t xdr_nfs_ftype4 (XDR *, NFS41::nfs_ftype4*); bool_t xdr_nfsstat4 (XDR *, NFS41::nfsstat4*); bool_t xdr_attrlist4 (XDR *, NFS41::attrlist4*); @@ -460,35 +459,30 @@ bool_t xdr_nfs_cb_argop4 (XDR *, NFS41::nfs_cb_argop4*); bool_t xdr_nfs_cb_resop4 (XDR *, NFS41::nfs_cb_resop4*); bool_t xdr_CB_COMPOUND4args (XDR *, NFS41::CB_COMPOUND4args*); bool_t xdr_CB_COMPOUND4res (XDR *, NFS41::CB_COMPOUND4res*); +// clang-format on // Procedure 0: NULL - Do nothing -inline auto proc_t_of(NFS41::NULL4args&)->decltype(&xdr_NULL4args) +inline auto proc_t_of(NFS41::NULL4args&) -> decltype(&xdr_NULL4args) { return xdr_NULL4args; } -inline auto proc_t_of(NFS41::NULL4res&)->decltype(&xdr_NULL4res) +inline auto proc_t_of(NFS41::NULL4res&) -> decltype(&xdr_NULL4res) { return &xdr_NULL4res; } // Procedure 1: COMPOUND -inline auto proc_t_of(NFS41::COMPOUND4args&)->decltype(&xdr_COMPOUND4args) +inline auto proc_t_of(NFS41::COMPOUND4args&) -> decltype(&xdr_COMPOUND4args) { return &xdr_COMPOUND4args; } -inline auto proc_t_of(NFS41::COMPOUND4res&)->decltype(&xdr_COMPOUND4res) +inline auto proc_t_of(NFS41::COMPOUND4res&) -> decltype(&xdr_COMPOUND4res) { return &xdr_COMPOUND4res; } -#define NST_PUBLIC __attribute__ ((visibility("default"))) - -extern"C" -NST_PUBLIC -const char* print_nfs41_procedures(const ProcEnumNFS41::NFSProcedure proc); - std::ostream& operator<<(std::ostream& out, const ProcEnumNFS41::NFSProcedure proc); std::ostream& operator<<(std::ostream& out, const NFS41::nfs_ftype4& obj); std::ostream& operator<<(std::ostream& out, const NFS41::nfsstat4& obj); @@ -625,5 +619,5 @@ std::ostream& operator<<(std::ostream& out, const NFS41::notify_deviceid_change4 } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS41_UTILS_H +#endif // NFS41_UTILS_H //------------------------------------------------------------------------------ diff --git a/src/protocols/nfs4/nfs4_utils.cpp b/src/protocols/nfs4/nfs4_utils.cpp index 4e1e855..b7b2486 100644 --- a/src/protocols/nfs4/nfs4_utils.cpp +++ b/src/protocols/nfs4/nfs4_utils.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Author: Alexey Costroma +// Author: Alexey Costroma // Description: Helpers for parsing NFS structures. // Copyright (c) 2014-2015 EPAM Systems //------------------------------------------------------------------------------ @@ -21,11 +21,12 @@ //------------------------------------------------------------------------------ #include <iomanip> +#include "api/plugin_api.h" // for NST_PUBLIC #include "protocols/nfs/nfs_utils.h" #include "protocols/nfs4/nfs4_utils.h" //------------------------------------------------------------------------------ using namespace NST::API::NFS4; -using namespace NST::protocols::NFS; // NFS helpers +using namespace NST::protocols::NFS; // NFS helpers //------------------------------------------------------------------------------ namespace NST { @@ -33,13 +34,14 @@ namespace protocols { namespace NFS4 { - std::ostream& operator<<(std::ostream& out, const ProcEnumNFS4::NFSProcedure proc) { return out << print_nfs4_procedures(proc); } -const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc) +// clang-format off + +extern "C" NST_PUBLIC const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc) { // In all cases we suppose, that NFSv4 operation ILLEGAL(10044) // has the second position in ProcEnumNFS4 @@ -316,9 +318,9 @@ std::ostream& operator<<(std::ostream& out, const settime4& obj) std::ostream& operator<<(std::ostream& out, const nfs_fh4& obj) { - NFS::print_nfs_fh(out, - obj.nfs_fh4_val, - obj.nfs_fh4_len); + print_nfs_fh(out, + obj.nfs_fh4_val, + obj.nfs_fh4_len); return out; } @@ -4436,6 +4438,8 @@ xdr_CB_COMPOUND4res (XDR* xdrs, CB_COMPOUND4res* objp) return TRUE; } +// clang-format on + } // namespace NFS4 } // namespace protocols } // namespace NST diff --git a/src/protocols/nfs4/nfs4_utils.h b/src/protocols/nfs4/nfs4_utils.h index 569f23f..c42eea3 100644 --- a/src/protocols/nfs4/nfs4_utils.h +++ b/src/protocols/nfs4/nfs4_utils.h @@ -24,8 +24,8 @@ //------------------------------------------------------------------------------ #include <ostream> -#include "api/nfs_types.h" #include "api/nfs4_types_rpcgen.h" +#include "api/nfs_types.h" #include "protocols/nfs/nfs_utils.h" #include "protocols/rpc/rpc_header.h" //------------------------------------------------------------------------------ @@ -35,19 +35,18 @@ namespace protocols { namespace NFS4 { - namespace NFS4 = NST::API::NFS4; using ProcEnumNFS4 = API::ProcEnumNFS4; -using Validator = rpc::RPCProgramValidator - < - 100003, // SunRPC/NFS program - 4, // v4 - ProcEnumNFS4::NFS_NULL, // NFSPROC4RPCGEN_NULL (0) - ProcEnumNFS4::COMPOUND // NFSPROC4RPCGEN_COMPOUND (1) - >; +using Validator = rpc::RPCProgramValidator< + 100003, // SunRPC/NFS program + 4, // v4 + ProcEnumNFS4::NFS_NULL, // NFSPROC4RPCGEN_NULL (0) + ProcEnumNFS4::COMPOUND // NFSPROC4RPCGEN_COMPOUND (1) + >; +// clang-format off bool_t xdr_nfs_ftype4 (XDR *, NFS4::nfs_ftype4*); bool_t xdr_nfsstat4 (XDR *, NFS4::nfsstat4*); bool_t xdr_bitmap4 (XDR *, NFS4::bitmap4*); @@ -283,36 +282,30 @@ bool_t xdr_nfs_cb_argop4 (XDR *, NFS4::nfs_cb_argop4*); bool_t xdr_nfs_cb_resop4 (XDR *, NFS4::nfs_cb_resop4*); bool_t xdr_CB_COMPOUND4args (XDR *, NFS4::CB_COMPOUND4args*); bool_t xdr_CB_COMPOUND4res (XDR *, NFS4::CB_COMPOUND4res*); - +// clang-format on // Procedure 0: NULL - Do nothing -inline auto proc_t_of(NFS4::NULL4args&)->decltype(&xdr_NULL4args) +inline auto proc_t_of(NFS4::NULL4args&) -> decltype(&xdr_NULL4args) { return &xdr_NULL4args; } -inline auto proc_t_of(NFS4::NULL4res&)->decltype(&xdr_NULL4res) +inline auto proc_t_of(NFS4::NULL4res&) -> decltype(&xdr_NULL4res) { return &xdr_NULL4res; } // Procedure 1: COMPOUND -inline auto proc_t_of(NFS4::COMPOUND4args&)->decltype(&xdr_COMPOUND4args) +inline auto proc_t_of(NFS4::COMPOUND4args&) -> decltype(&xdr_COMPOUND4args) { return &xdr_COMPOUND4args; } -inline auto proc_t_of(NFS4::COMPOUND4res&)->decltype(&xdr_COMPOUND4res) +inline auto proc_t_of(NFS4::COMPOUND4res&) -> decltype(&xdr_COMPOUND4res) { return &xdr_COMPOUND4res; } -#define NST_PUBLIC __attribute__ ((visibility("default"))) - -extern"C" -NST_PUBLIC -const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc); - std::ostream& operator<<(std::ostream& out, const ProcEnumNFS4::NFSProcedure proc); std::ostream& operator<<(std::ostream& out, const NFS4::nfs_ftype4& obj); std::ostream& operator<<(std::ostream& out, const NFS4::nfsstat4& obj); @@ -370,5 +363,5 @@ std::ostream& operator<<(std::ostream& out, const NFS4::secinfo4& obj); } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//NFS4_UTILS_H +#endif // NFS4_UTILS_H //------------------------------------------------------------------------------ diff --git a/src/protocols/rpc/rpc_header.h b/src/protocols/rpc/rpc_header.h index dc28b14..98e7a98 100644 --- a/src/protocols/rpc/rpc_header.h +++ b/src/protocols/rpc/rpc_header.h @@ -34,12 +34,11 @@ namespace protocols { namespace rpc { - using namespace NST::API; struct MessageHeader { - inline uint32_t xid () const { return ntohl(m_xid); } + inline uint32_t xid() const { return ntohl(m_xid); } inline MsgType type() const { return MsgType(ntohl(m_type)); } private: MessageHeader() = delete; @@ -48,28 +47,26 @@ private: uint32_t m_type; }; -struct CallHeader: public MessageHeader +struct CallHeader : public MessageHeader { - inline uint32_t rpcvers() const { return ntohl(m_rpcvers); } - inline uint32_t prog() const { return ntohl(m_prog); } - inline uint32_t vers() const { return ntohl(m_vers); } - inline uint32_t proc() const { return ntohl(m_proc); } - + inline uint32_t rpcvers() const { return ntohl(m_rpcvers); } + inline uint32_t prog() const { return ntohl(m_prog); } + inline uint32_t vers() const { return ntohl(m_vers); } + inline uint32_t proc() const { return ntohl(m_proc); } // OpaqueAuth cred - skipped // OpaqueAuth verf - skipped private: CallHeader() = delete; - uint32_t m_rpcvers; // must be equal to two (2) + uint32_t m_rpcvers; // must be equal to two (2) uint32_t m_prog; uint32_t m_vers; uint32_t m_proc; }; -struct ReplyHeader: public MessageHeader +struct ReplyHeader : public MessageHeader { inline ReplyStat stat() const { return ReplyStat(ntohl(m_stat)); } - // accepted_reply areply - skipped // rejected_reply rreply - skipped private: @@ -78,22 +75,21 @@ private: uint32_t m_stat; }; -struct RecordMark // RFC 5531 section 11 Record Marking Standard +struct RecordMark // RFC 5531 section 11 Record Marking Standard { - inline bool is_last() const { return ntohl(mark) & 0x80000000; /*1st bit*/ } - inline uint32_t fragment_len() const { return ntohl(mark) & 0x7FFFFFFF; /*31 bits*/ } - inline MessageHeader* fragment() const { return (MessageHeader*)(this+1); } + inline bool is_last() const { return ntohl(mark) & 0x80000000; /*1st bit*/ } + inline uint32_t fragment_len() const { return ntohl(mark) & 0x7FFFFFFF; /*31 bits*/ } + inline MessageHeader* fragment() const { return (MessageHeader*)(this + 1); } private: RecordMark() = delete; uint32_t mark; }; - class RPCValidator { public: - static inline bool check(const MessageHeader*const msg) + static inline bool check(const MessageHeader* const msg) { const MsgType type = msg->type(); @@ -101,65 +97,64 @@ public: type == MsgType::REPLY; } - static inline bool check(const CallHeader*const call) + static inline bool check(const CallHeader* const call) { return call->rpcvers() == SUNRPC_MSG_VERSION; } - static inline bool check(const ReplyHeader*const reply) + static inline bool check(const ReplyHeader* const reply) { const ReplyStat stat = reply->stat(); return stat == ReplyStat::MSG_ACCEPTED || stat == ReplyStat::MSG_DENIED; } + private: RPCValidator() = delete; }; - -template -< - uint32_t Program, // remote program number - uint32_t Version, // remote program version number - uint32_t MinProc, // min remote procedure number - uint32_t MaxProc // max remote procedure number -> +template < + uint32_t Program, // remote program number + uint32_t Version, // remote program version number + uint32_t MinProc, // min remote procedure number + uint32_t MaxProc // max remote procedure number + > class RPCProgramValidator { public: - static inline bool check(const CallHeader*const call) + static inline bool check(const CallHeader* const call) { const uint32_t proc = call->proc(); - return proc <= MaxProc && - proc >= MinProc && - call->prog() == Program && - call->vers() == Version ; + return proc <= MaxProc && + proc >= MinProc && + call->prog() == Program && + call->vers() == Version; } + private: RPCProgramValidator() = delete; }; //This template specialization for remove warning to compare unsigned with zero -template -< +template < uint32_t Program, uint32_t Version, - uint32_t MaxProc -> + uint32_t MaxProc> class RPCProgramValidator<Program, Version, 0, MaxProc> { public: - static inline bool check(const CallHeader*const call) + static inline bool check(const CallHeader* const call) { const uint32_t proc = call->proc(); // do not compare uint32_t with 0 (MinProc) - return proc <= MaxProc && - call->prog() == Program && - call->vers() == Version ; + return proc <= MaxProc && + call->prog() == Program && + call->vers() == Version; } + private: RPCProgramValidator() = delete; }; @@ -168,5 +163,5 @@ private: } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//RPC_HEADER_H +#endif // RPC_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/tcp/tcp_header.h b/src/protocols/tcp/tcp_header.h index 710a2f0..83a7f15 100644 --- a/src/protocols/tcp/tcp_header.h +++ b/src/protocols/tcp/tcp_header.h @@ -33,50 +33,49 @@ namespace protocols { namespace tcp { - // Transmission Control Protocol struct tcp_header { enum Flag // bit masks for flags { - FIN = 0x01, // finished send data - SYN = 0x02, // synchronize sequence numbers - RST = 0x04, // reset the connection - PSH = 0x08, // push data to the app layer - ACK = 0x10, // acknowledge - URG = 0x20, // urgent - ECE = 0x40, // ECN-echo - CWR = 0x80 // congestion window reduced + FIN = 0x01, // finished send data + SYN = 0x02, // synchronize sequence numbers + RST = 0x04, // reset the connection + PSH = 0x08, // push data to the app layer + ACK = 0x10, // acknowledge + URG = 0x20, // urgent + ECE = 0x40, // ECN-echo + CWR = 0x80 // congestion window reduced }; - in_port_t tcp_sport; // source port - in_port_t tcp_dport; // destination port - uint32_t tcp_seq; // sequence number - uint32_t tcp_ack; // acknowledgement number - uint8_t tcp_rsrvd_off; // (unused) and data offset - uint8_t tcp_flags; // control flags - uint16_t tcp_win; // window - uint16_t tcp_sum; // checksum - uint16_t tcp_urp; // urgent pointer -} __attribute__ ((__packed__)); + in_port_t tcp_sport; // source port + in_port_t tcp_dport; // destination port + uint32_t tcp_seq; // sequence number + uint32_t tcp_ack; // acknowledgement number + uint8_t tcp_rsrvd_off; // (unused) and data offset + uint8_t tcp_flags; // control flags + uint16_t tcp_win; // window + uint16_t tcp_sum; // checksum + uint16_t tcp_urp; // urgent pointer +} __attribute__((__packed__)); struct TCPHeader : private tcp_header { - inline in_port_t sport() const { return tcp_sport; } - inline in_port_t dport() const { return tcp_dport; } - inline uint32_t seq() const { return ntohl(tcp_seq); } - inline uint32_t ack() const { return ntohl(tcp_ack); } - inline uint8_t offset() const { return (tcp_rsrvd_off & 0xf0) >> 2 /* *4 */; } // return number of bytes - inline uint8_t flags() const { return tcp_flags; } - inline bool is(tcp_header::Flag flag) const { return tcp_flags & flag; } - inline uint16_t window() const { return ntohs(tcp_win); } - inline uint16_t checksum() const { return ntohs(tcp_sum); } - inline uint16_t urgent() const { return ntohs(tcp_urp); } -} __attribute__ ((__packed__)); + in_port_t sport() const { return tcp_sport; } + in_port_t dport() const { return tcp_dport; } + uint32_t seq() const { return ntohl(tcp_seq); } + uint32_t ack() const { return ntohl(tcp_ack); } + uint8_t offset() const { return (tcp_rsrvd_off & 0xf0) >> 2 /* *4 */; } // return number of bytes + uint8_t flags() const { return tcp_flags; } + bool is(tcp_header::Flag flag) const { return tcp_flags & flag; } + uint16_t window() const { return ntohs(tcp_win); } + uint16_t checksum() const { return ntohs(tcp_sum); } + uint16_t urgent() const { return ntohs(tcp_urp); } +} __attribute__((__packed__)); } // namespace tcp } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//TCP_HEADER_H +#endif // TCP_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/udp/udp_header.h b/src/protocols/udp/udp_header.h index d507cee..5ef9020 100644 --- a/src/protocols/udp/udp_header.h +++ b/src/protocols/udp/udp_header.h @@ -33,27 +33,26 @@ namespace protocols { namespace udp { - // User Datagram Protocol RFC 768 struct udp_header { - in_port_t udp_sport; // source port, optional, may be 0 - in_port_t udp_dport; // destination port - uint16_t udp_len; // length of the datagram, minimum value is 8 - uint16_t udp_sum; // checksum of IP pseudo header, the UDP header, and the data -} __attribute__ ((__packed__)); + in_port_t udp_sport; // source port, optional, may be 0 + in_port_t udp_dport; // destination port + uint16_t udp_len; // length of the datagram, minimum value is 8 + uint16_t udp_sum; // checksum of IP pseudo header, the UDP header, and the data +} __attribute__((__packed__)); struct UDPHeader : private udp_header { - inline in_port_t sport() const { return udp_sport; } - inline in_port_t dport() const { return udp_dport; } - inline uint16_t length() const { return ntohs(udp_len); } - inline uint16_t checksum() const { return ntohs(udp_sum); } -} __attribute__ ((__packed__)); + in_port_t sport() const { return udp_sport; } + in_port_t dport() const { return udp_dport; } + uint16_t length() const { return ntohs(udp_len); } + uint16_t checksum() const { return ntohs(udp_sum); } +} __attribute__((__packed__)); } // namespace udp } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//UDP_HEADER_H +#endif // UDP_HEADER_H //------------------------------------------------------------------------------ diff --git a/src/protocols/xdr/xdr_decoder.h b/src/protocols/xdr/xdr_decoder.h index c057442..968249d 100644 --- a/src/protocols/xdr/xdr_decoder.h +++ b/src/protocols/xdr/xdr_decoder.h @@ -25,8 +25,8 @@ #include <utility> #include <rpc/rpc.h> //------------------------------------------------------------------------------ -#include "utils/filtered_data.h" #include "api/nfs3_types_rpcgen.h" +#include "utils/filtered_data.h" //------------------------------------------------------------------------------ using NST::utils::FilteredData; using NST::utils::FilteredDataQueue; @@ -37,32 +37,32 @@ namespace protocols { namespace xdr { - class XDRDecoderError : public std::runtime_error { public: - explicit XDRDecoderError(const std::string& msg) : std::runtime_error{msg} { } + explicit XDRDecoderError(const std::string& msg) + : std::runtime_error{msg} + { + } }; class XDRDecoder { public: XDRDecoder(FilteredDataQueue::Ptr&& p) - : ptr{std::move(p)} + : ptr{std::move(p)} { xdrmem_create(&txdr, (char*)ptr->data, ptr->dlen, XDR_DECODE); } ~XDRDecoder() { - xdr_destroy (&txdr); + xdr_destroy(&txdr); } - inline XDR* xdr() { return &txdr; } - - inline const FilteredData& data() const { return *ptr; } - + XDR* xdr() { return &txdr; } + const FilteredData& data() const { return *ptr; } private: - XDR txdr; + XDR txdr; FilteredDataQueue::Ptr ptr; }; @@ -70,5 +70,5 @@ private: } // namespace protocols } // namespace NST //------------------------------------------------------------------------------ -#endif//XDR_DECODER_H +#endif // XDR_DECODER_H //------------------------------------------------------------------------------ diff --git a/src/utils/block_allocator.h b/src/utils/block_allocator.h index 798e4ba..41510f5 100644 --- a/src/utils/block_allocator.h +++ b/src/utils/block_allocator.h @@ -22,126 +22,126 @@ #ifndef BLOCK_ALLOCATOR_H #define BLOCK_ALLOCATOR_H //------------------------------------------------------------------------------ -#include <cstring> // for memset() +#include <algorithm> +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> //------------------------------------------------------------------------------ namespace NST { namespace utils { - -// May throw std::bad_alloc() when memory is not enough +// May throw std::bad_alloc during creation or allocation class BlockAllocator { - struct Chunk + struct Chunk // type for linking free chunks of memory in a list { - Chunk* next; // used only for free chunks in list + Chunk* next; // pointer to next chunk in a list }; -public: - BlockAllocator() noexcept - : chunk {0} - , block {0} - , limit {0} - , nfree {0} - , allocated{0} - , blocks{nullptr} - , list {nullptr} - { - } + using Chunks = std::unique_ptr<char[]>; + using Blocks = std::vector<Chunks>; - ~BlockAllocator() +public: + constexpr static std::size_t padding = 16; + + BlockAllocator() = default; + ~BlockAllocator() noexcept { - for(std::size_t i {0}; i<allocated; i++) - { - delete[] ((char*)blocks[i]); - } - delete[] blocks; + assert(max_chunks() == free_chunks()); } void init_allocation(std::size_t chunk_size, std::size_t block_size, std::size_t block_limit) { - chunk = chunk_size; + chunk = ((chunk_size + padding - 1) / padding) * padding; + assert(chunk % padding == 0); + assert(chunk >= chunk_size); + assert(chunk >= sizeof(Chunk)); block = block_size; + assert(block >= 1); limit = block_limit; + assert(limit >= 1); - blocks = new Chunk*[limit]; - memset(blocks, 0, sizeof(Chunk*)*limit); - list = new_block(); + blocks.reserve(limit); + list = preallocate_block(); + assert(list); } - inline void* allocate() + void* allocate() { if(list == nullptr) { - if(allocated == limit) // all blocks are allocated! + if(blocks.size() == limit) // all blocks are allocated! { - increase_blocks_limit(); + // soft limit of blocks is reached } - list = new_block(); + list = preallocate_block(); + ++limit; } - Chunk* c {list}; + Chunk* chunk = list; + assert(chunk); list = list->next; --nfree; - return c; + return chunk; } - inline void deallocate(void* ptr) + void deallocate(void* ptr) noexcept { - Chunk* c {(Chunk*) ptr}; - c->next = list; - list = c; + assert(ptr); + assert(std::any_of(std::begin(blocks), std::end(blocks), + [&](const Chunks& chunks) { + const auto b = reinterpret_cast<void*>(chunks.get()); + const auto e = reinterpret_cast<void*>(chunks.get() + block * chunk); + return (b <= ptr) && (ptr < e); + })); + Chunk* chunk = reinterpret_cast<Chunk*>(ptr); + chunk->next = list; + list = chunk; ++nfree; } - // limits - inline std::size_t max_chunks() const { return block*limit; } - inline std::size_t max_memory() const { return block*limit*chunk; } - inline std::size_t max_blocks() const { return limit; } - inline std::size_t free_chunks()const { return nfree; } - + std::size_t max_chunks() const noexcept { return block * limit; } + std::size_t max_memory() const noexcept { return block * limit * chunk; } + std::size_t max_blocks() const noexcept { return limit; } + std::size_t free_chunks() const noexcept { return nfree; } private: - Chunk* new_block() + Chunk* getof(std::size_t i, const Chunks& chunks) const noexcept { - char* ptr {new char[block*chunk]}; - for(std::size_t i {0}; i<block-1; ++i) - { - ((Chunk*) &ptr[i * chunk])->next = (Chunk*) &ptr[(i + 1) * chunk]; - } - ((Chunk*) &ptr[(block - 1) * chunk])->next = nullptr; - blocks[allocated] = (Chunk*) ptr; - ++allocated; - nfree += block; - return (Chunk*) ptr; + assert(i < block); + return reinterpret_cast<Chunk*>(&chunks.get()[i * chunk]); } - void increase_blocks_limit() + Chunk* preallocate_block() { - const std::size_t new_limit {limit * 2}; // increase soft limit by twice + Chunks chunks(std::make_unique<Chunks::element_type[]>(block * chunk)); - Chunk** new_blocks {new Chunk*[new_limit]}; // allocate new array of blocks pointers - limit = new_limit; - memcpy(new_blocks, blocks, sizeof(Chunk*)*allocated); // copy pointers of existing blocks - memset(&new_blocks[allocated], 0, sizeof(Chunk*)*(limit-allocated)); // fill pointers for new blocks by NULL - - delete[] blocks; // delete old array of blocks pointers - blocks = new_blocks; // set new array + // link chunks to a list + for(std::size_t i = 0; i < block - 1; ++i) + { + getof(i, chunks)->next = getof(i + 1, chunks); + } + getof(block - 1, chunks)->next = nullptr; + Chunk* first = getof(0, chunks); + blocks.emplace_back(std::move(chunks)); + nfree += block; + return first; } - std::size_t chunk; // chunk size - std::size_t block; // num chunks in block - std::size_t limit; // max blocks, soft limit - std::size_t nfree; // num of avaliable chunks - std::size_t allocated;// num of allocated blocks, up to limit - Chunk** blocks; // array of blocks - Chunk* list; // list of free chunks + Chunk* list = nullptr; // head of list of free chunks + std::size_t chunk = 0; // size of chunk + std::size_t block = 0; // num chunks in block + std::size_t limit = 0; // max blocks, soft limit + std::size_t nfree = 0; // num of avaliable chunks + Blocks blocks; // array of blocks }; } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//BLOCK_ALLOCATOR_H +#endif // BLOCK_ALLOCATOR_H //------------------------------------------------------------------------------ diff --git a/src/utils/dynamic_load.cpp b/src/utils/dynamic_load.cpp index 5e98108..c781510 100644 --- a/src/utils/dynamic_load.cpp +++ b/src/utils/dynamic_load.cpp @@ -28,7 +28,7 @@ using namespace NST::utils; //------------------------------------------------------------------------------ -DynamicLoad::DynamicLoad(const std::string &file) +DynamicLoad::DynamicLoad(const std::string& file) { handle = dlopen(file.c_str(), RTLD_LAZY); if(handle == nullptr) @@ -42,7 +42,7 @@ DynamicLoad::~DynamicLoad() dlclose(handle); } -void* DynamicLoad::get_symbol(const std::string &name) +void* DynamicLoad::get_symbol(const std::string& name) { void* address = (dlsym)(handle, name.c_str()); if(address == nullptr) diff --git a/src/utils/dynamic_load.h b/src/utils/dynamic_load.h index 8a56848..6620512 100644 --- a/src/utils/dynamic_load.h +++ b/src/utils/dynamic_load.h @@ -28,21 +28,23 @@ namespace NST { namespace utils { - class DynamicLoad { public: class DLException : public std::runtime_error { public: - explicit DLException(const std::string& msg) : std::runtime_error{msg} { } + explicit DLException(const std::string& msg) + : std::runtime_error{msg} + { + } }; protected: explicit DynamicLoad(const std::string& file); ~DynamicLoad(); - template<typename SymbolPtr> + template <typename SymbolPtr> void load_address_of(const std::string& name, SymbolPtr& address) { static_assert(sizeof(void*) == sizeof(SymbolPtr), "object pointer and function pointer sizes must be equal"); @@ -51,8 +53,8 @@ protected: using hook_dlsym_t = SymbolPtr (DynamicLoad::*)(const std::string&); hook_dlsym_t get_symbol_func = reinterpret_cast<hook_dlsym_t>(&DynamicLoad::get_symbol); - address = (*this.*get_symbol_func)(name); - } + address = (*this.*get_symbol_func)(name); + } /*! * Gets symbol by name from DLL @@ -69,5 +71,5 @@ private: } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//DYNAMIC_LOAD_H +#endif // DYNAMIC_LOAD_H //------------------------------------------------------------------------------ diff --git a/src/utils/filtered_data.h b/src/utils/filtered_data.h index 21398ee..c2bb4d7 100644 --- a/src/utils/filtered_data.h +++ b/src/utils/filtered_data.h @@ -22,52 +22,55 @@ #ifndef FILTERED_DATA_H #define FILTERED_DATA_H //------------------------------------------------------------------------------ -#include <cstdint> #include <cassert> +#include <cstdint> #include <sys/time.h> -#include "utils/sessions.h" #include "utils/queue.h" +#include "utils/sessions.h" //------------------------------------------------------------------------------ namespace NST { namespace utils { - struct FilteredData { using Direction = NST::utils::Session::Direction; + public: NetworkSession* session{nullptr}; // pointer to immutable session in Filtration - struct timeval timestamp; // timestamp of last collected packet - Direction direction; // direction of data transmission + struct timeval timestamp; // timestamp of last collected packet + Direction direction; // direction of data transmission - uint32_t dlen{0}; // length of filtered data - uint8_t* data{cache}; // pointer to data in memory. {Readonly. Always points to proper memory buffer} + uint32_t dlen{0}; // length of filtered data + uint8_t* data{cache}; // pointer to data in memory. {Readonly. Always points to proper memory buffer} private: - const static int CACHE_SIZE {4000}; - uint8_t cache[CACHE_SIZE]; - uint8_t* memory{nullptr}; - uint32_t memsize{0}; + const static int CACHE_SIZE{4000}; + + uint8_t cache[CACHE_SIZE]; + uint8_t* memory{nullptr}; + uint32_t memsize{0}; public: // disable copying - FilteredData(const FilteredData&) = delete; + FilteredData(const FilteredData&) = delete; FilteredData& operator=(const FilteredData&) = delete; - inline FilteredData() noexcept : data{cache} + FilteredData() noexcept + : data{cache} { } - inline ~FilteredData() { + ~FilteredData() + { delete[] memory; } - inline uint32_t capacity() const + uint32_t capacity() const { - if (nullptr == memory) + if(nullptr == memory) { assert(data == cache); return CACHE_SIZE; @@ -78,22 +81,22 @@ public: // Resize capacity with data safety void resize(uint32_t newsize) { - if (capacity() >= newsize) return; // not resize less + if(capacity() >= newsize) return; // not resize less - if (nullptr == memory) + if(nullptr == memory) { memory = new uint8_t[newsize]; - if (dlen) + if(dlen) { memcpy(memory, cache, dlen); } memsize = newsize; - data = memory; + data = memory; } else // have some filled memory { - uint8_t* mem {new uint8_t[newsize]}; - if (dlen) + uint8_t* mem{new uint8_t[newsize]}; + if(dlen) { memcpy(mem, memory, dlen); } @@ -105,16 +108,16 @@ public: } // Reset data. Release free memory if allocated - inline void reset() + void reset() { - if (nullptr != memory) + if(nullptr != memory) { delete[] memory; memory = nullptr; } memsize = 0; - dlen = 0; - data = cache; + dlen = 0; + data = cache; } }; @@ -123,5 +126,5 @@ using FilteredDataQueue = Queue<FilteredData>; } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//FILTERED_DATA_H +#endif // FILTERED_DATA_H //------------------------------------------------------------------------------ diff --git a/src/utils/log.cpp b/src/utils/log.cpp index 32ca4d9..c9760a7 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -48,27 +48,23 @@ namespace NST { namespace utils { - -static FILE* log_file {::stderr}; -static bool own_file {false}; +static FILE* log_file{::stderr}; +static bool own_file{false}; namespace // unnanmed { - static FILE* try_open(const std::string& file_name) { FILE* file = fopen(file_name.c_str(), "a+"); if(file == nullptr) { - throw std::system_error{errno, std::system_category(), - {"Error in opening file: " + file_name}}; + throw std::system_error{errno, std::system_category(), {"Error in opening file: " + file_name}}; } - chmod(file_name.c_str(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); + chmod(file_name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if(flock(fileno(file), LOCK_EX | LOCK_NB)) { fclose(file); - throw std::system_error{errno, std::system_category(), - {"Log file already locked: " + file_name}}; + throw std::system_error{errno, std::system_category(), {"Log file already locked: " + file_name}}; } time_t now = time(NULL); fprintf(file, "--------------------------------------------------------------------------\n"); @@ -81,7 +77,7 @@ static FILE* try_open(const std::string& file_name) } // namespace unnamed Log::Global::Global(const std::string& path) - : log_file_path {path} + : log_file_path{path} { if(own_file) { @@ -91,18 +87,17 @@ Log::Global::Global(const std::string& path) if(!log_file_path.empty()) { struct stat st; - bool exists = stat(log_file_path.c_str(), &st) == 0 ? true : false; + + bool exists = (stat(log_file_path.c_str(), &st) == 0); if(!exists && log_file_path.back() == '/') { - throw std::system_error{errno, std::system_category(), - {"Error accessing directory: " + log_file_path}}; + throw std::system_error{errno, std::system_category(), {"Error accessing directory: " + log_file_path}}; } if(exists && S_ISDIR(st.st_mode)) { - 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."}}; + 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."}}; } } else @@ -137,17 +132,16 @@ void Log::Global::reopen() FILE* temp = freopen(log_file_path.c_str(), "a+", log_file); if(temp == nullptr) { - throw std::system_error{errno, std::system_category(), - {std::string{"Can't reopen file: "} + log_file_path}}; + throw std::system_error{errno, std::system_category(), {std::string{"Can't reopen file: "} + log_file_path}}; } log_file = temp; } Log::Log() -: std::stringbuf {ios_base::out} -, std::ostream {nullptr} + : std::stringbuf{ios_base::out} + , std::ostream{nullptr} { - std::stringbuf::setp(buffer, buffer+sizeof(buffer)); + std::stringbuf::setp(buffer, buffer + sizeof(buffer)); std::ostream::init(static_cast<std::stringbuf*>(this)); std::ostream::put('\n'); } diff --git a/src/utils/log.h b/src/utils/log.h index dd78c35..4c23a0d 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -31,28 +31,33 @@ #define DO_STRINGIZE(x) #x // TODO: DANGEROUS MACRO ! Passing custom client string as format to printf(). // May be cause of SIGSEGV -#define TRACE(...) {\ - NST::utils::Log::message(__FILE__ ":" STRINGIZE(__LINE__) ": " __VA_ARGS__);\ - NST::utils::Log::message("\n");\ - NST::utils::Log::flush();\ -} +#define TRACE(...) \ + { \ + NST::utils::Log::message(__FILE__ ":" STRINGIZE(__LINE__) ": " __VA_ARGS__); \ + NST::utils::Log::message("\n"); \ + NST::utils::Log::flush(); \ + } #endif -#define LOG(...) {\ - NST::utils::Log::message(__VA_ARGS__);\ - NST::utils::Log::message("\n");\ -} +#define LOG(...) \ + { \ + NST::utils::Log::message(__VA_ARGS__); \ + NST::utils::Log::message("\n"); \ + } -#define LOGONCE(...) {\ - static bool notyet = true; \ - if(notyet) { LOG(__VA_ARGS__); notyet = false; }\ -} +#define LOGONCE(...) \ + { \ + static bool notyet = true; \ + if(notyet) { \ + LOG(__VA_ARGS__); \ + notyet = false; \ + } \ + } //------------------------------------------------------------------------------ namespace NST { namespace utils { - class Log : private std::stringbuf, public std::ostream { public: @@ -62,21 +67,23 @@ public: { explicit Global(const std::string& file_path); ~Global(); - Global(const Global&) = delete; + Global(const Global&) = delete; Global& operator=(const Global&) = delete; - void reopen(); + void reopen(); + private: std::string log_file_path; }; Log(); ~Log(); - Log(const Log&) = delete; + Log(const Log&) = delete; Log& operator=(const Log&) = delete; // lightweight logging static void message(const char* format, ...); static void flush(); + private: char buffer[256]; }; @@ -84,5 +91,5 @@ private: } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//LOG_H +#endif // LOG_H //------------------------------------------------------------------------------ diff --git a/src/utils/out.cpp b/src/utils/out.cpp index 9fd8b9d..80b7110 100644 --- a/src/utils/out.cpp +++ b/src/utils/out.cpp @@ -25,7 +25,6 @@ namespace NST { namespace utils { - static Out::Level global = Out::Level::Info; Out::Global::Global(const Level verbose_level) @@ -47,7 +46,7 @@ void Out::Global::set_level(Out::Level l) } Out::Out(Level level) -: std::ostream{ (global >= level) ? std::cout.rdbuf() : nullptr } + : std::ostream{(global >= level) ? std::cout.rdbuf() : nullptr} { } Out::~Out() diff --git a/src/utils/out.h b/src/utils/out.h index 8c12597..66d785a 100644 --- a/src/utils/out.h +++ b/src/utils/out.h @@ -28,7 +28,6 @@ namespace NST { namespace utils { - class Out : public std::ostream { public: @@ -44,20 +43,20 @@ public: { explicit Global(const Level verbose_level); ~Global(); - Global(const Global&) = delete; + Global(const Global&) = delete; Global& operator=(const Global&) = delete; - static Level get_level(); // return global level of verbosity - static void set_level(Level); // set global level of verbosity + static Level get_level(); // return global level of verbosity + static void set_level(Level); // set global level of verbosity }; - explicit Out(Level level=Level::Info); // verbose level of message + explicit Out(Level level = Level::Info); // verbose level of message ~Out(); - Out(const Out&) = delete; + Out(const Out&) = delete; Out& operator=(const Out&) = delete; }; -inline bool operator >=(const Out::Level a, const Out::Level b) +inline bool operator>=(const Out::Level a, const Out::Level b) { return (int)a >= (int)b; } @@ -65,5 +64,5 @@ inline bool operator >=(const Out::Level a, const Out::Level b) } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//OUT_H +#endif // OUT_H //------------------------------------------------------------------------------ diff --git a/src/utils/profiler.h b/src/utils/profiler.h index 747821b..eba6a98 100644 --- a/src/utils/profiler.h +++ b/src/utils/profiler.h @@ -45,16 +45,17 @@ * PROF; * ... */ -template<int id> +template <int id> class Profiler { - const char* name = "";//!< Name of function - const static size_t reservedBytes = 50 * 1000;//!< Reserved - calls count - struct timespec startTime;//!< Timestamp of start function + const char* name = ""; //!< Name of function + const static size_t reservedBytes = 50 * 1000; //!< Reserved - calls count + struct timespec startTime; //!< Timestamp of start function class Local { const char* name = ""; + public: std::vector<std::uint64_t> values; Local(const char* name) @@ -69,8 +70,8 @@ class Profiler std::cout << name << "(" << id << "): calls count=" << values.size() << ", avg time=" << sum / values.size() << " nanosecs" << std::endl; } }; -public: +public: /*! Constructor * \param name - name of function, which you are going to profile */ @@ -85,12 +86,11 @@ public: struct timespec stopTime; clock_gettime(CLOCK_REALTIME, &stopTime); - static Local local(name);// Time of vector initialization is not included into statistics + static Local local(name); // Time of vector initialization is not included into statistics - local.values.push_back(stopTime.tv_nsec - startTime.tv_nsec);// Assume, that time < 1 second! + local.values.push_back(stopTime.tv_nsec - startTime.tv_nsec); // Assume, that time < 1 second! } - }; //------------------------------------------------------------------------------ -#endif//PROFILER_H +#endif // PROFILER_H //------------------------------------------------------------------------------ diff --git a/src/utils/queue.h b/src/utils/queue.h index 941c543..e1860d0 100644 --- a/src/utils/queue.h +++ b/src/utils/queue.h @@ -22,6 +22,7 @@ #ifndef QUEUE_H #define QUEUE_H //------------------------------------------------------------------------------ +#include <cstddef> #include <memory> #include <type_traits> @@ -32,22 +33,22 @@ namespace NST { namespace utils { - template <typename T> class Queue { struct Element // an element of the queue { Element* prev; - T data; + T data; }; struct ElementDeleter { - inline explicit ElementDeleter() noexcept : queue{nullptr} {} - inline explicit ElementDeleter(Queue* q) noexcept : queue{q} {} - - inline void operator()(T* const pointer) const + explicit ElementDeleter(Queue* q = nullptr) noexcept + : queue{q} + { + } + void operator()(T* const pointer) const { if(pointer /*&& queue - dont check - optimization*/) { @@ -59,19 +60,19 @@ class Queue }; public: - using Ptr = std::unique_ptr<T, ElementDeleter>; - class List // List of elements for client code + class List // List of elements for client code { public: - inline explicit List(Queue& q) : queue{&q} + inline explicit List(Queue& q) + : queue{&q} { ptr = queue->pop_list(); } - List(const List&) = delete; + List(const List&) = delete; List& operator=(const List&) = delete; - inline ~List() + ~List() { while(ptr) { @@ -79,96 +80,96 @@ public: } } - inline operator bool() const { return ptr; } // is empty? - inline const T& data() const { return ptr->data; } // get data - inline Ptr get_current() // return element and switch to next + operator bool() const { return ptr; } // is empty? + const T& data() const { return ptr->data; } // get data + Ptr get_current() // return element and switch to next { - Element* tmp {ptr}; + Element* tmp{ptr}; ptr = ptr->prev; return Ptr{&tmp->data, ElementDeleter{queue}}; } - inline void free_current() // deallocate element and switch to next + void free_current() // deallocate element and switch to next { - Element* tmp {ptr->prev}; + Element* tmp{ptr->prev}; queue->deallocate(ptr); ptr = tmp; } + private: Element* ptr; - Queue* queue; + Queue* queue; }; - - Queue(uint32_t size, uint32_t limit) : last{nullptr}, first{nullptr} + Queue(uint32_t size, uint32_t limit) + : last{nullptr} + , first{nullptr} { allocator.init_allocation(sizeof(Element), size, limit); } ~Queue() { - List list{*this}; // deallocate items by destructor of List + List list{*this}; // deallocate items by destructor of List } - inline T* allocate() + T* allocate() { static_assert(std::is_nothrow_constructible<T>::value, "The construction of T must not to throw any exception"); Spinlock::Lock lock{a_spinlock}; - Element* e {(Element*)allocator.allocate()}; // may throw std::bad_alloc - auto ptr = &(e->data); - ::new(ptr)T; // only call constructor of T (placement) - return ptr; + Element* e{(Element*)allocator.allocate()}; // may throw std::bad_alloc + return ::new(&(e->data)) T; // placement construction T } - inline void deallocate(T* ptr) + void deallocate(T* ptr) { - ptr->~T(); // placement allocation functions syntax is used - Element* e { (Element*)( ((char*)ptr) - sizeof(Element*) ) }; + ptr->~T(); // placement construction was used + Element* e{(Element*)(((char*)ptr) - offsetof(Element, data))}; deallocate(e); } - inline void push(T* ptr) + void push(T* ptr) { - Element* e { (Element*)( ((char*)ptr) - sizeof(Element*) ) }; + Element* e{(Element*)(((char*)ptr) - offsetof(Element, data))}; Spinlock::Lock lock{q_spinlock}; - if(last) - { - last->prev = e; - last = e; - } - else // queue is empty - { - last = first = e; - } + if(last) + { + last->prev = e; + last = e; + } + else // queue is empty + { + last = first = e; + } } - inline Element* pop_list() // take out list of all queued elements + Element* pop_list() // take out list of all queued elements { - Element* list {nullptr}; + Element* list{nullptr}; if(last) { Spinlock::Lock lock{q_spinlock}; - if(last) - { - list = first; - last->prev = nullptr; // set end of list - last = first = nullptr; - } + if(last) + { + list = first; + last->prev = nullptr; // set end of list + last = first = nullptr; + } } return list; } private: // accessible from Queue::List and Queue::Ptr - inline void deallocate(Element* e) + void deallocate(Element* e) { Spinlock::Lock lock{a_spinlock}; - allocator.deallocate(e); + allocator.deallocate(e); } BlockAllocator allocator; - Spinlock a_spinlock; // for allocate/deallocate - Spinlock q_spinlock; // for queue push/pop + Spinlock a_spinlock; // for allocate/deallocate + Spinlock q_spinlock; // for queue push/pop // queue empty: last->nullptr<-first // queue filled: last->e<-e<-e<-e<-first @@ -180,5 +181,5 @@ private: } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//QUEUE_H +#endif // QUEUE_H //------------------------------------------------------------------------------ diff --git a/src/utils/sessions.cpp b/src/utils/sessions.cpp index 815a226..28a5782 100644 --- a/src/utils/sessions.cpp +++ b/src/utils/sessions.cpp @@ -21,10 +21,11 @@ //------------------------------------------------------------------------------ #include <sstream> -#include <arpa/inet.h> // for inet_ntop(), ntohs() -#include <sys/socket.h> // for AF_INET/AF_INET6 +#include <arpa/inet.h> // for inet_ntop(), ntohs() #include <netdb.h> +#include <sys/socket.h> // for AF_INET/AF_INET6 +#include "api/plugin_api.h" // for NST_PUBLIC #include "utils/out.h" #include "utils/sessions.h" //------------------------------------------------------------------------------ @@ -32,11 +33,10 @@ namespace NST { namespace utils { - std::ostream& operator<<(std::ostream& out, const ApplicationSession& session); ApplicationSession::ApplicationSession(const NetworkSession& s, Direction from_client) -: utils::Session (s) + : utils::Session(s) { if(s.direction != from_client) { @@ -44,11 +44,11 @@ ApplicationSession::ApplicationSession(const NetworkSession& s, Direction from_c std::swap(port[0], port[1]); switch(ip_type) { - case Session::IPType::v4: - std::swap(ip.v4.addr[0], ip.v4.addr[1]); + case Session::IPType::v4: + std::swap(ip.v4.addr[0], ip.v4.addr[1]); break; - case Session::IPType::v6: - std::swap(ip.v6.addr[0], ip.v6.addr[1]); + case Session::IPType::v6: + std::swap(ip.v6.addr[0], ip.v6.addr[1]); break; } } @@ -64,13 +64,14 @@ ApplicationSession::ApplicationSession(const NetworkSession& s, Direction from_c namespace { - std::ostream& operator<<(std::ostream& out, const Session::Type type) { switch(type) { - case Session::Type::TCP: return out << " [TCP]"; - case Session::Type::UDP: return out << " [UDP]"; + case Session::Type::TCP: + return out << " [TCP]"; + case Session::Type::UDP: + return out << " [UDP]"; } return out; } @@ -80,31 +81,31 @@ void print_ipv4_port(std::ostream& out, in_addr_t ipv4, in_port_t port) static_assert(sizeof(ipv4) == sizeof(struct in_addr), "they must be equal"); char buf[INET_ADDRSTRLEN]; - const char* str {inet_ntop(AF_INET, &ipv4, buf, sizeof(buf))}; + const char* str{inet_ntop(AF_INET, &ipv4, buf, sizeof(buf))}; out << (str ? str : "Invalid IPv4 address") << ':' << ntohs(port); } void print_ipv6_port(std::ostream& out, const uint8_t (&ipv6)[16], in_port_t port) { - static_assert(sizeof(ipv6) == sizeof(struct in6_addr),"they must be equal"); + static_assert(sizeof(ipv6) == sizeof(struct in6_addr), "they must be equal"); char buf[INET6_ADDRSTRLEN]; - const char* str {inet_ntop(AF_INET6, ipv6, buf, sizeof(buf))}; + const char* str{inet_ntop(AF_INET6, ipv6, buf, sizeof(buf))}; out << (str ? str : "Invalid IPv6 address") << ':' << ntohs(port); } // TODO: getnameinfo call may be expensive -template<typename SockAddr> +template <typename SockAddr> void print_sockaddr(std::ostream& out, SockAddr& addr) { - char hostname[1025]; - char service [65]; - const int err {getnameinfo((sockaddr*)&addr, sizeof(addr), - hostname, sizeof(hostname), - service, sizeof(service), - NI_NAMEREQD ) }; + char hostname[1025]; + char service[65]; + const int err{getnameinfo((sockaddr*)&addr, sizeof(addr), + hostname, sizeof(hostname), + service, sizeof(service), + NI_NAMEREQD)}; if(err == 0) { out << '(' << hostname << ':' << service << ')'; @@ -112,27 +113,27 @@ void print_sockaddr(std::ostream& out, SockAddr& addr) } void print_ipv4_port_as_hostname_service(std::ostream& out, - in_addr_t ipv4, - in_port_t port) + in_addr_t ipv4, + in_port_t port) { sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_port = port; - addr.sin_addr.s_addr= ipv4; + addr.sin_family = AF_INET; + addr.sin_port = port; + addr.sin_addr.s_addr = ipv4; print_sockaddr(out, addr); } void print_ipv6_port_as_hostname_service(std::ostream& out, const uint8_t (&ipv6)[16], - in_port_t port) + in_port_t port) { sockaddr_in6 addr; - addr.sin6_family = AF_INET6; - addr.sin6_port = port; - addr.sin6_flowinfo = 0; - addr.sin6_addr = (in6_addr&)ipv6; - addr.sin6_scope_id = 0; + addr.sin6_family = AF_INET6; + addr.sin6_port = port; + addr.sin6_flowinfo = 0; + addr.sin6_addr = (in6_addr&)ipv6; + addr.sin6_scope_id = 0; print_sockaddr(out, addr); } @@ -145,88 +146,88 @@ std::ostream& operator<<(std::ostream& out, const Session& session) return out; } -void print_session(std::ostream& out, const Session& session) +extern "C" NST_PUBLIC void print_session(std::ostream& out, const Session& session) { switch(session.ip_type) { - case Session::IPType::v4: - { - print_ipv4_port(out, session.ip.v4.addr[Session::Source], - session.port [Session::Source]); - out << " --> "; - print_ipv4_port(out, session.ip.v4.addr[Session::Destination], - session.port [Session::Destination]); - } - break; - case Session::IPType::v6: - { - print_ipv6_port(out, session.ip.v6.addr[Session::Source], - session.port [Session::Source]); - out << " --> "; - print_ipv6_port(out, session.ip.v6.addr[Session::Destination], - session.port [Session::Destination]); - } - break; + case Session::IPType::v4: + { + print_ipv4_port(out, session.ip.v4.addr[Session::Source], + session.port[Session::Source]); + out << " --> "; + print_ipv4_port(out, session.ip.v4.addr[Session::Destination], + session.port[Session::Destination]); + } + break; + case Session::IPType::v6: + { + print_ipv6_port(out, session.ip.v6.addr[Session::Source], + session.port[Session::Source]); + out << " --> "; + print_ipv6_port(out, session.ip.v6.addr[Session::Destination], + session.port[Session::Destination]); + } + break; } out << session.type; } std::ostream& operator<<(std::ostream& out, const ApplicationSession& session) { - const bool namelookup {Out::Global::get_level() == Out::Level::All}; + const bool namelookup{Out::Global::get_level() == Out::Level::All}; switch(session.ip_type) { - case Session::IPType::v4: + case Session::IPType::v4: + { { + auto& port = session.port[Session::Source]; + auto& addr = session.ip.v4.addr[Session::Source]; + + print_ipv4_port(out, addr, port); + if(namelookup) { - auto& port = session.port [Session::Source]; - auto& addr = session.ip.v4.addr[Session::Source]; - - print_ipv4_port(out, addr, port); - if(namelookup) - { - print_ipv4_port_as_hostname_service(out, addr, port); - } + print_ipv4_port_as_hostname_service(out, addr, port); } - out << " --> "; + } + out << " --> "; + { + auto& port = session.port[Session::Destination]; + auto& addr = session.ip.v4.addr[Session::Destination]; + + print_ipv4_port(out, addr, port); + if(namelookup) { - auto& port = session.port [Session::Destination]; - auto& addr = session.ip.v4.addr[Session::Destination]; - - print_ipv4_port(out, addr, port); - if(namelookup) - { - print_ipv4_port_as_hostname_service(out, addr, port); - } + print_ipv4_port_as_hostname_service(out, addr, port); } } - break; - case Session::IPType::v6: + } + break; + case Session::IPType::v6: + { { + auto& port = session.port[Session::Source]; + auto& addr = session.ip.v6.addr[Session::Source]; + + print_ipv6_port(out, addr, port); + if(namelookup) { - auto& port = session.port [Session::Source]; - auto& addr = session.ip.v6.addr[Session::Source]; - - print_ipv6_port(out, addr, port); - if(namelookup) - { - print_ipv6_port_as_hostname_service(out, addr, port); - } + print_ipv6_port_as_hostname_service(out, addr, port); } - out << " --> "; + } + out << " --> "; + { + auto& port = session.port[Session::Destination]; + auto& addr = session.ip.v6.addr[Session::Destination]; + + print_ipv6_port(out, addr, port); + if(namelookup) { - auto& port = session.port [Session::Destination]; - auto& addr = session.ip.v6.addr[Session::Destination]; - - print_ipv6_port(out, addr, port); - if(namelookup) - { - print_ipv6_port_as_hostname_service(out, addr, port); - } + print_ipv6_port_as_hostname_service(out, addr, port); } } - break; + } + break; } out << session.type; return out; @@ -235,4 +236,3 @@ std::ostream& operator<<(std::ostream& out, const ApplicationSession& session) } // namespace utils } // namespace NST //------------------------------------------------------------------------------ - diff --git a/src/utils/sessions.h b/src/utils/sessions.h index d78c303..6107630 100644 --- a/src/utils/sessions.h +++ b/src/utils/sessions.h @@ -28,13 +28,11 @@ #include "api/session.h" //------------------------------------------------------------------------------ -#define NST_PUBLIC __attribute__ ((visibility("default"))) //------------------------------------------------------------------------------ namespace NST { namespace utils { - using Session = NST::API::Session; // Network layer session @@ -42,16 +40,15 @@ struct NetworkSession : public Session { public: NetworkSession() - : application {nullptr} - , direction {Direction::Unknown} + : application{nullptr} + , direction{Direction::Unknown} { } - void* application; // pointer to application protocol implementation + void* application; // pointer to application protocol implementation Direction direction; }; - // Application layer session struct ApplicationSession : public Session { @@ -63,14 +60,10 @@ private: std::string session_str; }; -extern "C" -NST_PUBLIC -void print_session(std::ostream& out, const Session& session); - std::ostream& operator<<(std::ostream& out, const Session& session); } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//SESSIONS_H +#endif // SESSIONS_H //------------------------------------------------------------------------------ diff --git a/src/utils/spinlock.h b/src/utils/spinlock.h index bc8d25f..3489018 100644 --- a/src/utils/spinlock.h +++ b/src/utils/spinlock.h @@ -22,7 +22,7 @@ #ifndef SPINLOCK_H #define SPINLOCK_H //------------------------------------------------------------------------------ -#include <mutex> // for std::lock_guard +#include <mutex> // for std::lock_guard #include <pthread.h> //------------------------------------------------------------------------------ @@ -30,7 +30,6 @@ namespace NST { namespace utils { - class Spinlock { public: @@ -38,7 +37,7 @@ public: { pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE); } - Spinlock(const Spinlock&) = delete; + Spinlock(const Spinlock&) = delete; Spinlock& operator=(const Spinlock&) = delete; ~Spinlock() noexcept { @@ -69,5 +68,5 @@ private: } // namespace utils } // namespace NST //------------------------------------------------------------------------------ -#endif//SPINLOCK_H +#endif // SPINLOCK_H //------------------------------------------------------------------------------ diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index d6c41a0..7f22a05 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,5 +1,6 @@ -if ("${GMOCK_SOURCE_DIR}" STREQUAL "") - message (WARNING "GMOCK_SOURCE_DIR variable not set - unit-tests are not available. Use '-DGMOCK_SOURCE_DIR=<path_to_gmock_sources>' param for CMake") +if ("${GTEST_SOURCE_DIR}" STREQUAL "") + message (WARNING "GTEST_SOURCE_DIR variable not set - unit-tests are not available. Use + '-DGTEST_SOURCE_DIR=<path_to_nfstrace>/third_party/googletest' param for CMake") else () # Clang and GCC 4.9+ cause errors on GMock/GTest compilation, so we are adding following flags to suppress them set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") @@ -9,13 +10,13 @@ else () set (gmock_force_shared_crt true CACHE INTERNAL "") set (BUILD_SHARED_LIBS false CACHE INTERNAL "") add_definitions (-DGTEST_HAS_PTHREAD=1) # It fixes BUG in GTests in BSD - add_subdirectory (${GMOCK_SOURCE_DIR} ${CMAKE_BINARY_DIR}/gmock) + add_subdirectory (${GTEST_SOURCE_DIR}/googlemock ${CMAKE_BINARY_DIR}/gmock) set (GMOCK_LIBRARIES gmock gmock_main) - set (GMOCK_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/include" - "${GMOCK_SOURCE_DIR}/gtest/include" - "${GMOCK_SOURCE_DIR}") + set (GTEST_INCLUDE_DIRS + "${GTEST_SOURCE_DIR}/googletest/include" + "${GTEST_SOURCE_DIR}/googlemock/include") - include_directories (${CMAKE_SOURCE_DIR}/src ${GMOCK_INCLUDE_DIRS}) + include_directories (${CMAKE_SOURCE_DIR}/src ${GTEST_INCLUDE_DIRS}) add_subdirectory (utils) add_subdirectory (analyzers) diff --git a/tests/unit/analyzers/breakdown/breakdown.cpp b/tests/unit/analyzers/breakdown/breakdown.cpp index d9ac1c3..308c488 100644 --- a/tests/unit/analyzers/breakdown/breakdown.cpp +++ b/tests/unit/analyzers/breakdown/breakdown.cpp @@ -20,8 +20,8 @@ */ //------------------------------------------------------------------------------ #include <cstdlib> -#include <iostream> #include <ctime> +#include <iostream> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -36,12 +36,12 @@ using ::testing::_; //------------------------------------------------------------------------------ namespace { - class BreakdownTest : public ::testing::Test { protected: - size_t count; + size_t count; timeval t; + public: void SetUp() { @@ -53,12 +53,10 @@ public: { } }; - } //------------------------------------------------------------------------------ TEST_F(BreakdownTest, count) { - BreakdownCounter break_down(count); EXPECT_EQ(0U, break_down.get_total_count()); @@ -68,6 +66,5 @@ TEST_F(BreakdownTest, count) break_down[0].add(t); EXPECT_EQ(3U, break_down.get_total_count()); - } //------------------------------------------------------------------------------ diff --git a/tests/unit/analyzers/breakdown/latency.cpp b/tests/unit/analyzers/breakdown/latency.cpp index f8af2cc..df27398 100644 --- a/tests/unit/analyzers/breakdown/latency.cpp +++ b/tests/unit/analyzers/breakdown/latency.cpp @@ -36,13 +36,13 @@ using ::testing::_; //------------------------------------------------------------------------------ namespace { - class LatencyTest : public ::testing::Test { protected: - size_t count; + size_t count; timeval t1; timeval t2; + public: void SetUp() { @@ -60,12 +60,10 @@ public: { } }; - } //------------------------------------------------------------------------------ TEST_F(LatencyTest, max_min) { - Latencies latency; EXPECT_EQ(0U, latency.get_count()); @@ -80,7 +78,6 @@ TEST_F(LatencyTest, max_min) EXPECT_EQ(t1.tv_sec, latency.get_max().tv_sec); EXPECT_EQ(t1.tv_usec, latency.get_max().tv_usec); - } TEST_F(LatencyTest, avg) @@ -114,7 +111,7 @@ TEST_F(LatencyTest, convert_timeval_to_sec) */ struct timeval input; - input.tv_sec = 0; + input.tv_sec = 0; input.tv_usec = 500; const auto sec = to_sec(input); @@ -123,9 +120,12 @@ TEST_F(LatencyTest, convert_timeval_to_sec) std::stringstream ss; - ss.precision(6); ss << std::fixed << sec << ' '; - ss.precision(4); ss << std::fixed << sec << ' '; - ss.precision(3); ss << std::fixed << sec; + ss.precision(6); + ss << std::fixed << sec << ' '; + ss.precision(4); + ss << std::fixed << sec << ' '; + ss.precision(3); + ss << std::fixed << sec; EXPECT_EQ("0.000500 0.0005 0.001", ss.str()); } diff --git a/tests/unit/analyzers/breakdown/statistic.cpp b/tests/unit/analyzers/breakdown/statistic.cpp index 08f33d7..435b37b 100644 --- a/tests/unit/analyzers/breakdown/statistic.cpp +++ b/tests/unit/analyzers/breakdown/statistic.cpp @@ -20,8 +20,8 @@ */ //------------------------------------------------------------------------------ #include <cstdlib> -#include <iostream> #include <ctime> +#include <iostream> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -36,11 +36,11 @@ using ::testing::_; //------------------------------------------------------------------------------ namespace { - class StatisticTest : public ::testing::Test { protected: size_t count; + public: void SetUp() { @@ -69,72 +69,64 @@ public: { } - Session _session; - timeval _rtimestamp; - timeval _ctimestamp; + Session _session; + timeval _rtimestamp; + timeval _ctimestamp; const Session* session; const timeval* rtimestamp; const timeval* ctimestamp; }; - } //------------------------------------------------------------------------------ TEST_F(StatisticTest, statistics) { - Statistics stats(count); EXPECT_EQ(count, stats.proc_types_count); Mock each_procedure_mock; EXPECT_CALL(each_procedure_mock, mock_function()) - .Times(count); + .Times(count); - stats.for_each_procedure([&](const BreakdownCounter&, size_t) - { + stats.for_each_procedure([&](const BreakdownCounter&, size_t) { each_procedure_mock.mock_function(); }); } TEST_F(StatisticTest, sessions_statistics) { - Statistics stats(count); - Mock each_procedure_mock; - Proc proc; + Mock each_procedure_mock; + Proc proc; EXPECT_CALL(each_procedure_mock, mock_function()) - .Times(1); + .Times(1); EXPECT_FALSE(stats.has_session()); stats.account(&proc, 0); EXPECT_TRUE(stats.has_session()); - stats.for_each_session([&](const Session&) - { + stats.for_each_session([&](const Session&) { each_procedure_mock.mock_function(); }); } TEST_F(StatisticTest, statistics_per_session) { - Statistics stats(count); - Mock each_procedure_mock; - Proc proc; + Mock each_procedure_mock; + Proc proc; EXPECT_CALL(each_procedure_mock, mock_function()) - .Times(count); + .Times(count); - stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) - { + stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) { each_procedure_mock.mock_function(); }); stats.account(&proc, 1); - stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) - { + stats.for_each_procedure_in_session(proc._session, [&](const BreakdownCounter&, size_t) { each_procedure_mock.mock_function(); }); } diff --git a/tests/unit/analyzers/cifs.cpp b/tests/unit/analyzers/cifs.cpp index 8b12add..e2c94a6 100644 --- a/tests/unit/analyzers/cifs.cpp +++ b/tests/unit/analyzers/cifs.cpp @@ -26,9 +26,9 @@ #include "analysis/analyzers.h" #include "analysis/cifs_parser.h" -#include "api/cifs_types.h" -#include "api/cifs_pc_to_net.h" #include "api/cifs2_commands.h" +#include "api/cifs_pc_to_net.h" +#include "api/cifs_types.h" //------------------------------------------------------------------------------ using namespace NST::filtration; using namespace NST::analysis; @@ -42,19 +42,17 @@ using ::testing::_; namespace { - class PluginMock : public IAnalyzer { public: // ISMBv2 interface - MOCK_METHOD3(readSMBv2, void(const SMBv2::ReadCommand *, const NST::API::SMBv2::ReadRequest *, const NST::API::SMBv2::ReadResponse *)); + MOCK_METHOD3(readSMBv2, void(const SMBv2::ReadCommand*, const NST::API::SMBv2::ReadRequest*, const NST::API::SMBv2::ReadResponse*)); // IAnalyzer interface void flush_statistics() {} }; - -PluginMock* pluginMock;// pointer to mock +PluginMock* pluginMock; // pointer to mock } //------------------------------------------------------------------------------ Analyzers::Analyzers(const controller::Parameters& /*params*/) @@ -62,9 +60,13 @@ Analyzers::Analyzers(const controller::Parameters& /*params*/) this->modules.push_back(pluginMock); } //------------------------------------------------------------------------------ -Parameters::Parameters(int /*argc*/, char** /*argv*/) {} +Parameters::Parameters(int /*argc*/, char** /*argv*/) +{ +} -Parameters::~Parameters() {} +Parameters::~Parameters() +{ +} bool Parameters::show_help() const { @@ -142,19 +144,32 @@ const std::string Plugin::usage_of(const std::string& /*path*/) return ""; } -DynamicLoad::DynamicLoad(const std::string &/*file*/) {} +DynamicLoad::DynamicLoad(const std::string& /*file*/) +{ +} -DynamicLoad::~DynamicLoad() {} +DynamicLoad::~DynamicLoad() +{ +} -template<typename plugin_get_entry_points_func> +template <typename plugin_get_entry_points_func> void load_address_of(const std::string& /*name*/, plugin_get_entry_points_func& /*address*/) -{} +{ +} -Plugin::Plugin(const std::string& path) : DynamicLoad(path) {} +Plugin::Plugin(const std::string& path) + : DynamicLoad(path) +{ +} -PluginInstance::PluginInstance(const std::string& path, const std::string& /*args*/) : Plugin(path) {} +PluginInstance::PluginInstance(const std::string& path, const std::string& /*args*/) + : Plugin(path) +{ +} -PluginInstance::~PluginInstance() {} +PluginInstance::~PluginInstance() +{ +} //------------------------------------------------------------------------------ TEST(Parser, CIFSAsyncParser) @@ -162,20 +177,20 @@ TEST(Parser, CIFSAsyncParser) pluginMock = new PluginMock; NST::controller::Parameters params(0, nullptr); - Analyzers analyzers(params); + Analyzers analyzers(params); NST::utils::FilteredDataQueue queue(1, 1); - NST::utils::FilteredData* data = queue.allocate(); - NetworkSession s; + NST::utils::FilteredData* data = queue.allocate(); + NetworkSession s; data->session = &s; queue.push(data); NST::utils::FilteredDataQueue::List list(queue); - NST::utils::FilteredDataQueue::Ptr el = list.get_current(); + NST::utils::FilteredDataQueue::Ptr el = list.get_current(); CIFSv2::MessageHeader header; - header.head_code = NST::API::SMBv2::pc_to_net<uint32_t>(0x424d53fe);// Protocol's marker - header.cmd_code = NST::API::SMBv2::SMBv2Commands::READ; - header.flags = static_cast<uint32_t>(CIFSv2::Flags::ASYNC_COMMAND); + header.head_code = NST::API::SMBv2::pc_to_net<uint32_t>(0x424d53fe); // Protocol's marker + header.cmd_code = NST::API::SMBv2::SMBv2Commands::READ; + header.flags = static_cast<uint32_t>(CIFSv2::Flags::ASYNC_COMMAND); el->data = reinterpret_cast<uint8_t*>(&header); el->dlen = sizeof(header); @@ -184,7 +199,7 @@ TEST(Parser, CIFSAsyncParser) // Set conditions EXPECT_CALL(*pluginMock, readSMBv2(_, _, _)) - .Times(1); + .Times(1); // Do parser.parse_data(el); @@ -192,4 +207,3 @@ TEST(Parser, CIFSAsyncParser) delete pluginMock; } //------------------------------------------------------------------------------ - diff --git a/tests/unit/filtration/cifsv2.cpp b/tests/unit/filtration/cifsv2.cpp index d28a889..b24482a 100644 --- a/tests/unit/filtration/cifsv2.cpp +++ b/tests/unit/filtration/cifsv2.cpp @@ -23,8 +23,8 @@ #include <gtest/gtest.h> #include "controller/running_status.h" -#include "filtration/filtration_processor.h" #include "filtration/cifs_filtrator.h" +#include "filtration/filtration_processor.h" #include "filtration/filtrators.h" #include "filtration/packet.h" //------------------------------------------------------------------------------ @@ -36,14 +36,13 @@ using ::testing::_; namespace { - class Writer { public: - class Collection { Collection* pImpl = nullptr; + public: void set(Writer& w, NST::utils::NetworkSession* /*session_ptr*/) { @@ -52,7 +51,7 @@ public: virtual void reset() { - if (pImpl) + if(pImpl) { pImpl->reset(); } @@ -60,7 +59,7 @@ public: virtual void push(PacketInfo& info, size_t size) { - if (pImpl) + if(pImpl) { pImpl->push(info, size); } @@ -68,7 +67,7 @@ public: virtual void skip_first(size_t size) { - if (pImpl) + if(pImpl) { pImpl->skip_first(size); } @@ -76,7 +75,7 @@ public: virtual void complete(PacketInfo& info) { - if (pImpl) + if(pImpl) { pImpl->complete(info); } @@ -89,7 +88,7 @@ public: virtual const uint8_t* data() { - if (pImpl) + if(pImpl) { return pImpl->data(); } @@ -98,7 +97,7 @@ public: virtual size_t data_size() { - if (pImpl) + if(pImpl) { return pImpl->data_size(); } @@ -107,7 +106,7 @@ public: virtual size_t capacity() { - if (pImpl) + if(pImpl) { return pImpl->capacity(); } @@ -116,7 +115,7 @@ public: virtual void allocate() { - if (pImpl) + if(pImpl) { pImpl->allocate(); } @@ -127,18 +126,16 @@ public: public: MOCK_METHOD0(reset, void()); MOCK_METHOD2(push, void(PacketInfo&, size_t)); - MOCK_METHOD0(data, const uint8_t* ()); + MOCK_METHOD0(data, const uint8_t*()); MOCK_METHOD0(data_size, size_t()); MOCK_METHOD0(capacity, size_t()); MOCK_METHOD0(allocate, void()); MOCK_METHOD1(skip_first, void(size_t)); MOCK_METHOD1(complete, void(PacketInfo&)); - }; CollectionMock collection; }; - } TEST(Filtration, CIFSFiltratorReset) @@ -146,7 +143,7 @@ TEST(Filtration, CIFSFiltratorReset) // Set conditions Writer mock; EXPECT_CALL(mock.collection, reset()) - .Times(1); + .Times(1); CIFSFiltrator<Writer> f; f.set_writer(nullptr, &mock, 0); @@ -159,7 +156,7 @@ TEST(Filtration, filtratorsResets) // Set conditions Writer mock; EXPECT_CALL(mock.collection, reset()) - .Times(2); + .Times(2); Filtrators<Writer> f; f.set_writer(nullptr, &mock, 0); @@ -172,25 +169,24 @@ TEST(Filtration, pushRPCheader) // Prepare data struct pcap_pkthdr header; header.caplen = header.len = 16; - const uint8_t packet[] = {0x80, 0x00, 0x00, 0x84, + const uint8_t packet[] = {0x80, 0x00, 0x00, 0x84, 0xec, 0x8a, 0x42, 0xcb, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02 - }; + 0x00, 0x00, 0x00, 0x02}; PacketInfo info(&header, packet, 0); Writer mock; EXPECT_CALL(mock.collection, data()) - .WillRepeatedly(Return(packet)); + .WillRepeatedly(Return(packet)); EXPECT_CALL(mock.collection, data_size()) - .WillOnce(Return(0)) - .WillOnce(Return(0)) - .WillRepeatedly(Return(sizeof(packet))); + .WillOnce(Return(0)) + .WillOnce(Return(0)) + .WillRepeatedly(Return(sizeof(packet))); EXPECT_CALL(mock.collection, capacity()) - .WillRepeatedly(Return(1000000)); + .WillRepeatedly(Return(1000000)); // Set conditions EXPECT_CALL(mock.collection, push(_, _)) - .Times(AtLeast(1)); + .Times(AtLeast(1)); Filtrators<Writer> f; f.set_writer(nullptr, &mock, 0); @@ -203,25 +199,24 @@ TEST(Filtration, pushCIFSheader) // Prepare data struct pcap_pkthdr header; header.caplen = header.len = 16; - const uint8_t packet[] = {0x00, 0x00, 0x00, 0x68, + const uint8_t packet[] = {0x00, 0x00, 0x00, 0x68, 0xfe, 0x53, 0x4d, 0x42, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00}; PacketInfo info(&header, packet, 0); Writer mock; EXPECT_CALL(mock.collection, data()) - .WillRepeatedly(Return(packet)); + .WillRepeatedly(Return(packet)); EXPECT_CALL(mock.collection, data_size()) - .WillOnce(Return(0)) - .WillOnce(Return(0)) - .WillRepeatedly(Return(sizeof(packet))); + .WillOnce(Return(0)) + .WillOnce(Return(0)) + .WillRepeatedly(Return(sizeof(packet))); EXPECT_CALL(mock.collection, capacity()) - .WillRepeatedly(Return(1000000)); + .WillRepeatedly(Return(1000000)); // Set conditions EXPECT_CALL(mock.collection, push(_, _)) - .Times(AtLeast(1)); + .Times(AtLeast(1)); Filtrators<Writer> f; f.set_writer(nullptr, &mock, 0); diff --git a/tests/unit/filtration/stream.cpp b/tests/unit/filtration/stream.cpp index cc8c1f6..e79a90a 100644 --- a/tests/unit/filtration/stream.cpp +++ b/tests/unit/filtration/stream.cpp @@ -25,8 +25,8 @@ #include <gtest/gtest.h> #include "controller/running_status.h" -#include "filtration/filtration_processor.h" #include "filtration/cifs_filtrator.h" +#include "filtration/filtration_processor.h" #include "filtration/filtrators.h" #include "filtration/packet.h" //------------------------------------------------------------------------------ @@ -35,16 +35,16 @@ using ::testing::Return; using ::testing::AtLeast; using ::testing::_; //------------------------------------------------------------------------------ -namespace { - +namespace +{ class Writer { public: - class Collection { std::vector<uint8_t> packet; - Collection *pImpl = nullptr; + Collection* pImpl = nullptr; + public: void set(Writer& w, NST::utils::NetworkSession* /*session_ptr*/) { @@ -67,7 +67,7 @@ public: virtual void complete(PacketInfo& info) { - if (pImpl) + if(pImpl) { pImpl->complete(info); } @@ -78,7 +78,7 @@ public: return true; } - virtual const uint8_t * data() + virtual const uint8_t* data() { return packet.data(); } @@ -102,15 +102,13 @@ public: public: MOCK_METHOD0(reset, void()); MOCK_METHOD2(push, void(PacketInfo&, size_t)); - MOCK_METHOD0(data, const uint8_t *()); + MOCK_METHOD0(data, const uint8_t*()); MOCK_METHOD0(data_size, size_t()); MOCK_METHOD1(complete, void(PacketInfo&)); - }; CollectionMock collection; }; - } TEST(Filtration, pushCIFSbyTCPStream) @@ -118,7 +116,7 @@ TEST(Filtration, pushCIFSbyTCPStream) // Prepare data struct pcap_pkthdr header; header.caplen = header.len = 132; - const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80, + const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80, 0xfe, 0x53, 0x4d, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -158,10 +156,9 @@ TEST(Filtration, pushCIFSbyTCPStream) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00}; PacketInfo info(&header, packet, 0); - Writer mock; + Writer mock; // Set conditions EXPECT_CALL(mock.collection, complete(_)) .Times(AtLeast(1)); @@ -177,7 +174,7 @@ TEST(Filtration, pushCIFSbyTCPStreamPartByPart) // Prepare data struct pcap_pkthdr header1; header1.caplen = header1.len = 3; - const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80, + const uint8_t packet[] = {0x00, 0x00, 0x00, 0x80, 0xfe, 0x53, 0x4d, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -217,14 +214,13 @@ TEST(Filtration, pushCIFSbyTCPStreamPartByPart) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00}; PacketInfo info1(&header1, packet, 0); struct pcap_pkthdr header2; header2.caplen = header2.len = sizeof(packet) - header1.len; PacketInfo info2(&header2, packet + header1.len, 0); - Writer mock; + Writer mock; // Set conditions EXPECT_CALL(mock.collection, complete(_)) @@ -242,10 +238,10 @@ TEST(Filtration, pushRPCbyTCPStream) // Prepare data struct pcap_pkthdr header; header.caplen = header.len = 132; - const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80, + const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80, 0xec, 0x8a, 0x42, 0xcb, - 0x00, 0x00, 0x00, 0x00,// msg type - call - 0x00, 0x00, 0x00, 0x02,// RPC version + 0x00, 0x00, 0x00, 0x00, // msg type - call + 0x00, 0x00, 0x00, 0x02, // RPC version 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -282,10 +278,9 @@ TEST(Filtration, pushRPCbyTCPStream) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00}; PacketInfo info(&header, packet, 0); - Writer mock; + Writer mock; // Set conditions EXPECT_CALL(mock.collection, complete(_)) .Times(AtLeast(1)); @@ -301,10 +296,10 @@ TEST(Filtration, pushRPCbyTCPStreamPartByPart) // Prepare data struct pcap_pkthdr header1; header1.caplen = header1.len = 3; - const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80, + const uint8_t packet[] = {0x80, 0x00, 0x00, 0x80, 0xec, 0x8a, 0x42, 0xcb, - 0x00, 0x00, 0x00, 0x00,// msg type - call - 0x00, 0x00, 0x00, 0x02,// RPC version + 0x00, 0x00, 0x00, 0x00, // msg type - call + 0x00, 0x00, 0x00, 0x02, // RPC version 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -341,14 +336,13 @@ TEST(Filtration, pushRPCbyTCPStreamPartByPart) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00}; PacketInfo info1(&header1, packet, 0); struct pcap_pkthdr header2; header2.caplen = header2.len = sizeof(packet) - header1.len; PacketInfo info2(&header2, packet + header1.len, 0); - Writer mock; + Writer mock; // Set conditions EXPECT_CALL(mock.collection, complete(_)) @@ -362,4 +356,3 @@ TEST(Filtration, pushRPCbyTCPStreamPartByPart) } //------------------------------------------------------------------------------ - diff --git a/tests/unit/protocols/cifsv2.cpp b/tests/unit/protocols/cifsv2.cpp index 2d5508f..49967bd 100644 --- a/tests/unit/protocols/cifsv2.cpp +++ b/tests/unit/protocols/cifsv2.cpp @@ -19,9 +19,9 @@ along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. */ //------------------------------------------------------------------------------ +#include <arpa/inet.h> #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <arpa/inet.h> #include "api/cifs2_commands.h" #include "api/cifs_commands.h" @@ -38,8 +38,7 @@ TEST(CIFSv2, check_CIFS_constants_helpers) // UseCase: CIFSv1/CIFSv2 uses LE byteorder for encoding fields of messages // in network traffic. These messages may be read on BE platform and should // be compared with constants with corresponded BE byte order. - union TestData - { + union TestData { std::uint64_t ui64; std::uint32_t ui32; std::uint16_t ui16; @@ -73,26 +72,25 @@ TEST(CIFSv2, check_CIFS_constants_helpers) EXPECT_EQ(data.bytes[1], 0xEE); } - TEST(CIFSv2, bodies) { EXPECT_EQ(36u, sizeof(struct NegotiateRequest) - sizeof(Dialects)); EXPECT_EQ(65u, sizeof(struct NegotiateResponse)); EXPECT_EQ(25u, sizeof(struct SessionSetupRequest)); - EXPECT_EQ(9u, sizeof(struct SessionSetupResponse)); + EXPECT_EQ(9u, sizeof(struct SessionSetupResponse)); - EXPECT_EQ(4u, sizeof(struct LogOffRequest)); - EXPECT_EQ(4u, sizeof(struct LogOffResponse)); + EXPECT_EQ(4u, sizeof(struct LogOffRequest)); + EXPECT_EQ(4u, sizeof(struct LogOffResponse)); - EXPECT_EQ(4u, sizeof(struct EchoRequest)); - EXPECT_EQ(4u, sizeof(struct EchoResponse)); + EXPECT_EQ(4u, sizeof(struct EchoRequest)); + EXPECT_EQ(4u, sizeof(struct EchoResponse)); - EXPECT_EQ(9u, sizeof(struct TreeConnectRequest)); + EXPECT_EQ(9u, sizeof(struct TreeConnectRequest)); EXPECT_EQ(16u, sizeof(struct TreeConnectResponse)); - EXPECT_EQ(4u, sizeof(struct TreeDisconnectRequest)); - EXPECT_EQ(4u, sizeof(struct TreeDisconnectResponse)); + EXPECT_EQ(4u, sizeof(struct TreeDisconnectRequest)); + EXPECT_EQ(4u, sizeof(struct TreeDisconnectResponse)); EXPECT_EQ(57u, sizeof(struct CreateRequest)); EXPECT_EQ(89u, sizeof(struct CreateResponse)); @@ -101,13 +99,13 @@ TEST(CIFSv2, bodies) EXPECT_EQ(60u, sizeof(struct CloseResponse)); EXPECT_EQ(41u, sizeof(struct QueryInfoRequest)); - EXPECT_EQ(9u, sizeof(struct QueryInfoResponse)); + EXPECT_EQ(9u, sizeof(struct QueryInfoResponse)); EXPECT_EQ(33u, sizeof(struct QueryDirRequest)); - EXPECT_EQ(9u, sizeof(struct QueryDirResponse)); + EXPECT_EQ(9u, sizeof(struct QueryDirResponse)); EXPECT_EQ(24u, sizeof(struct FlushRequest)); - EXPECT_EQ(4u, sizeof(struct FlushResponse)); + EXPECT_EQ(4u, sizeof(struct FlushResponse)); EXPECT_EQ(49u, sizeof(struct ReadRequest)); EXPECT_EQ(17u, sizeof(struct ReadResponse)); @@ -119,17 +117,17 @@ TEST(CIFSv2, bodies) EXPECT_EQ(16u, sizeof(struct WriteResponse)); EXPECT_EQ(48u, sizeof(struct LockRequest)); - EXPECT_EQ(4u, sizeof(struct LockResponse)); + EXPECT_EQ(4u, sizeof(struct LockResponse)); - EXPECT_EQ(4u, sizeof(struct CancelRequest)); + EXPECT_EQ(4u, sizeof(struct CancelRequest)); EXPECT_EQ(32u, sizeof(struct ChangeNotifyRequest)); - EXPECT_EQ(8u + sizeof(struct FileNotifyInformation), sizeof(struct ChangeNotifyResponse)); + EXPECT_EQ(8u + sizeof(struct FileNotifyInformation), sizeof(struct ChangeNotifyResponse)); EXPECT_EQ(57u, sizeof(struct IoCtlRequest)); EXPECT_EQ(49u, sizeof(struct IoCtlResponse)); EXPECT_EQ(33u, sizeof(struct SetInfoRequest)); - EXPECT_EQ(2u, sizeof(struct SetInfoResponse)); + EXPECT_EQ(2u, sizeof(struct SetInfoResponse)); } //------------------------------------------------------------------------------ diff --git a/tests/unit/utils/block_allocator.cpp b/tests/unit/utils/block_allocator.cpp new file mode 100644 index 0000000..0832408 --- /dev/null +++ b/tests/unit/utils/block_allocator.cpp @@ -0,0 +1,77 @@ +//------------------------------------------------------------------------------ +// Author: Pavel Karneliuk +// Description: Unit tests for BlockAllocator +// Copyright (c) 2016 Pavel Karneliuk +//------------------------------------------------------------------------------ +/* + This file is part of Nfstrace. + + Nfstrace is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2 of the License. + + Nfstrace is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Nfstrace. If not, see <http://www.gnu.org/licenses/>. +*/ +//------------------------------------------------------------------------------ +#include <vector> + +#include <gtest/gtest.h> + +#include <utils/block_allocator.h> +//------------------------------------------------------------------------------ +using namespace NST::utils; +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +TEST(BlockAllocator, testBasicOperations) +{ + BlockAllocator allocator; + + using Item = char[64]; + const std::size_t nperblocks = 1024; + const std::size_t lim_blocks = 1; + + EXPECT_NO_THROW( + allocator.init_allocation(sizeof(Item), nperblocks, lim_blocks)); + + ASSERT_EQ(lim_blocks, allocator.max_blocks()); + ASSERT_EQ(nperblocks, allocator.free_chunks()); + ASSERT_EQ(nperblocks * lim_blocks, allocator.max_chunks()); + + std::vector<void*> allocated; + allocated.reserve(nperblocks + 1); + + { // get all memory chunks from preallocated block + for(std::size_t i = 0; i < nperblocks; ++i) + { + allocated.emplace_back(allocator.allocate()); + } + ASSERT_EQ(0u, allocator.free_chunks()); + } + + { // increase soft limit implicitly during allocation one new item + const auto old = allocator.max_blocks(); + allocated.emplace_back(allocator.allocate()); + ASSERT_EQ(old + 1, allocator.max_blocks()); + ASSERT_EQ(nperblocks - 1, allocator.free_chunks()); + } + + { // get last recently deallocated during new allocation + const auto old = allocator.allocate(); + allocator.deallocate(old); + const auto same = allocator.allocate(); + ASSERT_EQ(old, same); + allocated.emplace_back(same); + } + + for(auto& a : allocated) + { + allocator.deallocate(a); + } +} +//------------------------------------------------------------------------------ diff --git a/tests/unit/utils/filtered_data.cpp b/tests/unit/utils/filtered_data.cpp index c5a1e2b..9634b3b 100644 --- a/tests/unit/utils/filtered_data.cpp +++ b/tests/unit/utils/filtered_data.cpp @@ -1,5 +1,5 @@ -#include <gtest/gtest.h> #include <gmock/gmock.h> +#include <gtest/gtest.h> #include <utils/filtered_data.h> TEST(FilteredData, construct) diff --git a/third_party/README b/third_party/README new file mode 100644 index 0000000..4ebefa3 --- /dev/null +++ b/third_party/README @@ -0,0 +1,2 @@ +Here are third party libraries with necessary components for nfstrace. + diff --git a/traces/references/breakdown/1-packet.pcap.bz2.ref b/traces/references/breakdown/1-packet.pcap.bz2.ref index e030f50..bc935c3 100644 --- a/traces/references/breakdown/1-packet.pcap.bz2.ref +++ b/traces/references/breakdown/1-packet.pcap.bz2.ref @@ -1,233 +1,10 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/2sessions-tcp-wsize32k-tcp-wsize512k.pcap.bz2.ref b/traces/references/breakdown/2sessions-tcp-wsize32k-tcp-wsize512k.pcap.bz2.ref index 3e063bb..c472d45 100644 --- a/traces/references/breakdown/2sessions-tcp-wsize32k-tcp-wsize512k.pcap.bz2.ref +++ b/traces/references/breakdown/2sessions-tcp-wsize32k-tcp-wsize512k.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 413. Per operation: @@ -221,110 +125,6 @@ FSINFO Count: 2 ( 4.35%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 1 ( 2.17%) Min: 0.001 Max: 0.001 Avg: 0.001 StDev: 0.00000000 COMMIT Count: 1 ( 2.17%) Min: 0.148 Max: 0.148 Avg: 0.148 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-cifs2.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-cifs2.pcap.bz2.ref index ca3eba8..ee4c270 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-cifs2.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-cifs2.pcap.bz2.ref @@ -1,81 +1,5 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### CIFS v2 protocol Total operations: 30. Per operation: @@ -121,135 +45,8 @@ QUERY INFO Count: 2 ( 6.67%) Min: 0.001 Max: 0.001 Avg: 0.001 St SET INFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 OPLOCK BREAK Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv3-4-readdir-75k-entries.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv3-4-readdir-75k-entries.pcap.bz2.ref index 693bf37..a91f4ec 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv3-4-readdir-75k-entries.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv3-4-readdir-75k-entries.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 3892. Per operation: @@ -263,65 +167,4 @@ WRITE Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv3.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv3.pcap.bz2.ref index 79f508b..2226eb0 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv3.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv3.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 3331. Per operation: @@ -149,110 +53,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 10 ( 0.30%) Min: 0.001 Max: 0.001 Avg: 0.001 StDev: 0.00019761 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv4-incorrect_mount.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv4-incorrect_mount.pcap.bz2.ref index e949e6a..ef294bb 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv4-incorrect_mount.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv4-incorrect_mount.pcap.bz2.ref @@ -1,128 +1,9 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v4.0 protocol Total procedures: 3. Per procedure: @@ -214,65 +95,4 @@ WRITE Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv4-posix.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv4-posix.pcap.bz2.ref index b3fe4ac..b301fbd 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv4-posix.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv4-posix.pcap.bz2.ref @@ -1,128 +1,9 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v4.0 protocol Total procedures: 100671. Per procedure: @@ -522,65 +403,4 @@ WRITE Count: 32 ( 22.07%) Min: 0.000 Max: 0.000 Avg: 0.000 St RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv4.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv4.pcap.bz2.ref index 87a9b5d..d0d6926 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv4.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv4.pcap.bz2.ref @@ -1,128 +1,9 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v4.0 protocol Total procedures: 1607. Per procedure: @@ -214,65 +95,4 @@ WRITE Count: 1600 ( 33.20%) Min: 0.002 Max: 0.007 Avg: 0.005 St RELEASE_LOCKOWNER Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 GET_DIR_DELEGATION Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-nfsv41.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-nfsv41.pcap.bz2.ref index 2f8c4b9..78c4199 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-nfsv41.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-nfsv41.pcap.bz2.ref @@ -1,128 +1,9 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v4.0 protocol Total procedures: 1. Per procedure: diff --git a/traces/references/breakdown/eth-ipv4-tcp-smb2-putty.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-smb2-putty.pcap.bz2.ref index 1ad3417..85dea77 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-smb2-putty.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-smb2-putty.pcap.bz2.ref @@ -1,81 +1,5 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### CIFS v2 protocol Total operations: 35. Per operation: @@ -121,135 +45,8 @@ QUERY INFO Count: 3 ( 8.57%) Min: 0.000 Max: 0.000 Avg: 0.000 St SET INFO Count: 2 ( 5.71%) Min: 0.000 Max: 0.001 Avg: 0.001 StDev: 0.00039244 OPLOCK BREAK Count: 1 ( 2.86%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-tcp-smb2-zero-file-rw.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-tcp-smb2-zero-file-rw.pcap.bz2.ref index 62e6b3c..057d486 100644 --- a/traces/references/breakdown/eth-ipv4-tcp-smb2-zero-file-rw.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-tcp-smb2-zero-file-rw.pcap.bz2.ref @@ -1,81 +1,5 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### CIFS v2 protocol Total operations: 928. Per operation: @@ -121,135 +45,8 @@ QUERY INFO Count: 62 ( 6.68%) Min: 0.000 Max: 0.001 Avg: 0.001 St SET INFO Count: 6 ( 0.65%) Min: 0.000 Max: 0.001 Avg: 0.000 StDev: 0.00009635 OPLOCK BREAK Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v3 protocol -Total operations: 0. Per operation: -NULL 0 0.00% -GETATTR 0 0.00% -SETATTR 0 0.00% -LOOKUP 0 0.00% -ACCESS 0 0.00% -READLINK 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -CREATE 0 0.00% -MKDIR 0 0.00% -SYMLINK 0 0.00% -MKNOD 0 0.00% -REMOVE 0 0.00% -RMDIR 0 0.00% -RENAME 0 0.00% -LINK 0 0.00% -READDIR 0 0.00% -READDIRPLUS 0 0.00% -FSSTAT 0 0.00% -FSINFO 0 0.00% -PATHCONF 0 0.00% -COMMIT 0 0.00% +NFS v3 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-udp-nfsv3-dup-retransm.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-udp-nfsv3-dup-retransm.pcap.bz2.ref index a0592e2..a9ac6f7 100644 --- a/traces/references/breakdown/eth-ipv4-udp-nfsv3-dup-retransm.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-udp-nfsv3-dup-retransm.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 11. Per operation: @@ -149,110 +53,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-udp-nfsv3-reply-first.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-udp-nfsv3-reply-first.pcap.bz2.ref index f5e643d..fe0f493 100644 --- a/traces/references/breakdown/eth-ipv4-udp-nfsv3-reply-first.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-udp-nfsv3-reply-first.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 57. Per operation: @@ -173,110 +77,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv4-udp-nfsv3.pcap.bz2.ref b/traces/references/breakdown/eth-ipv4-udp-nfsv3.pcap.bz2.ref index 09829d2..38e06af 100644 --- a/traces/references/breakdown/eth-ipv4-udp-nfsv3.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv4-udp-nfsv3.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 58. Per operation: @@ -173,110 +77,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv6-tcp-nfsv3-bad_alloc.pcap.bz2.ref b/traces/references/breakdown/eth-ipv6-tcp-nfsv3-bad_alloc.pcap.bz2.ref index a9476d9..1261a9a 100644 --- a/traces/references/breakdown/eth-ipv6-tcp-nfsv3-bad_alloc.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv6-tcp-nfsv3-bad_alloc.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 28179. Per operation: @@ -149,110 +53,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/eth-ipv6-tcp-nfsv3.pcap.bz2.ref b/traces/references/breakdown/eth-ipv6-tcp-nfsv3.pcap.bz2.ref index 3063326..85250b8 100644 --- a/traces/references/breakdown/eth-ipv6-tcp-nfsv3.pcap.bz2.ref +++ b/traces/references/breakdown/eth-ipv6-tcp-nfsv3.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 1605. Per operation: @@ -149,110 +53,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 1 ( 0.06%) Min: 0.854 Max: 0.854 Avg: 0.854 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/lo-ipv4-tcp-nfsv3-nfsacl.pcap.bz2.ref b/traces/references/breakdown/lo-ipv4-tcp-nfsv3-nfsacl.pcap.bz2.ref index 02e6193..cac7bfd 100644 --- a/traces/references/breakdown/lo-ipv4-tcp-nfsv3-nfsacl.pcap.bz2.ref +++ b/traces/references/breakdown/lo-ipv4-tcp-nfsv3-nfsacl.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 7. Per operation: @@ -173,110 +77,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. diff --git a/traces/references/breakdown/tcp-seq-overlap-in-fragment-12721.pcap.bz2.ref b/traces/references/breakdown/tcp-seq-overlap-in-fragment-12721.pcap.bz2.ref index 703d1f7..0995952 100644 --- a/traces/references/breakdown/tcp-seq-overlap-in-fragment-12721.pcap.bz2.ref +++ b/traces/references/breakdown/tcp-seq-overlap-in-fragment-12721.pcap.bz2.ref @@ -1,103 +1,7 @@ ### Breakdown analyzer ### -CIFS v1 protocol -Total operations: 0. Per operation: -CREATE_DIRECTORY 0 0.00% -DELETE_DIRECTORY 0 0.00% -OPEN 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -DELETE 0 0.00% -RENAME 0 0.00% -QUERY_INFORMATION 0 0.00% -SET_INFORMATION 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK_BYTE_RANGE 0 0.00% -UNLOCK_BYTE_RANGE 0 0.00% -CREATE_TEMPORARY 0 0.00% -CREATE_NEW 0 0.00% -CHECK_DIRECTORY 0 0.00% -PROCESS_EXIT 0 0.00% -SEEK 0 0.00% -LOCK_AND_READ 0 0.00% -WRITE_AND_UNLOCK 0 0.00% -READ_RAW 0 0.00% -READ_MPX 0 0.00% -READ_MPX_SECONDARY 0 0.00% -WRITE_RAW 0 0.00% -WRITE_MPX 0 0.00% -WRITE_MPX_SECONDARY 0 0.00% -WRITE_COMPLETE 0 0.00% -QUERY_SERVER 0 0.00% -SET_INFORMATION2 0 0.00% -QUERY_INFORMATION2 0 0.00% -LOCKING_ANDX 0 0.00% -TRANSACTION 0 0.00% -TRANSACTION_SECONDARY 0 0.00% -IOCTL 0 0.00% -IOCTL_SECONDARY 0 0.00% -COPY 0 0.00% -MOVE 0 0.00% -ECHO 0 0.00% -WRITE_AND_CLOSE 0 0.00% -OPEN_ANDX 0 0.00% -READ_ANDX 0 0.00% -WRITE_ANDX 0 0.00% -NEW_FILE_SIZE 0 0.00% -CLOSE_AND_TREE_DISC 0 0.00% -TRANSACTION2 0 0.00% -TRANSACTION2_SECONDARY 0 0.00% -FIND_CLOSE2 0 0.00% -FIND_NOTIFY_CLOSE 0 0.00% -TREE_CONNECT 0 0.00% -TREE_DISCONNECT 0 0.00% -NEGOTIATE 0 0.00% -SESSION_SETUP_ANDX 0 0.00% -LOGOFF_ANDX 0 0.00% -TREE_CONNECT_ANDX 0 0.00% -SECURITY_PACKAGE_ANDX 0 0.00% -QUERY_INFORMATION_DISK 0 0.00% -SEARCH 0 0.00% -FIND 0 0.00% -FIND_UNIQUE 0 0.00% -FIND_CLOSE 0 0.00% -NT_TRANSACT 0 0.00% -NT_TRANSACT_SECONDARY 0 0.00% -NT_CREATE_ANDX 0 0.00% -NT_CANCEL 0 0.00% -NT_RENAME 0 0.00% -OPEN_PRINT_FILE 0 0.00% -WRITE_PRINT_FILE 0 0.00% -CLOSE_PRINT_FILE 0 0.00% -GET_PRINT_QUEUE 0 0.00% -READ_BULK 0 0.00% -WRITE_BULK 0 0.00% -WRITE_BULK_DATA 0 0.00% -INVALID 0 0.00% -NO_ANDX_COMMAND 0 0.00% +CIFS v1 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -CIFS v2 protocol -Total operations: 0. Per operation: -NEGOTIATE 0 0.00% -SESSION SETUP 0 0.00% -LOGOFF 0 0.00% -TREE CONNECT 0 0.00% -TREE DISCONNECT 0 0.00% -CREATE 0 0.00% -CLOSE 0 0.00% -FLUSH 0 0.00% -READ 0 0.00% -WRITE 0 0.00% -LOCK 0 0.00% -IOCTL 0 0.00% -CANCEL 0 0.00% -ECHO 0 0.00% -QUERY DIRECTORY 0 0.00% -CHANGE NOTIFY 0 0.00% -QUERY INFO 0 0.00% -SET INFO 0 0.00% -OPLOCK BREAK 0 0.00% +CIFS v2 protocol: Data transmission has not been detected. ### Breakdown analyzer ### NFS v3 protocol Total operations: 6171. Per operation: @@ -149,110 +53,6 @@ FSINFO Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 St PATHCONF Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 COMMIT Count: 0 ( 0.00%) Min: 0.000 Max: 0.000 Avg: 0.000 StDev: 0.00000000 ### Breakdown analyzer ### -NFS v4.0 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -GET_DIR_DELEGATION 0 0.00% +NFS v4.0 protocol: Data transmission has not been detected. ### Breakdown analyzer ### -NFS v4.1 protocol -Total procedures: 0. Per procedure: -NULL 0 0.00% -COMPOUND 0 0.00% -Total operations: 0. Per operation: -ILLEGAL 0 0.00% -ACCESS 0 0.00% -CLOSE 0 0.00% -COMMIT 0 0.00% -CREATE 0 0.00% -DELEGPURGE 0 0.00% -DELEGRETURN 0 0.00% -GETATTR 0 0.00% -GETFH 0 0.00% -LINK 0 0.00% -LOCK 0 0.00% -LOCKT 0 0.00% -LOCKU 0 0.00% -LOOKUP 0 0.00% -LOOKUPP 0 0.00% -NVERIFY 0 0.00% -OPEN 0 0.00% -OPENATTR 0 0.00% -OPEN_CONFIRM 0 0.00% -OPEN_DOWNGRADE 0 0.00% -PUTFH 0 0.00% -PUTPUBFH 0 0.00% -PUTROOTFH 0 0.00% -READ 0 0.00% -READDIR 0 0.00% -READLINK 0 0.00% -REMOVE 0 0.00% -RENAME 0 0.00% -RENEW 0 0.00% -RESTOREFH 0 0.00% -SAVEFH 0 0.00% -SECINFO 0 0.00% -SETATTR 0 0.00% -SETCLIENTID 0 0.00% -SETCLIENTID_CONFIRM 0 0.00% -VERIFY 0 0.00% -WRITE 0 0.00% -RELEASE_LOCKOWNER 0 0.00% -BACKCHANNEL_CTL 0 0.00% -BIND_CONN_TO_SESSION 0 0.00% -EXCHANGE_ID 0 0.00% -CREATE_SESSION 0 0.00% -DESTROY_SESSION 0 0.00% -FREE_STATEID 0 0.00% -GET_DIR_DELEGATION 0 0.00% -GETDEVICEINFO 0 0.00% -GETDEVICELIST 0 0.00% -LAYOUTCOMMIT 0 0.00% -LAYOUTGET 0 0.00% -LAYOUTRETURN 0 0.00% -SECINFO_NO_NAME 0 0.00% -SEQUENCE 0 0.00% -SET_SSV 0 0.00% -TEST_STATEID 0 0.00% -WANT_DELEGATION 0 0.00% -DESTROY_CLIENTID 0 0.00% -RECLAIM_COMPLETE 0 0.00% +NFS v4.1 protocol: Data transmission has not been detected. |