/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// $Date: 2010-06-04 19:11:07 +0200 (Fri, 04 Jun 2010) $
// $Rev: 3300 $
/******************************************************************************/

module UTRAN_CapabilityFunctions {

  import from UTRAN_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from UTRAN_ASN1_Templates all;
  import from UTRAN_Templates all;
  import from CommonDefs all;

  import from UTRAN_RAB_Templates all;
  import from UTRAN_RAB_TemplatesFDD all;
  import from UTRAN_RAB_TemplatesTDD all;

//----------------------------------------------------------------------
// Templates
//----------------------------------------------------------------------

  template (value) HandoverToUTRANCommand cs_HandoverToUTRANCommand_64kPS_FDD ( CipheringAlgorithm_r7          p_CiphAlg,
                                                                                UL_ScramblingCode              p_UL_ScramblingCode,
                                                                                PrimaryScramblingCode          p_PrimScramblingCode,
                                                                                template (value) FrequencyInfo p_FrequencyInfo ) :=
  /* Values according to 36.508 cl. 4.7B.1 Table 4.7B.1-1: HANDOVER TO UTRAN COMMAND using condition UTRA PS RB */
  {
    criticalExtensions := { //r3
      criticalExtensions := {//r4
        criticalExtensions := {//r5
          criticalExtensions := {//r6
            criticalExtensions := {//r7
              r8 := {
                handoverToUTRANCommand_r8 := {
                  new_U_RNTI := cs_URNTI_Short,
                  cipheringAlgorithm := p_CiphAlg,
                  supportForChangeOfUE_Capability := false,
                  new_H_RNTI := omit,
                  newPrimary_E_RNTI := omit,
                  newSecondary_E_RNTI := omit,
                  defaultConfigForCellFACH := omit,
                  specificationMode := {
                    complete := {
                      srb_InformationSetupList := {
                        //According to the RRC CONNECTION SETUP message (Transition to CELL_DCH or HS-PDSCH in CELL_FACH) using condition A1 in TS 34.108 clause 9.1.1
                        cs_SRB_InfoSetupUM_DCH_r8( tsc_UL_DCCH1, 1, 1, tsc_DL_DCCH1),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH2, 2, 2, tsc_DL_DCCH2),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH3, 3, 3, tsc_DL_DCCH3),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH4, 4, 4, tsc_DL_DCCH4)
                      },
                      rab_InformationSetupList := {
                        //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1
                        cs_RAB_InfoSetupDCH_PS_64k ( cs_RLC_InfoAM_Def )
                      },
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: UL Transport channel information common for all transport channels
                      ul_CommonTransChInfo := cs_UL_CommTrChInfoDCH_PS_64k_FDD,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Added or Reconfigured UL TrCH information
                      ul_AddReconfTransChInfoList := cs_UL_AddReconfTransChInfoListDCH_PS_64k,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: DL Transport channel information common for all transport channels
                      dl_CommonTransChInfo := cs_DL_CommonTransChInfoDCH_FDD ( cs_TFCS_Cmpl0_1_2_3_4_5_6_7_8_9_Rx ),
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Added or Reconfigured DL TrCH information
                      dl_AddReconfTransChInfoList := cs_DL_AddReconfTransChInfoListDCH_PS_64k,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Uplink DPCH info
                      ul_DPCH_Info := cs_UL_DPCH_Info_FDD( tsc_UL_DPDCH_SF_64k_PS, pl0_96, p_UL_ScramblingCode ),
                      ul_EDCH_Information := omit,
                      dl_HSPDSCH_Information := omit,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Downlink information common for all radio links
                      dl_CommonInformation := cs_DL_CommonInformationRB_SetUp_FDD ( tsc_DL_DPCH1_SFP_64k_PS, flexible ),
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Downlink information for each radio link list
                      dl_InformationPerRL_List := cs_DL_InformationPerRL_r7_FDD ( p_PrimScramblingCode,
                                                                              tsc_DL_DPCH1_ChC_64k_PS,
                                                                              tsc_DL_DPCH1_2ndScrC ),
                      frequencyInfo := p_FrequencyInfo,
                      multi_frequencyInfo := omit
                    }
                  },
                  maxAllowedUL_TX_Power := tsc_MaxAllowPwr
                },
                v7d0NonCriticalExtensions := omit                      /* @sic R5s100135 sic@ */
              }
            }
          }
        }
      }
    }
  };

  template (value) HandoverToUTRANCommand cs_HandoverToUTRANCommand_64kPS_TDD ( CipheringAlgorithm_r7            p_CiphAlg,
                                                                                CellParametersID                 p_CellParametersID,
                                                                                template (value) FrequencyInfo p_FrequencyInfo ) :=
  /* Value reference for TDD is FFS */
  {
    criticalExtensions := { //r3
      criticalExtensions := {//r4
        criticalExtensions := {//r5
          criticalExtensions := {//r6
            criticalExtensions := {//r7
              r8 := {
                handoverToUTRANCommand_r8 := {
                  new_U_RNTI := cs_URNTI_Short,
                  cipheringAlgorithm := p_CiphAlg,
                  supportForChangeOfUE_Capability := false,
                  new_H_RNTI := omit,
                  newPrimary_E_RNTI := omit,
                  newSecondary_E_RNTI := omit,
                  defaultConfigForCellFACH := omit,
                  specificationMode := {
                    complete := {
                      srb_InformationSetupList := {
                        cs_SRB_InfoSetupUM_DCH_r8( tsc_UL_DCCH1, 1, 1, tsc_DL_DCCH1),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH2, 2, 2, tsc_DL_DCCH2),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH3, 3, 3, tsc_DL_DCCH3),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH4, 4, 4, tsc_DL_DCCH4)
                      },
                      rab_InformationSetupList := {
                        cs_RAB_InfoSetupDCH_PS_64k ( cs_RLC_InfoAM_Def )
                      },
                      ul_CommonTransChInfo := cs_UL_CommTrChInfoDCH_PS_64k_TDD,
                      ul_AddReconfTransChInfoList := cs_UL_AddReconfTransChInfoListDCH_PS_64k,
                      dl_CommonTransChInfo := cs_DL_CommonTransChInfoSameAsUL_r4_TDD,
                      dl_AddReconfTransChInfoList := cs_DL_AddReconfTransChInfoListDCH_PS_64k,
                      ul_DPCH_Info := cs_UL_DPCH_64K_PS_TDD,
                      ul_EDCH_Information := omit,
                      dl_HSPDSCH_Information := omit,
                      dl_CommonInformation := cs_DL_CommonInfoDCH_initialise_TDD,
                      dl_InformationPerRL_List := cs_DL_InformationPerRL_r7_TDD ( p_CellParametersID, cs_DL_DPCH_InfoPerRL_r7_64K_PS_TDD ),
                      frequencyInfo := p_FrequencyInfo,
                      multi_frequencyInfo := omit
                    }
                  },
                  maxAllowedUL_TX_Power := tsc_MaxAllowPwr
                },
                v7d0NonCriticalExtensions := omit                      /* @sic R5s100135 sic@ */
              }
            }
          }
        }
      }
    }
  };

  template (value) HandoverToUTRANCommand cs_HandoverToUTRANCommand_HSDPA_FDD ( CipheringAlgorithm_r7          p_CiphAlg,
                                                                                UL_ScramblingCode              p_UL_ScramblingCode,
                                                                                PrimaryScramblingCode          p_PrimScramblingCode,
                                                                                template (value) FrequencyInfo p_FrequencyInfo ) :=
  /* Values according to 36.508 cl. 4.7B.1 Table 4.7B.1-1: HANDOVER TO UTRAN COMMAND using condition UTRA HSDPA RB */
  {
    criticalExtensions := { //r3
      criticalExtensions := {//r4
        criticalExtensions := {//r5
          criticalExtensions := {//r6
            criticalExtensions := {//r7
              r8 := {
                handoverToUTRANCommand_r8 := {
                  new_U_RNTI := cs_URNTI_Short,
                  cipheringAlgorithm := p_CiphAlg,
                  supportForChangeOfUE_Capability := false,
                  new_H_RNTI := '1010101010101010'B,
                  newPrimary_E_RNTI := omit,
                  newSecondary_E_RNTI := omit,
                  defaultConfigForCellFACH := omit,
                  specificationMode := {
                    complete := {
                      srb_InformationSetupList := {
                        //According to the RRC CONNECTION SETUP message (Transition to CELL_DCH or HS-PDSCH in CELL_FACH) using condition A1 in TS 34.108 clause 9.1.1
                        cs_SRB_InfoSetupUM_DCH_r8( tsc_UL_DCCH1, 1, 1, tsc_DL_DCCH1),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH2, 2, 2, tsc_DL_DCCH2),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH3, 3, 3, tsc_DL_DCCH3),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH4, 4, 4, tsc_DL_DCCH4)
                      },
                      rab_InformationSetupList := {
                        //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1
                        cs_RAB_InfoSetupDCH_PS_HSDPA ( cs_RLC_InfoAM_Def_HSDPA )//FFS - Check values
                      },
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: UL Transport channel information common for all transport channels
                      ul_CommonTransChInfo := cs_UL_CommTrChInfoDCH_PS_64k_FDD,//FFS - Check values
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: Added or Reconfigured UL TrCH information
                      ul_AddReconfTransChInfoList := cs_UL_AddReconfTransChInfoListDCH_PS_64k,//FFS - Checl values
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: DL Transport channel information common for all transport channels
                      dl_CommonTransChInfo := cs_DL_CommonTransChInfoDCH_FDD ( cs_TFCS_Cmpl0_1_Rx ),
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: Added or Reconfigured DL TrCH information
                      dl_AddReconfTransChInfoList := cs_DL_AddReconfTransChInfoList_2DCH_HS_PS_HSDPA_FDD,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: Uplink DPCH info
                      ul_DPCH_Info := cds_UL_DPCH_InfoACK_HSDPA_FDD ( tsc_UL_DPDCH_SF_64k_PS,
                                                                      pl0_96,
                                                                      p_UL_ScramblingCode ),
                      ul_EDCH_Information := omit,
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1
                      dl_HSPDSCH_Information := cs_DL_HSPDSCH_Information_FDD ( cs_HS_SCCH_Info_FDD,
                                                                                cs_Measurement_Feedback_Info ),//FFS - check values
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A10 in TS 34.108 clause 9.1.1: Downlink information common for all radio links
                      dl_CommonInformation := cs_DL_CommonInformationRB_SetUp_FDD ( tsc_DL_DPCH1_SFP_SRB_3_4k, flexible ),//ffs - check values
                      //According to the corresponding IE in the RADIO BEARER SETUP message using condition A3 in TS 34.108 clause 9.1.1: Downlink information for each radio link list
                      dl_InformationPerRL_List := cds_DL_InfoPerRL_HSDPA_r7_FDD ( p_PrimScramblingCode ,
                                                                                  tsc_Sfc256_C0,
                                                                                  tsc_DL_DPCH1_2ndScrC ),
                      frequencyInfo := p_FrequencyInfo,
                      multi_frequencyInfo := omit
                    }
                  },
                  maxAllowedUL_TX_Power := tsc_MaxAllowPwr
                },
                v7d0NonCriticalExtensions := omit                      /* @sic R5s100135 sic@ */
              }
            }
          }
        }
      }
    }
  };

  template (value) HandoverToUTRANCommand cs_HandoverToUTRANCommand_HSDPA_TDD ( CipheringAlgorithm_r7          p_CiphAlg,
                                                                                CellParametersID                 p_CellParametersID,
                                                                                template (value) FrequencyInfo p_FrequencyInfo ) :=
  {
    /* Value reference for TDD is FFS */
    criticalExtensions := { //r3
      criticalExtensions := {//r4
        criticalExtensions := {//r5
          criticalExtensions := {//r6
            criticalExtensions := {//r7
              r8 := {
                handoverToUTRANCommand_r8 := {
                  new_U_RNTI := cs_URNTI_Short,
                  cipheringAlgorithm := p_CiphAlg,
                  supportForChangeOfUE_Capability := false,
                  new_H_RNTI := '1010101010101010'B,
                  newPrimary_E_RNTI := omit,
                  newSecondary_E_RNTI := omit,
                  defaultConfigForCellFACH := omit,
                  specificationMode := {
                    complete := {
                      srb_InformationSetupList := {
                        cs_SRB_InfoSetupUM_DCH_r8( tsc_UL_DCCH1, 1, 1, tsc_DL_DCCH1),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH2, 2, 2, tsc_DL_DCCH2),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH3, 3, 3, tsc_DL_DCCH3),
                        cs_SRB_InfoSetupAM_DCH_r8( tsc_UL_DCCH4, 4, 4, tsc_DL_DCCH4)
                      },
                      rab_InformationSetupList := {
                        cs_RAB_InfoSetupDCH_PS_HSDPA ( cs_RLC_InfoAM_Def_HSDPA )//FFS - Check values
                      },
                      ul_CommonTransChInfo := cs_UL_CommTrChInfoDCH_PS_64k_TDD,//FFS - Check values
                      ul_AddReconfTransChInfoList := cs_UL_AddReconfTransChInfoListDCH_PS_64k,//FFS - Checl values
                      dl_CommonTransChInfo := cs_DL_CommonTransChInfoDCH_TDD ( cs_TFCS_Cmpl0_1_Rx ),
                      dl_AddReconfTransChInfoList := cs_DL_AddReconfTransChInfoList_2DCH_HS_PS_HSDPA_TDD,
                      ul_DPCH_Info := cs_UL_DPCH_64K_PS_TDD,//FFS - check values
                      ul_EDCH_Information := omit,
                      dl_HSPDSCH_Information := cs_DL_HSPDSCH_Information_TDD ( cs_HS_SCCH_Info_TDD,
                                                                                cs_HS_PDSCH_Midamble_Configuration_TDD128 ),//FFS - check values
                      dl_CommonInformation := cs_DL_CommonInfoDCH_initialise_TDD,
                      dl_InformationPerRL_List := cs_DL_InformationPerRL_r7_TDD ( p_CellParametersID, cs_DL_DPCH_InfoPerRL_SRB_TDD ),//ffs - check values
                      frequencyInfo := p_FrequencyInfo,
                      multi_frequencyInfo := omit
                    }
                  },
                  maxAllowedUL_TX_Power := tsc_MaxAllowPwr
                },
                v7d0NonCriticalExtensions := omit                      /* @sic R5s100135 sic@ */
              }
            }
          }
        }
      }
    }
  };

  template InterRATHandoverInfo cr_UeCapabilitiesRAT_Container_UTRAN :=
  { /* Values according to 36.523-1 Table 8.5.4.1.3.3-5: ueCapabilitiesRAT-Container-UTRAN */
    /* @status    APPROVED */
    predefinedConfigStatusList := {
      absent := NULL
    },
    uE_SecurityInformation := ?,
    ue_CapabilityContainer := {
      present_ := ?
    },
    v390NonCriticalExtensions := {
      present_ := {
        interRATHandoverInfo_v390ext := ?,
        v3a0NonCriticalExtensions := {
          interRATHandoverInfo_v3a0ext := ?,
          laterNonCriticalExtensions := {
            interRATHandoverInfo_v3d0ext := ?,
            interRATHandoverInfo_r3_add_ext := ?,
            v3g0NonCriticalExtensions := {
              interRATHandoverInfo_v3g0ext := ?,
              v4b0NonCriticalExtensions := {
                interRATHandoverInfo_v4b0ext := ?,
                v4d0NonCriticalExtensions := {
                  interRATHandoverInfo_v4d0ext := ?,
                  v590NonCriticalExtensions := {
                    interRATHandoverInfo_v590ext := ?,
                    v690NonCriticalExtensions := {
                      interRATHandoverInfo_v690ext := {
                        ue_SecurityInformation2 := {
                          start_PS := '00000000000000000000'B
                        },
                        ue_RadioAccessCapabilityComp := *,
                        ue_RadioAccessCapabilityComp2 := ?
                      },
                      v6b0NonCriticalExtensions := {
                        interRATHandoverInfo_v6b0ext := ?,
                        v6e0NonCriticalExtensions := {
                          interRATHandoverInfo_v6e0ext := ?,
                          v770NonCriticalExtensions := {
                            interRATHandoverInfo_v770ext := ?,
                            v790nonCriticalExtensions := {
                              interRATHandoverInfo_v790ext := ?,
                              v860NonCriticalExtensions := {
                                interRATHandoverInfo_v860ext := ?,
                                v880NonCriticalExtensions := {
                                  interRATHandoverInfo_v880ext := ?,                    /* @sic R5s100135 sic@ */
                                  nonCriticalExtensions := *
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };

//----------------------------------------------------------------------
// Functions
//----------------------------------------------------------------------

  // @desc To be called from the EUTRA PTC to encode the Handover to Utran command.
  // @param TBD
  // @return The encoded octetstring.
  function f_U_EncodeHandoverToUtran_64kPS_FDD ( UL_ScramblingCode     p_UL_ScramblingCode,
                                                 PrimaryScramblingCode p_PrimScramblingCode,
                                                 integer               p_UARFCN )
  return octetstring
  {
    var bitstring v_Bitstring;
    var octetstring v_Octetstring;

    v_Bitstring := encvalue ( ( cs_HandoverToUTRANCommand_64kPS_FDD ( uea2,//UEA0 or UEA1. The indicated algorithm must be one of the algorithms supported by the UE.
                                                                      p_UL_ScramblingCode,
                                                                      p_PrimScramblingCode,
                                                                      cs_FreqInfo_FDD ( p_UARFCN ) ) ) );
    // Make bitstring aligned with octetstring.
    // This is because bit2oct will add additional bits at the beginning (MSB) whereas in
    // this case it should be added at the end (LSB).
    // Take care of padding the bitstring to make it a multiple of 8.
    v_Octetstring := bit2oct ( f_OctetAlignedBitString ( v_Bitstring ) );

    return ( v_Octetstring );
  }

  function f_U_EncodeHandoverToUtran_64kPS_TDD ( CellParametersID      p_CellParametersID,
                                                 integer               p_UARFCN )
  return octetstring
  {
    var bitstring v_Bitstring;
    var octetstring v_Octetstring;

    v_Bitstring := encvalue ( ( cs_HandoverToUTRANCommand_64kPS_TDD ( uea2,//UEA0 or UEA1. The indicated algorithm must be one of the algorithms supported by the UE.
                                                                      p_CellParametersID,
                                                                      cs_FreqInfo_TDD ( p_UARFCN ) ) ) );
    // Make bitstring aligned with octetstring.
    // This is because bit2oct will add additional bits at the beginning (MSB) whereas in
    // this case it should be added at the end (LSB).
    // Take care of padding the bitstring to make it a multiple of 8.
    v_Octetstring := bit2oct ( f_OctetAlignedBitString ( v_Bitstring ) );

    return ( v_Octetstring );
  }

//----------------------------------------------------------------------------

  // @desc To be called from the EUTRA PTC to encode the Handover to Utran command.
  // @param TBD
  // @return The encoded octetstring.
  function f_U_EncodeHandoverToUtran_HSDPA_FDD ( UL_ScramblingCode     p_UL_ScramblingCode,
                                                 PrimaryScramblingCode p_PrimScramblingCode,
                                                 integer               p_UARFCN )
  return octetstring
  {
    var bitstring v_Bitstring;
    var octetstring v_Octetstring;

    v_Bitstring := encvalue ( ( cs_HandoverToUTRANCommand_HSDPA_FDD ( uea2,//FFS - UEA0 or UEA1. The indicated algorithm must be one of the algorithms supported by the UE. How to get this
                                                                      p_UL_ScramblingCode,
                                                                      p_PrimScramblingCode,
                                                                      cs_FreqInfo_FDD ( p_UARFCN ) ) ) );
    // Make bitstring aligned with octetstring.
    // This is because bit2oct will add additional bits at the beginning (MSB) whereas in
    // this case it should be added at the end (LSB).
    // Take care of padding the bitstring to make it a multiple of 8.
    v_Octetstring := bit2oct ( f_OctetAlignedBitString ( v_Bitstring ) );

    return ( v_Octetstring );
  }

  function f_U_EncodeHandoverToUtran_HSDPA_TDD ( CellParametersID p_CellParametersID,
                                                 integer          p_UARFCN )
  return octetstring
  {
    var bitstring v_Bitstring;
    var octetstring v_Octetstring;

    v_Bitstring := encvalue ( ( cs_HandoverToUTRANCommand_HSDPA_TDD ( uea2,//FFS - UEA0 or UEA1. The indicated algorithm must be one of the algorithms supported by the UE. How to get this
                                                                      p_CellParametersID,
                                                                      cs_FreqInfo_TDD ( p_UARFCN ) ) ) );
    // Make bitstring aligned with octetstring.
    // This is because bit2oct will add additional bits at the beginning (MSB) whereas in
    // this case it should be added at the end (LSB).
    // Take care of padding the bitstring to make it a multiple of 8.
    v_Octetstring := bit2oct ( f_OctetAlignedBitString ( v_Bitstring ) );

    return ( v_Octetstring );
  }

  //----------------------------------------------------------------------------

  /*
   * @desc      To be called from the EUTRA PTC to encode the Inter Rat Handover Info message
   * @param     p_Octetstring  ..  container which is to be decoded
   * @return    boolean        ..  indicates if match/check has been succesful
   * @status    APPROVED
   */
  function f_DecodeAndCheckInterRatHandoverInfo ( octetstring p_Octetstring ) return boolean
  { //36.331 cl. 6.3.6: The octet string contains the INTER RAT HANDOVER INFO message defined in TS 25.331
    var boolean v_MatchResult;
    var InterRATHandoverInfo v_Received_UeCapabilitiesRAT_Container_UTRAN;
    var bitstring v_Bitstring := oct2bit(p_Octetstring);
    var integer v_Result := decvalue(v_Bitstring, v_Received_UeCapabilitiesRAT_Container_UTRAN );

    if (v_Result != 0) {
      FatalError(__FILE__, __LINE__, "UE UTRAN Capability cannot be decoded");
    }

    //* @desc Match the received decoded template with the expected template
    v_MatchResult := match ( v_Received_UeCapabilitiesRAT_Container_UTRAN, cr_UeCapabilitiesRAT_Container_UTRAN );
    return v_MatchResult;
  }

  //----------------------------------------------------------------------------

  function f_UTRAN_ConvertIntegerToEUTRA_MeasurementBandwidth(integer p_EUTRA_DL_Bandwidth) return EUTRA_MeasurementBandwidth
  {
    var EUTRA_MeasurementBandwidth v_MeasurementBandwidth;   // defined in UTRAN_RRC_ASN1_Definitions

    select  (p_EUTRA_DL_Bandwidth)
    {
      case (6) {                                          //1.4MHz
        v_MeasurementBandwidth := mbw6;
      }
      case (15) {                                         //3MHz
        v_MeasurementBandwidth := mbw15;
      }
      case (25) {                                         //5MHz
        v_MeasurementBandwidth := mbw25;
      }
      case (50) {                                         //10MHz
        v_MeasurementBandwidth := mbw50;
      }
      case (75) {                                         //15MHz
        v_MeasurementBandwidth := mbw75;
      }
      case (100) {                                        //20MHz
        v_MeasurementBandwidth := mbw100;
      }
      case else {
        FatalError (__FILE__,__LINE__, "invalid value for ChannelBandwidth");
      }
    }
    return v_MeasurementBandwidth;
  };
}
