1 #ifndef PCAPPP_KNI_DEVICE 2 #define PCAPPP_KNI_DEVICE 9 #include "MBufRawPacket.h" 10 #include "LinuxNicInformationSocket.h" 286 inline bool isInitialized()
const {
return !(m_Device == NULL || m_MBufMempool == NULL); }
290 inline std::string
getName()
const {
return std::string(m_DeviceInfo.name); }
294 inline uint16_t
getPort()
const {
return m_DeviceInfo.portId; }
366 bool setMtu(uint16_t mtu);
615 struct rte_kni* m_Device;
616 struct rte_mempool* m_MBufMempool;
636 static void runCapture(
void* devicePointer, std::atomic<bool>& stopThread);
637 inline bool isRunning()
const {
return thread != NULL; }
646 static void runRequests(
void* devicePointer, std::atomic<bool>& stopThread);
The main namespace for the PcapPlusPlus lib.
Definition: KniDevice.h:156
KniPromiscuousMode getPromiscuous(KniInfoState state=INFO_CACHED)
Obtains information about promiscuous mode of KNI device. If called with INFO_CACHED - returns cached...
int(* change_mtu)(uint16_t port_id, unsigned int new_mtu)
Definition: KniDevice.h:178
Definition: KniDevice.h:121
void close()
Close the KNI device. When device is closed it's not possible to work with it. Stops asynchronous pac...
Definition: KniDevice.h:136
bool startCapture(OnKniPacketArriveCallback onPacketArrives, void *onPacketArrivesUserCookie)
Start capturing packets asynchronously on this KNI interface. Each time a burst of packets is capture...
bool setPromiscuous(KniPromiscuousMode mode)
Sets promiscuous mode of KNI device. Firstly the promiscuous mode information is updated as by call t...
KniInfoState
Definition: KniDevice.h:143
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...
Definition: KniDevice.h:148
bool bindKthread
Definition: KniDevice.h:265
bool isInitialized() const
Definition: KniDevice.h:286
Definition: PointerVector.h:24
MacAddress getMacAddress(KniInfoState state=INFO_CACHED)
Obtains MAC address of KNI device. If called with INFO_CACHED - returns cached data about MAC address...
Definition: RawPacket.h:252
uint32_t kthreadCoreId
Definition: KniDevice.h:267
Definition: MBufRawPacket.h:43
bool startRequestHandlerThread(long sleepSeconds, long sleepNanoSeconds=0)
Starts new thread (using pthread) to asynchronously handle KNI device requests. See description of ha...
int(* config_promiscusity)(uint16_t port_id, uint8_t to_on)
Definition: KniDevice.h:199
bool(* OnKniPacketArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, KniDevice *device, void *userCookie)
Definition: KniDevice.h:94
KniLinkState
Definition: KniDevice.h:129
New callbacks for KNI device events. This structure MUST be used ONLY when KniDeviceList::callbackVer...
Definition: KniDevice.h:172
KniLinkState getLinkState(KniInfoState state=INFO_CACHED)
Obtains link status of KNI device. If called with INFO_CACHED - returns cached data about link state ...
Old callbacks for KNI device events. This structure MUST be used ONLY when KniDeviceList::callbackVer...
Definition: KniDevice.h:209
MacAddress mac
Definition: KniDevice.h:248
int startCaptureBlockingMode(OnKniPacketArriveCallback onPacketArrives, void *onPacketArrivesUserCookie, int timeout)
Start capturing packets synchronously on this KNI interface in blocking mode. Blocking mode means tha...
int(* config_network_if)(uint16_t port_id, uint8_t if_up)
Definition: KniDevice.h:183
Definition: KniDevice.h:134
bool handleRequests()
Handle requests from Linux kernel synchronously in calling thread. When one of events which is needed...
Definition: KniDeviceList.h:22
KniLinkState updateLinkState(KniLinkState state)
Updates link state of KNI device. Unconditionally updates link state of KNI device via call to DPDK l...
bool setMacAddress(MacAddress mac)
Sets MAC address of KNI device. Unconditionally changes MAC of KNI device. If MAC is updated successf...
Definition: KniDevice.h:146
std::string name
Definition: KniDevice.h:236
Definition: KniDevice.h:158
KNI device initialization data. Used to create new KNI device. Usage of callbacks member or oldCallba...
Definition: KniDevice.h:229
bool setLinkState(KniLinkState state)
Sets link state of KNI device. Firstly the link information is updated as by call to getLinkState(INF...
std::string getName() const
Definition: KniDevice.h:290
bool setMtu(uint16_t mtu)
Sets MTU of KNI device. Unconditionally changes MTU of KNI device. If MTU is updated successfully the...
uint16_t portId
Definition: KniDevice.h:255
KniPromiscuousMode
Definition: KniDevice.h:153
uint16_t mtu
Definition: KniDevice.h:257
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr)
Receive raw packets from kernel.
Definition: KniDevice.h:138
void stopRequestHandlerThread()
Explicitly stops request thread for this device if it was running. See description of handleRequests(...
uint16_t getPort() const
Definition: KniDevice.h:294
Definition: KniDevice.h:132
Definition: MacAddress.h:28
bool sendPacket(RawPacket &rawPacket)
Send a raw packet to kernel. Please notice that if the raw packet isn't of type MBufRawPacket, a new temp MBufRawPacket will be created and the data will be copied to it. This is necessary to allocate an mbuf which will store the data to be sent. If performance is a critical factor please make sure you send a raw packet of type MBufRawPacket. Please also notice that the mbuf used or allocated in this method isn't freed by this method, it will be transparently freed by DPDK.
int(* config_mac_address)(uint16_t port_id, uint8_t mac_addr[])
Definition: KniDevice.h:191
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength)
Send an array of MBufRawPacket to kernel. Please notice the following: