Skip to content

Commit aaaaa4a

Browse files
authored
Update raw function pointers to std::function. (#1934)
1 parent 06a10a4 commit aaaaa4a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Packet++/header/TcpReassembly.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <map>
99
#include <list>
1010
#include <time.h>
11+
#include <functional>
1112

1213
/// @file
1314
/// This is an implementation of TCP reassembly logic, which means reassembly of TCP messages spanning multiple TCP
@@ -316,14 +317,14 @@ namespace pcpp
316317
/// @param[in] tcpData The TCP data itself + connection information
317318
/// @param[in] userCookie A pointer to the cookie provided by the user in TcpReassembly c'tor (or nullptr if no
318319
/// cookie provided)
319-
typedef void (*OnTcpMessageReady)(int8_t side, const TcpStreamData& tcpData, void* userCookie);
320+
using OnTcpMessageReady = std::function<void(int8_t side, const TcpStreamData& tcpData, void* userCookie)>;
320321

321322
/// @typedef OnTcpConnectionStart
322323
/// A callback invoked when a new TCP connection is identified (whether it begins with a SYN packet or not)
323324
/// @param[in] connectionData Connection information
324325
/// @param[in] userCookie A pointer to the cookie provided by the user in TcpReassembly c'tor (or nullptr if no
325326
/// cookie provided)
326-
typedef void (*OnTcpConnectionStart)(const ConnectionData& connectionData, void* userCookie);
327+
using OnTcpConnectionStart = std::function<void(const ConnectionData& connectionData, void* userCookie)>;
327328

328329
/// @typedef OnTcpConnectionEnd
329330
/// A callback invoked when a TCP connection is terminated, either by a FIN or RST packet or manually by the
@@ -332,8 +333,8 @@ namespace pcpp
332333
/// @param[in] reason The reason for connection termination: FIN/RST packet or manually by the user
333334
/// @param[in] userCookie A pointer to the cookie provided by the user in TcpReassembly c'tor (or nullptr if no
334335
/// cookie provided)
335-
typedef void (*OnTcpConnectionEnd)(const ConnectionData& connectionData, ConnectionEndReason reason,
336-
void* userCookie);
336+
using OnTcpConnectionEnd =
337+
std::function<void(const ConnectionData& connectionData, ConnectionEndReason reason, void* userCookie)>;
337338

338339
/// A c'tor for this class
339340
/// @param[in] onMessageReadyCallback The callback to be invoked when new data arrives

0 commit comments

Comments
 (0)