#ifndef PCAPPLUSPLUS_H #define PCAPPLUSPLUS_H #include #include #include class PcapPlusPlus { public: explicit PcapPlusPlus(std::string fileName); ~PcapPlusPlus(); bool openPcap(); void closePcap(); bool setFilter(QString filter); bool processPacket(pcpp::Packet & packet); pcpp::RawPacket& getRawPacket(size_t index); pcpp::Packet& getParsedPacket(size_t index); pcpp::LinkLayerType getLinkLayer(); std::vector::iterator rawPacketsBegin(); std::vector::iterator rawPacketsEnd(); std::vector::iterator parsedPacketsBegin(); std::vector::iterator parsedPacketsEnd(); bool randomizeEth(size_t index, bool isSourceEth); bool randomizeIp(size_t index, bool isSourceIp); bool randomizePort(size_t index, bool isSourcePort); bool setEth(size_t index, const std::string & eth, bool isSourceIp); bool setIp(size_t index, const std::string & ip, bool isSourceIp); bool setPort(size_t index, const std::string & port, bool isSourceIp); void fixupHeaders(size_t index); bool getPcapStatistics(pcpp::IFileDevice::PcapStats & stats); double getFirstPacketTimestamp() { return firstPacketTs; } static const pcpp::Layer *getFirstLayer(const pcpp::Packet & packet); static QString getProtocolTypeAsString(pcpp::ProtocolType protocolType); static std::tuple getEthTuple(const pcpp::Packet & packet); static std::tuple getIpTuple(const pcpp::Packet & packet); static std::tuple getLayer4Tuple(const pcpp::Packet & packet); private: double firstPacketTs = 0; pcpp::IFileReaderDevice *reader = nullptr; std::vector rawPackets; std::vector parsedPackets; }; #endif // PCAPPLUSPLUS_H