Replace ConnList linked list with multiset

Keeping a sorted multi-set allows faster search by source /
source+destination address.

Fixes O(n^2) complexity when handling a lot of connections (now it's
O(n log n)).
This commit is contained in:
Vladimir Panteleev
2022-03-23 17:28:09 +00:00
parent f46954525d
commit 92fb73116a
6 changed files with 100 additions and 96 deletions

View File

@@ -70,8 +70,11 @@ public:
/* is this packet coming from the local host? */
bool Outgoing();
bool match(Packet *other);
bool matchSource(Packet *other);
bool match(const Packet *other) const;
bool matchSource(const Packet *other) const;
/* returns a copy with destination information stripped (for comparisons) */
Packet onlySource() const;
bool operator< (const Packet& other) const;
/* returns '1.2.3.4:5-1.2.3.4:6'-style string */
char *gethashstring();