mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Renamed LL-Analyzers to Packet Analyzers.
This commit is contained in:
parent
b2e6c9ac9a
commit
e53ec46c23
148 changed files with 587 additions and 587 deletions
87
src/packet_analysis/Config.cc
Normal file
87
src/packet_analysis/Config.cc
Normal file
|
@ -0,0 +1,87 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "Config.h"
|
||||
#include "Reporter.h"
|
||||
#include "DebugLogger.h"
|
||||
|
||||
namespace zeek::packet_analysis {
|
||||
|
||||
// ##############################
|
||||
// ####### DispatcherConfig #####
|
||||
// ##############################
|
||||
const std::string& DispatcherConfig::GetName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
const std::map<identifier_t, std::string>& DispatcherConfig::GetMappings() const
|
||||
{
|
||||
return mappings;
|
||||
}
|
||||
|
||||
void DispatcherConfig::AddMapping(identifier_t identifier,
|
||||
const std::string& analyzer_name)
|
||||
{
|
||||
DBG_LOG(DBG_PACKET_ANALYSIS, "Adding configuration mapping: %s -> %#x -> %s",
|
||||
name.c_str(), identifier, analyzer_name.c_str());
|
||||
|
||||
if ( mappings.count(identifier) )
|
||||
reporter->InternalError("Invalid config, identifier %#x already exists "
|
||||
"for dispatcher set %s.",
|
||||
identifier, name.c_str());
|
||||
|
||||
mappings.emplace(identifier, analyzer_name);
|
||||
}
|
||||
|
||||
bool DispatcherConfig::operator==(const DispatcherConfig& rhs) const
|
||||
{
|
||||
return name == rhs.name;
|
||||
}
|
||||
|
||||
bool DispatcherConfig::operator!=(const DispatcherConfig& rhs) const
|
||||
{
|
||||
return ! (rhs == *this);
|
||||
}
|
||||
|
||||
// ##############################
|
||||
// ########### Config ###########
|
||||
// ##############################
|
||||
std::optional<std::reference_wrapper<DispatcherConfig>>
|
||||
Config::GetDispatcherConfig(const std::string& name)
|
||||
{
|
||||
auto it = std::find_if(
|
||||
dispatchers.begin(), dispatchers.end(),
|
||||
[&](const DispatcherConfig& conf) {
|
||||
return conf.GetName() == name;
|
||||
});
|
||||
|
||||
if ( it == dispatchers.end() )
|
||||
return {};
|
||||
else
|
||||
return {std::ref(*it)};
|
||||
}
|
||||
|
||||
const std::vector<DispatcherConfig>& Config::GetDispatchers() const
|
||||
{
|
||||
return dispatchers;
|
||||
}
|
||||
|
||||
DispatcherConfig& Config::AddDispatcherConfig(const std::string& name)
|
||||
{
|
||||
return dispatchers.emplace_back(name);
|
||||
}
|
||||
|
||||
void Config::AddMapping(const std::string& name, identifier_t identifier,
|
||||
const std::string& analyzer_name)
|
||||
{
|
||||
// Create dispatcher config if it does not exist yet
|
||||
std::optional<std::reference_wrapper<DispatcherConfig>> dispatch_config =
|
||||
GetDispatcherConfig(name);
|
||||
|
||||
if ( ! dispatch_config )
|
||||
AddDispatcherConfig(name).AddMapping(identifier, analyzer_name);
|
||||
else
|
||||
dispatch_config->get().AddMapping(identifier, analyzer_name);
|
||||
}
|
||||
|
||||
} // namespace packet_analysis
|
Loading…
Add table
Add a link
Reference in a new issue