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

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

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);
  receiveToAllPorts(p, info);
  if(p.payload().is_present()){
    receiveToAllLayers(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()
{
  // register factory
  StackFactory::getInstance()->registerLayerFactory("BTP", this);
filatov's avatar
filatov committed
}

Layer * BTPFactory::createLayer(const std::string & type, const std::string & param)
{
  return new BTPLayer();
}

BTPFactory BTPFactory::_f;