Skip to content
BTPLayer.cc 1.03 KiB
Newer Older
#include "BTPLayer.hh"
#include "BTPTypes.hh"
filatov's avatar
filatov committed

void BTPLayer::sendMsg(const LibItsBtp__TypesAndValues::BtpPacket& p, const Params& params){
filatov's avatar
filatov committed
  OCTETSTRING data;
  _codec.encode(p, data);
  sendData(data, params);
filatov's avatar
filatov committed
}

void BTPLayer::sendData(const OCTETSTRING& data, const Params& params){
  sendToAllLayers(data, params);
}
filatov's avatar
filatov committed
void BTPLayer::receiveData(const OCTETSTRING& data, const Params& info)
{
  LibItsBtp__TypesAndValues::BtpPacket p;
  _codec.decode(data, p);

  toAllUpperPorts(p, info);

  if(p.payload().is_present()) {
    toAllUpperLayers(p.payload()().rawPayload(), info);
filatov's avatar
filatov committed
}

class BTPFactory : public LayerFactory {
  static BTPFactory _f;
public:
  BTPFactory();
  virtual Layer * createLayer(const std::string &  type, const std::string &  param);
};

BTPFactory::BTPFactory(){
filatov's avatar
filatov committed
  // register factory
	LayerStackBuilder::RegisterLayerFactory("BTP", this);
Layer * BTPFactory::createLayer(const std::string & type, const std::string & param){
filatov's avatar
filatov committed
  return new BTPLayer();
}

BTPFactory BTPFactory::_f;