PcapLayer.cc 1.34 KB
Newer Older
#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;