Commit a7d6a25c authored by YannGarcia's avatar YannGarcia
Browse files

Finalyze support if titan-test-system-framework

parent c5f1a21c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
Copyright 2019 ETSI
Copyright 2019-2022 ETSI


Redistribution and use in source and binary forms, with or without 
Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
+1 −3
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ sources += \
           LibItsBtp_Encdec.cc  \
           LibItsBtp_Encdec.cc  \
           LibItsCam_Encdec.cc  \
           LibItsCam_Encdec.cc  \
           LibItsDenm_Encdec.cc  \
           LibItsDenm_Encdec.cc  \
           LibHttp_Encdec.cc \
           LibItsMapemSpatem_Encdec.cc \
           LibItsMapemSpatem_Encdec.cc \
           LibItsSremSsem_Encdec.cc \
           LibItsSremSsem_Encdec.cc \
           LibItsRtcmem_Encdec.cc \
           LibItsRtcmem_Encdec.cc \
@@ -54,6 +53,5 @@ ifeq (AtsPki, $(ATS))
sources += \
sources += \
           LibItsBtp_Encdec.cc \
           LibItsBtp_Encdec.cc \
           LibItsPki_Encdec.cc \
           LibItsPki_Encdec.cc \
           LibItsCam_Encdec.cc \
           LibItsCam_Encdec.cc
           LibHttp_Encdec.cc
endif
endif
+6 −2
Original line number Original line Diff line number Diff line
#include "HttpPort.hh"
#include "HttpPort.hh"
#include "http_layer_factory.hh"
#include "http_layer_factory.hh"
#include "http_layer.hh"
#include "http_codec_its.hh"
#include "loggers.hh"
#include "loggers.hh"


#include "LibHttp_TypesAndValues.hh"
#include "LibHttp_TypesAndValues.hh"
@@ -50,8 +52,10 @@ namespace LibHttp__TestSystem {
      if (static_cast<http_layer*>(_layer) == nullptr) {
      if (static_cast<http_layer*>(_layer) == nullptr) {
        loggers::get_instance().error("HttpPort::user_map: Invalid stack configuration: %s", it->second.c_str());
        loggers::get_instance().error("HttpPort::user_map: Invalid stack configuration: %s", it->second.c_str());
      }
      }
      if (!static_cast<http_layer*>(_layer)->set_codec(new http_codec_its())) {
        loggers::get_instance().error("HttpPort::user_map: Null codec");
      }
      static_cast<http_layer *>(_layer)->add_upper_port(this);
      static_cast<http_layer *>(_layer)->add_upper_port(this);

    } else {
    } else {
      loggers::get_instance().error("HttpPort::user_map: No layers defined in configuration file");
      loggers::get_instance().error("HttpPort::user_map: No layers defined in configuration file");
    }
    }
+80 −0
Original line number Original line Diff line number Diff line
#include "http_codec_its.hh"

#include "loggers.hh"

#include "http_etsi_ieee1609dot2_codec.hh"

bool http_codec_its::encode_body_binary(const LibHttp__BinaryMessageBodyTypes::BinaryBody &p_binary_body, OCTETSTRING &p_encoding_buffer, const std::string &p_content_type) {
  loggers::get_instance().log(">>> http_codec_its::encode_body_binary");

  std::map<std::string, std::unique_ptr<codec_gen<Record_Type, Record_Type>>>::const_iterator it;
  bool                                                                                    processed = false;
  if (p_content_type.find("x-its") != std::string::npos) {
    loggers::get_instance().log("http_codec_its::encode_body_binary: Find x-its");
    it = _codecs.find("http_its"); // TODO Use params
    if (it != _codecs.cend()) {
      loggers::get_instance().log("http_codec_its::encode_body_binary: Call '%s'", it->first.c_str());
      if (p_binary_body.ischosen(LibHttp__BinaryMessageBodyTypes::BinaryBody::ALT_ieee1609dot2__data)) {
        _codecs["http_its"]->encode((Record_Type &)p_binary_body.ieee1609dot2__data(), p_encoding_buffer); // TODO Use params
        processed = true;
      } else if (p_binary_body.ischosen(LibHttp__BinaryMessageBodyTypes::BinaryBody::ALT_ieee1609dot2__certificate)) {
        _codecs["http_its"]->encode((Record_Type &)p_binary_body.ieee1609dot2__certificate(), p_encoding_buffer); // TODO Use params
        processed = true;
      } else {
        loggers::get_instance().warning("http_codec_its::encode_body_binary: Unsupported variant");
      }
    }
  } // TODO Add new HTTP message codec here
  if (!processed) {
    loggers::get_instance().warning("http_codec_its::encode_body_binary: Unsupported HTTP codec, use raw field as default");
    p_encoding_buffer = OCTETSTRING(0, nullptr);
  }

  return true;
}

