1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Improved compile time using forward declarations and removing useless includes.

This commit is contained in:
Matias Fontanini
2012-09-05 11:59:46 -03:00
parent 2aa4e10b91
commit 3cb6603151
37 changed files with 267 additions and 238 deletions

View File

@@ -26,6 +26,7 @@
#include <pcap.h>
#include <string>
#include <memory>
#include <stdexcept>
#include "pdu.h"
#include "ethernetII.h"
@@ -138,14 +139,13 @@ namespace Tins {
template<class Functor>
void Tins::Sniffer::callback_handler(u_char *args, const struct pcap_pkthdr *header, const u_char *packet) {
try {
PDU *pdu = 0;
std::auto_ptr<PDU> pdu;
LoopData<Functor> *data = reinterpret_cast<LoopData<Functor>*>(args);
if(data->wired)
pdu = new Tins::EthernetII((const uint8_t*)packet, header->caplen);
pdu.reset(new Tins::EthernetII((const uint8_t*)packet, header->caplen));
else
pdu = new Tins::RadioTap((const uint8_t*)packet, header->caplen);
bool ret_val = data->c_handler(pdu);
delete pdu;
pdu.reset(new Tins::RadioTap((const uint8_t*)packet, header->caplen));
bool ret_val = data->c_handler(pdu.get());
if(!ret_val)
pcap_breakloop(data->handle);
}