mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -2,16 +2,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/IPAddr.h"
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/IPAddr.h"
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/UID.h"
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
namespace zeek {
|
||||
namespace zeek
|
||||
{
|
||||
|
||||
class Connection;
|
||||
|
||||
|
@ -22,15 +22,16 @@ class Connection;
|
|||
* transport layer protocol. EncapsulatingConn's are assigned a UID, which can
|
||||
* be shared with Connection's in the case the tunnel uses a transport-layer.
|
||||
*/
|
||||
class EncapsulatingConn {
|
||||
class EncapsulatingConn
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default tunnel connection constructor.
|
||||
*/
|
||||
EncapsulatingConn()
|
||||
: src_port(0), dst_port(0), proto(TRANSPORT_UNKNOWN),
|
||||
type(BifEnum::Tunnel::NONE), uid()
|
||||
{}
|
||||
: src_port(0), dst_port(0), proto(TRANSPORT_UNKNOWN), type(BifEnum::Tunnel::NONE), uid()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an IP tunnel "connection" with its own UID.
|
||||
|
@ -44,8 +45,7 @@ public:
|
|||
*/
|
||||
EncapsulatingConn(const IPAddr& s, const IPAddr& d,
|
||||
BifEnum::Tunnel::Type t = BifEnum::Tunnel::IP)
|
||||
: src_addr(s), dst_addr(d), src_port(0), dst_port(0),
|
||||
proto(TRANSPORT_UNKNOWN), type(t),
|
||||
: src_addr(s), dst_addr(d), src_port(0), dst_port(0), proto(TRANSPORT_UNKNOWN), type(t),
|
||||
uid(UID(detail::bits_per_uid))
|
||||
{
|
||||
}
|
||||
|
@ -65,16 +65,15 @@ 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)
|
||||
{}
|
||||
: 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~EncapsulatingConn()
|
||||
{}
|
||||
~EncapsulatingConn() { }
|
||||
|
||||
EncapsulatingConn& operator=(const EncapsulatingConn& other)
|
||||
{
|
||||
|
@ -92,44 +91,39 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
BifEnum::Tunnel::Type Type() const
|
||||
{ return type; }
|
||||
BifEnum::Tunnel::Type Type() const { return type; }
|
||||
|
||||
/**
|
||||
* Returns record value of type "EncapsulatingConn" representing the tunnel.
|
||||
*/
|
||||
RecordValPtr ToVal() const;
|
||||
|
||||
friend bool operator==(const EncapsulatingConn& ec1,
|
||||
const EncapsulatingConn& ec2)
|
||||
friend bool operator==(const EncapsulatingConn& ec1, const EncapsulatingConn& ec2)
|
||||
{
|
||||
if ( ec1.type != ec2.type )
|
||||
return false;
|
||||
|
||||
if ( ec1.type == BifEnum::Tunnel::IP ||
|
||||
ec1.type == BifEnum::Tunnel::GRE )
|
||||
if ( ec1.type == BifEnum::Tunnel::IP || ec1.type == BifEnum::Tunnel::GRE )
|
||||
// Reversing endpoints is still same tunnel.
|
||||
return ec1.uid == ec2.uid && ec1.proto == ec2.proto &&
|
||||
((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) ||
|
||||
(ec1.src_addr == ec2.dst_addr && ec1.dst_addr == ec2.src_addr));
|
||||
((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) ||
|
||||
(ec1.src_addr == ec2.dst_addr && ec1.dst_addr == ec2.src_addr));
|
||||
|
||||
if ( ec1.type == BifEnum::Tunnel::VXLAN )
|
||||
// Reversing endpoints is still same tunnel, destination port is
|
||||
// always the same.
|
||||
return ec1.dst_port == ec2.dst_port &&
|
||||
ec1.uid == ec2.uid && ec1.proto == ec2.proto &&
|
||||
((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) ||
|
||||
(ec1.src_addr == ec2.dst_addr && ec1.dst_addr == ec2.src_addr));
|
||||
return ec1.dst_port == ec2.dst_port && ec1.uid == ec2.uid && ec1.proto == ec2.proto &&
|
||||
((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) ||
|
||||
(ec1.src_addr == ec2.dst_addr && ec1.dst_addr == ec2.src_addr));
|
||||
|
||||
return ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr &&
|
||||
ec1.src_port == ec2.src_port && ec1.dst_port == ec2.dst_port &&
|
||||
ec1.uid == ec2.uid && ec1.proto == ec2.proto;
|
||||
ec1.src_port == ec2.src_port && ec1.dst_port == ec2.dst_port && ec1.uid == ec2.uid &&
|
||||
ec1.proto == ec2.proto;
|
||||
}
|
||||
|
||||
friend bool operator!=(const EncapsulatingConn& ec1,
|
||||
const EncapsulatingConn& ec2)
|
||||
friend bool operator!=(const EncapsulatingConn& ec1, const EncapsulatingConn& ec2)
|
||||
{
|
||||
return ! ( ec1 == ec2 );
|
||||
return ! (ec1 == ec2);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -140,15 +134,15 @@ protected:
|
|||
TransportProto proto;
|
||||
BifEnum::Tunnel::Type type;
|
||||
UID uid;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstracts an arbitrary amount of nested tunneling.
|
||||
*/
|
||||
class EncapsulationStack {
|
||||
class EncapsulationStack
|
||||
{
|
||||
public:
|
||||
EncapsulationStack() : conns(nullptr)
|
||||
{}
|
||||
EncapsulationStack() : conns(nullptr) { }
|
||||
|
||||
EncapsulationStack(const EncapsulationStack& other)
|
||||
{
|
||||
|
@ -192,17 +186,14 @@ public:
|
|||
* Return how many nested tunnels are involved in a encapsulation, zero
|
||||
* meaning no tunnels are present.
|
||||
*/
|
||||
size_t Depth() const
|
||||
{
|
||||
return conns ? conns->size() : 0;
|
||||
}
|
||||
size_t Depth() const { return conns ? conns->size() : 0; }
|
||||
|
||||
/**
|
||||
* Return the tunnel type of the inner-most tunnel.
|
||||
*/
|
||||
BifEnum::Tunnel::Type LastType() const
|
||||
{
|
||||
return conns ? (*conns)[conns->size()-1].Type() : BifEnum::Tunnel::NONE;
|
||||
return conns ? (*conns)[conns->size() - 1].Type() : BifEnum::Tunnel::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,8 +202,7 @@ public:
|
|||
*/
|
||||
VectorValPtr ToVal() const
|
||||
{
|
||||
auto vv = make_intrusive<VectorVal>(
|
||||
id::find_type<VectorType>("EncapsulatingConnVector"));
|
||||
auto vv = make_intrusive<VectorVal>(id::find_type<VectorType>("EncapsulatingConnVector"));
|
||||
|
||||
if ( conns )
|
||||
{
|
||||
|
@ -223,17 +213,15 @@ public:
|
|||
return vv;
|
||||
}
|
||||
|
||||
friend bool operator==(const EncapsulationStack& e1,
|
||||
const EncapsulationStack& e2);
|
||||
friend bool operator==(const EncapsulationStack& e1, const EncapsulationStack& e2);
|
||||
|
||||
friend bool operator!=(const EncapsulationStack& e1,
|
||||
const EncapsulationStack& e2)
|
||||
friend bool operator!=(const EncapsulationStack& e1, const EncapsulationStack& e2)
|
||||
{
|
||||
return ! ( e1 == e2 );
|
||||
return ! (e1 == e2);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<EncapsulatingConn>* conns;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace zeek
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue