mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Move packet filter out of NetSessions
This commit is contained in:
parent
50713b3c2d
commit
c752d76052
6 changed files with 29 additions and 22 deletions
|
@ -20,6 +20,7 @@ Manager::Manager()
|
|||
Manager::~Manager()
|
||||
{
|
||||
delete pkt_profiler;
|
||||
delete pkt_filter;
|
||||
}
|
||||
|
||||
void Manager::InitPostScript()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "zeek/plugin/ComponentManager.h"
|
||||
#include "zeek/iosource/Packet.h"
|
||||
#include "zeek/packet_analysis/Dispatcher.h"
|
||||
#include "zeek/PacketFilter.h"
|
||||
|
||||
namespace zeek {
|
||||
|
||||
|
@ -112,6 +113,13 @@ public:
|
|||
*/
|
||||
void ResetUnknownProtocolTimer(const std::string& analyzer, uint32_t protocol);
|
||||
|
||||
detail::PacketFilter* GetPacketFilter(bool init=true)
|
||||
{
|
||||
if ( ! pkt_filter && init )
|
||||
pkt_filter = new detail::PacketFilter(detail::packet_filter_default);
|
||||
return pkt_filter;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Instantiates a new analyzer instance.
|
||||
|
@ -140,6 +148,7 @@ private:
|
|||
|
||||
uint64_t num_packets_processed = 0;
|
||||
detail::PacketProfiler* pkt_profiler = nullptr;
|
||||
detail::PacketFilter* pkt_filter = nullptr;
|
||||
|
||||
using UnknownProtocolPair = std::pair<std::string, uint32_t>;
|
||||
std::map<UnknownProtocolPair, uint64_t> unknown_protocols;
|
||||
|
|
|
@ -122,7 +122,7 @@ bool IPAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet)
|
|||
}
|
||||
|
||||
// Ignore if packet matches packet filter.
|
||||
detail::PacketFilter* packet_filter = sessions->GetPacketFilter(false);
|
||||
detail::PacketFilter* packet_filter = packet_mgr->GetPacketFilter(false);
|
||||
if ( packet_filter && packet_filter->Match(packet->ip_hdr, total_len, len) )
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue