mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/ipv6-chain-vector'
* origin/topic/timw/ipv6-chain-vector: Switch IPv6_Hdr_Chain to a vector of objects instead of pointers
This commit is contained in:
commit
e39a1d7271
4 changed files with 22 additions and 22 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
8.0.0-dev.493 | 2025-06-23 10:52:22 -0700
|
||||||
|
|
||||||
|
* Switch IPv6_Hdr_Chain to a vector of objects instead of pointers (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
8.0.0-dev.491 | 2025-06-23 10:39:31 -0700
|
8.0.0-dev.491 | 2025-06-23 10:39:31 -0700
|
||||||
|
|
||||||
* Remove unneeded include dirs in zeromq CMakeLists.txt (Tim Wojtulewicz, Corelight)
|
* Remove unneeded include dirs in zeromq CMakeLists.txt (Tim Wojtulewicz, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
8.0.0-dev.491
|
8.0.0-dev.493
|
||||||
|
|
32
src/IP.cc
32
src/IP.cc
|
@ -457,8 +457,6 @@ static inline bool isIPv6ExtHeader(uint8_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IPv6_Hdr_Chain::~IPv6_Hdr_Chain() {
|
IPv6_Hdr_Chain::~IPv6_Hdr_Chain() {
|
||||||
for ( auto& c : chain )
|
|
||||||
delete c;
|
|
||||||
delete homeAddr;
|
delete homeAddr;
|
||||||
delete finalDst;
|
delete finalDst;
|
||||||
}
|
}
|
||||||
|
@ -481,23 +479,21 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, uint64_t total_len, bool se
|
||||||
return;
|
return;
|
||||||
|
|
||||||
current_type = next_type;
|
current_type = next_type;
|
||||||
IPv6_Hdr* p = new IPv6_Hdr(current_type, hdrs);
|
IPv6_Hdr p{current_type, hdrs};
|
||||||
|
|
||||||
next_type = p->NextHdr();
|
next_type = p.NextHdr();
|
||||||
uint16_t cur_len = p->Length();
|
uint16_t cur_len = p.Length();
|
||||||
|
|
||||||
// If this header is truncated, don't add it to chain, don't go further.
|
// If this header is truncated, don't add it to chain, don't go further.
|
||||||
if ( cur_len > total_len ) {
|
if ( cur_len > total_len )
|
||||||
delete p;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if ( set_next && next_type == IPPROTO_FRAGMENT ) {
|
if ( set_next && next_type == IPPROTO_FRAGMENT ) {
|
||||||
p->ChangeNext(next);
|
p.ChangeNext(next);
|
||||||
next_type = next;
|
next_type = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.push_back(p);
|
chain.emplace_back(std::move(p));
|
||||||
|
|
||||||
// Check for routing headers and remember final destination address.
|
// Check for routing headers and remember final destination address.
|
||||||
if ( current_type == IPPROTO_ROUTING )
|
if ( current_type == IPPROTO_ROUTING )
|
||||||
|
@ -521,7 +517,7 @@ bool IPv6_Hdr_Chain::IsFragment() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain[chain.size() - 1]->Type() == IPPROTO_FRAGMENT;
|
return chain.back().Type() == IPPROTO_FRAGMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddr IPv6_Hdr_Chain::SrcAddr() const {
|
IPAddr IPv6_Hdr_Chain::SrcAddr() const {
|
||||||
|
@ -533,7 +529,7 @@ IPAddr IPv6_Hdr_Chain::SrcAddr() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return IPAddr{((const struct ip6_hdr*)(chain[0]->Data()))->ip6_src};
|
return IPAddr{((const struct ip6_hdr*)(chain[0].Data()))->ip6_src};
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddr IPv6_Hdr_Chain::DstAddr() const {
|
IPAddr IPv6_Hdr_Chain::DstAddr() const {
|
||||||
|
@ -545,7 +541,7 @@ IPAddr IPv6_Hdr_Chain::DstAddr() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return IPAddr{((const struct ip6_hdr*)(chain[0]->Data()))->ip6_dst};
|
return IPAddr{((const struct ip6_hdr*)(chain[0].Data()))->ip6_dst};
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t len) {
|
void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t len) {
|
||||||
|
@ -647,9 +643,9 @@ VectorValPtr IPv6_Hdr_Chain::ToVal() const {
|
||||||
auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
|
auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
|
||||||
|
|
||||||
for ( size_t i = 1; i < chain.size(); ++i ) {
|
for ( size_t i = 1; i < chain.size(); ++i ) {
|
||||||
auto v = chain[i]->ToVal();
|
auto v = chain[i].ToVal();
|
||||||
auto ext_hdr = make_intrusive<RecordVal>(ip6_ext_hdr_type);
|
auto ext_hdr = make_intrusive<RecordVal>(ip6_ext_hdr_type);
|
||||||
uint8_t type = chain[i]->Type();
|
uint8_t type = chain[i].Type();
|
||||||
ext_hdr->Assign(0, type);
|
ext_hdr->Assign(0, type);
|
||||||
|
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
|
@ -700,11 +696,11 @@ IPv6_Hdr_Chain* IPv6_Hdr_Chain::Copy(const ip6_hdr* new_hdr) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
const u_char* new_data = (const u_char*)new_hdr;
|
const u_char* new_data = (const u_char*)new_hdr;
|
||||||
const u_char* old_data = chain[0]->Data();
|
const u_char* old_data = chain[0].Data();
|
||||||
|
|
||||||
for ( const auto& c : chain ) {
|
for ( const auto& c : chain ) {
|
||||||
int off = c->Data() - old_data;
|
int off = c.Data() - old_data;
|
||||||
rval->chain.push_back(new IPv6_Hdr(c->Type(), new_data + off));
|
rval->chain.emplace_back(c.Type(), new_data + off);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
6
src/IP.h
6
src/IP.h
|
@ -163,7 +163,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Accesses the header at the given location in the chain.
|
* Accesses the header at the given location in the chain.
|
||||||
*/
|
*/
|
||||||
const IPv6_Hdr* operator[](const size_t i) const { return chain[i]; }
|
const IPv6_Hdr* operator[](const size_t i) const { return &chain[i]; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the header chain indicates a fragmented packet.
|
* Returns whether the header chain indicates a fragmented packet.
|
||||||
|
@ -174,7 +174,7 @@ public:
|
||||||
* Returns pointer to fragment header structure if the chain contains one.
|
* Returns pointer to fragment header structure if the chain contains one.
|
||||||
*/
|
*/
|
||||||
const struct ip6_frag* GetFragHdr() const {
|
const struct ip6_frag* GetFragHdr() const {
|
||||||
return IsFragment() ? (const struct ip6_frag*)chain[chain.size() - 1]->Data() : nullptr;
|
return IsFragment() ? (const struct ip6_frag*)chain[chain.size() - 1].Data() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,7 +245,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
void ProcessDstOpts(const struct ip6_dest* d, uint16_t len);
|
void ProcessDstOpts(const struct ip6_dest* d, uint16_t len);
|
||||||
|
|
||||||
std::vector<IPv6_Hdr*> chain;
|
std::vector<IPv6_Hdr> chain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The summation of all header lengths in the chain in bytes.
|
* The summation of all header lengths in the chain in bytes.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue