|
virtual LiveDeviceType | getDeviceType () const |
|
bool | startCapture (OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie, int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void *onStatsUpdateUsrrCookie) |
|
bool | startCapture (int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void *onStatsUpdateUserCookie) |
|
bool | startCapture (RawPacketVector &capturedPacketsVector) |
|
virtual int | sendPackets (RawPacket *rawPacketsArr, int arrLength) |
|
bool | setMinAmountOfDataToCopyFromKernelToApplication (int size) |
|
int | getMinAmountOfDataToCopyFromKernelToApplication () const |
|
virtual | ~PcapLiveDevice () |
|
const char * | getName () const |
|
const char * | getDesc () const |
|
bool | getLoopback () const |
|
virtual uint16_t | getMtu () const |
|
virtual LinkLayerType | getLinkType () const |
|
const std::vector< pcap_addr_t > & | getAddresses () const |
|
virtual MacAddress | getMacAddress () const |
|
IPv4Address | getIPv4Address () const |
|
IPv4Address | getDefaultGateway () const |
|
const std::vector< IPv4Address > & | getDnsServers () const |
|
virtual bool | startCapture (OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie) |
|
virtual int | startCaptureBlockingMode (OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, int timeout) |
|
void | stopCapture () |
|
bool | captureActive () |
|
bool | sendPacket (RawPacket const &rawPacket) |
|
bool | sendPacket (const uint8_t *packetData, int packetDataLength) |
|
bool | sendPacket (Packet *packet) |
|
virtual int | sendPackets (Packet **packetsArr, int arrLength) |
|
virtual int | sendPackets (const RawPacketVector &rawPackets) |
|
bool | open () |
|
bool | open (const DeviceConfiguration &config) |
|
void | close () |
|
virtual void | getStatistics (pcap_stat &stats) const |
|
virtual bool | setFilter (std::string filterAsString) |
|
bool | clearFilter () |
|
virtual bool | setFilter (GeneralFilter &filter) |
|
virtual bool | setFilter (std::string filterAsString)=0 |
|
bool | isOpened () |
|
virtual bool | setFilter (GeneralFilter &filter) |
|
A class that wraps a Windows network interface (each of the interfaces listed in ipconfig). This class is almost similar in its capabilities to PcapLiveDevice (its parent class) with some small changes that mainly result from differences between libpcap and WinPcap. Please see the reference for PcapLiveDevice for more details
bool pcpp::WinPcapLiveDevice::startCapture |
( |
OnPacketArrivesCallback |
onPacketArrives, |
|
|
void * |
onPacketArrivesUserCookie, |
|
|
int |
intervalInSecondsToUpdateStats, |
|
|
OnStatsUpdateCallback |
onStatsUpdate, |
|
|
void * |
onStatsUpdateUserCookie |
|
) |
| |
|
virtual |
Start capturing packets on this network interface (device) with periodic stats collection. Each time a packet is captured the onPacketArrives callback is called. In addition, each intervalInSecondsToUpdateStats seconds stats are collected from the device and the onStatsUpdate callback is called. Both the capture and periodic stats collection are done on new threads created by this method, each on a different thread, meaning all callback calls are done in threads other than the caller thread. Capture process and stats collection will stop and threads will be terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called), otherwise an error will be returned.
- Parameters
-
[in] | onPacketArrives | A callback that is called each time a packet is captured |
[in] | onPacketArrivesUserCookie | A pointer to a user provided object. This object will be transferred to the onPacketArrives callback each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example: objects that counts packets, manages flow state or manages the application state according to the packet that was captured |
[in] | intervalInSecondsToUpdateStats | The interval in seconds to activate periodic stats collection |
[in] | onStatsUpdate | A callback that will be called each time intervalInSecondsToUpdateStats expires and stats are collected. This callback will contain the collected stats |
[in] | onStatsUpdateUserCookie | A pointer to a user provided object. This object will be transferred to the onStatsUpdate callback each time it is called |
- Returns
- True if capture started successfully, false if (relevant log error is printed in any case):
- Capture is already running
- Device is not opened
- Capture thread could not be created
- Stats collection thread could not be created
Reimplemented from pcpp::PcapLiveDevice.