/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   (c) 2023, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_23wk37
// $Date: 2018-12-17 17:07:06 +0100 (Mon, 17 Dec 2018) $
// $Rev: 23499 $
/******************************************************************************/

module NG_NasEmu_CtrlAspTypes {
  import from CommonDefs all;
  import from NasEmu_Common4G5G all;

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

  //----------------------------------------------------------------------------
  /* Primitive for Configuration and Control of NAS Security */
  // Note:
  // In the primitives only the COUNT is handled (rather than SQN and NasOverflowCounter);
  // to deal with SQN and NasOverflowCounter there are common TTCN functions:
  //   function f_EutranNasCount_GetSQN(NasCount_Type p_Count) return integer;
  //   function f_EutranPdcpCount_GetOverflowCounter(NasCount_Type) return integer;
  //   function f_EutranPdcpCount_Set(integer p_OverflowCounter, integer p_SQN) return NasCount_Type;

  type record NG_NAS_SecurityInfo_Type {                           /* ciphering/integrity algorithm and key */
    B4_Type                    Algorithm,                       /* acc. to 24.501 cl. 9.10.3.32 NAS security algorithms */
    B128_Key_Type              K_NAS                            /* key acc. 33.501 Figure 6.2-2 (K_NASint, K_NASenc) */
  };

  type record NG_NAS_SecurityStartRestart_Type {
    NG_NAS_SecurityInfo_Type     Integrity     optional,           /* omit: keep integrity protection as it is */
    NG_NAS_SecurityInfo_Type     Ciphering     optional,           /* omit: keep ciphering as it is */
    Null_Type                    NasCountReset optional            /* omit: maintain NAS COUNT */
  };

  type union NG_NAS_Security_Type {                                /* to download or reset NAS security algorithms and keys and to reset NAS COUNT;
                                                                   in DL security protection is applied acc. to the SecurityProtection info of
                                                                   the NAS_MSG_Request_Type;
                                                                   in the UL if a security protected NAS PDU is received it is assumed to be ciphered
                                                                   (this is because the SECURITY MODE COMMAND is already ciphered for NAS);
                                                                   (Note: if the latter assumption is not applicable, ciphering needs to be started explicitly);
                                                                   the NAS emulation shall distinguish between security protected and non-security protected NAS PDUs */
    NG_NAS_SecurityStartRestart_Type       StartRestart,
    Null_Type                           Release
  };

  type union NG_NasCtrlRequest_Type {
    NG_NAS_Security_Type         Security,                         /* StartRestart/Release of NAS security */
    NAS_CountReq_Type            NasCount                          /* to set or enquire NAS COUNT */
  };

  type record NG_NAS_CTRL_REQ {
    NasCtrlReqAspCommonPart_Type        Common,
    NG_NasCtrlRequest_Type              Request
  };

  type record NG_NAS_CTRL_CNF {
    NasCtrlCnfAspCommonPart_Type        Common,
    NasCtrlConfirm_Type                 Confirm
  };

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

  group Port_Definitions {

  type port NG_NASCTRL_PORT message {     /* EUTRA/NR PTC: Port for configuration of NAS emulation */
    out NG_NAS_CTRL_REQ;
    in  NG_NAS_CTRL_CNF;
  };

  type port NG_NASEMU_CTRL_PORT message {          /* NASEMU PTC: Port for configuration of NAS emulation */
    out NG_NAS_CTRL_CNF;
    in  NG_NAS_CTRL_REQ;
  };

  } // End group Port_Definitions

}
