/******************************************************************************/
// @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: 2023-09-14 09:54:06 +0200 (Thu, 14 Sep 2023) $
// $Rev: 37128 $
/******************************************************************************/

module NG_NAS_Templates {

  import from CommonDefs all;
  import from NAS_CommonTypeDefs all;
  import from NG_NAS_TypeDefs all;
  import from NG_NAS_MsgContainers all;
  import from NAS_CommonTemplates all;
  import from NG_NAS_Common all;
  import from Common4G5G_LoopBack all;
  import from CommonIP all;

  //****************************************************************************
  // common NAS message (security protected or non security protected)
  //----------------------------------------------------------------------------
  // templates for NAS_SecurityProtectionInfo_Type

  template (value) NG_NAS_SecurityProtectionInfoDL_Type cs_NG_NAS_SecurityProtectionInfo(SecurityHeaderType p_Status,
                                                                                         boolean p_ForceMacError := false) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    Status := p_Status,
    ForceMacError := p_ForceMacError
  };

  template (present) NG_NAS_SecurityProtectionInfoUL_Type cr_NG_NAS_SecurityProtectionInfo(template (present) SecurityHeaderType p_ExpectedStatus) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    Status := p_ExpectedStatus,
    NasCount := ?
  };

  // common templates for security-protected or non security-protected NAS messages

  template (value) NG_NAS_MSG_Request_Type cs_NG_NAS_Request(SecurityHeaderType p_SecurityStatus,
                                                             template (value) NG_NAS_DL_Message_Type p_Msg) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    SecurityProtection := cs_NG_NAS_SecurityProtectionInfo(p_SecurityStatus),
    Pdu := {
      Msg := p_Msg,
      PiggybackedPduList := omit
    }
  };


  template (present) NG_NAS_MSG_Indication_Type cr_NG_NAS_Ind(template (present) SecurityHeaderType p_ExpectedSecurityStatus,
                                                              template (present) NG_NAS_UL_Message_Type p_Msg := ?) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    SecurityProtection := cr_NG_NAS_SecurityProtectionInfo(p_ExpectedSecurityStatus),
    Pdu := {
      Msg := p_Msg,
      PiggybackedPduList := omit
    }
  };

  template (value) NG_NAS_MSG_Request_Type cs_NG_NAS_RequestWithPiggybacking(SecurityHeaderType p_SecurityStatus,
                                                                             template (value) NG_NAS_DL_Pdu_Type p_PiggyBackList) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    SecurityProtection := cs_NG_NAS_SecurityProtectionInfo(p_SecurityStatus),
    Pdu := p_PiggyBackList
  };

  template (value) NG_NAS_DL_Pdu_Type cs_NG_NAS_DL_PduWithPiggybacking(template (value) NG_NAS_DL_Message_Type p_GmmMsg,
                                                                       template (value) NG_NAS_DL_Message_Type p_PiggyBackedMsg) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    Msg := p_GmmMsg,
    PiggybackedPduList := {
      {
        Msg := p_PiggyBackedMsg,
        PiggybackedPduList := omit
      }
    }
  };

  template (value) NG_NAS_DL_Pdu_Type cs_NG_NAS_DL_PduWithoutPiggyback(template (value) NG_NAS_DL_Message_Type p_GmmMsg) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    Msg := p_GmmMsg,
    PiggybackedPduList := omit
  };

  template (present) NG_NAS_MSG_Indication_Type cr_NG_NAS_IndWithPiggybacking(template (present) SecurityHeaderType p_ExpectedSecurityStatus,
                                                                              template (present) NG_NAS_UL_Pdu_Type p_PiggyBackList := ?) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    SecurityProtection := cr_NG_NAS_SecurityProtectionInfo(p_ExpectedSecurityStatus),
    Pdu := p_PiggyBackList
  };

  //****************************************************************************
  // NG mobility management messages (24.501 cl. 8.2)
  //----------------------------------------------------------------------------

  template (omit) NG_NAS_DL_Message_Type cs_NG_AUTHENTICATION_REQUEST(NAS_KsiValue p_KeySetId,
                                                                      template (value) ABBA p_ABBA,
                                                                      template (omit) RAND p_RAND := omit,
                                                                      template (omit) AUTN p_AUTN := omit,
                                                                      template (omit) EAP_Message p_EAP := omit) :=
  { /* 24.501 cl. 8.2.1 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    authentication_Request := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_AuthenticationRequest, /* cl. 9.7      M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,              /* cl. 9.5      M V 1/2 */
      ngNasKeySetId           := cs_NAS_KeySetIdentifier_lv(p_KeySetId, tsc_NasKsi_NativeSecurityContext), /* cl. 9.11.3.32 M V 1/2 */
      abba                    := p_ABBA,                          /* cl. 9.11.3.10 M LV 3-n */
      rand                    := p_RAND,                          /* cl. 9.11.3.16 O TV 17  IEI=21 */
      autn                    := p_AUTN,                          /* cl. 9.11.3.15 O TLV 18 IEI=20 */
      eapMessage              := p_EAP                            /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_AUTHENTICATION_RESPONSE (template AuthenticationResponseParameter p_Res := cr_AuthenticationResponseParameter(?),
                                                                           template EAP_Message p_EAP := omit) :=
  { /* 24.501 cl. 8.2.2 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    authentication_Response := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_AuthenticationResponse, /* cl. 9.7      M V 1   */
      authResponseParam       := p_Res,   /* cl. 9.11.3.17 O TLV 18 IEI=2D */
      eapMessage              := p_EAP                    /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_AUTHENTICATION_RESULT (NAS_KsiValue p_KeySetId,
                                                                       template (omit) EAP_Message p_EAP,
                                                                       template (omit) ABBA p_ABBA) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.3 */
    authentication_Result := {
      protocolDiscriminator   := tsc_EPD_GMM,                      /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,               /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_AuthenticationResult,   /* cl. 9.7      M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,               /* cl. 9.5      M V 1/2 */
      ngNasKeySetId           := cs_NAS_KeySetIdentifier_lv(p_KeySetId, tsc_NasKsi_NativeSecurityContext), /* cl. 9.11.3.32 M V 1/2 */
      eapMessage              := p_EAP,                            /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      abba                    := p_ABBA                            /* cl. 9.11.3.10 M LV 3-n */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_AUTHENTICATION_FAILURE (template (present) GMM_GSM_Cause p_Cause := cr_GMM_GSM_Cause(omit),
                                                                          template AuthenticationFailureParameter p_AuthFailParam := omit) :=
  { /* 24.501 cl. 8.2.4 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    authentication_Failure := {
      protocolDiscriminator   := tsc_EPD_GMM,                      /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,               /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_AuthenticationFailure,  /* cl. 9.7      M V 1   */
      gmmCause                := p_Cause,                          /* cl. 9.11.3.2   M V 1   */
      authFailureParam        := p_AuthFailParam                   /* cl. 9.11.3.12  O TLV 16 IEI=30 */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_AUTHENTICATION_REJECT (template (omit) EAP_Message p_EAP):=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.5 */
    authentication_Reject := {
      protocolDiscriminator   := tsc_EPD_GMM,                    /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,             /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_AuthenticationReject, /* cl. 9.7      M V 1   */
      eapMessage              := p_EAP                           /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_REGISTRATION_REQUEST(template (present) RegistrationType p_RegistrationType,
                                                                       template (present) NAS_KsiValue p_KeySetId,
                                                                       template (present) B1_Type p_Tsc,
                                                                       template (present) NG_MobileIdentity p_MobileId,
                                                                       template NAS_KeySetIdentifier p_NonCurrentKSI,
                                                                       template NG_GMM_Cap p_GMM_Cap,
                                                                       template NG_UE_SecurityCapability p_UESecurityCap,
                                                                       template NSSAI p_ReqNSSAI,
                                                                       template NG_TrackingAreaId p_TAI,
                                                                       template UE_NetworkCap p_UE_NetworkCap,
                                                                       template ULDataStatus p_ULDataStatus,
                                                                       template PDU_SessionStatus p_PDU_SessionStatus,
                                                                       template MICO_Ind p_MICO_Ind,
                                                                       template UE_Status p_UE_Status,
                                                                       template NG_MobileIdentity p_AddGUTI,
                                                                       template AllowedPDU_SessionStatus p_AllowedPDU_SessionStatus,
                                                                       template UE_UsageSetting p_UE_UsageSetting,
                                                                       template NG_DRXparameter p_DRXparam,
                                                                       template EPS_MessageContainer p_EPSMsg,
                                                                       template LADN_Ind p_LADN_Ind,
                                                                       template PayloadContainerType p_ContainerType, // @sic R5w190113 sic@
                                                                       template PayloadContainer p_Payload,
                                                                       template NetworkSlicingInd p_NetworkSlicingInd,
                                                                       template NG_UpdateType p_NG_UpdateType,
                                                                       template MS_Clsmk2 p_MS_Clsmk2,
                                                                       template CodecList p_SupportedCodecs,
                                                                       template EPS_BearerContextStatus p_EPS_BearerContextStatus, // @sic R5s190543 sic@
                                                                       template NASMessageContainer p_Msg,
                                                                       template ExtdDRXParams p_ExtdDRXParams,
                                                                       template GPRS_Timer3 p_T3324,
                                                                       template UERadioCapId p_UERadioCapId,
                                                                       template MappedNSSAI p_MappedNSSAI,
                                                                       template AddInfoRequest p_AddInfoRequest,
                                                                       template WUSAssistInfo p_WUSAssistInfo,
                                                                       template N5GCInd p_N5GCInd,
                                                                       template NB_N1ModeDRXParams p_NB_N1ModeDRXParams,
                                                                       template UE_RequestType p_UeRequestType,
                                                                       template NG_PagingRestriction p_PagingRestrict,
                                                                       template ServiceLvlAAContainer p_ServiceLvlAA,
                                                                       template NID p_NId,
                                                                       template PLMN_IdIE p_MSPLMNwDisasterCondition,
                                                                       template PEIPS_AssistInfo p_RequestedPEIPS_AssistInfo,
                                                                       template GPRS_Timer3 p_T3512) :=
  { /* 24.501 cl. 8.2.6 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    registration_Request := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_RegistrationRequest,   /* cl. 9.7      M V 1   */
      ngNasKSI                := cr_NAS_KeySetIdentifier(p_KeySetId, p_Tsc), /* cl. 9.11.3.32 M V 1/2 */
      registrationType        := p_RegistrationType,              /* cl. 9.11.3.7 M LV 2  */
      ngMobileId              := p_MobileId,                      /* cl. 9.11.3.4 M LV 5-?  */
      nonCurrentNativeKSI     := p_NonCurrentKSI,                 /* cl. 9.11.3.32 O TV 1 IEI=C- */
      gmmCapability           := p_GMM_Cap,                       /* cl. 9.11.3.1  O TLV 3-15 IEI=10 */
      ueSecurityCapability    := p_UESecurityCap,                 /* cl. 9.11.3.54 O TLV 4-10 IEI=2E */
      requestedNSSAI          := p_ReqNSSAI,                      /* cl. 9.11.3.37 O TLV 4-74 IEI=2F */
      lastVisitedRegisteredTai := p_TAI,                          /* cl. 9.11.3.8  O TV 7 IEI=52 */
      s1_UE_Capability        := p_UE_NetworkCap,                 /* cl. 9.11.3.48 O LV 4-15 IEI=65 */
      ulDataStatus            := p_ULDataStatus,                  /* cl. 9.11.3.57 O TLV 4-34 IEI=40 */
      pduSessionStatus        := p_PDU_SessionStatus,             /* cl. 9.11.3.44  O TLV 4-34 IEI=50 */
      micoInd                 := p_MICO_Ind,                      /* cl. 9.11.3.31 O TLV 1 IEI=B */
      ueStatus                := p_UE_Status,                     /* cl. 9.11.3.56 O TLV 3 IEI=2B */
      additionalGUTI          := p_AddGUTI,                       /* cl. 9.11.3.4  O TLV 5-? IEI=2C */
      allowedPDUSessionStatus := p_AllowedPDU_SessionStatus,      /* cl. 9.11.3.13 O TLV 4-34 IEI=25 */
      ueUsageSetting          := p_UE_UsageSetting,               /* cl. 9.11.3.55 O TLV 3 IEI=60 */
      reqDRXParams            := p_DRXparam,                      /* cl. 9.11.3.22 O TLV ? IEI=51 */
      epsMessage              := p_EPSMsg,                        /* cl. 9.11.3.24 O TLV-E ? IEI=7C */
      ladnInd                 := p_LADN_Ind,                      /* cl. 9.11.3.29 O TLV-E 3-811 IEI=7E */
      payloadContainerType    := p_ContainerType,                 /* cl. 9.11.3.40 O TV 1 IEI=8 Mar 19 @sic R5w190113 sic@*/
      payload                 := p_Payload,                       /* cl. 9.11.3.39 O TLV-E 4-65538 IEI=7B */
      networkSlicingInd       := p_NetworkSlicingInd,             /* cl. 9.11.3.36 O TV 1 IEI=9 Dec18 */
      updateType              := p_NG_UpdateType,                 /* cl. 9.11.3.9A O TLV 3 IEI=53 Dec18 */
      msClassmark2            := p_MS_Clsmk2, /* cl. 9.11.3.31C O TLV 5 IEI=41 Sep20 @sic R5s201387 Baseline Moving sic@ */
      supportedCodecs         := p_SupportedCodecs, /* cl. 9.11.3.51A O TLV 5-n IEI=42 Sep20 @sic R5s201387 Baseline Moving sic@ */
      nasMsg                  := p_Msg,                           /* cl. 9.11.3.33 O TLV-E 4-n IEI=71 Dec18 */
      epsBearerContextStatus  := p_EPS_BearerContextStatus,       /* cl. 9.11.3.23A O TLV 4 IEI=60 Jun19 @sic R5s190543 sic@ */
      requestedExtdDRXParams  := p_ExtdDRXParams, /* cl. 9.11.3.26A O TLV 3 IEI=6E Sep20 @sic R5s201387 Baseline Moving sic@ */
      t3324Value              := p_T3324, /* cl. 9.11.2.5   O TLV 3 IEI=6A Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRadioCapabilityId     := p_UERadioCapId, /* cl. 9.11.3.68  O TLV 3-n IEI=67 Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedMappedNSSAI    := p_MappedNSSAI, /* cl. 9.11.3.31B O TLV 3-42 IEI=35 Sep20 @sic R5s201387 Baseline Moving sic@ */
      additionalInfoReq       := p_AddInfoRequest, /* cl. 9.11.3.12A O TLV 3 IEI=48 Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedWUSAssistanceInfo := p_WUSAssistInfo, /* cl. 9.11.3.71  O TLV 3-n IEI=1A Sep20 @sic R5s201387 Baseline Moving sic@ */
      n5GCInd                 := p_N5GCInd, /* cl. 9.11.3.72  O T   1 IEI=A Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedNB_N1DRXParams := p_NB_N1ModeDRXParams,  /* cl. 9.11.3.73  O TLV 3 IEI=30 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRequestType           := p_UeRequestType, /* cl. 9.11.3.76  O TLV 3 IEI=29 Sep22 @sic R5s221179 Baseline Moving sic@ */
      pagingRestrict          := p_PagingRestrict, /* cl. 9.11.3.77  O TLV 3-35 IEI=28 Sep22 @sic R5s221179 Baseline Moving sic@ */
      serviceLvlAA            := p_ServiceLvlAA, /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
      nId                     := p_NId, /* cl. 9.11.3.79  O TLV 8 IEI=32 Sep22 @sic R5s221179 Baseline Moving sic@ */
      msPLMNwDisasterCondition  := p_MSPLMNwDisasterCondition, /* cl. 9.11.3.85  O TLV 5 IEI=16 Sep22 @sic R5s221179 Baseline Moving sic@ */
      requestedPEIPS_AssistInfo := p_RequestedPEIPS_AssistInfo,  /* cl. 9.11.3.80  O TLV 3-n IEI=2A Sep22 @sic R5s221179 Baseline Moving sic@ */
      t3512Value              := p_T3512  /* cl. 9.11.2.5   O TLV 3 IEI=3B Jun23 @sic R5s230533 sic@ */
    }
  };

 template (omit) NG_NAS_UL_Message_Type cs_NG_REGISTRATION_REQUEST(template (value) RegistrationType p_RegistrationType,
                                                                   template (value) NAS_KsiValue p_KeySetId,
                                                                   template (value) B1_Type p_Tsc,
                                                                   template (value) NG_MobileIdentity p_MobileId,
                                                                   template (omit) NAS_KeySetIdentifier p_NonCurrentKSI := omit,
                                                                   template (omit) NG_GMM_Cap p_GMM_Cap := omit,
                                                                   template (omit) NG_UE_SecurityCapability p_UESecurityCap := omit,
                                                                   template (omit) NSSAI p_ReqNSSAI := omit,
                                                                   template (omit) NG_TrackingAreaId p_TAI := omit,
                                                                   template (omit) UE_NetworkCap p_UE_NetworkCap := omit,
                                                                   template (omit) ULDataStatus p_ULDataStatus := omit,
                                                                   template (omit) PDU_SessionStatus p_PDU_SessionStatus := omit,
                                                                   template (omit) MICO_Ind p_MICO_Ind := omit,
                                                                   template (omit) UE_Status p_UE_Status := omit,
                                                                   template (omit) NG_MobileIdentity p_AddGUTI := omit,
                                                                   template (omit) AllowedPDU_SessionStatus p_AllowedPDU_SessionStatus := omit,
                                                                   template (omit) UE_UsageSetting p_UE_UsageSetting := omit,
                                                                   template (omit) NG_DRXparameter p_DRXparam := omit,
                                                                   template (omit) EPS_MessageContainer p_EPSMsg := omit,
                                                                   template (omit) LADN_Ind p_LADN_Ind := omit,
                                                                   template (omit) PayloadContainerType p_ContainerType := omit, // @sic R5w190113 sic@
                                                                   template (omit) PayloadContainer p_Payload := omit,
                                                                   template (omit) NetworkSlicingInd p_NetworkSlicingInd := omit,
                                                                   template (omit) NG_UpdateType p_NG_UpdateType := omit,
                                                                   template (omit) MS_Clsmk2 p_MS_Clsmk2 := omit,
                                                                   template (omit) CodecList p_SupportedCodecs := omit,
                                                                   template (omit) EPS_BearerContextStatus p_EPS_BearerContextStatus := omit, // @sic R5s190543 sic@
                                                                   template (omit) NASMessageContainer p_Msg := omit,
                                                                   template (omit) ExtdDRXParams p_ExtdDRXParams := omit,
                                                                   template (omit) GPRS_Timer3 p_T3324 := omit,
                                                                   template (omit) UERadioCapId p_UERadioCapId := omit,
                                                                   template (omit) MappedNSSAI p_MappedNSSAI := omit,
                                                                   template (omit) AddInfoRequest p_AddInfoRequest := omit,
                                                                   template (omit) WUSAssistInfo p_WUSAssistInfo := omit,
                                                                   template (omit) N5GCInd p_N5GCInd := omit,
                                                                   template (omit) NB_N1ModeDRXParams p_NB_N1ModeDRXParams := omit,
                                                                   template (omit) UE_RequestType p_UeRequestType := omit,
                                                                   template (omit) NG_PagingRestriction p_PagingRestrict := omit,
                                                                   template (omit) ServiceLvlAAContainer p_ServiceLvlAA := omit,
                                                                   template (omit) NID p_NId := omit,
                                                                   template (omit) PLMN_IdIE p_MSPLMNwDisasterCondition := omit,
                                                                   template (omit) PEIPS_AssistInfo p_RequestedPEIPS_AssistInfo := omit,
                                                                   template (omit) GPRS_Timer3 p_T3512 := omit
                                                                   ) := { /* 24.501 cl. 8.2.6 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    registration_Request := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_RegistrationRequest,   /* cl. 9.7      M V 1   */
      ngNasKSI                := cs_NAS_KeySetIdentifier_lv(valueof(p_KeySetId), valueof(p_Tsc)), /* cl. 9.11.3.32 M V 1/2 */
      registrationType        := p_RegistrationType,              /* cl. 9.11.3.7 M LV 2  */
      ngMobileId              := p_MobileId,                      /* cl. 9.11.3.4 M LV 5-?  */
      nonCurrentNativeKSI     := p_NonCurrentKSI,                 /* cl. 9.11.3.32 O TV 1 IEI=C- */
      gmmCapability           := p_GMM_Cap,                       /* cl. 9.11.3.1  O TLV 3-15 IEI=10 */
      ueSecurityCapability    := p_UESecurityCap,                 /* cl. 9.11.3.54 O TLV 4-10 IEI=2E */
      requestedNSSAI          := p_ReqNSSAI,                      /* cl. 9.11.3.37 O TLV 4-74 IEI=2F */
      lastVisitedRegisteredTai := p_TAI,                          /* cl. 9.11.3.8  O TV 7 IEI=52 */
      s1_UE_Capability        := p_UE_NetworkCap,                 /* cl. 9.11.3.48 O LV 4-15 IEI=65 */
      ulDataStatus            := p_ULDataStatus,                  /* cl. 9.11.3.57 O TLV 4-34 IEI=40 */
      pduSessionStatus        := p_PDU_SessionStatus,             /* cl. 9.11.3.44  O TLV 4-34 IEI=50 */
      micoInd                 := p_MICO_Ind,                      /* cl. 9.11.3.31 O TLV 1 IEI=B */
      ueStatus                := p_UE_Status,                     /* cl. 9.11.3.56 O TLV 3 IEI=2B */
      additionalGUTI          := p_AddGUTI,                       /* cl. 9.11.3.4  O TLV 5-? IEI=2C */
      allowedPDUSessionStatus := p_AllowedPDU_SessionStatus,      /* cl. 9.11.3.13 O TLV 4-34 IEI=25 */
      ueUsageSetting          := p_UE_UsageSetting,               /* cl. 9.11.3.55 O TLV 3 IEI=60 */
      reqDRXParams            := p_DRXparam,                      /* cl. 9.11.3.22 O TLV ? IEI=51 */
      epsMessage              := p_EPSMsg,                        /* cl. 9.11.3.24 O TLV-E ? IEI=7C */
      ladnInd                 := p_LADN_Ind,                      /* cl. 9.11.3.29 O TLV-E 3-811 IEI=7E */
      payloadContainerType    := p_ContainerType,                 /* cl. 9.11.3.40 O TV 1 IEI=8 Mar 19 @sic R5w190113 sic@*/
      payload                 := p_Payload,                       /* cl. 9.11.3.39 O TLV-E 4-65538 IEI=7B */
      networkSlicingInd       := p_NetworkSlicingInd,             /* cl. 9.11.3.36 O TV 1 IEI=9 Dec18 */
      updateType              := p_NG_UpdateType,                 /* cl. 9.11.3.9A O TLV 3 IEI=53 Dec18 */
      msClassmark2            := p_MS_Clsmk2, /* cl. 9.11.3.31C O TLV 5 IEI=41 Sep20 @sic R5s201387 Baseline Moving sic@ */
      supportedCodecs         := p_SupportedCodecs, /* cl. 9.11.3.51A O TLV 5-n IEI=42 Sep20 @sic R5s201387 Baseline Moving sic@ */
      nasMsg                  := p_Msg,                           /* cl. 9.11.3.33 O TLV-E 4-n IEI=71 Dec18 */
      epsBearerContextStatus  := p_EPS_BearerContextStatus,       /* cl. 9.11.3.23A O TLV 4 IEI=60 Jun19 @sic R5s190543 sic@ */
      requestedExtdDRXParams  := p_ExtdDRXParams, /* cl. 9.11.3.26A O TLV 3 IEI=6E Sep20 @sic R5s201387 Baseline Moving sic@ */
      t3324Value              := p_T3324, /* cl. 9.11.2.5   O TLV 3 IEI=6A Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRadioCapabilityId     := p_UERadioCapId, /* cl. 9.11.3.68  O TLV 3-n IEI=67 Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedMappedNSSAI    := p_MappedNSSAI, /* cl. 9.11.3.31B O TLV 3-42 IEI=35 Sep20 @sic R5s201387 Baseline Moving sic@ */
      additionalInfoReq       := p_AddInfoRequest, /* cl. 9.11.3.12A O TLV 3 IEI=48 Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedWUSAssistanceInfo := p_WUSAssistInfo, /* cl. 9.11.3.71  O TLV 3-n IEI=1A Sep20 @sic R5s201387 Baseline Moving sic@ */
      n5GCInd                 := p_N5GCInd, /* cl. 9.11.3.72  O T   1 IEI=A Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedNB_N1DRXParams := p_NB_N1ModeDRXParams,  /* cl. 9.11.3.73  O TLV 3 IEI=30 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRequestType           := p_UeRequestType, /* cl. 9.11.3.76  O TLV 3 IEI=29 Sep22 @sic R5s221179 Baseline Moving sic@ */
      pagingRestrict          := p_PagingRestrict, /* cl. 9.11.3.77  O TLV 3-35 IEI=28 Sep22 @sic R5s221179 Baseline Moving sic@ */
      serviceLvlAA            := p_ServiceLvlAA, /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
      nId                     := p_NId, /* cl. 9.11.3.79  O TLV 8 IEI=32 Sep22 @sic R5s221179 Baseline Moving sic@ */
      msPLMNwDisasterCondition  := p_MSPLMNwDisasterCondition, /* cl. 9.11.3.85  O TLV 5 IEI=16 Sep22 @sic R5s221179 Baseline Moving sic@ */
      requestedPEIPS_AssistInfo := p_RequestedPEIPS_AssistInfo,  /* cl. 9.11.3.80  O TLV 3-n IEI=2A Sep22 @sic R5s221179 Baseline Moving sic@ */
      t3512Value              := p_T3512  /* cl. 9.11.2.5   O TLV 3 IEI=3B Jun23 @sic R5s230533 sic@ */
    }
  } // End of template m_NG_REGISTRATION_REQUEST

  template (present) NG_UpdateType cr_NG_Update (template (present) B1_Type p_NgRAN_RCU := ?,
                                                 template (present) B1_Type p_SmsRequested := ?,
                                                 template (present) B2_Type p_EPS_PNB_CIoT := ?,
                                                 template (present) B2_Type p_NG_PNB_CIoT := ?):=
  { /* 24.501 cl. 9.11.3.9A;
       @sic R5s201387 Baseline Moving sic@  */
    /* @status    APPROVED (NR5GC) */
    iei := '53'O,
    iel := '01'O,
    spare := '00'B,
    eps_PNB_CIoT := p_EPS_PNB_CIoT,
    ng_PNB_CIoT := p_NG_PNB_CIoT,
    ngRAN_RCU := p_NgRAN_RCU,
    smsRequested := p_SmsRequested
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_REGISTRATION_ACCEPT(template (value) RegistrationResult p_RegistrationResult,
                                                                    template (omit) NG_MobileIdentity p_GUTI,
                                                                    template (omit) PLMN_List p_EPLMNs,
                                                                    template (omit) NG_TrackingAreaIdList p_TAIList,
                                                                    template (omit) NSSAI p_AllowedNSSAI,
                                                                    template (omit) RejectedNSSAI p_RejectedNSSAI,
                                                                    template (omit) NSSAI p_ConfiguredNSSAI,
                                                                    template (omit) NG_NetworkFeatureSupport p_NwkFeatureSupport,
                                                                    template (omit) PDU_SessionStatus p_PDU_SessionStatus,
                                                                    template (omit) PDU_SessionReactivationResult p_PDU_SessionReactResult,
                                                                    template (omit) PDU_SessionReactivationError p_PDU_SessionReactError,
                                                                    template (omit) LADN_Info p_LADN_Info,
                                                                    template (omit) MICO_Ind p_MICO_Ind,
                                                                    template (omit) NetworkSlicingInd p_NetworkSlicingInd,
                                                                    template (omit) ServiceAreaIdList p_SAIList,
                                                                    template (omit) GPRS_Timer3 p_T3512,
                                                                    template (omit) GPRS_Timer2 p_Non3GPPDereg,
                                                                    template (omit) GPRS_Timer2 p_T3502,
                                                                    template (omit) EmergNumList p_EmergNumList,
                                                                    template (omit) ExtdEmergNumList p_ExtdEmergNumList,
                                                                    template (omit) SORTransparentContainer p_SOR,
                                                                    template (omit) EAP_Message p_EAP,
                                                                    template (omit) InclusionModeNSSAI p_InclusionModeNSSAI,
                                                                    template (omit) OperatorAccessCatDefinitions p_AccessCatDefinition,
                                                                    template (omit) NG_DRXparameter p_NG_DRXparameter,
                                                                    template (omit) Non3GPP_NW_ProvidedPolicies p_Non3GPP_NW_ProvidedPolicies,
                                                                    template (omit) EPS_BearerContextStatus p_EPS_BearerContextStatus,
                                                                    template (omit) ExtdDRXParams p_NegotiatedExtdDRXParams,
                                                                    template (omit) GPRS_Timer3 p_T3447,
                                                                    template (omit) GPRS_Timer3 p_T3448,
                                                                    template (omit) GPRS_Timer3 p_T3324,
                                                                    template (omit) UERadioCapId p_UERadioCapId,
                                                                    template (omit) UERadioCapIdDeletion p_UERadioCapIdDeletion,
                                                                    template (omit) NSSAI p_PendingNSSAI,
                                                                    template (omit) NG_CipheringKeyData p_CipheringKeyData,
                                                                    template (omit) CAGInfoList p_CAGInfoList,
                                                                    template (omit) TruncatedS_TMSIConfig p_TruncatedS_TMSIConfig,
                                                                    template (omit) WUSAssistInfo p_WUSAssistInfo,
                                                                    template (omit) NB_N1ModeDRXParams p_NB_N1ModeDRXParams,
                                                                    template (omit) ExtdRejectedNSSAI p_ExtdRejectedNSSAI,
                                                                    template (omit) ServiceLvlAAContainer p_ServiceLvlAA,
                                                                    template (omit) PEIPS_AssistInfo p_NegotiatedPEIPS_AssistInfo,
                                                                    template (omit) NG_AddReqResult p_AddRequestResult,
                                                                    template (omit) NSSRG_Info p_NssrgInfo,
                                                                    template (omit) RegistrationWaitRange p_DisasterRoamingWaitRange,
                                                                    template (omit) RegistrationWaitRange p_DisasterReturnWaitRange,
                                                                    template (omit) DisasterPLMNList p_DisasterPLMNList,
                                                                    template (omit) NG_TrackingAreaIdList p_ForbidTAIList_Roaming,
                                                                    template (omit) NG_TrackingAreaIdList p_ForbidTAIList_RegProvService,
                                                                    template (omit) ExtdCAGInfoList p_ExtdCAGInfoList,
                                                                    template (omit) NSAG_Info p_NsagInfo) :=
  { /* 24.501 cl. 8.2.7 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    registration_Accept := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_RegistrationAccept,    /* cl. 9.7      M V 1   */
      registrationResult      := p_RegistrationResult,            /* cl. 9.11.3.6 M LV 2 */
      guti                    := p_GUTI,                          /* cl. 9.11.3.4 O TLV 13 IEI=2C */
      equivalentPlmns         := p_EPLMNs,                        /* cl. 9.11.3.45 O TLV 5-47 IEI=4A */
      taiList                 := p_TAIList,                       /* cl. 9.11.3.9 O TLV 9-114 IEI=54 */
      allowedNSSAI            := p_AllowedNSSAI,                  /* cl. 9.11.3.37 O TLV 4-74 IEI=70 */
      rejectedNSSAI           := p_RejectedNSSAI,                 /* cl. 9.11.3.46 O TLV 4-42 IEI=0x11 */
      configuredNSSAI         := p_ConfiguredNSSAI,               /* cl. 9.11.3.37 O TLV 4-146 IEI=31 */
      ngs_NetworkFeatureSupport := p_NwkFeatureSupport,           /* cl. 9.11.3.5  O TLV 3-5  IEI=21*/
      pduSessionStatus        := p_PDU_SessionStatus,             /* cl. 9.11.3.44 O TLV 4-34 IEI=50 */
      pduSessionReactivationResult := p_PDU_SessionReactResult,   /* cl. 9.11.3.42 O TLV 4-32 IEI=26 */
      pduSessionReactResultError := p_PDU_SessionReactError,      /* cl. 9.11.3.43 O TLV-E 5-515 IEI=7E */
      ladnInfo                := p_LADN_Info,                     /* cl. 9.11.3.30 O TLV-E 12-1707 IEI=79 */
      micoInd                 := p_MICO_Ind,                      /* cl. 9.11.3.31 O TV 1 IEI=B */
      networkSlicingInd       := p_NetworkSlicingInd,             /* cl. 9.11.3.36 O TV 1 IEI=9 */
      saiList                 := p_SAIList,                       /* cl. 9.11.3.49 O TLV 6-114 IEI=27 */
      t3512Value              := p_T3512,                         /* cl. 9.11.2.5  O TLV 3 IEI=5E */
      non3GPPDeregisterValue  := p_Non3GPPDereg,                  /* cl. 9.11.2.4 O TLV 3 IEI=5D */
      t3502Value              := p_T3502,                         /* cl. 9.11.2.4 O TLV 3 IEI=16 */
      emergencyNumberList     := p_EmergNumList,                  /* cl. 9.11.3.23 O TLV 5-50 IEI=34 */
      xtdEmergencyNumberList  := p_ExtdEmergNumList,              /* cl. 9.11.3.26 O TLV-E 6-65538 IEI=7A */
      sorTransparentContainer := p_SOR,                           /* cl. 9.11.3.51 O TLV-E 20-2048 IEI=7F */
      eapMessage              := p_EAP,                           /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78*/
      inclusionModeNSSAI      := p_InclusionModeNSSAI,            /* cl. 9.11.3.37A O TV 1 IEI=A */
      operatorAccessCatDefs   := p_AccessCatDefinition,           /* cl. 9.11.3.38 O TLV-E 4-n IEI=76 */
      negotiatedDRXParams     := p_NG_DRXparameter,               /* cl. 9.11.3.2A O TLV 3 IEI=51 */
      non3GPP_NW_ProvidedPolicies := p_Non3GPP_NW_ProvidedPolicies,  /* cl. 9.11.3.58 O TV 1 IEI = ? Mar 19 @sic R5w190113 sic@ */
      epsBearerContextStatus  := p_EPS_BearerContextStatus,       /* cl. 9.11.3.23A O TLV 4 IEI=60 Jun19 @sic R5s190543 sic@ */
      negotiatedExtdDRXParams := p_NegotiatedExtdDRXParams,       /* cl. 9.11.3.26A O TLV 3 IEI=6E Sep20 @sic R5s201387 Baseline Moving sic@ */
      t3447Value              := p_T3447, /* cl. 9.11.2.5   O TLV 3 IEI=6C Sep20 @sic R5s201387 Baseline Moving sic@ */
      t3448Value              := p_T3448, /* cl. 9.11.2.4   O TLV 3 IEI=6B Sep20 @sic R5s201387 Baseline Moving sic@ */
      t3324Value              := p_T3324, /* cl. 9.11.2.5   O TLV 3 IEI=6A Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRadioCapabilityId     := p_UERadioCapId, /* cl. 9.11.3.68  O TLV 3-n IEI=67 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueRadioCapIdDeletionInd := p_UERadioCapIdDeletion, /* cl. 9.11.3.69  O TV  1 IEI=E Sep20 @sic R5s201387 Baseline Moving sic@ */
      pendingNSSAI            := p_PendingNSSAI, /* cl. 9.11.3.37  O TLV 4-146 IEI=39 Sep20 @sic R5s201387 Baseline Moving sic@ */
      cipheringKeyData        := p_CipheringKeyData, /* cl. 9.11.3.18C O TLV-E 34-n IEI=74 Sep20 @sic R5s201387 Baseline Moving sic@ */
      cagInfoList             := p_CAGInfoList, /* cl. 9.11.3.18A O TLV-E 3-n IEI=75 Sep20 @sic R5s201387 Baseline Moving sic@ */
      truncatedS_TMSIConfig   := p_TruncatedS_TMSIConfig, /* cl. 9.11.3.70  O TLV 3 IEI=1B Sep20 @sic R5s201387 Baseline Moving sic@ */
      negotiatedWUSAssistanceInfo  := p_WUSAssistInfo, /* cl. 9.11.3.71  O TLV 3-n IEI=1C Sep20 @sic R5s201387 Baseline Moving sic@ */
      negotiatedNB_N1DRXParams     := p_NB_N1ModeDRXParams,  /* cl. 9.11.3.73  O TLV 3 IEI=29 Sep20 @sic R5s201387 Baseline Moving sic@ */
      extdRejectedNSSAI            := p_ExtdRejectedNSSAI, /* cl. 9.11.3.75  O TLV 5-90 IEI=68 Sep22 @sic R5s221179 Baseline Moving sic@ */
      serviceLvlAA                 := p_ServiceLvlAA, /* cl. 9.11.2.10  O TLV-E 6-n IEI=7B Sep22 @sic R5s221179 Baseline Moving sic@ */
      negotiatedPEIPS_AssistInfo   := p_NegotiatedPEIPS_AssistInfo, /* cl. 9.11.3.80  O TLV 3-n IEI=33 Sep22 @sic R5s221179 Baseline Moving sic@ */
      ngAddRequestResult           := p_AddRequestResult, /* cl. 9.11.3.81  O TLV 3 IEI=34 Sep22 @sic R5s221179 Baseline Moving sic@ */
      nssrgInfo                    := p_NssrgInfo, /* cl. 9.11.3.82  O TLV-E 7-65538 IEI=70 Sep22 @sic R5s221179 Baseline Moving sic@ */
      disasterRoamingWaitRange     := p_DisasterRoamingWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=14 Sep22 @sic R5s221179 Baseline Moving sic@ */
      disasterReturnWaitRange      := p_DisasterReturnWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=2C Sep22 @sic R5s221179 Baseline Moving sic@ */
      disasterPLMNList             := p_DisasterPLMNList, /* cl. 9.11.3.83  O TLV 2-n IEI=13 Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_Roaming        := p_ForbidTAIList_Roaming, /* cl. 9.11.3.9   O TLV 9-114 IEI=1D Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_RegProvService := p_ForbidTAIList_RegProvService, /* cl. 9.11.3.9   O TLV 9-114 IEI=1E Sep22 @sic R5s221179 Baseline Moving sic@ */
      extdCAGInfoList              := p_ExtdCAGInfoList, /* cl. 9.11.3.86  O TLV-E 3-n IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
      nsagInfo                     := p_NsagInfo  /* cl. 9.11.3.87  O TLV-E 10-n IEI=7C Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_REGISTRATION_COMPLETE(template SORTransparentContainer p_SOR := *) :=
  { /* 24.501 cl. 8.2.8 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    registration_Complete := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_RegistrationComplete,  /* cl. 9.7      M V 1   */
      sorTransparentContainer := p_SOR                            /* cl. 9.11.3.49 O TLV-E 20-2048 IEI=7F */
    }
  };

   template (present) SORTransparentContainer cr_NG_SORTransparentContainer(template (present) SOR_Header p_Header,
                                                                            O16_Type p_Mac,
                                                                            template (omit) IEI8_Type p_IEI := '73'O,
                                                                            template (omit) Type6Length_Type p_IEL := '0011'O):=
    /* @status    APPROVED (NR5GC) */
        cr_NG_SORTransparentContainerValue (p_Header,
                                             p_Mac,
                                             omit,
                                             omit,
                                             p_IEI,
                                             p_IEL);

  template (value) SORTransparentContainer cs_NG_SORTransparentContainer_IeiIel(template (value) SOR_Header p_Header,
                                                                          O16_Type p_Mac,
                                                                          O2_Type p_Counter,
                                                                          octetstring p_Data) :=
    /* @status    APPROVED (NR5GC) */
        cs_NG_SORTransparentContainerValue (p_Header,
                                             p_Mac,
                                             p_Counter,
                                             p_Data,
                                             '73'O,
                                             int2oct(lengthof(p_Data) + 19, 2));


   template (omit) SORTransparentContainer cs_NG_SORTransparentContainerValue(template (value) SOR_Header p_Header,
                                                                                O16_Type p_Mac_UE,
                                                                                template (omit) O2_Type  p_Counter := omit,
                                                                                template (omit) octetstring p_Data := omit,
                                                                                template (omit) IEI8_Type p_IEI := omit,
                                                                                template (omit) Type6Length_Type p_IEL := omit):=
   {
    /* @status    APPROVED (NR5GC) */
    iei := p_IEI,
    iel := p_IEL,
    header :=p_Header,
    mac := p_Mac_UE,
    counter := p_Counter,
    data := p_Data
   };

   template (present) SORTransparentContainer cr_NG_SORTransparentContainerValue(template (present) SOR_Header p_Header,
                                                                                O16_Type p_Mac_UE,
                                                                                template (omit) O2_Type  p_Counter := omit,
                                                                                template (omit) octetstring p_Data := omit,
                                                                                template (omit) IEI8_Type p_IEI := omit,
                                                                                template (omit) Type6Length_Type p_IEL := omit):=
   {
    /* @status    APPROVED (NR5GC) */
    iei := p_IEI,
    iel := p_IEL,
    header :=p_Header,
    mac := p_Mac_UE,
    counter := p_Counter,
    data := p_Data
   };

  template (value) SOR_Header cs_NG_SOR_Header(B1_Type p_Ack,
                                               B1_Type p_ListType,
                                               B1_Type p_ListInd,
                                               B1_Type p_DataType,
                                               B1_Type p_Ap := '0'B):=
  { /* @status    APPROVED (NR5GC) */
    /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    spare             :=tsc_Spare3,
    ap                := p_Ap,
    ack               :=p_Ack,
    listType_MSSNPNSI :=p_ListType,
    listInd_MSSI      :=p_ListInd,
    dataType          :=p_DataType
  };

  template(present) SOR_Header cr_NG_SOR_Header(B1_Type p_Ack,
                                                template(present) B1_Type p_ListType,
                                                template(present) B1_Type p_ListInd,
                                                template(present) B1_Type p_DataType,
                                                template(present) B1_Type p_Ap := '0'B):=
  { /* @status    APPROVED (NR5GC) */
    /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    spare             :=tsc_Spare3,
    ap                := p_Ap,
    ack               :=p_Ack,
    listType_MSSNPNSI :=p_ListType,
    listInd_MSSI      :=p_ListInd,
    dataType          :=p_DataType
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_REGISTRATION_REJECT (template (value) GMM_GSM_Cause p_Cause,
                                                                     template (omit) GPRS_Timer2 p_T3346 := omit,
                                                                     template (omit) GPRS_Timer2 p_T3502 := omit,
                                                                     template (omit) EAP_Message p_EAP := omit,
                                                                     template (omit) RejectedNSSAI p_RejectedNSSAI := omit,
                                                                     template (omit) CAGInfoList p_CAGInfoList := omit,
                                                                     template (omit) ExtdRejectedNSSAI p_ExtdRejectedNSSAI := omit,
                                                                     template (omit) RegistrationWaitRange p_DisasterReturnWaitRange := omit,
                                                                     template (omit) ExtdCAGInfoList p_ExtdCAGInfoList := omit,
                                                                     template (omit) GPRS_Timer3 p_LowerBoundTimerValue := omit,
                                                                     template (omit) NG_TrackingAreaIdList p_ForbidTAIList_Roaming := omit,
                                                                     template (omit) NG_TrackingAreaIdList p_ForbidTAIList_RegProvService := omit) :=
  { /* @status    APPROVED (NR5GC, NR5GC_IRAT) */
    /* 24.501 cl. 8.2.9 */
    registration_Reject := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_RegistrationReject, /* cl. 9.7      M V 1   */
      gmmCause                := p_Cause,                      /* cl. 9.11.3.2 M V 1   */
      t3346                   := p_T3346,                      /* cl. 9.11.2.4 O TLV 3 IEI=5F */
      t3502                   := p_T3502,                      /* cl. 9.11.2.4 O TLV 3 IEI=16 */
      eapMessage              := p_EAP,                        /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      rejectedNSSAI           := p_RejectedNSSAI,              /* cl. 9.11.3.46 O TLV 4-42 IEI=69 Sep20 @sic R5s201387 Baseline Moving sic@ */
      cagInfoList             := p_CAGInfoList,                 /* cl. 9.11.3.18A O TLV-E 3-n IEI=75 Sep20 @sic R5s201387 Baseline Moving sic@ */
      extdRejectedNSSAI            := p_ExtdRejectedNSSAI, /* cl. 9.11.3.75  O TLV 5-90 IEI=68 Sep22 @sic R5s221179 Baseline Moving sic@ */
      disasterReturnWaitRange      := p_DisasterReturnWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=2C Sep22 @sic R5s221179 Baseline Moving sic@ */
      extdCAGInfoList              := p_ExtdCAGInfoList, /* cl. 9.11.3.86  O TLV-E 3-n IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
      lowerBoundTimerValue         := p_LowerBoundTimerValue, /* cl. 9.11.2.5  O TLV 3 IEI=3A Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_Roaming        := p_ForbidTAIList_Roaming, /* cl. 9.11.3.9   O TLV 9-114 IEI=3B Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_RegProvService := p_ForbidTAIList_RegProvService /* cl. 9.11.3.9   O TLV 9-114 IEI=3C Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_UL_NAS_TRANSPORT (template (present) PayloadContainerType p_PayloadContainerType,
                                                                    template NG_PDU_SessionId p_PDU_SessionId,
                                                                    template NG_PDU_SessionId p_OldPDU_SessionId,
                                                                    template NG_Request_Type p_RequestType,
                                                                    template S_NSSAI_Type p_S_NSSAI,
                                                                    template DNN p_DNN,
                                                                    template AdditionalInformation p_AdditionalInfo,
                                                                    template MA_PDUSessionInfo p_MA_PDUSessionInfo,
                                                                    template ReleaseAssistanceInd p_ReleaseAssistanceInd) :=
  { /* 24.501 cl. 8.2.10 */
   /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    ul_Nas_Transport := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_UL_NASTransport,       /* cl. 9.7      M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,              /* cl. 9.5      M V 1/2 */
      payloadContainerType    := p_PayloadContainerType,          /* cl. 9.11.3.40 M V 1/2 */
      payload                 := cr_PayloadContainer,             /* cl. 9.11.3.39 M LV-E 3-65537 */
      pduSessionId            := p_PDU_SessionId,                 /* cl. 9.11.3.41 C TV 2 IEI=70 */
      oldPDUSessionId         := p_OldPDU_SessionId,              /* cl. 9.11.3.41 O TV 3 IEI=61 */
      requestType             := p_RequestType,                   /* cl. 9.`0.3.47 O TV 1 IEI=8 */
      s_NSSAI                 := p_S_NSSAI,                       /* cl. 9.11.2.8  O TLV 3-10 IEI=22 */
      dnn                     := p_DNN,                           /* cl. 9.11.3.21 O TLV 3-102 IEI=25 */
      additionalInfo          := p_AdditionalInfo,                /* cl. 9.11.2.1  O TLV 3-n IEI=24 */
      maPDUSessionInfo        := p_MA_PDUSessionInfo,             /* cl. 9.11.3.31A  O TV 1 IEI=A Sep20 @sic R5s201387 Baseline Moving sic@ */
      releaseAssistanceInd    := p_ReleaseAssistanceInd          /* cl. 9.11.3.46A  O TV 1 IEI=F Sep20 @sic R5s201387 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_DL_NAS_TRANSPORT(template (value) PayloadContainerType p_PayloadContainerType,
                                                                 template (value) PayloadContainer p_Payload,
                                                                 template (omit) NG_PDU_SessionId p_PDU_SessionId,
                                                                 template (omit) AdditionalInformation p_AdditionalInfo,
                                                                 template (omit) GMM_GSM_Cause p_Cause,
                                                                 template (omit) GPRS_Timer3 p_BackOff,
                                                                 template (omit) GPRS_Timer3 p_LowerBoundTimerValue) :=
  { /* 24.501 cl. 8.2.11 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    dl_Nas_Transport := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_DL_NASTransport,       /* cl. 9.7      M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,              /* cl. 9.5      M V 1/2 */
      payloadContainerType    := p_PayloadContainerType,          /* cl. 9.11.3.40 M V 1/2 */
      payload                 := p_Payload,                       /* cl. 9.11.3.39 M LV-E 3-65537 */
      pduSessionId            := p_PDU_SessionId,                 /* cl. 9.11.3.41 C TV 2 IEI=70 */
      additionalInfo          := p_AdditionalInfo,                /* cl. 9.11.2.1  O TLV 3-n IEI=24 */
      gmmCause                := p_Cause,                         /* cl. 9.11.3.2  O TV 2 IEI=58  */
      backOffTimerValue       := p_BackOff,                       /* cl. 9.11.2.5  O TLV 3 IEI=37 */
      lowerBoundTimerValue    := p_LowerBoundTimerValue           /* cl. 9.11.2.5  O TLV 3 IEI=3A Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_DEREGISTRATION_REQUEST_MO(template (present) DeregisterType p_DeregisterType,
                                                                            template (present) NAS_KeySetIdentifier p_KSI,
                                                                            template (present) NG_MobileIdentity p_MobileId) :=
  { /* 24.501 cl. 8.2.12 (UE originating deregister) */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    deregistration_RequestMO := {
      protocolDiscriminator   := tsc_EPD_GMM,                         /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,                  /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_DeregistrationRequest_MO,  /* cl. 9.7      M V 1   */
      ngKSI                   := p_KSI,                               /* cl. 9.11.3.32 M V 1/2 */
      deregistrationType      := p_DeregisterType,                    /* cl. 9.11.3.20  M V 1/2 */
      ngMobileId              := p_MobileId                           /* cl. 9.11.3.4   M LV 5-?  */
    }
  };

  template (value) NG_NAS_DL_Message_Type cs_NG_DEREGISTRATION_ACCEPT :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.13/15 (DL) */
    deregistration_Accept := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_DeregistrationAccept_MO /* cl. 9.7      M V 1   */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_DEREGISTRATION_ACCEPT :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.2.13/15 (UL) */
    deregistration_Accept := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_DeregistrationAccept_MT /* cl. 9.7      M V 1   */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_DEREGISTRATION_REQUEST_MT (template (value) DeregisterType p_Type,
                                                                           template (omit) GMM_GSM_Cause p_Cause,
                                                                           template (omit) GPRS_Timer2 p_T3346 := omit,
                                                                           template (omit) RejectedNSSAI p_RejectedNSSAI := omit,
                                                                           template (omit) CAGInfoList p_CAGInfoList := omit,
                                                                           template (omit) ExtdRejectedNSSAI p_ExtdRejectedNSSAI := omit,
                                                                           template (omit) RegistrationWaitRange p_DisasterReturnWaitRange := omit,
                                                                           template (omit) ExtdCAGInfoList p_ExtdCAGInfoList := omit,
                                                                           template (omit) GPRS_Timer3 p_LowerBoundTimerValue := omit,
                                                                           template (omit) NG_TrackingAreaIdList p_ForbidTAIList_Roaming := omit,
                                                                           template (omit) NG_TrackingAreaIdList p_ForbidTAIList_RegProvService := omit) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.2.14 (UE terminated deregister) */
    deregistration_RequestMT := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_DeregistrationRequest_MT, /* cl. 9.7      M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      deregistrationType      := p_Type,                       /* cl. 9.11.3.20  M V 1/2 */
      gmmCause                := p_Cause,                      /* cl. 9.11.3.2   O TV 2 IEI=058 */
      t3346                   := p_T3346,                      /* cl. 9.11.2.4   O TLV 3 IEI=5F */
      rejectedNSSAI           := p_RejectedNSSAI,              /* cl. 9.11.3.46 O TLV 4-42 IEI=69 Sep20 @sic R5s201387 Baseline Moving sic@ */
      cagInfoList             := p_CAGInfoList,                /* cl. 9.11.3.18A O TLV-E 3-n IEI=75 Sep20 @sic R5s201387 Baseline Moving sic@ */
      extdRejectedNSSAI            := p_ExtdRejectedNSSAI, /* cl. 9.11.3.75  O TLV 5-90 IEI=68 Sep22 @sic R5s221179 Baseline Moving sic@ */
      disasterReturnWaitRange      := p_DisasterReturnWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=2C Sep22 @sic R5s221179 Baseline Moving sic@ */
      extdCAGInfoList              := p_ExtdCAGInfoList, /* cl. 9.11.3.86  O TLV-E 3-n IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
      lowerBoundTimerValue         := p_LowerBoundTimerValue, /* cl. 9.11.2.5  O TLV 3 IEI=3A Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_Roaming        := p_ForbidTAIList_Roaming, /* cl. 9.11.3.9   O TLV 9-114 IEI=3B Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_RegProvService := p_ForbidTAIList_RegProvService /* cl. 9.11.3.9   O TLV 9-114 IEI=3C Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_CP_SERVICE_REQUEST (template (present) NAS_KeySetIdentifier p_NAS_KeySetIdentifier,
                                                                      template (present) CP_ServiceType p_CP_ServiceType,
                                                                      template CIoTSmallDataRxdString p_CIoTSmallDataContainer,
                                                                      template PayloadContainerType p_PayloadContainerType,
                                                                      template PayloadContainer p_PayloadContainer,
                                                                      template NG_PDU_SessionId p_NG_PDU_SessionId,
                                                                      template PDU_SessionStatus p_PDU_SessionStatus,
                                                                      template ReleaseAssistanceInd p_ReleaseAssistanceInd,
                                                                      template ULDataStatus p_ULDataStatus,
                                                                      template AdditionalInformation p_AdditionalInfo,
                                                                      template AllowedPDU_SessionStatus p_AllowedPDU_SessionStatus,
                                                                      template NASMessageContainer p_NASMsg,
                                                                      template UE_RequestType p_UeRequestType,
                                                                      template NG_PagingRestriction p_PagingRestrict) :=
  {               /* 24.501 cl. 8.2.30         @sic R5s201387 Baseline Moving sic@ */
    cp_Service_Request := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_CP_Service_Request,    /* cl. 9.7        M V 1   */
      ngKSI                   := p_NAS_KeySetIdentifier,          /* cl. 9.11.3.32  M V 1/2 */
      cpServiceType           := p_CP_ServiceType,                /* cl. 9.11.3.18D M V 1/2 */
      cIoTSmallDataContainer  := p_CIoTSmallDataContainer,        /* cl. 9.11.3.18B O TLV 4-257 IEI=6F  */
      payloadContainerType    := p_PayloadContainerType,          /* cl. 9.11.3.40  O TV 1 IEI=8 */
      payload                 := p_PayloadContainer,              /* cl. 9.11.3.39  O TLV-E 4-65538 IEI=7B */
      pduSessionId            := p_NG_PDU_SessionId,              /* cl. 9.11.3.41  C TV 2 IEI=12 */
      pduSessionStatus        := p_PDU_SessionStatus,             /* cl. 9.11.2.44 O TLV 4-34 IEI=50 */
      releaseAssistanceInd    := p_ReleaseAssistanceInd,          /* cl. 9.11.3.46A  O TV 1 IEI=F */
      ulDataStatus            := p_ULDataStatus,                  /* cl. 9.11.2.57 O TLV 4-34 IEI=40 */
      nasMsg                  := p_NASMsg,                        /* cl. 9.11.3.33 O TLV-E 3-n IEI=71 */
      additionalInfo          := p_AdditionalInfo,                /* cl. 9.11.2.1  O TLV 3-n IEI=24 */
      allowedPDUSessionStatus := p_AllowedPDU_SessionStatus,      /* cl. 9.11.3.13 O TLV 4-34 IEI=25 Sep22 @sic R5s221179 Baseline Moving sic@ */
      ueRequestType           := p_UeRequestType,                 /* cl. 9.11.3.76  O TLV 3 IEI=29 Sep22 @sic R5s221179 Baseline Moving sic@ */
      pagingRestrict          := p_PagingRestrict                 /* cl. 9.11.3.77  O TLV 3-35 IEI=28 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_SERVICE_REQUEST (template (present) B4_Type p_ServiceType,
                                                                   template (present) NAS_KeySetIdentifier p_KSI,
                                                                   template (present) NG_MobileIdentity p_S_TMSI,
                                                                   template ULDataStatus p_ULDataStatus,
                                                                   template PDU_SessionStatus p_PDU_SessionStatus,
                                                                   template AllowedPDU_SessionStatus p_AllowedPDU_SessionStatus,
                                                                   template NASMessageContainer p_Msg,
                                                                   template UE_RequestType p_UeRequestType,
                                                                   template NG_PagingRestriction p_PagingRestrict):=
  { /* 24.501 cl. 8.2.16 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    service_Request          := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_ServiceRequest,     /* cl. 9.7      M V 1   */
      serviceType             := p_ServiceType,                /* cl. 9.11.3.50 M V 1/2 */
      ngKSI                   := p_KSI,                        /* cl. 9.11.3.32 M V 1/2 */
      s_TMSI                  := p_S_TMSI,                     /* cl. 9.11.3.4  M LV 6  */
      ulDataStatus            := p_ULDataStatus,               /* cl. 9.11.2.57 O TLV 4-34 IEI=40 */
      pduSessionStatus        := p_PDU_SessionStatus,          /* cl. 9.11.2.44 O TLV 4-34 IEI=50 */
      allowedPDUSessionStatus := p_AllowedPDU_SessionStatus,   /* cl. 9.11.3.13 O TLV 4-34 IEI=25 */
      nasMsg                  := p_Msg,                        /* cl. 9.11.3.33 O TLV-E 4-n IEI=71 Dec18 */
      ueRequestType           := p_UeRequestType,              /* cl. 9.11.3.76  O TLV 3 IEI=29 Sep22 @sic R5s221179 Baseline Moving sic@ */
      pagingRestrict          := p_PagingRestrict              /* cl. 9.11.3.77  O TLV 3-35 IEI=28 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_SERVICE_ACCEPT (template (omit) PDU_SessionStatus p_PDU_SessionStatus,
                                                                template (omit) PDU_SessionReactivationResult p_PDU_SessionReactivationResult,
                                                                template (omit) PDU_SessionReactivationError p_PDU_SessionReactivationError,
                                                                template (omit) EAP_Message p_EAP,
                                                                template (omit) GPRS_Timer2 p_T3448,
                                                                template (omit) NG_AddReqResult p_AddRequestResult,
                                                                template (omit) NG_TrackingAreaIdList p_ForbidTAIList_Roaming,
                                                                template (omit) NG_TrackingAreaIdList p_ForbidTAIList_RegProvService) :=
  { /* 24.501 cl. 8.2.17 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    service_Accept := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_ServiceAccept,      /* cl. 9.7      M V 1   */
      pduSessionStatus        := p_PDU_SessionStatus,          /* cl. 9.11.2.44 O TLV 4-34 IEI=50 */
      pduSessionReactivationResult  := p_PDU_SessionReactivationResult, /* cl. 9.11.3.42 O TLV 4-32 IEI=26 */
      pduSessionReactResultError    := p_PDU_SessionReactivationError,  /* cl. 9.11.3.43 O TLV-E 5-515 IEI=7E */
      eapMessage                    := p_EAP,                        /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78*/
      t3448                         := p_T3448,                      /* cl. 9.11.2.4  O TLV 3 IEI=6B Sep20 @sic R5s201387 Baseline Moving sic@ */
      ngAddRequestResult            := p_AddRequestResult, /* cl. 9.11.3.81  O TLV 3 IEI=34 Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_Roaming         := p_ForbidTAIList_Roaming, /* cl. 9.11.3.9   O TLV 9-114 IEI=1D Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_RegProvService  := p_ForbidTAIList_RegProvService /* cl. 9.11.3.9   O TLV 9-114 IEI=1E Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_SERVICE_REJECT (template (value) GMM_GSM_Cause p_Cause,
                                                                template (omit) PDU_SessionStatus p_PDU_SessionStatus,
                                                                template (omit) GPRS_Timer2 p_T3346,
                                                                template (omit) EAP_Message p_EAP,
                                                                template (omit) GPRS_Timer2 p_T3448,
                                                                template (omit) CAGInfoList p_CAGInfoList,
                                                                template (omit) RegistrationWaitRange p_DisasterReturnWaitRange,
                                                                template (omit) ExtdCAGInfoList p_ExtdCAGInfoList,
                                                                template (omit) GPRS_Timer3 p_LowerBoundTimerValue,
                                                                template (omit) NG_TrackingAreaIdList p_ForbidTAIList_Roaming,
                                                                template (omit) NG_TrackingAreaIdList p_ForbidTAIList_RegProvService) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.18 */
    service_Reject := {
      protocolDiscriminator   := tsc_EPD_GMM,                  /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,           /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_ServiceReject,       /* cl. 9.7      M V 1   */
      gmmCause                := p_Cause,                      /* cl. 9.11.3.2  M V 1   */
      pduSessionStatus        := p_PDU_SessionStatus,          /* cl. 9.11.2.44 O TLV 4-34 IEI=50 */
      t3346                   := p_T3346,                      /* cl. 9.11.2.4   O TLV 3 IEI=5F */
      eapMessage              := p_EAP,                        /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      t3448                   := p_T3448,                      /* cl. 9.11.2.4  O TLV 3 IEI=6B Sep20 @sic R5s201387 Baseline Moving sic@ */
      cagInfoList             := p_CAGInfoList,                /* cl. 9.11.3.18A O TLV-E 3-n IEI=75 Sep20 @sic R5s201387 Baseline Moving sic@ */
      disasterReturnWaitRange      := p_DisasterReturnWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=2C Sep22 @sic R5s221179 Baseline Moving sic@ */
      extdCAGInfoList              := p_ExtdCAGInfoList, /* cl. 9.11.3.86  O TLV-E 3-n IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
      lowerBoundTimerValue         := p_LowerBoundTimerValue, /* cl. 9.11.2.5  O TLV 3 IEI=3A Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_Roaming        := p_ForbidTAIList_Roaming, /* cl. 9.11.3.9   O TLV 9-114 IEI=3B Sep22 @sic R5s221179 Baseline Moving sic@ */
      forbidTAIList_RegProvService := p_ForbidTAIList_RegProvService /* cl. 9.11.3.9   O TLV 9-114 IEI=3C Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_CONFIGURATION_UPDATE_COMMAND (template (omit) ConfigUpdateInd p_ConfigUpdateInd := omit,
                                                                              template (omit) NG_MobileIdentity p_Guti := omit,
                                                                              template (omit) NG_TrackingAreaIdList p_TaiList := omit,
                                                                              template (omit) NSSAI p_AllowedNSSAI := omit,
                                                                              template (omit) ServiceAreaIdList p_SaiList := omit,
                                                                              template (omit) NetworkName p_FullNetworkName := omit,
                                                                              template (omit) NetworkName p_ShortNetworkName := omit,
                                                                              template (omit) TimeZone p_LocalTimeZone := omit,
                                                                              template (omit) TimeZoneAndTime p_LocalTimeZoneAndTime := omit,
                                                                              template (omit) DaylightSavingTime p_DaylightSavingTime := omit,
                                                                              template (omit) LADN_Info p_LadnInfo := omit,
                                                                              template (omit) MICO_Ind p_MicoInd := omit,
                                                                              template (omit) NetworkSlicingInd p_NetworkSlicingInd := omit,
                                                                              template (omit) NSSAI p_ConfiguredNSSAI := omit,
                                                                              template (omit) RejectedNSSAI p_RejectedNSSAI := omit,
                                                                              template (omit) OperatorAccessCatDefinitions p_OperatorAccessCatDefs := omit,
                                                                              template (omit) SMSInd p_SmsInd := omit,
                                                                              template (omit) GPRS_Timer3 p_T3447 := omit,
                                                                              template (omit) CAGInfoList p_CAGInfoList := omit,
                                                                              template (omit) UERadioCapId p_UERadioCapId := omit,
                                                                              template (omit) UERadioCapIdDeletion p_UERadioCapIdDeletion := omit,
                                                                              template (omit) RegistrationResult p_RegistrationResult := omit,
                                                                              template (omit) TruncatedS_TMSIConfig p_TruncatedS_TMSIConfig := omit,
                                                                              template (omit) AddConfigInfo p_AddConfigInfo := omit,
                                                                              template (omit) ExtdRejectedNSSAI p_ExtdRejectedNSSAI := omit,
                                                                              template (omit) ServiceLvlAAContainer p_ServiceLvlAA := omit,
                                                                              template (omit) NSSRG_Info p_NssrgInfo := omit,
                                                                              template (omit) RegistrationWaitRange p_DisasterRoamingWaitRange := omit,
                                                                              template (omit) RegistrationWaitRange p_DisasterReturnWaitRange := omit,
                                                                              template (omit) DisasterPLMNList p_DisasterPLMNList := omit,
                                                                              template (omit) ExtdCAGInfoList p_ExtdCAGInfoList := omit,
                                                                              template (omit) PEIPS_AssistInfo p_UpdatedPEIPS_AssistInfo := omit,
                                                                              template (omit) NSAG_Info p_NsagInfo := omit,
                                                                              template (omit) PriorityInd p_PriorityInd := omit) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.19.1 */
   configuration_Update_Command := {
    protocolDiscriminator   := tsc_EPD_GMM ,                              /* cl. 9.2       M V 1   */
    spareHalfOctet          := tsc_SpareHalfOctet,                        /* cl. 9.5       M V 1/2 */
    securityHeaderType      := tsc_SHT_NoSecurityProtection,              /* cl. 9.3       M V 1/2 */
    messageType             := tsc_MT_NG_ConfigurationUpdateCommand,      /* cl. 9.7       M V 1   */
    configUpdateInd         := p_ConfigUpdateInd,                         /* cl. 9.11.3.18 M TV 1 IEI=D */
    guti                    := p_Guti,                                    /* cl. 9.11.3.4  O TLV 13 IEI=77 Dec18 */
    taiList                 := p_TaiList,                                 /* cl. 9.11.3.9  O TLV 9-114 IEI=54 */
    allowedNSSAI            := p_AllowedNSSAI,                            /* cl. 9.11.3.37 O TLV 4-74 IEI=15 */
    saiList                 := p_SaiList,                                 /* cl. 9.11.3.49 O TLV 6-114 IEI=27 */
    fullNetworkName         := p_FullNetworkName,                         /* cl. 9.11.3.35 O TLV 3-? IEI=43 */
    shortNetworkName        := p_ShortNetworkName,                        /* cl. 9.11.3.35 O TLV 3-? IEI=45 */
    localTimeZone           := p_LocalTimeZone,                           /* cl. 9.11.3.52 O TV 2    IEI=46 */
    localTimeZoneAndTime    := p_LocalTimeZoneAndTime,                    /* cl. 9.11.3.53 O TV 8    IEI=47 */
    daylightSavingTime      := p_DaylightSavingTime,                      /* cl. 9.11.3.19 O TLV 3   IEI=49 */
    ladnInfo                := p_LadnInfo,                                /* cl. 9.11.3.30 O TLV-E 3-1715 IEI=79 */
    micoInd                 := p_MicoInd,                                 /* cl. 9.11.3.31 O TLV 1 IEI=B */
    networkSlicingInd       := p_NetworkSlicingInd,                       /* cl. 9.11.3.36 O TV 1 IEI=9 */
    configuredNSSAI         := p_ConfiguredNSSAI,                         /* cl. 9.11.3.37 O TLV 4-146 IEI=31 */
    rejectedNSSAI           := p_RejectedNSSAI,                           /* cl. 9.11.3.46 O TLV 4-42 IEI=11 */
    operatorAccessCatDefs   := p_OperatorAccessCatDefs,                   /* cl. 9.11.3.38 O TLV-E 4-n IEI=76 Dec18 */
    smsInd                  := p_SmsInd,                                  /* cl. 9.10.3.50A O TV 1 IEI=F Dec18 */
    t3447Value              := p_T3447,                                   /* cl. 9.11.2.5   O TLV 3 IEI=6C Sep20 @sic R5s201387 Baseline Moving sic@ */
    cagInfoList             := p_CAGInfoList,                             /* cl. 9.11.3.18A O TLV-E 3-n IEI=75 Sep20 @sic R5s201387 Baseline Moving sic@ */
    ueRadioCapabilityId     := p_UERadioCapId,                            /* cl. 9.11.3.68  O TLV 3-n IEI=67 Sep20 @sic R5s201387 Baseline Moving sic@ */
    ueRadioCapIdDeletionInd := p_UERadioCapIdDeletion,                    /* cl. 9.11.3.69  O TV  1 IEI=E Sep20 @sic R5s201387 Baseline Moving sic@ */
    registrationResult      := p_RegistrationResult,                      /* cl. 9.11.3.6   O TLV 3 IEI=44 Sep20 @sic R5s201387 Baseline Moving sic@ */
    truncatedS_TMSIConfig   := p_TruncatedS_TMSIConfig,                   /* cl. 9.11.3.70  O TLV 3 IEI=1B Sep20 @sic R5s201387 Baseline Moving sic@ */
    addConfigInfo           := p_AddConfigInfo,                           /* cl. 9.11.3.74  O TV  1 IEI=C Sep20 @sic R5s201387 Baseline Moving sic@ */
    extdRejectedNSSAI            := p_ExtdRejectedNSSAI, /* cl. 9.11.3.75  O TLV 5-90 IEI=68 Sep22 @sic R5s221179 Baseline Moving sic@ */
    serviceLvlAA                 := p_ServiceLvlAA, /* cl. 9.11.2.10  O TLV-E 6-n IEI=7B Sep22 @sic R5s221179 Baseline Moving sic@ */
    nssrgInfo                    := p_NssrgInfo, /* cl. 9.11.3.82  O TLV-E 7-65538 IEI=70 Sep22 @sic R5s221179 Baseline Moving sic@ */
    disasterRoamingWaitRange     := p_DisasterRoamingWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=14 Sep22 @sic R5s221179 Baseline Moving sic@ */
    disasterReturnWaitRange      := p_DisasterReturnWaitRange, /* cl. 9.11.3.84  O TLV 4 IEI=2C Sep22 @sic R5s221179 Baseline Moving sic@ */
    disasterPLMNList             := p_DisasterPLMNList, /* cl. 9.11.3.83  O TLV 2-n IEI=13 Sep22 @sic R5s221179 Baseline Moving sic@ */
    extdCAGInfoList              := p_ExtdCAGInfoList, /* cl. 9.11.3.86  O TLV-E 3-n IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
    updatedPEIPS_AssistInfo      := p_UpdatedPEIPS_AssistInfo, /* cl. 9.11.3.80  O TLV 3-n IEI=33 Sep22 @sic R5s221179 Baseline Moving sic@ */
    nsagInfo                     := p_NsagInfo,  /* cl. 9.11.3.87  O TLV-E 10-n IEI=7C Sep22 @sic R5s221179 Baseline Moving sic@ */
    priorityInd                  := p_PriorityInd  /* cl. 9.11.3.91  O TV  1 IEI=E- Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  }

  template (present) NG_NAS_UL_Message_Type cr_NG_CONFIGURATION_UPDATE_COMPLETE :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.20 */
   configuration_Update_Complete := {
    protocolDiscriminator   := tsc_EPD_GMM ,                              /* cl. 9.2       M V 1   */
    spareHalfOctet          := tsc_SpareHalfOctet,                        /* cl. 9.5       M V 1/2 */
    securityHeaderType      := tsc_SHT_NoSecurityProtection,              /* cl. 9.3       M V 1/2 */
    messageType             := tsc_MT_NG_ConfigurationUpdateComplete      /* cl. 9.7       M V 1   */
   }
  };

    template (value) NG_NAS_DL_Message_Type cs_NG_IDENTITY_REQUEST(NAS_IdType p_IdType) :=
    { /* @status    APPROVED (NR5GC) */
      identity_Request :={
        protocolDiscriminator   := tsc_EPD_GMM,
        spareHalfOctet          := tsc_SpareHalfOctet,
        securityHeaderType      := tsc_SHT_NoSecurityProtection,
        messageType             := tsc_MT_NG_IdentityRequest,
        spareHalfOctet2         := tsc_SpareHalfOctet,
        identityType            := cs_IdentityType(p_IdType)
      }
    };

   template (present) NG_NAS_UL_Message_Type cr_NG_IDENTITY_RESPONSE(template (present) NG_MobileIdentity p_MobileId) :=
   { /* @status    APPROVED (NR5GC) */
      identity_Response :={
        protocolDiscriminator   := tsc_EPD_GMM,
        spareHalfOctet          := tsc_SpareHalfOctet,
        securityHeaderType      := tsc_SHT_NoSecurityProtection,
        messageType             := tsc_MT_NG_IdentityResponse,
        ngMobileId              := p_MobileId
      }
    };

  template (omit) NG_NAS_DL_Message_Type cs_NG_SECURITY_MODE_COMMAND(template (value) NG_NAS_SecurityAlgorithms p_Algs,
                                                                      NAS_KsiValue p_KeySetId,
                                                                      NG_UE_SecurityCapability p_UECap,
                                                                      template (omit) IMEISV_Request p_IMEISV,
                                                                      template (omit) NAS_SecurityAlgorithms p_EPSAlgs,
                                                                      template (omit) AdditionalSecurityInfo p_AddInfo,
                                                                      template (omit) EAP_Message p_EAP,
                                                                      template (omit) ABBA p_ABBA,
                                                                      template (omit) S1_UE_SecurityCapability p_ReplayedSecurityCap) :=
  { /* 24.501 cl. 8.2.25 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    security_Mode_Command := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_SecurityModeCommand,   /* cl. 9.7      M V 1   */
      nasSecurityAlgorithms   := p_Algs,                          /* cl. 9.11.3.34 M V 1   */
      spareHalfOctet2         := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      ngNasKSI                := cs_NAS_KeySetIdentifier_lv(p_KeySetId, tsc_NasKsi_NativeSecurityContext), /* cl. 9.11.3.32 M V 1/2 */
      ueSecurityCapability    := p_UECap,                         /* cl. 9.11.3.54 M LV 3-9 */
      imeisvRequest           := p_IMEISV,                        /* cl. 9.11.3.28 O TV 1 IEI=E */
      epsSecurityAlgorithms   := p_EPSAlgs,                       /* cl. 9.11.3.25 O TV 2 IEI=57 */
      add5GSecurityInfo       := p_AddInfo,                       /* cl. 9.11.3.12 O TLV 3 IEI=36 */
      eapMessage              := p_EAP,                           /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      abba                    := p_ABBA,                          /* cl. 9.11.3.10 O TLV 4-n IEI=38 Dec18 */
      replayedUESecurityCap   := p_ReplayedSecurityCap            /* cl. 9.11.3.48 O TLV 4-7 IEI=19 Dec18 */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_SECURITY_MODE_COMPLETE (template (present) NG_MobileIdentity p_IMEISV,
                                                                          template (present) ReplayedNASMessageContainer p_NASMsg,
                                                                          template (present) NG_MobileIdentity p_NonIMEISV_PEI) :=
  { /* 24.501 cl. 8.2.26 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    security_Mode_Complete := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_SecurityModeComplete,  /* cl. 9.7      M V 1   */
      imeisv                  := p_IMEISV,                        /* cl. 9.11.3.4  O TLV 11 IEI=2C  */
      nasMsg                  := p_NASMsg,                        /* cl. 9.11.3.33 O TLV-E 3-n IEI=7D */
      nonIMEISV_PEI           := p_NonIMEISV_PEI                  /* cl. 9.11.3.4  O TLV-E 7-n IEI=78 Sep20 @sic R5s201387 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_SECURITY_MODE_REJECT (template (present) GMM_GSM_Cause p_Cause) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.2.27 */
    security_Mode_Reject := {
      protocolDiscriminator   := tsc_EPD_GMM,                     /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,              /* cl. 9.3      M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,
      messageType             := tsc_MT_NG_SecurityModeReject,    /* cl. 9.7      M V 1   */
      gmmCause                := p_Cause                          /* cl. 9.11.3.2  M V 1   */
    }
  };

  //----------------------------------------------------------------------------
  // NG session management messages (24.501 cl. 8.3)
  //----------------------------------------------------------------------------

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_ESTABLISHMENT_REQUEST(template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                    template (present) ProcedureTransactionIdentifier p_PTI,
                                                                                    template PDU_SessionType p_PDU_SessionType,
                                                                                    template SSC_Mode p_SSC_Mode,
                                                                                    template NG_UE_SM_Cap p_UECap,
                                                                                    template MaxNumPacketFilters p_MaxNumPacketFilters,
                                                                                    template IntegrityProtMaxDataRate p_IntegrityProtMaxDataRate,
                                                                                    template AlwaysOnPDUSessionReq p_AlwaysOnPDUSessionReq,
                                                                                    template SM_PDU_DN_RequestContainer p_PDUReq,
                                                                                    template ExtdProtocolConfigOptions p_ExtdPCO,
                                                                                    template IPHeaderCompressionConfig p_IPHeaderCompConfig,
                                                                                    template DS_TT_EthernetPortMACAddr p_DS_TT_EthernetPortMACAddr,
                                                                                    template UE_DS_TT_ResidenceTime p_UE_DS_TT_ResidenceTime,
                                                                                    template PortManagementInfoContainer p_PortManagementInfoContainer,
                                                                                    template EthernetHeaderCompressConfig p_EthernetHeaderCompConfig,
                                                                                    template PDU_Address p_SuggestedInterfaceId,
                                                                                    template ServiceLvlAAContainer p_ServiceLvlAA,
                                                                                    template RequestedMBSContainer p_RequestedMBS,
                                                                                    template PDUSessionPairId p_PduSessionPairId,
                                                                                    template RSN p_RSN) :=
  { /* 24.501 cl. 8.3.1 */
   /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    pdu_Session_Establishment_Request := {
      protocolDiscriminator         := tsc_EPD_GSM,                     /* cl. 9.2       M V 1   */
      pduSessionId                  := p_PDU_SessionId,                 /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                   /* cl. 9.6       M V 1   */
      messageType                   := tsc_MT_NG_PDUSessionEstablishmentRequest, /* cl. 9.7       M V 1   */
      integrityProtMaxDataRate      := p_IntegrityProtMaxDataRate,     /* cl. 9.11.4.7  M V 2 */
      pduSessionType                := p_PDU_SessionType,               /* cl. 9.11.4.11 O TV 1 IEI=9 */
      sscMode                       := p_SSC_Mode,                      /* cl. 9.11.4.16 O TV 1 IEI=A */
      smCapability                  := p_UECap,                         /* cl. 9.11.4.1  O TLV 3-15 IEI=28 */
      maxNumPacketFilters           := p_MaxNumPacketFilters,           /* cl. 9.11.4.6  O TV 3 IEI=55 */
      alwaysOnPDUSessionReq         := p_AlwaysOnPDUSessionReq,         /* cl. 9.11.4.4  O TV 1 IEI=B */
      smPDU_RequestContainer        := p_PDUReq,                        /* cl. 9.11.4.15 O TLV ? ? */
      extdProtocolConfigurationOptions := p_ExtdPCO,                    /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      ipHeaderCompressionConfig     := p_IPHeaderCompConfig,            /* cl. 9.11.4.24   O TLV 5-257 IEI=66 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ds_TT_EthernetPortMACAddr     := p_DS_TT_EthernetPortMACAddr,     /* cl. 9.11.4.25  O TLV 8 IEI=6E Sep20 @sic R5s201387 Baseline Moving sic@ */
      ueDS_TT_ResidenceTime         := p_UE_DS_TT_ResidenceTime,        /* cl. 9.11.4.26  O TLV 10 IEI=6F Sep20 @sic R5s201387 Baseline Moving sic@ */
      portManagementInfoContainer   := p_PortManagementInfoContainer,   /* cl. 9.11.4.27  O TLV-E 8-65538 IEI=7C Sep20 @sic R5s201387 Baseline Moving sic@ */
      ethernetHeaderCompressConfig  := p_EthernetHeaderCompConfig,      /* cl. 9.11.4.28  O TLV 3 IEI=1F Sep20 @sic R5s201387 Baseline Moving sic@ */
      suggestedInterfaceId          := p_SuggestedInterfaceId,          /* cl. 9.11.4.10  O TLV 11 IEI=29 Sep20 @sic R5s201387 Baseline Moving sic@ */
      serviceLvlAA                  := p_ServiceLvlAA,                  /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
      requestedMBS                  := p_RequestedMBS,                  /* cl. 9.11.4.30  O TLV-E 8-65538 IEI=70 Sep22 @sic R5s221179 Baseline Moving sic@ */
      pduSessionPairId              := p_PduSessionPairId,              /* cl. 9.11.4.32  O TLV 3 IEI=34 Sep22 @sic R5s221179 Baseline Moving sic@ */
      rsn                           := p_RSN                            /* cl. 9.11.4.33  O TLV 3 IEI=35 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_ESTABLISHMENT_ACCEPT (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                                  ProcedureTransactionIdentifier p_PTI,
                                                                                  template (value) SSC_Mode p_SSC_Mode,
                                                                                  template (value) PDU_SessionType p_PDU_SessionType,
                                                                                  template (value) QoS_Rules p_QoS_Rules,
                                                                                  template (value) Session_AMBR p_Session_AMBR,
                                                                                  template (omit) GMM_GSM_Cause p_Cause,
                                                                                  template (omit) PDU_Address p_PDU_Address,
                                                                                  template (omit) GPRS_Timer p_RQTimer,
                                                                                  template (omit) S_NSSAI_Type p_S_NSSAI,
                                                                                  template (omit) AlwaysOnPDUSessionInd p_AlwaysOnPDUSessionInd,
                                                                                  template (omit) MappedEPSBearerContexts p_MappedEPSBearerContexts,
                                                                                  template (omit) EAP_Message p_EAP,
                                                                                  template (omit) QoSFlowDescr p_QoSFlowDescr,
                                                                                  template (omit) ExtdProtocolConfigOptions p_ExtdPCO,
                                                                                  template (omit) DNN p_DNN,
                                                                                  template (omit) NGSM_NetworkFeatureSupport p_NGSM_NtwkFeatSupport,
                                                                                  template (omit) ServingPLMNRateControl p_ServingPLMNRateCtrl,
                                                                                  template (omit) ATSSSContainer p_ATSSSContainer,
                                                                                  template (omit) ControlPlaneInd p_ControlPlaneInd,
                                                                                  template (omit) IPHeaderCompressionConfig p_IPHeaderCompConfig,
                                                                                  template (omit) EthernetHeaderCompressConfig p_EthernetHeaderCompConfig,
                                                                                  template (omit) ServiceLvlAAContainer p_ServiceLvlAA,
                                                                                  template (omit) ReceivedMBSContainer p_ReceivedMBS) :=
  { /* 24.501 cl. 8.3.2 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    pdu_Session_Establishment_Accept := {
      protocolDiscriminator   := tsc_EPD_GSM,                 /* cl. 9.2       M V 1   */
      pduSessionId            := p_PDU_SessionId,             /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,               /* cl. 9.6       M V 1   */
      messageType             := tsc_MT_NG_PDUSessionEstablishmentAccept, /* cl. 9.7       M V 1   */
      sscMode                 := p_SSC_Mode,                  /* cl. 9.11.4.16 M V 1/2 */
      pduSessionType          := p_PDU_SessionType,           /* cl. 9.11.4.11 M V 1/2 */
      authorizedQoSRules      := p_QoS_Rules,                 /* cl. 9.11.4.13 M LV-E 7-65538 */
      sessionAMBR             := p_Session_AMBR,              /* cl. 9.11.4.14 M LV ? */
      gsmCause                := p_Cause,                     /* cl. 9.11.4.2  O TV 2 IEI=59 */
      pduAddress              := p_PDU_Address,               /* cl. 9.11.4.10 O TLV 7-15 IEI=29 */
      rqTimerValue            := p_RQTimer,                   /* cl. 9.11.2.3  O TLV 2 IEI=56 */
      s_NSSAI                 := p_S_NSSAI,                   /* cl. 9.11.2.6  O TLV 3-10 IEI=22 */
      alwaysOnPDUSessionInd   := p_AlwaysOnPDUSessionInd,     /* c.  9.11.4.3  O TV 1 IEI=8 */
      mappedEPSContexts       := p_MappedEPSBearerContexts,   /* cl. 9.11.4.9  O TLV-E 7-65538 IEI=7F */
      eapMessage              := p_EAP,                       /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      authorizedQoSFlowDescr  := p_QoSFlowDescr,              /* cl. 9.11.4.12  O TLV-E 6-65538 IEI=79 */
      extdProtocolConfigurationOptions := p_ExtdPCO,          /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      dnn                     := p_DNN,                       /* cl. 9.11.2.1A O TLV 3-102 IEI=25 */
      ngs_NetworkFeatureSupport     := p_NGSM_NtwkFeatSupport,  /* cl. 9.11.4.18 O TLV 3-15  IEI=17 Sep20 @sic R5s201387 Baseline Moving sic@ */
      servingPLMNRateControl        := p_ServingPLMNRateCtrl,  /* cl. 9.11.4.20 O TLV 4  IEI=18 Sep20 @sic R5s201387 Baseline Moving sic@ */
      atsssContainer                := p_ATSSSContainer,  /* cl. 9.11.4.22 O TLV-E 3-65538  IEI=77 Sep20 @sic R5s201387 Baseline Moving sic@ */
      controlPlaneOnlyIndication    := p_ControlPlaneInd,  /* cl. 9.11.4.23 O TV 1  IEI=C Sep20 @sic R5s201387 Baseline Moving sic@ */
      ipHeaderCompressionConfig     := p_IPHeaderCompConfig,  /* cl. 9.11.4.24 O TLV 5-257 IEI=66 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ethernetHeaderCompressConfig  := p_EthernetHeaderCompConfig,   /* cl. 9.11.4.28 O TLV 3 IEI=1F Sep20 @sic R5s201387 Baseline Moving sic@ */
      serviceLvlAA                  := p_ServiceLvlAA,                  /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
      receivedMBS                   := p_ReceivedMBS                  /* cl. 9.11.4.30  O TLV-E 8-65538 IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_ESTABLISHMENT_REJECT (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                                  template (value) ProcedureTransactionIdentifier p_PTI,
                                                                                  template (value) GMM_GSM_Cause p_Cause,
                                                                                  template (omit) GPRS_Timer3 p_BackOff,
                                                                                  template (omit) AllowedSSCMode p_SSC_Mode,
                                                                                  template (omit) EAP_Message p_EAP,
                                                                                  template (omit) ExtdProtocolConfigOptions p_ExtdPCO,
                                                                                  template (omit) ReAttemptIndicator p_ReAttemptIndicator,
                                                                                  template (omit) NGSM_CongestionReattemptInd p_NGSM_CongestionReattemptInd, // @sic R5s190543 sic@
                                                                                  template (omit) ServiceLvlAAContainer p_ServiceLvlAA ) :=
  { /* 24.501 cl. 8.3.3 */
    /* @status    APPROVED (NR5GC) */
    pdu_Session_Establishment_Reject := {
      protocolDiscriminator   := tsc_EPD_GSM,                 /* cl. 9.2       M V 1   */
      pduSessionId            := p_PDU_SessionId,             /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,               /* cl. 9.6       M V 1   */
      messageType             := tsc_MT_NG_PDUSessionEstablishmentReject, /* cl. 9.7       M V 1   */
      gsmCause                := p_Cause,                     /* cl. 9.11.4.2  M V 1   */
      backOffTimerValue       := p_BackOff,                   /* cl. 9.11.2.5  O TLV 3 IEI=37 */
      allowedSSCMode          := p_SSC_Mode,                  /* cl. 9.11.4.5  O TV  1 IEI=F */
      eapMessage              := p_EAP,                       /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      ngsmCongestionReattemptInd  := p_NGSM_CongestionReattemptInd,  /* cl. 9.11.4.2A O TLV 3 IEI=61 Jun19 @sic R5s201387, R5s210444 Baseline Moving sic@ */
      extdProtocolConfigurationOptions := p_ExtdPCO,          /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      reattemptInd            := p_ReAttemptIndicator,        /* cl. 9.11.4.17 O TLV 3 IEI=1D Sep20 @sic R5s201387 Baseline Moving sic@ */
      serviceLvlAA            := p_ServiceLvlAA               /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_AUTHENTICATION_COMMAND (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                                    ProcedureTransactionIdentifier p_PTI,
                                                                                    template (value) EAP_Message p_EAP,
                                                                                    template (omit) ExtdProtocolConfigOptions p_ExtdPCO) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.3.4 */
    pdu_Session_Authentication_Command := {
      protocolDiscriminator   := tsc_EPD_GSM,                 /* cl. 9.2       M V 1   */
      pduSessionId            := p_PDU_SessionId,             /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,               /* cl. 9.6       M V 1   */
      messageType             := tsc_MT_NG_PDUSessionAuthenticationCommand, /* cl. 9.7       M V 1   */
      eapMessage              := p_EAP,                       /* cl. 9.11.2.2  M LV-E 6-1502 */
      extdProtocolConfigurationOptions := p_ExtdPCO           /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_AUTHENTICATION_COMPLETE (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                       template (present) ProcedureTransactionIdentifier p_PTI,
                                                                                       template (present) EAP_Message p_EAP,
                                                                                       template ExtdProtocolConfigOptions p_ExtdPCO) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.3.5 */
    pdu_Session_Authentication_Complete := {
      protocolDiscriminator   := tsc_EPD_GSM,                  /* cl. 9.2       M V 1   */
      pduSessionId            := p_PDU_SessionId,              /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                /* cl. 9.6       M V 1   */
      messageType             := tsc_MT_NG_PDUSessionAuthenticationComplete, /* cl. 9.7       M V 1   */
      eapMessage              := p_EAP               ,         /* cl. 9.11.2.2   M LV-E 6-1502 */
      extdProtocolConfigurationOptions := p_ExtdPCO            /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (value) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_AUTHENTICATION_RESULT (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                                   ProcedureTransactionIdentifier p_PTI,
                                                                                   template (omit) EAP_Message p_EAP,
                                                                                   template (omit) ExtdProtocolConfigOptions p_ExtdPCO) :=
  { /* 24.501 cl. 8.3.6 */
    /* @status    APPROVED (NR5GC) */
    pdu_Session_Authentication_Result := {
      protocolDiscriminator   := tsc_EPD_GSM,                  /* cl. 9.2       M V 1   */
      pduSessionId            := p_PDU_SessionId,              /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                /* cl. 9.6       M V 1   */
      messageType             := tsc_MT_NG_PDUSessionAuthenticationResult, /* cl. 9.7       M V 1   */
      eapMessage              := p_EAP,                        /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      extdProtocolConfigurationOptions := p_ExtdPCO            /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_MODIFICATION_REQUEST (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                    template (present) ProcedureTransactionIdentifier p_PTI,
                                                                                    template NG_UE_SM_Cap p_NG_UE_SM_Cap,
                                                                                    template GMM_GSM_Cause p_Cause,
                                                                                    template MaxNumPacketFilters p_MaxNumPacketFilters,
                                                                                    template AlwaysOnPDUSessionReq p_AlwaysOnPDUSessionReq,
                                                                                    template IntegrityProtMaxDataRate p_IntegrityProtMaxDataRate,
                                                                                    template QoS_Rules p_QoS_Rules,
                                                                                    template QoSFlowDescr p_QoSFlowDescr,
                                                                                    template MappedEPSBearerContexts p_MappedEPSBearerContexts,
                                                                                    template ExtdProtocolConfigOptions p_ExtdPCO,
                                                                                    template PortManagementInfoContainer p_PortManagementInfoContainer,
                                                                                    template IPHeaderCompressionConfig p_IPHeaderCompConfig,
                                                                                    template EthernetHeaderCompressConfig p_EthernetHeaderCompConfig,
                                                                                    template RequestedMBSContainer p_RequestedMBS,
                                                                                    template ServiceLvlAAContainer p_ServiceLvlAA) :=
  { /* @status    APPROVED (NR5GC, NR5GC_IRAT) */
    /* 24.501 cl. 8.3.7 */
    pdu_Session_Modification_Request := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionModificationRequest, /* cl. 9.7       M V 1   */
      smCapability                    := p_NG_UE_SM_Cap,                 /* cl. 9.11.4.1  O TLV 3-15 IEI=28 */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  O TV 2 IEI=59   */
      maxNumPacketFilters             := p_MaxNumPacketFilters,          /* c.  9.11.4.9  O TV 3 IEI=55 */
      alwaysOnPDUSessionReq           := p_AlwaysOnPDUSessionReq,        /* c.  9.11.4.4  O TV 1 IEI=B */
      integrityProtMaxDataRate        := p_IntegrityProtMaxDataRate,     /* c.  9.11.4.7  O TV 2 IEI=13 */
      requestedQoSRules               := p_QoS_Rules,                    /* cl. 9.11.4.13 O TLV-E 7-65538 IEI=7A */
      requestedQoSFlowDescr           := p_QoSFlowDescr,                 /* cl. 9.11.4.12 O TLV-E 5-65538 IEI=79 */
      mappedEPSbearerContexts         := p_MappedEPSBearerContexts,      /* cl. 9.11.4.8  O TLV-E 7-65538 IEI=7F Dec18 */
      extdProtocolConfigurationOptions := p_ExtdPCO,                     /* cl. 9.11.4.6  O TLV-E 4-65538 IEI=0x7B */
      portManagementInfoContainer     := p_PortManagementInfoContainer,  /* cl. 9.11.4.27  O TLV-E 8-65538 IEI=7C Sep20 @sic R5s201387 Baseline Moving sic@ */
      ipHeaderCompressionConfig       := p_IPHeaderCompConfig,           /* cl. 9.11.4.24 O TLV 5-257 IEI=66 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ethernetHeaderCompressConfig    := p_EthernetHeaderCompConfig,     /* cl. 9.11.4.28 O TLV 3 IEI=1F Sep20 @sic R5s201387 Baseline Moving sic@ */
      requestedMBS                    := p_RequestedMBS,                 /* cl. 9.11.4.30  O TLV-E 8-65538 IEI=70 Sep22 @sic R5s221179 Baseline Moving sic@ */
      serviceLvlAA                    := p_ServiceLvlAA                  /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (value) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_MODIFICATION_COMMAND (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                                  ProcedureTransactionIdentifier p_PTI,
                                                                                  template (omit) GMM_GSM_Cause p_Cause,
                                                                                  template (omit) Session_AMBR p_Session_AMBR,
                                                                                  template (omit) GPRS_Timer p_RQTimer,
                                                                                  template (omit) AlwaysOnPDUSessionInd p_AlwaysOnPDUSessionInd,
                                                                                  template (omit) QoS_Rules p_QoS_Rules,
                                                                                  template (omit) QoSFlowDescr p_QoSFlowDescr,
                                                                                  template (omit) MappedEPSBearerContexts p_MappedEPSBearerContexts,
                                                                                  template (omit) ExtdProtocolConfigOptions p_ExtdPCO,
                                                                                  template (omit) ATSSSContainer p_ATSSSContainer,
                                                                                  template (omit) IPHeaderCompressionConfig p_IPHeaderCompConfig,
                                                                                  template (omit) PortManagementInfoContainer p_PortManagementInfoContainer,
                                                                                  template (omit) ServingPLMNRateControl p_ServingPLMNRateCtrl,
                                                                                  template (omit) EthernetHeaderCompressConfig p_EthernetHeaderCompConfig,
                                                                                  template (omit) ReceivedMBSContainer p_ReceivedMBS,
                                                                                  template (omit) ServiceLvlAAContainer p_ServiceLvlAA) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT) */
    /* 24.501 cl. 8.3.9 */
    pdu_Session_Modification_Command := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionModificationCommand, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  O TV 2 IEI=59   */
      sessionAMBR                     := p_Session_AMBR,                 /* cl. 9.11.4.14  O TLV 8 IEI=2A */
      rqTimerValue                    := p_RQTimer,                      /* cl. 9.11.2.3   O TV 2 IEI=56 */
      alwaysOnPDUSessionInd           := p_AlwaysOnPDUSessionInd,        /* c.  9.11.4.3   O TV 1 IEI=8 */
      authorizedQoSRules              := p_QoS_Rules,                    /* cl. 9.11.4.13  O TLV-E 7-65538 IEI=7A */
      mappedEPSContexts               := p_MappedEPSBearerContexts,      /* cl. 9.11.4.8   O TLV-E 7-65538 IEI=7F */
      authorizedQoSFlowDescr          := p_QoSFlowDescr,                 /* cl. 9.11.4.12  O TLV-E 6-65538 IEI=79 */
      extdProtocolConfigurationOptions := p_ExtdPCO,                     /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      atsssContainer                  := p_ATSSSContainer,               /* cl. 9.11.4.22 O TLV-E 3-65538  IEI=77 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ipHeaderCompressionConfig       := p_IPHeaderCompConfig,           /* cl. 9.11.4.24 O TLV 5-257 IEI=66 Sep20 @sic R5s201387 Baseline Moving sic@ */
      portManagementInfoContainer     := p_PortManagementInfoContainer,  /* cl. 9.11.4.27  O TLV-E 8-65538 IEI=7C Sep20 @sic R5s201387 Baseline Moving sic@ */
      servingPLMNRateControl          := p_ServingPLMNRateCtrl,          /* cl. 9.11.4.20 O TLV 4  IEI=18 Sep20 @sic R5s201387 Baseline Moving sic@ */
      ethernetHeaderCompressConfig    := p_EthernetHeaderCompConfig,     /* cl. 9.11.4.28 O TLV 3 IEI=1F Sep20 @sic R5s201387 Baseline Moving sic@ */
      receivedMBS                     := p_ReceivedMBS,                  /* cl. 9.11.4.30  O TLV-E 8-65538 IEI=71 Sep22 @sic R5s221179 Baseline Moving sic@ */
      serviceLvlAA                    := p_ServiceLvlAA                  /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_MODIFICATION_COMPLETE (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                     template (present) ProcedureTransactionIdentifier p_PTI := '00'O,
                                                                                     template ExtdProtocolConfigOptions p_ExtdPCO := *,
                                                                                     template PortManagementInfoContainer p_PortManagementInfoContainer := *) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT) */
    /* 24.501 cl. 8.3.10 */
    pdu_Session_Modification_Complete := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionModificationComplete, /* cl. 9.7       M V 1   */
      extdProtocolConfigurationOptions := p_ExtdPCO,                    /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      portManagementInfoContainer     := p_PortManagementInfoContainer  /* cl. 9.11.4.27  O TLV-E 8-65538 IEI=7C Sep20 @sic R5s201387 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_MODIFICATION_COMMAND_REJECT (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                           template (present) ProcedureTransactionIdentifier p_PTI := '00'O,
                                                                                           template (present) GMM_GSM_Cause p_Cause := ?,
                                                                                           template ExtdProtocolConfigOptions p_ExtdPCO := *) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.3.11 */
    pdu_Session_Modification_Command_Reject := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionModificationCommandReject, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  O TV 2 IEI=59  */
      extdProtocolConfigurationOptions := p_ExtdPCO                     /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_RELEASE_REQUEST (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                               template (present) ProcedureTransactionIdentifier p_PTI,
                                                                               template GMM_GSM_Cause p_Cause,
                                                                               template ExtdProtocolConfigOptions p_ExtdPCO) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.3.12 */
    pdu_Session_Release_Request := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionReleaseRequest, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  O TV 2 IEI=59  */
      extdProtocolConfigurationOptions := p_ExtdPCO                      /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (value) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_RELEASE_REJECT (NG_PDU_SessionId p_PDU_SessionId,
                                                                            ProcedureTransactionIdentifier p_PTI,
                                                                            GMM_GSM_Cause p_Cause,
                                                                            template (omit) ExtdProtocolConfigOptions p_ExtdPCO) :=
  {                      /* 24.501 cl. 8.3.13 */
    pdu_Session_Release_Reject := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionReleaseReject, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  M V 1   */
      extdProtocolConfigurationOptions := p_ExtdPCO                      /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (omit) NG_NAS_DL_Message_Type cs_NG_PDU_SESSION_RELEASE_COMMAND (template (value) NG_PDU_SessionId p_PDU_SessionId,
                                                                             ProcedureTransactionIdentifier p_PTI,
                                                                             template (value) GMM_GSM_Cause p_Cause,
                                                                             template (omit) GPRS_Timer3 p_BackOffTimer,
                                                                             template (omit) EAP_Message p_EAP,
                                                                             template (omit) NGSM_CongestionReattemptInd p_NGSM_CongestionReattemptInd, // @sic R5s190543 sic@
                                                                             template (omit) ExtdProtocolConfigOptions p_ExtdPCO,
                                                                             template (omit) AccessType p_AccessType,
                                                                             template (omit) ServiceLvlAAContainer p_ServiceLvlAA) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.3.14 */
    pdu_Session_Release_Command := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionReleaseCommand, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  M V 1   */
      backOffTimerValue               := p_BackOffTimer,                 /* cl. 9.11.2.5  O TLV 3 IEI=37 */
      eapMessage                      := p_EAP,                          /* cl. 9.11.2.2  O TLV-E 7-1503 IEI=78 */
      ngsmCongestionReattemptInd      := p_NGSM_CongestionReattemptInd,  /* cl. 9.11.4.2A O TLV 3 IEI=61 Jun19 @sic R5s190543 sic@ */
      extdProtocolConfigurationOptions := p_ExtdPCO,                     /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
      accessType                      := p_AccessType,                   /* cl. 9.11.2.1A O TV 1 IEI=D Sep20 @sic R5s201387 Baseline Moving sic@ */
      serviceLvlAA                    := p_ServiceLvlAA                  /* cl. 9.11.2.10  O TLV-E 6-n IEI=72 Sep22 @sic R5s221179 Baseline Moving sic@ */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_PDU_SESSION_RELEASE_COMPLETE (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                template (present) ProcedureTransactionIdentifier p_PTI := '00'O,
                                                                                template GMM_GSM_Cause p_Cause := *,
                                                                                template ExtdProtocolConfigOptions p_ExtdPCO := *) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.3.15 */
    pdu_Session_Release_Complete := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_PDUSessionReleaseComplete, /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause,                        /* cl. 9.11.4.2  O TV 2 IEI=59  */
      extdProtocolConfigurationOptions := p_ExtdPCO                      /* cl. 9.11.4.6 O TLV-E 4-65538 IEI=0x7B */
    }
  };

  template (present) NG_NAS_UL_Message_Type cr_NG_GSM_STATUS (template (present) NG_PDU_SessionId p_PDU_SessionId,
                                                                                template ProcedureTransactionIdentifier p_PTI := *,
                                                                                template GMM_GSM_Cause p_Cause := *) :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 8.3.16 */
    gsm_Status := {
      protocolDiscriminator           := tsc_EPD_GSM,                    /* cl. 9.2       M V 1   */
      pduSessionId                    := p_PDU_SessionId,                /* cl. 9.4       M V 1   */
      procedureTransactionIdentifier  := p_PTI,                          /* cl. 9.6       M V 1   */
      messageType                     := tsc_MT_NG_GSM_Status,           /* cl. 9.7       M V 1   */
      gsmCause                        := p_Cause                         /* cl. 9.11.4.2  M V 1 IEI=59  */
    }
  };

  //----------------------------------------------------------------------------
  // NG Mobility Management (GMM) information elements (24.501 cl. 9.11.3)
  //----------------------------------------------------------------------------

  template (value) EAP_Message cs_DummyEAP_Message :=
  { /* 24.501 cl. 9.11.2.2 */
    iei       := omit,
    iel       := '0000'O,
    eapMsg    := ''O
  };

  template (present) EAP_Message cr_EAP_Message (template IEI8_Type p_IEI := '78'O, template (present) octetstring p_EAPMsg := ?) :=
  { /* 24.501 cl. 9.11.2.2 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei       := p_IEI,
    iel       := ?,
    eapMsg    := p_EAPMsg
  };

  template (value) EAP_Message cs_EAP_Message (octetstring p_EncodedEapMsg,
                                               template (omit) IEI8_Type p_IEI := '78'O) :=
  { /* 24.501 cl. 9.11.2.2 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei       := p_IEI,
    iel       := int2oct(lengthof(p_EncodedEapMsg), 2),
    eapMsg    := p_EncodedEapMsg
  };

  template (value) NG_NetworkFeatureSupport cs_NG_NetworkFeatureSupport_Def :=
  { /* 24.501 cl 9.11.3.5 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei                    := '21'O, /* @sic R5s190109 sic@ */
    iel                    := '03'O, /* present in case of LV or TLV; omit in case of V @sic R5s201526 sic@ */
    mpsi                   := '0'B,
    iwk_N26                := '0'B,
    emf                    := '00'B,
    emc                    := '11'B,  //@sic R5-198540 sic@
    imsVoPS_n3GPP          := '0'B,
    imsVoPS_3GPP           := '1'B,
    ng_UP_CIoT             := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    ngIPHC_CP_CIoT         := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    n3Data                 := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    ng_CP_CIoT             := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    restrictEC             := '00'B,                 /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    mcsi                   := '0'B,
    emcn3                  := '0'B,
    spareBit               := tsc_Spare1,
    pr                     := '0'B,                  /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    rpr                    := '0'B,                  /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    piv                    := '0'B,                  /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ncr                    := '0'B,                  /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngEHC_CP_CIoT          := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    atsInd                 := '0'B,                  /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    ngLCS                  := '0'B                   /* Sep20 @sic R5s201387 Baseline Moving sic@ */
  };

  template (value) NG_NetworkFeatureSupport cds_NG_NetworkFeatureSupport_NoN26
            modifies cs_NG_NetworkFeatureSupport_Def :=
  { /* @status    APPROVED (NR5GC_IRAT) */
    iwk_N26 := '1'B
  };

  template (value) NG_NetworkFeatureSupport cds_NG_NetworkFeatureSupport_NoImsVoPS_3GPP
            modifies cs_NG_NetworkFeatureSupport_Def :=
  { /* @status    APPROVED (NR5GC) */
    imsVoPS_3GPP           := '0'B
  };

  template (value) RegistrationResult cs_RegistrationResult(B3_Type p_Result,
                                                            B1_Type p_SMS,
                                                            B1_Type p_EmergencyRegistered,
                                                            B1_Type p_NssaaPerformed,
                                                            B1_Type p_DisasterRoamingResult) :=
  { /* 24.501 cl. 9.11.3.6 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iel             := '01'O,          /* present in case of LV or TLV; omit in case of V */
    spare           := tsc_Spare1,
    disasterRoamingResult := p_DisasterRoamingResult,        /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    emergencyRegistered := p_EmergencyRegistered,            /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    nssaaPerformed  := p_NssaaPerformed,                     /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    smsAllowed      := p_SMS,
    resultValue     := p_Result
  };

  template (present) RegistrationType cr_RegistrationType (template (present) B3_Type p_Type,
                                                           template (present) B1_Type p_FOR) :=
  { /* 24.501 cl. 9.11.3.7 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    fOR                 := p_FOR,
    registrationType    := p_Type
  };

  template (value) RegistrationType cs_RegistrationType (template (value) B3_Type p_Type,
                                                         template (value) B1_Type p_FOR) :=
  { /* 24.501 cl. 9.11.3.7 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    fOR                 := p_FOR,
    registrationType    := p_Type
  };

  template (value) CAGInfoList cs_EmptyCAGInfoList :=
  { /* @status    APPROVED (NR5GC) */
    /* 24.501 cl. 9.11.3.18A */
    iei     := '75'O,    // @sic R5-213413 sic@
    iel     := '0000'O,
    listOfCAGInfos := omit
  };

  template (present) AuthenticationResponseParameter cr_AuthenticationResponseParameter(template (present) B32_128_Type p_ExpectedRES) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei := '2D'O,
    iel := ?,        /* RES has length of 32..128 bits i.e. 4..16 octets */
    res := p_ExpectedRES
  };

  template (value) NG_PartialTaiType cs_NG_NonConsecutivePartialTaiList(NAS_PlmnId  p_PlmnId,
                                                                        NG_NAS_TacList p_TacList):=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    type0List := {
      {
        plmnId  := p_PlmnId,
        tacList := p_TacList
      }
    }
  };

  template (value) NG_ListOfPartialTaiList cs_NG_ListNonConsecutivePartialTaiList (NAS_PlmnId  p_PlmnId,
                                                                                   NG_NAS_TacList p_TacList):=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    allowedType      := tsc_Spare1,
    typeOfList       := tsc_NonConsecutiveTacs,
    numberOfElements := int2bit(lengthof(p_TacList) - 1, 5),
    partialTaiList   := cs_NG_NonConsecutivePartialTaiList (p_PlmnId, p_TacList)
  };

  template (value) NG_TrackingAreaIdList cs_NG_TAIListNonConsecutive(NAS_PlmnId  p_PlmnId,
                                                                     NG_NAS_TacList p_TacList) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei := '54'O,
    lvPart  := { /* separated definition into TLV and LV parts Sep22 @sic R5s221179 Baseline Moving sic@ */
      iel := int2oct(4 + 3 * lengthof(p_TacList), 1),
      listOfPartialTais := {cs_NG_ListNonConsecutivePartialTaiList (p_PlmnId, p_TacList) }
    }
  };

  template (value) NG_PartialTaiType cs_NG_ConsecutivePartialTaiList(NG_PartialTai p_PartialTac):=
  { /* @status    APPROVED (NR5GC) */
    type1List := {
      {
        partialTac := p_PartialTac
      }
    }
  };

  template (value) NG_ListOfPartialTaiList cs_NG_ListConsecutivePartialTaiList ( B5_Type p_NumberOfElements,
                                                                                 NG_PartialTai p_PartialTac):=
  { /* @status    APPROVED (NR5GC) */
    allowedType      := tsc_Spare1,
    typeOfList       := tsc_ConsecutiveTacs,
    numberOfElements := p_NumberOfElements,
    partialTaiList   := cs_NG_ConsecutivePartialTaiList (p_PartialTac)
  };

  template (value) NG_TrackingAreaIdList cs_NG_TAIListConsecutive(B5_Type p_NumberOfElements,
                                                                  NG_PartialTai p_PartialTac) :=
  { /* @status    APPROVED (NR5GC) */
    iei := '54'O,
    lvPart  := { /* separated definition into TLV and LV parts Sep22 @sic R5s221179 Baseline Moving sic@ */
      iel := int2oct(7, 1),
      listOfPartialTais := {cs_NG_ListConsecutivePartialTaiList(p_NumberOfElements, p_PartialTac) }
    }
  };

  template (value) NG_PartialTai cs_NG_PartialTai(NAS_PlmnId p_PlmnId, O3_Type p_Tac) :=
  { /* @status    APPROVED (NR5GC) */
    plmnId :=p_PlmnId,
    tac :=p_Tac
  };
  template (present) NG_TrackingAreaId cr_NG_TAI(NAS_PlmnId p_PlmnId,  // O3_Type
                                                 O3_Type    p_Tac) :=  // O3_Type
  { /* @status    APPROVED (NR5GC, NR5GC_IRAT) */
    iei := '52'O,
    plmnId := p_PlmnId,
    tac := p_Tac
  };

  template (value) NG_NAS_SecurityAlgorithms cs_NG_NAS_SecurityAlgorithms (B4_Type p_CipherAlg,
                                                                           B4_Type p_IntAlg) :=
  { /* 24.501 cl. 9.11.3.34 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := omit, /* present in case of TV; omit in case of V */
    cipheringType   := p_CipherAlg,                  /* Type of ciphering algorithm */
    integrityType   := p_IntAlg                  /* Type of integrity protection algorithm */
  };

  template (present) CIoTSmallDataContainer cr_CIoTSmallDataContainer (template (present) B3_Type p_DataType,
                                                                       template (present) B2_Type p_DDX,
                                                                       template (present) B3_Type p_PDUSessionId,
                                                                       template (present) octetstring p_DataContents,
                                                                       template Type4Length_Type p_AddInfoLength,
                                                                       template octetstring p_AddInfo):=
  {                 /* 24.501 cl. 9.11.3.18B */
    iel             := ?,
    dataType        := p_DataType,
    ddx             := p_DDX,                 /* set to 00 for dataType = 001 */
    pduSessionId    := p_PDUSessionId,        /* set to 00 for dataType = 010 or 001 */
    lengthOfAddInfo := p_AddInfoLength,       /* only present for dataType = 010 */
    addInfo         := p_AddInfo,             /* not present for dataType = 000 or 001 */
    dataContents    := p_DataContents
  };

  template (value) ConfigUpdateInd cs_ConfigUpdateInd (B1_Type p_Red := '0'B,
                                                       B1_Type p_Ack := '0'B):=
  { /* @status    APPROVED (NR5GC) */
    iei := 'D'H,    // currently only used as TV cl. 9.11.3.18
    spare := '00'B, //B2_Type  cl. 9.11.3.18
    red := p_Red,   //B1_Type  cl. 9.11.3.18
    ack := p_Ack    //B1_Type  cl. 9.11.3.18
  };

  template (value) DNN cs_DNN (template (omit) IEI8_Type p_IEI := '25'O, // @sic R5s190109 sic@
                               octetstring p_DNN) :=
  { /* 24.501 cl. 9.11.3.21 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei              := p_IEI, /* present in case of TV; omit in case of V */
    iel              := int2oct(lengthof (p_DNN), 1), /* present in case of LV or TLV; omit in case of V */
    dnnValue         := p_DNN
  };

  template (value) DeregisterType crs_DeregisterType (B1_Type p_SwitchOff,
                                                      B1_Type p_ReReg,
                                                      B2_Type p_Access := '01'B) :=
  { // 24.501 cl. 9.11.3.20
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    // IEI is always skipped
    switchOff       := p_SwitchOff,
    reRegistration  := p_ReReg,
    accessType      := p_Access
  };

  template (value) AdditionalSecurityInfo cs_AdditionalSecurityInfo (B1_Type p_Rinmr,
                                                                     B1_Type p_Hdp := '0'B) :=
  { /* 24.501 cl 9.11.3.12 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := '36'O,
    iel             := '01'O,     // @sic R5s211480 sic@
    spareBits       := tsc_Spare6,
    rinmr           := p_Rinmr,
    hdp             := p_Hdp
  };

  template (value) NetworkSlicingInd cs_NetworkSlicingInd (B1_Type p_DCNI,
                                                           B1_Type p_NSSCI) :=
  { // 24.501 cl. 9.11.3.36
    /* @status    APPROVED (NR5GC) */
    iei     := '9'H,
    spare   := tsc_Spare2,
    dcni    := p_DCNI,
    nssci   := p_NSSCI
  };

  template (value) S_NSSAI_Type cs_S_NSSAI_WithIEI(IEI8_Type p_IEI,
                                           template (value) S_NSSAI_LV p_LvPart) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei     := p_IEI,
    lvPart  := p_LvPart

  };

  template (value) S_NSSAI_LV cs_S_NSSAI(Type4Length_Type p_Length,
                                         O1_Type p_SST,
                                         template (omit) O3_Type p_SD,
                                         template (omit) O1_Type p_MappedSST := omit,
                                         template (omit) O3_Type p_MappedSD := omit) :=
  { // 24.501 cl. 9.11.2.8
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* @sic R5s221179 Baseline Moving sic@ */
    iel          := p_Length,
    vPart := {                /* @sic R5s221179 Baseline Moving sic@ */
      sst          := p_SST,
      sd           := p_SD,
      mappedSST    := p_MappedSST,
      mappedSD     := p_MappedSD
    }
  };

  template (value) S_NSSAI_Type cs_S_NSSAI_SST1eMBB_WithIEI := cs_S_NSSAI_WithIEI('22'O, cs_S_NSSAI_SST1eMBB);   /* @sic R5s221179 sic@ @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) S_NSSAI_LV cs_S_NSSAI_SST1eMBB := cs_S_NSSAI('01'O, '01'O, omit);            /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) S_NSSAI_LV cs_S_NSSAI_SST2_URLLC := cs_S_NSSAI('01'O, '02'O, omit);          /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) S_NSSAI_LV cs_S_NSSAI_SST3_MIoT := cs_S_NSSAI('01'O, '03'O, omit);          /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) S_NSSAI_LV cs_S_NSSAI_SST4_V2X := cs_S_NSSAI('01'O, '04'O, omit);            /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */

  template (value) NSSAI cs_NSSAI_SST1eMBB (template (value) IEI8_Type p_IEI) :=
    // 24.501 cl. 9.11.3.37
    /* @status    */
      cs_NSSAI_Def (p_IEI, {cs_S_NSSAI_SST1eMBB});

  template (value) NSSAI cs_NSSAI_SSTs (template (value) IEI8_Type p_IEI) :=
    /* @status    APPROVED (NR5GC) */
    // @sic R5s210440 Ch. 1 sic@
      cs_NSSAI_Def (p_IEI, {cs_S_NSSAI('02'O, '01'O, omit, '01'O)});

  template (value) NSSAI cs_NSSAI_Allowed_Def :=
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
       cs_NSSAI_Def ('15'O, {cs_S_NSSAI_SST1eMBB, cs_S_NSSAI_SST2_URLLC, cs_S_NSSAI_SST3_MIoT, cs_S_NSSAI_SST4_V2X});

  template (value) NSSAI cs_NSSAI_Def (template (value) IEI8_Type p_IEI, template (value) S_NSSAI_TypeList p_List) :=
  {  /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
     // 24.501 cl. 9.11.3.37
    iei        := p_IEI, /* present in case of TLV; omit in case of LV */
    lvPart := {                 /* @sic R5s221179 Baseline Moving sic@ */
      iel        := fl_NR5GC_NSSAILength(p_List),
      s_nssai    := p_List
    }
  };

  template (value) RejectedS_NSSAI cs_RejectedS_NSSAI(B4_Type p_Length,
                                           B4_Type p_CauseValue,
                                           O1_Type p_SST,
                                           template (omit) O3_Type p_SD := omit
                                           ) :=
  { /* @status    APPROVED (NR5GC) */
    // 24.501 cl. 9.11.3.46
    len          := p_Length,
    causeValue   := p_CauseValue,
    sst          := p_SST,
    sd           := p_SD
  };

  /*
   * @desc      Returns length of S-NSSAI list
   * @param     p_List
   * @return    Type4Length_Type
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
   function fl_NR5GC_NSSAILength (template (value) S_NSSAI_TypeList p_List) return Type4Length_Type
  {
    var integer j;
    var integer v_Length:=0;

    for (j:= 0; j < lengthof(p_List); j:= j+1) {
      v_Length := v_Length + oct2int(valueof(p_List[j].iel));
      v_Length := v_Length + 1; // for iel
    }
    return int2oct(v_Length, 1);
 }

  /*
   * @desc      To extract a single NSSAI from part of an AT command
   *            *** For common module use only ***
   *            Incoming string MUST be already parsed for ':'
   * @param     p_Cause             (by reference)
   * @param     p_ATCommand
   * @return    template (value) S_NSSAI_LV
   * @status    APPROVED (NR5GC)
   */
  function fl_ExtractNSSAI_FromEachATCommandLine(out integer p_Cause, charstring p_ATCommand) return template (value) S_NSSAI_LV
  {
    var CharStringList_Type v_ListOfSubStr := {};
    var CharStringList_Type v_ListOfRejCause := {};
    var CharStringList_Type v_ListOfSst_Sd := {};
    var O1_Type v_SST;
    var template (omit) O3_Type v_SD;
    var template (omit) O1_Type v_MappedSST;
    var template (omit) O3_Type v_MappedSD;
    var integer v_Length := 0;

    p_Cause := -1;

    // AT Command format is sst.sd;mappedsst.mappedsd[if rejectedNSSAI #cause]:
      v_ListOfRejCause := f_StringSplit(p_ATCommand, {"#"});
      if (lengthof(v_ListOfRejCause) > 1) { // There is a cause value
        p_Cause := str2int(v_ListOfRejCause[1]);
        // now parse the string with the cause value removed
        p_ATCommand := v_ListOfRejCause[0];
      }
      v_ListOfSubStr := f_StringSplit(p_ATCommand, {";"});
      v_ListOfSst_Sd := f_StringSplit(v_ListOfSubStr[0], {"."});
      v_SST := str2oct(v_ListOfSst_Sd[0]);
      v_Length := v_Length + 1;  // SST = 1 octet
      if (lengthof(v_ListOfSst_Sd) > 1) {
        v_SD := str2oct(v_ListOfSst_Sd[1]);
        v_Length := v_Length + 3;  // SD = 3 octets
      } else {
        v_SD := omit;
      }
      if (lengthof(v_ListOfSubStr) > 1) {
        // now get mapped values
        v_ListOfSst_Sd := f_StringSplit(v_ListOfSubStr[1], {"."});
        v_MappedSST := str2oct(v_ListOfSst_Sd[0]);
        v_Length := v_Length + 1; // SST = 1 octet
        if (lengthof(v_ListOfSst_Sd) > 1) {
          v_MappedSD := str2oct(v_ListOfSst_Sd[1]);
          v_Length := v_Length + 3; // SD = 3 octets
        } else {
          v_MappedSD := omit;
        }
      } else {
        // No mapped values
        v_MappedSST := omit;
        v_MappedSD := omit;
      }

    return cs_S_NSSAI (int2oct(v_Length, 1), v_SST, v_SD, v_MappedSST, v_MappedSD);
  }

  /*
   * @desc      To match the AT command with a listed NSSAI in any order
   * @param     p_NSSAI
   * @param     p_ATCommand
   * @return    boolean
   * @status    APPROVED (NR5GC)
   */
  function f_MatchListOfNSSAI_WithATCommand(template (value) NSSAI_LV p_NSSAI, charstring p_ATCommand) return boolean
  {
    var CharStringList_Type v_ListOfAllowed := {};
    var template (value) S_NSSAI_TypeList v_ListOfNSSAI := {};
    var template S_NSSAI_TypeList v_PermutationNSSAI := {};
    var integer v_Cause;  // ignore cause value for NSSAI_LV types
    var integer v_NumAllowed;

    // AT Command format is NSSAI:NSSAI
    v_ListOfAllowed := f_StringSplit(p_ATCommand, {":"});
    for (v_NumAllowed := 0; v_NumAllowed < lengthof(v_ListOfAllowed); v_NumAllowed := v_NumAllowed +1 ) {
      v_ListOfNSSAI[v_NumAllowed] := fl_ExtractNSSAI_FromEachATCommandLine(v_Cause, v_ListOfAllowed[v_NumAllowed]);
    }
    v_PermutationNSSAI := {permutation (all from p_NSSAI.s_nssai)};
    return match (valueof(v_ListOfNSSAI), v_PermutationNSSAI);
  }

  /*
   * @desc      To match the AT command with a list of RejectNSSAI in any order
   * @param     p_NSSAI - of type XtdRejectedS_NSSAI_List
   * @param     p_ATCommand
   * @param     p_AtLeastThisList - other values can be included in list.  Set to false if AT command should ONLY consist of p_NSSAI
   * @return    boolean
   */
  function f_MatchXtdRejectedNSSAI_WithATCommand(template (value) XtdRejectedS_NSSAI_List p_NSSAI,
                                                 charstring p_ATCommand,
                                                 boolean p_AtLeastThisList := true) return boolean
  {
    var CharStringList_Type v_ListOfAllowed := {};
    var template (value) XtdRejectedS_NSSAI_List v_ListOfNSSAI := {};
    var template XtdRejectedS_NSSAI_List v_PermutationNSSAI := {};
    var template (value) S_NSSAI_LV v_NSSAI_LV;
    var integer v_Cause;
    var integer v_NumAllowed;

    // AT Command format is NSSAI:NSSAI
    v_ListOfAllowed := f_StringSplit(p_ATCommand, {":"});
    for (v_NumAllowed := 0; v_NumAllowed < lengthof(v_ListOfAllowed); v_NumAllowed := v_NumAllowed +1 ) {
      v_NSSAI_LV := fl_ExtractNSSAI_FromEachATCommandLine(v_Cause, v_ListOfAllowed[v_NumAllowed]);
      // Fit returned template into XtdRejectedNSSAI type
      v_ListOfNSSAI[v_NumAllowed] := cs_XtdRejectedS_NSSAI(int2bit(oct2int(valueof(v_NSSAI_LV.iel)), 4),
                                                         int2bit(v_Cause, 4),
                                                         valueof(v_NSSAI_LV.vPart.sst),
                                                         v_NSSAI_LV.vPart.sd,
                                                         v_NSSAI_LV.vPart.mappedSST,
                                                         v_NSSAI_LV.vPart.mappedSD);
    }
    if (p_AtLeastThisList) {
      v_PermutationNSSAI := {permutation (all from p_NSSAI, *)};
    } else {
      v_PermutationNSSAI := {permutation (all from p_NSSAI)};
    }
    return match (valueof(v_ListOfNSSAI), v_PermutationNSSAI);
  }

  /*
   * @desc      Returns length of XtdRejectedS_NSSAI list
   * @param     p_List
   * @return    integer
   */
   function fl_XtdRejectedS_NSSAILength (template (value) XtdRejectedS_NSSAI_List p_List) return integer
  {
    var integer j;
    var integer v_Length:=0;

    for (j:= 0; j < lengthof(p_List); j:= j+1) {
      v_Length := v_Length + bit2int(valueof(p_List[j].len));
      v_Length := v_Length + 1; // for len & cause
    }
    return v_Length;
 }

  /*
   * @desc      Returns a template of type PartialXtdRejectedNSSAIType0
   * @param     p_List
   * @return    template (value) PartialXtdRejectedNSSAI
   */
   function f_BuildNR5GC_PartialXtdRejectedNSSAIType0 (template (value) XtdRejectedS_NSSAI_List p_List) return template (value) PartialXtdRejectedNSSAI
  {
    var integer j;
    var integer v_Length:=0;
    var integer v_NumOfElements := -1;

    for (j:= 0; j < lengthof(p_List); j:= j+1) {
      v_NumOfElements := v_NumOfElements +1;
      v_Length := v_Length + bit2int(valueof(p_List[j].len));
      v_Length := v_Length + 2; // for type of list etc + back off timer
    }
    return cs_PartialXtdRejectedNSSAIType0(int2bit(v_NumOfElements, 4),
                                           p_List);
 }

  /*
   * @desc      Returns a template of type PartialXtdRejectedNSSAIType1
   * @param     p_List
   * @return    template (value) PartialXtdRejectedNSSAI
   */
   function f_BuildNR5GC_PartialXtdRejectedNSSAIType1 (template (value) XtdRejectedS_NSSAI_List p_List,
                                                       O1_Type p_BackOffTimer) return template (value) PartialXtdRejectedNSSAI
  {
    var integer j;
    var integer v_Length:=0;
    var integer v_NumOfElements := -1;

    for (j:= 0; j < lengthof(p_List); j:= j+1) {
      v_NumOfElements := v_NumOfElements +1;
      v_Length := v_Length + bit2int(valueof(p_List[j].len));
      v_Length := v_Length + 2; // for type of list etc + back off timer
    }
    return cs_PartialXtdRejectedNSSAIType1(int2bit(v_NumOfElements, 4),
                                           p_BackOffTimer,
                                           p_List);
 }

  /*
   * @desc      Returns a template of type ExtdRejectedNSSAI
   * @param     p_List
   * @return    template (value) ExtdRejectedNSSAI
   */
   function f_BuildNR5GC_ExtdRejectedNSSAI (template (value) PartialXtdRejectedNSSAI_List p_List) return template (value) ExtdRejectedNSSAI
  {
    var integer j;
    var integer v_Length:=0;

    for (j:= 0; j < lengthof(p_List); j:= j+1) {
      if (ischosen(p_List[j].type0)){
        v_Length := v_Length + fl_XtdRejectedS_NSSAILength(p_List[j].type0.rejectS_NSSAI);
        v_Length := v_Length + 1;  // for type of list etc
      } else {
        v_Length := v_Length + fl_XtdRejectedS_NSSAILength(p_List[j].type1.rejectS_NSSAI);
        v_Length := v_Length + 2;  // for type of list etc + back off timer
      }
    }
    return cs_ExtdRejectedNSSAI(int2oct(v_Length, 1), p_List);
 }

  template (value) ExtdRejectedNSSAI cs_ExtdRejectedNSSAI(Type4Length_Type p_Len,
                                                          template(value) PartialXtdRejectedNSSAI_List p_List) :=
  {
    iei := '68'O,
    iel := p_Len,
    partialXtd := p_List
  };

  template (value) PartialXtdRejectedNSSAI cs_PartialXtdRejectedNSSAIType0 (B4_Type p_NumOfElements,
                                                                            template (value) XtdRejectedS_NSSAI_List p_List):=
  {
    type0 := {
      spare                := '0'B,
      typeOfList           := '000'B,
      numOfElements        := p_NumOfElements,
      rejectS_NSSAI        := p_List
    }
   };

  template (value) PartialXtdRejectedNSSAI cs_PartialXtdRejectedNSSAIType1 (B4_Type p_NumOfElements,
                                                                            O1_Type p_BackOffTimer,
                                                                            template (value) XtdRejectedS_NSSAI_List p_List):=
  {
    type1 := {
      spare                := '0'B,
      typeOfList           := '001'B,
      numOfElements        := p_NumOfElements,
      backOffTimerValue    := p_BackOffTimer,
      rejectS_NSSAI        := p_List
    }
   };

  template (value) XtdRejectedS_NSSAI cs_XtdRejectedS_NSSAI (B4_Type p_Len,
                                                             B4_Type p_Cause,
                                                             O1_Type p_SST,
                                                             template (omit) O3_Type p_SD := omit,
                                                             template (omit) O1_Type p_MappedSST := omit,
                                                             template (omit) O3_Type p_MappedSD := omit) :=
  {
    len                := p_Len,
    causeValue         := p_Cause,
    snssai             := {
        sst          := p_SST,
        sd           := p_SD,
        mappedSST    := p_MappedSST,
        mappedSD     := p_MappedSD
     }
   };

  template (present) NG_GMM_Cap cr_NG_GMM_CapAny :=
  { /* @status    APPROVED (NR5GC, NR5GC_IRAT) */
    /* 24.501 cl. 9.11.3.1 */
    iei         := '10'O, /* present in case of TLV; omit in case of LV */
    iel         := ?,     /* @sic R5s210786 sic@ */
    sgc         := ?,                            /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    ngIPHC_CP_CIoT := ?,              /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    n3Data      := ?,                         /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    ng_CP_CIoT  := ?,                     /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    restrictEC  := ?,                     /* Sep20 @sic R5s201387 Baseline Moving sic@ */
    lpp         := ?,                            /* Dec18 */
    hoAttach    := ?,
    s1Cap       := ?,
    racs        := *,                           /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    nssaa       := *,                          /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    ngLCS       := *,                          /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    v2xNPC5     := *,                        /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    v2xEPC5     := *,                        /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    v2x         := *,                            /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    ng_UP_CIoT  := *,                     /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    ngSRVCC     := *,                        /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    ngProSeL2relay := *,                /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngProSe_dc  := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngProSe_dd  := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    erNSSAI     := *,                    /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngEHC_CP_CIoT := *,                /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    multipleUP  := *,                     /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    wusa        := *,                           /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    cag         := *,                            /* Sep20 @sic R5s201387 Baseline Moving, R5s201531 sic@ */
    pr          := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    rpr         := *,                    /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    piv         := *,                  /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ncr         := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    nrPSSI      := *,                    /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngProSeL3rmt := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngProSeL2rmt := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ngProSeL3relay := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    mpsiu       := *,                    /* Jun23 @sic R5s230533 sic@  */
    uas         := *,                    /* Jun23 @sic R5s230533 sic@ */
    nsag        := *,                    /* Jun23 @sic R5s230533 sic@ */
    exCAG       := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    ssnpnsi     := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    eventNotification := *,              /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    mint        := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    nssrg       := *,                   /* Sep22 @sic R5s221179 Baseline Moving sic@ */
    spareBits   := *,                   /* Jun23 @sic R5s230533  sic@ */
    rcman       := *,                   /* Jun23 @sic R5s230533 sic@ */
    rcmap       := *,                   /* Jun23 @sic R5s230533 sic@ */
    spare       := omit
  };

  template (present) NG_GMM_Cap cdr_NG_GMM_Cap_RACS modifies cr_NG_GMM_CapAny :=
  { /* @status    APPROVED (NR5GC, NR5GC_IRAT) */
    racs        := '1'B
  };

  template (present) NG_GMM_Cap cdr_NG_GMM_Cap_S1 modifies cr_NG_GMM_CapAny :=
  { /* @status    APPROVED (NR5GC_IRAT) */
    s1Cap       := '1'B
  };

  template (present) NG_GMM_Cap cdr_NG_GMM_Cap_ERNSSAI modifies cr_NG_GMM_CapAny :=
  {
    erNSSAI       := '1'B
  };

  template (value) PayloadContainer cs_DummyPayloadContainer :=
  { // 24.501 cl. 9.11.3.39
    /* This is just a dummy to use in the GMM message as the NAS Emulator encodes the payload */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := omit,
    iel             := '0000'O,
    payload         := ''O
  };

  template (present) PayloadContainer cr_PayloadContainer(template IEI8_Type p_IEI := omit) :=
  { // 24.501 cl. 9.11.3.39
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := p_IEI, /* present in case of TLV; omit in case of LV */
    iel             := ?,     /* allow any length */
    payload         := ?      /* allow any value for now */
  };

  template (value) PayloadContainerType cs_PayloadContainerType (B4_Type p_ContainerType,
                                                                 template (omit) IEI4_Type p_IEI := omit) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 9.11.3.40 */
    iei         := p_IEI,
    container   := p_ContainerType
  };

  template (present) PayloadContainerType cr_PayloadContainerType (B4_Type p_ContainerType,
                                                                   template IEI4_Type p_IEI := omit) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 9.11.3.40 */
    iei         := p_IEI,
    container   := p_ContainerType
  };

  template (present) NG_PDU_SessionId cr_NG_PDU_SessionId(template IEI8_Type p_IEI := omit,
                                                          template (present) O1_Type p_Id := '00'O) :=
  { /* 24.501 cl. 9.11.3.41 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei  := p_IEI,
    sessionId := p_Id
  };

  template (value) NG_PDU_SessionId cs_NG_PDU_SessionId(template (value) O1_Type p_Id := '00'O,
                                                        template (omit) IEI8_Type p_IEI := '12'O) := // @sic R5s190338 sic@
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 9.11.3.41 */
    iei  := p_IEI,
    sessionId := p_Id
  };

  template (value) GMM_GSM_Cause cs_GMM_GSM_Cause(template (omit) IEI8_Type p_IEI,
                                                  NAS_CauseValue_Type p_Cause) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 9.11.3.2, 9.11.4.2 */
    iei         := p_IEI, /* present in case of TV; omit in case of V */
    causeValue  := p_Cause
  };

  template (value) ABBA cs_ABBA(octetstring p_ABBA,
                                template (omit) IEI8_Type p_IEI := '38'O,
                                Type4Length_Type p_Length := '02'O) :=
  { /* 24.501 cl. 9.11.3.10 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei        := p_IEI,
    iel        := p_Length,
    abbaValue  := p_ABBA
  };

  template (present) GMM_GSM_Cause cr_GMM_GSM_Cause(template IEI8_Type p_IEI,
                                                    template (present) NAS_CauseValue_Type p_Cause := ?) :=
  { /* 24.501 cl. 9.11.3.2, 9.11.4.2 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei         := p_IEI, /* present in case of TV; omit in case of V */
    causeValue  := p_Cause
  };

  template (present) PDU_SessionStatus cr_PDU_SessionStatusAny (IEI8_Type p_IEI := '50'O) :=
  { /* 24.501 cl. 9.11.3.44 */
    /* @status    APPROVED (NR5GC_IRAT) */
    iei       := p_IEI, /* present in case of TV or TLV; omit in case of V */
    iel       := ?, /* present in case of LV or TLV; omit in case of V */
    psi0_7    := ?,                         /* PSI(0)- PSI(7) */
    psi8_15   := ?,                        /* PSI(8)- PSI(15)*/
    spare     := *
  };

  template (present) PDU_SessionStatus cr_PDU_SessionStatus(B8_Type p_Psi0_7, B8_Type p_Psi8_15):=
  { /* @status    APPROVED (NR5GC_IRAT) */
    /* 24.501 cl. 9.11.3.44 */
    iei       := '50'O,
    iel       := '02'O,
    psi0_7    := p_Psi0_7,
    psi8_15   := p_Psi8_15,
    spare     := omit
  };

  template (present) NG_Request_Type cr_NG_Request_Type (B3_Type p_RequestValue) :=
  { /* 24.501 cl. 9.11.3.47 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := '8'H,                        // currently only used as TV
    spare           := tsc_Spare1,
    requestValue    := p_RequestValue
  };

  //----------------------------------------------------------------------------
  // NG Session Management (GSM) information elements (24.501 cl. 9.11.4)
  //----------------------------------------------------------------------------

  template (present) AlwaysOnPDUSessionReq cr_AlwaysOnRequested := crs_AlwaysOn('1'B);  /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) AlwaysOnPDUSessionInd cs_AlwaysOnAllowed := crs_AlwaysOn('1'B);      /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) AlwaysOnPDUSessionInd cs_AlwaysOnNotAllowed := crs_AlwaysOn('0'B);   /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) AlwaysOnPDUSessionInd crs_AlwaysOn (B1_Type p_Apsi) :=
  { // 24.501 cl. 9.11.4.3
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei         := '8'H,
    spare       := tsc_Spare3,
    apsi        := p_Apsi
  };

  template (value) EPSParameters cs_EPSParameter_QoS (octetstring p_Param) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    id              := '01'O,
    lenOfContent    := omit, // this field is included in the EPS QoS template @sic R5s210302 sic@
    epsParam        := p_Param
  };

  template (value) EPSParameters cs_EPSParameter_TFT (octetstring p_Param) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT) */
    id              := '03'O,
    lenOfContent    := omit, // this field is included in the TFT template
    epsParam        := p_Param
  };

   template (value) MappedEPSContext cs_OneMappedEPSContext (O1_Type p_EPSBearerId,
                                                             integer p_ParamLength,
                                                             template (value) EPSParameters p_EPSParams) :=
   { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    epsBearerId     := p_EPSBearerId,
    lenOfContext    := int2oct(p_ParamLength + 2, 2), // @sic R5s190987, R5s210302 sic@ operation code line + id1
    operationCode   := '01'B,
    spare           := tsc_Spare1,
    eBit            := '1'B,
    numOfParams     := '0001'B,
    epsParamsList   := {p_EPSParams}
  };

   template (value) MappedEPSContext cs_OneMappedEPSContextTwoParams (O1_Type p_EPSBearerId,
                                                             integer p_ParamLength,
                                                             template (value) EPSParameters p_EPSParam1,
                                                             template (value) EPSParameters p_EPSParam2) :=
   { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT) */
    epsBearerId     := p_EPSBearerId,
    lenOfContext    := int2oct(p_ParamLength + 3, 2),  // operation code line + id1 + id2
    operationCode   := '01'B,
    spare           := tsc_Spare1,
    eBit            := '1'B,
    numOfParams     := '0010'B,
    epsParamsList   := {p_EPSParam1, p_EPSParam2}
  };

  template (value) MappedEPSBearerContexts cs_OneMappedEPSBearerContextList (template (value) MappedEPSContext p_MappedEPSContext) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 9.11.4.8 */
    iei        := '75'O,
    iel        := int2oct(oct2int(valueof(p_MappedEPSContext.lenOfContext)) + 3, 2), // @sic R5s190987 sic@ bearer id + 2 octets of len
    mappedContextList := {p_MappedEPSContext}
  };

  template (value) MappedEPSBearerContexts cs_TwoMappedEPSBearerContextList (template (value) MappedEPSContext p_MappedEPSContext1,
                                                                             template (value) MappedEPSContext p_MappedEPSContext2) :=
  { /* @status    APPROVED (IMS, NR5GC) */
    /* 24.501 cl. 9.11.4.8 */
    iei        := '75'O,
    iel        := int2oct(oct2int(valueof(p_MappedEPSContext1.lenOfContext)) + 3 + oct2int(valueof(p_MappedEPSContext2.lenOfContext)) + 3, 2), // @sic R5s211478 sic@
    mappedContextList := {p_MappedEPSContext1, p_MappedEPSContext2}
  };

  template (value) PDU_SessionType cs_PDU_SessionType (B3_Type p_Type) :=
  { /* 24.501 cl. 9.11.4.11 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei        := omit,
    spare      := tsc_Spare1,
    typeValue  := p_Type
  };

  template (present) PDU_SessionType cr_PDU_SessionType(template (present) B3_Type p_Type) :=
  { /* 24.501 cl. 9.11.4.11 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei        := '9'H,       // @sic R5s190703 sic@
    spare      := tsc_Spare1,
    typeValue  := p_Type
  };

  template (value) SSC_Mode crs_SSC_Mode(template (omit) IEI4_Type p_IEI := omit,
                                        B3_Type p_SSCMode) :=
  { // 24.501 cl. 9.11.4.16
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei         := p_IEI,
    spare       := tsc_Spare1,
    sscModeValue := p_SSCMode
  };

  template (value) QoSParameters cs_QoSParameters (O1_Type p_Id,
                                                   Type4Length_Type p_Length,
                                                   octetstring p_Param) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    id           := p_Id,
    lenOfContent := p_Length,
    qosParam     := p_Param
  };

  template (value) QoS_Flow cs_QoS_Flow (B6_Type p_QFI, template (value) QoSParametersList p_ParamList) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    // @sic R5-194896 sic@
    spare2      := tsc_Spare2,
    qfi         := p_QFI,
    operationCode := '001'B,
    spare6      := tsc_Spare6,
    eBit        := '1'B,
    numOfParameters := int2bit(lengthof(p_ParamList), 6),
    parameterList := p_ParamList
  };

  template (value) PEIPS_AssistInfo cs_PEIPS_AssistInfo(template (value) IEI8_Type p_IEI,
                                                      template (value) Type4Length_Type p_IEL,
                                                      template (value)PEIPS_AssistIEList p_EIPS_AssistIEList):=
 {
    iei := p_IEI,
    iel := p_IEL,
    list:= p_EIPS_AssistIEList
 };
  //==================================================================
  //  QoS Templates
  //==================================================================

  /*
   * @desc      To convert the bit rate used in the QoS Flow parameters GFBR and MFBR
   *            according to 24.501 table 9.11.4.12.1
   * @param     p_Value
   * @param     p_Multiplier
   * @return    O3_Type
   * @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function fl_FlowParameterBitRate(integer p_Value,
                                   integer p_Multiplier) return O3_Type
  {
    var integer v_BitValue;
    var integer v_Unit;
    var integer i := 256;

    while ((p_Value mod i) != 0) {
      i := i / 4;
    }
    v_BitValue := p_Value / i;
    v_Unit := (f_FloorLog2(i) / 2) + 1;

    v_Unit := v_Unit + (5* (p_Multiplier -1));

    return int2oct(v_Unit, 1) & int2oct(v_BitValue, 2);
  }

  /*
   * @desc      Returns default Qos Flow according to 38.508-1 cl.4.8.2.3
   * @param     p_FlowNumber
   * @param     p_InterworkWithEPS  (default value: false)
   * @param     p_EPSBearerId  (default value: '0'H - invalid value, but will not be used if not InterworkingWithEPS)
   * @return    template (value) QoS_Flow
   * @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function f_BuildDefaultQosFlow (charstring p_FlowNumber,
                                   boolean p_InterworkWithEPS := false,
                                   O1_Type p_EPSBearerId := '00'O) return template (value) QoS_Flow
  {
    var template (value) QoSParametersList v_QoSParametersList;
    var B6_Type v_QFI;

    select (p_FlowNumber) {
      case ("1") {
        v_QFI := '000001'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '09'O)};
        if (p_InterworkWithEPS) {
          v_QoSParametersList[1] := cs_QoSParameters(tsc_QoSFlowParameter_EPSBearerId, '01'O, p_EPSBearerId); // @sic R5-204400 sic@
        }
      }
      case ("2") {
        v_QFI := '000010'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '05'O)};
        if (p_InterworkWithEPS) {
          v_QoSParametersList[1] := cs_QoSParameters(tsc_QoSFlowParameter_EPSBearerId, '01'O, p_EPSBearerId); // @sic R5-214436 sic@
        }
      }
      case ("2a") {
        v_QFI := '000100'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '05'O)};
      }
      case ("3") {
        v_QFI := '000101'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '05'O)};
      }
      case ("4") {
        v_QFI := '000110'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '05'O)};
      }
      case ("5") {
        v_QFI := '000111'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '01'O),
                                 cs_QoSParameters(tsc_QoSFlowParameter_GFBR_UL, '03'O, fl_FlowParameterBitRate(128, 1)), // @sic R5s210330, R5s210462 sic@
                                 cs_QoSParameters(tsc_QoSFlowParameter_GFBR_DL, '03'O, fl_FlowParameterBitRate(128, 1)),
                                 cs_QoSParameters(tsc_QoSFlowParameter_MFBR_UL, '03'O, fl_FlowParameterBitRate(320, 1)),
                                 cs_QoSParameters(tsc_QoSFlowParameter_MFBR_DL, '03'O, fl_FlowParameterBitRate(320, 1))};  // @sic R5s210330 sic@
        if (p_InterworkWithEPS) {
          v_QoSParametersList[5] := cs_QoSParameters(tsc_QoSFlowParameter_EPSBearerId, '01'O, p_EPSBearerId); // @sic R5s210330, R5-213155 sic@
        }
      }
      case ("6") {
        v_QFI := '001000'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '02'O),
                                 cs_QoSParameters(tsc_QoSFlowParameter_GFBR_UL, '03'O, fl_FlowParameterBitRate(72, 1)),
                                 cs_QoSParameters(tsc_QoSFlowParameter_GFBR_DL, '03'O, fl_FlowParameterBitRate(72, 1)),
                                 cs_QoSParameters(tsc_QoSFlowParameter_MFBR_UL, '03'O, fl_FlowParameterBitRate(816, 1)),
                                 cs_QoSParameters(tsc_QoSFlowParameter_MFBR_DL, '03'O, fl_FlowParameterBitRate(816, 1))};
        if (p_InterworkWithEPS) {
          v_QoSParametersList[5] := cs_QoSParameters(tsc_QoSFlowParameter_EPSBearerId, '01'O, p_EPSBearerId); // @sic R5-213155 sic@
        }
      }
      case ("7") { // @sic R5-211499 sic@
        v_QFI := '001001'B;
        v_QoSParametersList := { cs_QoSParameters(tsc_QoSFlowParameter_5QI, '01'O, '52'O)}; // 5QI 82
      }
    }
    return cs_QoS_Flow (v_QFI, v_QoSParametersList);
  }

  template (value) QoS_Flow cs_QoS_Flow1(boolean p_InterworkWithEPS := false,
                                         O1_Type p_EPSBearerId := '00'O) := f_BuildDefaultQosFlow("1", p_InterworkWithEPS, p_EPSBearerId);  /* @sic R5-204400 sic@ @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) QoS_Flow cs_QoS_Flow2(boolean p_InterworkWithEPS := false,
                                         O1_Type p_EPSBearerId := '00'O) := f_BuildDefaultQosFlow("2", p_InterworkWithEPS, p_EPSBearerId); /* @sic R5-204400 sic@  @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
  template (value) QoS_Flow cs_QoS_Flow2a := f_BuildDefaultQosFlow("2a");  /* @sic R5s201094 sic@  @status    APPROVED (NR5GC) */
  template (value) QoS_Flow cs_QoS_Flow3 := f_BuildDefaultQosFlow("3");   /* @sic R5s201094 sic@  @status    APPROVED (NR5GC) */
  template (value) QoS_Flow cs_QoS_Flow4 := f_BuildDefaultQosFlow("4");   /* @sic R5s201094 sic@  @status    APPROVED (NR5GC) */
  template (value) QoS_Flow cs_QoS_Flow5(boolean p_InterworkWithEPS := true, O1_Type p_EPSBearerId := '00'O) := f_BuildDefaultQosFlow("5", p_InterworkWithEPS, p_EPSBearerId);  /* @status    APPROVED (IMS, NR5GC) */
  template (value) QoS_Flow cs_QoS_Flow6(boolean p_InterworkWithEPS := true, O1_Type p_EPSBearerId := '00'O) := f_BuildDefaultQosFlow("6", p_InterworkWithEPS, p_EPSBearerId);  /* @status    APPROVED (IMS, NR5GC) */

  /*
   * @desc      Returns length of QoS Flow list
   * @param     p_FlowList
   * @return    Type6Length_Type
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
   function fl_NR5GC_QoSFlowsLength (template (value) QoS_FlowList p_FlowList) return Type6Length_Type
  {
    var integer i;
    var integer j;
    var integer v_Length:=0;

    for (j:= 0; j < lengthof(p_FlowList); j:= j+1) {
      if (isvalue(p_FlowList[j].parameterList)) { // @sic R5s210671 sic@
        for (i:= 0; i < lengthof(p_FlowList[j].parameterList); i:= i+1) {
          v_Length := v_Length + oct2int(valueof(p_FlowList[j].parameterList[i].lenOfContent));
          v_Length := v_Length + 2; // Parameter identifier & length @sic R5s190856 sic@
        }
      }
      v_Length := v_Length + 3; // QFI + Operation Code + Num of Parameters
    }
    return int2oct(v_Length, 2);
 }

  template (value) QoSFlowDescr cs_QoSFlowDescr (template (value) QoS_FlowList p_QoS_Flows) :=
  { /* 24.501 cl. 9.11.4.12 */
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei             := '79'O,
    iel             := fl_NR5GC_QoSFlowsLength(p_QoS_Flows), // @sic R5s190109, R5-194896 sic@
    listofFlows     := p_QoS_Flows
  };

  template (value) QoSFlowDescr cs_QoSFlowDescr1 := cs_QoSFlowDescr ({cs_QoS_Flow1});           /* @status      */
  template (value) QoSFlowDescr cs_QoSFlowDescr2 := cs_QoSFlowDescr ({cs_QoS_Flow2});           /* @status      */

  template (value) NG_PacketFilter_Type2 cs_PacketFilter_1MatchAll :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    spare          := tsc_Spare2,
    direction      := '11'B,       // bi-directional
    packetFilterId := '0001'B,     // @sic R5-216158 sic@
    len            := '01'O,
    contents       := '01'O        // match-all
  };

  template (value) NG_PacketFilter_Type2 cs_PacketFilter_MediaUDP (B4_Type p_Id, integer p_Port) :=
      cs_NG_PacketFilter_Type2 ('11'B,       // bi-directional
                                p_Id,
                                fl_BuildRemotePortRange(p_Port) & fl_BuildProtocolIdNextHeaderUDP());

  template (value) NG_PacketFilter_Type2 cs_NG_PacketFilter_Type2 (B2_Type p_Dir,
                                                                   B4_Type p_Id,
                                                                   octetstring p_Contents) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    spare          := tsc_Spare2,
    direction      := p_Dir,
    packetFilterId := p_Id,
    len            := int2oct(lengthof(p_Contents), 1),
    contents       := p_Contents
  };

  /*
   * @desc      Build a Remote Port Range Packet Filter according to 38.508-1 cl. 4.8.2
   * @param     p_Port
   * @return    octetstring
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function fl_BuildRemotePortRange (integer p_Port) return octetstring
  {
    var octetstring v_PacketFilter;

    v_PacketFilter := '51'O; // id = remote port range
    v_PacketFilter := v_PacketFilter & int2oct(p_Port, 2) & int2oct(p_Port+1, 2); // @sic R5s220046 sic@
    return v_PacketFilter;
  }

  /*
   * @desc      Build a Protocol Id Next Header Packet Filter according to 38.508-1 cl. 4.8.2
   * @return    octetstring
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function fl_BuildProtocolIdNextHeaderUDP () return octetstring
  {
    var octetstring v_PacketFilter;

    v_PacketFilter := '30'O; // id = remote port range
    v_PacketFilter := v_PacketFilter & int2oct(17, 1);
    return v_PacketFilter;
  }

  template (value) QoS_Rule cs_QoS_Rule (template (value) O1_Type p_Id,
                                         template (value) QoS_RuleU qos_rule_u) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    identifier          := p_Id,
    iel                 := fl_NR5GC_QoSRuleLength(valueof(qos_rule_u)),   // @sic R5s210074 sic@
    u                   := qos_rule_u
  };


  template (value) QoS_RuleU cs_QoS_RuleU_Create(
                                  template (value) B6_Type p_QFI,
                                  template (value) O1_Type p_Precedence,
                                  template (omit) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (value) B1_Type spare := tsc_Spare1,
                                  template (value) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    creat := {
      ruleOperationCode   := '001'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_and_add_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (value) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_and_add_pf := {
      ruleOperationCode   := '011'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_and_replace_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (omit) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_and_replace_pf := {
      ruleOperationCode   := '100'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_no_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_no_pf := {
      ruleOperationCode   := '110'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := '0000'B,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  /*
   * @desc      To build the default QoS Rules as defined in 38.508-1 cl. 4.8.2.1
   *            Builds rules #1 to #7
   *            If you need a (non-default) combination, please use f_BuildDefaultQoSRule and/or f_BuildQoSRuleRemoteAccess
   *            For #7, please use identifier 7_Voice or 7_VoiceVideo
   * @param     p_RuleNum
   * @param     p_IEI               (default value: omit)
   * @return    template (value) QoS_Rules
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function f_BuildDefaultQoSRules (charstring p_RuleNum,
                                   template (omit) IEI8_Type p_IEI := omit) return template (value) QoS_Rules
  {
    var template (value) QoS_Rules v_QoS_Rules;
    var template (value) QoS_Rule v_VoiceQoS;
    var template (value) QoS_Rule v_VoiceQoS2;

    v_VoiceQoS := cs_QoS_Rule('03'O,
                              cs_QoS_RuleU_Create(int2bit(7, 6),
                                                  '01'O,
                                                  { cs_PacketFilter_MediaUDP('0110'B, tsc_IMS_MediaPort_M1) },
                                                  '0'B)); // @sic R5-210627, R5s220046 sic@;
    v_VoiceQoS2 := cs_QoS_Rule('04'O,
                               cs_QoS_RuleU_Create(int2bit(8, 6),
                                                   '02'O,
                                                   { cs_PacketFilter_MediaUDP('0111'B, tsc_IMS_MediaPort_M2) },
                                                   '0'B));


    if (p_RuleNum == "7_Voice") {
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS}, p_IEI) // @sic R5-213440 sic@
    } else if (p_RuleNum == "7_Video") {
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS2}, p_IEI) // @sic R5-217796, R5s220046, R5s220336 sic@
    } else if (p_RuleNum == "7_VoiceVideo") {
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS, v_VoiceQoS2}, p_IEI) // @sic R5-210627, R5-216161, R5s220046 sic@
    } else {
      v_QoS_Rules := cs_QoS_Rules ({f_BuildDefaultQoSRule(p_RuleNum)}, p_IEI);
    }
    return v_QoS_Rules;
  }

  /*
   * @desc      To build a single default QoS Rule as defined in 38.508-1 cl. 4.8.2.1
   *            Builds rules #1 to #6
   * @param     p_RuleNum
   * @return    template (value) QoS_Rule
   * @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS)
   */
  function f_BuildDefaultQoSRule (charstring p_RuleNum) return template (value) QoS_Rule
  {
    var template (value) QoS_Rule v_QoS_Rule;

    select (p_RuleNum) {
      case ("1") {
        v_QoS_Rule := cs_QoS_Rule('01'O,
                                  cs_QoS_RuleU_Create(int2bit(1, 6),
                                                      'FF'O)); // @sic R5-202585 sic@
      }
      case ("2") {
        v_QoS_Rule := cs_QoS_Rule('02'O,
                                  cs_QoS_RuleU_Create(int2bit(2, 6),
                                                      'FF'O)); // @sic R5-202585 sic@
      }
      case ("3", "4", "4a", "5", "6") {
        v_QoS_Rule := f_BuildQoSRuleRemoteAccess (p_RuleNum);
      }
      case ("8") {
        v_QoS_Rule := cs_QoS_Rule('07'O,
                                  cs_QoS_RuleU_Create(int2bit(9, 6),
                                                      'FF'O)); // @sic R5-211499 sic@
      }
    }
    return v_QoS_Rule;
  }

  /*
   * @desc      Returns "number of packet filters" for a given input NG_PacketFilterList
   * @param     p_FilterList
   * @return    B4_Type
   */
  function fl_NR5GC_numOfPacketFilters (template (omit) NG_PacketFilterList_Type2 p_FilterList) return B4_Type
  {
    if (isvalue(p_FilterList)) {
      return int2bit(lengthof(valueof(p_FilterList)), 4);
    }
    return '0000'B;
  }


  /*
   * @desc      Returns length of QoS Rule for a given input
   * @param     p_FilterList
   * @return    Type6Length_Type
   * @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS)
   */
   function fl_NR5GC_QoSRuleLength (QoS_RuleU u) return Type6Length_Type
  {
    if (ischosen(u.creat)) {
      return int2oct(lengthof(bit2oct(encvalue(u.creat))), 2);
    }
    if (ischosen(u.delete)) {
      return int2oct(lengthof(bit2oct(encvalue(u.delete))), 2);
    }
    if (ischosen(u.modify_and_add_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_add_pf))), 2);
    }
    if (ischosen(u.modify_and_replace_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_replace_pf))), 2);
    }
    if (ischosen(u.modify_and_delete_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_delete_pf))), 2);
    }
    if (ischosen(u.modify_no_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_no_pf))), 2);
    }
    return int2oct(0, 2);
 }

  /*
   * @desc      Returns length of QoS Rules List
   * @param     p_Rules
   * @return    Type6Length_Type
   * @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS)
   */
   function fl_NR5GC_QosRulesLength (template (value) QoS_RuleList p_Rules) return Type6Length_Type
   {
     var integer i;
     var integer v_Length:=0;

     for (i:= 0; i < lengthof(p_Rules); i:= i+1) {
       v_Length := v_Length + oct2int (valueof(p_Rules[i].iel)) + 3; // @sic R5s190109 sic@
     }
     return int2oct(v_Length, 2);
   }

  template (value) QoS_Rules cs_QoS_Rules (template (value) QoS_RuleList p_Rules,
                                           template (omit) IEI8_Type p_IEI := omit) := // @sic R5s190673 sic@
  { // 24.501 cl. 9.11.4.13
    /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei         := p_IEI, /* present in case of TLV; omit in case of LV */
    iel         := fl_NR5GC_QosRulesLength(p_Rules), // @sic R5s190109 sic@
    listofQoSRules := p_Rules
  };

  template (value) Session_AMBR cs_Session_AMBR(template (omit) Type4Length_Type p_Length,
                                                O1_Type p_UnitDL,
                                                O2_Type p_DL,
                                                O1_Type p_UnitUL,
                                                O2_Type p_UL) :=
  { // 24.501 cl. 9.11.4.14
    /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    iei         := omit, /* present in case of TLV; omit in case of LV */
    iel         := p_Length, /* present in case of LV or TLV; omit in case of V */
    unitDL      := p_UnitDL,
    downlink    := p_DL,
    unitUL      := p_UnitUL,
    uplink      := p_UL
  };

  template (value) IMEISV_Request cds_NG_IMEISV_Request (B3_Type p_Value := tsc_IMEISV_Requested) modifies cs_IMEISV_Request_WithIEI :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    iei     := 'E'H
  };

  template (value) AllowedNSSAI cs_AllowedNSSAI (template (value) NAS_PlmnId p_PLMN,
                                                 B2_Type p_AccessType) :=
  { /* @status    APPROVED (NR5GC) */
    allowedNSSAI    := p_PLMN,
    spareBits       := tsc_Spare6,
    accessType      := p_AccessType
  };

  template (value) NG_NAS_DL_Message_Type  cs_NSSAI_DELETE_REQUEST (B8_Type p_DeleteNSSAI_Type,
                                                                    template (omit) NAS_PlmnId p_Configured,
                                                                    template (omit) AllowedNSSAI p_Allowed) :=
  { /* @status    APPROVED (NR5GC) */
    nssai_Delete_Request:= {
      skipIndicator            := tsc_Gen_SkipIndicator,                            /*    M V 1/2    */
      protocolDiscriminator    := tsc_LB_ProtocolDiscriminator,                     /*    M V 1/2    */
      messageType              := tsc_MsgType_NSSAI_DeleteReq,                      /*    M V 1      */
      deleteNSSAI_Type         := p_DeleteNSSAI_Type,
      configuredNSSAI          := p_Configured,   /* only present if deleteNSSAI_Type = DeleteConfigured */
      allowedNSSAI             := p_Allowed    /* only present if deleteNSSAI_Type = DeleteAllowed */
    }
  };

  template (present) NG_NAS_UL_Message_Type  cr_NSSAI_DELETE_RESPONSE :=
  { /* @status    APPROVED (NR5GC) */
    nssai_Delete_Response:= {
      skipIndicator            := tsc_Gen_SkipIndicator,                            /*    M V 1/2    */
      protocolDiscriminator    := tsc_LB_ProtocolDiscriminator,                     /*    M V 1/2    */
      messageType              := tsc_MsgType_NSSAI_DeleteResp                      /*    M V 1      */
    }
  };

  template (value) NG_NAS_DL_Message_Type  cs_SET_UAI_REQUEST (B2_Type p_PreferredRRCState) :=
  { /* @status    APPROVED (NR5GC) */
    set_UAI_Request:= {
      skipIndicator            := tsc_Gen_SkipIndicator,                            /*    M V 1/2    */
      protocolDiscriminator    := tsc_LB_ProtocolDiscriminator,                     /*    M V 1/2    */
      messageType              := tsc_MsgType_SetUAIReq,                            /*    M V 1      */
      spare                    := tsc_Spare6,
      preferredRRCState        := p_PreferredRRCState
    }
  };

  template (present) NG_NAS_UL_Message_Type  cr_SET_UAI_RESPONSE :=
  { /* @status    APPROVED (NR5GC) */
    set_UAI_Response:= {
      skipIndicator            := tsc_Gen_SkipIndicator,                            /*    M V 1/2    */
      protocolDiscriminator    := tsc_LB_ProtocolDiscriminator,                     /*    M V 1/2    */
      messageType              := tsc_MsgType_SetUAIResp                            /*    M V 1      */
    }
  };

template (present) NG_NAS_UL_Message_Type cr_NG_GMM_STATUS (template (present) GMM_GSM_Cause p_Cause) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    /* 24.501 cl. 8.2.29 */
    gmm_Status := {
      protocolDiscriminator   := tsc_EPD_GMM,                    /* cl. 9.2       M V 1   */
      spareHalfOctet          := tsc_SpareHalfOctet,             /* cl. 9.5       M V 1/2 */
      securityHeaderType      := tsc_SHT_NoSecurityProtection,   /* cl. 9.3       M V 1/2 */
      messageType             := tsc_MT_NG_GMM_Status,           /* cl. 9.7       M V 1   */
      gmmCause                := p_Cause                         /* cl. 9.11.3.2  M V 1   */
    }
  };

  template (value) NSSAI_LV cs_NSSAI_LV(Type4Length_Type p_Length,
                                        template (value) S_NSSAI_TypeList p_S_NSSAI):=
  { /* 24.501 cl. 9.11.3.37 */
    iel          := p_Length,
    s_nssai      := p_S_NSSAI
  };

  /*
   * @desc      Returns length of NSAG info element
   * @param     p_NSAG
   * @param     p_TaiList
   * @return    Type4Length_Type
   */
   function fl_NR5GC_NSAGLength (template (value) NSSAI_LV p_NSAG, template(omit) NG_TrackingAreaIdList_LV p_TaiList) return Type4Length_Type
  {
    var integer v_Length := oct2int(valueof(p_NSAG.iel));

    v_Length := v_Length + 3; // id + length of S-NSSAI list + priority

    if (isvalue(p_TaiList)) {
      v_Length := v_Length + oct2int(valueof(p_TaiList.iel)) + 1;  // + length of TAIList
    }
    return int2oct(v_Length, 1);
 }

   template (value) NSAG cs_NSAG_InfoElement(O1_Type                       p_Id,
                                            template(value) NSSAI_LV       p_NSAG,
                                            O1_Type                        p_Priority,
                                            template(omit) NG_TrackingAreaIdList_LV p_TaiList) :=
  { // 24.501 cl. 9.11.3.87, Figure 9.11.3.87.2: NSAG
    iel        := fl_NR5GC_NSAGLength(p_NSAG, p_TaiList),
    id         := p_Id,
    sNSSAIList := p_NSAG,
    priority   := p_Priority,
    taiList    := p_TaiList
  };

  template (value) NSAG_Info cs_NSAG_2Elements(template(value) NSAG p_NSAG1,
                                               template(value) NSAG p_NSAG2) :=
  { // 24.501 cl. 9.11.3.87, Figure 9.11.3.87.1: NSAG information information element
    iei      := '7C'O,
    iel      := int2oct(oct2int(valueof(p_NSAG1.iel)) + oct2int(valueof(p_NSAG2.iel)) + 2, 2), // 1 + 1 + (p_NSAG1.iel) + (p_NSAG2.iel)
    nsagList := {p_NSAG1, p_NSAG2}
  };

  /*
   * @desc      Build an NID according to 24.502 cl. 9.2.7
   * @return    template (value) NID
   */
  function fl_BuildNIDTemplate (integer p_NID, integer p_AssignmentMode := 1) return template (value) NID
  {
    var hexstring v_Hex := int2hex(p_NID, 10);
    var hexstring v_Digits2_9 := '00000000'H;
    var template (value) NID v_NIDTemplate := cs_NIDBlank (int2bit(p_AssignmentMode, 4));

    // arrange digits 2 to 9 in the order specified in 24.502 cl. 9.2.7
    v_Digits2_9  := v_Hex[2] & v_Hex[1] &
                    v_Hex[4] & v_Hex[3] &
                    v_Hex[6] & v_Hex[5] &
                    v_Hex[8] & v_Hex[7];

    v_NIDTemplate.digit1    := v_Hex[0];
    v_NIDTemplate.digits2_9 := v_Digits2_9;
    v_NIDTemplate.digit10   := v_Hex[9];

    return v_NIDTemplate;
  }

  template (value) NID cs_NIDBlank (B4_Type p_AssignmentMode) :=
  {                           /* 24.301 cl. 9.11.3.79 */
    iei         := '32'O, /* present in case of TV; omit in case of V */
    iel         := '06'O, /* present in case of LV or TLV; omit in case of V */
    digit1      := '0'H,
    assignmentMode := p_AssignmentMode,
    digits2_9   := '00000000'H,
    spare       := '0000'B,
    digit10     := '0'H
  };

  template (value) ExtdDRXParams cs_NG_NAS_EDRXParams (B4_Type p_PTW,
                                                       B4_Type p_EDRXVal,
                                                       template (omit) B8_Type p_ExtdPTW := omit) :=
  { /* @status    */
    iei          := '6E'O,
    iel          := '01'O, // length
    pagingTimeWindow := p_PTW,
    eDRXValue    := p_EDRXVal,
    extdPTW      := p_ExtdPTW
  };


}

