10 #include "MBufRawPacket.h"
11 #include "LinuxNicInformationSocket.h"
246 return !(m_Device ==
nullptr || m_MBufMempool ==
nullptr);
251 return std::string(m_DeviceInfo.name);
256 return m_DeviceInfo.portId;
528 struct rte_kni* m_Device;
529 struct rte_mempool* m_MBufMempool;
549 static void runCapture(
void* devicePointer, std::atomic<bool>& stopThread);
550 inline bool isRunning()
const
552 return thread !=
nullptr;
562 static void runRequests(
void* devicePointer, std::atomic<bool>& stopThread);
Definition: KniDevice.h:116
bool sendPacket(MBufRawPacket &rawPacket)
Send a MBufRawPacket to kernel. Please notice that the mbuf used in this method isn't freed by this m...
bool sendPacket(RawPacket &rawPacket)
Send a raw packet to kernel. Please notice that if the raw packet isn't of type MBufRawPacket,...
KniPromiscuousMode getPromiscuous(KniInfoState state=INFO_CACHED)
Obtains information about promiscuous mode of KNI device. If called with INFO_CACHED - returns cached...
uint16_t receivePackets(Packet **packetsArr, uint16_t packetsArrLength)
Receive parsed packets from kernel.
bool sendPacket(Packet &packet)
Send a parsed packet to kernel. Please notice that the mbuf used or allocated in this method isn't fr...
std::string getName() const
Obtains name of KNI device in form of C++ string.
Definition: KniDevice.h:249
bool startCapture(OnKniPacketArriveCallback onPacketArrives, void *onPacketArrivesUserCookie)
Start capturing packets asynchronously on this KNI interface. Each time a burst of packets is capture...
KniInfoState
Various information related constants for KNI device.
Definition: KniDevice.h:135
@ INFO_CACHED
Used to identify intent to obtain cached version of KNI device information.
Definition: KniDevice.h:137
@ INFO_RENEW
Used to identify intent to renew/update KNI device information.
Definition: KniDevice.h:139
bool isInitialized() const
Indicates whether the KNI device was initialized successfully.
Definition: KniDevice.h:244
bool setPromiscuous(KniPromiscuousMode mode)
Sets promiscuous mode of KNI device. Firstly the promiscuous mode information is updated as by call t...
KniLinkState updateLinkState(KniLinkState state)
Updates link state of KNI device. Unconditionally updates link state of KNI device via call to DPDK l...
uint16_t receivePackets(MBufRawPacket **rawPacketsArr, uint16_t rawPacketArrLength)
Receive raw packets from kernel. Please notice that in terms of performance, this is the best method ...
MacAddress getMacAddress(KniInfoState state=INFO_CACHED)
Obtains MAC address of KNI device. If called with INFO_CACHED - returns cached data about MAC address...
KniLinkState getLinkState(KniInfoState state=INFO_CACHED)
Obtains link status of KNI device. If called with INFO_CACHED - returns cached data about link state ...
int startCaptureBlockingMode(OnKniPacketArriveCallback onPacketArrives, void *onPacketArrivesUserCookie, int timeout)
Start capturing packets synchronously on this KNI interface in blocking mode. Blocking mode means tha...
bool setMtu(uint16_t mtu)
Sets MTU of KNI device. Unconditionally changes MTU of KNI device. If MTU is updated successfully the...
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr)
Receive raw packets from kernel.
KniLinkState
Various link related constants for KNI device.
Definition: KniDevice.h:123
@ LINK_NOT_SUPPORTED
Returned by KNI functions if DPDK version used don't support link setup capability.
Definition: KniDevice.h:125
@ LINK_UP
Used to put link status on KNI device UP.
Definition: KniDevice.h:131
@ LINK_DOWN
Used to put link status on KNI device DOWN.
Definition: KniDevice.h:129
@ LINK_ERROR
Returned by KNI functions if link changing function meets an error.
Definition: KniDevice.h:127
void stopRequestHandlerThread()
Explicitly stops request thread for this device if it was running. See description of handleRequests(...
bool setLinkState(KniLinkState state)
Sets link state of KNI device. Firstly the link information is updated as by call to getLinkState(INF...
uint16_t sendPackets(MBufRawPacketVector &rawPacketsVec)
Send a vector of MBufRawPacket pointers to kernel. Please notice the following:
uint16_t getPort() const
Obtains port ID of KNI device.
Definition: KniDevice.h:254
void stopCapture()
Stop a currently running asynchronous packet capture.
bool handleRequests()
Handle requests from Linux kernel synchronously in calling thread. When one of events which is needed...
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength)
Send an array of MBufRawPacket to kernel. Please notice the following:
uint16_t sendPackets(Packet **packetsArr, uint16_t arrLength)
Send an array of parsed packets to kernel. Please notice the following:
uint16_t sendPackets(RawPacketVector &rawPacketsVec)
Send a vector of RawPacket pointers to kernel. Please notice the following:
KniPromiscuousMode
Promiscuous mode related constants for KNI device.
Definition: KniDevice.h:143
@ PROMISC_ENABLE
Used to ENABLE promiscuous mode on KNI device.
Definition: KniDevice.h:147
@ PROMISC_DISABLE
Used to DISABLE promiscuous mode on KNI device.
Definition: KniDevice.h:145
bool setMacAddress(const MacAddress &mac)
Sets MAC address of KNI device. Unconditionally changes MAC of KNI device. If MAC is updated successf...
uint16_t getMtu(KniInfoState state=INFO_CACHED)
Obtains MTU of KNI device. If called with INFO_CACHED - returns cached data about MTU (SUPER FAST may...
bool startRequestHandlerThread(long sleepSeconds, long sleepNanoSeconds=0)
Starts new thread (using pthread) to asynchronously handle KNI device requests. See description of ha...
void close()
Close the KNI device. When device is closed it's not possible to work with it. Stops asynchronous pac...
Definition: KniDeviceList.h:19
Definition: MBufRawPacket.h:45
Definition: MacAddress.h:21
Definition: PointerVector.h:50
Definition: RawPacket.h:269
The main namespace for the PcapPlusPlus lib.
bool(* OnKniPacketArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, KniDevice *device, void *userCookie)
Defines the signature callback used by capturing API on KNI device.
Definition: KniDevice.h:89
KNI device initialization data. Used to create new KNI device. Usage of callbacks member or oldCallba...
Definition: KniDevice.h:201
uint16_t portId
Definition: KniDevice.h:219
std::string name
Definition: KniDevice.h:205
uint16_t mtu
MTU of new KNI device. Will be cached by new KNI device info structure.
Definition: KniDevice.h:221
uint32_t kthreadCoreId
ID of core to bind Linux kernel thread to (same as DPDK cores IDs)
Definition: KniDevice.h:229
bool bindKthread
Definition: KniDevice.h:227
MacAddress mac
Definition: KniDevice.h:214
New callbacks for KNI device events. This structure MUST be used ONLY when KniDeviceList::callbackVer...
Definition: KniDevice.h:160
int(* change_mtu)(uint16_t port_id, unsigned int new_mtu)
Definition: KniDevice.h:163
int(* config_mac_address)(uint16_t port_id, uint8_t mac_addr[])
Definition: KniDevice.h:172
int(* config_network_if)(uint16_t port_id, uint8_t if_up)
Definition: KniDevice.h:166
int(* config_promiscusity)(uint16_t port_id, uint8_t to_on)
Definition: KniDevice.h:178
Old callbacks for KNI device events. This structure MUST be used ONLY when KniDeviceList::callbackVer...
Definition: KniDevice.h:187
int(* change_mtu)(uint8_t port_id, unsigned int new_mtu)
Definition: KniDevice.h:190
int(* config_network_if)(uint8_t port_id, uint8_t if_up)
Definition: KniDevice.h:193