/******************************************************************************/
// @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-08-17 12:18:17 +0200 (Tue, 17 Aug 2010) $
// $Rev: 3673 $
/******************************************************************************/

module RRC_ConnReconfig {

//----------------------------------------------------------------------
// Import part
//----------------------------------------------------------------------

  import from CommonDefs all;
  import from EPS_NAS_Constants all;
  import from EPS_NAS_MsgContainers all;
  import from EPS_NAS_Templates all;
  import from EPS_NAS_TypeDefs all;
  import from EUTRA_ASP_SrbDefs all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_CellInfo all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_Component all;
  import from EUTRA_ConfigurationSteps all;
  import from EUTRA_DRB_Templates all;
  import from EUTRA_NASSteps all;
  import from EUTRA_Paging all;
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from EUTRA_RRC_Templates all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_SecurityFunctions all;
  import from EUTRA_SRB_Templates all;
  import from EUTRA_SecuritySteps all;

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

  group TC_8_2_1_1_Templates {
  
  template (value) SRB_COMMON_REQ cads_SRB1_RrcPdu_REQ_FollowOnTRUE( CellId_Type p_CellId,
                                                                     template (value) TimingInfo_Type p_TimingInfo,
                                                                     template (value) DL_DCCH_Message p_RrcPdu)
    modifies cas_SRB1_RrcPdu_REQ :=
  { /* to achieve that two RRC messages are sent in the same TTI, FollowOnFlag is set to true for the 1st RRC PDU */
    /* @status    APPROVED */
    Common := cs_ReqAspCommonPart_SRB( p_CellId, tsc_SRB1, p_TimingInfo, true) // FollowOnFlag := true
  };
  
  } //group TC_8_2_1_1_Templates
  
  group TC_8_2_1_7_templates {
  
  template (value) RadioResourceConfigDedicated cds_NON_DEFAULT_SRB2_1AM_DRB_Config(template (omit) CQI_ReportPeriodic p_CQI_ReportingPeriodic,
                                                                                    template (omit) SoundingRS_UL_ConfigDedicated p_SoundingRsUl_ConfigDedicated,
                                                                                    template (value) PhysicalConfigDedicated_AntennaInfo_Type p_AntennaInfo // @sic R5-100786 sic@
                                                                                    )
    modifies cs_SRB2_1AM_DRB_Config_Def := {
    srb_ToAddModList := {
      {   /* SRB2 */
        //srb_Identity := 2,
        rlc_Config := {
          explicitValue := cs_RLC_Config_NON_DEFAULT_SRB2
        }//,
        //logicalChannelConfig := {
        //  defaultValue := NULL
        //}
      }
    }
  };
  
  template (value) RLC_Config cs_RLC_Config_NON_DEFAULT_SRB2 := {
    am := {
      ul_AM_RLC := {
        t_PollRetransmit := ms100,
        pollPDU := p16,
        pollByte := kB500,
        maxRetxThreshold := t6
      },
      dl_AM_RLC := {
        t_Reordering := ms100,
        t_StatusProhibit := ms200
      }
    }
  };
  
  } //group TC_8_2_1_7_templates
  
  group TC_8_2_2_1_Templates {
  
  template (value) RadioResourceConfigDedicated cs_SRB1_SRB2_DRB1AM_DRB2AM_Config :=
  { /* @status    APPROVED */
    srb_ToAddModList := cs_508_SRB_ToAddModList_RECONFIG,
    drb_ToAddModList := cs_508_DRB_ToAddModList_RECONFIG,
    drb_ToReleaseList := omit,
    mac_MainConfig := {
      explicitValue := cs_MAC_MainConfiguration_RECONFIG // @sic R5-103802 sic@ DRX config removed
    },
    sps_Config := omit,
    physicalConfigDedicated := cds_PhysicalConfigDedicated_RECONFIG(omit, omit, cs_PhysicalConfigDedicated_AntennaInfo_Def)
  };
  
  template (value) PhysicalConfigDedicated cds_PhysicalConfigDedicated_RECONFIG(template (omit) CQI_ReportPeriodic p_CQI_ReportingPeriodic,
                                                                                template (omit) SoundingRS_UL_ConfigDedicated p_SoundingRsUl_ConfigDedicated,
                                                                                template (value) PhysicalConfigDedicated_AntennaInfo_Type p_AntennaInfo // @sic R5-100786 sic@
                                                                                )
    modifies cs_508_PhysicalConfigDedicated_Default_RBC :=
  { /* @status    APPROVED */
    pdsch_ConfigDedicated := cds_PDSCH_ConfigDedicated_RECONFIG,
    //pucch_ConfigDedicated := omit,
    //pusch_ConfigDedicated := omit,
    //uplinkPowerControlDedicated := omit,
    tpc_PDCCH_ConfigPUCCH := omit,
    tpc_PDCCH_ConfigPUSCH := omit,
    cqi_ReportConfig := omit,
    soundingRS_UL_ConfigDedicated := omit,
    //antennaInfo := { defaultValue := NULL },
    schedulingRequestConfig := omit
  };
  
  template (value) PDSCH_ConfigDedicated cds_PDSCH_ConfigDedicated_RECONFIG
  modifies cs_508_PDSCH_ConfigDedicated_Default :=
  { /* @status    APPROVED */
    p_a := dB1
  };
  
  template (value) MAC_MainConfig cs_MAC_MainConfiguration_RECONFIG := // @sic R5-103802 sic@ DRX config removed
  { /* @status    APPROVED */
    ul_SCH_Config := {
      maxHARQ_Tx := n5,
      periodicBSR_Timer := sf32,
      retxBSR_Timer := sf2560,
      ttiBundling := false
    },
    drx_Config := omit, // @sic R5-103802 sic@ DRX config removed
    timeAlignmentTimerDedicated := sf750,
    phr_Config := {
      setup := {
        periodicPHR_Timer := sf1000,
        prohibitPHR_Timer := sf500,
        dl_PathlossChange := dB3
      }
    }
  };
  
  } //group TC_8_2_2_1_Templates
  
  group TC_8_2_2_2_Templates {
  
  template (value) RadioResourceConfigDedicated cs_RadioResourceConfigDedicated_SRBRECONFIG :=
  { /* @status    APPROVED */
    srb_ToAddModList := cs_508_SRB_ToAddModList_RECONFIG,
    drb_ToAddModList := omit,
    drb_ToReleaseList := omit,
    mac_MainConfig := omit,
    sps_Config := omit,
    physicalConfigDedicated := omit
  };
  
  } //group TC_8_2_2_2_Templates
  
  
  //----------------------------------------------------------------------
  // Functions
  //----------------------------------------------------------------------
  
  function fl_EUTRA_GenericRbEst_Steps_1_to_7(CellId_Type p_CellId)
    runs on EUTRA_PTC {
  //Generic Radio Bearer Establishment (State 3) - Steps 1 - 7
    
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NAS_Ind;
    var NAS_KsiValue v_KsiValue;
    var EUTRA_SecurityParams_Type v_AuthParams := f_EUTRA_Security_Get();
    var GutiParameters_Type v_GutiParameters := f_EUTRA_CellInfo_GetGuti(p_CellId);
    //var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_Cell1);
    
    /* Step 2 */
    f_EUTRA_UE_Page(p_CellId,
                    cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_GutiParameters.MME_Code, v_GutiParameters.M_TMSI)));
    
    /* Step 3 - 5 */
    v_KsiValue := f_EUTRA_SecurityKSIasme_Get();
    v_NAS_Ind := f_EUTRA_RRC_ConnEst_DefWithNas(p_CellId,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_mt_Access,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(v_KsiValue)));
    
    /* Step 6 - 7 */
    v_AuthParams := f_EUTRA_Authentication_InitAS(v_AuthParams, v_NAS_Ind.SecurityProtection.NasCount);
    v_AuthParams := f_EUTRA_RRC_ActivateSecurity(p_CellId, v_AuthParams, v_NAS_Ind.SecurityProtection.NasCount);
    f_EUTRA_Security_Set(v_AuthParams);
    
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 8.2.1.1
   * @status    APPROVED
   */
  function f_TC_8_2_1_1_EUTRA() runs on EUTRA_PTC
  { /* RRC Connection Reconfiguration / Radio Bearer Establishment for transition from RRC_IDLE to RRC_CONNECTED: Success (Default bearer, early bearer establishment) */
    
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var EUTRA_SecurityParams_Type v_Auth_Params;
    var B3_Type v_KsiValue;
    var O4_Type v_NasCountUL;
    var SRB_COMMON_IND v_ReceivedAsp;
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info;
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo;
    
    f_EUTRA_Init(c1);
    
    //Get FDD or TDD mode from Cell-configuration
    v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info(eutra_Cell1);
    v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_Cell1);
    
    //Create and configure cell
    f_EUTRA_CellConfig_Def(eutra_Cell1);
    
    /* Preamble to enter UE in E-UTRA RRC_IDLE (state 2) */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    
    //Get security parameters
    v_Auth_Params := f_EUTRA_Security_Get();
    v_KsiValue := f_EUTRA_SecurityKSIasme_Get();
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1" siclog@
    //SS sends a Paging message to the UE on the appropriate paging block, and including the UE identity in one entry of the IE pagingRecordLists.
    f_EUTRA_UE_Page_Def(eutra_Cell1);
    
    //@siclog "Step 2" siclog@
    //UE transmits an RRCConnectionRequest message.
    SRB.receive(car_SRB0_RrcPdu_IND(eutra_Cell1,
                                    cr_RRCConnectionRequest(cr_EstablishmentCause_mt_Access)));
    
    //@siclog "Step 3" siclog@
    //SS transmit an RRCConnectionSetup message.
    f_EUTRA_RRC_ConnectionSetup_Def(eutra_Cell1,
                                    cs_TimingInfo_Now,
                                    v_RRC_TI);
    
    //@siclog "Step 4" siclog@
    //The UE transmits an RRCConnectionSetupComplete to confirm the successful completion of the connection establishment. (Note 1)
    SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_Cell1,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?),
                                       cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cr_508_SERVICE_REQUEST(v_KsiValue)))) -> value v_ReceivedAsp;
    v_NasCountUL := v_ReceivedAsp.Signalling.Nas[0].SecurityProtection.NasCount;
    
    //@siclog "Step 5" siclog@
    //SS transmits a SecurityModeCommand message to activate AS security.
    v_Auth_Params := f_EUTRA_Authentication_InitAS(v_Auth_Params,
                                                   v_NasCountUL);                  /* Calculate Kenb and KRRCenc, KRRCint, KUPenc */
    
    // Read PDCP SQN for all RBs and calcuate Ciphering Activation times
    v_Auth_Params.AS_Ciphering.ActTimeList := f_EUTRA_RRC_CipherActTime_Get(eutra_Cell1);
    
    f_EUTRA_SS_RRC_EnableIntegrityProtection(eutra_Cell1,
                                             v_Auth_Params.AS_Integrity);             /* SecurityModeCommand is integrity protected with the algorithm
                                                                                         being contained in the message; all sub-sequent RRC messages
                                                                                         are integrity protected in UL and DL (36.331 cl. 5.3.4.3)    */
    
    // DL ciphering is activated for SRB1=(DL)SQN+1 i.e. for RRCConnectionReconfiguration and for other RBs, not yet configured, immediately.
    // UL ciphering is activated for SRB1=(UL)SQN+1 i.e. for RRCConnectionReconfigurationComplete and for other RBs, not yet configured, immediately.
    f_EUTRA_SS_RRC_EnableCipheringULandDL(eutra_Cell1,
                                          v_Auth_Params.AS_Ciphering);
    
    SRB.send(cads_SRB1_RrcPdu_REQ_FollowOnTRUE(eutra_Cell1,
                                               cs_TimingInfo_Now,
                                               cs_508_SecurityModeCommand(v_RRC_TI,
                                                                          v_Auth_Params.AS_Integrity.Algorithm,
                                                                          v_Auth_Params.AS_Ciphering.Algorithm)));
    /* Send SecurityModeCommand on SRB1. Follow on flag is set to TRUE
       to ensure that UE receives RRCConnectionReconfiguration message
       before it sends SecurityModeComplete message.  */
    
    //@siclog "Step 6" siclog@
    //Using the same TTI as the SecurityModeCommand message in step 5, the SS transmits an RRCConnectionReconfiguration message to establish a data radio bearer.
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_Cell1,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_SRB2_1AM_DRB_Est(v_RRC_TI,
                                                                                  v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                  v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                  v_AntennaInfo)));


    //@siclog "Step 7" siclog@
    //Check: Does the UE transmit a SecurityModeComplete message?
    SRB.receive( car_SRB1_RrcPdu_IND(eutra_Cell1,
                                     cr_508_SecurityModeComplete(v_RRC_TI)));          /* SecurityModeComplete is not ciphered
                                                                                          acc. to 36.331 cl. 5.3.4.3 and 5.3.1.1 */
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.1.1 Step 7");
    
    //@siclog "Step 8" siclog@
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message to confirm the establishment of data radio bearer?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(v_RRC_TI)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.1.1 Step 8");
    
    //@siclog "Step 9" siclog@
    //Check: Does the test result of CALL generic procedure in TS 36.508 subclause 6.4.2.3 indicate that UE is in E-UTRA RRC_CONNECTED state?
    f_EUTRA_508Check_ConnectedState(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED); //@sic R5-103875 sic@
  }
  
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 8.2.1.3
   * @status    APPROVED
   */
  function f_TC_8_2_1_3_EUTRA() runs on EUTRA_PTC
  { /* RRC Connection Reconfiguration / Radio Bearer Establishment: Success (Dedicated bearer) */
    
    var ProcedureTransactionIdentifier v_EpsProcedureTransactionId := '00'O;
    var EPS_BearerIdentity v_DedicatedEpsBearerId := tsc_EpsDedicatedBearerId;
    var EPS_BearerIdentity v_LinkedEpsBearerId := tsc_EpsDefaultBearerId;
    
    f_EUTRA_Init(c1);
    
    //Create and configure cell
    f_EUTRA_CellConfig_DRB_Common(eutra_Cell1, 1, 0);
    
    /* Preamble to enter UE in state Generic RB Established (state 3) */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_Def(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1 - 2" siclog@
    //The SS transmits an RRCConnectionReconfiguration message to establish a data radio bearer.
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message?
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_Cell1,
                                        tsc_DRB2,
                                        v_DedicatedEpsBearerId,
                                        v_EpsProcedureTransactionId,
                                        cs_LinkedId(hex2bit( v_LinkedEpsBearerId)),
                                        cs_508_EPS_QoS_Dedicated_1, // According to Context#1 in TS 36.508
                                        cs_508_Tft_Dedicated_1); // According to Context#1 in TS 36.508
    
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.1.3 Step 2");
    
    //@siclog "Step 3" siclog@
    //The UE transmits an ULInformationTransfer message. This message includes an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message.
    SRB.receive(car_SRB2_NasPdu_IND(eutra_Cell1,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(v_DedicatedEpsBearerId))));
    
    //@siclog "Step 4" siclog@
    //Check: Does the test result of generic test procedure in TS 36.508 subclause 6.4.2.3 indicate that the UE is in E-UTRA RRC_CONNECTED state on Cell 1?
    f_EUTRA_508Check_ConnectedState(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED); //@sic R5-103875 sic@
  }
  
  function f_TC_8_2_1_7_EUTRA()
      runs on EUTRA_PTC {
    /* RRC Connection Reconfiguration / Radio Bearer Establishment: Success (SRB2) */
    
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info;
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo;
    
    f_EUTRA_Init(c1);

    //Get FDD or TDD mode from Cell-configuration
    v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info(eutra_Cell1);
    v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_Cell1);
    
    //Create and configure cell
    f_EUTRA_CellConfig_Def(eutra_Cell1);
    
    /* Preamble to enter UE in E-UTRA RRC_IDLE (state 2) */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1 - 7" siclog@
    //Generic Radio Bearer Establishment (State 3) step 1 to 7 in TS 36.508 subclause 4.5.3.3.
    fl_EUTRA_GenericRbEst_Steps_1_to_7(eutra_Cell1);
    
    //@siclog "Step 8" siclog@
    //The SS transmits an RRCConnectionReconfiguration message to establish SRB2.
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_Cell1,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_RadioResConfig(tsc_RRC_TI_Def,
                                                                                cds_NON_DEFAULT_SRB2_1AM_DRB_Config(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                    v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                    v_AntennaInfo))));
    
    //@siclog "Step 9" siclog@
    //Check: Does the UE transmits an RRCConnectionReconfigurationComplete message?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.1.7 Step 9");
    
    //@siclog "Step 10" siclog@
    //Check: Does the test result of CALL generic procedure in TS 36.508 subclause 6.4.2.3 indicates that UE is in E-UTRA RRC_CONNECTED state on Cell 1?
    f_EUTRA_508Check_ConnectedState(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED);
    
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 8.2.2.1
   * @status    APPROVED
   */
  function f_TC_8_2_2_1_EUTRA()
    runs on EUTRA_PTC
  { /* RRC Connection Reconfiguration / Radio Resource Reconfiguration: Success */
    
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    
    f_EUTRA_Init(c1);
    
    //Create and configure cell
    f_EUTRA_CellConfig_DRB_Common(eutra_Cell1, 1, 0);
    
    /* Preamble to enter UE in state Generic RB Established (state 3)
       Note! Also 1 AM DRB is established here compared to default state 3 */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_508_AM(eutra_Cell1); // @sic R5-100488: UM bearer changed to AM sic@
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1" siclog@
    //The SS transmits an RRCConnectionReconfiguration message containing a radioResourceConfigDedicated with SRBs, DRB, transport channel and physical channel reconfiguration.
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_Cell1,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_RadioResConfig(v_RRC_TI,
                                                                                cs_SRB1_SRB2_DRB1AM_DRB2AM_Config)));
    
    //@siclog "Step 2" siclog@
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(v_RRC_TI)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.2.1 Step 2");
    
    //@siclog "Step 3" siclog@
    //Check: Does the test result of generic test procedure in TS 36.508 subclause 6.4.2.3 indicate that the UE is in E-UTRA RRC_CONNECTED state on Cell 1?
    f_EUTRA_508Check_ConnectedState(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED); //@sic R5-103875 sic@
    
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 8.2.2.2
   * @status    APPROVED
   */
  function f_TC_8_2_2_2_EUTRA()
    runs on EUTRA_PTC
  { /* RRC Connection Reconfiguration / SRB/DRB Reconfiguration: Success */
    
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    
    f_EUTRA_Init(c1);
    
    //Create and configure cell
    f_EUTRA_CellConfig_DRB_Common(eutra_Cell1, 1, 0);
    
    /* Preamble to enter UE in state Generic RB Established (state 3)
       Note! Also 1 AM DRB is established here compared to default state 3 */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_508_AM(eutra_Cell1); // @sic R5-100489: UM bearer changed to AM sic@
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1" siclog@
    //The SS transmits an RRConnectionReconfiguration message containing a radioResourceConfigDedicated with SRB reconfiguration
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_Cell1,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_RadioResConfig(v_RRC_TI, cs_RadioResourceConfigDedicated_SRBRECONFIG)));
    
    //@siclog "Step 2" siclog@
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(v_RRC_TI)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.2.2 Step 2");
    
    //@siclog "Step 3" siclog@
    //SS transmits RRCConnectionReconfiguration message containing a radioResourceConfigDedicated with DRB reconfiguration.
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_Cell1,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_RadioResConfig(v_RRC_TI, cs_RadioResourceConfig_DRB_RECONFIG)));
    
    //@siclog "Step 4" siclog@
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(v_RRC_TI)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.2.2 Step 4");
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED); //@sic R5-103875 sic@
    
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 8.2.3.1
   * @status    APPROVED
   */
  function f_TC_8_2_3_1_EUTRA()
    runs on EUTRA_PTC
  { /* RRC Connection Reconfiguration / Radio Bearer Release: Success */
    
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var EPS_BearerIdentity v_DedicatedEpsBearerId := tsc_EpsDedicatedBearerId;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var template(value) NAS_MSG_Request_Type v_NAS_MSG_Request;
    var template (value) ESM_Cause v_EsmCause36 := cs_ESM_Cause_v ('00100100'B); // "Regular deactivation"  // @sic R5-100492: ESM_Cause sic@
    
    f_EUTRA_Init(c1);
    
    v_NAS_MSG_Request := cs_NAS_Request( tsc_SHT_IntegrityProtected_Ciphered,
                                         cs_508_DeactivateEPSBearerCxtReq( v_DedicatedEpsBearerId,
                                                                           v_EPS_TI,
                                                                           v_EsmCause36)); //@sic R5-100492: ESM_Cause sic@
    
    //Create and configure cell
    f_EUTRA_CellConfig_DRB_Common(eutra_Cell1, 1, 0); // @sic R5-100492: UM bearer changed to AM sic@
    
    /* Preamble to enter UE in state Generic RB Established (state 3)
       Note! Also 1 AM DRB is established here compared to default state 3 */
    f_EUTRA_Preamble (eutra_Cell1, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_508_AM(eutra_Cell1); // @sic R5-100492: UM bearer changed to AM sic@
    
    f_EUTRA_TestBody_Set(true);
    
    //@siclog "Step 1" siclog@
    //The SS transmits an RRCConnectionReconfiguration message with a drb-ToReleaseList
    SRB.send(cas_SRB1_RrcNasPdu_REQ(eutra_Cell1,
                                    cs_TimingInfo_Now,
                                    cs_RRCConnectionReconfiguration_DRB_Release(v_RRC_TI, tsc_DRB2),
                                    v_NAS_MSG_Request));
    
    //@siclog "Step 2" siclog@
    //Check: Does the UE transmit an RRCConnectionReconfigurationComplete message?
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_Cell1, cr_508_RRCConnectionReconfigurationComplete(v_RRC_TI)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Test Case 8.2.3.1 Step 2");
    
    //@siclog "Step 2a" siclog@
    //The UE transmits an ULInformationTransfer message.
    SRB.receive(car_SRB2_NasPdu_IND(eutra_Cell1,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_DeactivateEPSBearerCxtAccept(v_DedicatedEpsBearerId))));
    
    //@siclog "Step 3" siclog@
    //Check: Does the test result of generic test procedure in TS 36.508 subclause 6.4.2.3 indicate that the UE is in E-UTRA RRC_CONNECTED state on Cell 1?
    f_EUTRA_508Check_ConnectedState(eutra_Cell1);
    
    f_EUTRA_TestBody_Set(false);
    
    /* Postamble */
    f_EUTRA_Postamble(eutra_Cell1, E2_CONNECTED); //@sic R5-103875 sic@
    
  }

}
