diff options
Diffstat (limited to 'pcapplusplus.cpp')
-rw-r--r-- | pcapplusplus.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pcapplusplus.cpp b/pcapplusplus.cpp index 894d799..d78a2eb 100644 --- a/pcapplusplus.cpp +++ b/pcapplusplus.cpp @@ -31,6 +31,31 @@ PcapPlusPlus::~PcapPlusPlus() } } +bool PcapPlusPlus::openPcap() +{ + if (!reader) + return false; + + if (reader->isOpened()) + throw std::runtime_error("PCAP File already open. Close it first."); + + return reader->open(); +} + +void PcapPlusPlus::closePcap() +{ + if (reader) + reader->close(); +} + +bool PcapPlusPlus::setFilter(QString filter) +{ + if (reader) + return reader->setFilter(filter.toStdString()); + + return false; +} + bool PcapPlusPlus::processPacket(pcpp::Packet & packet) { pcpp::RawPacket rawPacket; @@ -82,6 +107,16 @@ std::vector<pcpp::Packet>::iterator PcapPlusPlus::parsedPacketsEnd() return parsedPackets.end(); } +bool PcapPlusPlus::getPcapStatistics(pcpp::IFileDevice::PcapStats & stats) +{ + if (reader) { + reader->getStatistics(stats); + return true; + } + + return false; +} + const pcpp::Layer *PcapPlusPlus::getFirstLayer(const pcpp::Packet & packet) { const auto *curLayer = packet.getFirstLayer(); |