Update master branch

Update master branch

Merge request reports

Loading
+10 −2
Changes for ccsrc/Framework/include/converter.hh: 10 added lines, 2 removed lines.
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
Changes for ccsrc/Framework/include/params.hh: 4 added lines, 0 removed lines.
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
Changes for ccsrc/Framework/src/converter.cc: 25 added lines, 11 removed lines.
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;
}
+4
Changes for ccsrc/Framework/src/params.cc: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ const std::string& params::filter = std::string("filter");

const std::string& params::nic          = std::string("nic");

const std::string& params::ip_src      = std::string("ip_src");
const std::string& params::ip_dst      = std::string("ip_dst");
const std::string& params::ip_proto    = std::string("ip_proto");

const std::string& params::server       = std::string("server");
const std::string& params::port         = std::string("port");
const std::string& params::use_ssl      = std::string("use_ssl");
+6 −6
Changes for ccsrc/Helpers/helpers_externals.cc: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@ namespace LibHelpers__Functions {
  OCTETSTRING fx__enc__base64(const OCTETSTRING& p_to_encode) {
    loggers::get_instance().log_msg(">>> fx__enc__base64: ", p_to_encode);

    const std::vector<unsigned char> to_encode(static_cast<const unsigned char*>(p_to_encode), static_cast<const unsigned char*>(p_to_encode) + p_to_encode.lengthof());
    std::vector<unsigned char> b64 = converter::get_instance().buffer_to_base64(to_encode);
    const std::vector<uint8_t> to_encode(static_cast<const uint8_t*>(p_to_encode), static_cast<const uint8_t*>(p_to_encode) + p_to_encode.lengthof());
    std::vector<uint8_t> b64 = converter::get_instance().buffer_to_base64(to_encode);
    OCTETSTRING os(b64.size(), b64.data());
    loggers::get_instance().log_msg("<<< fx__enc__base64: ", os);
    return os;
@@ -72,18 +72,18 @@ namespace LibHelpers__Functions {
  OCTETSTRING fx__dec__base64(const OCTETSTRING& p_to_decode) {
    loggers::get_instance().log_msg(">>> fx__dec__base64: ", p_to_decode);

    const std::vector<unsigned char> to_decode(static_cast<const unsigned char*>(p_to_decode), static_cast<const unsigned char*>(p_to_decode) + p_to_decode.lengthof());
    std::vector<unsigned char> b64 = converter::get_instance().base64_to_buffer(to_decode);
    const std::vector<uint8_t> to_decode(static_cast<const uint8_t*>(p_to_decode), static_cast<const uint8_t*>(p_to_decode) + p_to_decode.lengthof());
    std::vector<uint8_t> b64 = converter::get_instance().base64_to_buffer(to_decode);
    OCTETSTRING os(b64.size(), b64.data());
    loggers::get_instance().log_msg("<<< fx__dec__base64: ", os);
    return os;
  }

  static unsigned char random_char() {
  static uint8_t random_char() {
    std::random_device rd;
    std::mt19937 gen(rd()); 
    std::uniform_int_distribution<> dis(0, 255);
    return static_cast<unsigned char>(dis(gen));
    return static_cast<uint8_t>(dis(gen));
  }

  static std::string generate_hex(const unsigned int len) {
Loading
Loading