/******************************************************************************/
// @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.
//   (c) 2023, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_23wk37
// $Date: 2018-06-08 13:10:36 +0200 (Fri, 08 Jun 2018) $
// $Rev: 21524 $
/******************************************************************************/
module EPS_NAS_LoopBack_TypeDefs {
  import from CommonDefs all;
  import from NAS_CommonTypeDefs all;

  //----------------------------------------------------------------------------
  // General Info Elements (36.509 )
  //----------------------------------------------------------------------------

  type Octet_Type       UE_TestLoopModeB_LB_Setup_Type;
/*  type Octet_Type       UE_PositioningTechnology_Type;
  36.509 cl 6.9, not needed: corresponding bitstring constants are defined in Positioning ATS @sic R5s170597 - Rel-14 Baseline move sic@ */
  type O4_Type          MBMS_PacketCounterValue_Type;
  type O4_Type          SCPTM_PacketCounterValue_Type;
  const integer tsc_MAX_ModeA_LB_Entities := 8;
  const integer tsc_MAX_ModeD_Monitor_Entities := 400; // 36.509 cl 7.2
  const integer tsc_MAX_ModeE_Monitor_Entities := 16;   // 36.509 cl 7.2

  //****************************************************************************
  // Test Loop PROTOCOL DEFINITIONS: PDUs
  //----------------------------------------------------------------------------
  // Special conformance testing functions for User Equipment messages (36.509 cl. 6)
  //----------------------------------------------------------------------------

  // =============================================================================
  // Close UE Test Loop
  // 3G TS 36.509 cl. 6.1
  // Direction:     SS to UE
  // -----------------------------------------------------------------------------

  type record CLOSE_UE_TEST_LOOP {
    SkipIndicator                       skipIndicator,                          /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,                  /*    M V 1/2    */
    MessageType                         messageType,                            /*    M V 1      */
    UE_TestLoopMode_Type                ueTestLoopMode,                         /*    M V 1      */
    UE_TestLoopModeA_LB_Setup_Type      ueTestLoopModeA_LB_Setup optional,      /*    C LV 1-25
                                                                                      present if ueTestLoopMode ='00'F */
    UE_TestLoopModeB_LB_Setup_Type      ueTestLoopModeB_LB_Setup optional,      /*    C V 1
                                                                                      present if ueTestLoopMode ='01'F/
                                                                                      represents IP PDU delay time 0..255 seconds */
    UE_TestLoopModeC_LB_Setup_Type      ueTestLoopModeC_LB_Setup optional,      /*    C V 3
                                                                                      present if ueTestLoopMode ='02'H
                                                                                      @sic R5-155362 D2D sic@ */
    UE_TestLoopModeD_LB_Setup_Type      ueTestLoopModeD_LB_Setup optional,      /*    C LV-E 3-803
                                                                                      This IE is mandatory present if the IE "UE test loop mode" is set to UE test loop Mode D. Else it shall be absent.
                                                                                      @sic R5-155362 D2D sic@ */
    UE_TestLoopModeE_LB_Setup_Type      ueTestLoopModeE_LB_Setup optional,      /*    C LV 2-18
                                                                                      This IE is mandatory present if the IE "UE test loop mode" is set to UE test loop Mode E. Else it shall be absent. */
    UE_TestLoopModeF_LB_Setup_Type      ueTestLoopModeF_LB_Setup optional,      /*    C V 2
                                                                                      This IE is mandatory present if the IE "UE test loop mode" is set to UE test loop Mode F. Else it shall be absent. */
    UE_TestLoopModeGH_LB_Setup_Type     ueTestLoopModeGH_LB_Setup optional      /*    C V 2
                                                                                      This IE is mandatory present if the IE "UE test loop mode" is set to UE test loop Mode G or UE test loop mode H. Else it shall be absent. */
  };
   
  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode A LB Setup  36.509 cl. 6.1
  // *** additional Notes:
  // The maximum number of LB entities in the LB setup list is less than or equal to 5.
  // -----------------------------------------------------------------------------
  type record UE_TestLoopModeA_LB_Setup_Type {
    O1_Type                             iel,
    LB_SetupDRB_IE_List_Type            lbSetupDrbList optional
  };

  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode C LB Setup  36.509 cl. 6.1
  // =============================================================================
   type record UE_TestLoopModeC_LB_Setup_Type {
    B8_Type                            mBSFN_AreaId,  //MBSFN area Identity  0.. 255 Binary coded
    B4_Type                            reservedB1,
    B4_Type                            pMCHIdentity, // MCH identity 0.. 14 (binary coded,
    B3_Type                            reservedB2,
    B5_Type                            logChId //Logical channel identity 0..28 (binary coded,
  };

  // =============================================================================
  // LB Setup DRB IE
  // UE Test Loop Mode A LB Setup 36.509 cl. 6.1
  // -----------------------------------------------------------------------------
  type record LB_SetupDRB_IE_Type {
    B16_Type                            uplinkPdcpSduSize,
    B3_Type                             reserved,
    B5_Type                             drbIdentity
  };

  type record length (1..tsc_MAX_ModeA_LB_Entities)of LB_SetupDRB_IE_Type LB_SetupDRB_IE_List_Type;

  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode D LB Setup  36.509 cl. 6.1
  // =============================================================================
   type record UE_TestLoopModeD_LB_Setup_Type {
    B16_Type                           discMonitorListLength,   // Length of UE test loop mode D monitor list in bytes
    B7_Type                            reserved,
    B1_Type                            discAnnounceOrMonitor,   // D0 - Discovery Announce or Monitor
    DiscMonitorList_Type               discMonitorList optional
  };
  
  type record length (1..tsc_MAX_ModeD_Monitor_Entities) of DiscMonitor_Type DiscMonitorList_Type;  // Monitor list
  
  type record DiscMonitor_Type {
    //ProSe App Code (LSBs) #n to monitor
    B1_Type             proSeAppCodeLSB_A7,
    B1_Type             proSeAppCodeLSB_A6,
    B1_Type             proSeAppCodeLSB_A5,
    B1_Type             proSeAppCodeLSB_A4,
    B1_Type             proSeAppCodeLSB_A3,
    B1_Type             proSeAppCodeLSB_A2,
    B1_Type             proSeAppCodeLSB_A1,
    B1_Type             proSeAppCodeLSB_A0,
    B7_Type             reserved,
    B1_Type             proSeAppCodeLSB_A8
  }
   
  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode E LB Setup  36.509 cl. 6.1
  // =============================================================================
   type record UE_TestLoopModeE_LB_Setup_Type {
    B8_Type                            commMonitorListLength,   // Length of UE test loop mode E Monitor setup contents in bytes
    B6_Type                            reserved,
    B1_Type                            commTransmitOrReceive,   // Communication Transmit or Receive
    CommMonitorList_Type               commMonitorList optional,
    B1_Type                            d2dOrV2x // @sic R5-175219: addition of V2x in mode E sic@
  };
  
  type record length (1..tsc_MAX_ModeE_Monitor_Entities) of CommMonitor_Type CommMonitorList_Type;
  type B8_Type CommMonitor_Type;

  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode F LB Setup  36.509 cl. 6.1
  // =============================================================================
  type record UE_TestLoopModeF_LB_Setup_Type {
    B16_Type                            sC_MTCH_ID  //SC-MTCH ID
  };
  
  // =============================================================================
  // Structured Type Definition
  // *** Comments:
  // UE Test Loop Mode G/H LB Setup  36.509 cl. 6.1
  // =============================================================================
  type record UE_TestLoopModeGH_LB_Setup_Type { // @sic R5s170591 sic@
    B1_Type     uplinkLoopbackMode,
    B7_Type     repetitions,
    B8_Type     uplinkDataDelay
  };

