mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Add bif that allows searching for all matching subnets in table.
Example: global test: set[subnet] = { 10.0.0.0/8, 10.1.0.0/16, 10.2.0.0/16, 10.2.0.2/31 } print matching_subnets(10.2.0.2/32, test); -> [10.2.0.2/31, 10.2.0.0/16, 10.0.0.0/8]
This commit is contained in:
parent
42e4072673
commit
562e5a9f63
10 changed files with 274 additions and 11 deletions
|
@ -36,6 +36,10 @@ public:
|
|||
void* Lookup(const IPAddr& addr, int width, bool exact = false) const;
|
||||
void* Lookup(const Val* value, bool exact = false) const;
|
||||
|
||||
// Returns list of all found matches or empty list otherwhise.
|
||||
list<IPPrefix> FindAll(const IPAddr& addr, int width) const;
|
||||
list<IPPrefix> FindAll(const SubNetVal* value) const;
|
||||
|
||||
// Returns pointer to data or nil if not found.
|
||||
void* Remove(const IPAddr& addr, int width);
|
||||
void* Remove(const Val* value);
|
||||
|
@ -45,6 +49,10 @@ public:
|
|||
iterator InitIterator();
|
||||
void* GetNext(iterator* i);
|
||||
|
||||
private:
|
||||
static prefix_t* MakePrefix(const IPAddr& addr, int width);
|
||||
static IPPrefix PrefixToIPPrefix(prefix_t* p);
|
||||
|
||||
patricia_tree_t* tree;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue