summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/analysis_manager.cpp7
-rw-r--r--src/analysis/analysis_manager.h20
-rw-r--r--src/analysis/analyzers.cpp3
-rw-r--r--src/analysis/analyzers.h32
-rw-r--r--src/analysis/cifs_parser.cpp220
-rw-r--r--src/analysis/cifs_parser.h28
-rw-r--r--src/analysis/nfs_parser.cpp239
-rw-r--r--src/analysis/nfs_parser.h19
-rw-r--r--src/analysis/parser_thread.h25
-rw-r--r--src/analysis/parsers.h17
-rw-r--r--src/analysis/plugin.cpp19
-rw-r--r--src/analysis/plugin.h15
-rw-r--r--src/analysis/print_analyzer.cpp1682
-rw-r--r--src/analysis/print_analyzer.h11
-rw-r--r--src/analysis/rpc_sessions.h30
-rw-r--r--src/api/cifs2_commands.h6
-rw-r--r--src/api/cifs_commands.h5
-rw-r--r--src/api/cifs_pc_to_net.h37
-rw-r--r--src/api/cifs_types.h220
-rw-r--r--src/api/ianalyzer.h10
-rw-r--r--src/api/nfs3_types_rpcgen.h5
-rw-r--r--src/api/nfs41_types_rpcgen.h7
-rw-r--r--src/api/nfs4_types_rpcgen.h7
-rw-r--r--src/api/nfs_types.h17
-rw-r--r--src/api/procedure.h5
-rw-r--r--src/api/rpc_types.h83
-rw-r--r--src/api/session.h34
-rw-r--r--src/api/xdr_types.h14
-rw-r--r--src/controller/build_info.h.in4
-rw-r--r--src/controller/cmdline_args.cpp9
-rw-r--r--src/controller/cmdline_args.h4
-rw-r--r--src/controller/cmdline_parser.h60
-rw-r--r--src/controller/controller.cpp63
-rw-r--r--src/controller/controller.h22
-rw-r--r--src/controller/parameters.cpp73
-rw-r--r--src/controller/parameters.h43
-rw-r--r--src/controller/running_status.h66
-rw-r--r--src/controller/signal_handler.cpp38
-rw-r--r--src/controller/signal_handler.h7
-rw-r--r--src/filtration/cifs_filtrator.h34
-rw-r--r--src/filtration/dumping.cpp36
-rw-r--r--src/filtration/dumping.h72
-rw-r--r--src/filtration/filtration_manager.cpp69
-rw-r--r--src/filtration/filtration_manager.h16
-rw-r--r--src/filtration/filtration_processor.h266
-rw-r--r--src/filtration/filtratorimpl.h104
-rw-r--r--src/filtration/filtrators.h37
-rw-r--r--src/filtration/packet.h160
-rw-r--r--src/filtration/pcap/base_reader.h30
-rw-r--r--src/filtration/pcap/bpf.h10
-rw-r--r--src/filtration/pcap/capture_reader.cpp58
-rw-r--r--src/filtration/pcap/capture_reader.h16
-rw-r--r--src/filtration/pcap/file_reader.cpp6
-rw-r--r--src/filtration/pcap/file_reader.h16
-rw-r--r--src/filtration/pcap/network_interfaces.h107
-rw-r--r--src/filtration/pcap/packet_dumper.h16
-rw-r--r--src/filtration/pcap/pcap_error.h7
-rw-r--r--src/filtration/processing_thread.h16
-rw-r--r--src/filtration/queuing.h49
-rw-r--r--src/filtration/rpc_filtrator.h55
-rw-r--r--src/filtration/sessions_hash.h63
-rw-r--r--src/main.cpp6
-rw-r--r--src/protocols/cifs/cifs.cpp16
-rw-r--r--src/protocols/cifs/cifs.h8
-rw-r--r--src/protocols/cifs2/cifs2.cpp40
-rw-r--r--src/protocols/cifs2/cifs2.h20
-rw-r--r--src/protocols/cifs2/cifs2_utils.cpp163
-rw-r--r--src/protocols/cifs2/cifs2_utils.h11
-rw-r--r--src/protocols/ethernet/ethernet_header.h44
-rw-r--r--src/protocols/ip/ip_header.h63
-rw-r--r--src/protocols/ip/ipv4_header.h29
-rw-r--r--src/protocols/ip/ipv6_header.h76
-rw-r--r--src/protocols/netbios/netbios.h17
-rw-r--r--src/protocols/nfs/nfs_procedure.h69
-rw-r--r--src/protocols/nfs/nfs_utils.cpp25
-rw-r--r--src/protocols/nfs/nfs_utils.h41
-rw-r--r--src/protocols/nfs3/nfs3_utils.cpp213
-rw-r--r--src/protocols/nfs3/nfs3_utils.h115
-rw-r--r--src/protocols/nfs4/nfs41_utils.cpp16
-rw-r--r--src/protocols/nfs4/nfs41_utils.h34
-rw-r--r--src/protocols/nfs4/nfs4_utils.cpp18
-rw-r--r--src/protocols/nfs4/nfs4_utils.h35
-rw-r--r--src/protocols/rpc/rpc_header.h77
-rw-r--r--src/protocols/tcp/tcp_header.h61
-rw-r--r--src/protocols/udp/udp_header.h23
-rw-r--r--src/protocols/xdr/xdr_decoder.h22
-rw-r--r--src/utils/block_allocator.h140
-rw-r--r--src/utils/dynamic_load.cpp4
-rw-r--r--src/utils/dynamic_load.h14
-rw-r--r--src/utils/filtered_data.h57
-rw-r--r--src/utils/log.cpp34
-rw-r--r--src/utils/log.h43
-rw-r--r--src/utils/out.cpp3
-rw-r--r--src/utils/out.h15
-rw-r--r--src/utils/profiler.h18
-rw-r--r--src/utils/queue.h107
-rw-r--r--src/utils/sessions.cpp182
-rw-r--r--src/utils/sessions.h15
-rw-r--r--src/utils/spinlock.h7
99 files changed, 3288 insertions, 3042 deletions
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
//------------------------------------------------------------------------------