mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Further simplified the packet analysis API.
This is still WIP and includes the following changes: * Dispatchers are now part of analyzers (moving dispatching logic from the manager to the analyzers) * All available analyzers are instantiated on start up * Removal of configuration class
This commit is contained in:
parent
9feda100b9
commit
d4ff5a236c
12 changed files with 104 additions and 340 deletions
|
@ -2,43 +2,31 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "Analyzer.h"
|
||||
|
||||
namespace zeek::packet_analysis {
|
||||
|
||||
class Dispatcher; // Forward decl for Value
|
||||
using DispatcherPtr = std::shared_ptr<Dispatcher>;
|
||||
class Analyzer; // Forward declaration for Value
|
||||
using AnalyzerPtr = std::shared_ptr<zeek::packet_analysis::Analyzer>;
|
||||
|
||||
using register_pair = std::pair<uint32_t, std::pair<AnalyzerPtr, DispatcherPtr>>;
|
||||
using register_map = std::map<uint32_t, std::pair<AnalyzerPtr, DispatcherPtr>>;
|
||||
|
||||
class Value {
|
||||
public:
|
||||
AnalyzerPtr analyzer;
|
||||
DispatcherPtr dispatcher;
|
||||
|
||||
Value(AnalyzerPtr analyzer, DispatcherPtr dispatcher)
|
||||
: analyzer(analyzer), dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
using ValuePtr = std::shared_ptr<Value>;
|
||||
using register_pair = std::pair<uint32_t, AnalyzerPtr>;
|
||||
using register_map = std::map<uint32_t, AnalyzerPtr>;
|
||||
|
||||
class Dispatcher {
|
||||
public:
|
||||
Dispatcher()
|
||||
: table(std::vector<ValuePtr>(1, nullptr))
|
||||
: table(std::vector<AnalyzerPtr>(1, nullptr))
|
||||
{ }
|
||||
|
||||
~Dispatcher();
|
||||
|
||||
bool Register(uint32_t identifier, AnalyzerPtr analyzer, DispatcherPtr dispatcher);
|
||||
bool Register(uint32_t identifier, AnalyzerPtr analyzer);
|
||||
void Register(const register_map& data);
|
||||
|
||||
ValuePtr Lookup(uint32_t identifier) const;
|
||||
AnalyzerPtr Lookup(uint32_t identifier) const;
|
||||
|
||||
size_t Size() const;
|
||||
void Clear();
|
||||
|
@ -46,7 +34,7 @@ public:
|
|||
|
||||
private:
|
||||
uint32_t lowest_identifier = 0;
|
||||
std::vector<ValuePtr> table;
|
||||
std::vector<AnalyzerPtr> table;
|
||||
|
||||
void FreeValues();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue