Examples/HttpAnalyzer/main.cpp
/**
 * activate HTTP analysis from pcap file
 */
activate HTTP analysis from pcap file
activate HTTP analysis from pcap file
void analyzeHttpFromPcapFile(std::string pcapFileName, uint16_t dstPort)
{
	pcpp::IFileReaderDevice* reader = pcpp::IFileReaderDevice::getReader(pcapFileName);
	if (!reader->open())
		EXIT_WITH_ERROR("Could not open input pcap file");
	pcpp::PortFilter httpPortFilter(dstPort, pcpp::SRC_OR_DST);
	if (!reader->setFilter(httpPortFilter))
		EXIT_WITH_ERROR("Could not set up filter on file");
	HttpStatsCollector collector(dstPort);
	pcpp::RawPacket rawPacket;
	while(reader->getNextPacket(rawPacket))
	{
		pcpp::Packet parsedPacket(&rawPacket);
		collector.collectStats(&parsedPacket);
	}
	std::cout << std::endl << std::endl
		<< "STATS SUMMARY" << std::endl
		<< "=============" << std::endl;
	printStatsSummary(collector);
	reader->close();
	delete reader;
}
void analyzeHttpFromPcapFile ( std :: string pcapFileName , uint16_t dstPort ) { pcpp :: IFileReaderDevice * reader = pcpp :: IFileReaderDevice :: getReader ( pcapFileName ) ; if ( ! reader -> open ( ) ) EXIT_WITH_ERROR ( " " ) ; pcpp :: PortFilter httpPortFilter ( dstPort , pcpp :: SRC_OR_DST ) ; if ( ! reader -> setFilter ( httpPortFilter ) ) EXIT_WITH_ERROR ( " " ) ; HttpStatsCollector collector ( dstPort ) ; pcpp :: RawPacket rawPacket ; while ( reader -> getNextPacket ( rawPacket ) ) { pcpp :: Packet parsedPacket ( & rawPacket ) ; collector . collectStats ( & parsedPacket ) ; } std :: cout << std :: endl << std :: endl << " " << std :: endl << " " << std :: endl ; printStatsSummary ( collector ) ; reader -> close ( ) ; delete reader ; }
activate HTTP analysis from pcap file
activate HTTP analysis from pcap file
// open input file (pcap or pcapng file)
 // set a port  filter on the reader device to process only HTTP packets
 // read the input file packet by packet and give it to the HttpStatsCollector for collecting stats
 // print stats summary
 // close input file
 // free reader memory
