Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "PORT.hh"
#include "PcapLayer.hh"
#include "loggers.hh"
PcapLayer::PcapLayer(const std::string & type, const std::string & param) : PcapLayer() {
loggers::loggers::log(">>> PcapLayer::PcapLayer: %s, %s", type.c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
_params.log();
// char error_buffer[64];
// pcap_if_t devices = NULL;
//
// if (pcap_findalldevs(devices, error_buffer) == -1) {
// // Add throw exception
// }
//
// _pcap_h = pcap_get_selectable(_device);
Handler_Add_Fd_Read(_pcap_h);
}
void PcapLayer::sendData(const OCTETSTRING& data, const Params& params) {
loggers::loggers::log_msg(">>> PcapLayer::sendData: ", data);
}
void PcapLayer::receiveData(const OCTETSTRING& data, const Params& info) {
}
class PcapFactory: public LayerFactory {
static PcapFactory _f;
public:
PcapFactory();
virtual Layer * createLayer(const std::string & type,
const std::string & param);
};
PcapFactory::PcapFactory() {
// register factory
loggers::loggers::log(">>> PcapFactory::PcapFactory");
LayerStackBuilder::RegisterLayerFactory("PCAP", this);
}
Layer * PcapFactory::createLayer(const std::string & type, const std::string & param) {
return new PcapLayer(type, param);
}
PcapFactory PcapFactory::_f;