PcapPlusPlus
|
#include <TcpReassembly.h>
Public Types | |
enum | ConnectionEndReason { TcpReassemblyConnectionClosedByFIN_RST, TcpReassemblyConnectionClosedManually } |
typedef void(* | OnTcpMessageReady) (int side, TcpStreamData tcpData, void *userCookie) |
typedef void(* | OnTcpConnectionStart) (ConnectionData connectionData, void *userCookie) |
typedef void(* | OnTcpConnectionEnd) (ConnectionData connectionData, ConnectionEndReason reason, void *userCookie) |
Public Member Functions | |
TcpReassembly (OnTcpMessageReady onMessageReadyCallback, void *userCookie=NULL, OnTcpConnectionStart onConnectionStartCallback=NULL, OnTcpConnectionEnd onConnectionEndCallback=NULL) | |
~TcpReassembly () | |
void | reassemblePacket (Packet &tcpData) |
void | reassemblePacket (RawPacket *tcpRawData) |
void | closeConnection (uint32_t flowKey) |
void | closeAllConnections () |
const std::vector< ConnectionData > & | getConnectionInformation () const |
int | isConnectionOpen (const ConnectionData &connection) |
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
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) |
pcpp::TcpReassembly::TcpReassembly | ( | OnTcpMessageReady | onMessageReadyCallback, |
void * | userCookie = NULL , |
||
OnTcpConnectionStart | onConnectionStartCallback = NULL , |
||
OnTcpConnectionEnd | onConnectionEndCallback = NULL |
||
) |
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 |
pcpp::TcpReassembly::~TcpReassembly | ( | ) |
A d'tor for this class. Frees all internal structures. Notice that if the d'tor is called while connections are still open, all data is lost and TcpReassembly::OnTcpConnectionEnd won't be called for those connections
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 |
const std::vector<ConnectionData>& pcpp::TcpReassembly::getConnectionInformation | ( | ) | const |
Get a list 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 | ) |
Check if a certain connection managed by this TcpReassembly instance is currently opened or closed
[in] | connection | The connection to check |
void 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 |
void 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 |