Commit 26ee7675 authored by Yann Garcia's avatar Yann Garcia
Browse files

Big fixes and enhancements from CV2X#2 Plugtest

parent 118e09db
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
#include <unistd.h>

#include <Port.hh>

#include "loggers.hh"

#include "uppertester_debug_layer_factory.hh"

#include "uppertester_types.hh"

uppertester_debug_layer::uppertester_debug_layer(const std::string & p_type, const std::string & param) : layer(p_type), PORT(p_type.c_str()), _params() {
  loggers::get_instance().log(">>> uppertester_debug_layer::uppertester_debug_layer: %s, %s", to_string().c_str(), param.c_str());
  
  // Setup parameters
  params::convert(_params, param);
}

uppertester_debug_layer::~uppertester_debug_layer() {
  loggers::get_instance().log(">>> uppertester_debug_layer::~uppertester_debug_layer");
}

void uppertester_debug_layer::send_data(OCTETSTRING& p_data, params& p_params) {
  loggers::get_instance().log_msg(">>> uppertester_debug_layer::send_data: ", p_data);

  receive_data(p_data, p_params);
}

void uppertester_debug_layer::receive_data(OCTETSTRING& p_data, params& p_params) {
  loggers::get_instance().log_msg(">>> uppertester_debug_layer::receive_data: ", p_data);

  OCTETSTRING data;
  if (p_data[0].get_octet() == 0x00) {          // UtInitialize
    data = int2oct(257, 2); // '0101'O
  } else if (p_data[0].get_octet() == 0x02) {   // UtChangePosition
    data = int2oct(769, 2); // '0301'O
  } else if (p_data[0].get_octet() == 0x04) {   // UtChangePseudonym
    data = int2oct(1281, 2); // '0501'O
  } else if (p_data[0].get_octet() == 0x10) {   // UtDenmTrigger
    data = int2oct(4353, 2) + int2oct(1234, 2);   // '110104D2'O
  } else if (p_data[0].get_octet() == 0x12) {   // UtDenmUpdate
    data = int2oct(4609, 2) + int2oct(1234, 2);   // '110104D2'O
  } else if (p_data[0].get_octet() == 0x14) {   // UtDenmTermination
    // '15xxxx'O
  } else if ((p_data[0].get_octet() >= 0x30) && (p_data[0].get_octet() <= 0x3f)) {
                                                // UtCamTrigger
    data = int2oct(8449, 2);                      // '2101'O
  } else {
    data = int2oct(256, 2);                       // '0100'O
  }

  receive_to_all_layers(data, p_params);
}

uppertester_debug_layer_factory uppertester_debug_layer_factory::_f;
+61 −0
Original line number Diff line number Diff line
/*!
 * \file      uppertester_debug_layer.hh
 * \brief     Header file for ITS UPPERTESTER_DEBUG/IP protocol layer definition.
 * \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 <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "t_layer.hh"
#include "params.hh"

class PORT; //! Forward declaration of TITAN class

/*!
 * \class uppertester_debug_layer
 * \brief  This class provides description of ITS UPPERTESTER_DEBUG/IP protocol layer
 */
class uppertester_debug_layer : public layer, public PORT {
  params _params;            //! Layer parameters

public: //! \publicsection
  /*!
   * \brief Specialised constructor
   *        Create a new instance of the uppertester_debug_layer class
   * \param[in] p_type \todo
   * \param[in] p_param \todo
   */
  uppertester_debug_layer(const std::string & p_type, const std::string & p_param);
  /*!
   * \brief Default destructor
   */
  virtual ~uppertester_debug_layer();

