mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
Remove Session prefix from some session-related classes and files
This commit is contained in:
parent
18c6aaaa33
commit
0b7ca5e7bc
37 changed files with 121 additions and 122 deletions
|
@ -10,7 +10,7 @@
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/Timer.h"
|
#include "zeek/Timer.h"
|
||||||
#include "zeek/iosource/IOSource.h"
|
#include "zeek/iosource/IOSource.h"
|
||||||
|
|
11
src/Conn.h
11
src/Conn.h
|
@ -32,7 +32,7 @@ class RecordVal;
|
||||||
using ValPtr = IntrusivePtr<Val>;
|
using ValPtr = IntrusivePtr<Val>;
|
||||||
using RecordValPtr = IntrusivePtr<RecordVal>;
|
using RecordValPtr = IntrusivePtr<RecordVal>;
|
||||||
|
|
||||||
namespace session { class SessionManager; }
|
namespace session { class Manager; }
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
class Specific_RE_Matcher;
|
class Specific_RE_Matcher;
|
||||||
|
@ -114,8 +114,8 @@ public:
|
||||||
// connection is in the session map. If it is removed, the key
|
// connection is in the session map. If it is removed, the key
|
||||||
// should be marked invalid.
|
// should be marked invalid.
|
||||||
const detail::ConnIDKey& Key() const { return key; }
|
const detail::ConnIDKey& Key() const { return key; }
|
||||||
session::detail::SessionKey SessionKey(bool copy) const override
|
session::detail::Key SessionKey(bool copy) const override
|
||||||
{ return session::detail::SessionKey{&key, sizeof(key), copy}; }
|
{ return session::detail::Key{&key, sizeof(key), copy}; }
|
||||||
|
|
||||||
const IPAddr& OrigAddr() const { return orig_addr; }
|
const IPAddr& OrigAddr() const { return orig_addr; }
|
||||||
const IPAddr& RespAddr() const { return resp_addr; }
|
const IPAddr& RespAddr() const { return resp_addr; }
|
||||||
|
@ -251,10 +251,9 @@ public:
|
||||||
bool PermitWeird(const char* name, uint64_t threshold, uint64_t rate,
|
bool PermitWeird(const char* name, uint64_t threshold, uint64_t rate,
|
||||||
double duration);
|
double duration);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
// Allow other classes to access pointers to these:
|
friend class session::detail::Timer;
|
||||||
friend class session::detail::SessionTimer;
|
|
||||||
|
|
||||||
IPAddr orig_addr;
|
IPAddr orig_addr;
|
||||||
IPAddr resp_addr;
|
IPAddr resp_addr;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "zeek/Hash.h"
|
#include "zeek/Hash.h"
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ void FragTimer::Dispatch(double t, bool /* is_expire */)
|
||||||
reporter->InternalWarning("fragment timer dispatched w/o reassembler");
|
reporter->InternalWarning("fragment timer dispatched w/o reassembler");
|
||||||
}
|
}
|
||||||
|
|
||||||
FragReassembler::FragReassembler(session::SessionManager* arg_s,
|
FragReassembler::FragReassembler(session::Manager* arg_s,
|
||||||
const std::unique_ptr<IP_Hdr>& ip, const u_char* pkt,
|
const std::unique_ptr<IP_Hdr>& ip, const u_char* pkt,
|
||||||
const FragReassemblerKey& k, double t)
|
const FragReassemblerKey& k, double t)
|
||||||
: Reassembler(0, REASSEM_FRAG)
|
: Reassembler(0, REASSEM_FRAG)
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace zeek {
|
||||||
|
|
||||||
class IP_Hdr;
|
class IP_Hdr;
|
||||||
|
|
||||||
namespace session { class SessionManager; }
|
namespace session { class Manager; }
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ using FragReassemblerKey = std::tuple<IPAddr, IPAddr, bro_uint_t>;
|
||||||
|
|
||||||
class FragReassembler : public Reassembler {
|
class FragReassembler : public Reassembler {
|
||||||
public:
|
public:
|
||||||
FragReassembler(session::SessionManager* s, const std::unique_ptr<IP_Hdr>& ip,
|
FragReassembler(session::Manager* s, const std::unique_ptr<IP_Hdr>& ip,
|
||||||
const u_char* pkt, const FragReassemblerKey& k, double t);
|
const u_char* pkt, const FragReassemblerKey& k, double t);
|
||||||
~FragReassembler() override;
|
~FragReassembler() override;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ protected:
|
||||||
|
|
||||||
u_char* proto_hdr;
|
u_char* proto_hdr;
|
||||||
std::unique_ptr<IP_Hdr> reassembled_pkt;
|
std::unique_ptr<IP_Hdr> reassembled_pkt;
|
||||||
session::SessionManager* s;
|
session::Manager* s;
|
||||||
uint64_t frag_size; // size of fully reassembled fragment
|
uint64_t frag_size; // size of fully reassembled fragment
|
||||||
FragReassemblerKey key;
|
FragReassemblerKey key;
|
||||||
uint16_t next_proto; // first IPv6 fragment header's next proto field
|
uint16_t next_proto; // first IPv6 fragment header's next proto field
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "zeek/Frame.h"
|
#include "zeek/Frame.h"
|
||||||
#include "zeek/Var.h"
|
#include "zeek/Var.h"
|
||||||
#include "zeek/analyzer/protocol/login/Login.h"
|
#include "zeek/analyzer/protocol/login/Login.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/RE.h"
|
#include "zeek/RE.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Traverse.h"
|
#include "zeek/Traverse.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Timer.h"
|
#include "zeek/Timer.h"
|
||||||
#include "zeek/ID.h"
|
#include "zeek/ID.h"
|
||||||
|
@ -195,7 +195,7 @@ void init_run(const std::optional<std::string>& interface,
|
||||||
|
|
||||||
zeek::detail::init_ip_addr_anonymizers();
|
zeek::detail::init_ip_addr_anonymizers();
|
||||||
|
|
||||||
session_mgr = new session::SessionManager();
|
session_mgr = new session::Manager();
|
||||||
|
|
||||||
// Initialize the stepping stone manager. We intentionally throw away the result here.
|
// Initialize the stepping stone manager. We intentionally throw away the result here.
|
||||||
SteppingStoneManager::Get();
|
SteppingStoneManager::Get();
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#warning "This file is deprecated and will be removed in v5.1. Use session/SessionManager.h instead."
|
#warning "This file is deprecated and will be removed in v5.1. Use session/Manager.h instead."
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/ID.h"
|
#include "zeek/ID.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Scope.h"
|
#include "zeek/Scope.h"
|
||||||
#include "zeek/DNS_Mgr.h"
|
#include "zeek/DNS_Mgr.h"
|
||||||
#include "zeek/Trigger.h"
|
#include "zeek/Trigger.h"
|
||||||
|
@ -145,7 +145,7 @@ void ProfileLogger::Log()
|
||||||
expensive ? session_mgr->SessionMemoryUsageVals() / 1024 : 0
|
expensive ? session_mgr->SessionMemoryUsageVals() / 1024 : 0
|
||||||
));
|
));
|
||||||
|
|
||||||
session::SessionStats s;
|
session::Stats s;
|
||||||
session_mgr->GetStats(s);
|
session_mgr->GetStats(s);
|
||||||
|
|
||||||
file->Write(util::fmt("%.06f Conns: tcp=%zu/%zu udp=%zu/%zu icmp=%zu/%zu\n",
|
file->Write(util::fmt("%.06f Conns: tcp=%zu/%zu udp=%zu/%zu icmp=%zu/%zu\n",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "zeek/analyzer/protocol/ayiya/AYIYA.h"
|
#include "zeek/analyzer/protocol/ayiya/AYIYA.h"
|
||||||
|
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Func.h"
|
#include "zeek/Func.h"
|
||||||
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%%{
|
%%{
|
||||||
#include "zeek/analyzer/protocol/conn-size/ConnSize.h"
|
#include "zeek/analyzer/protocol/conn-size/ConnSize.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
|
|
||||||
static zeek::analyzer::Analyzer* GetConnsizeAnalyzer(zeek::Val* cid)
|
static zeek::analyzer::Analyzer* GetConnsizeAnalyzer(zeek::Val* cid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "zeek/ZeekString.h"
|
#include "zeek/ZeekString.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "zeek/analyzer/protocol/gtpv1/GTPv1.h"
|
#include "zeek/analyzer/protocol/gtpv1/GTPv1.h"
|
||||||
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
||||||
|
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/analyzer/protocol/gtpv1/events.bif.h"
|
#include "zeek/analyzer/protocol/gtpv1/events.bif.h"
|
||||||
|
|
||||||
namespace zeek::analyzer::gtpv1 {
|
namespace zeek::analyzer::gtpv1 {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
%%{
|
%%{
|
||||||
#include "zeek/analyzer/protocol/login/Login.h"
|
#include "zeek/analyzer/protocol/login/Login.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
%%}
|
%%}
|
||||||
|
|
||||||
## Returns the state of the given login (Telnet or Rlogin) connection.
|
## Returns the state of the given login (Telnet or Rlogin) connection.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "zeek/ZeekString.h"
|
#include "zeek/ZeekString.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/analyzer/protocol/rpc/XDR.h"
|
#include "zeek/analyzer/protocol/rpc/XDR.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
|
|
||||||
#include "zeek/analyzer/protocol/rpc/events.bif.h"
|
#include "zeek/analyzer/protocol/rpc/events.bif.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "zeek/File.h"
|
#include "zeek/File.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/DebugLogger.h"
|
#include "zeek/DebugLogger.h"
|
||||||
|
|
||||||
#include "zeek/analyzer/protocol/tcp/events.bif.h"
|
#include "zeek/analyzer/protocol/tcp/events.bif.h"
|
||||||
|
|
|
@ -143,7 +143,7 @@ protected:
|
||||||
void CheckRecording(bool need_contents, TCP_Flags flags);
|
void CheckRecording(bool need_contents, TCP_Flags flags);
|
||||||
void CheckPIA_FirstPacket(bool is_orig, const IP_Hdr* ip);
|
void CheckPIA_FirstPacket(bool is_orig, const IP_Hdr* ip);
|
||||||
|
|
||||||
friend class session::detail::SessionTimer;
|
friend class session::detail::Timer;
|
||||||
void AttemptTimer(double t);
|
void AttemptTimer(double t);
|
||||||
void PartialCloseTimer(double t);
|
void PartialCloseTimer(double t);
|
||||||
void ExpireTimer(double t);
|
void ExpireTimer(double t);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
||||||
#include "zeek/analyzer/protocol/tcp/TCP_Reassembler.h"
|
#include "zeek/analyzer/protocol/tcp/TCP_Reassembler.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/File.h"
|
#include "zeek/File.h"
|
||||||
#include "zeek/Val.h"
|
#include "zeek/Val.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
%%{
|
%%{
|
||||||
#include "zeek/File.h"
|
#include "zeek/File.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
||||||
%%}
|
%%}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "zeek/Conn.h"
|
#include "zeek/Conn.h"
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/ZeekString.h"
|
#include "zeek/ZeekString.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
#include "zeek/packet_analysis/protocol/iptunnel/IPTunnel.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "zeek/zeek-setup.h"
|
#include "zeek/zeek-setup.h"
|
||||||
|
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/broker/Manager.h"
|
#include "zeek/broker/Manager.h"
|
||||||
#include "zeek/file_analysis/Manager.h"
|
#include "zeek/file_analysis/Manager.h"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/Conn.h"
|
#include "zeek/Conn.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/analyzer/Analyzer.h"
|
#include "zeek/analyzer/Analyzer.h"
|
||||||
#include "zeek/analyzer/Manager.h"
|
#include "zeek/analyzer/Manager.h"
|
||||||
#include "zeek/analyzer/protocol/pia/PIA.h"
|
#include "zeek/analyzer/protocol/pia/PIA.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "zeek/util.h"
|
#include "zeek/util.h"
|
||||||
#include "zeek/Hash.h"
|
#include "zeek/Hash.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/broker/Manager.h"
|
#include "zeek/broker/Manager.h"
|
||||||
#include "zeek/iosource/Manager.h"
|
#include "zeek/iosource/Manager.h"
|
||||||
#include "zeek/packet_analysis/Manager.h"
|
#include "zeek/packet_analysis/Manager.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "zeek/Dict.h"
|
#include "zeek/Dict.h"
|
||||||
#include "zeek/DebugLogger.h"
|
#include "zeek/DebugLogger.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/util.h"
|
#include "zeek/util.h"
|
||||||
|
|
||||||
namespace zeek::packet_analysis {
|
namespace zeek::packet_analysis {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <pcap.h> // For DLT_ constants
|
#include <pcap.h> // For DLT_ constants
|
||||||
|
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
#include "zeek/Discard.h"
|
#include "zeek/Discard.h"
|
||||||
#include "zeek/PacketFilter.h"
|
#include "zeek/PacketFilter.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/Frag.h"
|
#include "zeek/Frag.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <pcap.h> // For DLT_ constants
|
#include <pcap.h> // For DLT_ constants
|
||||||
|
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
#include "zeek/TunnelEncapsulation.h"
|
#include "zeek/TunnelEncapsulation.h"
|
||||||
|
|
|
@ -8,8 +8,8 @@ include_directories(BEFORE
|
||||||
|
|
||||||
set(session_SRCS
|
set(session_SRCS
|
||||||
Session.cc
|
Session.cc
|
||||||
SessionKey.cc
|
Key.cc
|
||||||
SessionManager.cc
|
Manager.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
bro_add_subdir_library(session ${session_SRCS})
|
bro_add_subdir_library(session ${session_SRCS})
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#include "zeek/session/SessionKey.h"
|
#include "zeek/session/Key.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace zeek::session::detail {
|
namespace zeek::session::detail {
|
||||||
|
|
||||||
SessionKey::SessionKey(const void* session, size_t size, bool copy) : size(size)
|
Key::Key(const void* session, size_t size, bool copy) : size(size)
|
||||||
{
|
{
|
||||||
data = reinterpret_cast<const uint8_t*>(session);
|
data = reinterpret_cast<const uint8_t*>(session);
|
||||||
if ( copy )
|
if ( copy )
|
||||||
CopyData();
|
CopyData();
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionKey::SessionKey(SessionKey&& rhs)
|
Key::Key(Key&& rhs)
|
||||||
{
|
{
|
||||||
data = rhs.data;
|
data = rhs.data;
|
||||||
size = rhs.size;
|
size = rhs.size;
|
||||||
|
@ -22,7 +22,7 @@ SessionKey::SessionKey(SessionKey&& rhs)
|
||||||
rhs.copied = false;
|
rhs.copied = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionKey& SessionKey::operator=(SessionKey&& rhs)
|
Key& Key::operator=(Key&& rhs)
|
||||||
{
|
{
|
||||||
if ( this != &rhs )
|
if ( this != &rhs )
|
||||||
{
|
{
|
||||||
|
@ -38,13 +38,13 @@ SessionKey& SessionKey::operator=(SessionKey&& rhs)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionKey::~SessionKey()
|
Key::~Key()
|
||||||
{
|
{
|
||||||
if ( copied )
|
if ( copied )
|
||||||
delete [] data;
|
delete [] data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionKey::CopyData()
|
void Key::CopyData()
|
||||||
{
|
{
|
||||||
if ( copied )
|
if ( copied )
|
||||||
return;
|
return;
|
||||||
|
@ -56,7 +56,7 @@ void SessionKey::CopyData()
|
||||||
data = temp;
|
data = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionKey::operator<(const SessionKey& rhs) const
|
bool Key::operator<(const Key& rhs) const
|
||||||
{
|
{
|
||||||
if ( size != rhs.size )
|
if ( size != rhs.size )
|
||||||
return size < rhs.size;
|
return size < rhs.size;
|
|
@ -12,12 +12,12 @@ namespace zeek::session::detail {
|
||||||
* raw block of memory that points to a key of some type for a session, such as
|
* raw block of memory that points to a key of some type for a session, such as
|
||||||
* a ConnIDKey for a Connection. This allows us to do type-independent
|
* a ConnIDKey for a Connection. This allows us to do type-independent
|
||||||
* comparison of the keys in the map. By default, this type does not maintain
|
* comparison of the keys in the map. By default, this type does not maintain
|
||||||
* the lifetime of the data pointed to by the SessionKey. It only holds a
|
* the lifetime of the data pointed to by the Key. It only holds a
|
||||||
* pointer. When a SessionKey object is inserted into the SessionManager's map,
|
* pointer. When a Key object is inserted into the SessionManager's map,
|
||||||
* the data is copied into the object so the lifetime of the key data is
|
* the data is copied into the object so the lifetime of the key data is
|
||||||
* guaranteed over the lifetime of the map entry.
|
* guaranteed over the lifetime of the map entry.
|
||||||
*/
|
*/
|
||||||
class SessionKey final {
|
class Key final {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,23 +25,23 @@ public:
|
||||||
*
|
*
|
||||||
* @param session A pointer to the data for the key.
|
* @param session A pointer to the data for the key.
|
||||||
* @param size The size of the key data, in bytes.
|
* @param size The size of the key data, in bytes.
|
||||||
* @param copy Flag for whether the data should be copied into the SessionKey
|
* @param copy Flag for whether the data should be copied into the Key
|
||||||
* during construction. This defaults to false because normally the only time
|
* during construction. This defaults to false because normally the only time
|
||||||
* data is copied into the key is when it's inserted into the session map.
|
* data is copied into the key is when it's inserted into the session map.
|
||||||
*/
|
*/
|
||||||
SessionKey(const void* key_data, size_t size, bool copy=false);
|
Key(const void* key_data, size_t size, bool copy=false);
|
||||||
|
|
||||||
~SessionKey();
|
~Key();
|
||||||
|
|
||||||
// Implement move semantics for SessionKey, since they're used as keys
|
// Implement move semantics for Key, since they're used as keys
|
||||||
// in a map.
|
// in a map.
|
||||||
SessionKey(SessionKey&& rhs);
|
Key(Key&& rhs);
|
||||||
SessionKey& operator=(SessionKey&& rhs);
|
Key& operator=(Key&& rhs);
|
||||||
|
|
||||||
// Explicitly delete the copy constructor and operator since copying
|
// Explicitly delete the copy constructor and operator since copying
|
||||||
// may cause issues with double-freeing pointers.
|
// may cause issues with double-freeing pointers.
|
||||||
SessionKey(const SessionKey& rhs) = delete;
|
Key(const Key& rhs) = delete;
|
||||||
SessionKey& operator=(const SessionKey& rhs) = delete;
|
Key& operator=(const Key& rhs) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the data pointed at by the data pointer into a new memory location
|
* Copy the data pointed at by the data pointer into a new memory location
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void CopyData();
|
void CopyData();
|
||||||
|
|
||||||
bool operator<(const SessionKey& rhs) const;
|
bool operator<(const Key& rhs) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint8_t* data = nullptr;
|
const uint8_t* data = nullptr;
|
|
@ -1,7 +1,7 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include "zeek/zeek-config.h"
|
#include "zeek/zeek-config.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
#include "zeek/analyzer/protocol/stepping-stone/events.bif.h"
|
#include "zeek/analyzer/protocol/stepping-stone/events.bif.h"
|
||||||
|
|
||||||
zeek::session::SessionManager* zeek::session_mgr = nullptr;
|
zeek::session::Manager* zeek::session_mgr = nullptr;
|
||||||
zeek::session::SessionManager*& zeek::sessions = zeek::session_mgr;
|
zeek::session::Manager*& zeek::sessions = zeek::session_mgr;
|
||||||
|
|
||||||
namespace zeek::session {
|
namespace zeek::session {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -92,22 +92,22 @@ private:
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
SessionManager::SessionManager()
|
Manager::Manager()
|
||||||
{
|
{
|
||||||
stats = new detail::ProtocolStats();
|
stats = new detail::ProtocolStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionManager::~SessionManager()
|
Manager::~Manager()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
delete stats;
|
delete stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Done()
|
void Manager::Done()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::ProcessTransportLayer(double t, const Packet* pkt, size_t remaining)
|
void Manager::ProcessTransportLayer(double t, const Packet* pkt, size_t remaining)
|
||||||
{
|
{
|
||||||
const std::unique_ptr<IP_Hdr>& ip_hdr = pkt->ip_hdr;
|
const std::unique_ptr<IP_Hdr>& ip_hdr = pkt->ip_hdr;
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ void SessionManager::ProcessTransportLayer(double t, const Packet* pkt, size_t r
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::detail::ConnIDKey conn_key(id);
|
zeek::detail::ConnIDKey conn_key(id);
|
||||||
detail::SessionKey key(&conn_key, sizeof(conn_key), false);
|
detail::Key key(&conn_key, sizeof(conn_key), false);
|
||||||
Connection* conn = nullptr;
|
Connection* conn = nullptr;
|
||||||
|
|
||||||
// FIXME: The following is getting pretty complex. Need to split up
|
// FIXME: The following is getting pretty complex. Need to split up
|
||||||
|
@ -264,8 +264,8 @@ void SessionManager::ProcessTransportLayer(double t, const Packet* pkt, size_t r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SessionManager::ParseIPPacket(int caplen, const u_char* const pkt, int proto,
|
int Manager::ParseIPPacket(int caplen, const u_char* const pkt, int proto,
|
||||||
IP_Hdr*& inner)
|
IP_Hdr*& inner)
|
||||||
{
|
{
|
||||||
if ( proto == IPPROTO_IPV6 )
|
if ( proto == IPPROTO_IPV6 )
|
||||||
{
|
{
|
||||||
|
@ -301,8 +301,8 @@ int SessionManager::ParseIPPacket(int caplen, const u_char* const pkt, int proto
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionManager::CheckHeaderTrunc(int proto, uint32_t len, uint32_t caplen,
|
bool Manager::CheckHeaderTrunc(int proto, uint32_t len, uint32_t caplen,
|
||||||
const Packet* p)
|
const Packet* p)
|
||||||
{
|
{
|
||||||
uint32_t min_hdr_len = 0;
|
uint32_t min_hdr_len = 0;
|
||||||
switch ( proto ) {
|
switch ( proto ) {
|
||||||
|
@ -335,7 +335,7 @@ bool SessionManager::CheckHeaderTrunc(int proto, uint32_t len, uint32_t caplen,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection* SessionManager::FindConnection(Val* v)
|
Connection* Manager::FindConnection(Val* v)
|
||||||
{
|
{
|
||||||
const auto& vt = v->GetType();
|
const auto& vt = v->GetType();
|
||||||
if ( ! IsRecord(vt->Tag()) )
|
if ( ! IsRecord(vt->Tag()) )
|
||||||
|
@ -380,7 +380,7 @@ Connection* SessionManager::FindConnection(Val* v)
|
||||||
htons((unsigned short) resp_portv->Port()),
|
htons((unsigned short) resp_portv->Port()),
|
||||||
orig_portv->PortType(), false);
|
orig_portv->PortType(), false);
|
||||||
|
|
||||||
detail::SessionKey key(&conn_key, sizeof(conn_key), false);
|
detail::Key key(&conn_key, sizeof(conn_key), false);
|
||||||
|
|
||||||
Connection* conn = nullptr;
|
Connection* conn = nullptr;
|
||||||
auto it = session_map.find(key);
|
auto it = session_map.find(key);
|
||||||
|
@ -390,7 +390,7 @@ Connection* SessionManager::FindConnection(Val* v)
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Remove(Session* s)
|
void Manager::Remove(Session* s)
|
||||||
{
|
{
|
||||||
if ( s->IsInSessionTable() )
|
if ( s->IsInSessionTable() )
|
||||||
{
|
{
|
||||||
|
@ -398,7 +398,7 @@ void SessionManager::Remove(Session* s)
|
||||||
s->Done();
|
s->Done();
|
||||||
s->RemovalEvent();
|
s->RemovalEvent();
|
||||||
|
|
||||||
detail::SessionKey key = s->SessionKey(false);
|
detail::Key key = s->SessionKey(false);
|
||||||
|
|
||||||
if ( session_map.erase(key) == 0 )
|
if ( session_map.erase(key) == 0 )
|
||||||
reporter->InternalWarning("connection missing");
|
reporter->InternalWarning("connection missing");
|
||||||
|
@ -418,10 +418,10 @@ void SessionManager::Remove(Session* s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Insert(Session* s)
|
void Manager::Insert(Session* s)
|
||||||
{
|
{
|
||||||
Session* old = nullptr;
|
Session* old = nullptr;
|
||||||
detail::SessionKey key = s->SessionKey(true);
|
detail::Key key = s->SessionKey(true);
|
||||||
|
|
||||||
auto it = session_map.find(key);
|
auto it = session_map.find(key);
|
||||||
if ( it != session_map.end() )
|
if ( it != session_map.end() )
|
||||||
|
@ -440,7 +440,7 @@ void SessionManager::Insert(Session* s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Drain()
|
void Manager::Drain()
|
||||||
{
|
{
|
||||||
for ( const auto& entry : session_map )
|
for ( const auto& entry : session_map )
|
||||||
{
|
{
|
||||||
|
@ -450,7 +450,7 @@ void SessionManager::Drain()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Clear()
|
void Manager::Clear()
|
||||||
{
|
{
|
||||||
for ( const auto& entry : session_map )
|
for ( const auto& entry : session_map )
|
||||||
Unref(entry.second);
|
Unref(entry.second);
|
||||||
|
@ -460,7 +460,7 @@ void SessionManager::Clear()
|
||||||
zeek::detail::fragment_mgr->Clear();
|
zeek::detail::fragment_mgr->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::GetStats(SessionStats& s)
|
void Manager::GetStats(Stats& s)
|
||||||
{
|
{
|
||||||
auto* tcp_stats = stats->GetCounters("tcp");
|
auto* tcp_stats = stats->GetCounters("tcp");
|
||||||
s.max_TCP_conns = tcp_stats->max;
|
s.max_TCP_conns = tcp_stats->max;
|
||||||
|
@ -482,9 +482,9 @@ void SessionManager::GetStats(SessionStats& s)
|
||||||
s.num_packets = packet_mgr->PacketsProcessed();
|
s.num_packets = packet_mgr->PacketsProcessed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection* SessionManager::NewConn(const zeek::detail::ConnIDKey& k, double t, const ConnID* id,
|
Connection* Manager::NewConn(const zeek::detail::ConnIDKey& k, double t, const ConnID* id,
|
||||||
const u_char* data, int proto, uint32_t flow_label,
|
const u_char* data, int proto, uint32_t flow_label,
|
||||||
const Packet* pkt)
|
const Packet* pkt)
|
||||||
{
|
{
|
||||||
// FIXME: This should be cleaned up a bit, it's too protocol-specific.
|
// FIXME: This should be cleaned up a bit, it's too protocol-specific.
|
||||||
// But I'm not yet sure what the right abstraction for these things is.
|
// But I'm not yet sure what the right abstraction for these things is.
|
||||||
|
@ -542,7 +542,7 @@ Connection* SessionManager::NewConn(const zeek::detail::ConnIDKey& k, double t,
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionManager::IsLikelyServerPort(uint32_t port, TransportProto proto) const
|
bool Manager::IsLikelyServerPort(uint32_t port, TransportProto proto) const
|
||||||
{
|
{
|
||||||
// We keep a cached in-core version of the table to speed up the lookup.
|
// We keep a cached in-core version of the table to speed up the lookup.
|
||||||
static std::set<bro_uint_t> port_cache;
|
static std::set<bro_uint_t> port_cache;
|
||||||
|
@ -569,9 +569,9 @@ bool SessionManager::IsLikelyServerPort(uint32_t port, TransportProto proto) con
|
||||||
return port_cache.find(port) != port_cache.end();
|
return port_cache.find(port) != port_cache.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionManager::WantConnection(uint16_t src_port, uint16_t dst_port,
|
bool Manager::WantConnection(uint16_t src_port, uint16_t dst_port,
|
||||||
TransportProto transport_proto,
|
TransportProto transport_proto,
|
||||||
uint8_t tcp_flags, bool& flip_roles)
|
uint8_t tcp_flags, bool& flip_roles)
|
||||||
{
|
{
|
||||||
flip_roles = false;
|
flip_roles = false;
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ bool SessionManager::WantConnection(uint16_t src_port, uint16_t dst_port,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Weird(const char* name, const Packet* pkt, const char* addl, const char* source)
|
void Manager::Weird(const char* name, const Packet* pkt, const char* addl, const char* source)
|
||||||
{
|
{
|
||||||
const char* weird_name = name;
|
const char* weird_name = name;
|
||||||
|
|
||||||
|
@ -637,12 +637,12 @@ void SessionManager::Weird(const char* name, const Packet* pkt, const char* addl
|
||||||
reporter->Weird(weird_name, addl, source);
|
reporter->Weird(weird_name, addl, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::Weird(const char* name, const IP_Hdr* ip, const char* addl)
|
void Manager::Weird(const char* name, const IP_Hdr* ip, const char* addl)
|
||||||
{
|
{
|
||||||
reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl);
|
reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SessionManager::SessionMemoryUsage()
|
unsigned int Manager::SessionMemoryUsage()
|
||||||
{
|
{
|
||||||
unsigned int mem = 0;
|
unsigned int mem = 0;
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ unsigned int SessionManager::SessionMemoryUsage()
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SessionManager::SessionMemoryUsageVals()
|
unsigned int Manager::SessionMemoryUsageVals()
|
||||||
{
|
{
|
||||||
unsigned int mem = 0;
|
unsigned int mem = 0;
|
||||||
|
|
||||||
|
@ -670,7 +670,7 @@ unsigned int SessionManager::SessionMemoryUsageVals()
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SessionManager::MemoryAllocation()
|
unsigned int Manager::MemoryAllocation()
|
||||||
{
|
{
|
||||||
if ( run_state::terminating )
|
if ( run_state::terminating )
|
||||||
// Connections have been flushed already.
|
// Connections have been flushed already.
|
||||||
|
@ -684,7 +684,7 @@ unsigned int SessionManager::MemoryAllocation()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::InsertSession(detail::SessionKey key, Session* session)
|
void Manager::InsertSession(detail::Key key, Session* session)
|
||||||
{
|
{
|
||||||
session->SetInSessionTable(true);
|
session->SetInSessionTable(true);
|
||||||
key.CopyData();
|
key.CopyData();
|
||||||
|
@ -702,7 +702,7 @@ void SessionManager::InsertSession(detail::SessionKey key, Session* session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::detail::PacketFilter* SessionManager::GetPacketFilter(bool init)
|
zeek::detail::PacketFilter* Manager::GetPacketFilter(bool init)
|
||||||
{
|
{
|
||||||
return packet_mgr->GetPacketFilter(init);
|
return packet_mgr->GetPacketFilter(init);
|
||||||
}
|
}
|
|
@ -27,7 +27,7 @@ namespace session {
|
||||||
|
|
||||||
namespace detail { class ProtocolStats; }
|
namespace detail { class ProtocolStats; }
|
||||||
|
|
||||||
struct SessionStats {
|
struct Stats {
|
||||||
size_t num_TCP_conns;
|
size_t num_TCP_conns;
|
||||||
size_t max_TCP_conns;
|
size_t max_TCP_conns;
|
||||||
uint64_t cumulative_TCP_conns;
|
uint64_t cumulative_TCP_conns;
|
||||||
|
@ -45,10 +45,10 @@ struct SessionStats {
|
||||||
uint64_t num_packets;
|
uint64_t num_packets;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SessionManager final {
|
class Manager final {
|
||||||
public:
|
public:
|
||||||
SessionManager();
|
Manager();
|
||||||
~SessionManager();
|
~Manager();
|
||||||
|
|
||||||
void Done(); // call to drain events before destructing
|
void Done(); // call to drain events before destructing
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
// Clears the session maps.
|
// Clears the session maps.
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
void GetStats(SessionStats& s);
|
void GetStats(Stats& s);
|
||||||
|
|
||||||
void Weird(const char* name, const Packet* pkt,
|
void Weird(const char* name, const Packet* pkt,
|
||||||
const char* addl = "", const char* source = "");
|
const char* addl = "", const char* source = "");
|
||||||
|
@ -146,7 +146,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using SessionMap = std::map<detail::SessionKey, Session*>;
|
using SessionMap = std::map<detail::Key, Session*>;
|
||||||
|
|
||||||
Connection* NewConn(const zeek::detail::ConnIDKey& k, double t, const ConnID* id,
|
Connection* NewConn(const zeek::detail::ConnIDKey& k, double t, const ConnID* id,
|
||||||
const u_char* data, int proto, uint32_t flow_label,
|
const u_char* data, int proto, uint32_t flow_label,
|
||||||
|
@ -179,7 +179,7 @@ private:
|
||||||
// the new one. Connection count stats get updated either way (so most
|
// the new one. Connection count stats get updated either way (so most
|
||||||
// cases should likely check that the key is not already in the map to
|
// cases should likely check that the key is not already in the map to
|
||||||
// avoid unnecessary incrementing of connecting counts).
|
// avoid unnecessary incrementing of connecting counts).
|
||||||
void InsertSession(detail::SessionKey key, Session* session);
|
void InsertSession(detail::Key key, Session* session);
|
||||||
|
|
||||||
SessionMap session_map;
|
SessionMap session_map;
|
||||||
detail::ProtocolStats* stats;
|
detail::ProtocolStats* stats;
|
||||||
|
@ -188,9 +188,9 @@ private:
|
||||||
} // namespace session
|
} // namespace session
|
||||||
|
|
||||||
// Manager for the currently active sessions.
|
// Manager for the currently active sessions.
|
||||||
extern session::SessionManager* session_mgr;
|
extern session::Manager* session_mgr;
|
||||||
|
|
||||||
extern session::SessionManager*& sessions [[deprecated("Remove in v5.1. Use zeek::sessions::session_mgr.")]];
|
extern session::Manager*& sessions [[deprecated("Remove in v5.1. Use zeek::sessions::session_mgr.")]];
|
||||||
using NetSessions [[deprecated("Remove in v5.1. Use zeek::session::SessionManager.")]] = session::SessionManager;
|
using NetSessions [[deprecated("Remove in v5.1. Use zeek::session::Manager.")]] = session::Manager;
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
|
@ -7,14 +7,14 @@
|
||||||
#include "zeek/Val.h"
|
#include "zeek/Val.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Desc.h"
|
#include "zeek/Desc.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "zeek/IP.h"
|
#include "zeek/IP.h"
|
||||||
|
|
||||||
namespace zeek::session {
|
namespace zeek::session {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
void SessionTimer::Init(Session* arg_session, timer_func arg_timer,
|
void Timer::Init(Session* arg_session, timer_func arg_timer,
|
||||||
bool arg_do_expire)
|
bool arg_do_expire)
|
||||||
{
|
{
|
||||||
session = arg_session;
|
session = arg_session;
|
||||||
timer = arg_timer;
|
timer = arg_timer;
|
||||||
|
@ -22,16 +22,16 @@ void SessionTimer::Init(Session* arg_session, timer_func arg_timer,
|
||||||
Ref(session);
|
Ref(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionTimer::~SessionTimer()
|
Timer::~Timer()
|
||||||
{
|
{
|
||||||
if ( session->RefCnt() < 1 )
|
if ( session->RefCnt() < 1 )
|
||||||
reporter->InternalError("reference count inconsistency in ~SessionTimer");
|
reporter->InternalError("reference count inconsistency in session~Timer");
|
||||||
|
|
||||||
session->RemoveTimer(this);
|
session->RemoveTimer(this);
|
||||||
Unref(session);
|
Unref(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionTimer::Dispatch(double t, bool is_expire)
|
void Timer::Dispatch(double t, bool is_expire)
|
||||||
{
|
{
|
||||||
if ( is_expire && ! do_expire )
|
if ( is_expire && ! do_expire )
|
||||||
return;
|
return;
|
||||||
|
@ -43,7 +43,7 @@ void SessionTimer::Dispatch(double t, bool is_expire)
|
||||||
(session->*timer)(t);
|
(session->*timer)(t);
|
||||||
|
|
||||||
if ( session->RefCnt() < 1 )
|
if ( session->RefCnt() < 1 )
|
||||||
reporter->InternalError("reference count inconsistency in SessionTimer::Dispatch");
|
reporter->InternalError("reference count inconsistency in session::Timer::Dispatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -172,7 +172,7 @@ void Session::AddTimer(timer_func timer, double t, bool do_expire,
|
||||||
if ( ! IsInSessionTable() )
|
if ( ! IsInSessionTable() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zeek::detail::Timer* conn_timer = new detail::SessionTimer(this, timer, t, do_expire, type);
|
zeek::detail::Timer* conn_timer = new detail::Timer(this, timer, t, do_expire, type);
|
||||||
zeek::detail::timer_mgr->Add(conn_timer);
|
zeek::detail::timer_mgr->Add(conn_timer);
|
||||||
timers.push_back(conn_timer);
|
timers.push_back(conn_timer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "zeek/Obj.h"
|
#include "zeek/Obj.h"
|
||||||
#include "zeek/EventHandler.h"
|
#include "zeek/EventHandler.h"
|
||||||
#include "zeek/Timer.h"
|
#include "zeek/Timer.h"
|
||||||
#include "zeek/session/SessionKey.h"
|
#include "zeek/session/Key.h"
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ using RecordValPtr = IntrusivePtr<RecordVal>;
|
||||||
namespace analyzer { class Analyzer; }
|
namespace analyzer { class Analyzer; }
|
||||||
|
|
||||||
namespace session {
|
namespace session {
|
||||||
namespace detail { class SessionTimer; }
|
namespace detail { class Timer; }
|
||||||
|
|
||||||
class Session;
|
class Session;
|
||||||
typedef void (Session::*timer_func)(double t);
|
typedef void (Session::*timer_func)(double t);
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
* @param copy Flag to indicate that the key returned must have a copy of the
|
* @param copy Flag to indicate that the key returned must have a copy of the
|
||||||
* key data instead of just a pointer to it.
|
* key data instead of just a pointer to it.
|
||||||
*/
|
*/
|
||||||
virtual detail::SessionKey SessionKey(bool copy) const = 0;
|
virtual detail::Key SessionKey(bool copy) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether this session is in the session table.
|
* Set whether this session is in the session table.
|
||||||
|
@ -199,7 +199,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class detail::SessionTimer;
|
friend class detail::Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a given timer to expire at a specific time.
|
* Add a given timer to expire at a specific time.
|
||||||
|
@ -250,14 +250,14 @@ protected:
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
class SessionTimer final : public zeek::detail::Timer {
|
class Timer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
SessionTimer(Session* arg_session, timer_func arg_timer,
|
Timer(Session* arg_session, timer_func arg_timer,
|
||||||
double arg_t, bool arg_do_expire,
|
double arg_t, bool arg_do_expire,
|
||||||
zeek::detail::TimerType arg_type)
|
zeek::detail::TimerType arg_type)
|
||||||
: zeek::detail::Timer(arg_t, arg_type)
|
: zeek::detail::Timer(arg_t, arg_type)
|
||||||
{ Init(arg_session, arg_timer, arg_do_expire); }
|
{ Init(arg_session, arg_timer, arg_do_expire); }
|
||||||
~SessionTimer() override;
|
~Timer() override;
|
||||||
|
|
||||||
void Dispatch(double t, bool is_expire) override;
|
void Dispatch(double t, bool is_expire) override;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ function get_conn_stats%(%): ConnStats
|
||||||
r->Assign(n++, Connection::CurrentConnections());
|
r->Assign(n++, Connection::CurrentConnections());
|
||||||
r->Assign(n++, session_mgr->CurrentSessions());
|
r->Assign(n++, session_mgr->CurrentSessions());
|
||||||
|
|
||||||
session::SessionStats s;
|
session::Stats s;
|
||||||
if ( session_mgr )
|
if ( session_mgr )
|
||||||
session_mgr->GetStats(s);
|
session_mgr->GetStats(s);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "LLCDemo.h"
|
#include "LLCDemo.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Val.h"
|
#include "zeek/Val.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
#include "events.bif.h"
|
#include "events.bif.h"
|
||||||
|
|
||||||
using namespace zeek::packet_analysis::PacketDemo;
|
using namespace zeek::packet_analysis::PacketDemo;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "RawLayer.h"
|
#include "RawLayer.h"
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/Val.h"
|
#include "zeek/Val.h"
|
||||||
#include "zeek/session/SessionManager.h"
|
#include "zeek/session/Manager.h"
|
||||||
|
|
||||||
#include "events.bif.h"
|
#include "events.bif.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue