mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -6,66 +6,63 @@
|
|||
#include "zeek/Reporter.h"
|
||||
#include "zeek/util.h"
|
||||
|
||||
namespace zeek
|
||||
{
|
||||
namespace zeek {
|
||||
|
||||
EncapsulatingConn::EncapsulatingConn(Connection* c, BifEnum::Tunnel::Type t)
|
||||
: src_addr(c->OrigAddr()), dst_addr(c->RespAddr()), src_port(c->OrigPort()),
|
||||
dst_port(c->RespPort()), proto(c->ConnTransport()), type(t), uid(c->GetUID())
|
||||
{
|
||||
if ( ! uid )
|
||||
{
|
||||
uid.Set(zeek::detail::bits_per_uid);
|
||||
c->SetUID(uid);
|
||||
}
|
||||
}
|
||||
: src_addr(c->OrigAddr()),
|
||||
dst_addr(c->RespAddr()),
|
||||
src_port(c->OrigPort()),
|
||||
dst_port(c->RespPort()),
|
||||
proto(c->ConnTransport()),
|
||||
type(t),
|
||||
uid(c->GetUID()) {
|
||||
if ( ! uid ) {
|
||||
uid.Set(zeek::detail::bits_per_uid);
|
||||
c->SetUID(uid);
|
||||
}
|
||||
}
|
||||
|
||||
RecordValPtr EncapsulatingConn::ToVal() const
|
||||
{
|
||||
auto rv = make_intrusive<RecordVal>(BifType::Record::Tunnel::EncapsulatingConn);
|
||||
RecordValPtr EncapsulatingConn::ToVal() const {
|
||||
auto rv = make_intrusive<RecordVal>(BifType::Record::Tunnel::EncapsulatingConn);
|
||||
|
||||
auto id_val = make_intrusive<RecordVal>(id::conn_id);
|
||||
id_val->Assign(0, make_intrusive<AddrVal>(src_addr));
|
||||
id_val->Assign(1, val_mgr->Port(ntohs(src_port), proto));
|
||||
id_val->Assign(2, make_intrusive<AddrVal>(dst_addr));
|
||||
id_val->Assign(3, val_mgr->Port(ntohs(dst_port), proto));
|
||||
rv->Assign(0, std::move(id_val));
|
||||
rv->Assign(1, BifType::Enum::Tunnel::Type->GetEnumVal(type));
|
||||
auto id_val = make_intrusive<RecordVal>(id::conn_id);
|
||||
id_val->Assign(0, make_intrusive<AddrVal>(src_addr));
|
||||
id_val->Assign(1, val_mgr->Port(ntohs(src_port), proto));
|
||||
id_val->Assign(2, make_intrusive<AddrVal>(dst_addr));
|
||||
id_val->Assign(3, val_mgr->Port(ntohs(dst_port), proto));
|
||||
rv->Assign(0, std::move(id_val));
|
||||
rv->Assign(1, BifType::Enum::Tunnel::Type->GetEnumVal(type));
|
||||
|
||||
rv->Assign(2, uid.Base62("C"));
|
||||
rv->Assign(2, uid.Base62("C"));
|
||||
|
||||
return rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool operator==(const EncapsulationStack& e1, const EncapsulationStack& e2)
|
||||
{
|
||||
if ( ! e1.conns )
|
||||
return e2.conns;
|
||||
bool operator==(const EncapsulationStack& e1, const EncapsulationStack& e2) {
|
||||
if ( ! e1.conns )
|
||||
return e2.conns;
|
||||
|
||||
if ( ! e2.conns )
|
||||
return false;
|
||||
if ( ! e2.conns )
|
||||
return false;
|
||||
|
||||
if ( e1.conns->size() != e2.conns->size() )
|
||||
return false;
|
||||
if ( e1.conns->size() != e2.conns->size() )
|
||||
return false;
|
||||
|
||||
for ( size_t i = 0; i < e1.conns->size(); ++i )
|
||||
{
|
||||
if ( (*e1.conns)[i] != (*e2.conns)[i] )
|
||||
return false;
|
||||
}
|
||||
for ( size_t i = 0; i < e1.conns->size(); ++i ) {
|
||||
if ( (*e1.conns)[i] != (*e2.conns)[i] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EncapsulationStack::Pop()
|
||||
{
|
||||
if ( Depth() == 0 )
|
||||
{
|
||||
reporter->InternalWarning("Attempted to pop from empty EncapsulationStack\n");
|
||||
return;
|
||||
}
|
||||
void EncapsulationStack::Pop() {
|
||||
if ( Depth() == 0 ) {
|
||||
reporter->InternalWarning("Attempted to pop from empty EncapsulationStack\n");
|
||||
return;
|
||||
}
|
||||
|
||||
conns->pop_back();
|
||||
}
|
||||
conns->pop_back();
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue