Commit f4aa01bc authored by Denis Filatov's avatar Denis Filatov
Browse files

Merge branch 'STF525' of https://forge.etsi.org/gitlab/ITS/ITS into STF525

parents df975a0f 7c8f25e2
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
#include <TTCN3.hh>

#include "loggers.hh"
#include "registration.hh"

#include "cam_layer.hh"

//=============================================================================
namespace LibItsCam__TestSystem {

@@ -63,9 +70,36 @@ void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcGns

}

void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& /*send_par*/)
void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& send_par)
{

    loggers::get_instance().log_msg(">>> AdapterControlPort::outgoing_send: ", send_par);

    // Register this object for AdapterControlPort
    cam_layer* p = registration<cam_layer>::get_instance().get_item(std::string("CAM"));
    if (p != NULL) {
      loggers::get_instance().log("AdapterControlPort::outgoing_send: Got GN layer %p", p);
      LibItsCommon__TypesAndValues::AdapterControlResults response;
      response.acSecResponse() = BOOLEAN(true);
      if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acEnableSecurity)) {
        loggers::get_instance().log("AdapterControlPort::outgoing_send: Enable secured mode");
        std::string str(static_cast<const char*>(send_par.acEnableSecurity().certificateId()));
        if (p->enable_secured_mode(str, send_par.acEnableSecurity().enforceSecurity()) == -1) {
          response.acSecResponse() = BOOLEAN(false);
        }
      } else if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acDisableSecurity)) {
        loggers::get_instance().log("AdapterControlPort::outgoing_send: Disable secured mode");
        if (p->disable_secured_mode() == -1) {
          response.acSecResponse() = BOOLEAN(false);
        }
      } else {
        response.acSecResponse() = BOOLEAN(false);
      }
      // Send response
      loggers::get_instance().log_msg("AdapterControlPort::outgoing_send: Send response: ", response);
      incoming_message(response);
    } else {
      loggers::get_instance().error("AdapterControlPort::outgoing_send: %s not registered", "geoNetworkingPort");
    }
}

} /* end of namespace */
+36 −2
Original line number Diff line number Diff line
#include <TTCN3.hh>

#include "loggers.hh"
#include "registration.hh"

#include "denm_layer.hh"

//=============================================================================
namespace LibItsDenm__TestSystem {

@@ -63,8 +70,35 @@ void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcGns

}

void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& /*send_par*/)
{
void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& send_par)
{    loggers::get_instance().log_msg(">>> AdapterControlPort::outgoing_send: ", send_par);

    // Register this object for AdapterControlPort
    denm_layer* p = registration<denm_layer>::get_instance().get_item(std::string("DENM"));
    if (p != NULL) {
      loggers::get_instance().log("AdapterControlPort::outgoing_send: Got GN layer %p", p);
      LibItsCommon__TypesAndValues::AdapterControlResults response;
      response.acSecResponse() = BOOLEAN(true);
      if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acEnableSecurity)) {
        loggers::get_instance().log("AdapterControlPort::outgoing_send: Enable secured mode");
        std::string str(static_cast<const char*>(send_par.acEnableSecurity().certificateId()));
        if (p->enable_secured_mode(str, send_par.acEnableSecurity().enforceSecurity()) == -1) {
          response.acSecResponse() = BOOLEAN(false);
        }
      } else if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acDisableSecurity)) {
        loggers::get_instance().log("AdapterControlPort::outgoing_send: Disable secured mode");
        if (p->disable_secured_mode() == -1) {
          response.acSecResponse() = BOOLEAN(false);
        }
      } else {
        response.acSecResponse() = BOOLEAN(false);
      }
      // Send response
      loggers::get_instance().log_msg("AdapterControlPort::outgoing_send: Send response: ", response);
      incoming_message(response);
    } else {
      loggers::get_instance().error("AdapterControlPort::outgoing_send: %s not registered", "geoNetworkingPort");
    }

}

+18 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

#include "cam_layer_factory.hh"

#include "registration.hh"

#include "loggers.hh"

cam_layer::cam_layer(const std::string & p_type, const std::string & param) : t_layer<LibItsCam__TestSystem::CamPort>(p_type), _params(), _codec() {
@@ -10,6 +12,10 @@ cam_layer::cam_layer(const std::string & p_type, const std::string & param) : t_
  params::convert(_params, param);
  _params.insert(std::make_pair<std::string, std::string>("its_aid", "36")); // ETSI TS 102 965 V1.2.1 (2015-06)
  _params.insert(std::make_pair<std::string, std::string>("payload_type", "2")); // CA message id - See ETSI TS 102 894

  // Register this object for AdapterControlPort
  loggers::get_instance().log("cam_layer::cam_layer: Register %s/%p", p_type.c_str(), this);
  registration<cam_layer>::get_instance().add_item(p_type, this);
}

void cam_layer::sendMsg(const LibItsCam__TestSystem::CamReq& p, params& params){
@@ -120,4 +126,16 @@ void cam_layer::receive_data(OCTETSTRING& data, params& params)
  to_all_upper_ports(p, params);
}

int cam_layer::enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security) {
  loggers::get_instance().log(">>> cam_layer::enable_secured_mode: '%s' - %x", p_certificate_id.c_str(), p_enforce_security);

  return 0;
}

int cam_layer::disable_secured_mode() {
  loggers::get_instance().log(">>> cam_layer::disable_secured_mode");

  return 0;
}

cam_layer_factory cam_layer_factory::_f;
+5 −0
Original line number Diff line number Diff line
@@ -68,5 +68,10 @@ public: //! \publicsection
   * \param[in] p_params Some lower layers parameters values when data was received
   */
  virtual void receive_data(OCTETSTRING& data, params& info);

  int enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security);

  int disable_secured_mode();

}; // End of class cam_layer
+18 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

#include "denm_layer_factory.hh"

#include "registration.hh"

#include "loggers.hh"

denm_layer::denm_layer(const std::string & p_type, const std::string & param) : t_layer<LibItsDenm__TestSystem::DenmPort>(p_type), _params(), _codec() {
@@ -10,6 +12,10 @@ denm_layer::denm_layer(const std::string & p_type, const std::string & param) :
  params::convert(_params, param);
  _params.insert(std::make_pair<std::string, std::string>("its_aid", "37")); // ETSI TS 102 965 V1.2.1 (2015-06)
  _params.insert(std::make_pair<std::string, std::string>("payload_type", "1")); // DE message id - See ETSI TS 102 894

  // Register this object for AdapterControlPort
  loggers::get_instance().log("denm_layer::denm_layer: Register %s/%p", p_type.c_str(), this);
  registration<denm_layer>::get_instance().add_item(p_type, this);
}

void denm_layer::sendMsg(const LibItsDenm__TestSystem::DenmReq& p, params& params){
@@ -119,4 +125,16 @@ void denm_layer::receive_data(OCTETSTRING& data, params& params)
  to_all_upper_ports(p, params);
}

int denm_layer::enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security) {
  loggers::get_instance().log(">>> denm_layer::enable_secured_mode: '%s' - %x", p_certificate_id.c_str(), p_enforce_security);

  return 0;
}

int denm_layer::disable_secured_mode() {
  loggers::get_instance().log(">>> denm_layer::disable_secured_mode");

  return 0;
}

denm_layer_factory denm_layer_factory::_f;
Loading