/******************************************************************************/
// @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: 2022-11-29 17:53:31 +0100 (Tue, 29 Nov 2022) $
// $Rev: 34751 $
/******************************************************************************/

module NAS_CommonTypeDefs {
  /* Module containing type definitions for EPS, UTRAN and/or GERAN */

  import from CommonDefs all;

  //****************************************************************************
  // Common Type definitions:
  //----------------------------------------------------------------------------

  //****************************************************************************
  //****************************************************************************

  type HalfOctet_Type           IEI4_Type; /* 4 bit info element identifier for type 1 IEs */
  type Octet_Type               IEI8_Type; /* 8 bit info element identifier */

  type O1_Type                  Type4Length_Type with { variant "COMP(nosign), BYTEORDER(last)" };
  type O2_Type                  Type6Length_Type with { variant "COMP(nosign), BYTEORDER(last)" };

  type HalfOctet_Type           SpareHalfOctet;

  type hexstring   NAS_Mcc length(3) with { variant "FIELDLENGTH(3)" };   //* @desc Type which can be used to represent an MCC (as string of 3 decimal digits).

  type record of hexstring EmergencyNumList;

  type enumerated PDU_PDN_DNN_Type {V2X_DNN, MIOT_DNN, URLLC_DNN, IMS_DNN, Internet_DNN, Emergency_PDN, Ethernet_DNN, None};          /* @status    APPROVED (NR5GC) @sic R5-204399, R5-221467 sic@ */
  type enumerated APN_DefaultConfiguration_Type {None, internet, ims, urllc, miot, v2x, ethernet};  // @sic R5-221467, R5-227472 sic@
  type enumerated InterworkWithoutN26 {NOT_SUPPORTED,  /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
                                       SUPPORTED}

  //****************************************************************************
  // NAS PROTOCOL DEFINITIONS: IEs
  //----------------------------------------------------------------------------
  // General Info Elements (24.301 cl. 9)
  //----------------------------------------------------------------------------

  type B4_Type     SecurityHeaderType;                       /* 24.301 cl. 9.3.1 */
  type B4_Type     ProtocolDiscriminator;                    /* 24.301 cl. 9.2 and 24.007 cl. 11.2.3.1.1 */
  type Octet_Type  ProcedureTransactionIdentifier;           /* 24.301 cl. 9.4 */
  type B4_Type     SkipIndicator;                            /* 24.007 cl. 11.2.3.1.2 */
  type B8_Type     MessageType;                              /* 24.301 cl. 9.8 */
  type Octet_Type  NAS_SequenceNumber;                       /* 24.301 cl. 9.6 */

  type B3_Type     NAS_AttDetValue_Type;
  type B3_Type     KeySeq;                                   /* ciphering key sequence
                                                                3G TS 24008 cl. 10.5.1.2 */
  type B3_Type     NAS_KsiValue;
  type O3_Type     NAS_PlmnId;

  type O4_Type     NAS_Tmsi;
  type O4_Type     NAS_P_Tmsi;

  type O2_Type     NAS_Lac;
  type O1_Type     NAS_Rac;

  type B3_Type PdnTypeValue;

  type bitstring   BcdDigit_Bit length(4) with { variant "FIELDLENGTH(4)" };

  type B3_Type              NAS_IdType;
  type B8_Type              NAS_CauseValue_Type;

  type B1_Type TmsiStatusValue;

  type enumerated PS_MODE {VOICE_CENTRIC, DATA_CENTRIC};        /* @status  @sic R5s120274 sic@   */
  type enumerated CS_PS_MODE {VOICE_CENTRIC, DATA_CENTRIC};     /* @status    APPROVED */
  // This is here because it's the best place for it
  const NAS_Lac tsc_LAC_Def := '0001'O ;                        /* Default NAS LAC, the value may need to be updated in CS combined/CS fallback test cases
                                                                   @status    APPROVED
                                                                   @sic R5s090180 sic@ */
  const NAS_Lac tsc_LAC_Deleted := 'FFFE'O;                     /* @status    APPROVED (UTRAN) */

  //-----------------------------------------------------------------------------
  // Defined in 24.008, but also referenced from 24.301
  //-----------------------------------------------------------------------------

