/* Our own NG NAS Types on top of
 * deps/nas/ttcn/Lib3GPP/NG_NAS/NG_NAS_TypesDefs.ttcn, NG_NAS_MsgContainers.ttcn,
 * etc. */
module NG_NAS_Osmo_Types {

/* (C) 2025 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

import from CommonDefs all;
import from NAS_CommonTypeDefs all;
import from NAS_CommonTemplates all;
import from NG_NAS_Common all;
import from NG_NAS_TypeDefs all;
import from NG_NAS_Templates all;
import from NG_NAS_MsgContainers all;

import from General_Types all;

/* 3GPP TS 24.501 9.11.3.40 Payload container type */
const BIT4 c_PayloadContainer_N1_SM_Info := '0001'B;
const BIT4 c_PayloadContainer_SMS := '0010'B;
const BIT4 c_PayloadContainer_LPP_Msg_Container := '0011'B;
const BIT4 c_PayloadContainer_SOR_Transp_Container := '0100'B;
const BIT4 c_PayloadContainer_UE_Policy_Container := '0101'B;
const BIT4 c_PayloadContainer_UE_Pars_Upd_Transp_Container := '0110'B;
const BIT4 c_PayloadContainer_Loc_Services_Msg_Container := '0110'B;
const BIT4 c_PayloadContainer_CIoT_User_Data_Container := '0111'B;
const BIT4 c_PayloadContainer_Serv_Lvl_AA_Container := '1001'B;
const BIT4 c_PayloadContainer_Event_Notification := '1010'B;
const BIT4 c_PayloadContainer_UPP_CMI_Container := '1011'B;
const BIT4 c_PayloadContainer_SLPP_Message_Container := '1100'B;
const BIT4 c_PayloadContainer_Multiple_Payloads := '1111'B;

const NAS_CauseValue_Type c_5GSM_Cause_RegularDeactivation := '00100100'B;


/* This is a subset of the msgs in NG_NAS_DL_Message_Type. The subset is formed
 * by Session Management messages, see 3GPP TS 24.501 clause 6 and clause 8.3.
 * This is needed to properly decode 3GPP TS 24.501 9.11.3.39 Payload container,
 * whose content changes based on 9.11.3.40 Payload container type. Trying to decode
 * it through dec_NG_NAS_DL_Message_Type() may end up with unexpected union choice
 * due to circumstancial match in previous field securityHeaderType. */
type union NG_NAS_DL_SM_Message_Type { /* NAS message with direction 'network to UE' or 'both' */
	NG_PDU_SESSION_AUTHENTICATION_COMMAND                  pdu_Session_Authentication_Command,
	NG_PDU_SESSION_AUTHENTICATION_RESULT                   pdu_Session_Authentication_Result,
	NG_PDU_SESSION_ESTABLISHMENT_ACCEPT                    pdu_Session_Establishment_Accept,
	NG_PDU_SESSION_ESTABLISHMENT_REJECT                    pdu_Session_Establishment_Reject,
	NG_PDU_SESSION_MODIFICATION_COMMAND                    pdu_Session_Modification_Command,
	NG_PDU_SESSION_MODIFICATION_REJECT                     pdu_Session_Modification_Reject,
	NG_PDU_SESSION_RELEASE_COMMAND                         pdu_Session_Release_Command,
	NG_PDU_SESSION_RELEASE_REJECT                          pdu_Session_Release_Reject,
	NG_GSM_STATUS                                          gsm_Status
	} with {
	variant "TAG(
		pdu_Session_Authentication_Command,            messageType = '11000101'B;
		pdu_Session_Authentication_Result,             messageType = '11000111'B;
		pdu_Session_Establishment_Accept,              messageType = '11000010'B;
		pdu_Session_Establishment_Reject,              messageType = '11000011'B;
		pdu_Session_Modification_Command,              messageType = '11001011'B;
		pdu_Session_Modification_Reject,               messageType = '11001010'B;
		pdu_Session_Release_Command,                   messageType = '11010011'B;
		pdu_Session_Release_Reject,                    messageType = '11010010'B;
		gsm_Status,                                    messageType = '11010110'B;
	)"
};

} with { encode "RAW" }
