Commit e9f3d3a9 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Merge branch 'devel' into 'main'

Update master branch

See merge request !3
parents 57565dc1 ed00235c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Copyright 2022 ETSI
Copyright 2019-2024 ETSI

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
+53 −1
Original line number Diff line number Diff line
# TITAN Test System Framework

## Introduction

This module provides the bases to start the development of any Conformance Testing project or Interoperability Testing project.
It contains:
- A set C/C++ modules such as logging, codec support,
- A set of TTCN-3 modules such as LibHttp
- A set of TTCN-3 modules such as LibHelper or LibHttp

## How to use it

### The layers

The purpose of a lower test adapter is to prepare and adapt the protocol messages used by TTCN-3 test suites so that they can be transmitted successfully to the SUT.
The lower layers implement and encapsulate protocol messages accordingly. For instance, TCP need to be encapsulated into IP layer and ETHERNET layer.
Each Layer is responsible for encapsulating and decapsulating packets and transmitting result to lower using send_data()/receive_data() methods

#### Final layers

The final layer is where the physical communication is done. PCAP is an example a the final layer: this layer read and write data to the network interface controller (NIC).
Some final layer such as PCAP, PCAP_OFFLINE, SCTP are provided by this framework to facilitate the development of the Test Adapter.

#### Layers

Some layers such as ETHERNET, IP, TCP or UDP are provided by this framework to facilitate the development of the Test Adapter.

### The C++ libraries

This framework provides some C++ and TTCN-3 libraries such as layer parameters processor (class params), base time (class base_time), basic data convertions (class converter).
These classes can be derived to enhance and add new functionalities.

### The external functions

This framework provides some useful TTCN-3 external function such as time access (e.g. fx__getCurrentTimeUtc) or base 64 encoding/decoding.

### The logger class

This class provides a logging framework with log levels and some special features such as hexadecimal dump of TITAN data structure logging (e.g. RECORD...).

### The TTCN-3 libraries

This framework provides some TTCN-3 libraries such as LibXSD, libHTTP or LibJson.
These libraries provides the typing and the templates to manipulate these protocols.
They can be used and extend to enhance and add new typings and functionalities.

### The LibSecurity

This libraries provides the minimal set of functionalities such SHA and HMAC computing, Signature and Certificates manipulations.

## How to add it in your project

When you create your project, you just need to add it as a GIT submodule:

```bash
$ git submodule add --branch devel https://labs.etsi.org/rep/cti-tools/titan-test-system-framework.git ./titan-test-system-framework
$ git submodule init
$ git submodule update
$ git add .
$ git commit -a -m "Added submodule titan-test-system-framework"
$ git push
```
+10 −2
Original line number Diff line number Diff line
@@ -380,14 +380,22 @@ public:
   * \param[in] p_value The buffer value
   * \return The Base64 encoded buffert
   */
  std::vector<unsigned char> buffer_to_base64(const std::vector<unsigned char> &p_value, const bool p_is_url = false);
  std::vector<uint8_t> buffer_to_base64(const std::vector<uint8_t> &p_value, const bool p_is_url = false);

  /*!
   * \brief Convert the provided Base64 buffer
   * \param[in] p_value The buffer value
   * \return The Base64 encoded buffert
   */
  std::vector<unsigned char> base64_to_buffer(const std::vector<unsigned char> &p_value, const bool p_remove_crlf = true);
  std::vector<uint8_t> base64_to_buffer(const std::vector<uint8_t> &p_value, const bool p_remove_crlf = true);

  /*!
   * \brief Split a string line by line
   * \param[in] p_input The buffer value
   * \return The lines list
   */
  std::vector<std::string> split_lines(const std::string& p_input);


  static const std::string lut_u;
  static const std::string lut_l;
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ public: //! \publicsection

  static const std::string& nic;          //! Network Interface Card parameter name

  static const std::string& ip_src;      //! Source IP address parameter name
  static const std::string& ip_dst;      //! Destination IP address parameter name
  static const std::string& ip_proto;    //! IP proto parameter name

  static const std::string& server;       //! Remote server address (e.g. www.etsi.org)
  static const std::string& port;         //! Remote server port. Default: 80
  static const std::string& use_ssl;      //! Set to 1 to use SSL to communicate with the HTTP server. Default: false
+25 −11
Original line number Diff line number Diff line
@@ -159,13 +159,13 @@ const std::string converter::base64_enc_map[2] = {
 * @param[in] chr 
 * @return Return the position of chr within base64_encode()
 */
static unsigned char pos_of_char(const unsigned char chr) {
static uint8_t pos_of_char(const uint8_t chr) {
  if ((chr >= 'A' && chr <= 'Z')) {
    return static_cast<unsigned char>(chr - 'A');
    return static_cast<uint8_t>(chr - 'A');
  } else if ((chr >= 'a' && chr <= 'z')) {
    return static_cast<unsigned char>(chr - 'a' + ('Z' - 'A') + 1);
    return static_cast<uint8_t>(chr - 'a' + ('Z' - 'A') + 1);
  } else if ((chr >= '0' && chr <= '9')) {
    return static_cast<unsigned char>(chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2);
    return static_cast<uint8_t>(chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2);
  } else if ((chr == '+' || chr == '-')) {
    return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters (
  } else if ((chr == '/' || chr == '_')) {
@@ -197,11 +197,11 @@ std::string converter::replace(const std::string& p_value, const std::string& p_
  return str; 
}

std::vector<unsigned char> converter::buffer_to_base64(const std::vector<unsigned char> &p_value, const bool p_is_url) {
std::vector<uint8_t> converter::buffer_to_base64(const std::vector<uint8_t> &p_value, const bool p_is_url) {
  const std::string& base64_enc_map_ = converter::base64_enc_map[(p_is_url) ? 1 : 0];
  const unsigned char trailing_char = (p_is_url) ? '.' : '=';
  const uint8_t trailing_char = (p_is_url) ? '.' : '=';

  std::vector<unsigned char> out;
  std::vector<uint8_t> out;
  //out.resize((p_value.size() + 2) / 3 * 4);

  unsigned int pos = 0;
@@ -229,19 +229,19 @@ std::vector<unsigned char> converter::buffer_to_base64(const std::vector<unsigne
  return out;
}

std::vector<unsigned char> converter::base64_to_buffer(const std::vector<unsigned char> &p_value, const bool p_remove_crlf) {
std::vector<uint8_t> converter::base64_to_buffer(const std::vector<uint8_t> &p_value, const bool p_remove_crlf) {

  if (p_value.size() == 0) {
    return std::vector<unsigned char>();
    return std::vector<uint8_t>();
  }

  std::vector<unsigned char> value(p_value);
  std::vector<uint8_t> value(p_value);
  if (p_remove_crlf) {
    value.erase(std::remove(value.begin(), value.end(), '\r'), value.end());
    value.erase(std::remove(value.begin(), value.end(), '\n'), value.end());
  }

  std::vector<unsigned char> out;
  std::vector<uint8_t> out;
  //out.resize(value.size() / 4 * 3);

  size_t pos = 0;
@@ -268,3 +268,17 @@ std::vector<unsigned char> converter::base64_to_buffer(const std::vector<unsigne

  return out;
}

#include <string>
#include <string_view>
#include <vector>

std::vector<std::string> converter::split_lines(const std::string& p_input) {
    std::vector<std::string> lines;
    std::istringstream stream(p_input);
    std::string line;
    while (std::getline(stream, line)) {
        lines.push_back(line);
    }
    return lines;
}
Loading