Commit 0ff22dff authored by garciay's avatar garciay
Browse files

STF538: Start validation

parent 54dd2aa9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@
class Params : public std::map<std::string, std::string> {
public: //! \publicsection
  // TODO Use static constexpr (see CommsigniaLayer.hh)
  static const std::string& debug;                 //! Set to 1 to enable the debug mode

  static const std::string& loopback;

  static const std::string& mac_src;               //! Source MAC address parameter name
  static const std::string& mac_dst;               //! Destination MAC address parameter name
  static const std::string& mac_bc;                //! Broadcast MAC address parameter name
@@ -69,6 +73,11 @@ public: //! \publicsection
  
  static const std::string& interface_id;          //! Commsignia antenna selector

  static const std::string& server;                //! HTTP server address (e.g. www.etsi.org)
  static const std::string& port;                  //! Commsignia HTTP server port. Default: 80
  static const std::string& use_ssl;               //! Set to 1 to use SSL to communicate with the HTTP server. Default: false


  /*!
   * \brief Default constructor
   *        Create a new instance of the Params class
+8 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@
#include "Params.hh"
#include "loggers.hh"

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

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

const std::string& Params::mac_src = std::string("mac_src");
const std::string& Params::mac_dst = std::string("mac_dst");
const std::string& Params::mac_bc = std::string("mac_bc");
@@ -62,6 +66,10 @@ const std::string& Params::header_sub_type = std::string("header_sub_type");

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

const std::string& Params::server = std::string("server");
const std::string& Params::port = std::string("port");
const std::string& Params::use_ssl = std::string("use_ssl");

void Params::convert(Params& p_param, const std::string p_parameters) {
  // Sanity checks
  if (p_parameters.length() == 0) {
+5 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ namespace LibItsGeoNetworking__TestSystem {
        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);
      }
+14 −4
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ void GeoNetworkingLayer::receiveData(OCTETSTRING& data, Params& params) {
  loggers::get_instance().log_msg(">>> GeoNetworkingLayer::receiveData: ", data);

  // Check security mode
  IEEE1609dot2::Ieee1609Dot2Data ieee_1609dot2_data;
  LibItsGeoNetworking__TypesAndValues::BasicHeader basic_header;
  decode_basic_header(data, basic_header);
  if ((int)basic_header.nextHeader() == 2) { // Verify and extract the GeoNetworking Secured Packet as specified in ETSI EN 302 636-4-1 V1.3.1 (2017-08) Clause 9.6.1 Composition of the Basic Header
@@ -195,7 +196,7 @@ void GeoNetworkingLayer::receiveData(OCTETSTRING& data, Params& params) {
      return;
    }
    ///////////////////
    if (security_services::get_instance().verify_and_extract_gn_payload(secured_data, _enable_security_checks, unsecured_gn_payload, params) != 0) {
    if (security_services::get_instance().verify_and_extract_gn_payload(secured_data, _enable_security_checks, ieee_1609dot2_data, unsecured_gn_payload, params) != 0) {
      loggers::get_instance().warning("GeoNetworkingLayer::receiveData: Security error");
      if (_enable_security_checks) {
        return;
@@ -211,6 +212,11 @@ void GeoNetworkingLayer::receiveData(OCTETSTRING& data, Params& params) {
  LibItsGeoNetworking__TestSystem::GeoNetworkingInd ind;
  _codec.decode(data, ind.msgIn(), &params);
  if (ind.msgIn().is_bound()) {
    // Update optional securedMsg field if required
    if (ieee_1609dot2_data.is_bound()) {
      ind.msgIn().gnPacket().securedMsg() = OPTIONAL<IEEE1609dot2::Ieee1609Dot2Data>(ieee_1609dot2_data);
    } // else, nothing to do
    // Update context
    const LibItsGeoNetworking__TypesAndValues::LongPosVector* sopv = nullptr;
    const LibItsGeoNetworking__TypesAndValues::GnNonSecuredPacket& p = ind.msgIn().gnPacket().packet();
    const LibItsGeoNetworking__TypesAndValues::HeaderTST& htst = p.commonHeader().headerTST();
@@ -480,12 +486,9 @@ void GeoNetworkingLayer::stop_pass_beaconing() {
  _pass_beacon_table.reset();
} // End of stop_pass_beaconing method


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

  loggers::get_instance().log("GeoNetworkingLayer::enable_secured_mode: GN Layer address = %p", this);

  loggers::get_instance().log("GeoNetworkingLayer::enable_secured_mode: _secured_mode = %x", _secured_mode);
  if (!_secured_mode) {
    loggers::get_instance().log("GeoNetworkingLayer::enable_secured_mode: Setup secured mode");
@@ -504,6 +507,13 @@ int GeoNetworkingLayer::enable_secured_mode(const std::string& p_certificate_id,
  return 0;
}

int GeoNetworkingLayer::disable_secured_mode() {
  loggers::get_instance().log(">>> GeoNetworkingLayer::disable_secured_mode");
  _secured_mode = false;
  _enable_security_checks = false;
  return 0;
}

const LongPosVector* GeoNetworkingLayer::get_lpv(const GN__Address& p_gn_address)
{
  loggers::get_instance().log_msg(">>> GeoNetworkingLayer::get_lpv", p_gn_address);
+2 −0
Original line number Diff line number Diff line
@@ -126,7 +126,9 @@ public:
  void stop_beaconing();
  void start_pass_beaconing(const LibItsGeoNetworking__TypesAndValues::BeaconHeader& p_beacon);
  void stop_pass_beaconing();
  
  int enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security = false);
  int disable_secured_mode();
  
private:
  void send_beacon();
Loading