/******************************************************************************
 * Copyright (c) 2000-2021 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
 *
 * Contributors:
 *   Balasko, Jeno
 *   Lovassy, Arpad
 *   Raduly, Csaba
 *
 ******************************************************************************/

module NAS_EPS_v970
{

import from General_Types all;


external function enc_PDU_NAS_EPS(in PDU_NAS_EPS pdu) return octetstring
with { extension "prototype(convert)" extension "encode(RAW)" }

external function dec_PDU_NAS_EPS(in octetstring stream) return PDU_NAS_EPS
with { extension "prototype(convert)" extension "decode(RAW)" }

type record ESM_CauseV
{
  OCT1    causeValue
}

// 8.2.32 PDU_NAS_EPS_Uplink_Generic_NAS_Transport
type record PDU_NAS_EPS_Uplink_Generic_NAS_Transport
{
  BIT4                                  securityHeaderType,
  BIT8                                  messageType,
  BIT8                                  generic_MessageContainerType
} with {
  variant "PRESENCE(securityHeaderType='0000'B)"
}

// 8.3.15 PDU_NAS_EPS_ESM_Status
type record PDU_NAS_EPS_ESM_Status
{
  BIT4                                ePSBearerIdentity,
  BIT8                                procedureTransactionIdentifier,
  BIT8                                messageType, 
  ESM_CauseV                          esmCause  
}

//see table 9.8.2/24.301:
type union EPS_SessionManagement
{ 
  PDU_NAS_EPS_ESM_Status                       pDU_NAS_EPS_ESM_Status  
} with {
  variant "TAG (    
  
  pDU_NAS_EPS_ESM_Status,                      messageType = '11101000'B;
  )"
} 

//see Table 9.8.1/24.301:
type union EPS_MobilityManagement
{ 
  PDU_NAS_EPS_Uplink_Generic_NAS_Transport		pDU_NAS_EPS_Uplink_Generic_NAS_Transport		//Table 9.8.1/23.301 v10.1.0
} with {
  variant "TAG (
  
  pDU_NAS_EPS_Uplink_Generic_NAS_Transport,		messageType = '01101001'B;
  )"
};


type union EPS_messages
{
  EPS_SessionManagement  ePS_SessionManagement,
  EPS_MobilityManagement ePS_MobilityManagement 
};

//see 11.2.3.1.1/24.007
type record PDU_NAS_EPS
{
  BIT4                 protocolDiscriminator,
  EPS_messages         ePS_messages
} with { variant (ePS_messages)"CROSSTAG(
                          ePS_SessionManagement,  protocolDiscriminator='0010'B;
                          ePS_MobilityManagement, protocolDiscriminator='0111'B;
                          )"
};

} with { encode "RAW"} // End of module
