Commit b07b4b34 authored by garciay's avatar garciay
Browse files

Review IVIM, MAPEM/SPATEM and SREM/SSEM

parent dfd0549e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ namespace LibItsCam__EncdecDeclarations {
  }

  /****************************************************
   * @desc    External function to decode a DenmReq type
   * @desc    External function to decode a CamReq type
   * @param   value to encode
   * @return  encoded value
   ****************************************************/
+267 −0
Original line number Diff line number Diff line
#include "LibItsIvim_EncdecDeclarations.hh"

#include "CAMCodec.hh"
#include "UpperTesterCamCodec.hh"
#include "loggers.hh"

namespace LibItsIvim__EncdecDeclarations {
  /****************************************************
   * @desc    External function to encode a IvimReq type
   * @param   value to encode
   * @return  encoded value
   ****************************************************/
  BITSTRING fx__enc__IvimReq(const LibItsIvim__TestSystem::IvimReq& p_camReq)
  {
    loggers::get_instance().log_msg(">>> fx__enc__IvimReq: ", p_camReq);
    
    IVIMCodec codec;
    OCTETSTRING os;
    if (codec.encode(p_camReq.msgOut(), os) == -1) {
      loggers::get_instance().warning("fx__enc__IvimReq: -1 result code was returned");
      return int2bit(0, 1);
    }
    
    return oct2bit(os);
  }

  /****************************************************
   * @desc    External function to decode a DenmReq type
   * @param   value to encode
   * @return  encoded value
   ****************************************************/
  INTEGER fx__dec__IvimReq(BITSTRING& b, LibItsIvim__TestSystem::IvimReq& p)
  {
    loggers::get_instance().log(">>> fx__dec__IvimReq");

    IVIMCodec codec;
    IVIM__PDU__Descriptions::IVIM cam;
    OCTETSTRING is = bit2oct(b);

    if (codec.decode(is, cam) == -1) {
      loggers::get_instance().warning("fx__dec__IvimReq: -1 result code was returned");
      return -1;
    }
    p.msgOut() = cam;
    
    return 0;
  }