  // =============================================================================
  // Structured Type Definition
  // 3G TS 24.008, section 10.5.6.1
  // -----------------------------------------------------------------------------
  type record AccessPointName {                                 /* 24.301 cl. 9.9.4.1 -> 24.008 cl. 10.5.6.1 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel,
    octetstring                 nameValue length(1..100)
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (nameValue)";
    variant (iel) "BYTEORDER(last)";
    variant (nameValue) "BYTEORDER(last)";
  };

  type record AdditionalUpdateType {                          /* 24.301 cl. 9.9.3.0B @sic R5s100135 sic@ */
    IEI4_Type                   iei,                          // currently only used as TV
    B2_Type                     pnb_CIOT,                     // 0=no additional info, 1=CP, 2=UP, 3=reserved @sic R5s160711 Baseline Moving sic@
    B1_Type                     signallingActiveFlag,         // @sic R5s160711 Baseline Moving sic@
    B1_Type                     addUpdateTypeValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Ciphering Key Sequence Number
  // 3G TS 24.008 cl. 10.5.1.2
  // -----------------------------------------------------------------------------
  type record CiphKeySeqNum {
    IEI4_Type            iei  optional,                   // '1000'B
    B1_Type              spare1,
    KeySeq               keySeq
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Priority Level
  // 3G TS 24.008 cl. 10.5.6.19 / 24.301 9.9.4.2A
  // -----------------------------------------------------------------------------
  type record ConnectivityType {
    IEI4_Type            iei,
    B4_Type              connectivityValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // 3G TS 24.008, section 10.5.5.5/ 24.301 cl. 9.9.3.7
  // -----------------------------------------------------------------------------
  type record DetachType {
    // IEI is always skipped
    B1_Type                     switchOff,
    NAS_AttDetValue_Type        typeOfDetach
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Device Properties
  // 3G TS 24.008 cl. 10.5.7.8
  // -----------------------------------------------------------------------------
  type record DeviceProperties {
    IEI4_Type            iei,
    B3_Type              spare,
    B1_Type              lowPriority
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // DRX paramter
  // 3GPP 24.008 / 10.5.5.6
  // -----------------------------------------------------------------------------
  type record DRXparameter {
    IEI8_Type            iei   optional,        // '00100111'B (hex 27)
    B8_Type              splitPGcycleCode,      // Split PG cycle code
    B4_Type              cnDRXcoef,             // CN specific DRX cycle length coefficient
    B1_Type              splitOnCCCH,           // Split on CCCCH
    B3_Type              nonDRXtimer            // non-DRX timer
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Emergency Service Category
  // 3GPP 24.008 / 10.5.4.33
  // -----------------------------------------------------------------------------
  type record EmergServCat {
    B1_Type              spare,
    B7_Type              emergSCValue             // Emergency Service Category value
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Emergency Number
  // 3G TS 24.008 cl. 10.5.3.13
  // -----------------------------------------------------------------------------
  type record EmergNum {
    Type4Length_Type   len,                   // length
    EmergServCat       emergServCat,          // Emergency Service Category
    octetstring        digits length(0..10)   // BCD numbers
  } with {
    variant "FIELDORDER(msb)";
    variant (len) "LENGTHTO (emergServCat, digits)";
    variant (len) "BYTEORDER(last)";
    variant (digits) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Emergency Number List
  // 3G TS 24.008 cl. 10.5.3.13
  // -----------------------------------------------------------------------------
  type record EmergNumList {
    IEI8_Type            iei,                   // '00110100'B (34 hex) @sic R5s110420 sic@
    Type4Length_Type     iel,                   // length @sic R5s110420 sic@
    record length (1..10) of EmergNum  emergNum             // Emergency Number
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (emergNum)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // GPRS timer
  // 3GPP 24.008 / 10.5.7.3
  // -----------------------------------------------------------------------------
  type record GPRS_Timer {                                       /* 24.301 cl. 9.9.3.14 -> 24.008 cl. 10.5.7.3 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    GprsTimerUnit               unit,
    B5_Type                     timerValue
  } with {
    variant "FIELDORDER(msb)";
  };

  type B3_Type GprsTimerUnit;

  // =============================================================================
  // Structured Type Definition
  // GPRS timer 2 or GPRS timer 3 (definition is identical)
  // 3GPP 24.008 / 10.5.7.4(a)
  // -----------------------------------------------------------------------------
  type record GPRS_Timer2 {
    IEI8_Type            iei,               // @sic R5s110420, R5s160712 Baseline Moving sic@
    Type4Length_Type     iel,                   // length  @sic R5s110420 sic@
    GprsTimerUnit        unit,                      // Unit
    B5_Type              gprsTimerValue             // Timer  value
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (unit, gprsTimerValue)";
    variant (iel) "BYTEORDER(last)";
  };

  type GPRS_Timer2 GPRS_Timer3; // definition is identical @sic R5s150329 Baseline Moving sic@

  // =============================================================================
  // Structured Type Definition
  // IMEISV Request
  // 3GPP 24.008 /  10.5.5.10
  // -----------------------------------------------------------------------------
  type record IMEISV_Request {                                  /* 24.301 cl. 9.9.3.16 -> 24.008 cl. 10.5.5.10 */
    IEI4_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    B1_Type                     spare,
    B3_Type                     requestValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Location Area Identification Value
  // 3G TS 24.008 cl. 10.5.1.3
  // -----------------------------------------------------------------------------
  type record LocAreaId {
    IEI8_Type   iei          optional,
    NAS_PlmnId  plmn,        // MCC  + MNC 3 digits each
    NAS_Lac     lac          // LAC
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // RoutingAreaId
  // 3GPP 24.008 /  10.5.5.15
  // -----------------------------------------------------------------------------
  type record RoutingAreaId             {                       /* 24.301 cl. 9.9.3.24 -> 24.008 cl. 10.5.5.15 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    LocAreaId                   lai,                            /* MCC  + MNC + LAC */
    O1_Type                     rac                             /* RAC */
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // 24.007, clause 10.5.6.9
  // -----------------------------------------------------------------------------
  type record LLC_SAPI {                                        /* 24.301 cl. 9.9.4.4 -> 24.008 cl. 10.5.6.9 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    B4_Type                     spare,
    B4_Type                     llcSapiValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Mobile Identity
  // 3G TS 24.008 cl. 10.5.1.4
  // Maximum number of digits is 16 (IMEISV). Filler may be used.
  // -----------------------------------------------------------------------------
  type record MobileIdentity {
    IEI8_Type            iei optional,                   // '00100011'B
    Type4Length_Type     iel,
    BcdDigit_Bit         idDigit1,                // 1st identitity digit
    B1_Type              oddEvenInd,              // Odd/even indicator
    NAS_IdType           typeOfId,                // Type of identity
    octetstring          otherDigits length(0..10) // Other identity digits (10 octets rather than 8 to cover Guti as well)
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (idDigit1, oddEvenInd, typeOfId, otherDigits)";
    variant (iel) "BYTEORDER(last)";
    variant (otherDigits) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Mobile Station Classmark 2
  // 3G TS 24.008 cl. 10.5.1.6
  // -----------------------------------------------------------------------------
  type record MS_Clsmk2 {
    IEI8_Type            iei  optional,
    Type4Length_Type     iel,    // @sic R5s110420 sic@
    B1_Type              spare1_1,              // Spare bit
    B2_Type              revLvl,                // Revision Level
    B1_Type              eSIND,                 // Early Sending Indication
    B1_Type              a5_1,                  // Algorithm A5/1 Support
    B3_Type              rFPwrCap,              // RF Power Capability
    B1_Type              spare1_2,              // Spare bit
    B1_Type              pSCap,                 // Pseudo Synchronisation Capability
    B2_Type              sSSI,                  // SS Screen Indicator
    B1_Type              sMCap,                 // Short Message Capability
    B1_Type              vBS,                   // VBS Capability
    B1_Type              vGCS,                  // VGCS Capability
    B1_Type              fC,                    // Frequency Capability
    B1_Type              cM3,                   // Classmark 3 Indicator
    B1_Type              spare1_3,              // Spare bit
    B1_Type              lCSVA,                 // LCS VA Capability
    B1_Type              uCS2,                  // UCS2 Encoding  Support
    B1_Type              soLSA,                 // SoLSA  Support
    B1_Type              cMSP,                  // CM Service Prompt Support
    B1_Type              a5_3,                  // Algorithm A5/3 Support
    B1_Type              a5_2                   // Algorithm A5/2 Support
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare1_1, revLvl, eSIND, a5_1, rFPwrCap, spare1_2, pSCap, sSSI, sMCap, vBS, vGCS, fC, cM3, spare1_3, lCSVA, uCS2, soLSA, cMSP, a5_3, a5_2)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Mobile station classmark 3
  // 3GPP TS 24.008 clause  10.5.1.7
  // The information element has 34 octets maximum length
  // -----------------------------------------------------------------------------
  type record MS_Clsmk3 {
    IEI8_Type            iei                        optional, // 0x20
    Type4Length_Type     iel                        optional, // OCTETSTRING [1]
    B1_Type              spareBit,                            // spare bit @sic R5s120178 Baseline Moving sic@
    B3_Type              multibandSupported,                  //  @sic R5s120178 Baseline Moving sic@
    B1_Type              a5_7,                                // a5/7 algorithm supported @sic R5s120178 Baseline Moving sic@
    B1_Type              a5_6,                                // a5/6 algorithm supported @sic R5s120178 Baseline Moving sic@
    B1_Type              a5_5,                                // a5/5 algorithm supported @sic R5s120178 Baseline Moving sic@
    B1_Type              a5_4,                                // a5/4 algorithm supported @sic R5s120178 Baseline Moving sic@
    B4_Type              associatedRadioCapabilty2  optional, // present if multibandSupported = 101 or 110
    B4_Type              spareBits1                 optional, // present if multibandSupported = 001 or 010 or 100
    B4_Type              associatedRadioCapabilty1  optional, // present if multibandSupported = 001 or 010 or 100 or 101 or 110
    B1_Type              maskBit1                   optional,
    B3_Type              rGSM_RadioCapability       optional, // R-GSM band associated radio capability not present if maskBit1 = 0
    B1_Type              maskBit2                   optional,
    B5_Type              multiSlotClass             optional, // multi slot class not present if multiSlotClass = 0
    B1_Type              uCS2Treatment              optional,
    B1_Type              extMeasurementCapability   optional, // extended measurement capability
    B1_Type              maskBit3                   optional,
    MS_MeasCapability    msMeasurementCapability    optional, // MS measurement capability
    // not present if maskBit3 = 0
    B1_Type              maskBit4                   optional,
    B5_Type              msPositioningMethod        optional, // MS positioning method capability
    // not present if maskBit4 = 0
    B1_Type              maskBit5                   optional,
    B5_Type              eDGE_MultiSlot             optional, // EDGE multi slot capability
    // not present if maskB5_Type = 0
    B1_Type              maskBit6                   optional,
    EDGE_Struct          psk8_Struct                optional, // 8PSK struct
    // not present if maskB6_Type = 0
    B1_Type              maskBit7                   optional,
    B2_Type              gSM400BandsSupported       optional, // not present if maskBIt7 = 0
    B4_Type              gSM400AssociatedRadioCapability  optional, // not present if gSM400BandsSupported = 00 or maskB7_Type = 0
    B1_Type              maskBit8                   optional,
    B4_Type              gSM850AssociatedRadiioCapability optional, // not present if maskBIt8 = 0
    B1_Type              maskBit9                   optional,
    B4_Type              pCS1900AssociatedRadiioCapability optional, // not present if maskBIt9 = 0
    B1_Type              uMTS_FDD_RAT_Capability    optional,
    B1_Type              uMTS384TDD_RAT_Capability  optional,
    B1_Type              cDMA2000_RAT_Capability    optional,
    B1_Type              maskBit10                  optional,
    B2_Type              dTM_GPRS_MultiSlotSubclass optional, // not present if maskBit10 = 0
    B1_Type              singleSlotDTM              optional, // not present if maskBit10 = 0
    B1_Type              maskBit11                  optional, // not present if maskBit10 = 0
    B2_Type              dTM_EGPRS_MultiSlorSubclass optional, // not present if maskBit10 = 0 or maskBit11 = 0
    B1_Type              maskBit12                  optional,
    B4_Type              singleBandSupport          optional, // not present if maskBit12 = 0
    B1_Type              maskBit13                  optional,
    B4_Type              gSM700AssociatedRadioCapability optional, // not present if maskBit13 = 0
    B1_Type              uMTS128TDD_RAT_Capability  optional,
    B1_Type              gERANFeatPack1             optional,
    B1_Type              mask14                     optional,
    B2_Type              extDTM_GPRS_MultiSlotSubclass  optional, // not present if maskBit14 = 0
    B2_Type              etxDTM_EGPRS_MultiSlotSubclass optional, // not present if maskBit14 = 0
    B1_Type              mask15                     optional,
    B2_Type              highMultislotCap           optional, // not present if mask15 = 0
    B1_Type              spare2                     optional, // value '1' indicated GERAN Iu Mode Capabilities in earlier versions @sic R5s150329 Baseline Moving sic@
    B1_Type              gERANFeatPack2             optional,
    B2_Type              gMSKMultislotPowerProfile  optional,
    B2_Type              pSKMultislotPowerProfile   optional,
    B1_Type              mask17                     optional, // rel 6 features
    B2_Type              tGSM400BandsSupported      optional, // not present if maskBit17 = 0
    B4_Type              tGSM400AssocRadioCap       optional, // not present if maskBit17 = 0
    B1_Type              spare                      optional, // Set to 0 @sic R5s110176 Baseline Moving sic@
    B2_Type              dlAdvancedRxPerf           optional,
    B1_Type              dTMEhancCap                optional,
    B1_Type              mask19                     optional,
    B3_Type              dTMGPRSHighMultislotClass  optional, // not present if maskBit19 = 0
    B1_Type              offsetReq                  optional, // not present if maskBit19 = 0
    B1_Type              mask20                     optional, // not present if maskBit19 = 0
    B3_Type              dTMEGPRSHighMultislotClass optional, // not present if maskBit19 and maskBit20 = 0
    B1_Type              rptdACCHCap                optional,
    B1_Type              mask21                     optional,
    B4_Type              gsm710AssocRadioCap        optional, // not present if maskBit21 = 0
    B1_Type              mask22                     optional,
    B4_Type              tgsm810AssocRadioCap       optional, // not present if maskBit22 = 0
    B1_Type              cipheringModeSettingCap    optional,
    B1_Type              addPositionCap             optional,
    B1_Type              eutraFDDSupport            optional, // rel 8 features
    B1_Type              eutraTDDSupport            optional,
    B1_Type              eutraMeasAndReporting      optional, // @sic R5s100135 sic@
    B1_Type              priorityBasedReselection   optional,  // @sic R5s110176 Baseline Moving sic@
    B1_Type              utraCSGCellsReporting      optional,  // @sic R5s110176 Baseline Moving sic@
    B2_Type              vamosLevel                 optional, // @sic R5s110176 Baseline Moving sic@
    B2_Type              tighterCap                 optional, // @sic R5s120178 Baseline Moving sic@
    B1_Type              selectCipheringDLSACCH     optional, // @sic R5s120178 Baseline Moving sic@
    B2_Type              csPS_SRVCC_G2U             optional, // @sic R5s130195 Baseline Moving sic@
    B2_Type              csPS_SRVCC_G2E             optional, // @sic R5s130195 Baseline Moving sic@
    B1_Type              geranNwkSharing            optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              eutraWidebandRSRQMeas      optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              erBandSupport              optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              utraMultipleFreqBandInd    optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              eutraMultipleFreqBandInd   optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              xtdTSCSetCap               optional, // @sic R5s150329 Baseline Moving sic@
    B1_Type              xtdEARFCNValueRange        optional, // @sic R5s160712 Baseline Moving sic@
    bitstring            spareBits2                 optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spareBit, multibandSupported, a5_7, a5_6, a5_5, a5_4, associatedRadioCapabilty2, spareBits1, associatedRadioCapabilty1, maskBit1, rGSM_RadioCapability, maskBit2, multiSlotClass, uCS2Treatment, extMeasurementCapability, maskBit3, msMeasurementCapability, maskBit4, msPositioningMethod, maskBit5, eDGE_MultiSlot, maskBit6, psk8_Struct, maskBit7, gSM400BandsSupported, gSM400AssociatedRadioCapability, maskBit8, gSM850AssociatedRadiioCapability, maskBit9, pCS1900AssociatedRadiioCapability, uMTS_FDD_RAT_Capability, uMTS384TDD_RAT_Capability, cDMA2000_RAT_Capability, maskBit10, dTM_GPRS_MultiSlotSubclass, singleSlotDTM, maskBit11, dTM_EGPRS_MultiSlorSubclass, maskBit12, singleBandSupport, maskBit13, gSM700AssociatedRadioCapability, uMTS128TDD_RAT_Capability, gERANFeatPack1, mask14, extDTM_GPRS_MultiSlotSubclass, etxDTM_EGPRS_MultiSlotSubclass, mask15, highMultislotCap, spare2, gERANFeatPack2, gMSKMultislotPowerProfile, pSKMultislotPowerProfile, mask17, tGSM400BandsSupported, tGSM400AssocRadioCap, spare, dlAdvancedRxPerf, dTMEhancCap, mask19, dTMGPRSHighMultislotClass, offsetReq, mask20, dTMEGPRSHighMultislotClass, rptdACCHCap, mask21, gsm710AssocRadioCap, mask22, tgsm810AssocRadioCap, cipheringModeSettingCap, addPositionCap, eutraFDDSupport, eutraTDDSupport, eutraMeasAndReporting, priorityBasedReselection, utraCSGCellsReporting, vamosLevel, tighterCap, selectCipheringDLSACCH, csPS_SRVCC_G2U, csPS_SRVCC_G2E, geranNwkSharing, eutraWidebandRSRQMeas, erBandSupport, utraMultipleFreqBandInd, eutraMultipleFreqBandInd, xtdTSCSetCap, xtdEARFCNValueRange, spareBits2)";
    variant (iel) "BYTEORDER(last)";
    variant (spareBits2) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Reference : 3GPP TS 24.008 clause 10.5.1.7
  // -----------------------------------------------------------------------------
  type record EDGE_Struct {
    B1_Type              modulationCapability,
    B1_Type              pwrMask1,
    B2_Type              eDGE_RF_PowerCapability1  optional, // not present if pwrMask1 = 0
    B1_Type              pwrMask2,
    B2_Type              eDGE_RF_PowerCapability2  optional // not present if pwrMask2 = 0
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Reference : 3GPP TS 24.008 clause 10.5.1.7
  // -----------------------------------------------------------------------------
  type record MS_MeasCapability {
    B4_Type              sMS_VALUE,
    B4_Type              sM_VALUE
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // MS network capability
  // 3GPP 24.008 /  10.5.5.12
  // -----------------------------------------------------------------------------
  type record MS_NetworkCap {                            /* 24.301 cl. 9.9.3.18 -> 24.008 cl. 10.5.5.12 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    Type4Length_Type            iel,                      // @sic R5s110420 sic@
    B1_Type                     gea1,
    B1_Type                     smCapDedicated,
    B1_Type                     smCapGPRS,
    B1_Type                     ucs2,
    B2_Type                     ssScreeningIndicator,
    B1_Type                     soLSACap,
    B1_Type                     revLevelIndicator,
    B1_Type                     pfcFeatureMode,
    B1_Type                     gea2,
    B1_Type                     gea3,
    B1_Type                     gea4,
    B1_Type                     gea5,
    B1_Type                     gea6,
    B1_Type                     gea7,
    B1_Type                     lcsVACap optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     psHOtoUTRAN_IuModeCap optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     psHOtoEUTRAN_S1ModeCap optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     emmCombinedCap optional,         // @sic R5s110176 Baseline Moving, R5s130477 not present for r99 sic@
    B1_Type                     isrSupport optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     srvccToGERAN_UTRANCap optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     epcCap optional, // @sic R5s130477 not present for r99 sic@
    B1_Type                     nfCap optional,         // @sic R5s110176 Baseline Moving, not present for Rel-8 R5s110242 sic@
    B1_Type                     gERANNtwkShareCap optional,         // @sic R5s130195 Baseline Moving, not present for Rel-8 sic@
    B1_Type                     userPlaneIntegrityProtSupport optional,         // @sic R5s160712 Baseline Moving, not present for Rel-12 sic@
    B1_Type                     gia4 optional,         // @sic R5s160712 Baseline Moving, not present for Rel-12 sic@
    B1_Type                     gia5 optional,         // @sic R5s160712 Baseline Moving, not present for Rel-12 sic@
    B1_Type                     gia6 optional,         // @sic R5s160712 Baseline Moving, not present for Rel-12 sic@
    B1_Type                     gia7 optional,         // @sic R5s160712 Baseline Moving, not present for Rel-12 sic@
    B1_Type                     ePCOInd optional,  // @sic R5s170598 Baseline Moving sic@
    B1_Type                     restrictEnhancedCoverageCap optional,  // @sic R5s170598 Baseline Moving sic@
    B1_Type                     dualConnectivityEUTRA_NR optional, // @sic R5s180553 Baseline Moving sic@
    bitstring                   spareBits length (0..43) optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (gea1, smCapDedicated, smCapGPRS, ucs2, ssScreeningIndicator, soLSACap, revLevelIndicator, pfcFeatureMode, gea2, gea3, gea4, gea5, gea6, gea7, lcsVACap, psHOtoUTRAN_IuModeCap, psHOtoEUTRAN_S1ModeCap, emmCombinedCap, isrSupport, srvccToGERAN_UTRANCap, epcCap, nfCap, gERANNtwkShareCap, userPlaneIntegrityProtSupport, gia4, gia5, gia6, gia7, ePCOInd, restrictEnhancedCoverageCap, dualConnectivityEUTRA_NR, spareBits)";
    variant (iel) "BYTEORDER(last)";
    variant (spareBits) "BYTEORDER(last)";
  };

// =============================================================================
// Structured Type Definition
// Non-3GPP NW provided Policies
// 3G TS 24.008 cl. 10.5.5.37  / 24.301 cl. 9.9.3.49
// -----------------------------------------------------------------------------
type record Non3GPP_NW_ProvidedPolicies {
  IEI4_Type            iei,
  B3_Type              spareBits,
  B1_Type              n3ENInd
  } with {
    variant "FIELDORDER(msb)";
};

  // =============================================================================
  // Structured Type Definition
  // Additional Network Feature Support
  // 3G TS 24.008 cl. 10.5.5.31
  // -----------------------------------------------------------------------------
  type record NwkResourceId {
    IEI8_Type            iei,                   //
    Type4Length_Type     iel,                   //
    B10_Type              nriContainerValue,      // @sic R5s140778 sic@
    B6_Type              spareBits                // @sic R5s140778 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (nriContainerValue, spareBits)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // PacketFlowIdentifier
  // 24.008, section 10.5.6.11
  // -----------------------------------------------------------------------------
  type record PacketFlowIdentifier {                            /* 24.301 cl. 9.9.4.5 -> 24.008 cl. 10.5.6.11 */
    IEI8_Type                   iei,   // @sic R5s110420 sic@
    Type4Length_Type            iel,   // @sic R5s110420 sic@
    B1_Type                     spare,
    B7_Type                     idValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, idValue)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // PLMN Identity of the CN Operator
  // 3G TS 24.008 cl. 10.5.5.36
  // -----------------------------------------------------------------------------
  type record PLMN_IdIE {
    IEI8_Type                   iei,
    Type4Length_Type            iel,
    NAS_PlmnId                  plmn
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (plmn)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // PLMN list
  // 3G TS 24.008 cl. 10.5.1.13
  // -----------------------------------------------------------------------------
  type record PLMN_List {                         /* 24.301 cl. 9.9.2.4 -> 24.008 cl. 10.5.1.13 */
    IEI8_Type                   iei,              // @sic R5s110420 sic@
    Type4Length_Type            iel,              // @sic R5s110420 sic@
    record length(1..15) of
    NAS_PlmnId                  plmnList          /* list of PLMNs */
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (plmnList)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // MS network feature support
  // 3GPP 24.008 /  10.5.5.15
  // -----------------------------------------------------------------------------
  type record MS_NetworkFeatureSupport {                            /* 24.301 cl. 9.9.2.0A -> 24.008 cl. 10.5.5.15 */
    IEI4_Type                   iei,
    B3_Type                     spare,
    B1_Type                     extdPeriodicTimers
  } with {
    variant "FIELDORDER(msb)";
  };

  type PLMN_List.plmnList NAS_PlmnIdList_Type;

  // =============================================================================
  // Structured Type Definition
  // ProtocolConfigOptions
  // 3G TS 24.008 cl. 10.5.6.3
  // -----------------------------------------------------------------------------
  type record ProtocolConfigOptions {                    /* 24.301 cl. 9.9.4.8 -> 24.008 cl. 10.5.6.3 */
    IEI8_Type                   iei,          // @sic R5s110420 sic@
    Type4Length_Type            iel,
    B1_Type                     ext,
    B4_Type                     spare,
    B3_Type                     configProtocol,
    NAS_ProtocolConfigOptions_Type pco optional
  } with {
    variant "FIELDORDER(msb)";
    // FIXME variant (pco) "FORCEOMIT(protocolLongLength)";
    variant (iel) "LENGTHTO (ext, spare, configProtocol, pco)";
    variant (iel) "BYTEORDER(last)";
  };

  type record ProtocolContainer {
    O2_Type                   protocolID,                     /* id is always 2 octets */
    Type4Length_Type          protocolLength        optional, // @sic R5s201386 Baseline Moving sic@
    Type6Length_Type          protocolLongLength    optional, // always set to omit in UL @sic R5s201386 Baseline Moving sic@
    octetstring               content               optional
  } with {
    variant "FIELDORDER(msb)";
    variant (protocolLength) "LENGTHTO (content)";
    variant (protocolLength) "BYTEORDER(last)";
    variant (content) "BYTEORDER(last)";
  };

  type record length (0..83) of ProtocolContainer NAS_ProtocolConfigOptions_Type;

  type record APNRateControlParams { // 3GPP 24.008 /  10.5.6.3.2
    B4_Type     spare,
    B1_Type     aer,
    B3_Type     uplinkTimeUnit,
    O3_Type     maxUplinkRate  optional // @sic R5s170598 Baseline Moving sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (maxUplinkRate) "BYTEORDER(last)";
  };
  // =============================================================================
  // Structured Type Definition
  // P-TMSI signature
  // 3GPP 24.008 /  10.5.5.8
  // -----------------------------------------------------------------------------
  type record PTMSI_Signature {                                 /* 24.301 cl. 9.9.3.23 -> 24.008 cl. 10.5.5.8 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    Type4Length_Type            iel                   optional, // only present in 24.008 version of DETACH REQUEST message
    O3_Type                     signatureValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (signatureValue)";
    variant (iel) "BYTEORDER(last)";
    variant (signatureValue) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // 24.008, clause 10.5.6.5
  // -----------------------------------------------------------------------------
  type record QualityOfService {                                /* 24.301 cl. 9.9.4.9 -> 24.008 cl. 10.5.6.5 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel,
    B2_Type                     spare1,
    B3_Type                     delayClass,
    B3_Type                     relabilityClass,
    B4_Type                     peakThroughput,
    B1_Type                     spare2,
    B3_Type                     precedenceClass,
    B3_Type                     spare3,
    B5_Type                     meanThroughput,
    B3_Type                     trafficClass,
    B2_Type                     deliveryOrder,
    B3_Type                     deliveryErrorSDU,
    B8_Type                     maxSduSize,
    B8_Type                     maxBitRateUL,
    B8_Type                     maxBitRateDL,
    B4_Type                     residualBER,
    B4_Type                     sduErrorRatio,
    B6_Type                     transferDelay,
    B2_Type                     trafficHandlingPrio,
    B8_Type                     guaranteedBitRateUL,
    B8_Type                     guaranteedBitRateDL,
    B3_Type                     spare4,
    B1_Type                     signallingInd,
    B4_Type                     sourceStatisticsDescriptor,
    B8_Type                     maxBitRateDL_Ext             optional,
    B8_Type                     guaranteedBitRateDL_Ext      optional,
    B8_Type                     maxBitRateUL_Ext             optional,
    B8_Type                     guaranteedBitRateUL_Ext      optional,
    B8_Type                     maxBitRateDL_Ext2            optional,  // @sic R5s1300195 Baseline Moving sic@
    B8_Type                     guaranteedBitRateDL_Ext2     optional,  // @sic R5s1300195 Baseline Moving sic@
    B8_Type                     maxBitRateUL_Ext2            optional,  // @sic R5s1300195 Baseline Moving sic@
    B8_Type                     guaranteedBitRateUL_Ext2     optional   // @sic R5s1300195 Baseline Moving sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare1, delayClass, relabilityClass, peakThroughput, spare2, precedenceClass, spare3, meanThroughput, trafficClass, deliveryOrder, deliveryErrorSDU, maxSduSize, maxBitRateUL, maxBitRateDL, residualBER, sduErrorRatio, transferDelay, trafficHandlingPrio, guaranteedBitRateUL, guaranteedBitRateDL, spare4, signallingInd, sourceStatisticsDescriptor, maxBitRateDL_Ext, guaranteedBitRateDL_Ext, maxBitRateUL_Ext, guaranteedBitRateUL_Ext, maxBitRateDL_Ext2, guaranteedBitRateDL_Ext2, maxBitRateUL_Ext2, guaranteedBitRateUL_Ext2)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Radio priority
  // 3GPP 24.008 / 10.5.7.2
  // -----------------------------------------------------------------------------
  type record RadioPriority {                                   /* 24.301 cl. 9.9.4.10 -> 24.008 cl. 10.5.7.2 */
    IEI4_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    B1_Type                     spare,
    B3_Type                     levelValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // Codec
  // 3G TS 24.008 cl. 10.5.4.32
  // -----------------------------------------------------------------------------
  type record Codec {
    O1_Type          sysId,       // system identifcation
    Type4Length_Type len,                   // length
    B8_Type          bitMap1to8,  // codec bitmap bits 1-8
    B8_Type          bitMap9to16 optional // codec bitmap bits 9-16
  } with {
    variant "FIELDORDER(msb)";
    variant (len) "LENGTHTO (bitMap1to8, bitMap9to16)";
    variant (len) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Supported Codec List
  // 3G TS 24.008 cl. 10.5.4.32
  // -----------------------------------------------------------------------------
  type record CodecList {
    IEI8_Type            iei,                   // '01000000'B (40 hex) @sic R5s110420 sic@
    Type4Length_Type     iel,                   // length @sic R5s110420 sic@
    record of Codec      codec// list of codecs
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (codec)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // TMSI status
  // 3GPP 24.008 cl. 10.5.6.17
  // -----------------------------------------------------------------------------
  type record Request_Type {                                     /* 24.301 cl. 9.9.4.11 */
    // IEI is always skipped
    B1_Type                     spare,
    B3_Type                     typeValue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // TMSI status
  // 3GPP 24.008 cl. 10.5.5.4
  // -----------------------------------------------------------------------------
  type record TMSI_Status {
    IEI4_Type            iei  optional,
    B3_Type              spare3,
    TmsiStatusValue      flag                     // Flag
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // TrafficFlowTemplate
  // 3GPP 24.008 /  10.5.6.12
  // -----------------------------------------------------------------------------
  type record TrafficFlowTemplate {                             /* 24.301 cl. 9.9.4.13 -> 24.008 cl. 10.5.6.12 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel,
    B3_Type                     tftOperationCode,
    B1_Type                     eBit,
    B4_Type                     noOfPktFilter,
    record of PacketFilter      packetFilterList      optional,
    record of TftParameter      parameterList         optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (tftOperationCode, eBit, noOfPktFilter, packetFilterList, parameterList)";
    variant (iel) "BYTEORDER(last)";
  };

  type record TftParameter {
    IEI8_Type                   iei,
    Type4Length_Type            iel,
    octetstring                 contents
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (contents)";
    variant (iel) "BYTEORDER(last)";
    variant (contents) "BYTEORDER(last)";
  };

  type record PacketFilter {
    B2_Type                     spare,                // @sic R5s130195 Baseline Moving sic@
    B2_Type                     direction,            // @sic R5s130195 Baseline Moving sic@
    IEI4_Type                   iei,                  // @sic R5s130195 Baseline Moving sic@
    B8_Type                     precedence            optional,
    Type4Length_Type            iel                   optional,
    PacketFilterContents        contents              optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (contents)";
    variant (iel) "BYTEORDER(last)";
    variant (contents) "BYTEORDER(last)";
  };

  type record of PacketFilterComponent PacketFilterContents;

  type record PacketFilterComponent {
    O1_Type                     id,
    PacketFilterComponentValue  packetFilterComponentValue
  } with {
    variant "FIELDORDER(msb)";
  };

  type union PacketFilterComponentValue {
    O8_Type    ipv4RemoteAddress,
    O32_Type   ipv6RemoteAddress,
    O1_Type    protocolIdNextHeader,
    O2_Type    singleLocalPort,
    O4_Type    localPortRange,
    O2_Type    singleRemotePort,
    O4_Type    remotePortRange,
    O4_Type    securityParameterIndex,
    O2_Type    typeOfServiceTrafficClass,
    O3_Type    flowLabel
  } with {
    variant "FIELDORDER(msb)";
    variant (ipv4RemoteAddress) "BYTEORDER(last)";
    variant (ipv6RemoteAddress) "BYTEORDER(last)";
    variant (singleLocalPort) "BYTEORDER(last)";
    variant (localPortRange) "BYTEORDER(last)";
    variant (singleRemotePort) "BYTEORDER(last)";
    variant (remotePortRange) "BYTEORDER(last)";
    variant (securityParameterIndex) "BYTEORDER(last)";
    variant (typeOfServiceTrafficClass) "BYTEORDER(last)";
    variant (flowLabel) "BYTEORDER(last)";
  };

  type record UE_NetworkCap {                                   // 24.301 cl. 9.9.3.34
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B8_Type                     eeaCap,                         // @sic R5s100135, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     eiaCap,                         // @sic R5s100135, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     ueaCap                optional, // @sic R5s100135, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     uiaCap                optional, // @sic R5s100135, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     srvcc_LPP_ProSeCap    optional, // @sic R5s150329, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     cIoT_proSeCap         optional, // @sic R5s160711, R5s150329, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     cIoT_V2X              optional, // @sic R5s170598, R5s180271 Baseline Moving 2018 Phase 1 sic@
    B8_Type                     edt_WUS               optional, // @sic R5s201386 Baseline Moving sic@
    B8_Type                     musim                 optional, // Sep22 @sic R5s221179 Baseline Moving sic@
    octetstring                 spare                 optional  // @sic R5s100135 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO(eeaCap, eiaCap, ueaCap, uiaCap, srvcc_LPP_ProSeCap, cIoT_proSeCap, cIoT_V2X, edt_WUS, musim, spare)";
    variant (iel) "BYTEORDER(last)";
  }

  type record ReAttemptIndicator {                                   // 24.301 cl. 9.9.4.13A, 24.008 cl. 10.5.6.5A
                                                                     // The two definitions are exactly the same.
                                                                     // The only difference is the meaning of the ratcValue bit
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B6_Type                     spare,                          //  @sic R5s160712 Baseline Moving sic@
    B1_Type                     eplmncValue,                    //  @sic R5s160712 Baseline Moving sic@
    B1_Type                     ratcValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO(spare, eplmncValue, ratcValue)";
    variant (iel) "BYTEORDER(last)";
  }

  // =============================================================================
  // Structured Type Definition
  // Authentication Parameter  AUTN
  // 3G TS 24.008 cl. 10.5.3.1.1
  // -----------------------------------------------------------------------------
  type record AUTN {                                            /* 24.301 cl. 9.9.3.2 -> 24.008 cl. 10.5.3.1.1 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel,                            // @sic R5s110420 sic@
    B128_Type                   aUTN                            /* (as for UMTS) */
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (aUTN)";
    variant (iel) "BYTEORDER(last)";
    variant (aUTN) "BYTEORDER(last)";
  }

  // =============================================================================
  // Structured Type Definition
  // Authentication Failure Parameter  (TLV)
  // 3G TS 24.008 cl. 10.5.3.2.2
  // -----------------------------------------------------------------------------
  type record AuthenticationFailureParameter {
    IEI8_Type            iei,              // '00100010'B for MM (22 hex)
    // '00110000'B for GMM (30 hex)
    Type4Length_Type     iel,              // M 1 octet
    B112_Type            auts              // AUTS, 14 octets
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (auts)";
    variant (iel) "BYTEORDER(last)";
    variant (auts) "BYTEORDER(last)";
  }

  // =============================================================================
  // Structured Type Definition
  // Authentication Parameter  RAND (TV, 17 octets)
  // 3G TS 24.008 cl. 10.5.3.1
  // -----------------------------------------------------------------------------
  type record RAND {
    IEI8_Type            iei optional,         // '00100001'B (21 hex)
    B128_Type            randValue    // Authentication Parameter RAND value
  } with {
    variant "FIELDORDER(msb)";
    variant (randValue) "BYTEORDER(last)";
  }

  type record DaylightSavingTime {                              /* 24.301 cl. 9.9.3.5 -> 24.008 cl. 10.5.3.12 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B6_Type                     spare,
    B2_Type                     val
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, val)";
    variant (iel) "BYTEORDER(last)";
  };

  type record NetworkName {                                     /* 24.301 cl. 9.9.3.21 -> 24.008 cl. 10.5.3.5a */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel,
    B1_Type                     ext,
    B3_Type                     codingScheme,
    B1_Type                     addCI,
    B3_Type                     spareBitCnt,
    octetstring                 text
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (ext, codingScheme, addCI, spareBitCnt, text)";
    variant (iel) "BYTEORDER(last)";
    variant (text) "BYTEORDER(last)";
  };

  type record TimeZone {                                        /* 24.301 cl. 9.9.3.26 -> 24.008 cl. 10.5.3.8 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    O1_Type                     timeZone
  } with {
    variant "FIELDORDER(msb)";
  };

  type record TimeZoneAndTime {                                 /* 24.301 cl. 9.9.3.27 -> 24.008 cl. 10.5.3.9 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    O1_Type                     year,
    O1_Type                     month,
    O1_Type                     day,
    O1_Type                     hour,
    O1_Type                     minute,
    O1_Type                     second,
    O1_Type                     timeZone
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // 3G TS 24.008 cl. 10.5.5.28
  // @sic R5s110176 Baseline Moving sic@
  // -----------------------------------------------------------------------------
  type record VoiceDomainPref {
    IEI8_Type            iei  optional,              // 01111110'B
    Type4Length_Type     iel  optional,                   // length
    B5_Type              spareBits,
    B1_Type              ueUsageSetting,
    B2_Type              voiceDomainPrefEUTRA        // @sic R5s110233 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spareBits, ueUsageSetting, voiceDomainPrefEUTRA)";
    variant (iel) "BYTEORDER(last)";
  };

  type record IdentityType {                                    /* 24.301 cl. 9.9.3.15 -> 24.008 cl. 10.5.3.4 */
    // IEI is always skipped
    B1_Type                     spare,
    NAS_IdType                  typeOfId
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // REGISTER
  // ue->n or n->ue, 3GPPP TS 24.080, 2.4
  // -----------------------------------------------------------------------------
  type record REGISTER {
    TI              ti,                     // transaction identifier BITSTRING [4]
    ProtocolDiscriminator sS_ProtocolDiscriminator, // "1011" Protocol discriminator for supplementary services BITSTRING [4]
    MessageType     msgType,                // message type BITSTRING [8]
    FacilityIE      facility_Str,           // M, BER enconded ASN.1 object
    SS_VersionInd   sS_VersionInd optional  // O for ue->n, N/A for n->ue
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // FACILITY
  // n->ue, 3GPPP TS 24.080, 2.3 and 24.008, 10.4
  // -----------------------------------------------------------------------------
  type record FACILITY {
    TI              ti,                   // transaction identifier BITSTRING [4]
    ProtocolDiscriminator sS_ProtocolDiscriminator, // "1011" Protocol discriminator for supplementary services BITSTRING [4]
    MessageType     msgType,              // message type BITSTRING [8], for n->ue "00111010", for ue->n "xx111010" (see 24.007)
    FacilityIE      facility_Str          // M, BER enconded ASN.1 object
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // FACILITY
  // ue->n  3GPPP TS 24.080, 2.3 and 24.008, 10.4
  // -----------------------------------------------------------------------------
  type record FACILITYul {
    TI              ti,                   // transaction identifier BITSTRING [4]
    ProtocolDiscriminator sS_ProtocolDiscriminator, // "1011" Protocol discriminator for supplementary services BITSTRING [4]
    MessageType     msgType,              // message type BITSTRING [8], for n->ue "00111010", for ue->n "xx111010" (see 24.007)
    FacilityIE      facility_Str,          // M, BER enconded ASN.1 object
    SS_VersionInd   sS_VersionInd  optional // O @sic R5s140989 sic@
  } with {
    variant "FIELDORDER(msb)";
  };
  // =============================================================================
  // Structured Type Definition
  // Facility Information Element
  // 3GPPP TS 24.080, 3.6 / 24.008, 10.5.4.15
  // -----------------------------------------------------------------------------
  type record FacilityIE {
    IEI8_Type        iei optional,         // Facility IE identifier
    Type4Length_Type iel,         // length of Facility contents
    octetstring      components   // ASN.1 definitions BER encoded
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (components)";
    variant (iel) "BYTEORDER(last)";
    variant (components) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Transaction identifier
  // 3G TS 24.007 cl. 11.2.3.1.3
  // -----------------------------------------------------------------------------
  type record TI {
    B1_Type              tiFlag,                // Flag
    B3_Type              tiVal                    // TIO
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // SS version indicator
  // 3G TS 24.008 cl. 10.5.4.24
  // 1. Usually this IE has only one octet of content.
  // Exact definition see TS 24.080
  // -----------------------------------------------------------------------------
  type record SS_VersionInd {
    IEI8_Type            iei,              // '01111111'B @sic R5s110420 sic@
    Type4Length_Type     iel,                   // length @sic R5s110420 sic@
    O1_Type              sS_VersionInfo // ss version information
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (sS_VersionInfo)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // RESETUEPOSITIONINGSTOREDINFORMATION
  // n->ue, 3GPPP TS 34.109, 6.10/36.509 6.9
  // -----------------------------------------------------------------------------
  type record RESETUEPOSITIONINGSTOREDINFORMATION {
    SkipIndicator   skipIndicator,                // "0000" skip indicator BITSTRING [4]
    ProtocolDiscriminator  protocolDiscriminator, // M, "1111" Protocol discriminator for test procedure messages BITSTRING [4]
    MessageType     msgType,                      // M, message type BITSTRING [8]
    B8_Type         uePositioningTech             // M, BITSTRING [8]
  } with {
    variant "FIELDORDER(msb)";
  };

  // =============================================================================
  // Structured Type Definition
  // WLANOffloadAcceptability
  // 3GPPP TS 24.008 10.5.6.20
  // -----------------------------------------------------------------------------
 type record WLANOffloadAcceptability {
  IEI4_Type            iei,
  B2_Type              spare,
  B1_Type              utranOffload,
  B1_Type              eutranOffload
  } with {
    variant "FIELDORDER(msb)";
};

// =============================================================================
// Structured Type Definition
// Extended DRX Parameters
// 3GPP 24.008 / 10.5.5.32
// -----------------------------------------------------------------------------
type record ExtdDRXParams {
  IEI8_Type     iei,
  Type4Length_Type     iel,           // length
  B4_Type       pagingTimeWindow,
  B4_Type       eDRXValue,
  B8_Type       extdPTW         optional // @sic R5s221182 Baseline Moving Rel-17 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (pagingTimeWindow, eDRXValue, extdPTW)";
    variant (iel) "BYTEORDER(last)";
};

// =============================================================================
// Structured Type Definition
// NBIFOM Container
// 3GPP 24.008 / 10.5.6.21
// -----------------------------------------------------------------------------
type record NBIFOMContainer {
  IEI8_Type     iei,
  Type4Length_Type     iel,           // length
  octetstring   containerContents
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (containerContents)";
    variant (iel) "BYTEORDER(last)";
    variant (containerContents) "BYTEORDER(last)";
};

// =============================================================================
// Structured Type Definition
// DCN Id
// 3G TS 24.008 cl. 10.5.5.35
// -----------------------------------------------------------------------------
  type record DCN_ID {
    IEI8_Type                   iei,
    Type4Length_Type            iel,
    O2_Type                     dcnIdValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (dcnIdValue)";
    variant (iel) "BYTEORDER(last)";
    variant (dcnIdValue) "BYTEORDER(last)";
  };

// =============================================================================
// Structured Type Definition
// ePCO
// 3G TS 24.008 cl. 10.5.6.3A
// -----------------------------------------------------------------------------
  type record ExtdProtocolConfigOptions {
    IEI8_Type                   iei,
    Type6Length_Type            iel,
    B1_Type                     ext,
    B4_Type                     spare,
    B3_Type                     configProtocol,
    NAS_ExtdProtocolConfigOptions_Type pco optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (ext, spare, configProtocol, pco)";
    variant (iel) "BYTEORDER(last)";
  };

  type record of ProtocolContainer NAS_ExtdProtocolConfigOptions_Type; /* @sic R5-2001649 sic@ @status    APPROVED (LTE_A_PRO, NBIOT) */

  //-----------------------------------------------------------------------------
  // Defined in 24.301, but also referenced from 24.501
  //-----------------------------------------------------------------------------

  type record AdditionalInformation{                            /* 24.301 cl. 9.9.2.0     @sic R5s110176 Baseline Moving sic@ */
    IEI8_Type                   iei,
    Type4Length_Type            iel,
    octetstring                 additionalInfo
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (additionalInfo)";
    variant (iel) "BYTEORDER(last)";
    variant (additionalInfo) "BYTEORDER(last)";
  };

  type record AuthenticationResponseParameter {                 /* 24.301 cl. 9.9.3.4 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B32_128_Type                res                             /* 4..16 octets */
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (res)";
    variant (iel) "BYTEORDER(last)";
    variant (res) "BYTEORDER(last)";
  }

  type record NAS_KeySetIdentifier {                            /* 24.301 cl. 9.9.3.21 */
    IEI4_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    B1_Type                     tsc,                            // Type of security context: 0 = cached, 1 = mapped
    NAS_KsiValue                nasKeySetId
  } with {
    variant "FIELDORDER(msb)";
  }

  type record HashMME { /* 24.301 cl. 9.9.3.50 @sic R5s170597 Baseline Moving sic@ */
    IEI8_Type                   iei optional,
    Type4Length_Type            iel,
    O8_Type                     hashMME
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (hashMME)";
    variant (iel) "BYTEORDER(last)";
    variant (hashMME) "BYTEORDER(last)";
  }

  type record PDN_Address {                                     /* 24.301 cl. 9.9.4.9 */
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B5_Type                     spare,
    B3_Type                     typeValue,
    octetstring                 adressInfo length(4..12)
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, typeValue, adressInfo)";
    variant (iel) "BYTEORDER(last)";
    variant (adressInfo) "BYTEORDER(last)";
  };

  type record ReplayedNASMessageContainer { /* 24.301 cl. 9.9.3.51 @sic R5s170597 Baseline Moving sic@ */
    IEI8_Type                   iei optional,
    Type6Length_Type            iel,
    octetstring                 replayedNASMsgContainerValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (replayedNASMsgContainerValue)";
    variant (iel) "BYTEORDER(last)";
  };

  type record NAS_SecurityAlgorithms {                          /* 24.301 cl. 9.9.3.23 */
    IEI8_Type                   iei                   optional, /* present in case of TV; omit in case of V */
    B1_Type                     spare1,
    B3_Type                     cipheringType,                  /* Type of ciphering algorithm */
    B1_Type                     spare2,
    B3_Type                     integrityType                   /* Type of integrity protection algorithm */
  } with {
    variant "FIELDORDER(msb)";
  };

  type record Extd_EPS_QOS {                             /* 24.301 cl. 9.9.4.30 */
    IEI8_Type                   iei                    optional,
    Type4Length_Type            iel,
    B8_Type                     unitMaxBitRate,
    B8_Type                     maxBitRateUl_1,
    B8_Type                     maxBitRateUl_2,
    B8_Type                     maxBitRateDl_1,
    B8_Type                     maxBitRateDl_2,
    B8_Type                     unitGuaranteedBitRate,
    B8_Type                     guaranteedBitRateUl_1,
    B8_Type                     guaranteedBitRateUl_2,
    B8_Type                     guaranteedBitRateDl_1,
    B8_Type                     guaranteedBitRateDl_2
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (unitMaxBitRate, maxBitRateUl_1, maxBitRateUl_2, maxBitRateDl_1, maxBitRateDl_2, unitGuaranteedBitRate, guaranteedBitRateUl_1, guaranteedBitRateUl_2, guaranteedBitRateDl_1, guaranteedBitRateDl_2)";
    variant (iel) "BYTEORDER(last)";
  };

  type record UE_Status {                                     // 24.501 cl. 9.11.3.56
    IEI8_Type                   iei                   optional, /* present in case of TLV; omit in case of LV */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B6_Type                     spare,
    B1_Type                     n1ModeRegistered,
    B1_Type                     s1ModeRegistered
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, n1ModeRegistered, s1ModeRegistered)";
    variant (iel) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Emergency Number List
  // 3G TS 24.301 cl. 9.9.3.37A
  // -----------------------------------------------------------------------------
  type record ExtdEmergNumList {
    IEI8_Type            iei,
    Type6Length_Type     iel,
    B7_Type              spareBits,                 // @sic R5s201386 Baseline Moving sic@
    B1_Type              extdEmergNumListValidity,
    record of ExtdEmergNum  emergNum
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spareBits, extdEmergNumListValidity, emergNum)";
    variant (iel) "BYTEORDER(last)";
  };

  type record ExtdEmergNum {
    Type4Length_Type   len,
    octetstring        digits,                 // BCD numbers
    Type4Length_Type   lengthOfSubService,
    octetstring        subServices
  } with {
    variant "FIELDORDER(msb)";
    variant (lengthOfSubService) "LENGTHTO (subServices)";
    variant (lengthOfSubService) "BYTEORDER(last)";
    variant (digits) "BYTEORDER(last)";
    variant (subServices) "BYTEORDER(last)";
  };

  // =============================================================================
  // Structured Type Definition
  // Emergency Number List
  // 3G TS 24.301 cl. 9.9.3.36
  // -----------------------------------------------------------------------------
  type record UE_SecurityCapability {
    Type4Length_Type            iel,                            // @sic R5s10035 iei never used, so removed sic@
    O1_Type                     eeaCap,                         // @sic R5s100135 sic@
    O1_Type                     eiaCap,                         // @sic R5s100135 sic@
    O1_Type                     ueaCap                optional, // @sic R5s100135 sic@
    O1_Type                     uiaCap                optional, // @sic R5s100135 sic@
    O1_Type                     geaCap                optional  // @sic R5s100135 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (eeaCap, eiaCap, ueaCap, uiaCap, geaCap)";
    variant (iel) "BYTEORDER(last)";
  };

  type record EPS_QualityOfService {                             /* 24.301 cl. 9.9.4.3 */
    IEI8_Type                   iei                    optional,
    Type4Length_Type            iel,
    B8_Type                     qci,
    B8_Type                     maxBitRateUl           optional,
    B8_Type                     maxBitRateDl           optional,
    B8_Type                     guaranteedBitRateUl    optional,
    B8_Type                     guaranteedBitRateDl    optional,
    B8_Type                     maxBitRateUlExt        optional,
    B8_Type                     maxBitRateDlExt        optional,
    B8_Type                     guaranteedBitRateUlExt optional,
    B8_Type                     guaranteedBitRateDlExt optional,
    B8_Type                     maxBitRateUL_Ext2            optional,  // @sic R5s1300195 Baseline Moving, R5s180640 sic@
    B8_Type                     maxBitRateDL_Ext2            optional,  // @sic R5s1300195 Baseline Moving, R5s180640 sic@
    B8_Type                     guaranteedBitRateUL_Ext2     optional,  // @sic R5s1300195 Baseline Moving, R5s180640 sic@
    B8_Type                     guaranteedBitRateDL_Ext2     optional   // @sic R5s1300195 Baseline Moving, R5s180640 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (qci, maxBitRateUl, maxBitRateDl, guaranteedBitRateUl, guaranteedBitRateDl, maxBitRateUlExt, maxBitRateDlExt, guaranteedBitRateUlExt, guaranteedBitRateDlExt, maxBitRateUL_Ext2, maxBitRateDL_Ext2, guaranteedBitRateUL_Ext2, guaranteedBitRateDL_Ext2)";
    variant (iel) "BYTEORDER(last)";
  };

  type record EPS_BearerContextStatus {                         /* 24.301 cl. 9.9.2.1 */
    IEI8_Type                   iei                   optional, /* present in case of TV or TLV; omit in case of V */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    B3_Type                     ebi5_7,                         /* EBI(5)- EBI(7) */
    B4_Type                     ebi4_1,                         /* EBI(1)- EBI(4) @sic R5s180552 Baseline Moving 2018 Phase 2 sic@ */
    B1_Type                     spare,                          /* EBI(0) is spare and shall be coded as zero @sic R5s180552 Baseline Moving 2018 Phase 2 sic@ */
    B8_Type                     ebi8_15                         /* EBI(8)- EBI(15)*/
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (ebi5_7, ebi4_1, spare, ebi8_15)";
    variant (iel) "BYTEORDER(last)";
  };

  type record UERadioCapId {                       /* 24.501 cl. 9.11.3.68 */
    IEI8_Type                   iei                   optional, /* present in case of TV or TLV; omit in case of V */
    Type4Length_Type            iel                   optional, /* present in case of LV or TLV; omit in case of V */
    octetstring                 id
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (id)";
    variant (iel) "BYTEORDER(last)";
    variant (id) "BYTEORDER(last)";
  };

  type record UERadioCapIdDeletion  {                 /* 24.501 cl. 9.11.3.69 */
    IEI4_Type                   iei                   optional,
    B1_Type                     spare,
    B3_Type                     deleteReq
  } with {
    variant "FIELDORDER(msb)";
  };

  type record DRXParamCommon  {                      /* 24.301 cl. 9.9.3.63 */
    IEI8_Type                   iei                   optional,
    Type4Length_Type            iel,
    B4_Type                     spare,
    B4_Type                     drxValue
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, drxValue)";
    variant (iel) "BYTEORDER(last)";
  };

  type record ReleaseAssistanceInd {                 /* 24.301 cl. 9.9.4.25 */
    IEI4_Type                   iei                   optional,
    B2_Type                     spare,
    B2_Type                     dlDataExpected
  } with {
    variant "FIELDORDER(msb)";
  };

  type record WUSAssistInfo {                           /* 24.301 cl. 9.9.3.62 */
    IEI8_Type                   iei                   optional,
    Type4Length_Type            iel,
    record of WusInfoType       infoType
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (infoType)";
    variant (iel) "BYTEORDER(last)";
  };

  type record WusInfoType {
    B3_Type                     wusType,
    B5_Type                     pagingProbability,
    octetstring                 wusValue    optional
  } with {
    variant "FIELDORDER(msb)";
    variant (wusValue) "BYTEORDER(last)";
  };

  type record ServingPLMNRateControl {                           /* 24.301 cl. 9.9.4.28 */
    IEI8_Type                   iei                   optional,
    Type4Length_Type            iel,
    O2_Type                     servingPLMNRate
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (servingPLMNRate)";
    variant (iel) "BYTEORDER(last)";
    variant (servingPLMNRate) "BYTEORDER(last)";
  };

  type record ControlPlaneInd {                           /* 24.301 cl. 9.9.4.23 */
    IEI4_Type                   iei                   optional,
    B3_Type                     spare,
    B1_Type                     cpIndValue
  } with {
    variant "FIELDORDER(msb)";
  };

  type record QoSParameters {
    O1_Type                    id,
    Type4Length_Type           lenOfContent,
    octetstring                qosParam
  } with {
    variant "FIELDORDER(msb)";
    variant (lenOfContent) "LENGTHTO (qosParam)";
    variant (lenOfContent) "BYTEORDER(last)";
    variant (qosParam) "BYTEORDER(last)";
  };

  type record of QoSParameters QoSParametersList;

  type record UE_RequestType {                           /* 24.301 cl. 9.9.3.65 */
    IEI8_Type                   iei                   optional,
    Type4Length_Type            iel,
    B4_Type                     spare,
    B4_Type                     requestType
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (spare, requestType)";
    variant (iel) "BYTEORDER(last)";
  };

//}  with { encode "NAS Types" }
}  with { encode "RAW" }
