PcapPlusPlus  Next
pcpp::internal::IWinDivertHandle Class Referenceabstract

An abstract handle for interacting with the WinDivert device. More...

#include <WinDivertDevice.h>

Public Types

enum class  WinDivertParam {
  QueueLength = 0 , QueueTime = 1 , QueueSize = 2 , VersionMajor = 3 ,
  VersionMinor = 4
}
 WinDivert runtime parameters that can be queried or configured. More...
 

Public Member Functions

virtual uint32_t close ()=0
 Close the underlying WinDivert handle. More...
 
virtual uint32_t recvEx (uint8_t *buffer, uint32_t bufferLen, size_t addressesSize, IOverlappedWrapper *overlapped)=0
 Begin or perform an overlapped receive of raw packet data. More...
 
virtual std::vector< WinDivertAddressrecvExComplete ()=0
 Finalize a previous overlapped receive and fetch per-packet address metadata. More...
 
virtual uint32_t sendEx (uint8_t *buffer, uint32_t bufferLen, size_t addressesSize)=0
 Send a batch of raw packets. More...
 
virtual std::unique_ptr< IOverlappedWrappercreateOverlapped ()=0
 Create a new overlapped wrapper bound to this handle. More...
 
virtual bool getParam (WinDivertParam param, uint64_t &value)=0
 Query a WinDivert runtime/queue parameter. More...
 
virtual bool setParam (WinDivertParam param, uint64_t value)=0
 Set a WinDivert runtime/queue parameter. More...
 

Static Public Attributes

static constexpr uint32_t SuccessResult = 0
 Generic success code returned by most operations.
 
static constexpr uint32_t ErrorIoPending = 997
 Windows ERROR_IO_PENDING (997) reported when an async operation is in flight.
 

Detailed Description

An abstract handle for interacting with the WinDivert device.

This interface represents an opened WinDivert handle and provides the minimal set of operations used by WinDivertDevice: asynchronous receive, batched send, querying/setting queue parameters and handle closure. Concrete implementations wrap the corresponding WinDivert C APIs and Windows OVERLAPPED I/O.

Member Enumeration Documentation

◆ WinDivertParam

WinDivert runtime parameters that can be queried or configured.

Enumerator
QueueLength 

Maximum number of packets in the queue.

QueueTime 

Maximum time (ms) a packet may stay in the queue.

QueueSize 

Maximum total queue size (bytes)

VersionMajor 

WinDivert major version.

VersionMinor 

WinDivert minor version.

Member Function Documentation

◆ close()

virtual uint32_t pcpp::internal::IWinDivertHandle::close ( )
pure virtual

Close the underlying WinDivert handle.

Returns
Windows error code-style result. 0 indicates success.

◆ createOverlapped()

virtual std::unique_ptr<IOverlappedWrapper> pcpp::internal::IWinDivertHandle::createOverlapped ( )
pure virtual

Create a new overlapped wrapper bound to this handle.

Returns
A unique_ptr to a fresh IOverlappedWrapper for async operations.

◆ getParam()

virtual bool pcpp::internal::IWinDivertHandle::getParam ( WinDivertParam  param,
uint64_t &  value 
)
pure virtual

Query a WinDivert runtime/queue parameter.

Parameters
[in]paramThe parameter to query.
[out]valueThe retrieved value.
Returns
True on success, false on failure.

◆ recvEx()

virtual uint32_t pcpp::internal::IWinDivertHandle::recvEx ( uint8_t *  buffer,
uint32_t  bufferLen,
size_t  addressesSize,
IOverlappedWrapper overlapped 
)
pure virtual

Begin or perform an overlapped receive of raw packet data.

If an overlapped object is provided, the call initiates an asynchronous read and typically returns ErrorIoPending. Completion status and size should be obtained via the provided IOverlappedWrapper.

Parameters
[in]bufferDestination buffer for packet data.
[in]bufferLenSize of the destination buffer in bytes.
[in]addressesSizeNumber of address entries the implementation may capture for a batch.
[in]overlappedWrapper around Windows OVERLAPPED used for async I/O. Must not be null for async.
Returns
0 on success, ErrorIoPending if async operation started, or a Windows error code on failure.

◆ recvExComplete()

virtual std::vector<WinDivertAddress> pcpp::internal::IWinDivertHandle::recvExComplete ( )
pure virtual

Finalize a previous overlapped receive and fetch per-packet address metadata.

Returns
A vector of WinDivertAddress entries, one per packet captured in the last receive.

◆ sendEx()

virtual uint32_t pcpp::internal::IWinDivertHandle::sendEx ( uint8_t *  buffer,
uint32_t  bufferLen,
size_t  addressesSize 
)
pure virtual

Send a batch of raw packets.

Parameters
[in]bufferBuffer containing one or more consecutive packets.
[in]bufferLenTotal size in bytes of the packets contained in buffer.
[in]addressesSizeNumber of address entries accompanying the send batch.
Returns
0 on success, otherwise a Windows error code.

◆ setParam()

virtual bool pcpp::internal::IWinDivertHandle::setParam ( WinDivertParam  param,
uint64_t  value 
)
pure virtual

Set a WinDivert runtime/queue parameter.

Parameters
[in]paramThe parameter to set.
[in]valueThe value to set.
Returns
True on success, false on failure.