  /*!
   * \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& p_data, params& p_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& p_data, params& p_params);

}; // End of class uppertester_debug_layer
+44 −0
Original line number Diff line number Diff line
/*!
 * \file      uppertester_debug_layer_factory.hh
 * \brief     Header file for ITS UpperTester Debug protocol layer factory.
 * \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.o
 * \version   0.1
 */
#pragma once

#include "layer_stack_builder.hh"

#include "uppertester_debug_layer.hh"

/*!
 * \class uppertester_debug_layer_factory
 * \brief  This class provides a factory class to create an uppertester_debug_layer class instance
 */
class uppertester_debug_layer_factory: public layer_factory {
  static uppertester_debug_layer_factory _f; //! Reference to the unique instance of this class
public: //! \publicsection
  /*!
   * \brief Default constructor
   *        Create a new instance of the uppertester_debug_layer_factory class
   * \remark The UPPERTESTER_DEBUG/IP layer identifier is UPPERTESTER_DEBUG
   */
  uppertester_debug_layer_factory() {
    // register factory
    layer_stack_builder::register_layer_factory("DEBUG", this);
  };
  /*!
   * \fn layer* create_layer(const std::string & type, const std::string & param);
   * \brief  Create the layers stack based on the provided layers stack description
   * \param[in] p_type The provided layers stack description
   * \param[in] p_params Optional parameters
   * \return 0 on success, -1 otherwise
   * \inline
   */
  inline virtual layer* create_layer(const std::string& p_type, const std::string& p_param) {
    return new uppertester_debug_layer(p_type, p_param);
  };
}; // End of class uppertester_debug_layer_factory
+157 −0
Original line number Diff line number Diff line

[MODULE_PARAMETERS]
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.

# IUT Station ID
LibItsCommon_Pixits.PX_IUT_STATION_ID := 2533729309

LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_btpB

LibItsCam_Pics.PICS_DANGEROUSGOODS := true
LibItsCam_Pics.PICS_IS_IUT_SECURED := true

[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).

LogFile := "../logs/%e.%h-%r.%s"
FileMask := LOG_ALL | USER | DEBUG | MATCHING
ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING
#FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP
#ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP
LogSourceInfo := Stack
LogEntityName:= Yes
LogEventTypes:= Yes
#TimeStampFormat := DateTime

[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
# CAM Layer
#   next_header     : btpA|btpB (overwrite BTP.type)
#   header_type     : tsb|gbc
#   header_sub_type : sh (single hop)
# DENM Layer
#   next_header     : btpA|btpB (overwrite BTP.type)
#   header_type     : tsb|gbc
# BTP Layer
#   type            : btpA|btpB
#   destination port: dst_port
#   source port     : src_port
#   device_mode     : Set to 1 if the layer shall encapsulate upper layer PDU
#   device_mode     : Set to 1 if the layer shall encapsulate upper layer PDU
# GN Layer
#   ll_address             : GeoNetworking address of the Test System
#   latitude               : Latitude of the Test System
#   longitude              : Longitude of the Test System
#   beaconing              : Set to 1 if GnLayer shall start beaconing
#   expiry                 : Beaconing timer expiry (ms)
#   device_mode            : Set to 1 if the layer shall encapsulate upper layer PDU
#   secured_mode           : Set to 1 if message exchanges shall be signed
#   encrypted_mode         : Set to 1 if message exchanges shall be encrypted
#                            NOTE: For signed & encrypted message exchanges, both secured_mode and encrypted_mode shall be set to 1
#   sec_db_path            : Path to the certificates and keys storage location
#   hash                   : Hash algorithm to be used when secured mode is set
#                            Authorized values are SHA-256 or SHA-384
#                            Default: SHA-256
#   signature              : Signature algorithm to be used when secured mode is set
#                            Authorized values are NISTP-256, NISTP-384, BP-256 and BP-384
#                            Default: NISTP-256
#   cypher                 : Cyphering algorithm to be used when secured mode is set
#                            Authorized values are NISTP-256, BP-256 and BP-384
#                            Default: NISTP-256
# Ethernet layer
#   mac_src  :Source MAC address
#   mac_bc   :Broadcast address
#   eth_type : Ethernet type
# Commsignia layer
#   mac_src     : IUT MAC address, used to discard packets
#                 To indicate no filering, use the value 000000000000
#   mac_bc      : Broadcast address
#   eth_type    : Ethernet type, used to discard packets
#   target_host : Device address
#   target_port : Device port
#   source_port : Test System port
#   interface_id: Interface id, used to discard packets
#   tx_power    : TX power (dB)
#   xport_mode  : G5 or LTE-V2X
# UDP layer (IP/UDP based on Pcap)
#   dst_ip  : Destination IPv4 address (aa.bb.cc.dd)
#   dst_port: Destination port
#   src_ip  : Source IPv4 address (aa.bb.cc.dd)
#   src_port: Source port
# Pcap layer
#   mac_src    : Source MAC address, used to exclude from capture the acket sent by the Test System
#   filter     : Pcap filter (compliant with tcpdump syntax) 
#   Online mode:
#     nic: Local NIC
#          If set, online mode is used
#   Offline mode (nic is present but not set):
#     file        : File to read
#     frame_offset: Frame offset, used to skip packets with frame number < frame_offset
#     time_offset : Time offset, used to skip packets with time offset < time_offset
#     save_mode   : Set to 1 to save sent packet, 0 otherwise

#system.camPort.params := "CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,distanceA=1500,distanceB=1500,angle=0,device_mode=1,secured_mode=1,sec_db_path=/home/yann/tmp/asn1c_cert)/ETH(mac_src=4e685195ff0a)/PCAP(mac_src=ce550426c7e4,nic=tap0,filter=and ether proto 0x8947)"
system.camPort.params := "CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,distanceA=1500,distanceB=1500,angle=0,device_mode=1,secured_mode=1,sec_db_path=/home/yann/tmp/asn1c_cert)/ETH(mac_src=f8cab8083918)/PCAP(mac_src=f8cab8083918,nic=eno1,filter=and ether proto 0x8947)"

# CAM UpperTester port based on UDP
#system.utPort.params := "UT_CAM/UDP(dst_ip=192.168.20.142,src_port=12345)"
system.utPort.params := "UT_CAM/DEBUG"

[EXECUTE]
ItsCam_TestCases.TC_CAM_MSD_FMT_BV_01
#ItsCam_TestCases.TC_CAM_MSD_FMT_BV_02
#ItsCam_TestCases.TC_CAM_MSD_FMT_BV_03
#ItsCam_TestCases.TC_CAM_MSD_FMT_BV_04
#ItsCam_TestCases.TC_CAM_MSD_FMT_BV_05
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_01
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_02
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_03
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_04
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_05
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_06
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_07
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_08
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_09
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_10
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_11
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_12
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_13
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_14
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_15
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_16
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_17
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_18
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_19
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_20
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_21
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_22
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_23
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_24
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_25
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_26
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_27
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_28
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_29
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_30
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_31
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_32
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_33
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_34
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_01_35
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_02
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_03
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_04
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_05
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_06
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_07
#ItsCam_TestCases.TC_CAM_MSD_INA_BV_08
#ItsCam_TestCases.TC_CAM_MSD_SSP_BO_02
#ItsCam_TestCases.TC_CAM_MSP_BV_01

[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
KillTimer := 10.0
LocalAddress := 127.0.0.1
TCPPort := 12000
NumHCs := 1
+0 −0

File moved.File mode changed from 100755 to 100644.

Loading