6 #include <unordered_map>
129 void setStartTime(
const std::chrono::time_point<std::chrono::high_resolution_clock>& startTimeValue);
135 void setEndTime(
const std::chrono::time_point<std::chrono::high_resolution_clock>& endTimeValue);
158 std::chrono::time_point<std::chrono::high_resolution_clock> timestamp)
159 : m_Data(tcpData), m_DataLen(tcpDataLength), m_MissingBytes(missingBytes), m_Connection(connData),
160 m_Timestamp(timestamp)
187 return m_MissingBytes;
222 const uint8_t* m_Data;
224 size_t m_MissingBytes;
226 std::chrono::time_point<std::chrono::high_resolution_clock> m_Timestamp;
464 return m_ConnectionInfo;
489 std::chrono::time_point<std::chrono::high_resolution_clock> timestamp;
491 TcpFragment() : sequence(0), dataLength(0), data(nullptr)
499 struct TcpOneSideData
504 PointerVector<TcpFragment> tcpFragmentList;
507 TcpOneSideData() : srcPort(0), sequence(0), gotFinOrRst(false)
511 struct TcpReassemblyData
516 TcpOneSideData twoSides[2];
517 ConnectionData connData;
519 TcpReassemblyData() : closed(false), numOfSides(0), prevSide(-1)
523 class OutOfOrderProcessingGuard
529 explicit OutOfOrderProcessingGuard(
bool& flag) : m_Flag(flag)
534 ~OutOfOrderProcessingGuard()
540 OutOfOrderProcessingGuard(
const OutOfOrderProcessingGuard&) =
delete;
541 OutOfOrderProcessingGuard& operator=(
const OutOfOrderProcessingGuard&) =
delete;
544 typedef std::unordered_map<uint32_t, TcpReassemblyData> ConnectionList;
545 typedef std::map<time_t, std::list<uint32_t>> CleanupList;
551 ConnectionList m_ConnectionList;
553 CleanupList m_CleanupList;
554 bool m_RemoveConnInfo;
555 uint32_t m_ClosedConnectionDelay;
556 uint32_t m_MaxNumToClean;
557 size_t m_MaxOutOfOrderFragments;
558 time_t m_PurgeTimepoint;
559 bool m_EnableBaseBufferClearCondition;
560 bool m_ProcessingOutOfOrder =
false;
562 void checkOutOfOrderFragments(TcpReassemblyData* tcpReassemblyData, int8_t sideIndex,
bool cleanWholeFragList);
564 void handleFinOrRst(TcpReassemblyData* tcpReassemblyData, int8_t sideIndex, uint32_t flowKey,
bool isRst);
568 void insertIntoCleanupList(uint32_t flowKey);
Definition: IpAddress.h:358
Definition: RawPacket.h:269
Definition: TcpReassembly.h:288
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:305
@ NonIpPacket
Definition: TcpReassembly.h:356
@ FIN_RSTWithNoData
Definition: TcpReassembly.h:335
@ Error_PacketDoesNotMatchFlow
Definition: TcpReassembly.h:367
@ Ignore_PacketOfClosedFlow
Definition: TcpReassembly.h:346
@ NonTcpPacket
Definition: TcpReassembly.h:361
@ Ignore_Retransimission
Definition: TcpReassembly.h:351
@ TcpMessageHandled
Definition: TcpReassembly.h:317
@ OutOfOrderTcpMessageBuffered
Definition: TcpReassembly.h:329
@ Ignore_PacketWithNoData
Definition: TcpReassembly.h:341
const ConnectionInfoList & getConnectionInformation() const
Definition: TcpReassembly.h:462
void(* OnTcpConnectionStart)(const ConnectionData &connectionData, void *userCookie)
Definition: TcpReassembly.h:393
uint32_t purgeClosedConnections(uint32_t maxNumToClean=0)
void closeAllConnections()
ReassemblyStatus reassemblePacket(Packet &tcpData)
std::unordered_map< uint32_t, ConnectionData > ConnectionInfoList
Definition: TcpReassembly.h:373
void(* OnTcpMessageReady)(int8_t side, const TcpStreamData &tcpData, void *userCookie)
Definition: TcpReassembly.h:384
void closeConnection(uint32_t flowKey)
ConnectionEndReason
Definition: TcpReassembly.h:294
@ TcpReassemblyConnectionClosedByFIN_RST
Definition: TcpReassembly.h:296
@ TcpReassemblyConnectionClosedManually
Definition: TcpReassembly.h:298
void(* OnTcpConnectionEnd)(const ConnectionData &connectionData, ConnectionEndReason reason, void *userCookie)
Definition: TcpReassembly.h:403
Definition: TcpReassembly.h:147
bool isBytesMissing() const
Definition: TcpReassembly.h:194
size_t getDataLength() const
Definition: TcpReassembly.h:176
timeval getTimeStamp() const
size_t getMissingByteCount() const
Definition: TcpReassembly.h:185
TcpStreamData(const uint8_t *tcpData, size_t tcpDataLength, size_t missingBytes, const ConnectionData &connData, std::chrono::time_point< std::chrono::high_resolution_clock > timestamp)
Definition: TcpReassembly.h:157
std::chrono::time_point< std::chrono::high_resolution_clock > getTimeStampPrecise() const
Definition: TcpReassembly.h:216
const uint8_t * getData() const
Definition: TcpReassembly.h:167
const ConnectionData & getConnectionData() const
Definition: TcpReassembly.h:203
The main namespace for the PcapPlusPlus lib.
Definition: TcpReassembly.h:99
IPAddress srcIP
Definition: TcpReassembly.h:101
IPAddress dstIP
Definition: TcpReassembly.h:103
std::chrono::time_point< std::chrono::high_resolution_clock > startTimePrecise
Definition: TcpReassembly.h:115
timeval endTime
Definition: TcpReassembly.h:113
timeval startTime
Definition: TcpReassembly.h:111
void setStartTime(const std::chrono::time_point< std::chrono::high_resolution_clock > &startTimeValue)
std::chrono::time_point< std::chrono::high_resolution_clock > endTimePrecise
Definition: TcpReassembly.h:117
uint16_t dstPort
Definition: TcpReassembly.h:107
uint16_t srcPort
Definition: TcpReassembly.h:105
ConnectionData()
Definition: TcpReassembly.h:122
uint32_t flowKey
Definition: TcpReassembly.h:109
void setEndTime(const std::chrono::time_point< std::chrono::high_resolution_clock > &endTimeValue)
Definition: TcpReassembly.h:234
uint32_t closedConnectionDelay
Definition: TcpReassembly.h:242
uint32_t maxNumToClean
Definition: TcpReassembly.h:248
uint32_t maxOutOfOrderFragments
Definition: TcpReassembly.h:254
TcpReassemblyConfiguration(bool removeConnInfo=true, uint32_t closedConnectionDelay=5, uint32_t maxNumToClean=30, uint32_t maxOutOfOrderFragments=0, bool enableBaseBufferClearCondition=true)
Definition: TcpReassembly.h:273
bool enableBaseBufferClearCondition
Definition: TcpReassembly.h:258
bool removeConnInfo
Definition: TcpReassembly.h:236