Newer
Older
#include "EthernetLayer.hh"
#include "loggers.hh"
EthernetLayer::EthernetLayer(const std::string & type, const std::string & param) : EthernetLayer() {
loggers::loggers::log(">>> EthernetLayer::EthernetLayer: %s, %s", type.c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
_params.log();
}
void EthernetLayer::sendData(const OCTETSTRING& data, const Params& params) {
loggers::loggers::log_msg(">>> EthernetLayer::sendData: ", data);
}
void EthernetLayer::receiveData(const OCTETSTRING& data, const Params& info) {
loggers::loggers::log_msg(">>> EthernetLayer::receiveData: ", data);
// Extract dest MAC Address
OCTETSTRING dst = data << 6;
loggers::loggers::log_msg("EthernetLayer::receiveData: dst: ", dst);
// Extract source MAC Address
OCTETSTRING src = data << 6;
loggers::loggers::log_msg("EthernetLayer::receiveData: src: ", src);
// Extract ethertype
OCTETSTRING type = data << 2;
loggers::loggers::log_msg("EthernetLayer::receiveData: type: ", type);
// Update params
loggers::loggers::log_msg("<<< EthernetLayer::receiveData: ", data);
}
class EthernetFactory: public LayerFactory {
static EthernetFactory _f;
public:
EthernetFactory();
virtual Layer * createLayer(const std::string & type,
const std::string & param);
};
EthernetFactory::EthernetFactory() {
// register factory
loggers::loggers::log(">>> EthernetFactory::EthernetFactory");
LayerStackBuilder::RegisterLayerFactory("ETH", this);
}
Layer * EthernetFactory::createLayer(const std::string & type, const std::string & param) {
return new EthernetLayer(type, param);
}
EthernetFactory EthernetFactory::_f;