PcapPlusPlus
21.05
|
#include <TcpReassembly.h>
Public Types | |
enum | ConnectionEndReason { TcpReassemblyConnectionClosedByFIN_RST, TcpReassemblyConnectionClosedManually } |
enum | ReassemblyStatus { TcpMessageHandled, OutOfOrderTcpMessageBuffered, FIN_RSTWithNoData, Ignore_PacketWithNoData, Ignore_PacketOfClosedFlow, Ignore_Retransimission, NonIpPacket, NonTcpPacket, Error_PacketDoesNotMatchFlow } |
typedef std::map< uint32_t, ConnectionData > | ConnectionInfoList |
typedef void(* | OnTcpMessageReady) (int8_t side, const TcpStreamData &tcpData, void *userCookie) |
typedef void(* | OnTcpConnectionStart) (const ConnectionData &connectionData, void *userCookie) |
typedef void(* | OnTcpConnectionEnd) (const ConnectionData &connectionData, ConnectionEndReason reason, void *userCookie) |
Public Member Functions | |
TcpReassembly (OnTcpMessageReady onMessageReadyCallback, void *userCookie=NULL, OnTcpConnectionStart onConnectionStartCallback=NULL, OnTcpConnectionEnd onConnectionEndCallback=NULL, const TcpReassemblyConfiguration &config=TcpReassemblyConfiguration()) | |
ReassemblyStatus | reassemblePacket (Packet &tcpData) |
ReassemblyStatus | reassemblePacket (RawPacket *tcpRawData) |
void | closeConnection (uint32_t flowKey) |
void | closeAllConnections () |
const ConnectionInfoList & | getConnectionInformation () const |
int | isConnectionOpen (const ConnectionData &connection) const |
uint32_t | purgeClosedConnections (uint32_t maxNumToClean=0) |
A class containing the TCP reassembly logic. Please refer to the documentation at the top of TcpReassembly.h for understanding how to use this class
typedef std::map<uint32_t, ConnectionData> pcpp::TcpReassembly::ConnectionInfoList |
The type for storing the connection information
pcpp::TcpReassembly::OnTcpConnectionEnd |
A callback invoked when a TCP connection is terminated, either by a FIN or RST packet or manually by the user
[in] | connectionData | Connection information |
[in] | reason | The reason for connection termination: FIN/RST packet or manually by the user |
[in] | userCookie | A pointer to the cookie provided by the user in TcpReassembly c'tor (or NULL if no cookie provided) |
pcpp::TcpReassembly::OnTcpConnectionStart |
A callback invoked when a new TCP connection is identified (whether it begins with a SYN packet or not)
[in] | connectionData | Connection information |
[in] | userCookie | A pointer to the cookie provided by the user in TcpReassembly c'tor (or NULL if no cookie provided) |
pcpp::TcpReassembly::OnTcpMessageReady |
A callback invoked when new data arrives on a connection
[in] | side | The side this data belongs to (MachineA->MachineB or vice versa). The value is 0 or 1 where 0 is the first side seen in the connection and 1 is the second side seen |
[in] | tcpData | The TCP data itself + connection information |
[in] | userCookie | A pointer to the cookie provided by the user in TcpReassembly c'tor (or NULL if no cookie provided) |
An enum for providing reassembly status for each processed packet
pcpp::TcpReassembly::TcpReassembly | ( | OnTcpMessageReady | onMessageReadyCallback, |
void * | userCookie = NULL , |
||
OnTcpConnectionStart | onConnectionStartCallback = NULL , |
||
OnTcpConnectionEnd | onConnectionEndCallback = NULL , |
||
const TcpReassemblyConfiguration & | config = TcpReassemblyConfiguration() |
||
) |
A c'tor for this class
[in] | onMessageReadyCallback | The callback to be invoked when new data arrives |
[in] | userCookie | A pointer to an object provided by the user. This pointer will be returned when invoking the various callbacks. This parameter is optional, default cookie is NULL |
[in] | onConnectionStartCallback | The callback to be invoked when a new connection is identified. This parameter is optional |
[in] | onConnectionEndCallback | The callback to be invoked when a new connection is terminated (either by a FIN/RST packet or manually by the user). This parameter is optional |
[in] | config | Optional parameter for defining special configuration parameters. If not set the default parameters will be set |
void pcpp::TcpReassembly::closeAllConnections | ( | ) |
Close all open connections manually. This method will cause the TcpReassembly::OnTcpConnectionEnd to be invoked for each connection with a reason of TcpReassembly::TcpReassemblyConnectionClosedManually
void pcpp::TcpReassembly::closeConnection | ( | uint32_t | flowKey | ) |
Close a connection manually. If the connection doesn't exist or already closed an error log is printed. This method will cause the TcpReassembly::OnTcpConnectionEnd to be invoked with a reason of TcpReassembly::TcpReassemblyConnectionClosedManually
[in] | flowKey | A 4-byte hash key representing the connection. Can be taken from a ConnectionData instance |
|
inline |
Get a map of all connections managed by this TcpReassembly instance (both connections that are open and those that are already closed)
int pcpp::TcpReassembly::isConnectionOpen | ( | const ConnectionData & | connection | ) | const |
Check if a certain connection managed by this TcpReassembly instance is currently opened or closed
[in] | connection | The connection to check |
uint32_t pcpp::TcpReassembly::purgeClosedConnections | ( | uint32_t | maxNumToClean = 0 | ) |
Clean up the closed connections from the memory
[in] | maxNumToClean | The maximum number of items to be cleaned up per one call. This parameter, when its value is not zero, overrides the value that was set by the constructor. |
ReassemblyStatus pcpp::TcpReassembly::reassemblePacket | ( | Packet & | tcpData | ) |
The most important method of this class which gets a packet from the user and processes it. If this packet opens a new connection, ends a connection or contains new data on an existing connection, the relevant callback will be called (TcpReassembly::OnTcpMessageReady, TcpReassembly::OnTcpConnectionStart, TcpReassembly::OnTcpConnectionEnd)
[in] | tcpData | A reference to the packet to process |
TcpReassembly::ReassemblyStatus
, indicating status of TCP reassembly ReassemblyStatus pcpp::TcpReassembly::reassemblePacket | ( | RawPacket * | tcpRawData | ) |
The most important method of this class which gets a raw packet from the user and processes it. If this packet opens a new connection, ends a connection or contains new data on an existing connection, the relevant callback will be invoked (TcpReassembly::OnTcpMessageReady, TcpReassembly::OnTcpConnectionStart, TcpReassembly::OnTcpConnectionEnd)
[in] | tcpRawData | A reference to the raw packet to process |
TcpReassembly::ReassemblyStatus
, indicating status of TCP reassembly