  // =============================================================================
  // Close UE Test Loop Complete
  // 3G TS 36.509 cl. 6.2
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record CLOSE_UE_TEST_LOOP_COMPLETE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // OPEN UE Test Loop
  // 3G TS 36.509 cl. 6.3
  // Direction:     SS  to UE
  // -----------------------------------------------------------------------------
  type record OPEN_UE_TEST_LOOP {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // OPEN UE Test Loop Complete
  // 3G TS 36.509 cl. 6.4
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record OPEN_UE_TEST_LOOP_COMPLETE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // Activate RB Test Mode
  // 3G TS 36.509 cl. 6.5
  // Direction:     SS  to UE
  // -----------------------------------------------------------------------------
  type record ACTIVATE_TEST_MODE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType,                    /*    M V 1      */
    UE_TestLoopMode_Type                ueTestLoopMode                  /*    M V 1      */
  };

  // =============================================================================
  // Activate RB Test Mode Complete
  // 3G TS 36.509 cl. 6.6
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record ACTIVATE_TEST_MODE_COMPLETE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // Deactivate RB Test Mode
  // 3G TS 36.509 cl. 6.7
  // Direction:     SS  to UE
  // -----------------------------------------------------------------------------
  type record DEACTIVATE_TEST_MODE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // Deactivate RB Test Mode Complete
  // 3G TS 36.509 cl. 6.8
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
   type record DEACTIVATE_TEST_MODE_COMPLETE {
     SkipIndicator                       skipIndicator,                 /*    M V 1/2    */
     ProtocolDiscriminator               protocolDiscriminator,         /*    M V 1/2    */
     MessageType                         messageType                    /*    M V 1      */
   };

