mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Change Packet::ip_hdr to be a shared_ptr so it can be copied into EncapsulatingConn
This commit is contained in:
parent
d4f57a6100
commit
ed798c6aba
24 changed files with 91 additions and 42 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/IP.h"
|
||||
#include "zeek/IPAddr.h"
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/UID.h"
|
||||
|
@ -66,8 +67,9 @@ public:
|
|||
* Copy constructor.
|
||||
*/
|
||||
EncapsulatingConn(const EncapsulatingConn& other)
|
||||
: src_addr(other.src_addr), dst_addr(other.dst_addr), src_port(other.src_port),
|
||||
dst_port(other.dst_port), proto(other.proto), type(other.type), uid(other.uid)
|
||||
: ip_hdr(other.ip_hdr), src_addr(other.src_addr), dst_addr(other.dst_addr),
|
||||
src_port(other.src_port), dst_port(other.dst_port), proto(other.proto), type(other.type),
|
||||
uid(other.uid)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -87,6 +89,7 @@ public:
|
|||
proto = other.proto;
|
||||
type = other.type;
|
||||
uid = other.uid;
|
||||
ip_hdr = other.ip_hdr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -127,6 +130,9 @@ public:
|
|||
return ! (ec1 == ec2);
|
||||
}
|
||||
|
||||
// TODO: temporarily public
|
||||
std::shared_ptr<IP_Hdr> ip_hdr;
|
||||
|
||||
protected:
|
||||
IPAddr src_addr;
|
||||
IPAddr dst_addr;
|
||||
|
@ -221,6 +227,28 @@ public:
|
|||
return ! (e1 == e2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer the last element in the stack. Returns a nullptr
|
||||
* if the stack is empty or hasn't been initialized yet.
|
||||
*/
|
||||
EncapsulatingConn* Last() { return Depth() > 0 ? &(conns->back()) : nullptr; }
|
||||
|
||||
/**
|
||||
* Returns an EncapsulatingConn from the requested index in the stack.
|
||||
*
|
||||
* @param index An index to look up. Note this is one-indexed, since it's generally
|
||||
* looked up using a value from Depth().
|
||||
* @return The corresponding EncapsulatingConn, or a nullptr if the requested index is
|
||||
* out of range.
|
||||
*/
|
||||
EncapsulatingConn* At(size_t index)
|
||||
{
|
||||
if ( index > 0 && index <= Depth() )
|
||||
return &(conns->at(index - 1));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<EncapsulatingConn>* conns;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue