Commit 8129a062 authored by garciay's avatar garciay
Browse files

STF525: Test AtsCAM, AtsDENM is secured mode

parent e0f208f7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -52,8 +52,6 @@ public: //! \publicsection
  static const std::string& longitude;             //! Test system Longitude parameter name
  static const std::string& expiry;                //! Test system GeoNetworking Lifetime parameter name (in ms)
  
  static const std::string& station_id;            //! To indicate to the peer ITS_Container::stationID
  
  static const std::string& device_mode;           //! To indicate to the lower layer to act as a standalone device
  static const std::string& secured_mode;          //! To indicate to the lower layer to apply signature on message exchanges as defined in IEEE 1609.2 & ETSI TS 102 965
  static const std::string& encrypted_mode;        //! To indicate to the lower layer to apply encryption on message exchanges as defined in IEEE 1609.2 & ETSI TS 102 965
+0 −2
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@ const std::string& Params::longitude = std::string("longitude");
const std::string& Params::ll_address = std::string("ll_address");
const std::string& Params::expiry = std::string("expiry");

const std::string& Params::station_id = std::string("station_id");

const std::string& Params::device_mode = std::string("device_mode");
const std::string& Params::secured_mode = std::string("secured_mode");
const std::string& Params::encrypted_mode = std::string("encrypted_mode");
+88 −16
Original line number Diff line number Diff line
@@ -4,7 +4,9 @@

#include "ItsRSUsSimulator_TestSystem.hh"

ConfigRsuSimulatorLayer::ConfigRsuSimulatorLayer(const std::string & p_type, const std::string & param) : t_layer<ItsRSUsSimulator__TestSystem::ConfigRsuSimulatorPort>(p_type), _params(), _codec() {
#include "UpperTesterCamCodec.hh"

ConfigRsuSimulatorLayer::ConfigRsuSimulatorLayer(const std::string & p_type, const std::string & param) : t_layer<ItsRSUsSimulator__TestSystem::ConfigRsuSimulatorPort>(p_type), _params(), _codec(), _codec_cam() {
  loggers::get_instance().log(">>> ConfigRsuSimulatorLayer::ConfigRsuSimulatorLayer: %s, %s", to_string().c_str(), param.c_str());
  // Setup parameters
  Params::convert(_params, param);
@@ -23,6 +25,54 @@ void ConfigRsuSimulatorLayer::sendMsg(const ItsRSUsSimulator__TestSystem::CfInit
  send_data(data, _params);
}

void ConfigRsuSimulatorLayer::sendMsg(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par, Params& params) {
  loggers::get_instance().log_msg(">>> ConfigRsuSimulatorLayer::sendMsg: ", send_par);

  TTCN_Buffer encoding_buffer;
  if (send_par.ischosen(LibItsGeoNetworking__TypesAndValues::UtGnResults::ALT_utGnInitializeResult)) {
    encoding_buffer.put_c(0x01/*static_cast<const unsigned char>(UpperTesterGnCodec::c_utGnInitializeResult)*/);
    encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utGnInitializeResult()));
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::sendMsg: Unsupported UtGnResults variant");
    return;
  }

  OCTETSTRING os(encoding_buffer.get_len(), encoding_buffer.get_data());
  send_data(os, _params);
}

void ConfigRsuSimulatorLayer::sendMsg(const LibItsCam__TypesAndValues::UtCamResults& send_par, Params& params) {
  loggers::get_instance().log_msg(">>> ConfigRsuSimulatorLayer::sendMsg: ", send_par);

  TTCN_Buffer encoding_buffer;
  if (send_par.ischosen(LibItsCam__TypesAndValues::UtCamResults::ALT_utCamInitializeResult)) {
    encoding_buffer.put_c(0x01/*static_cast<const unsigned char>(UpperTesterCamCodec::c_utCamInitializeResult)*/);
    encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utCamInitializeResult()));
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::sendMsg: Unsupported UtCamResults variant");
    return;
  }

  OCTETSTRING os(encoding_buffer.get_len(), encoding_buffer.get_data());
  send_data(os, _params);
}

void ConfigRsuSimulatorLayer::sendMsg(const LibItsDenm__TypesAndValues::UtDenmResults& send_par, Params& params) {
  loggers::get_instance().log_msg(">>> ConfigRsuSimulatorLayer::sendMsg: ", send_par);

  TTCN_Buffer encoding_buffer;
  if (send_par.ischosen(LibItsDenm__TypesAndValues::UtDenmResults::ALT_utDenmInitializeResult)) {
    encoding_buffer.put_c(0x01/*static_cast<const unsigned char>(UpperTesterDenmCodec::c_utDenmInitializeResult)*/);
    encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utDenmInitializeResult()));
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::sendMsg: Unsupported UtDenmResults variant");
    return;
  }

  OCTETSTRING os(encoding_buffer.get_len(), encoding_buffer.get_data());
  send_data(os, _params);
}

void ConfigRsuSimulatorLayer::send_data(OCTETSTRING& data, Params& params) {
  loggers::get_instance().log_msg(">>> ConfigRsuSimulatorLayer::send_data: ", data);
  
@@ -33,23 +83,45 @@ void ConfigRsuSimulatorLayer::receive_data(OCTETSTRING& data, Params& params)
{
  loggers::get_instance().log_msg(">>> ConfigRsuSimulatorLayer::receive_data: ", data);

  // Sanity check
  if (*(static_cast<const unsigned char*>(data)+ 1) != 0x02) { // Check that received packet has CA message id - See ETSI TS 102 894
    // Not a ConfigRsuSimulator message, discard it
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::receive_data: Wrong message id: 0x%02x", *(static_cast<const unsigned char*>(data)+ 1));
    return;
  unsigned char id = *(static_cast<const unsigned char*>(data));
  if (id == 0x00) { // Receive an UtxxInitialise
    process_data(data, params);
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::receive_data: Unsupported tag %02x", id);
  }
  
  // Decode the payload
  BOOLEAN p;
  /*_codec.decode(data, p);
  if (!p.msgIn().is_bound()) {
    // Discard it
    return;
    }*/ // else, continue
}

int ConfigRsuSimulatorLayer::process_data(OCTETSTRING& data, Params& params) {
  loggers::get_instance().log("ConfigRsuSimulatorLayer::process_data");
  
  Params::const_iterator it = _params.find("ut");
  if (it == _params.cend()) {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_data: CF layer's ut parameter is missing");
    return -1;
  }

  // Pass it to the ports if amy
  if (_params[std::string("ut")].compare("gn") == 0) {
    OCTETSTRING hashedId(data.lengthof() - 1,  1 + static_cast<const unsigned char*>(data));
    LibItsGeoNetworking__TypesAndValues::UtGnInitialize p(hashedId);
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else if (_params[std::string("ut")].compare("cam") == 0) {
    OCTETSTRING hashedId(data.lengthof() - 1,  1 + static_cast<const unsigned char*>(data));
    LibItsCam__TypesAndValues::UtCamInitialize p(hashedId);
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else if (_params[std::string("ut")].compare("denm") == 0) {
    OCTETSTRING hashedId(data.lengthof() - 1,  1 + static_cast<const unsigned char*>(data));
    LibItsDenm__TypesAndValues::UtDenmInitialize p(hashedId);
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_data: Unsupported protocol");
    return -1;
  }

  return 0;
}

ConfigRsuSimulatorLayerFactory ConfigRsuSimulatorLayerFactory::_f;
+16 −4
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@

#include "t_layer.hh"
#include "ConfigRsuSimulatorCodec.hh"
#include "UpperTesterGnCodec.hh"
#include "UpperTesterCamCodec.hh"
#include "UpperTesterDenmCodec.hh"

namespace ItsRSUsSimulator__TestSystem {
  class ConfigRsuSimulatorPort;
@@ -21,13 +24,22 @@ namespace ItsRSUsSimulator__TestSystem {
class ConfigRsuSimulatorLayer : public t_layer<ItsRSUsSimulator__TestSystem::ConfigRsuSimulatorPort> {
  Params _params;
  ConfigRsuSimulatorCodec _codec;
  UpperTesterCamCodec _codec_cam; // FIXME Enhance all codec to encode inputs messages also

public:
  ConfigRsuSimulatorLayer() : t_layer<ItsRSUsSimulator__TestSystem::ConfigRsuSimulatorPort>(), _params(), _codec() {};
  ConfigRsuSimulatorLayer() : t_layer<ItsRSUsSimulator__TestSystem::ConfigRsuSimulatorPort>(), _params(), _codec(), _codec_cam() {};
  ConfigRsuSimulatorLayer(const std::string& p_type, const std::string& param);
  virtual ~ConfigRsuSimulatorLayer() {};

  void sendMsg(const ItsRSUsSimulator__TestSystem::CfInitialize&, Params& params);
  void sendMsg(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par, Params& params);
  void sendMsg(const LibItsCam__TypesAndValues::UtCamResults& send_par, Params& params);
  void sendMsg(const LibItsDenm__TypesAndValues::UtDenmResults& send_par, Params& params);
  
  virtual void send_data(OCTETSTRING& data, Params& params);
  virtual void receive_data(OCTETSTRING& data, Params& info);
}; // End of class cam_layer
  virtual void receive_data(OCTETSTRING& data, Params& params);

private:
  int process_data(OCTETSTRING& data, Params& params);

}; // End of class ConfigRsuSimulatorLayer
+43 −1
Original line number Diff line number Diff line
@@ -109,6 +109,28 @@ namespace ItsRSUsSimulator__TestSystem {
  {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
    // float duration;
    // loggers::get_instance().set_start_time(_time_key);
    // static_cast<ConfigRsuSimulatorLayer *>(_layer)->sendMsg(send_par, _layer_params);
    // loggers::get_instance().set_stop_time(_time_key, duration);
  }

  void ConfigRsuSimulatorPort::outgoing_send(const LibItsCam__TypesAndValues::UtCamResults& send_par) {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<ConfigRsuSimulatorLayer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

  void ConfigRsuSimulatorPort::outgoing_send(const LibItsDenm__TypesAndValues::UtDenmResults& send_par) {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<ConfigRsuSimulatorLayer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

  void ConfigRsuSimulatorPort::receiveMsg (const BOOLEAN& p_ind, const Params& p_params) {
@@ -131,5 +153,25 @@ namespace ItsRSUsSimulator__TestSystem {
    incoming_message(p_ind);
  }
  
  void ConfigRsuSimulatorPort::receiveMsg (const LibItsCam__TypesAndValues::UtCamInitialize& p_ind, const Params& p_params) {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
    // Sanity check
    if (!p_ind.is_bound()) {
      return;
    }

    incoming_message(p_ind);
  }
  
  void ConfigRsuSimulatorPort::receiveMsg (const LibItsDenm__TypesAndValues::UtDenmInitialize& p_ind, const Params& p_params) {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
    // Sanity check
    if (!p_ind.is_bound()) {
      return;
    }

    incoming_message(p_ind);
  }
  
} /* end of namespace */
Loading