///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2023 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
//
//  File:               MobileL3_GMM_SM_Types.ttcn
//  Rev:                R2A
//  Prodnr:             CNL 113 832
//  Contact:            http://ttcn.ericsson.se
//  Reference:          3GPP TS 24.008 v13.4.0

module MobileL3_GMM_SM_Types
{

// This module contains the GPRS Mobility Management Messages and
// GPRS Session Management Messages of Mobile Radio Interface Layer 3 protocol
// (DTAP) version 24.008 v13.4.0 with attributes for RAW encoding/decoding.
//
// Protocol discriminators and other general parts are defined in 24.007 v6.5.0
// Some deviations added in order to make the module compatible with
// V97 version of L3. These changes are indicated by 'V97' in comments

import from General_Types all;
import from MobileL3_CommonIE_Types all;
import from MobileL3_MM_Types all;

// =============================================================
// GPRS Mobilty management information elements (chapter 10.5.5)
// =============================================================

// Additional Update Type - 10.5.5.0, TS 24.301 v13.4.0/9.9.3.0B
type record AdditionalUpdateTypeTV
{
  AdditionalUpdateTypeV additionalUpdateType,
  BIT4                  elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '0111'B)" };

type record AdditionalUpdateTypeV
{
  BIT1        aUTV,
  BIT3        spare
};

// Attach Result - 10.5.5.1
type record AttachResultV
{
  BIT3               resultOfAttach,
  BIT1               fop_l3
};


// Attach Type - 10.5.5.2
type record  AttachTypeV
{
  BIT3               attachType,
  BIT1               for_l3
};


// Ciphering Algorithm - 10.5.5.3
type record   CipheringAlgorithmTV
{
  CipheringAlgorithmV          cipheringAlgorithm,
  BIT4                         cipheringAlgorithmIEI
};


type record   CipheringAlgorithmV
{
  BIT3               valueField,
  BIT1               spare
};


// TMSI status - 10.5.5.4
type record TMSIStatusTV
{
  TMSIStatusV        tmsiStatusV,
  BIT4               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1001'B)" };


type record TMSIStatusV
{
  BIT1               tmsiFlag,
  BIT3               spare // '000'B
};


// Detach Type - 10.5.5.5
type record DetachTypeTV
{
  DetachTypeV        detachTypeV,
  BIT4               detachTypeIEI
};


type record DetachTypeV
{
  BIT3               detachType,
  BIT1               powerOffFlag
};


// DRX Parameter - 10.5.5.6
type record DRXParameterTV
{
  OCT1               elementIdentifier,
  DRXParameterV      drxParameter
} with { variant "PRESENCE (elementIdentifier = '27'O)"; };


type record DRXParameterV
{
  OCT1               splitPGCycleCode,
  BIT3               nonDRXTimer,
  BIT1               splitOnCCCH,
  BIT4               cnSpecificDRXCycleLength
};


//Force To Standby - 10.5.5.7
type record ForceToStandbyTV
{
  ForceToStandbyV    valueField,
  BIT4               forceToStandbyIEI
};


type record ForceToStandbyV{
  BIT3               forceToStandbyValue,
  BIT1               spare   // '0'B
};


// P-TMSI Signature - 10.5.5.8
type record P_TMSISignatureTV
{
  OCT1               elementIdentifier,
  OCT3               valueField
} with { variant "PRESENCE (elementIdentifier = '19'O)"; }


//P-TMSI Signature 2 - 10.5.5.8a
//moved into MobileL3_CommonIE_Types


// Identity Type 2 - 10.5.5.9
type record IdentityType2TV
{
  IdentityType2V     valueField,
  BIT4               identityType2IEI
};


type record IdentityType2V
{
  BIT3                valueField,
  BIT1                spare
};


// IMEISV request - 10.5.5.10
type record IMEISVRequestTV
{
  IMEISVRequestV     imeisvRequest,
  BIT4               imeisvRequestIEI
};


type record IMEISVRequestV
{
  BIT3               valueField,
  BIT1               spare  //'0'B
};


// Receive N-PDU Numbers list - 10.5.5.11
type record ReceiveNPDUNumbersListTLV
{
  OCT1                         elementIdentifier,
  LIN1                         lengthIndicator,
  ReceiveNPDUNumbersListV      numberList
} with {
  variant "PRESENCE (elementIdentifier = '26'O)";
  variant (lengthIndicator) "LENGTHTO (numberList)";
  variant (numberList)      "PADDING(yes)"// Padding is needed when odd
  // number of ReceiveNPDUNumber is used
};

type record length(1..11) of ReceiveNPDUNumber ReceiveNPDUNumbersListV;

type record ReceiveNPDUNumber
{
  BIT4               sapi,
  BIT8               numberValue
} with { variant "FIELDORDER(msb)" };


// MS network capability - 10.5.5.12
type record  MSNetworkCapabilityTLV
{
  OCT1                         elementIdentifier,
  MSNetworkCapabilityLV        mSNetworkCapabilityLV
} with { variant "PRESENCE (elementIdentifier = '31'O)"; };


type record MSNetworkCapabilityLV
{
  LIN1                         lengthIndicator,
  MSNetworkCapabilityV         msNetworkCapabilityV
} with { variant (lengthIndicator) "LENGTHTO (msNetworkCapabilityV)";
  variant (msNetworkCapabilityV)    "PADDING(yes)"
};


type record MSNetworkCapabilityV    //length 3-10 octets
{
  BIT1               gea1bit,
  BIT1               smCapabilitiesviaDedicatedChannels,
  BIT1               smCapabilitiesviaGPRSChannels,
  BIT1               ucs2Support,
  BIT2               ssScreeningIndicator,
  BIT1               solSACapability            optional, //spare in V97
  BIT1               revisionLevelIndicatior    optional, //spare in V97
  BIT1               pFCFeatureMode             optional, //spare in V97(opt)
  BIT6               extendedGEAbits            optional, //spare in V97(opt)
  BIT1               lcsVAcapability            optional, //spare in V97(opt)
  BIT1               pSInterRATHOtoUTRANIuModeCapability optional,
  BIT1               pSInterRATHOtoEUTRANS1ModeCapability optional,
  BIT1               eMMCombinedProceduresCapability optional,
  BIT1               iSRSupport                 optional,
  BIT1               sRVCCtoGERANUTRANCapability optional,
  BIT1               ePCCapability              optional,
  BIT1               nFCapability               optional,
  BIT1               gERANNertworkSharingCapability optional,
  octetstring        spare_octets length (0..3) optional
} with { variant "FIELDORDER(msb)" };


//MS Radio Access capability - 10.5.5.12a

// Note: specification allows application of spare bits (even the forming of
// spare octets), The only limitation is that the MS Radio Access capability IE
// has maximum length of 51 octets
type record MSRadioAccessCapabilityLV
{
  LIN1                         lengthIndicator,
  MSRadioAccessCapabilityV     msRadioAccessCapabilityV
  // Note that spareBits is automatically handled/calculated as padding
  // so that MSRadioAccessCapabilityLV will be octet aligned when encoded
  // even if the padding (spareBits) is not visible for the tester.
  // lengthIndicator value = MSRadioAccessCapabilityV + (virtual) padding.
} with {
  variant "FIELDORDER(msb)";
  variant (lengthIndicator) "LENGTHTO (msRadioAccessCapabilityV )";
  variant "PADDING(yes)"				
};

type record of MSRACapabilityValuesRecord MSRadioAccessCapabilityV
with { variant "EXTENSION_BIT(reverse)";variant "FIELDORDER(msb)" };


type record MSRACapabilityValuesRecord
{
  MSRACapabilityValues         mSRACapabilityValues,
  BIT1                         presenceBitMSRACap
} with { variant "FIELDORDER(msb)" };


type union MSRACapabilityValues
{
  MSRACapabilityValuesExclude1111        mSRACapabilityValuesExclude1111,
  MSRACapabilityValues1111               mSRACapabilityValues1111
} with { variant "FIELDORDER(msb)" };


type record MSRACapabilityValuesExclude1111
{
  BIT4                         accessTechnType,
  AccessCapabilitiesStruct     accessCapabilities
} with {
  variant "PRESENCE (
  accessTechnType = '0000'B,     // GSM P
  accessTechnType = '0001'B,     // GSM E
  accessTechnType = '0010'B,     // GSM R
  accessTechnType = '0011'B,     // GSM 1800
  accessTechnType = '0100'B,     // GSM190
  accessTechnType = '0101'B,     // GSM 450
  accessTechnType = '0110'B,     // GSM480
  accessTechnType = '0111'B,     // GSM 480
  accessTechnType = '1000'B,     // GSM 700
  accessTechnType = '1001'B,     // GSM T 310
  accessTechnType = '1010'B,     // GSM T 410
  accessTechnType = '1011'B      // GSM T 900
  )"
  variant (accessTechnType) "BYTEORDER(last)";
  variant "FIELDORDER(msb)"
};


// Access Capabilities Struct
type record AccessCapabilitiesStruct
{
  integer                      lengthIndicator,
  AccessCapabilities           accessCapabilities,
  // spare_bits "expands to the indicated length",
  // i.e. 24.008 spec puts no restriction on number
  // of spare_bits.  The only restriction is that the whole
  // MS Radio Access Capability  IE is less than 52 octets
  bitstring                    spare_bits              optional
} with {
  variant (lengthIndicator) "FIELDLENGTH(7)";
  variant (lengthIndicator) "LENGTHTO(accessCapabilities,spare_bits)";
  variant (lengthIndicator) "UNIT(bits)";
  variant "FIELDORDER(msb)";
  variant (lengthIndicator) "BYTEORDER(last)";
}


//Access Capabilities
type record AccessCapabilities
{
  BIT3                         rfPowerCapability,
  BIT1                         presenceBitA5,
  A5BITS                       a5bits               optional,
  BIT1                         esind,
  BIT1                         psbit,
  BIT1                         vgcs,
  BIT1                         vbs,
  BIT1                         presenceBitMultislot,
  MultislotCap                 multislotcap         optional,
  AccessCapAdditionsAfterRel97 accessCapAdditionsAfterRel97 optional //opt because of V97
  //Note: AccessCapAdditionsAfterRel97 can include:
  // Rel99 or
  // Rel99 + Rel4 or
  // Rel99 + Rel4 + Rel5 or
  // Rel99 + Rel4 + Rel5  + Rel6
} with {
  variant "FIELDORDER(msb)";
  variant(rfPowerCapability) "BYTEORDER(last)";
  variant (a5bits)               "PRESENCE(presenceBitA5 = '1'B)";
  variant (multislotcap)         "PRESENCE(presenceBitMultislot = '1'B)";
}


type record AccessCapAdditionsAfterRel97
{
  AccessCapAdditionsRel99                accessCapAdditionsRel99,
  AccessCapAdditionsAfterRel99           accessCapAdditionsAfterRel99 optional
} with {
  variant "FIELDORDER(msb)";
}


type record AccessCapAdditionsRel99
{
  BIT1               presenceBitPskpow,
  BIT2               pskpowercap                     optional,
  BIT1               compactIntMeasurCap,
  BIT1               revisionLevelInd,
  BIT1               umtsfddRadAccTechCap,
  BIT1               umtstddRadAccTechCap,
  BIT1               cdma2kRadAccTechCap
} with {
  variant "FIELDORDER(msb)";
  variant(pskpowercap) "BYTEORDER(last)";
  variant (pskpowercap) "PRESENCE(presenceBitPskpow = '1'B)";
}


type record AccessCapAdditionsAfterRel99
{
  AccessCapAdditionsRel4       accessCapAdditionsRel4,
  AccessCapAdditionsAfterRel4  accessCapAdditionsAfterRel4 optional
} with {
  variant "FIELDORDER(msb)";
}


type record AccessCapAdditionsRel4
{
  BIT1               umts128RadAccTechCap,
  BIT1               geranFeaturePackage,
  BIT1               presenceBitExtendedDTM,
  ExtendedDTM        extendedDTM                       optional,
  BIT1               modulationBasedMultislotClass
} with {
  variant "FIELDORDER(msb)";
  variant (extendedDTM)          "PRESENCE(presenceBitExtendedDTM = '1'B)";
}


type record AccessCapAdditionsAfterRel4
{
  AccessCapAdditionsRel5       accessCapAdditionsRel5, 
  AccessCapAdditionsAfterRel5  accessCapAdditionsAfterRel5 optional
} with {
  variant "FIELDORDER(msb)";
}


type record AccessCapAdditionsRel5
{
  BIT1               presenceBitHighMultislotCapability,
  BIT2               highMultislotCapability            optional,
  BIT1               presenceBitGeranIuModeCapability,  // this field is present to make the module compatible with earlier versions; it always must be set to 0, 
  BIT2               gMSKMultislotPowerProfile,
  BIT2               eightPSKMultislotPowerProfile
} with {
  variant "FIELDORDER(msb)";
  variant(highMultislotCapability) "BYTEORDER(last)";
  variant(gMSKMultislotPowerProfile) "BYTEORDER(last)";
  variant(eightPSKMultislotPowerProfile) "BYTEORDER(last)";
  variant (highMultislotCapability)
  "PRESENCE(presenceBitHighMultislotCapability = '1'B)"
}


type record AccessCapAdditionsAfterRel5
{
  AccessCapAdditionsRel6        accessCapAdditionsRel6,
  AccessCapAdditionsAfterRel6   accessCapAdditionsAfterRel6 optional  
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel6
{
  AccessCapAdditionsRel7        accessCapAdditionsRel7,
  //AccessCapAdditionsRel8        accessCapAdditionsAfterRel7 optional 
  AccessCapAdditionsAfterRel7   accessCapAdditionsAfterRel7 optional 
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsRel6
{
  BIT1               multipleTBFCapability,
  BIT2               downlinkAdvancedReceiverPerformance,
  BIT1               extendedRLCMACCtrlMsgSegmentationCap,
  BIT1               dTMEnhancementsCapability,
  BIT1               presenceBitDTMGPRSHighMultiSlotClass,
  DTMGPRSHighMultiSlotClass  dTMGPRSHighMultiSlotClass optional,
  BIT1               pSHandoverCapability
} with {
  variant "FIELDORDER(msb)";
  variant(downlinkAdvancedReceiverPerformance) "BYTEORDER(last)";
  variant (dTMGPRSHighMultiSlotClass)
  "PRESENCE(presenceBitDTMGPRSHighMultiSlotClass = '1'B)"
}


type record DTMGPRSHighMultiSlotClass
{
  BIT3               dTMGPRSHighMultiSlotClassValue,
  BIT1               presenceBitDTMEGPRSHighMultiSlotClass,
  BIT3               dTMEGPRSHighMultiSlotClassValue optional
} with {
  variant "FIELDORDER(msb)";
  variant(dTMGPRSHighMultiSlotClassValue) "BYTEORDER(last)";
  variant(dTMEGPRSHighMultiSlotClassValue) "BYTEORDER(last)";
  variant (dTMEGPRSHighMultiSlotClassValue)
  "PRESENCE(presenceBitDTMEGPRSHighMultiSlotClass = '1'B)"
  
}


type record AccessCapAdditionsRel7
{
  BIT1                  dTMHandoverCapability,
  BIT1                  presenceBitDownlinkDualCarrier, 
  DownlinkDualCarrier   downlinkDualCarrier optional,
  BIT1                  flexibleTimeslotAssignment,
  BIT1                  gANPSHandoverCapability,
  BIT1                  rLCNonPersistentMode,
  BIT1                  reducedLatencyCapability,
  BIT2                  uplinkEGPRS2,
  BIT2                  downlinkEGPRS2
} with {
  variant "FIELDORDER(msb)";
  variant(uplinkEGPRS2) "BYTEORDER(last)";
  variant(downlinkEGPRS2) "BYTEORDER(last)";
  variant (downlinkDualCarrier) "PRESENCE(presenceBitDownlinkDualCarrier = '1'B)"
}

type record AccessCapAdditionsAfterRel7
{
  AccessCapAdditionsRel8       accessCapAdditionsRel8,
  AccessCapAdditionsAfterRel8  accessCapAdditionsAfterRel8
}


type record AccessCapAdditionsRel8
{
  BIT1                  eUTRAFDDsupport ,
  BIT1                  eUTRATDDsupport, 
  BIT2                  gERANToEUTRASupportInGERANPacketTransferMode,
  BIT1                  priorityBasedReselectionSupport 
} with {
  variant(gERANToEUTRASupportInGERANPacketTransferMode) "BYTEORDER(last)";
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel8
{
  AccessCapAdditionsRel9       accessCapAdditionsRel9,
  AccessCapAdditionsAfterRel9  accessCapAdditionsAfterRel9
}

type record AccessCapAdditionsRel9
{
  EnhancedFlexTimeslotAssignment   enhancedFlexTimeslotAssignment,
  BIT1                             indicationofUpperLayerPDUStartCapabilityforRLCUM,
  BIT1                             eMSTCapability,
  BIT1                             mTTICapability,
  BIT1                             uTRACSGCellsReporting,
  BIT1                             eUTRACSGCellsReporting
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel9
{
  AccessCapAdditionsRel10       accessCapAdditionsRel10,
  AccessCapAdditionsAfterRel10  accessCapAdditionsAfterRel10
}

type record AccessCapAdditionsRel10
{
  BIT1           dTRCapability,
  BIT1           eMSRCapability,
  BIT1           fastDownlinkFrequencySwitchingCapability,
  BIT2           tIGHTER_Capability  
} with {
  variant(tIGHTER_Capability) "BYTEORDER(last)";
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel10
{
  AccessCapAdditionsRel11       accessCapAdditionsRel11,
  AccessCapAdditionsAfterRel11  accessCapAdditionsAfterRel11
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsRel11
{
  BIT1           fANRCapability,
  BIT1           iPACapability,
  BIT1           gERANNetworkSharingSupport,
  BIT1           eUTRAWidebandRSRQMeasurementsSupport  
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel11
{
  AccessCapAdditionsRel12       accessCapAdditionsRel12,
  AccessCapAdditionsAfterRel12  accessCapAdditionsAfterRel12
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsRel12
{
  BIT1           uTRAMultipleFrequencyBandIndicatorsSupport,
  BIT1           eUTRAMultipleFrequencyBandIndicatorsSupport,
  BIT1           presenceBitDLMCCapability, 
  DLMCCapability dLMCCapability optional,
  BIT1           extendedTSCSetCapabilitySupport 
} with {
  variant "FIELDORDER(msb)";
  variant (dLMCCapability) "PRESENCE(presenceBitDLMCCapability = '1'B)"
}

type record DLMCCapability
{
  BIT1               presenceDLMC,
  DLMCBandReception  dLMCBandReception    optional,
  BIT2               dLMCMaxBandwidth,
  BIT6               dLMCMaxNumOfDownlinkTimeslots,
  BIT3               dLMCMaxNumOfDownlinkCarriers
} with {
  variant "FIELDORDER(msb)";
  variant(dLMCMaxBandwidth) "BYTEORDER(last)";
  variant(dLMCMaxNumOfDownlinkTimeslots) "BYTEORDER(last)";
  variant(dLMCMaxNumOfDownlinkCarriers) "BYTEORDER(last)";
  variant (dLMCBandReception) "PRESENCE(presenceDLMC = '1'B)"
}

type record DLMCBandReception
{
  BIT2  dLMCNonContiguousIntraBandReception,
  BIT1  dLMCInterBandReception
} with {
  variant(dLMCNonContiguousIntraBandReception) "BYTEORDER(last)";
  variant "FIELDORDER(msb)";
}

type record AccessCapAdditionsAfterRel12
{
  AccessCapLateAdditionsRel11   accessCapLateAdditionsRel11,
  octetstring                   accessCapLateAdditionsAfterRel11
} with {
  variant "FIELDORDER(msb)";
}

type record AccessCapLateAdditionsRel11
{
  BIT1     extendedEARFCNValueRange
}

type record EnhancedFlexTimeslotAssignment
{
  BIT1                  presenceBitalternativeEFTAMultislotClass,
  BIT4                  alternativeEFTAMultislotClass,
  BIT3                  eFTAMultislotCapabilityReductionforDownlinkDualCarrier
} with {
  variant(alternativeEFTAMultislotClass) "BYTEORDER(last)";
  variant(eFTAMultislotCapabilityReductionforDownlinkDualCarrier) "BYTEORDER(last)";
  variant "FIELDORDER(msb)"
};


type record DownlinkDualCarrier
{
  BIT3  multislotCapReductionforDownLinkDualCarrier,
  BIT1  downlinkDualCarrierforDTMCapability
} with { variant "FIELDORDER(msb)" };


type record  ExtendedDTM
{
  BIT2               ExtendedDTM_GPRSMultislot,
  BIT2               ExtendedDTM_EGPRSMultislot
} with { variant "FIELDORDER(msb)" };


//MultislotCap
type record  MultislotCap
{
  BIT1               presenceBitHscsd,
  BIT5               hscsdmultislotclass      optional,
  BIT1               presenceBitGprs,
  MultislotCap_GPRS  gprsmultislot           optional,
  BIT1               presenceBitSms,
  MultislotCap_SMS   multislotCap_SMS        optional,
  MultislotCapAdditionsAfterRel97 multislotCapAdditionsAfterRel97 optional
} with {
  variant "FIELDORDER(msb)";
  variant (hscsdmultislotclass)     "PRESENCE(presenceBitHscsd = '1'B)";
  variant(hscsdmultislotclass) "BYTEORDER(last)";
  variant (gprsmultislot)          "PRESENCE(presenceBitGprs = '1'B)";
  variant (multislotCap_SMS)       "PRESENCE(presenceBitSms = '1'B)";
  
}


type record MultislotCapAdditionsAfterRel97
{
  BIT1                         presenceBitEcsdmulti,
  BIT5                         ecsdmultislotclass      optional,
  BIT1                         presenceBitEgprsmulti,
  MultislotCap_EGPRS           multislotCap_EGPRS      optional,
  BIT1                         presenceBitDtmGprsmulti,
  MultislotCap_dtmgprsmultislotsubclass   multislotCapdtmgprsmultislotsubclass optional
} with {
  variant "FIELDORDER(msb)";
  variant (ecsdmultislotclass)     "PRESENCE(presenceBitEcsdmulti = '1'B)";
  variant (multislotCap_EGPRS)     "PRESENCE(presenceBitEgprsmulti = '1'B)" ;
  variant(ecsdmultislotclass) "BYTEORDER(last)";
  variant (multislotCapdtmgprsmultislotsubclass)
  "PRESENCE(presenceBitDtmGprsmulti = '1'B)"
}


type record MultislotCap_GPRS
{
  BIT5               gprsmultislotclass,
  BIT1               gprsextendeddynalloccap
} with {
  variant "FIELDORDER(msb)" 
  variant(gprsmultislotclass) "BYTEORDER(last)"
};


type record MultislotCap_SMS
{
  BIT4               smsValue,
  BIT4               smValue
} with { 
  variant "FIELDORDER(msb)" 
  variant(smsValue) "BYTEORDER(last)";
  variant(smValue) "BYTEORDER(last)"
};


type record  MultislotCap_EGPRS
{
  BIT5               egprsmultislotclass,
  BIT1               egprsextendeddynalloccap
}  with {
  variant "FIELDORDER(msb)" 
  variant(egprsmultislotclass) "BYTEORDER(last)"
};

type record MultislotCap_dtmgprsmultislotsubclass
{
  BIT2               dtmgprsmultislotsubclass,
  BIT1               singleSlotDTM,
  BIT1               presenceBitDTM_EGPRSMultiSlot,
  BIT2               dTM_EGPRSMultiSlot       optional
} with {
  variant "FIELDORDER(msb)";
  variant(dtmgprsmultislotsubclass) "BYTEORDER(last)";
  variant(dTM_EGPRSMultiSlot) "BYTEORDER(last)";
  variant (dTM_EGPRSMultiSlot) "PRESENCE(presenceBitDTM_EGPRSMultiSlot = '1'B)"
};


//A5BITS
type record  A5BITS
{
  BIT1       a51 ,
  BIT1       a52 ,
  BIT1       a53 ,
  BIT1       a54 ,
  BIT1       a55 ,
  BIT1       a56 ,
  BIT1       a57
} with { variant "FIELDORDER(msb)" };


type record MSRACapabilityValues1111
{
  BIT4               accessTechnType,    //1111
  integer            lengthIndicator,
  BIT1               presenceIndicator_AdditionalAccessTechnologiesRepetition,
  AdditionalAccessTechnologiesRepetition // coded '1'B if list is not empty
  additionalAccessTechnologiesRepetition           optional,
  bitstring          spare_bits
} with {
  variant "PRESENCE (accessTechnType = '1111'B)";
  variant (accessTechnType) "BYTEORDER(last)";
  variant "FIELDORDER(msb)";
  variant (lengthIndicator) "FIELDLENGTH(7)";
  variant (lengthIndicator) "UNIT(bits)";
  variant (lengthIndicator) "BYTEORDER(last)";
  variant (additionalAccessTechnologiesRepetition)
  "PRESENCE(presenceIndicator_AdditionalAccessTechnologiesRepetition = '1'B)";
  variant (lengthIndicator)
  "LENGTHTO(presenceIndicator_AdditionalAccessTechnologiesRepetition,
  additionalAccessTechnologiesRepetition,spare_bits)";
};


type record of AdditionalAccessTechnologiesRecord
AdditionalAccessTechnologiesRepetition
with { variant "EXTENSION_BIT(reverse)" };


type record AdditionalAccessTechnologiesRecord
{
  AdditionalAccessTechnologies additionalAccessTechnologies,
  BIT1                         extensionBit
} with { variant "FIELDORDER(msb)" };


type record  AdditionalAccessTechnologies
{
  BIT4               accessTechnType,
  BIT3               gMSKPowerClass,
  BIT2               psk8PowerClass
} with { variant "FIELDORDER(msb)" 
  variant (accessTechnType) "BYTEORDER(last)";
  variant (gMSKPowerClass) "BYTEORDER(last)";
  variant (psk8PowerClass) "BYTEORDER(last)";
};


// GMM Cause - 10.5.5.14
type record GMM_CauseTV
{
  OCT1               elementIdentifier,
  GMM_CauseV         causeValue
} with { variant "PRESENCE (elementIdentifier = '25'O)"; };

type record GMM_CauseV
{
  OCT1               causeValue
};


// Routing Area identification - 10.5.5.15
type record RoutingAreaIdentificationV
{
  HEX1               mccDigit1,
  HEX1               mccDigit2,
  HEX1               mccDigit3,
  HEX1               mncDigit3,
  HEX1               mncDigit1,
  HEX1               mncDigit2,
  OCT2               lac,
  OCT1               rac
};

// Routing Area identification - 10.5.5.15a
// moved into MobileL3_CommonIE_Types

//Update Result - 10.5.5.17
type record UpdateResultTV
{
  UpdateResultV      valueField,
  BIT4               elementIdentifier
};

type record  UpdateResultV
{
  BIT3               valueField,
  BIT1               fOP_l3
};


// Update Type - 10.5.5.18
type record  UpdateTypeTV
{
  UpdateTypeV        valueField,
  BIT4               elementIdentifier
};

type record  UpdateTypeV
{
  BIT3               valueField,
  BIT1               for_l3
};


// ACReferenceNumber - 10.5.5.19
type record   ACReferenceNumberTV
{
  ACReferenceNumberV acReferenceNumber,
  BIT4               acReferenceNumberIEI
};

type record ACReferenceNumberV
{
  BIT4               valueField
};


// Service type - 10.5.5.20
type record  ServiceTypeV
{
  BIT3               serviceType,
  BIT1               spare  //'0'B
};


// Cell Notification - 10.5.5.21
type record CellNotificationT
{
  OCT1               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '8C'O)"; };


// PC_LCSCapability - 10.5.5.22
type record PC_LCSCapability
{
  OCT1                         elementIdentifier,
  PC_LCSCapabilityLV           pC_LCSCapabilityLV
} with { variant "PRESENCE (elementIdentifier = '33'O)"; };


type record PC_LCSCapabilityLV
{
  LIN1               lengthIndicator,       // 3 octets
  PC_LCSCapabilityV  pC_LCSCapabilityV
} with { variant (lengthIndicator) "LENGTHTO (pC_LCSCapabilityV)"};


type record PC_LCSCapabilityV
{
  BIT1               gPS_C,
  BIT1               gPS_B,
  BIT1               gPS_A,
  BIT1               oTD_B,
  BIT1               oTD_A,
  BIT1               aPC,
  BIT2               spare  //'00'B
};


// NetworkFeatureSupportTV - 10.5.5.23
type record NetworkFeatureSupportTV
{
  NetworkFeatureSupportV  networkFeatureSupportV,
  BIT4                    elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1011'B)"; };


type record NetworkFeatureSupportV
{
  BIT1               eMCBS,     // 24.008 v9.5.0
  BIT1               iMSVoPS,
  BIT1               mBMS,
  BIT1               lCS_MOLR
};

// AdditionalNetworkFeatureSupportTLV - 10.5.5.23A
type record AdditionalNetworkFeatureSupportTLV
{
  OCT1                               elementIdentifier,
  LIN1                               lengthIndicator,
  AdditionalNetworkFeatureSupportV   additionalNetworkFeatureSupportV
} with {
  variant "PRESENCE (elementIdentifier = '66'O)";
  variant (lengthIndicator) "LENGTHTO (additionalNetworkFeatureSupportV)"
};


type record AdditionalNetworkFeatureSupportV
{
  BIT1      gPRS_SMS,
  BIT7      spare
};

// 10.5.5.24 Inter RAT information container
type record InterRATInformationContainerTLV
{
  OCT1                      elementIdentifier,
  LIN1                      lengthIndicator,
  octetstring               interRATInformationContainerV length(0..248)
} with {
  variant "PRESENCE (elementIdentifier = '27'O)";
  variant (lengthIndicator) "LENGTHTO (interRATInformationContainerV)"
};


// 10.5.5.25 Requested MS information
type record RequestedMSInformationTV
{
  BIT2                     spare,  //'00'B
  BIT1                     i_RAT2,
  BIT1                     i_RAT,
  BIT4                     elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1010'B)"; };

// 10.5.5.26 UE network capability TS 24.301 v13.4.0 / 9.9.3.34
type record UENetworkCapabilityTLV
{
  OCT1                            elementIdentifier,
  UENetworkCapabilityLV           uENetworkCapabilityLV
}with {
  variant "PRESENCE (elementIdentifier = '58'O)"
} 

type record UENetworkCapabilityLV
{
  LIN1                  lengthIndicator,    //2..13
  UENetworkCapabilityV  uENetworkCapabilityV
} with {
  variant (lengthIndicator) "LENGTHTO (uENetworkCapabilityV)"
}

type record UENetworkCapabilityV
{
  BIT8     eEA,
  BIT8     eIA,  
  BIT8     uEA      optional,  
  BIT7     uIA      optional,
  BIT1     uCS2     optional,//4. octet
  BIT1     nF       optional,
  BIT1     sRVCC    optional,
  BIT1     lCS      optional,
  BIT1     lPP      optional,
  BIT1     aCC_CSFB optional,
  BIT1     h245_ASH optional,
  BIT1     proSe    optional,
  BIT1     proSe_dd optional,
  BIT1     proSe_dc optional,
  BIT7     spare    optional,//6. octet
  octetstring     spare4 length (0..7) optional
}

// 10.5.5.27 E-UTRAN inter RAT information container
type record EUTRANinterRATInformationContainerTLV
{
  OCT1                      elementIdentifier,
  LIN1                      lengthIndicator,
  octetstring               eUTRANinterRATInformationContainerV length(0..255)
} with {
  variant "PRESENCE (elementIdentifier = '2B'O)";
  variant (lengthIndicator) "LENGTHTO (eUTRANinterRATInformationContainerV)"
};

// 10.5.5.28 Voice Domain Preference and UE's Usage Setting
type record VoiceDomainPreferenceandUEsUsageSettingTLV
{
  OCT1                      elementIdentifier,
  LIN1                      lengthIndicator,
  VDPaUEsUS_V               informationElement
} with {
  variant "PRESENCE (elementIdentifier = '5D'O)"
  variant (lengthIndicator) "LENGTHTO (informationElement)"
};

type record VDPaUEsUS_V
{
  BIT2                      voiceDomainPreferenceforEUTRAN,
  BIT1                      uEsUsageSetting,
  BIT1                      spare1,
  BIT1                      spare2,
  BIT1                      spare3,
  BIT1                      spare4,
  BIT1                      spare5
};

// P_TMSI Type 10.5.5.29
//moved into MobileL3_CommonIE_Types

// 10.5.5.30
type record LocationAreaIdentification2_TLV
{
  OCT1                           elementIdentifier,
  LIN1                           lengthIndicator, 
  OCT5                           locationAreaIdentificationValue
} with {
  variant "PRESENCE (elementIdentifier = '14'O)";
  variant (lengthIndicator) "LENGTHTO (locationAreaIdentificationValue)"
};

// 10.5.5.31
type record NetworkResourceIdentifierContainerTLV
{
  OCT1                                 elementIdentifier,
  NetworkResourceIdentifierContainerLV networkResourceIdentifierContainerLV
} with {
  variant "PRESENCE (elementIdentifier = '10'O)";
};

type record NetworkResourceIdentifierContainerLV
{
  LIN1                                lengthIndicator, 
  NetworkResourceIdentifierContainerV networkResourceIdentifierContainerV
} with {
  variant (lengthIndicator) "LENGTHTO (networkResourceIdentifierContainerV)"
};

type record NetworkResourceIdentifierContainerV
{
  BIT10  nRIContainerValue, 
  BIT6   spare
} with {
  variant (nRIContainerValue) "BITORDER (msb)";
  variant (nRIContainerValue,spare) "FIELDORDER (msb)";
};

// 10.5.5.32
type record ExtendedDRXParametersTLV
{
  OCT1                           elementIdentifier,
  LIN1                           lengthIndicator, 
  BIT4                           eDRXValue,
  BIT4                           pagingTimeWindow
} with {
  variant "PRESENCE (elementIdentifier = '6E'O)";
  variant (lengthIndicator) "LENGTHTO (eDRXValue,pagingTimeWindow)"
};
// ========================================================
// Session management information elements (chapter 10.5.6)
// ========================================================

// Access Point Name - 10.5.6.1

type record AccessPointNameTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,       // 3-102 octets  ,
  AccessPointNameV   accessPointNameValue
} with {
  variant "PRESENCE (elementIdentifier = '28'O)";
  variant (lengthIndicator) "LENGTHTO (accessPointNameValue)"
};

type record AccessPointNameLV
{
  LIN1               lengthIndicator,       // 3-102 octets  ,
  AccessPointNameV   accessPointNameValue
} with { variant (lengthIndicator) "LENGTHTO (accessPointNameValue)"};

type octetstring AccessPointNameV;


//NSAPI - 10.5.6.2
type record NSAPITV
{
  OCT1               elementIdentifier,
  NSAPIV             valueField
};

type record  NSAPIV
{
  BIT4               valueField,
  BIT4               spare     //'0000'B
};


//Protocol Configuration Options - 10.5.6.3
type record ProtocolConfigOptionsTLV
{
  OCT1                         elementIdentifier,
  LIN1                         lengthIndicator,
  ProtocolConfigOptionsV       protocolConfigOptionsV
} with {
  variant "PRESENCE (elementIdentifier = '27'O)";
  variant (lengthIndicator) "LENGTHTO (protocolConfigOptionsV)"
};

type record ProtocolConfigOptionsV
{
  BIT3                         configProtocol,
  BIT4                         spare , //'0000'B
  BIT1                         extensionField,   //'1'B
  ProtocolIDs_and_ContainerIDs protocolIDs_and_ContainerIDs optional
};

type record of  ProtocolID_or_ContainerID   ProtocolIDs_and_ContainerIDs;

type record ProtocolID_or_ContainerID
{
  OCT2               protocolID_or_ContainerID,
  LIN1               lengthIndicator,
  octetstring        protID_orContID_Contents
} with { variant (lengthIndicator) "LENGTHTO (protID_orContID_Contents)"};


// PDP Address - 10.5.6.4
type record PDPAddressTLV
{
  OCT1               elementIdentifier,
  PDPAddressLV       pDPAddressLV
} with { variant "PRESENCE (elementIdentifier = '2B'O)"; };


type record PDPAddressLV
{
  LIN1               lengthIndicator,
  PDPAddressV        pdpAddressV
} with { variant (lengthIndicator) "LENGTHTO (pdpAddressV)"};


type record  PDPAddressV
{
  BIT4               pdpTypeOrg,
  BIT4               spare,   //'0000'B
  OCT1               pdpTypeNum,
  octetstring        addressInfo   optional
};


// QoS - 10.5.6.5
type record  QoSTLV
{
  OCT1               elementIdentifier,
  QoSLV              qoSLV
} with { variant "PRESENCE (elementIdentifier = '30'O)"; };


type record  QoSLV
{
  LIN1               lengthIndicator,
  QoSV               qoSV
} with { variant (lengthIndicator) "LENGTHTO (qoSV)"};


type record QoSV
{
  BIT3               reliabilityClass,
  BIT3               delayClass,
  BIT2               spare1,  // '00'B
  BIT3               precedenceClass,
  BIT1               spare2, //'0'B
  BIT4               peakThroughput,
  BIT5               meanThroughput,
  BIT3               spare3, //'000'B
  BIT3               deliverErroneusSDU            optional, //opt because of V97
  BIT2               deliveryOrder                 optional, //opt because of V97
  BIT3               trafficClass                  optional, //opt because of V97
  OCT1               maxSDUSize                    optional, //opt because of V97
  OCT1               maxBitrateUplink              optional, //opt because of V97
  OCT1               maxBitrateDownlink            optional, //opt because of V97
  BIT4               sduErrorRatio                 optional, //opt because of V97
  BIT4               residualBER                   optional, //opt because of V97
  BIT2               trafficHandlingPriority       optional, //opt because of V97
  BIT6               transferDelay                 optional, //opt because of V97
  OCT1               guaranteedBitRateUplink       optional, //opt because of V97
  OCT1               guaranteedBitRateDownlink     optional, //opt because of V97
  BIT4               sourceStatisticsDescriptor    optional, //opt because of V97
  BIT1               signallingIndication          optional, //opt because of V97
  BIT3               spare4                        optional, //opt because of V97
  // '000'B
  OCT1               maxBitrateDownlinkExt         optional, //opt because of V97
  OCT1               guaranteedBitRateDownlinkExt  optional, //opt because of V97
  OCT1               maxBitrateUplinkExt           optional, //opt because of V97
  OCT1               guaranteedBitRateUplinkExt    optional, //opt because of V97 
  OCT1               maxBitrateDownlinkExt2        optional, //opt because of V97
  OCT1               guaranteedBitRateDownlinkExt2 optional, //opt because of V97
  OCT1               maxBitrateUplinkExt2          optional, //opt because of V97
  OCT1               guaranteedBitRateUplinkExt2   optional  //opt because of V97 
};

// ReAttemptIndicator - 10.5.6.5a
type record ReAttemptIndicatorTLV
{
  OCT1                 elementIdentifier,
  ReAttemptIndicatorLV reAttemptIndicatorLV
} with { variant "PRESENCE (elementIdentifier = '6B'O)"; };

type record ReAttemptIndicatorLV
{
  LIN1                lengthIndicator,
  ReAttemptIndicatorV reAttemptIndicatorV
} with { variant (lengthIndicator) "LENGTHTO (reAttemptIndicatorV)"};

type record ReAttemptIndicatorV
{
  BIT1  rATCValue,
  BIT1  ePLMNCValue,
  BIT6  spare
}

// SM Cause - 10.5.6.6
type OCT1 SMCauseV;

// SM Cause2 - 10.5.6.6a
type record SMCause2TLV
{
  OCT1               elementIdentifier,
  SMCause2LV         sMCause2LV
} with { variant "PRESENCE (elementIdentifier = '39'O)"; };

type record SMCause2LV 
{
  LIN1               lengthIndicator,
  OCT1               sMCause2V
} with { variant (lengthIndicator) "LENGTHTO (sMCause2V)"};

// Linked TI - 10.5.6.7
type record LinkedTITLV
{
  OCT1               elementIdentifier,
  LinkedTILV         linkedTILV
}

type record LinkedTILV
{
  LIN1               lengthIndicator,
  LinkedTIV          valueField
} with { variant (lengthIndicator) "LENGTHTO (valueField)"};


type record LinkedTIV
{
  BIT4               spare,  //'0000'B
  BIT3               tio,
  BIT1               tiFlag,
  TI_Extension       tIExtension  optional
} with { variant (tIExtension)"PRESENCE(tio = '111'B)"};


type record        TI_Extension
{
  BIT7               tI_Value,
  BIT1               tI_ExtBit         //'1'B
};


// LLC SAPI - 10.5.6.9
type record LLC_SAPITV
{
  OCT1               elementIdentifier,
  LLC_SAPIV          valueField
} with { variant "PRESENCE (elementIdentifier = '32'O)"; };


type record  LLC_SAPIV
{
  BIT4               valueField,
  BIT4               spare        //'0000'B
};


// Tear down indicator - 10.5.6.10
type record  TearDownIndicatorTV
{
  TearDownIndicatorV tearDownIndicatorV,
  BIT4               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1001'B)"; };

type record TearDownIndicatorV
{
  BIT1               tdi_flag,
  BIT3               spare     //'000'B
};


// Packet Flow Identifier - 10.5.6.11
type record PacketFlowIDTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,
  PacketFlowIDV      valueField
} with {
  variant "PRESENCE (elementIdentifier = '34'O)";
  variant (lengthIndicator) "LENGTHTO (valueField)"
};


type record PacketFlowIDV
{
  BIT7               valueField,
  BIT1               spare   // '0'B
};


// Traffic Flow Template - 10.5.6.12
// when TFT operation is  "delete packet filters from existing TFT"
// NOTE: will need to use "TAG" variant if both IEI is present within a PDU
type record TrafficFlowTemplateTLV
{
  OCT1                         elementIdentifier,
  TrafficFlowTemplateLV        trafficFlowTemplateLV
} with { variant "PRESENCE (elementIdentifier = '31'O,
  elementIdentifier = '36'O)";
};

type record TrafficFlowTemplateLV
{
  LIN1                         lengthIndicator,
  TrafficFlowTemplateV         valueField
} with { variant (lengthIndicator) "LENGTHTO(valueField)"};


type union TrafficFlowTemplateV
{
  TrafficFlowTemplateV_CreateAddReplaceTFT
  trafficFlowTemplateV_CreateAddReplaceTFT,
  TrafficFlowTemplateV_DeletePacketFilter
  trafficFlowTemplateV_DeletePacketFilter,
  TrafficFlowTemplateV_Delete_Existing_TFT_or_No_TFT_Operation
  trafficFlowTemplateV_Delete_Existing_TFT_or_No_TFT_Operation
};


type record TrafficFlowTemplateV_CreateAddReplaceTFT
{
  integer                                numberOfPacketFilters,
  BIT1                                   eBIT,
  BIT3                                   operationCodeTFT,  //'001'B or
  PacketFilterList_CreateAddReplaceTFT   packetFilterList_CreateAddReplaceTFT,
  ParametersList                         parametersList            optional
} with {
  variant "PRESENCE (operationCodeTFT  = '001'B, //  Create New TFT
  operationCodeTFT  = '011'B, //  Add packet filters to existing TFT
  operationCodeTFT  = '100'B  //  Replace packet filters in existing TFT
  )";
  variant(parametersList)       "PRESENCE(eBIT = '1'B)";
  variant(numberOfPacketFilters)"FIELDLENGTH(4)";
  variant(numberOfPacketFilters)"LENGTHTO(packetFilterList_CreateAddReplaceTFT)";
  variant(numberOfPacketFilters)"UNIT(elements)";
};


type record TrafficFlowTemplateV_DeletePacketFilter
{
  integer                                numberOfPacketFilters,
  BIT1                                   eBIT,
  BIT3                                   operationCodeTFT,
  //'101'B or '011'B or '100'B
  PacketFilterList_DeletePacketFilter    packetFilterList_DeletePacketFilter,
  ParametersList                         parametersList         optional
} with {
  variant "PRESENCE (operationCodeTFT = '101'B)"  // Delete packet filters from existing TFT
  variant(parametersList) "PRESENCE(eBIT = '1'B)";
  variant(numberOfPacketFilters)"FIELDLENGTH(4)";
  variant(numberOfPacketFilters)"LENGTHTO(packetFilterList_DeletePacketFilter)";
  variant  (numberOfPacketFilters)"UNIT(elements)";
};


type record TrafficFlowTemplateV_Delete_Existing_TFT_or_No_TFT_Operation
{
  BIT4                         numberOfPacketFilters, //'0000'B
  // numberOfPacketFilters is meaningless here since there is no PacketFilterList
  BIT1                         eBIT,
  BIT3                         operationCodeTFT,      // '010'B  or '110'B
  ParametersList               parametersList   optional
} with {
  variant "PRESENCE (operationCodeTFT = '010'B,  // delete existing TFT
  operationCodeTFT = '110'B   // No TFT Operation
  )";
  variant (parametersList) "PRESENCE(eBIT = '1'B)"
};


type record of PacketFilter PacketFilterList_CreateAddReplaceTFT;


type record PacketFilter
{
  PacketFilterIdentifier_CreateAddReplaceTFT       identifier,
  OCT1                         evaluationPrecedence,
  LIN1                         lengthIndicator,
  octetstring                  contents
} with { variant (lengthIndicator) "LENGTHTO (contents)"};

type record PacketFilterIdentifier_CreateAddReplaceTFT
{
  BIT4 packetFilterIdentifier,
  BIT2 packetFilterDirection,
  BIT2 spare
}

type record of PacketFilterIdentifier  PacketFilterList_DeletePacketFilter;


type record PacketFilterIdentifier
{
  BIT4 packetFilterIdentifier,
  BIT4 spare
}


type record of Parameter ParametersList;


type record Parameter
{
  OCT1               parameterIdentifier,
  LIN1               lengthIndicator,
  octetstring        contents
} with { variant (lengthIndicator) "LENGTHTO (contents)"};


// Temporary Mobile Group Identity - 10.5.6.13
type record TemporaryMobileGroupIDLV
{
  LIN1               lengthIndicator,
  OCT3               mBMSServiceID,
  HEX1               mccDigit1,
  HEX1               mccDigit2,
  HEX1               mccDigit3,
  HEX1               mncDigit3,
  HEX1               mncDigit1,
  HEX1               mncDigit2
}  with { variant (lengthIndicator) "LENGTHTO
  (mBMSServiceID,mccDigit1,mccDigit2,mccDigit3,
  mccDigit3,mncDigit1,mncDigit2)"};


// MBMS Bearer Capabilities - 10.5.6.14
type record MBMSBearerCapabilitiesLV
{
  LIN1               lengthIndicator,
  OCT1               maxBitrateDownlink,
  OCT1               maxBitrateDownlinkExtended optional
} with { variant (lengthIndicator) "LENGTHTO (maxBitrateDownlink,
  maxBitrateDownlinkExtended)"};

// MBMS Protocol Configuration Options - 10.5.6.15
type record MBMSProtocolConfigOptionsTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,
  OCT1               spare, // '00'O
  octetstring        valueField
} with {
  variant "PRESENCE (elementIdentifier = '35'O)";
  variant (lengthIndicator) "LENGTHTO (spare,valueField)"
};


//10.5.6.16
type record EnhancedNetworkSeviveAccessPointIDV  //(V)
{
  OCT1               enhancedNetworkSeviveAccessPointIDValue
}

// 10.5.6.17 Request type
type record RequestTypeTV {
  RequestTypeV       requestTypeV,
  BIT1				 spare,
  BIT4               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1010'B)" };

//001 initial request
//010 Handover
//011 Unused. If received, the network shall interpret this as "initial request".
//100 Emergency
type BIT3 RequestTypeV;

// 10.5.6.18 Notification Indicator
type record NotificationIndicatorLV
{
  LIN1              lengthIndicator,
  OCT1              valueField
} with {
  variant (lengthIndicator) "LENGTHTO (valueField)"
};

// 10.5.6.19 Connectivity Type
type record ConnectivityTypeTV
{
  BIT4               connectivityTypeValue,
  BIT4               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1011'B)" };

// 10.5.6.20 WLAN Offload Acceptability
type record WLANOffloadAcceptabilityTV
{
  BIT1  eUTRANOffloadAcceptabilityValue,
  BIT1  uTRANOffloadAcceptabilityValue,
  BIT2  spare,
  BIT4  elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1100'B)" };

// 10.5.6.21 NBIFOM container
type record NBIFOM_ContainerTLV
{
  OCT1                   elementIdentifier,
  LIN1                   lengthIndicator,
  NBIFOM_ParameterList   contents
} with { variant "PRESENCE (elementIdentifier = '33'O)";
  variant (lengthIndicator) "LENGTHTO (contents)" };

// 6.1.1 - TS 24.161 v2.0.0
type record of NBIFOM_Parameter NBIFOM_ParameterList;

type record NBIFOM_Parameter
{
  OCT1         parameterIdentifier,
  LIN1         lengthIndicator,
  NBIFOM_ParameterContents parameterContents
} with {  variant (lengthIndicator) "LENGTHTO (parameterContents)";
  variant (parameterContents) "CROSSTAG(
		nBIFOM_Mode, parameterIdentifier = '01'O;
		nBIFOM_DefaultAccess, parameterIdentifier = '02'O;
    nBIFOM_Status, parameterIdentifier = '03'O;
    nBIFOM_RoutingRules, parameterIdentifier = '04'O;
    nBIFOM_IPFlowMapping, parameterIdentifier = '05'O;
    nBIFOM_RANRulesHandling, parameterIdentifier = '06'O;
    nBIFOM_RANRulesStatus, parameterIdentifier = '07'O;
    nBIFOM_AccessUsabilityIndication, parameterIdentifier = '08'O;
    unknownParameter, OTHERWISE)"};

type union NBIFOM_ParameterContents
{
  OCT1 nBIFOM_Mode,
  OCT1 nBIFOM_DefaultAccess,
  OCT1 nBIFOM_Status,
  NBIFOM_RoutingRules nBIFOM_RoutingRules,
  NBIFOM_RoutingRules nBIFOM_IPFlowMapping,
  OCT1 nBIFOM_RANRulesHandling,
  OCT1 nBIFOM_RANRulesStatus,
  NBIFOM_AccessUsabilityIndication nBIFOM_AccessUsabilityIndication,
  octetstring unknownParameter
};

type record of NBIFOM_RoutingRule NBIFOM_RoutingRules
type record NBIFOM_RoutingRule
{
  LIN1         lengthIndicator,
  OCT1         routingRuleIdentifier,
  BIT3         operationCode,
  BIT3         spare,
  BIT2         routingAccess,
  OCT1         routingRulePrioroty,
  RoutingFilter routingFilter
} with {  variant (lengthIndicator) "LENGTHTO (routingRuleIdentifier,operationCode,
  spare,routingAccess,routingRulePrioroty,routingFilter)";}

type record RoutingFilter
{
  BIT1 flagA,
  BIT1 flagB,
  BIT1 flagC,
  BIT1 flagD,
  BIT1 flagE,
  BIT1 flagF,
  BIT1 flagG,
  BIT1 flagH,
  BIT1 flagI,
  BIT1 flagJ,
  BIT1 flagK,
  BIT1 flagL,
  BIT1 flagM,
  BIT1 flagN,
  bitstring flagsZ length(18),
  OCT4  sourceIPv4Address optional,
  OCT4  destinationIPv4Address optional,
  OCT16 sourceIPv6Address optional,
  OCT16 destinationIPv6Address optional,
  OCT1  sourceAddressPrefixLength optional,
  OCT1  destinationAddressPrefixLength optional,
  OCT4  iPSecSecurityParameterIndex optional,
  OCT1  protocolTypeNextHeader optional,
  OCT4  startSourcePortRange optional,
  OCT4  endSourcePortRange optional,
  OCT4  startDestinationPortRange optional,
  OCT4  endDestinationPortRange optional,
  OCT1  typeOfService optional,
  OCT4  flowLabel optional
}  with { variant (sourceIPv4Address)  "PRESENCE(flagA = '1'B)";
  variant (destinationIPv4Address)  "PRESENCE(flagB = '1'B)";
  variant (sourceIPv6Address)  "PRESENCE(flagC = '1'B)";
  variant (destinationIPv6Address)  "PRESENCE(flagD = '1'B)";
  variant (sourceAddressPrefixLength)  "PRESENCE(flagE = '1'B)";
  variant (destinationAddressPrefixLength)  "PRESENCE(flagF = '1'B)";
  variant (iPSecSecurityParameterIndex)  "PRESENCE(flagG = '1'B)";
  variant (protocolTypeNextHeader)  "PRESENCE(flagH = '1'B)";
  variant (startSourcePortRange)  "PRESENCE(flagI = '1'B)";
  variant (endSourcePortRange)  "PRESENCE(flagJ = '1'B)";
  variant (startDestinationPortRange)  "PRESENCE(flagK = '1'B)";
  variant (endDestinationPortRange)  "PRESENCE(flagL = '1'B)";
  variant (typeOfService)  "PRESENCE(flagM = '1'B)";
  variant (flowLabel)  "PRESENCE(flagN = '1'B)";
}

type record NBIFOM_AccessUsabilityIndication
{
  BIT2 threeGPPAccessUsableValue,
  BIT2 wLANAccessUsableValue,
  BIT4 spare
}
// =================================================
// GPRS Common information elements (chapter 10.5.7)
// =================================================

//PDPContextStatus - 10.5.7.1
type record PDPContextStatusTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,
  OCT2               valueField
} with {
  variant "PRESENCE (elementIdentifier = '32'O)";
  variant (lengthIndicator) "LENGTHTO (valueField)"
};


// Radio priority - 10.5.7.2
type record RadioPriorityTV
{
  RadioPriorityV     valueField,
  BIT4               elementIdentifier
} with { variant "PRESENCE (elementIdentifier = '1000'B)"; };


type record RadioPriorityV
{
  BIT3               priorityLevelValue,
  BIT1               spare  // '0'B
};


//GPRS Timer - 10.5.7.3
type record GPRSTimerTV
{
  OCT1               elementIdentifier,
  GPRSTimerV         gprsTimerV
} with { variant "PRESENCE (elementIdentifier = '17'O)"; };


type record GPRSTimerV
{
  BIT5               timerValue,
  BIT3               unit
};

// GPRS Timer2 - 10.5.7.4
type record GPRSTimer2TLV
{
  OCT1               elementIdentifier,  //'2A'O or '37'O
  LIN1               lengthIndicator,
  GPRSTimerV         gprsTimer2V    // the same as GPRSTimerV
} with {
  variant (lengthIndicator) "LENGTHTO (gprsTimer2V)"
};

// GPRS Timer3 - 10.5.7.4a
// GPRSTimer3TLV See MobileL3_CommonIE_Types.ttcn

// Radio priority2 - 10.5.7.5
type record RadioPriority2TV
{
  RadioPriority2V    valueField,
  BIT4               elementIdentifier
};


type record RadioPriority2V
{
  BIT3               priorityLevelValue,
  BIT1               spare   // '0'B
};


// 10.5.7.6 MBMS context status
type record MBMS_ContextStatusTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,
  octetstring        mBMSContextStatusInformation length (0..16)
} with {
  variant "PRESENCE (elementIdentifier = '35'O)";
  variant (lengthIndicator) "LENGTHTO (mBMSContextStatusInformation)"
};


// 10.5.7.7
type record UplinkDataStatusTLV
{
  OCT1               elementIdentifier,
  LIN1               lengthIndicator,
  UplinkDataStatusV  valueField
} with {
  variant "PRESENCE (elementIdentifier = '36'O)";
  variant (lengthIndicator) "LENGTHTO (valueField)"
};

type record UplinkDataStatusV
{
  BIT5               spare,
  BIT3               nSAPI_5_to_7,
  BIT8               nSAPI_8_to_15
}; 

// 10.5.7.8
// DevicePropertiesTV -> See MobileL3_CommonIE_Types.ttcn


// ==============================================
// GPRS Mobility Management Messages (chapter 9.4)
// ==============================================

// GMM Attach Request - 9.4.1
type record PDU_GMM_AttachRequest
{
  BIT8                             messageType, // '00000001'B
  MSNetworkCapabilityLV            msNetworkCapability,
  AttachTypeV                      attachType,
  CipheringKeySequenceNumberV      gprsCKSN,
  DRXParameterV                    drxParam,
  MobileIdentityLV                 mobileIdentity,
  RoutingAreaIdentificationV       oldRoutingAreaID,
  MSRadioAccessCapabilityLV        msRACap,
  P_TMSISignatureTV                ptmsiSignature                optional,
  GPRSTimerTV                      reqGPRStimer                  optional,
  TMSIStatusTV                     tmsiStatus                    optional,
  PC_LCSCapability                 pC_LCSCapability              optional,
  MobileStationClassmark2_TLV      mobileStationClassmark2       optional,
  MobileStationClassmark3_TLV      mobileStationClassmark3       optional,
  SupportedCodecList               supportedCodecs               optional,
  UENetworkCapabilityTLV           uENetworkCapability           optional,
  MobileIdentityTLV                additionalMobileIdentity      optional,
  RoutingAreaIdentification2TLV    routingAreaIdentification2    optional,
  VoiceDomainPreferenceandUEsUsageSettingTLV  voiceDomainandUEsUsageSetting optional,
  DevicePropertiesTV               deviceProperties optional,
  P_TMSI_TypeTV                    p_TMSI_Type optional,
  MS_NetworkFeatureSupportTV       mS_NetworkFeatureSupport optional,
  LocationAreaIdentification2_TLV  oldLocationAreaIdentification optional,
  AdditionalUpdateTypeTV           additionalUpdateType optional,
  NetworkResourceIdentifierContainerTLV tMSIBasedNRIcontainer optional,
  GPRSTimer2TLV                    t3324 optional,
  GPRSTimer3TLV                    t3312_ExtendedValue optional,
  ExtendedDRXParametersTLV         extendedDRXParameters optional
} with {
  variant "PRESENCE (messageType = '00000001'B)";
  variant "TAG
  ( 
  additionalMobileIdentity,                      elementIdentifier = '0011010'B; 
  deviceProperties,                              elementIdentifier = '1101'B;  //D
  mS_NetworkFeatureSupport,                      elementIdentifier = '1100'B;  //C
  t3324,                      elementIdentifier = '6a'O;
  t3312_ExtendedValue,        elementIdentifier = '39'O
  )"
};

// GMM Attach Accept - 9.4.2
type record PDU_GMM_AttachAccept
{
  BIT8                         messageType,
  AttachResultV                attachResult,
  ForceToStandbyV              forceToStandby,
  GPRSTimerV                   updateTimer,
  RadioPriorityV               radioPriority,    //SMS
  RadioPriority2V              radioPriorityTOM8, //  TOM8
  RoutingAreaIdentificationV   routingAreaIdentification,
  P_TMSISignatureTV            ptmsiSignature      optional,
  GPRSTimerTV                  readyTimer          optional,
  MobileIdentityTLV            allocatedPTMSI      optional,
  MobileIdentityTLV            msIdentity          optional,
  GMM_CauseTV                  gmmCause            optional,
  GPRSTimer2TLV                t3302               optional,
  CellNotificationT            cellNotification    optional,
  PLMNListTLV                  equivalentPLMNs     optional,
  NetworkFeatureSupportTV      networkFeatureSupport     optional,
  EmergencyNumberListTLV       emergencyNumberList       optional,
  RequestedMSInformationTV     requestedMSInformation    optional,
  GPRSTimer2TLV                t3319                     optional,  
  GPRSTimer2TLV                t3323                     optional,
  GPRSTimer3TLV                t3312_ExtendedValue       optional,
  AdditionalNetworkFeatureSupportTLV additionalNetworkFeatureSupport optional,
  GPRSTimer2TLV                t3324 optional,
  ExtendedDRXParametersTLV     extendedDRXParameters optional
} with {
  variant "PRESENCE (messageType = '00000010'B)";
  variant "TAG
  (
  allocatedPTMSI,             elementIdentifier = '0011000'B;  //'18'O  7 bits
  msIdentity,                 elementIdentifier = '0100011'B;  //'23'O  7 bits
  t3302,                      elementIdentifier = '2A'O;  
  t3319,                      elementIdentifier = '37'O;  
  t3323,                      elementIdentifier = '38'O;
  t3312_ExtendedValue,        elementIdentifier = '39'O;
  t3324,                      elementIdentifier = '6a'O;
  )"
};


// GMM Attach Complete - 9.4.3
type record  PDU_GMM_AttachComplete
{
  BIT8                             messageType,
  InterRATInformationContainerTLV  interRATHandoverInformation optional,
  EUTRANinterRATInformationContainerTLV eUTRANinterRATHandoverInformation optional
} with { variant "PRESENCE (messageType = '00000011'B)"; };


// GMM Attach Reject - 9.4.4
type record PDU_GMM_AttachReject
{
  BIT8                         messageType,
  GMM_CauseV                   gmmCause,
  GPRSTimer2TLV                t3302          optional,
  GPRSTimer2TLV                t3346          optional 
  
} with { variant "PRESENCE (messageType = '00000100'B)"; 
  variant "TAG 
  ( 
  t3302,     elementIdentifier = '2A'O;
  t3346,     elementIdentifier = '3A'O;
  )" 
};

// GMM Detach Request - 9.4.5

// GMM Detach Request (mobile terminated detach) - 9.4.5.1
type record PDU_GMM_DetachRequest_SGSN_MS
{
  BIT8                         messageType,
  DetachTypeV                  detachType,
  ForceToStandbyV              forceToStandby,
  GMM_CauseTV                  gmmCause    optional
} with { variant "PRESENCE (messageType = '00000101'B)"; };

// GMM Detach Request (mobile originating detach) - 9.4.5.2
type record   PDU_GMM_DetachRequest_MS_SGSN
{
  BIT8                         messageType,
  DetachTypeV                  detachType,
  BIT4                         spare,
  MobileIdentityTLV            ptmsi             optional,
  P_TMSISignature2TLV          ptmsiSignature    optional
} with {
  variant "PRESENCE (messageType = '00000101'B)";
  variant "TAG (ptmsi, elementIdentifier = '0011000'B;)" //'18'O 7 bits
};

// GMM Detach Accept - 9.4.6

// GMM Detach Accept (mobile terminated detach) 9.4.6.1
type record  PDU_GMM_DetachAccept_MS_SGSN
{
  BIT8  messageType
} with { variant "PRESENCE (messageType = '00000110'B)"; };

// GMM Detach Accept (mobile originating detach) 9.4.6.2
type record  PDU_GMM_DetachAccept_SGSN_MS
{
  BIT8                         messageType,
  ForceToStandbyV              forceToStandby,
  BIT4                         spare
} with { variant "PRESENCE (messageType = '00000110'B)"; };

// GMM P-TMSI reallocation command - 9.4.7
type record  PDU_GMM_P_TMSIReallocationCommand
{
  BIT8                         messageType,
  MobileIdentityLV             allocatedPTMSI,
  RoutingAreaIdentificationV   routingAreaIdentification,
  ForceToStandbyV              forceToStandby,
  BIT4                         spare,
  P_TMSISignatureTV            ptmsiSignature    optional
} with { variant "PRESENCE (messageType = '00010000'B)"; };

// GMM P-TMSI reallocation complete - 9.4.8
type record  PDU_GMM_P_TMSIReallocationComplete
{
  BIT8              messageType
} with { variant "PRESENCE (messageType = '00010001'B)"; };

// GMM Authentication and ciphering request - 9.4.9
type record PDU_GMM_AuthenticationAndCipheringRequest
{
  BIT8                                   messageType,
  CipheringAlgorithmV                    cipheringAlgorithm,
  IMEISVRequestV                         imeisvRequest,
  ForceToStandbyV                        forceToStandby,
  ACReferenceNumberV                     acReferenceNumber,
  AuthenticationParameterRANDTV          authenticationParameterRAND optional,
  CipheringKeySequenceNumberTV           cipheringKeySequenceNumber  optional,
  AuthenticationParameterAUTNTLV         authenticationParameterAUTN optional
} with { variant "PRESENCE (messageType = '00010010'B)"; 
  variant "TAG (authenticationParameterAUTN,   elementIdentifier = '28'O)";
};

// GMM Authentication and ciphering response  - 9.4.10
type record PDU_GMM_AuthenticationAndCipheringResponse
{
  BIT8                                   messageType,
  ACReferenceNumberV                     acReferenceNumber,
  BIT4                                   spare,
  AuthenticationResponseParameterTV      authenticationParResp     optional,
  MobileIdentityTLV                      imeisv                    optional,
  AuthenticationResponseParameterUMTSTLV authenticationRespParExt  optional
} with {
  variant "PRESENCE (messageType = '00010011'B)";
  variant "TAG (imeisv,                     elementIdentifier = '0100011'B;)"
  variant "TAG (authenticationRespParExt,   elementIdentifier = '29'O)";
};

// GMM Authentication and Ciphering Failure  - 9.4.10a
type record PDU_GMM_AuthenticationAndCipheringFailure
{
  BIT8                                   messageType,
  GMM_CauseV                             gmmCause,
  AuthenticationFailureParametersTLV     authenticationFailureParam   optional
} with { variant "PRESENCE (messageType = '00011100'B)"; 
  variant "TAG (authenticationFailureParam,   elementIdentifier = '30'O)";
};

// GMM Authentication and ciphering reject - 9.4.11
type record PDU_GMM_AuthenticationAndCipheringReject
{
  BIT8               messageType
} with { variant "PRESENCE (messageType = '00010100'B)"; };

// GMM Identity Request - 9.4.12
type record PDU_GMM_IdentityRequest
{
  BIT8               messageType,
  IdentityType2V     identityType,
  ForceToStandbyV    forceToStandby
} with { variant "PRESENCE (messageType = '00010101'B)"; };

// GMM Identity response - 9.4.13
type record PDU_GMM_IdentityResponse
{
  BIT8               messageType,
  MobileIdentityLV   mobileIdentity
} with { variant "PRESENCE (messageType = '00010110'B)"; };

// GMM Routing area update request - 9.4.14
type record PDU_GMM_RoutingAreaUpdateRequest
{
  BIT8                         messageType,
  UpdateTypeV                  updateType,
  CipheringKeySequenceNumberV  gprsCKSN,
  RoutingAreaIdentificationV   oldRoutingAreaId,
  MSRadioAccessCapabilityLV    msRACap,
  P_TMSISignatureTV            oldPTMSISignature           optional,
  GPRSTimerTV                  readyTimerValue             optional,
  DRXParameterTV               drxParameter                optional,
  TMSIStatusTV                 tmsiStatus                  optional,
  MobileIdentityTLV            ptmsi                       optional,
  MSNetworkCapabilityTLV       mSNetworkCapability         optional,
  PDPContextStatusTLV          pdpContextStatus            optional,
  PC_LCSCapability             pC_LCSCapability            optional,
  MBMS_ContextStatusTLV        mBMS_ContextStatus          optional,
  UENetworkCapabilityTLV       uENetworkCapability         optional,
  MobileIdentityTLV            additionalMobileIdentity    optional,
  RoutingAreaIdentification2TLV oldRoutingAreaIdentification2 optional,
  MobileStationClassmark2_TLV  mobileStationClassmark2     optional,
  MobileStationClassmark3_TLV  mobileStationClassmark3     optional,
  SupportedCodecList           supportedCodecs             optional,
  VoiceDomainPreferenceandUEsUsageSettingTLV  voiceDomainUEUsageSetting  optional,
  P_TMSI_TypeTV                p_TMSI_Type                 optional,
  DevicePropertiesTV           deviceProperties            optional,  
  MS_NetworkFeatureSupportTV   mS_NetworkFeatureSupport    optional,  
  LocationAreaIdentification2_TLV oldLocationAreaIdentification optional,  
  AdditionalUpdateTypeTV       additionalUpdateType optional,
  NetworkResourceIdentifierContainerTLV tMSIBasedNRIcontainer optional,
  GPRSTimer2TLV                t3324 optional,
  GPRSTimer3TLV                t3312_ExtendedValue optional,
  ExtendedDRXParametersTLV     extendedDRXParameters optional
} with {
  variant "PRESENCE (messageType = '00001000'B)";
  variant "TAG (
  ptmsi,                                  elementIdentifier = '0011000'B; //'18'O 7 bits
  additionalMobileIdentity,               elementIdentifier = '0011010'B;
  deviceProperties,                       elementIdentifier = '1101'B;  //D
  mS_NetworkFeatureSupport,               elementIdentifier = '1100'B;  //C
  t3324,                                  elementIdentifier = '6a'O;
  t3312_ExtendedValue,                    elementIdentifier = '39'O
  )"
};

// GMM Routing Area update accept  - 9.4.15
type record PDU_GMM_RoutingAreaUpdateAccept
{
  BIT8                         messageType,
  ForceToStandbyV              forceToStandby,
  UpdateResultV                updateResult,
  GPRSTimerV                   raUpdateTimer,
  RoutingAreaIdentificationV   routingAreaId,
  P_TMSISignatureTV            ptmsiSignature             optional,
  MobileIdentityTLV            allocatedPTMSI             optional,
  MobileIdentityTLV            msIdentity                 optional,
  ReceiveNPDUNumbersListTLV    receiveNPDUNumbers         optional,
  GPRSTimerTV                  readyTimer                 optional,
  GMM_CauseTV                  gmmCause                   optional,
  GPRSTimer2TLV                t3302                      optional,
  CellNotificationT            cellNotification           optional,
  PLMNListTLV                  equivalentPLMNs            optional,
  PDPContextStatusTLV          pdpContextStatus           optional,
  NetworkFeatureSupportTV      networkFeatureSupport      optional,
  EmergencyNumberListTLV       emergencyNumberList        optional,
  MBMS_ContextStatusTLV        mBMS_ContextStatus         optional,
  RequestedMSInformationTV     requestedMSInformation     optional,
  GPRSTimer2TLV                t3319                      optional,
  GPRSTimer2TLV                t3323                      optional,
  GPRSTimer3TLV                t3312_ExtendedValue        optional,   
  AdditionalNetworkFeatureSupportTLV additionalNetworkFeatureSupport optional,
  GPRSTimer2TLV                t3324 optional,
  ExtendedDRXParametersTLV     extendedDRXParameters optional
} with {
  variant "PRESENCE (messageType = '00001001'B)";
  variant "TAG
  (
  allocatedPTMSI,            elementIdentifier = '0011000'B; //'18'O 7 bits
  msIdentity,                elementIdentifier = '0100011'B; //'23'O 7 bits
  t3302,                     elementIdentifier = '2A'O; 
  t3319,                     elementIdentifier = '37'O;   
  t3323,                     elementIdentifier = '38'O;
  t3312_ExtendedValue,       elementIdentifier = '39'O;
  t3324,                     elementIdentifier = '6a'O;
  )"
};

// GMM Routing area update complete - 9.4.16
type record PDU_GMM_RoutingAreaUpdateComplete
{
  BIT8                             messageType,
  ReceiveNPDUNumbersListTLV        receiveNPDUNumbers     optional,
  InterRATInformationContainerTLV  interRATHandoverInformation optional,
  EUTRANinterRATInformationContainerTLV eUTRANinterRATHandoverInformation optional
} with { variant "PRESENCE (messageType = '00001010'B)"; };

// GMM Routing area update reject - 9.4.17
type record PDU_GMM_RoutingAreaUpdateReject
{
  BIT8                         messageType,
  GMM_CauseV                   gmmCause,
  ForceToStandbyV              forceToStandby,
  BIT4                         spare,
  GPRSTimer2TLV                t3302                  optional,
  GPRSTimer2TLV                t3346                  optional
} with { 
  variant "PRESENCE (messageType = '00001011'B)"; 
  variant "TAG
  (   
  t3302,                     elementIdentifier = '2A'O; 
  t3346,                     elementIdentifier = '3A'O;       
  )"
};

// GMM GMM Status - 9.4.18
type record PDU_GMM_GMM_Status
{
  BIT8                         messageType,
  GMM_CauseV                   gmmCause
} with { variant "PRESENCE (messageType = '00100000'B)"; };


// GMM GMM Information - 9.4.19
type record PDU_GMM_GMM_Information
{
  BIT8                         messageType,
  NetworkNameTLV               fullNetworkName            optional,
  NetworkNameTLV               shortNetworkName           optional,
  TimeZoneTV                   networkTimeZone            optional,
  TimeZoneAndTimeTV            networkTimeAndTimeZone     optional,
  LSA_IdentifierTLV            lsaIdentity                optional,
  DaylightSavingTimeTLV        networkDaylightSavingTime  optional
} with {
  variant "PRESENCE (messageType = '00100001'B)";
  variant "TAG
  (
  fullNetworkName,           elementIdentifier = '1000011'B;//'43'O  7 bits
  shortNetworkName,          elementIdentifier = '1000101'B;//'45'O  7 bits
  )"
};

// GMM Service Request - 9.4.20
type record PDU_GMM_ServiceRequest
{
  BIT8                         messageType,
  CipheringKeySequenceNumberV  cipheringKeySeqNum,
  ServiceTypeV                 serviceType,
  MobileIdentityLV             ptmsi,
  PDPContextStatusTLV          pdpContextStatus    optional, // this IE shall be included by the MS
  MBMS_ContextStatusTLV        mBMS_ContextStatus  optional,
  UplinkDataStatusTLV          uplinkDataStatus    optional,
  DevicePropertiesTV           deviceProperties    optional
} with { variant "PRESENCE (messageType = '00001100'B)"; 
         variant "TAG (deviceProperties,  elementIdentifier = '1101'B;  //D
  )"  
};

// GMM Service Accept - 9.4.21
type record PDU_GMM_ServiceAccept
{
  BIT8                         messageType,
  PDPContextStatusTLV          pdpContextStatus     optional,
  MBMS_ContextStatusTLV        mBMS_ContextStatus   optional
} with { variant "PRESENCE (messageType = '00001101'B)"; };

// GMM Service Reject - 9.4.22
type record PDU_GMM_ServiceReject
{
  BIT8                          messageType,
  GMM_CauseV                    gmmCause,
  GPRSTimer2TLV                 t3346 optional
} with { variant "PRESENCE (messageType = '00001110'B)"; };


// ==============================================
// GPRS Session Management Messages (chapter 9.5)
// ==============================================

// SM Activate PDP Context Request - 9.5.1
type record PDU_SM_ActivatePDPContextRequest
{
  BIT8                         messageType,
  NSAPIV                       requestedNSAPI,
  LLC_SAPIV                    requestedLLCSAPI,
  QoSLV                        requestedQoS,
  PDPAddressLV                 requestedPDPaddress,
  AccessPointNameTLV           accessPointName       optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts    optional,
  RequestTypeTV                requestType           optional,
  DevicePropertiesTV           deviceProperties      optional,
  NBIFOM_ContainerTLV          nBIFOM_Container      optional
} with { variant "PRESENCE (messageType = '01000001'B)"; 
         variant "TAG ( deviceProperties,  elementIdentifier = '1100'B;  //C
  )"    
};


// SM Activate PDP Context Accept - 9.5.2
type record PDU_SM_ActivatePDPContextAccept
{
  BIT8                         messageType,
  LLC_SAPIV                    negotiatedLLCSAPI,
  QoSLV                        negotiatedQoS,
  RadioPriorityV               radioPriority,
  BIT4                         spare,
  PDPAddressTLV                pdpAddress            optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts    optional,
  PacketFlowIDTLV              packetFlowID          optional,
  SMCause2TLV                  sMCause2              optional,
  ConnectivityTypeTV           connectivityType      optional,
  WLANOffloadAcceptabilityTV   wLANOffloadIndication optional,
  NBIFOM_ContainerTLV          nBIFOM_Container      optional
} with { variant "PRESENCE (messageType = '01000010'B)"; };


// SM Activate PDP Context Reject - 9.5.3
type record PDU_SM_ActivatePDPContextReject
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  ProtocolConfigOptionsTLV     protocolConfigOpts     optional,
  GPRSTimer3TLV                backOffTimer           optional,
  ReAttemptIndicatorTLV        reAttemptIndicator     optional,
  NBIFOM_ContainerTLV          nBIFOM_Container       optional
} with { variant "PRESENCE (messageType = '01000011'B)"; 
         variant "TAG (backOffTimer,  elementIdentifier = '37'O)"
};


// SM Activate Secondary PDP Context - 9.5.4
type record PDU_SM_ActivateSecondaryPDPContextRequest
{
  BIT8                         messageType,
  NSAPIV                       requestedNSAPI,
  LLC_SAPIV                    requestedLLC_SAPI,
  QoSLV                        requestedQoS,
  LinkedTILV                   linkedTI,
  TrafficFlowTemplateTLV       tft                     optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  DevicePropertiesTV           deviceProperties        optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional          
} with { variant "PRESENCE (messageType = '01001101'B)";     
         variant "TAG (deviceProperties,   elementIdentifier = '1100'B;  //C
  )" 
};
// SM Activate Secondary PDP Context Accept - 9.5.5
type record PDU_SM_ActivateSecondaryPDPContextAccept
{
  BIT8                         messageType,
  LLC_SAPIV                    negotiatedLLC_SAPI,
  QoSLV                        negotiatedQoS,
  RadioPriorityV               radioPriority,
  BIT4                         spare,
  PacketFlowIDTLV              packetFlowIdentifier     optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts       optional,
  WLANOffloadAcceptabilityTV   wLANOffloadIndication    optional,
  NBIFOM_ContainerTLV          nBIFOM_Container         optional
} with { variant "PRESENCE (messageType = '01001110'B)"; };


// SM Activate Secondary PDP Context Reject - 9.5.6
type record PDU_SM_ActivateSecondaryPDPContextReject
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  GPRSTimer3TLV                backOffTimer            optional,
  ReAttemptIndicatorTLV        reAttemptIndicator      optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional
} with  { variant "PRESENCE (messageType = '01001111'B)"; 
          variant "TAG (backOffTimer,  elementIdentifier = '37'O)"
};


// SM Request PDP context activation -  9.5.7
type record PDU_SM_RequestPDPContextActivation
{
  BIT8                         messageType,
  PDPAddressLV                 offeredPDPAdress,
  AccessPointNameTLV           accessPointName         optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional
} with { variant "PRESENCE (messageType = '01000100'B)"; };


// SM Request PDP context activation reject - 9.5.8
type record PDU_SM_RequestPDPContextActivationReject
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional
} with { variant "PRESENCE (messageType = '01000101'B)"; };


// SM Modify PDP context request (Network to MS direction) - 9.5.9
type record PDU_SM_ModifyPDPContextRequest_SGSN_MS
{
  BIT8                         messageType ,
  RadioPriorityV               radioPriority,
  BIT4                         spare,
  LLC_SAPIV                    requestedLLC_SAPI,
  QoSLV                        newQoS,
  PDPAddressTLV                pdpAddress              optional,
  PacketFlowIDTLV              packetFlowIdentifier    optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  TrafficFlowTemplateTLV       tFT                     optional,  
  WLANOffloadAcceptabilityTV   wLANOffloadIndication   optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional
} with { variant "PRESENCE (messageType = '01001000'B)"; };


// SM Modify PDP context request (MS to network direction) - 9.5.10
type record PDU_SM_ModifyPDPContextRequest_MS_SGSN
{
  BIT8                         messageType,
  LLC_SAPITV                   requestedLLC_SAPI      optional,
  QoSTLV                       requestedNewQoS        optional,
  TrafficFlowTemplateTLV       newTFT                 optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts     optional,
  DevicePropertiesTV           deviceProperties       optional,
  NBIFOM_ContainerTLV          nBIFOM_Container       optional           
} with { variant "PRESENCE (messageType = '01001010'B)"; 
         variant "TAG (deviceProperties, elementIdentifier = '1100'B;  //C
    )"     
};


// SM Modify PDP context accept (MS to network direction) - 9.5.11
type record PDU_SM_ModifyPDPContextAccept_MS_SGSN
{
  BIT8                         messageType,
  ProtocolConfigOptionsTLV     protocolConfigOpts     optional,
  NBIFOM_ContainerTLV          nBIFOM_Container       optional
} with { variant "PRESENCE (messageType = '01001001'B)"; };


// SM Modify PDP context accept (Network to MS direction) - 9.5.12
type record PDU_SM_ModifyPDPContextAccept_SGSN_MS
{
  BIT8                         messageType,
  QoSTLV                       negotiatedQoS          optional,
  LLC_SAPITV                   negotiatedLLC_SAPI     optional,
  RadioPriorityTV              newRadioPriority       optional,
  PacketFlowIDTLV              packetFlowIdentifier   optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts     optional,
  WLANOffloadAcceptabilityTV   wLANOffloadIndication  optional,
  NBIFOM_ContainerTLV          nBIFOM_Container       optional
} with { variant "PRESENCE (messageType = '01001011'B)"; };


// SM Modify PDP Context reject - 9.5.13
type record PDU_SM_ModifyPDPContextReject
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  ProtocolConfigOptionsTLV     protocolConfigOpts     optional,
  GPRSTimer3TLV                backOffTimer           optional,
  ReAttemptIndicatorTLV        reAttemptIndicator     optional,
  NBIFOM_ContainerTLV          nBIFOM_Container       optional
} with { variant "PRESENCE (messageType = '01001100'B)"; 
         variant "TAG (backOffTimer,  elementIdentifier = '37'O)"
};


// SM Deactivate PDP Context Request - 9.5.14
type record PDU_SM_DeactivatePDPContextRequest
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  TearDownIndicatorTV          tearDownIndicator         optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts        optional,
  MBMSProtocolConfigOptionsTLV mBMSprotocolConfigOptions optional,
  GPRSTimer3TLV                t3396                     optional,
  WLANOffloadAcceptabilityTV   wLANOffloadIndication     optional,
  NBIFOM_ContainerTLV          nBIFOM_Container          optional
} with { variant "PRESENCE (messageType = '01000110'B)";
  variant "TAG (t3396,  elementIdentifier = '37'O)"
};


// SM Deactivate PDP Context Accept 3GPP - 9.5.15
type record PDU_SM_DeactivatePDPContextAccept
{
  BIT8                         messageType,
  ProtocolConfigOptionsTLV     protocolConfigOpts        optional,
  MBMSProtocolConfigOptionsTLV mBMSprotocolConfigOptions optional,
  NBIFOM_ContainerTLV          nBIFOM_Container          optional
} with { variant "PRESENCE (messageType = '01000111'B)"; };


// Request Secondary PDP Context Activation - 9.5.15a
type record PDU_SM_RequestSecondaryPDPContextActivation
{
  BIT8                         messageType,
  QoSLV                        requiredQoS,
  LinkedTILV                   linkedTI,
  TrafficFlowTemplateTLV       tFT                     optional,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,  
  WLANOffloadAcceptabilityTV   wLANOffloadIndication   optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional
} with { variant "PRESENCE (messageType = '01011011'B)"; };


// Request Secondary PDP Context Activation Reject - 9.5.15b
type record PDU_SM_RequestSecondaryPDPContextActivationReject
{
  BIT8                         messageType,
  SMCauseV                     smCause,
  ProtocolConfigOptionsTLV     protocolConfigOpts      optional,
  NBIFOM_ContainerTLV          nBIFOM_Container        optional  
} with { variant "PRESENCE (messageType = '01011100'B)"; };

// Notification - 9.5.16a
type record PDU_SM_Notification
{
  BIT8                         messageType,
  NotificationIndicatorLV      notificationIndicator
} with { variant "PRESENCE (messageType = '01011101'B)"; };

// SM SM Status - 9.5.21
type record PDU_SM_SM_Status
{
  BIT8                         messageType,
  SMCauseV                     smCause
} with { variant "PRESENCE (messageType = '01010101'B)"; };


// Activate MBMS Context Request - 9.5.22
type record PDU_SM_ActivateMBMSContextRequest
{
  BIT8                                   messageType,
  EnhancedNetworkSeviveAccessPointIDV    requestedMBMS_NSAPI,
  LLC_SAPIV                              requestedLLCSAPI,
  MBMSBearerCapabilitiesLV               supportdMBMSBearerCapabilities,
  PDPAddressLV                           requestedMulticastAddress,
  AccessPointNameLV                      accessPointName,
  MBMSProtocolConfigOptionsTLV           mBMSprotocolConfigOptions optional,
  DevicePropertiesTV                     deviceProperties optional
} with { variant "PRESENCE (messageType = '01010110'B)";    
         variant "TAG(deviceProperties,  elementIdentifier = '1100'B;  //C
  )"        
};


// Activate MBMS Context Accept - 9.5.23
type record PDU_SM_ActivateMBMSContextAccept
{
  BIT8                                   messageType,
  TemporaryMobileGroupIDLV               temporaryMobileGroupIDLV,
  LLC_SAPIV                              negotiatedLLCSAPI,
  MBMSProtocolConfigOptionsTLV           mBMSprotocolConfigOptions optional
} with { variant "PRESENCE (messageType = '01010111'B)"; };


// Activate MBMS Context Reject - 9.5.24
type record PDU_SM_ActivateMBMSContextReject
{
  BIT8                                   messageType,
  SMCauseV                               smCause,
  MBMSProtocolConfigOptionsTLV           mBMSprotocolConfigOptions optional,
  GPRSTimer3TLV                          backOffTimer optional,
  ReAttemptIndicatorTLV                  reAttemptIndicator     optional
} with { variant "PRESENCE (messageType = '01011000'B)"; 
         variant "TAG (backOffTimer,  elementIdentifier = '37'O)"
};


// Request MBMS Context Activation - 9.5.25
type record PDU_SM_RequestMBMSContextActivation
{
  BIT8                                   messageType,
  NSAPIV                                 linkedNSAPI,
  PDPAddressLV                           offeredMulticastAddress,
  AccessPointNameLV                      accessPointName,
  MBMSProtocolConfigOptionsTLV           mBMSprotocolConfigOptions optional
} with { variant "PRESENCE (messageType = '01011001'B)"; };


