http_etsi_ieee1609dot2_codec.cc 1.57 KB
Newer Older
garciay's avatar
garciay committed
#include "EtsiTs103097Module.hh"

#include "http_etsi_ieee1609dot2_codec_factory.hh"

#include "LibItsHttp_MessageBodyTypes.hh"

#include "security_services.hh"

#include "loggers.hh"

int http_etsi_ieee1609dot2_codec::encode (const LibItsHttp__BinaryMessageBodyTypes::BinaryBody& p_binary_body, OCTETSTRING& p_data)
{
  loggers::get_instance().log_msg(">>> http_etsi_ieee1609dot2_codec::encode: ", p_binary_body);

garciay's avatar
garciay committed
  if (p_binary_body.ischosen(LibItsHttp__BinaryMessageBodyTypes::BinaryBody::ALT_ieee1609dot2__data)) {
    // Encode the Ieee1609Dot2Data
    if (_codec.encode(p_binary_body.ieee1609dot2__data(), p_data) == -1) {
garciay's avatar
garciay committed
      loggers::get_instance().warning("http_etsi_ieee1609dot2_codec::encode: Failed to encode InnerEcRequest");
      return -1;
    }

    loggers::get_instance().log_msg("<<< http_etsi_ieee1609dot2_codec::encode: ", p_data);
    return 0;
  }
garciay's avatar
garciay committed
  loggers::get_instance().warning("http_etsi_ieee1609dot2_codec::encode: No codec found");
  return -1;
}

int http_etsi_ieee1609dot2_codec::decode (const OCTETSTRING& p_data, LibItsHttp__BinaryMessageBodyTypes::BinaryBody& p_binary_body, params* p_params)
{
  loggers::get_instance().log_msg(">>> http_etsi_ieee1609dot2_codec::decode: ", p_data);

  /*if (p_binary_body.ischosen(LibItsHttp__BinaryMessageBodyTypes::BinaryBody::ALT_innerEcResponse)) {
    
    return codec.decode(p_data, p_binary_body.innerEcResponse(), p_data);
    }*/
  loggers::get_instance().warning("http_etsi_ieee1609dot2_codec::decode: No codec found");

  return -1;
}

http_etsi_ieee1609dot2_codec_factory http_etsi_ieee1609dot2_codec_factory::_f;