Commit e27923da authored by garciay's avatar garciay
Browse files

Validate AtsRSUSimulator for CAM & DENM

parent 9b1b6235
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
#include "LibItsSecurity_EncdecDeclarations.hh"

#include "EtsiTs103097Codec_Certificate.hh"
#include "EtsiTs103097Codec_ToBeSignedCertificate.hh"
#include "EtsiTs103097Codec_Data.hh"

#include "loggers.hh"
@@ -34,16 +35,32 @@ namespace LibItsSecurity__EncdecDeclarations {
    return 0;
  }
  
  BITSTRING fx__enc__ToBeSignedCertificate(const IEEE1609dot2::ToBeSignedCertificate& p) {
  BITSTRING fx__enc__ToBeSignedCertificate(const IEEE1609dot2::ToBeSignedCertificate& p_toBeSignedCertificate) {
    loggers::get_instance().log_msg(">>> fx__enc__ToBeSignedCertificate: ", p_toBeSignedCertificate);

    EtsiTs103097Codec_ToBeSignedCertificate codec;
    OCTETSTRING os;
    if (codec.encode(p_toBeSignedCertificate, os) == -1) {
      loggers::get_instance().warning("fx__enc__ToBeSignedCertificate: -1 result code was returned");
      return int2bit(0, 1);
    }
    
  BITSTRING fx__enc__Ieee1609Dot2Data(const IEEE1609dot2::Ieee1609Dot2Data& p) {
    loggers::get_instance().log_msg(">>> fx__enc__CertificateBase: ", p);
    return oct2bit(os);
  }
  
  BITSTRING fx__enc__Ieee1609Dot2Data(const IEEE1609dot2::Ieee1609Dot2Data& p__ieee1609Dot2Data) {
    loggers::get_instance().log_msg(">>> fx__enc__Ieee1609Dot2Data: ", p__ieee1609Dot2Data);

    EtsiTs103097Codec_Data codec;
    OCTETSTRING os;
    if (codec.encode(p__ieee1609Dot2Data, os) == -1) {
      loggers::get_instance().warning("fx__enc__Ieee1609Dot2Data: -1 result code was returned");
      return int2bit(0, 1);
    }
    
    return oct2bit(os);
  }
  
  INTEGER fx__dec__Ieee1609Dot2Data(BITSTRING& p__data, IEEE1609dot2::Ieee1609Dot2Data& p__ieee1609Dot2Data) {
    loggers::get_instance().log_msg(">>> fx__dec__Ieee1609Dot2Data: ", p__data);

@@ -61,24 +78,33 @@ namespace LibItsSecurity__EncdecDeclarations {
  BITSTRING fx__enc__SspCAM(const LibItsSecurity__TypesAndValues::SspCAM& p__ssp) {
    loggers::get_instance().log_msg(">>> fx__enc__SspCAM: ", p__ssp);

    return int2bit(0, 1);
    TTCN_Buffer encoding_buffer;
    p__ssp.encode(*p__ssp.get_descriptor(), encoding_buffer, TTCN_EncDec::CT_RAW);
    return oct2bit(OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()));
  }
  
  INTEGER fx__dec__SspCAM(BITSTRING& p__data, LibItsSecurity__TypesAndValues::SspCAM& p__ssp) {
    loggers::get_instance().log_msg(">>> fx__dec__SspCAM: ", p__data);

    return -1;
    TTCN_Buffer decoding_buffer(bit2oct(p__data));
    p__ssp.decode(*p__ssp.get_descriptor(), decoding_buffer, TTCN_EncDec::CT_RAW);
    return 0;
  }
  
  BITSTRING fx__enc__SspDENM(const LibItsSecurity__TypesAndValues::SspDENM& p__ssp) {
    loggers::get_instance().log_msg(">>> fx__enc__SspDENM: ", p__ssp);

    return int2bit(0, 1);
    TTCN_Buffer encoding_buffer;
    p__ssp.encode(*p__ssp.get_descriptor(), encoding_buffer, TTCN_EncDec::CT_RAW);
    return oct2bit(OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()));
  }
  
  INTEGER fx__dec__SspDENM(BITSTRING& p__data, LibItsSecurity__TypesAndValues::SspDENM& p__ssp) {
    loggers::get_instance().log_msg(">>> fx__dec__SspDENM: ", p__data);

    return -1;
    TTCN_Buffer decoding_buffer(bit2oct(p__data));
    p__ssp.decode(*p__ssp.get_descriptor(), decoding_buffer, TTCN_EncDec::CT_RAW);
    return 0;
  }
  
} //end namespace
+11 −0
Original line number Diff line number Diff line
#include "ItsRSUsSimulator_Functions.hh"

namespace ItsRSUsSimulator__Functions
{
  void fx__computePositionFromRotation(const INTEGER& p__refLatitude, const INTEGER& p__refLongitude, const INTEGER& p__cenLatitude, const INTEGER& p__cenLongitude, const INTEGER& p__rotation, INTEGER& p__latitude, INTEGER& p__longitude) {
    // TODO
    p__latitude = p__cenLatitude;
    p__longitude = p__cenLongitude;
  }

} // end of namespace
+88 −88
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public:
  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& packetize;             //! Packetize mode, to indicate to the lower layer to build packet
  static const std::string& device_mode;           //! To indicate to the lower layer to act as a standalone device
  static const std::string& distanceA;             //! Test system GeoNetworking DistanceA parameter name
  static const std::string& distanceB;             //! Test system GeoNetworking DistanceB parameter name
  static const std::string& angle;                 //! Test system GeoNetworking Angle parameter name
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ 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::packetize = std::string("packetize");
const std::string& Params::device_mode = std::string("device_mode");
const std::string& Params::distanceA = std::string("distanceA");
const std::string& Params::distanceB = std::string("distanceB");
const std::string& Params::angle = std::string("angle");
+97 −94
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

#include "loggers.hh"

BTPLayer::BTPLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsBtp__TestSystem::BtpPort>(p_type), _params(), _codec() {
BTPLayer::BTPLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsBtp__TestSystem::BtpPort>(p_type), _params(), _codec(), _device_mode{false} {
  loggers::get_instance().log(">>> BTPLayer::BTPLayer: %s, %s", to_string().c_str(), param.c_str());
  // Setup parameters
  Params::convert(_params, param);
@@ -22,6 +22,10 @@ BTPLayer::BTPLayer(const std::string & p_type, const std::string & param) : TLay
  if (it == _params.cend()) {
    _params[Params::btp_info] = std::to_string(0);
  }
  it = _params.find(Params::device_mode);
  if (it != _params.cend()) {
    _device_mode = (0 == str2int(CHARSTRING(it->second.c_str())));
  }
}

void BTPLayer::sendMsg(const LibItsBtp__TestSystem::BtpReq& p, Params& params){
@@ -36,10 +40,9 @@ void BTPLayer::sendMsg(const LibItsBtp__TestSystem::BtpReq& p, Params& params){

void BTPLayer::sendData(OCTETSTRING& data, Params& params) {
  loggers::get_instance().log_msg(">>> BTPLayer::sendData: ", data);
  params.log();
  params.log(); // TODO To be removed

  Params::const_iterator it = params.find(Params::packetize);
  if (it != params.cend()) {
  if (_device_mode) {
    LibItsBtp__TypesAndValues::BtpHeader header;
    if (_params[Params::btp_type].compare("btpA") == 0) {
      header.btpAHeader() = LibItsBtp__TypesAndValues::BtpAHeader(
Loading