bool http_codec_its::decode_body_binary(const OCTETSTRING &p_data, LibHttp__BinaryMessageBodyTypes::BinaryBody &p_binary_body, const std::string &p_content_type, params* p_params) {
  loggers::get_instance().log(">>> http_codec_its::decode_body_binary");

  std::map<std::string, std::unique_ptr<codec_gen<Record_Type, Record_Type>>>::const_iterator it;
  bool                                                                                    processed = false;
  // TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">"
  if ((p_content_type.find("x-its") != std::string::npos) || (p_content_type.find("application/octet-stream") != std::string::npos)) {
    loggers::get_instance().log("http_codec_its::decode_body_binary: Find 'x-its'");
    it = _codecs.cbegin(); //_codecs.find("http_its");
    if (it != _codecs.cend()) {
      /***
          FIXME:
          This code generate a codedump, I don't undertsand the reason.
          The same code works file for Ng112 HELD & LOST codec. Ununderstandable!!!!
          ==> Use a patch
          if (_codecs["http_its"].get() != nullptr) {
          loggers::get_instance().log("http_codec_its::decode_body_binary: Call 'http_etsi_ieee1609dot2_codec'");
          if (_codecs["http_its"]->decode(p_data, (Record_Type&)binary_body) == 0) {
          processed = true;
          }
          }*/
      loggers::get_instance().log("http_codec_its::decode_body_binary: Call '%s'", it->first.c_str());
      http_etsi_ieee1609dot2_codec *codec = new http_etsi_ieee1609dot2_codec();
      if (p_data[0].get_octet() != 0x80) {
        if (codec->decode(p_data, p_binary_body.ieee1609dot2__data()) == 0) {
          processed                   = true;
        }
      } else {
        if (codec->decode(p_data, p_binary_body.ieee1609dot2__certificate()) == 0) {
           processed                   = true;
        }
      }
      delete codec;
    }
    if (!processed) {
      loggers::get_instance().warning("http_codec_its::decode_body_binary: Unsupported HTTP codec, use raw field as default");
      p_binary_body.raw()           = p_data;
    }
  } else {
    loggers::get_instance().warning("http_codec_its::decode_body_binary: Unsupported HTTP codec, use raw field as default");
    p_binary_body.raw()           = p_data;
  }

  return true;
}
+16 −0
Original line number Original line Diff line number Diff line
#pragma once

#include "http_codec.hh"

#include "LibHttp_MessageBodyTypes.hh"

class http_codec_its : public http_codec {

public:
  explicit http_codec_its() : http_codec() {};
  virtual ~http_codec_its(){};

protected: //! \protectedsection
  bool encode_body_binary(const LibHttp__BinaryMessageBodyTypes::BinaryBody &p_binary_body, OCTETSTRING &p_encoding_buffer, const std::string &p_content_type);
  bool decode_body_binary(const OCTETSTRING &p_data, LibHttp__BinaryMessageBodyTypes::BinaryBody &p_binary_body, const std::string &p_content_type, params* p_params);
};
 No newline at end of file
Loading