Commit eed9a834 authored by YannGarcia's avatar YannGarcia
Browse files

Remove useless files

parent 7d953e64
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
#include "cam_pdu_codec.hh"
#include "AtsCam_TestSystem.hh"
#include "asn1/asn_application.h" // from asn1c
#include "loggers.hh"

extern "C" {
extern asn_TYPE_descriptor_t asn_DEF_CAM;
}

int cam_pdu_codec::encode(const CAM__PDU__Descriptions::CAM &p_cam, BITSTRING &p_data) {
  return _encode(CAM__PDU__Descriptions::CAM_descr_, asn_DEF_CAM, p_cam, p_data);
}

int cam_pdu_codec::decode(const BITSTRING &p_data, CAM__PDU__Descriptions::CAM &p_cam) {
  return _decode(CAM__PDU__Descriptions::CAM_descr_, asn_DEF_CAM, p_data, p_cam);
}
+0 −2
Original line number Diff line number Diff line
sources := cam_codec.cc cam_layer.cc cam_pdu_codec.cc
includes := .
 No newline at end of file
+0 −147
Original line number Diff line number Diff line
#include "cam_types.hh"

#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<AtsCam__TestSystem::CamPort>(p_type), _params(), _codec() {
  loggers::get_instance().log(">>> cam_layer::cam_layer: %s, %s", to_string().c_str(), param.c_str());
  // Setup parameters
  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__TypesAndValues::CamReq &p, params &params) {
  loggers::get_instance().log_msg(">>> cam_layer::sendMsg: ", p);

  // Encode CAM PDU
  OCTETSTRING data;
  if (_codec.encode(p.msgOut(), data) == -1) {
    loggers::get_instance().warning("cam_layer::sendMsg: Encoding failure");
    return;
  }

  send_data(data, _params);
}

void cam_layer::send_data(OCTETSTRING &data, params &params) {
  loggers::get_instance().log_msg(">>> cam_layer::send_data: ", data);

  send_to_all_layers(data, params);
}

void cam_layer::receive_data(OCTETSTRING &data, params &params) {
  loggers::get_instance().log_msg(">>> cam_layer::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 CAM message, discard it
    loggers::get_instance().warning("cam_layer::receive_data: Wrong message id: 0x%02x", *(static_cast<const unsigned char *>(data) + 1));
    return;
  }

  // Decode the payload
  LibItsCam__TypesAndValues::CamInd p;
  _codec.decode(data, p.msgIn());
  if (!p.msgIn().is_bound()) {
    // Discard it
    return;
  } // else, continue

  // Process lower layer data
  // recvTime
  params::const_iterator it = params.find(params::timestamp);
  if (it != params.cend()) {
    p.recvTime().set_long_long_val(std::stoll(it->second));
  } else {
    p.recvTime().set_to_omit();
  }
  // gnNextHeader
  it = params.find(params::gn_next_header);
  if (it != params.cend()) {
    p.gnNextHeader() = std::stoi(it->second);
  } else {
    p.gnNextHeader().set_to_omit();
  }
  // gnHeaderType
  it = params.find(params::gn_header_type);
  if (it != params.cend()) {
    p.gnHeaderType() = std::stoi(it->second);
  } else {
    p.gnHeaderType().set_to_omit();
  }
  // gnHeaderSubtype
  it = params.find(params::gn_header_sub_type);
  if (it != params.cend()) {
    p.gnHeaderSubtype() = std::stoi(it->second);
  } else {
    p.gnHeaderSubtype().set_to_omit();
  }
  // gnLifetime
  it = params.find(params::gn_lifetime);
  if (it != params.cend()) {
    p.gnLifetime() = std::stoi(it->second);
  } else {
    p.gnLifetime().set_to_omit();
  }
  // gnTrafficClass
  it = params.find(params::gn_traffic_class);
  if (it != params.cend()) {
    p.gnTrafficClass() = std::stoi(it->second);
  } else {
    p.gnTrafficClass().set_to_omit();
  }
  // btpDestinationPort
  it = params.find(params::btp_destination_port);
  if (it != params.cend()) {
    p.btpDestinationPort() = std::stoi(it->second);
  } else {
    p.btpDestinationPort().set_to_omit();
  }
  // btpInfo
  it = params.find(params::btp_info);
  if (it != params.cend()) {
    p.btpInfo() = std::stoi(it->second);
  } else {
    p.btpInfo().set_to_omit();
  }
  // ssp
  it = params.find(params::ssp);
  if (it != params.cend()) {
    loggers::get_instance().log("cam_layer::receive_data: ssp=%s", it->second.c_str());
    p.ssp() = oct2bit(str2oct(CHARSTRING(it->second.c_str())));
  } else {
    p.ssp().set_to_omit();
  }
  // its_aid
  it = params.find(params::its_aid);
  if (it != params.cend()) {
    p.its__aid() = std::stoi(it->second);
  } else {
    p.its__aid().set_to_omit();
  }

  // Pass it to the ports if any
  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;
+0 −79
Original line number Diff line number Diff line
/*!
 * \file      cam_layer.hh
 * \brief     Header file for ITS CAM protocol layer.
 * \author    ETSI STF525
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once

#include "cam_codec.hh"
#include "t_layer.hh"

namespace AtsCam__TestSystem {
  class CamPort; //! Forward declaration of TITAN class
} // namespace AtsCam__TestSystem

namespace LibItsCam__TypesAndValues {
  class CamReq;  //! Forward declaration of TITAN class
  class CamInd;  //! Forward declaration of TITAN class
} // namespace AtsCam__TestSystem

/*!
 * \class cam_layer
 * \brief  This class provides description of ITS CAM protocol layer
 */
class cam_layer : public t_layer<AtsCam__TestSystem::CamPort> {
  params    _params; //! Layer parameters
  cam_codec _codec;  //! CAM codec
public:              //! \publicsection
  /*!
   * \brief Default constructor
   *        Create a new instance of the cam_layer class
   */
  explicit cam_layer() : t_layer<AtsCam__TestSystem::CamPort>(), _params(), _codec(){};
  /*!
   * \brief Specialised constructor
   *        Create a new instance of the cam_layer class
   * \param[in] p_type \todo
   * \param[in] p_param \todo
   */
  cam_layer(const std::string &p_type, const std::string &param);
  /*!
   * \brief Default destructor
   */
  virtual ~cam_layer(){};

  /*!
   * \fn void sendMsg(const LibItsCam__TypesAndValues::CamReq& p_cam_req, params& p_params);
   * \brief Send CA message to the lower layers
   * \param[in] p_cam_req The CA message to be sent
   * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
   */
  void sendMsg(const LibItsCam__TypesAndValues::CamReq &p_cam_req, params &p_params);

  /*!
   * \virtual
   * \fn void send_data(OCTETSTRING& data, params& params);
   * \brief Send bytes formated data to the lower layers
   * \param[in] p_data The data to be sent
   * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
   */
  virtual void send_data(OCTETSTRING &data, params &params);
  /*!
   * \virtual
   * \fn void receive_data(OCTETSTRING& data, params& params);
   * \brief Receive bytes formated data from the lower layers
   * \param[in] p_data The bytes formated data received
   * \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
+0 −14
Original line number Diff line number Diff line
/*!
 * \file      cam_types.hh
 * \brief     Header file for TITAN CAM types.
 * \author    ETSI STF525
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once

using namespace std; // Required for isnan()
#include "LibItsCam_TypesAndValues.hh"
Loading