  INTEGER fx__dec__IvimInd(BITSTRING& b, LibItsIvim__TestSystem::IvimInd& p_camInd)
  {
    loggers::get_instance().log(">>> fx__dec__IvimInd");
    
    IVIMCodec codec;
    IVIM__PDU__Descriptions::IVIM cam;
    OCTETSTRING is = bit2oct(b);

    // Calculate the size of the lower layers information
    int s = (
	     LibItsIvim__TestSystem::IvimInd_gnNextHeader_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_gnHeaderType_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_gnHeaderSubtype_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_gnLifetime_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_gnTrafficClass_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_btpDestinationPort_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_btpInfo_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_ssp_raw_.fieldlength +
	     LibItsIvim__TestSystem::IvimInd_its__aid_raw_.fieldlength
	     ) / 8;
    // Decode CA message
    if (codec.decode(OCTETSTRING(is.lengthof() - s, static_cast<const unsigned char *>(is)), cam) == -1) {
      loggers::get_instance().warning("fx__dec__IvimInd: -1 result code was returned");
      return -1;
    }
    p_camInd.msgIn() = cam;
    // Decode lower layer data
    TTCN_Buffer decoding_buffer(OCTETSTRING(s, static_cast<const unsigned char *>(is) + is.lengthof() - s));
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // gnNextHeader
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_gnNextHeader_raw_.fieldlength / 8)) {
      p_camInd.gnNextHeader().set_to_omit();
    } else {
      OCTETSTRING os;
      os.decode(LibItsIvim__TestSystem::IvimInd_gnNextHeader_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.gnNextHeader() = oct2int(os);
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: gnNextHeader=", p_camInd.gnNextHeader());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // gnHeaderType
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_gnHeaderType_raw_.fieldlength / 8)) {
      p_camInd.gnHeaderType().set_to_omit();
    } else {
      OCTETSTRING os;
      os.decode(LibItsIvim__TestSystem::IvimInd_gnHeaderType_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.gnHeaderType() = oct2int(os);
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: gnHeaderType=", p_camInd.gnHeaderType());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // gnHeaderSubtype
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_gnHeaderSubtype_raw_.fieldlength / 8)) {
      p_camInd.gnHeaderSubtype().set_to_omit();
    } else {
      OCTETSTRING os;
      os.decode(LibItsIvim__TestSystem::IvimInd_gnHeaderSubtype_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.gnHeaderSubtype() = oct2int(os);
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: gnHeaderSubtype=", p_camInd.gnHeaderSubtype());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // gnLifetime
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_gnLifetime_raw_.fieldlength / 8)) {
      p_camInd.gnLifetime().set_to_omit();
    } else {
      INTEGER i;
      i.decode(LibItsIvim__TestSystem::IvimInd_gnLifetime_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.gnLifetime() = i;
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: gnLifetime=", p_camInd.gnLifetime());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // gnTrafficClass
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_gnTrafficClass_raw_.fieldlength / 8)) {
      p_camInd.gnTrafficClass().set_to_omit();
    } else {
      OCTETSTRING os;
      os.decode(LibItsIvim__TestSystem::IvimInd_gnTrafficClass_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.gnTrafficClass() = oct2int(os);
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: gnTrafficClass=", p_camInd.gnTrafficClass());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // btpDestinationPort
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_btpDestinationPort_raw_.fieldlength / 8)) {
      p_camInd.btpDestinationPort().set_to_omit();
    } else {
      INTEGER i;
      i.decode(LibItsIvim__TestSystem::IvimInd_btpDestinationPort_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.btpDestinationPort() = i;
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: btpDestinationPort=", p_camInd.btpDestinationPort());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // btpInfo
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_btpInfo_raw_.fieldlength / 8)) {
      p_camInd.btpInfo().set_to_omit();
    } else {
      INTEGER i;
      i.decode(LibItsIvim__TestSystem::IvimInd_btpInfo_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.btpInfo() = i;
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: btpInfo=", p_camInd.btpInfo());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // ssp
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_ssp_raw_.fieldlength / 8)) {
      p_camInd.ssp().set_to_omit();
    } else {
      BITSTRING bs;
      bs.decode(LibItsIvim__TestSystem::IvimInd_ssp_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.ssp() = bs;
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: ssp=", p_camInd.ssp());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    // its__aid
    if (decoding_buffer.get_read_len() < static_cast<size_t>(LibItsIvim__TestSystem::IvimInd_its__aid_raw_.fieldlength / 8)) {
      p_camInd.its__aid().set_to_omit();
    } else {
      INTEGER i;
      i.decode(LibItsIvim__TestSystem::IvimInd_its__aid_descr_, decoding_buffer, TTCN_EncDec::CT_RAW);
      p_camInd.its__aid() = i;
    }
    loggers::get_instance().log_msg("fx__dec__IVIM: its_aid=", p_camInd.its__aid());
    loggers::get_instance().log_to_hexa("fx__dec__IVIM: ", decoding_buffer);
    
    return 0;
  }

  BITSTRING fx__enc__IVIM(const IVIM__PDU__Descriptions::IVIM& p_cam)
  {
    loggers::get_instance().log_msg(">>> fx__enc__IVIM: ", p_cam);
    
    IVIMCodec codec;
    OCTETSTRING os;
    codec.encode(p_cam, os);
    return oct2bit(os);
  }

  INTEGER fx__dec__IVIM(BITSTRING& b, IVIM__PDU__Descriptions::IVIM& p)
  {
    loggers::get_instance().log(">>> fx__dec__IVIM");
    IVIMCodec codec;
    OCTETSTRING is = bit2oct(b);

    if (codec.decode(OCTETSTRING(is.lengthof(), static_cast<const unsigned char *>(is)), p) == -1) {
      loggers::get_instance().warning("fx__dec__IVIM: -1 result code was returned");
      return -1;
    }
    
    return 0;
  }

  BITSTRING fx__enc__UtIvimInitialize (const LibItsIvim__TypesAndValues::UtIvimInitialize& p_utIvimInitialize)
  {
    loggers::get_instance().log_msg(">>> fx__enc__UtIvimInitialize: ", p_utIvimInitialize);
    
    UpperTesterIvimCodec codec;
    OCTETSTRING os;
    codec.encode(p_utIvimInitialize, os);
    return oct2bit(os);
  }

  BITSTRING fx__enc__UtIvimChangePosition (const LibItsIvim__TypesAndValues::UtIvimChangePosition& p_utIvimChangePosition)
  {
    loggers::get_instance().log_msg(">>> fx__enc__UtIvimChangePosition: ", p_utIvimChangePosition);
    
    UpperTesterIvimCodec codec;
    OCTETSTRING os;
    codec.encode(p_utIvimChangePosition, os);
    return oct2bit(os);
  }

  BITSTRING fx__enc__UtIvimTrigger (const LibItsIvim__TypesAndValues::UtIvimTrigger& p_utIvimTrigger)
  {
    loggers::get_instance().log_msg(">>> fx__enc__UtIvimTrigger: ", p_utIvimTrigger);
    
    UpperTesterIvimCodec codec;
    OCTETSTRING os;
    codec.encode(p_utIvimTrigger, os);
    return oct2bit(os);
  }

  /****************************************************
   * @desc    External function to decode a UtIvimResults type
   * @param   value to encode
   * @return  encoded value
   ****************************************************/
  INTEGER fx__dec__UtIvimResults(BITSTRING& b, LibItsIvim__TypesAndValues::UtIvimResults& p)
  {
    loggers::get_instance().log(">>> fx__dec__UtIvimResults");

    UpperTesterIvimCodec codec;
    OCTETSTRING is = bit2oct(b);
    std::unique_ptr<Base_Type> ptr = codec.decode(is);
    if (ptr == nullptr) {
      loggers::get_instance().warning("fx__dec__UtIvimResults: -1 result code was returned");
      return -1;
    }
    p = static_cast<LibItsIvim__TypesAndValues::UtIvimResults&>(*ptr);
    return 0;
  }

  /****************************************************
   * @desc    External function to decode a UtIvimEventInd type
   * @param   value to encode
   * @return  encoded value
   ****************************************************/
  INTEGER fx__dec__UtIvimEventInd(BITSTRING& b, LibItsIvim__TypesAndValues::UtIvimEventInd& p)
  {
    loggers::get_instance().log(">>> fx__dec__UtIvimEventInd");

    UpperTesterIvimCodec codec;
    OCTETSTRING is = bit2oct(b);
    std::unique_ptr<Base_Type> ptr = codec.decode(is);
    if (ptr == nullptr) {
      loggers::get_instance().warning("fx__dec__UtIvimEventInd: -1 result code was returned");
      return -1;
    }
    p = static_cast<LibItsIvim__TypesAndValues::UtIvimEventInd&>(*ptr);
    return 0;
  }

} //end namespace
+465 −0

File added.

Preview size limit exceeded, changes collapsed.

+465 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −18
Original line number Diff line number Diff line
#include "LibItsMapemSpatem_externals.hh"
#include <time.h>
#include <math.h>

namespace LibItsMapemSpatem__externals
{
/*FIXME RGY @desc sounds like a copy-paste, not as the real purpose of the function
         * @desc    External function to compute distance between two points
         * @param   p_rawData   Octetstring to analyse
         * @return  true or false according to the check
        fx_checkUperEncoding ( in RawData p_rawData ) return boolean;
*/
BOOLEAN fx__checkUperEncoding(const OCTETSTRING& p__rawData)
{
  return TRUE;
}

} //end namespace
Loading