// Request MBMS Context Activation Reject - 9.5.26
type record PDU_SM_RequestMBMSContextActivationReject
{
  BIT8                                   messageType,
  SMCauseV                               smCause,
  MBMSProtocolConfigOptionsTLV           mBMSprotocolConfigOptions optional
} with { variant "PRESENCE (messageType = '01011010'B)"; };


//==============================================================================
//==============================================================================
// GPRS SESSION MANAGEMENT MESSAGES Messages MS TO SGSN
//==============================================================================
//==============================================================================
type union L3_GSM_MS_SGSN
{
  PDU_SM_ActivatePDPContextRequest          activatePDPContextRequest,
  PDU_SM_ActivateSecondaryPDPContextRequest activateSecondaryPDPContextRequest,
  PDU_SM_RequestPDPContextActivationReject  requestPDPContextActivationReject,
  PDU_SM_ModifyPDPContextRequest_MS_SGSN    modifyPDPContextRequest_MS_SGSN,
  PDU_SM_ModifyPDPContextAccept_MS_SGSN     modifyPDPContextAccept_MS_SGSN,
  //SGSN_MS, MS_SGSN
  PDU_SM_DeactivatePDPContextRequest        deactivatePDPContextRequest,
  //SGSN_MS, MS_SGSN
  PDU_SM_DeactivatePDPContextAccept         deactivatePDPContextAccept,
  //SGSN_MS, MS_SGSN
  PDU_SM_SM_Status                          sM_Status,
  PDU_SM_ActivateMBMSContextRequest         activateMBMSContextRequest,
  PDU_SM_RequestMBMSContextActivationReject requestMBMSContextActivationReject,
  PDU_SM_RequestSecondaryPDPContextActivationReject  requestSecondaryPDPContextActivationReject,
  PDU_SM_Notification                       notification
};

