mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Merge remote-tracking branch 'origin/topic/johanna/netcontrol'
BIT-1550 #merged * origin/topic/johanna/netcontrol: (72 commits) Update baselines and news Move prefixtable back to all IPv6 internal handling. NetControl: Add functions to search for rules affecting IPs/subnets Add check_subnet bif that allows exact membership test for subnet tables. Rewrite internal handling of rules. Add bif that allows searching for all matching subnets in table. Add signaling of succesful initialization of plugins to NetControl. Add rule hooks to the acld plugin. Add new logfiles for shunting and drops to netcontrol Extend NetControl logging and fix bugs. Update OpenFlow API and events. small acld plugin fix Revert "introduce &weaken attribute" Fix crash when printing type of recursive structures. Testcase for crash when a record contains a function referencing a record. Rename Pacf to NetControl fix acld plugin to use address instead of subnet (and add functions for conversion) implement quarantine miscelaneous missing bits and pieces Acld implementation for Pacf - Bro side. ...
This commit is contained in:
commit
2233521de7
107 changed files with 6071 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "PrefixTable.h"
|
||||
#include "Reporter.h"
|
||||
|
||||
inline static prefix_t* make_prefix(const IPAddr& addr, int width)
|
||||
prefix_t* PrefixTable::MakePrefix(const IPAddr& addr, int width)
|
||||
{
|
||||
prefix_t* prefix = (prefix_t*) safe_malloc(sizeof(prefix_t));
|
||||
|
||||
|
@ -13,9 +13,14 @@ inline static prefix_t* make_prefix(const IPAddr& addr, int width)
|
|||
return prefix;
|
||||
}
|
||||
|
||||
IPPrefix PrefixTable::PrefixToIPPrefix(prefix_t* prefix)
|
||||
{
|
||||
return IPPrefix(IPAddr(IPv6, reinterpret_cast<const uint32_t*>(&prefix->add.sin6), IPAddr::Network), prefix->bitlen, 1);
|
||||
}
|
||||
|
||||
void* PrefixTable::Insert(const IPAddr& addr, int width, void* data)
|
||||
{
|
||||
prefix_t* prefix = make_prefix(addr, width);
|
||||
prefix_t* prefix = MakePrefix(addr, width);
|
||||
patricia_node_t* node = patricia_lookup(tree, prefix);
|
||||
Deref_Prefix(prefix);
|
||||
|
||||
|
@ -57,13 +62,39 @@ void* PrefixTable::Insert(const Val* value, void* data)
|
|||
}
|
||||
}
|
||||
|
||||
list<IPPrefix> PrefixTable::FindAll(const IPAddr& addr, int width) const
|
||||
{
|
||||
std::list<IPPrefix> out;
|
||||
prefix_t* prefix = MakePrefix(addr, width);
|
||||
|
||||
int elems = 0;
|
||||
patricia_node_t** list = nullptr;
|
||||
|
||||
patricia_search_all(tree, prefix, &list, &elems);
|
||||
|
||||
for ( int i = 0; i < elems; ++i )
|
||||
out.push_back(PrefixToIPPrefix(list[i]->prefix));
|
||||
|
||||
Deref_Prefix(prefix);
|
||||
free(list);
|
||||
return out;
|
||||
}
|
||||
|
||||
list<IPPrefix> PrefixTable::FindAll(const SubNetVal* value) const
|
||||
{
|
||||
return FindAll(value->AsSubNet().Prefix(), value->AsSubNet().LengthIPv6());
|
||||
}
|
||||
|
||||
void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
|
||||
{
|
||||
prefix_t* prefix = make_prefix(addr, width);
|
||||
prefix_t* prefix = MakePrefix(addr, width);
|
||||
patricia_node_t* node =
|
||||
exact ? patricia_search_exact(tree, prefix) :
|
||||
patricia_search_best(tree, prefix);
|
||||
|
||||
int elems = 0;
|
||||
patricia_node_t** list = nullptr;
|
||||
|
||||
Deref_Prefix(prefix);
|
||||
return node ? node->data : 0;
|
||||
}
|
||||
|
@ -94,7 +125,7 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const
|
|||
|
||||
void* PrefixTable::Remove(const IPAddr& addr, int width)
|
||||
{
|
||||
prefix_t* prefix = make_prefix(addr, width);
|
||||
prefix_t* prefix = MakePrefix(addr, width);
|
||||
patricia_node_t* node = patricia_search_exact(tree, prefix);
|
||||
Deref_Prefix(prefix);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue