Deprecate the old Connection constructor and detail::ConnKey class.

The new key-based Connection constructor replaces the former, and the new
ConnKey class tree replaces the latter.
This commit is contained in:
Christian Kreibich 2025-06-12 13:48:12 -07:00 committed by Arne Welzel
parent 52d6228b06
commit 7548dc9e96
4 changed files with 18 additions and 5 deletions

View file

@ -42,6 +42,8 @@ Connection::Connection(zeek::IPBasedConnKeyPtr k, const zeek::ConnTuple& ct, dou
Init(flow, pkt);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Connection::Connection(const detail::ConnKey& k, double t, const ConnTuple* id, uint32_t flow, const Packet* pkt)
: Session(t, connection_timeout, connection_status_update, detail::connection_status_update_interval) {
orig_addr = id->src_addr;
@ -63,6 +65,7 @@ Connection::Connection(const detail::ConnKey& k, double t, const ConnTuple* id,
Init(flow, pkt);
}
#pragma GCC diagnostic pop
Connection::~Connection() {
if ( ! finished )

View file

@ -69,7 +69,10 @@ static inline int addr_port_canon_lt(const IPAddr& addr1, uint32_t p1, const IPA
class Connection final : public session::Session {
public:
Connection(zeek::IPBasedConnKeyPtr k, const zeek::ConnTuple& ct, double t, uint32_t flow, const Packet* pkt);
[[deprecated("Remove in v8.1. Switch to ConnKey factories and the new zeek::ConnKey tree.")]]
Connection(const detail::ConnKey& k, double t, const ConnTuple* id, uint32_t flow, const Packet* pkt);
~Connection() override;
/**
@ -201,7 +204,8 @@ public:
bool IsFinished() { return finished; }
private:
// Common initialization for the constructors.
// Common initialization for the constructors. This can move back into the
// (sole) constructor when we remove the deprecated one in 8.1.
void Init(uint32_t flow, const Packet* pkt);
friend class session::detail::Timer;

View file

@ -27,6 +27,8 @@ ConnKey::ConnKey(const ConnTuple& id) {
Init(id.src_addr, id.dst_addr, id.src_port, id.dst_port, id.proto, id.is_one_way);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
ConnKey& ConnKey::operator=(const ConnKey& rhs) {
if ( this == &rhs )
return *this;
@ -45,6 +47,7 @@ ConnKey& ConnKey::operator=(const ConnKey& rhs) {
return *this;
}
#pragma GCC diagnostic pop
ConnKey::ConnKey(Val* v) {
const auto& vt = v->GetType();

View file

@ -25,6 +25,7 @@ constexpr uint16_t INVALID_CONN_KEY_IP_PROTO = 65534;
class HashKey;
// Deprecated: Remove the whole class in v8.1. Switch usage to the conntuple factories and the new zeek::ConnKey tree.
class ConnKey {
public:
in6_addr ip1;
@ -33,10 +34,12 @@ public:
uint16_t port2 = 0;
uint16_t transport = INVALID_CONN_KEY_IP_PROTO;
ConnKey(const IPAddr& src, const IPAddr& dst, uint16_t src_port, uint16_t dst_port, uint16_t proto, bool one_way);
ConnKey(const ConnTuple& conn);
ConnKey(const ConnKey& rhs) { *this = rhs; }
ConnKey(Val* v);
[[deprecated("Remove in v8.1: Switch to new conn_key framework")]] ConnKey(const IPAddr& src, const IPAddr& dst,
uint16_t src_port, uint16_t dst_port,
uint16_t proto, bool one_way);
[[deprecated("Remove in v8.1: Switch to new conn_key framework")]] ConnKey(const ConnTuple& conn);
[[deprecated("Remove in v8.1: Switch to new conn_key framework")]] ConnKey(const ConnKey& rhs) { *this = rhs; }
[[deprecated("Remove in v8.1: Switch to new conn_key framework")]] ConnKey(Val* v);
// FIXME: This is getting reworked as part of the connection tuple changes. Suppress
// the clang-tidy warning for the time being.