13 #include <condition_variable>
19 typedef struct __pfring pfring;
28 typedef void (*OnPfRingPacketsArriveCallback)(RawPacket* packets, uint32_t numOfPackets, uint8_t threadId,
29 PfRingDevice* device,
void* userCookie);
38 struct CoreConfiguration
53 void waitForStartup();
57 std::condition_variable m_Cv;
61 pfring** m_PfRingDescriptors;
62 uint8_t m_NumOfOpenedRxChannels;
63 std::string m_DeviceName;
67 std::array<CoreConfiguration, MAX_NUM_OF_CORES> m_CoreConfiguration;
68 std::atomic<bool> m_StopThread;
69 OnPfRingPacketsArriveCallback m_OnPacketsArriveCallback;
70 void* m_OnPacketsArriveUserCookie;
72 bool m_HwClockEnabled;
73 bool m_IsFilterCurrentlySet;
77 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
78 void captureThreadMain(std::shared_ptr<StartupBlock> startupBlock);
80 int openSingleRxChannel(
const char* deviceName, pfring** ring);
82 bool getIsHwClockEnable()
84 setPfRingDeviceAttributes();
85 return m_HwClockEnabled;
87 bool setPfRingDeviceClock(pfring* ring);
89 void clearCoreConfiguration();
90 int getCoresInUseCount()
const;
92 void setPfRingDeviceAttributes();
94 bool sendData(
const uint8_t* packetData,
int packetDataLength,
bool flushTxQueues);
123 setPfRingDeviceAttributes();
131 setPfRingDeviceAttributes();
132 return m_InterfaceIndex;
139 setPfRingDeviceAttributes();
148 setPfRingDeviceAttributes();
149 return m_HwClockEnabled;
213 return m_NumOfOpenedRxChannels;
262 bool sendPacket(
const uint8_t* packetData,
int packetDataLength);
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:63
Definition: MacAddress.h:21
Definition: PfRingDevice.h:34
bool sendPacket(const RawPacket &rawPacket)
bool startCaptureMultiThread(OnPfRingPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
ChannelDistribution
An enum representing the type of packet distribution between different RX channels.
Definition: PfRingDevice.h:99
@ RoundRobin
Packets are distributed between channels in a round-robin manner.
Definition: PfRingDevice.h:101
@ PerFlow
Packets are distributed between channels per flow (each flow goes for different channel)
Definition: PfRingDevice.h:103
bool startCaptureSingleThread(OnPfRingPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
void stopCapture()
Stops capturing packets (works will all type of startCapture*)
int getMtu()
Definition: PfRingDevice.h:137
bool isHwClockEnabledForDevice()
Definition: PfRingDevice.h:146
bool openMultiRxChannels(uint8_t numOfRxChannelsToOpen, ChannelDistribution dist)
bool openSingleRxChannel(uint8_t channelId)
uint8_t getTotalNumOfRxChannels() const
void getThreadStatistics(SystemCore core, PfRingStats &stats) const
~PfRingDevice()
A destructor for PfRingDevice class.
bool sendPacket(const Packet &packet)
int sendPackets(const Packet **packetsArr, int arrLength)
bool openMultiRxChannels(const uint8_t *channelIds, int numOfChannelIds)
int sendPackets(const RawPacketVector &rawPackets)
uint8_t getNumOfOpenedRxChannels() const
Definition: PfRingDevice.h:211
std::string getDeviceName() const
Definition: PfRingDevice.h:154
int getInterfaceIndex()
Definition: PfRingDevice.h:129
bool isFilterCurrentlySet() const
SystemCore getCurrentCoreId() const
void getCurrentThreadStatistics(PfRingStats &stats) const
MacAddress getMacAddress()
Definition: PfRingDevice.h:121
bool sendPacket(const uint8_t *packetData, int packetDataLength)
void close()
Closes all RX channels currently opened in device.
bool setFilter(std::string filterAsString)
void getStatistics(PfRingStats &stats) const
int sendPackets(const RawPacket *rawPacketsArr, int arrLength)
Definition: PfRingDeviceList.h:17
Definition: PointerVector.h:50
Definition: RawPacket.h:259
The main namespace for the PcapPlusPlus lib.
Definition: PfRingDevice.h:109
uint64_t drop
Number of packets dropped.
Definition: PfRingDevice.h:113
uint64_t recv
Number of packets received.
Definition: PfRingDevice.h:111
Definition: SystemUtils.h:29