//==============================================================================
//==============================================================================
// GPRS SESSION MANAGEMENT MESSAGES Messages SGSN -> MS
//==============================================================================
//==============================================================================
type union L3_GSM_SGSN_MS
{
  PDU_SM_ActivatePDPContextAccept           activatePDPContextAccept,
  PDU_SM_ActivatePDPContextReject           activatePDPContextReject,
  PDU_SM_ActivateSecondaryPDPContextAccept  activateSecondaryPDPContextAccept,
  PDU_SM_ActivateSecondaryPDPContextReject  activateSecondaryPDPContextReject,
  PDU_SM_RequestPDPContextActivation        requestPDPContextActivation,
  PDU_SM_ModifyPDPContextRequest_SGSN_MS    modifyPDPContextRequest_SGSN_MS,
  PDU_SM_ModifyPDPContextAccept_SGSN_MS     modifyPDPContextAccept_SGSN_MS,
  PDU_SM_ModifyPDPContextReject             modifyPDPContextReject,
  //SGSN_MS, MS_SGSN
  PDU_SM_DeactivatePDPContextRequest        deactivatePDPContextRequest,
  //SGSN_MS, MS_SGSN
  PDU_SM_DeactivatePDPContextAccept         deactivatePDPContextAccept,
  //SGSN_MS, MS_SGSN
  PDU_SM_SM_Status                          sM_Status,
  PDU_SM_ActivateMBMSContextAccept          activateMBMSContextAccept,
  PDU_SM_ActivateMBMSContextReject          activateMBMSContextReject,
  PDU_SM_RequestMBMSContextActivation       requestMBMSContextActivation,
  PDU_SM_RequestSecondaryPDPContextActivation  requestSecondaryPDPContextActivation
};

//==============================================================================
//==============================================================================
// GPRS Mobility Management Messages MS TO SGSN
//==============================================================================
//==============================================================================
type union L3_GMM_MS_SGSN
{
  PDU_GMM_AttachRequest                     attachRequest,
  PDU_GMM_AttachComplete                    attachComplete,
  PDU_GMM_DetachRequest_MS_SGSN             detachRequest_MS_SGSN,
  PDU_GMM_DetachAccept_MS_SGSN              detachAccept_MS_SGSN,
  PDU_GMM_P_TMSIReallocationComplete        p_TMSIReallocationComplete,
  PDU_GMM_AuthenticationAndCipheringResponse  authenticationAndCipheringResponse,
  PDU_GMM_AuthenticationAndCipheringFailure authenticationAndCipheringFailure,
  PDU_GMM_IdentityResponse                  identityResponse,
  PDU_GMM_RoutingAreaUpdateRequest          routingAreaUpdateRequest,
  PDU_GMM_RoutingAreaUpdateComplete         routingAreaUpdateComplete,
  //SGSN_MS, MS_SGSN
  PDU_GMM_GMM_Status                        gMM_Status,
  PDU_GMM_ServiceRequest                    serviceRequest
};

//==============================================================================
//==============================================================================
// GPRS Mobility Management Messages SGSN TO MS
//==============================================================================
//==============================================================================
type union L3_GMM_SGSN_MS
{
  PDU_GMM_AttachAccept                      attachAccept,
  PDU_GMM_AttachReject                      attachReject,
  PDU_GMM_DetachRequest_SGSN_MS             detachRequest_SGSN_MS,
  PDU_GMM_DetachAccept_SGSN_MS              detachAccept_SGSN_MS,
  PDU_GMM_P_TMSIReallocationCommand         p_TMSIReallocationCommand,
  PDU_GMM_AuthenticationAndCipheringRequest authenticationAndCipheringRequest,
  PDU_GMM_AuthenticationAndCipheringReject  authenticationAndCipheringReject,
  PDU_GMM_IdentityRequest                   identityRequest,
  PDU_GMM_RoutingAreaUpdateAccept           routingAreaUpdateAccept,
  PDU_GMM_RoutingAreaUpdateReject           routingAreaUpdateReject,
  //SGSN_MS, MS_SGSN
  PDU_GMM_GMM_Status                        gMM_Status,
  PDU_GMM_GMM_Information                   gMM_Information,
  PDU_GMM_ServiceAccept                     serviceAccept,
  PDU_GMM_ServiceReject                     serviceReject
};

}//end of module
with {
extension "version R2A"
encode "RAW"
} 

