PcapPlusPlus  22.11
pcpp::KniDeviceList Class Reference

#include <KniDeviceList.h>

Public Types

enum  KniCallbackVersion { CALLBACKS_NEW = 0, CALLBACKS_OLD = 1 }
 
enum  KniCallbackType { CALLBACK_MTU, CALLBACK_LINK, CALLBACK_MAC, CALLBACK_PROMISC }
 

Public Member Functions

bool isInitialized ()
 
KniDevicecreateDevice (const KniDevice::KniDeviceConfiguration &config, const size_t mempoolSize)
 Factory method for KNI devices. Newly created device is remembered under portId and name provided in config and can be found later by them. If KNI device is not destroyed explicitly thru KniDeviceList::destroyDevice then it will be destroyed implicitly by the time application exits. More...
 
KniDevicegetDeviceByPort (const uint16_t portId)
 Returns KNI device with specified portId. More...
 
KniDevicegetDeviceByName (const std::string &name)
 Returns KNI device with specified name. More...
 

Static Public Member Functions

static KniDeviceListgetInstance ()
 Getter for singleton. More...
 
static KniCallbackVersion callbackVersion ()
 
static bool isCallbackSupported (const KniCallbackType cbType)
 

Detailed Description

A singleton class that encapsulates DPDK KNI module initialization and holds the list of KniDevice instances. As it's a singleton, it has only one active instance doesn't have a public c'tor.

Member Enumeration Documentation

◆ KniCallbackType

◆ KniCallbackVersion

Callback related constants for KNI device

Enumerator
CALLBACKS_NEW 

Reports that DPDK supports only KniDevice::KniIoctlCallbacks callback structure

CALLBACKS_OLD 

Reports that DPDK supports only KniDevice::KniOldIoctlCallbacks callback structure

Member Function Documentation

◆ callbackVersion()

static KniCallbackVersion pcpp::KniDeviceList::callbackVersion ( )
static

Returns KniCallbackVersion::CALLBACKS_NEW or KniCallbackVersion::CALLBACKS_OLD based on DPDK version used

Note
MT SAFE

◆ createDevice()

KniDevice* pcpp::KniDeviceList::createDevice ( const KniDevice::KniDeviceConfiguration config,
const size_t  mempoolSize 
)

Factory method for KNI devices. Newly created device is remembered under portId and name provided in config and can be found later by them. If KNI device is not destroyed explicitly thru KniDeviceList::destroyDevice then it will be destroyed implicitly by the time application exits.

Warning
NOT MT SAFE
Parameters
[in]configKNI device configuration structure
[in]mempoolSizeSize of packet mempool used by this device
Returns
Pointer to new KNI device or NULL in case of error

◆ getDeviceByName()

KniDevice* pcpp::KniDeviceList::getDeviceByName ( const std::string &  name)

Returns KNI device with specified name.

Note
MT SAFE if createDevice or destroyDevice is not called concurrently
Parameters
[in]nameName of KNI device to find
Returns
Pointer to KNI device or NULL if device not found

◆ getDeviceByPort()

KniDevice* pcpp::KniDeviceList::getDeviceByPort ( const uint16_t  portId)

Returns KNI device with specified portId.

Note
MT SAFE if createDevice or destroyDevice is not called concurrently
Parameters
[in]portIdID of KNI device to find
Returns
Pointer to KNI device or NULL if device not found

◆ getInstance()

static KniDeviceList& pcpp::KniDeviceList::getInstance ( )
static

Getter for singleton.

Warning
Initialization of Kni module depends on initialization of DPDK made by DpdkDeviceList
Returns
The singleton instance of KniDeviceList

◆ isCallbackSupported()

static bool pcpp::KniDeviceList::isCallbackSupported ( const KniCallbackType  cbType)
static

Returns true if provided callback type is supported by used DPDK version

Note
MT SAFE
Parameters
[in]cbTypeOne of KniCallbackType enum values

◆ isInitialized()

bool pcpp::KniDeviceList::isInitialized ( )
inline
Returns
true if KNI module was initialized successfully false otherwise