14 #include <condition_variable>
20 typedef struct __pfring pfring;
29 typedef void (*OnPfRingPacketsArriveCallback)(RawPacket* packets, uint32_t numOfPackets, uint8_t threadId,
30 PfRingDevice* device,
void* userCookie);
39 struct CoreConfiguration
54 void waitForStartup();
58 std::condition_variable m_Cv;
62 bool m_DeviceOpened =
false;
64 std::vector<pfring*> m_PfRingDescriptors;
65 std::string m_DeviceName;
69 std::array<CoreConfiguration, MAX_NUM_OF_CORES> m_CoreConfiguration;
70 std::atomic<bool> m_StopThread;
71 OnPfRingPacketsArriveCallback m_OnPacketsArriveCallback;
72 void* m_OnPacketsArriveUserCookie;
74 bool m_HwClockEnabled;
75 bool m_IsFilterCurrentlySet;
79 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
80 void captureThreadMain(std::shared_ptr<StartupBlock> startupBlock);
82 int openSingleRxChannel(
const char* deviceName, pfring*& ring);
84 void closeAllRxChannels();
86 bool getIsHwClockEnable()
88 setPfRingDeviceAttributes();
89 return m_HwClockEnabled;
91 bool setPfRingDeviceClock(pfring* ring);
93 void clearCoreConfiguration();
94 size_t getCoresInUseCount()
const;
96 void setPfRingDeviceAttributes();
98 bool sendData(
const uint8_t* packetData,
int packetDataLength,
bool flushTxQueues);
127 setPfRingDeviceAttributes();
135 setPfRingDeviceAttributes();
136 return m_InterfaceIndex;
143 setPfRingDeviceAttributes();
152 setPfRingDeviceAttributes();
153 return m_HwClockEnabled;
217 return static_cast<uint8_t
>(m_PfRingDescriptors.size());
266 bool sendPacket(
const uint8_t* packetData,
int packetDataLength);
315 return m_DeviceOpened;
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:56
Definition: MacAddress.h:24
Definition: PfRingDevice.h:35
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:103
@ RoundRobin
Packets are distributed between channels in a round-robin manner.
Definition: PfRingDevice.h:105
@ PerFlow
Packets are distributed between channels per flow (each flow goes for different channel)
Definition: PfRingDevice.h:107
bool startCaptureSingleThread(OnPfRingPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
void stopCapture()
Stops capturing packets (works will all type of startCapture*)
int getMtu()
Definition: PfRingDevice.h:141
bool isHwClockEnabledForDevice()
Definition: PfRingDevice.h:150
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:215
std::string getDeviceName() const
Definition: PfRingDevice.h:158
int getInterfaceIndex()
Definition: PfRingDevice.h:133
bool isFilterCurrentlySet() const
SystemCore getCurrentCoreId() const
void getCurrentThreadStatistics(PfRingStats &stats) const
MacAddress getMacAddress()
Definition: PfRingDevice.h:125
bool sendPacket(const uint8_t *packetData, int packetDataLength)
bool isOpened() const override
Definition: PfRingDevice.h:313
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:18
Definition: PointerVector.h:50
Definition: RawPacket.h:259
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
Definition: PfRingDevice.h:113
uint64_t drop
Number of packets dropped.
Definition: PfRingDevice.h:117
uint64_t recv
Number of packets received.
Definition: PfRingDevice.h:115
Definition: SystemUtils.h:30