6 #include <unordered_map>
160 : m_Data(tcpData), m_DataLen(tcpDataLength), m_MissingBytes(missingBytes), m_Connection(connData),
161 m_Timestamp(timestamp)
188 return m_MissingBytes;
219 const uint8_t* m_Data;
221 size_t m_MissingBytes;
461 return m_ConnectionInfo;
488 TcpFragment() : sequence(0), dataLength(0), data(nullptr)
496 struct TcpOneSideData
501 PointerVector<TcpFragment> tcpFragmentList;
504 TcpOneSideData() : srcPort(0), sequence(0), gotFinOrRst(false)
508 struct TcpReassemblyData
513 TcpOneSideData twoSides[2];
514 ConnectionData connData;
516 TcpReassemblyData() : closed(false), numOfSides(0), prevSide(-1)
520 class OutOfOrderProcessingGuard
526 explicit OutOfOrderProcessingGuard(
bool& flag) : m_Flag(flag)
531 ~OutOfOrderProcessingGuard()
537 OutOfOrderProcessingGuard(
const OutOfOrderProcessingGuard&) =
delete;
538 OutOfOrderProcessingGuard& operator=(
const OutOfOrderProcessingGuard&) =
delete;
541 typedef std::unordered_map<uint32_t, TcpReassemblyData> ConnectionList;
542 typedef std::map<time_t, std::list<uint32_t>> CleanupList;
548 ConnectionList m_ConnectionList;
550 CleanupList m_CleanupList;
551 bool m_RemoveConnInfo;
552 uint32_t m_ClosedConnectionDelay;
553 uint32_t m_MaxNumToClean;
554 size_t m_MaxOutOfOrderFragments;
555 time_t m_PurgeTimepoint;
556 bool m_EnableBaseBufferClearCondition;
557 bool m_ProcessingOutOfOrder =
false;
559 void checkOutOfOrderFragments(TcpReassemblyData* tcpReassemblyData, int8_t sideIndex,
bool cleanWholeFragList);
561 void handleFinOrRst(TcpReassemblyData* tcpReassemblyData, int8_t sideIndex, uint32_t flowKey,
bool isRst);
565 void insertIntoCleanupList(uint32_t flowKey);
Definition: IpAddress.h:358
Definition: RawPacket.h:269
Definition: TcpReassembly.h:285
ReassemblyStatus reassemblePacket(RawPacket *tcpRawData)
int isConnectionOpen(const ConnectionData &connection) const
TcpReassembly(OnTcpMessageReady onMessageReadyCallback, void *userCookie=nullptr, OnTcpConnectionStart onConnectionStartCallback=nullptr, OnTcpConnectionEnd onConnectionEndCallback=nullptr, const TcpReassemblyConfiguration &config=TcpReassemblyConfiguration())
ReassemblyStatus
Definition: TcpReassembly.h:302
@ NonIpPacket
Definition: TcpReassembly.h:353
@ FIN_RSTWithNoData
Definition: TcpReassembly.h:332
@ Error_PacketDoesNotMatchFlow
Definition: TcpReassembly.h:364
@ Ignore_PacketOfClosedFlow
Definition: TcpReassembly.h:343
@ NonTcpPacket
Definition: TcpReassembly.h:358
@ Ignore_Retransimission
Definition: TcpReassembly.h:348
@ TcpMessageHandled
Definition: TcpReassembly.h:314
@ OutOfOrderTcpMessageBuffered
Definition: TcpReassembly.h:326
@ Ignore_PacketWithNoData
Definition: TcpReassembly.h:338
const ConnectionInfoList & getConnectionInformation() const
Definition: TcpReassembly.h:459
void(* OnTcpConnectionStart)(const ConnectionData &connectionData, void *userCookie)
Definition: TcpReassembly.h:390
uint32_t purgeClosedConnections(uint32_t maxNumToClean=0)
void closeAllConnections()
ReassemblyStatus reassemblePacket(Packet &tcpData)
std::unordered_map< uint32_t, ConnectionData > ConnectionInfoList
Definition: TcpReassembly.h:370
void(* OnTcpMessageReady)(int8_t side, const TcpStreamData &tcpData, void *userCookie)
Definition: TcpReassembly.h:381
void closeConnection(uint32_t flowKey)
ConnectionEndReason
Definition: TcpReassembly.h:291
@ TcpReassemblyConnectionClosedByFIN_RST
Definition: TcpReassembly.h:293
@ TcpReassemblyConnectionClosedManually
Definition: TcpReassembly.h:295
void(* OnTcpConnectionEnd)(const ConnectionData &connectionData, ConnectionEndReason reason, void *userCookie)
Definition: TcpReassembly.h:400
Definition: TcpReassembly.h:148
TcpStreamData(const uint8_t *tcpData, size_t tcpDataLength, size_t missingBytes, const ConnectionData &connData, timeval timestamp)
Definition: TcpReassembly.h:158
bool isBytesMissing() const
Definition: TcpReassembly.h:195
size_t getDataLength() const
Definition: TcpReassembly.h:177
timeval getTimeStamp() const
Definition: TcpReassembly.h:213
size_t getMissingByteCount() const
Definition: TcpReassembly.h:186
const uint8_t * getData() const
Definition: TcpReassembly.h:168
const ConnectionData & getConnectionData() const
Definition: TcpReassembly.h:204
The main namespace for the PcapPlusPlus lib.
Definition: TcpReassembly.h:98
IPAddress srcIP
Definition: TcpReassembly.h:100
IPAddress dstIP
Definition: TcpReassembly.h:102
timeval endTime
Definition: TcpReassembly.h:112
void setEndTime(const timeval &endTimeValue)
Definition: TcpReassembly.h:133
timeval startTime
Definition: TcpReassembly.h:110
uint16_t dstPort
Definition: TcpReassembly.h:106
uint16_t srcPort
Definition: TcpReassembly.h:104
void setStartTime(const timeval &startTimeValue)
Definition: TcpReassembly.h:124
ConnectionData()
Definition: TcpReassembly.h:117
uint32_t flowKey
Definition: TcpReassembly.h:108
Definition: TcpReassembly.h:231
uint32_t closedConnectionDelay
Definition: TcpReassembly.h:239
uint32_t maxNumToClean
Definition: TcpReassembly.h:245
uint32_t maxOutOfOrderFragments
Definition: TcpReassembly.h:251
TcpReassemblyConfiguration(bool removeConnInfo=true, uint32_t closedConnectionDelay=5, uint32_t maxNumToClean=30, uint32_t maxOutOfOrderFragments=0, bool enableBaseBufferClearCondition=true)
Definition: TcpReassembly.h:270
bool enableBaseBufferClearCondition
Definition: TcpReassembly.h:255
bool removeConnInfo
Definition: TcpReassembly.h:233