   // =============================================================================
  // UE TEST LOOP MODE C MBMS PACKET COUNTER REQUEST
  // 3G TS 36.509 cl. 6.10
  // Direction:    SS to UE
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOPMODEC_MBMS_PACKETCOUNTERREQUEST {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // UE TEST LOOP MODE C MBMS PACKET COUNTER RESPONSE
  // 3G TS 36.509 cl. 6.11
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOPMODEC_MBMS_PACKETCOUNTERRESPONSE {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType,                    /*    M V 1      */
    MBMS_PacketCounterValue_Type        MBMS_PacketCounterValue          /*   M V 4      */
  };

  // =============================================================================
  // UE TEST LOOP PROSE PACKET COUNTER REQUEST
  // 3G TS 36.509 cl. 6.13
  // Direction:    SS to UE
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOP_PROSE_PACKETCOUNTERREQUEST {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };

  // =============================================================================
  // UE TEST LOOP PROSE PACKET COUNTER RESPONSE
  // 3G TS 36.509 cl. 6.14
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOP_PROSE_PACKETCOUNTERRESPONSE {
    SkipIndicator                                skipIndicator,                                 /*    M V 1/2    */
    ProtocolDiscriminator                        protocolDiscriminator,                         /*    M V 1/2    */
    MessageType                                  messageType,                                   /*    M V 1      */
    ProSeDirectDiscPacketCounterValue_Type       proSeDirectDiscPacketCounterValue optional,         /* CV-ModeD  TLV-E  4 * (ND + 1) +3 */
    ProSeDirectCommPSCCH_PacketCounterValue_Type proSeDirectCommPSCCH_PacketCounterValue optional,   /* CV-ModeE TLV  4 * (NC + 1) + 2 */
    ProSeDirectCommSTCH_PacketCounterValue_Type  proSeDirectCommSTCH_PacketCounterValue optional,    /* CV-ModeE TLV  4*  (NC + 1) + 2 */
    ProSeDirectCommPSSCH_PacketCounterValue_Type proSeDirectCommPSSCH_PacketCounterValue optional   /* CV-ModeE TLV  4 * (NC + 1) + 2 @sic R5-183787 sic@ */
  };

  type record length(1..tsc_MAX_ModeD_Monitor_Entities) of O4_Type ProSeDirectDiscPacketCounterList_Type;
  type record length(1..tsc_MAX_ModeE_Monitor_Entities) of O4_Type ProSeDirectCommPSCCH_PacketCounterList_Type;
  type record length(1..tsc_MAX_ModeE_Monitor_Entities) of O4_Type ProSeDirectCommSTCH_PacketCounterList_Type;
  type record length(1..tsc_MAX_ModeE_Monitor_Entities) of O4_Type ProSeDirectCommPSSCH_PacketCounterList_Type; // @sic R5-183787 sic@
  
  type record ProSeDirectDiscPacketCounterValue_Type {
    MessageType                            proSeDirectDiscPacketCounterValueType,  /* shall be '0000 0000'B */
    B16_Type                               proSeDirectDiscPacketCounterListLength, /* Length of ProSe Direct Discovery Packet Counter(s) Value contents in bytes */
    ProSeDirectDiscPacketCounterList_Type  proSeDirectDiscPacketCounterList        /* ProSe Direct Discovery Packet Counter IE's */
  };

  type record ProSeDirectCommPSCCH_PacketCounterValue_Type {
    MessageType                                    proSeDirectCommPSCCH_PacketCounterValueType,  /* shall be '0000 0001'B */
    B8_Type                                        proSeDirectCommPSCCH_PacketCounterListLength, /* Length of ProSe Direct Communication PSCCH Packet Counter(s) Value contents in bytes */
    ProSeDirectCommPSCCH_PacketCounterList_Type    proSeDirectCommPSCCH_PacketCounterList        /* ProSe Direct Communication PSCCH Packet Counter IE's */
  };

  type record ProSeDirectCommSTCH_PacketCounterValue_Type {
    MessageType                                    proSeDirectCommSTCH_PacketCounterValueType,  /* shall be '0000 0010'B */
    B8_Type                                        proSeDirectCommSTCH_PacketCounterValueLength, /* Length of ProSe Direct Communication PSCCH Packet Counter(s) Value contents in bytes */
    ProSeDirectCommSTCH_PacketCounterList_Type     proSeDirectCommSTCH_PacketCounterList        /* ProSe Direct Communication PSCCH Packet Counter IE's */
  };

  type record ProSeDirectCommPSSCH_PacketCounterValue_Type {  // @sic R5-183787 sic@
    MessageType                                    proSeDirectCommPSSCH_PacketCounterValueType,  /* shall be '0000 0011'B */
    B8_Type                                        proSeDirectCommPSSCH_PacketCounterListLength, /* Length of ProSe Direct Communication PSSCH Packet Counter(s) Value contents in bytes */
    ProSeDirectCommPSSCH_PacketCounterList_Type    proSeDirectCommPSSCH_PacketCounterList        /* ProSe Direct Communication PSSCH Packet Counter IE's */
  };
  
  // =============================================================================
  // UE TEST LOOP MODE F SCPTM PACKET COUNTER REQUEST
  // 3G TS 36.509 cl. 6.15
  // Direction:     SS to UE
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOPMODEF_SCPTM_PACKETCOUNTERREQUEST {
    SkipIndicator                       skipIndicator,                  /*    M V 1/2    */
    ProtocolDiscriminator               protocolDiscriminator,          /*    M V 1/2    */
    MessageType                         messageType                     /*    M V 1      */
  };
  
  // =============================================================================
  // UE TEST LOOP MODE F SCPTM PACKET COUNTER RESPONSE
  // 3G TS 36.509 cl. 6.16
  // Direction:     UE to SS
  // -----------------------------------------------------------------------------
  type record UE_TESTLOOPMODEF_SCPTM_PACKETCOUNTERRESPONSE {
    SkipIndicator                                skipIndicator,                                 /*    M V 1/2    */
    ProtocolDiscriminator                        protocolDiscriminator,                         /*    M V 1/2    */
    MessageType                                  messageType,                                   /*    M V 1      */
    SCPTM_PacketCounterValue_Type                sCPTM_PacketCounterValue                       /*    M V 4      */
  };
} with { encode "NAS Types"}
