mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix reassembly of data w/ sizes beyond 32-bit capacities (BIT-348).
The main change is that reassembly code (e.g. for TCP) now uses int64/uint64 (signedness is situational) data types in place of int types in order to support delivering data to analyzers that pass 2GB thresholds. There's also changes in logic that accompany the change in data types, e.g. to fix TCP sequence space arithmetic inconsistencies. Another significant change is in the Analyzer API: the *Packet and *Undelivered methods now use a uint64 in place of an int for the relative sequence space offset parameter.
This commit is contained in:
parent
2f57c26d5b
commit
2b3c2bd394
75 changed files with 1627 additions and 1540 deletions
|
@ -8,16 +8,16 @@
|
|||
|
||||
class DataBlock {
|
||||
public:
|
||||
DataBlock(const u_char* data, int size, int seq,
|
||||
DataBlock(const u_char* data, uint64 size, uint64 seq,
|
||||
DataBlock* prev, DataBlock* next);
|
||||
|
||||
~DataBlock();
|
||||
|
||||
int Size() const { return upper - seq; }
|
||||
uint64 Size() const { return upper - seq; }
|
||||
|
||||
DataBlock* next; // next block with higher seq #
|
||||
DataBlock* prev; // previous block with lower seq #
|
||||
int seq, upper;
|
||||
uint64 seq, upper;
|
||||
u_char* block;
|
||||
};
|
||||
|
||||
|
@ -26,22 +26,22 @@ enum ReassemblerType { REASSEM_IP, REASSEM_TCP };
|
|||
|
||||
class Reassembler : public BroObj {
|
||||
public:
|
||||
Reassembler(int init_seq, ReassemblerType arg_type);
|
||||
Reassembler(uint64 init_seq, ReassemblerType arg_type);
|
||||
virtual ~Reassembler();
|
||||
|
||||
void NewBlock(double t, int seq, int len, const u_char* data);
|
||||
void NewBlock(double t, uint64 seq, uint64 len, const u_char* data);
|
||||
|
||||
// Throws away all blocks up to seq. Returns number of bytes
|
||||
// if not all in-sequence, 0 if they were.
|
||||
int TrimToSeq(int seq);
|
||||
uint64 TrimToSeq(uint64 seq);
|
||||
|
||||
// Delete all held blocks.
|
||||
void ClearBlocks();
|
||||
|
||||
int HasBlocks() const { return blocks != 0; }
|
||||
int LastReassemSeq() const { return last_reassem_seq; }
|
||||
uint64 LastReassemSeq() const { return last_reassem_seq; }
|
||||
|
||||
int TotalSize() const; // number of bytes buffered up
|
||||
uint64 TotalSize() const; // number of bytes buffered up
|
||||
|
||||
void Describe(ODesc* d) const;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
static Reassembler* Unserialize(UnserialInfo* info);
|
||||
|
||||
// Sum over all data buffered in some reassembler.
|
||||
static unsigned int TotalMemoryAllocation() { return total_size; }
|
||||
static uint64 TotalMemoryAllocation() { return total_size; }
|
||||
|
||||
protected:
|
||||
Reassembler() { }
|
||||
|
@ -58,20 +58,20 @@ protected:
|
|||
|
||||
friend class DataBlock;
|
||||
|
||||
virtual void Undelivered(int up_to_seq);
|
||||
virtual void Undelivered(uint64 up_to_seq);
|
||||
|
||||
virtual void BlockInserted(DataBlock* b) = 0;
|
||||
virtual void Overlap(const u_char* b1, const u_char* b2, int n) = 0;
|
||||
virtual void Overlap(const u_char* b1, const u_char* b2, uint64 n) = 0;
|
||||
|
||||
DataBlock* AddAndCheck(DataBlock* b, int seq,
|
||||
int upper, const u_char* data);
|
||||
DataBlock* AddAndCheck(DataBlock* b, uint64 seq,
|
||||
uint64 upper, const u_char* data);
|
||||
|
||||
DataBlock* blocks;
|
||||
DataBlock* last_block;
|
||||
int last_reassem_seq;
|
||||
int trim_seq; // how far we've trimmed
|
||||
uint64 last_reassem_seq;
|
||||
uint64 trim_seq; // how far we've trimmed
|
||||
|
||||
static unsigned int total_size;
|
||||
static uint64 total_size;
|
||||
};
|
||||
|
||||
inline DataBlock::~DataBlock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue