mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Deprecate Connection::Event and Analyzer::Event methods
And update usages to the "EnqueueEvent" methods.
This commit is contained in:
parent
2a63e4a4a2
commit
9b2fb29aca
10 changed files with 56 additions and 29 deletions
6
NEWS
6
NEWS
|
@ -92,7 +92,7 @@ Deprecated Functionality
|
||||||
- The ``EventMgr::QueueEvent()`` and EventMgr::QueueEventFast()`` methods
|
- The ``EventMgr::QueueEvent()`` and EventMgr::QueueEventFast()`` methods
|
||||||
are now deprecated, use ``EventMgr::Enqueue()`` instead.
|
are now deprecated, use ``EventMgr::Enqueue()`` instead.
|
||||||
|
|
||||||
- The ``Connection::ConnectionEvent()`` and
|
- The ``Connection::ConnectionEvent()``, ``Connection::Event()``, and
|
||||||
``Connection::ConnectionEventFast()`` methods are now deprecated, use
|
``Connection::ConnectionEventFast()`` methods are now deprecated, use
|
||||||
``Connection::EnqueueEvent()`` instead.
|
``Connection::EnqueueEvent()`` instead.
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ Deprecated Functionality
|
||||||
arguments are now deprecated, use the overload that takes a ``zeek::Args``
|
arguments are now deprecated, use the overload that takes a ``zeek::Args``
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
- The ``analyzer::Analyzer::ConnectionEvent()`` and
|
- The ``analyzer::Analyzer::ConnectionEvent()``, ``analyzer::Analyzer::Event``,
|
||||||
``analyzer::Analyzer::ConectionEventFast()`` methods are deprecated, use
|
and ``analyzer::Analyzer::ConectionEventFast()`` methods are deprecated, use
|
||||||
``analyzer::Analyzer::EnqueueConnEvent()`` instead.
|
``analyzer::Analyzer::EnqueueConnEvent()`` instead.
|
||||||
|
|
||||||
- All ``val_mgr`` methods starting with "Get" are deprecated, use the new
|
- All ``val_mgr`` methods starting with "Get" are deprecated, use the new
|
||||||
|
|
17
src/Conn.cc
17
src/Conn.cc
|
@ -144,23 +144,34 @@ void Connection::CheckEncapsulation(const EncapsulationStack* arg_encap)
|
||||||
{
|
{
|
||||||
if ( *encapsulation != *arg_encap )
|
if ( *encapsulation != *arg_encap )
|
||||||
{
|
{
|
||||||
Event(tunnel_changed, nullptr, arg_encap->GetVectorVal());
|
if ( tunnel_changed )
|
||||||
|
EnqueueEvent(tunnel_changed, nullptr, ConnVal(),
|
||||||
|
IntrusivePtr{AdoptRef{}, arg_encap->GetVectorVal()});
|
||||||
|
|
||||||
delete encapsulation;
|
delete encapsulation;
|
||||||
encapsulation = new EncapsulationStack(*arg_encap);
|
encapsulation = new EncapsulationStack(*arg_encap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( encapsulation )
|
else if ( encapsulation )
|
||||||
|
{
|
||||||
|
if ( tunnel_changed )
|
||||||
{
|
{
|
||||||
EncapsulationStack empty;
|
EncapsulationStack empty;
|
||||||
Event(tunnel_changed, nullptr, empty.GetVectorVal());
|
EnqueueEvent(tunnel_changed, nullptr, ConnVal(),
|
||||||
|
IntrusivePtr{AdoptRef{}, empty.GetVectorVal()});
|
||||||
|
}
|
||||||
|
|
||||||
delete encapsulation;
|
delete encapsulation;
|
||||||
encapsulation = nullptr;
|
encapsulation = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( arg_encap )
|
else if ( arg_encap )
|
||||||
{
|
{
|
||||||
Event(tunnel_changed, nullptr, arg_encap->GetVectorVal());
|
if ( tunnel_changed )
|
||||||
|
EnqueueEvent(tunnel_changed, nullptr, ConnVal(),
|
||||||
|
IntrusivePtr{AdoptRef{}, arg_encap->GetVectorVal()});
|
||||||
|
|
||||||
encapsulation = new EncapsulationStack(*arg_encap);
|
encapsulation = new EncapsulationStack(*arg_encap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,6 +193,7 @@ public:
|
||||||
// 'v1' and 'v2' reference counts get decremented. The event's first
|
// 'v1' and 'v2' reference counts get decremented. The event's first
|
||||||
// argument is the connection value, second argument is 'v1', and if 'v2'
|
// argument is the connection value, second argument is 'v1', and if 'v2'
|
||||||
// is given that will be it's third argument.
|
// is given that will be it's third argument.
|
||||||
|
[[deprecated("Remove in v4.1. Use EnqueueEvent() instead (note it doesn't automatically add the connection argument).")]]
|
||||||
void Event(EventHandlerPtr f, analyzer::Analyzer* analyzer, Val* v1, Val* v2 = nullptr);
|
void Event(EventHandlerPtr f, analyzer::Analyzer* analyzer, Val* v1, Val* v2 = nullptr);
|
||||||
|
|
||||||
// If a handler exists for 'f', an event will be generated. In any case,
|
// If a handler exists for 'f', an event will be generated. In any case,
|
||||||
|
|
|
@ -691,12 +691,14 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
|
||||||
if ( ipv6_ext_headers && ip_hdr->NumHeaders() > 1 )
|
if ( ipv6_ext_headers && ip_hdr->NumHeaders() > 1 )
|
||||||
{
|
{
|
||||||
pkt_hdr_val = ip_hdr->BuildPktHdrVal();
|
pkt_hdr_val = ip_hdr->BuildPktHdrVal();
|
||||||
conn->Event(ipv6_ext_headers, nullptr, pkt_hdr_val);
|
conn->EnqueueEvent(ipv6_ext_headers, nullptr, conn->ConnVal(),
|
||||||
|
IntrusivePtr{AdoptRef{}, pkt_hdr_val});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( new_packet )
|
if ( new_packet )
|
||||||
conn->Event(new_packet, nullptr,
|
conn->EnqueueEvent(new_packet, nullptr, conn->ConnVal(), pkt_hdr_val ?
|
||||||
pkt_hdr_val ? pkt_hdr_val->Ref() : ip_hdr->BuildPktHdrVal());
|
IntrusivePtr{NewRef{}, pkt_hdr_val} :
|
||||||
|
IntrusivePtr{AdoptRef{}, ip_hdr->BuildPktHdrVal()});
|
||||||
|
|
||||||
conn->NextPacket(t, is_orig, ip_hdr, len, caplen, data,
|
conn->NextPacket(t, is_orig, ip_hdr, len, caplen, data,
|
||||||
record_packet, record_content, pkt);
|
record_packet, record_content, pkt);
|
||||||
|
|
|
@ -803,7 +803,11 @@ void Analyzer::Event(EventHandlerPtr f, const char* name)
|
||||||
|
|
||||||
void Analyzer::Event(EventHandlerPtr f, Val* v1, Val* v2)
|
void Analyzer::Event(EventHandlerPtr f, Val* v1, Val* v2)
|
||||||
{
|
{
|
||||||
conn->Event(f, this, v1, v2);
|
IntrusivePtr val1{AdoptRef{}, v1};
|
||||||
|
IntrusivePtr val2{AdoptRef{}, v2};
|
||||||
|
|
||||||
|
if ( f )
|
||||||
|
conn->EnqueueEvent(f, this, conn->ConnVal(), std::move(val1), std::move(val2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::ConnectionEvent(EventHandlerPtr f, val_list* vl)
|
void Analyzer::ConnectionEvent(EventHandlerPtr f, val_list* vl)
|
||||||
|
@ -935,7 +939,7 @@ void TransportLayerAnalyzer::PacketContents(const u_char* data, int len)
|
||||||
if ( packet_contents && len > 0 )
|
if ( packet_contents && len > 0 )
|
||||||
{
|
{
|
||||||
BroString* cbs = new BroString(data, len, true);
|
BroString* cbs = new BroString(data, len, true);
|
||||||
Val* contents = new StringVal(cbs);
|
auto contents = make_intrusive<StringVal>(cbs);
|
||||||
Event(packet_contents, contents);
|
EnqueueConnEvent(packet_contents, ConnVal(), std::move(contents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,6 +568,7 @@ public:
|
||||||
* Convenience function that forwards directly to the corresponding
|
* Convenience function that forwards directly to the corresponding
|
||||||
* Connection::Event().
|
* Connection::Event().
|
||||||
*/
|
*/
|
||||||
|
[[deprecated("Remove in v4.1. Use EnqueueConnEvent() instead (note it doesn't automatically ad the connection argument).")]]
|
||||||
void Event(EventHandlerPtr f, Val* v1, Val* v2 = nullptr);
|
void Event(EventHandlerPtr f, Val* v1, Val* v2 = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -624,9 +624,10 @@ bool Manager::ApplyScheduledAnalyzers(Connection* conn, bool init, TransportLaye
|
||||||
|
|
||||||
parent->AddChildAnalyzer(analyzer, init);
|
parent->AddChildAnalyzer(analyzer, init);
|
||||||
|
|
||||||
EnumVal* tag = it->AsEnumVal();
|
if ( scheduled_analyzer_applied )
|
||||||
Ref(tag);
|
conn->EnqueueEvent(scheduled_analyzer_applied, nullptr,
|
||||||
conn->Event(scheduled_analyzer_applied, nullptr, tag);
|
conn->ConnVal(),
|
||||||
|
IntrusivePtr{NewRef{}, it->AsEnumVal()});
|
||||||
|
|
||||||
DBG_ANALYZER_ARGS(conn, "activated %s analyzer as scheduled",
|
DBG_ANALYZER_ARGS(conn, "activated %s analyzer as scheduled",
|
||||||
analyzer_mgr->GetComponentName(*it).c_str());
|
analyzer_mgr->GetComponentName(*it).c_str());
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool TeredoEncapsulation::DoParse(const u_char* data, int& len,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordVal* TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const
|
IntrusivePtr<RecordVal> TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const
|
||||||
{
|
{
|
||||||
static RecordType* teredo_hdr_type = nullptr;
|
static RecordType* teredo_hdr_type = nullptr;
|
||||||
static RecordType* teredo_auth_type = nullptr;
|
static RecordType* teredo_auth_type = nullptr;
|
||||||
|
@ -109,7 +109,7 @@ RecordVal* TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const
|
||||||
teredo_origin_type = internal_type("teredo_origin")->AsRecordType();
|
teredo_origin_type = internal_type("teredo_origin")->AsRecordType();
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordVal* teredo_hdr = new RecordVal(teredo_hdr_type);
|
auto teredo_hdr = make_intrusive<RecordVal>(teredo_hdr_type);
|
||||||
|
|
||||||
if ( auth )
|
if ( auth )
|
||||||
{
|
{
|
||||||
|
@ -201,30 +201,36 @@ void Teredo_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* teredo_hdr = nullptr;
|
IntrusivePtr<Val> teredo_hdr;
|
||||||
|
|
||||||
if ( teredo_packet )
|
if ( teredo_packet )
|
||||||
{
|
{
|
||||||
teredo_hdr = te.BuildVal(inner);
|
teredo_hdr = te.BuildVal(inner);
|
||||||
Conn()->Event(teredo_packet, nullptr, teredo_hdr);
|
Conn()->EnqueueEvent(teredo_packet, nullptr, ConnVal(), teredo_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( te.Authentication() && teredo_authentication )
|
if ( te.Authentication() && teredo_authentication )
|
||||||
{
|
{
|
||||||
teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner);
|
if ( ! teredo_hdr )
|
||||||
Conn()->Event(teredo_authentication, nullptr, teredo_hdr);
|
teredo_hdr = te.BuildVal(inner);
|
||||||
|
|
||||||
|
Conn()->EnqueueEvent(teredo_authentication, nullptr, ConnVal(), teredo_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( te.OriginIndication() && teredo_origin_indication )
|
if ( te.OriginIndication() && teredo_origin_indication )
|
||||||
{
|
{
|
||||||
teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner);
|
if ( ! teredo_hdr )
|
||||||
Conn()->Event(teredo_origin_indication, nullptr, teredo_hdr);
|
teredo_hdr = te.BuildVal(inner);
|
||||||
|
|
||||||
|
Conn()->EnqueueEvent(teredo_origin_indication, nullptr, ConnVal(), teredo_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( inner->NextProto() == IPPROTO_NONE && teredo_bubble )
|
if ( inner->NextProto() == IPPROTO_NONE && teredo_bubble )
|
||||||
{
|
{
|
||||||
teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner);
|
if ( ! teredo_hdr )
|
||||||
Conn()->Event(teredo_bubble, nullptr, teredo_hdr);
|
teredo_hdr = te.BuildVal(inner);
|
||||||
|
|
||||||
|
Conn()->EnqueueEvent(teredo_bubble, nullptr, ConnVal(), teredo_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EncapsulatingConn ec(Conn(), BifEnum::Tunnel::TEREDO);
|
EncapsulatingConn ec(Conn(), BifEnum::Tunnel::TEREDO);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
const u_char* Authentication() const
|
const u_char* Authentication() const
|
||||||
{ return auth; }
|
{ return auth; }
|
||||||
|
|
||||||
RecordVal* BuildVal(const IP_Hdr* inner) const;
|
IntrusivePtr<RecordVal> BuildVal(const IP_Hdr* inner) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool DoParse(const u_char* data, int& len, bool found_orig, bool found_au);
|
bool DoParse(const u_char* data, int& len, bool found_orig, bool found_au);
|
||||||
|
|
|
@ -101,8 +101,9 @@ void VXLAN_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
|
||||||
ProtocolConfirmation();
|
ProtocolConfirmation();
|
||||||
|
|
||||||
if ( vxlan_packet )
|
if ( vxlan_packet )
|
||||||
Conn()->Event(vxlan_packet, nullptr, inner->BuildPktHdrVal(),
|
Conn()->EnqueueEvent(vxlan_packet, nullptr, ConnVal(),
|
||||||
val_mgr->Count(vni).release());
|
IntrusivePtr{AdoptRef{}, inner->BuildPktHdrVal()},
|
||||||
|
val_mgr->Count(vni));
|
||||||
|
|
||||||
EncapsulatingConn ec(Conn(), BifEnum::Tunnel::VXLAN);
|
EncapsulatingConn ec(Conn(), BifEnum::Tunnel::VXLAN);
|
||||||
sessions->DoNextInnerPacket(network_time, &pkt, inner, estack, ec);
|
sessions->DoNextInnerPacket(network_time, &pkt, inner, estack, ec);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue