lte/gateway/c/core/oai/tasks/amf/amf_smf_send.cpp
/****************************************************************************
 **                                                                        **
 ** Name        :  construct_pdu_session_reject_dl_req()                   **
 **                                                                        **
 ** Description :  Construct Session Establishment Reject Struct           **
 **                                                                        **
 ** Inputs      :  sequence_number     : seq to construct Secure msgs      **
 **                session_id          : PDU Session Identity              **
 **                pti                 : Procedure transaction identity    **
 **                is_security_enabled : indcates to construct plain msg   **
 **                                      secure msg                        **
 **                msg                 : out parameter Session             **
 **                                      Establishment Reject              **
 **                                                                        **
 **  Return     :  len                 : buffer required for               **
 **                                      DLNASTransportMsg                 **
 **                                                                        **
 ***************************************************************************/


Description :  Construct Session Establishment Reject Struct



Return     :  len                 : buffer required for
DLNASTransportMsg
Description : Construct Session Establishment Reject Struct Return : len : buffer required for DLNASTransportMsg
int construct_pdu_session_reject_dl_req(
    uint8_t sequence_number, uint8_t session_id, uint8_t pti, uint8_t cause,
    bool is_security_enabled, amf_nas_message_t* msg) {
  uint32_t len             = 0;
  uint32_t container_len   = 0;
  DLNASTransportMsg* dlmsg = nullptr;
  if (nullptr == msg) {
    return 0;
  }
  if (is_security_enabled) {
    msg->security_protected.plain.amf.header.extended_protocol_discriminator =
        M5G_MOBILITY_MANAGEMENT_MESSAGES;
    msg->security_protected.plain.amf.header.message_type = DLNASTRANSPORT;
    msg->header.security_header_type =
        SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
    dlmsg = &msg->security_protected.plain.amf.msg.downlinknas5gtransport;
  } else {
    msg->plain.amf.header.extended_protocol_discriminator =
        M5G_MOBILITY_MANAGEMENT_MESSAGES;
    msg->plain.amf.header.message_type = DLNASTRANSPORT;
    msg->header.security_header_type   = SECURITY_HEADER_TYPE_NOT_PROTECTED;
    dlmsg = &msg->plain.amf.msg.downlinknas5gtransport;
  }
  msg->header.extended_protocol_discriminator =
      M5G_MOBILITY_MANAGEMENT_MESSAGES;
  msg->header.sequence_number = sequence_number;
  dlmsg->extended_protocol_discriminator.extended_proto_discriminator =
      M5G_MOBILITY_MANAGEMENT_MESSAGES;
  len++;
  dlmsg->spare_half_octet.spare  = 0x00;
  dlmsg->sec_header_type.sec_hdr = SECURITY_HEADER_TYPE_NOT_PROTECTED;
  len++;
  dlmsg->message_type.msg_type = DLNASTRANSPORT;
  len++;
  dlmsg->payload_container.iei = PAYLOAD_CONTAINER;
  dlmsg->payload_container_type.iei      = 0;
  dlmsg->payload_container_type.type_val = N1_SM_INFO;
  len++;
  dlmsg->pdu_session_identity.iei =
      static_cast<uint8_t>(M5GIei::PDU_SESSION_IDENTITY_2);
  len++;
  dlmsg->pdu_session_identity.pdu_session_id = session_id;
  len++;
  SmfMsg& pdu_sess_est_reject = dlmsg->payload_container.smf_msg;
  pdu_sess_est_reject.header.extended_protocol_discriminator =
      M5G_SESSION_MANAGEMENT_MESSAGES;
  pdu_sess_est_reject.header.pdu_session_id = session_id;
  pdu_sess_est_reject.header.message_type   = PDU_SESSION_ESTABLISHMENT_REJECT;
  pdu_sess_est_reject.header.procedure_transaction_id = pti;
  pdu_sess_est_reject.msg.pdu_session_estab_reject
      .extended_protocol_discriminator.extended_proto_discriminator =
      M5G_SESSION_MANAGEMENT_MESSAGES;
  container_len++;
  pdu_sess_est_reject.msg.pdu_session_estab_reject.pdu_session_identity
      .pdu_session_id = session_id;
  container_len++;
  pdu_sess_est_reject.msg.pdu_session_estab_reject.pti.pti = pti;
  container_len++;
  pdu_sess_est_reject.msg.pdu_session_estab_reject.message_type.msg_type =
      PDU_SESSION_ESTABLISHMENT_REJECT;
  container_len++;
  pdu_sess_est_reject.msg.pdu_session_estab_reject.m5gsm_cause.cause_value =
      cause;
  container_len++;
  dlmsg->payload_container.len = container_len;
  len += PAYLOAD_CONTAINER_TAG_LENGTH;
  len += dlmsg->payload_container.len;
  AMF_GET_BYTE_ALIGNED_LENGTH(len);
  if (SECURITY_HEADER_TYPE_NOT_PROTECTED != msg->header.security_header_type) {
    amf_msg_header* header = &msg->security_protected.plain.amf.header;
    len += NAS_MESSAGE_SECURITY_HEADER_SIZE;
    header->extended_protocol_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES;
    header->security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED;
  }
  return len;
}
int construct_pdu_session_reject_dl_req ( uint8_t sequence_number , uint8_t session_id , uint8_t pti , uint8_t cause , bool is_security_enabled , amf_nas_message_t * msg ) { uint32_t len = 0 ; uint32_t container_len = 0 ; DLNASTransportMsg * dlmsg = nullptr ; if ( nullptr == msg ) { return 0 ; } if ( is_security_enabled ) { msg -> security_protected . plain . amf . header . extended_protocol_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES ; msg -> security_protected . plain . amf . header . message_type = DLNASTRANSPORT ; msg -> header . security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED ; dlmsg = & msg -> security_protected . plain . amf . msg . downlinknas5gtransport ; } else { msg -> plain . amf . header . extended_protocol_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES ; msg -> plain . amf . header . message_type = DLNASTRANSPORT ; msg -> header . security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED ; dlmsg = & msg -> plain . amf . msg . downlinknas5gtransport ; } msg -> header . extended_protocol_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES ; msg -> header . sequence_number = sequence_number ; dlmsg -> extended_protocol_discriminator . extended_proto_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES ; len ++ ; dlmsg -> spare_half_octet . spare = 0x00 ; dlmsg -> sec_header_type . sec_hdr = SECURITY_HEADER_TYPE_NOT_PROTECTED ; len ++ ; dlmsg -> message_type . msg_type = DLNASTRANSPORT ; len ++ ; dlmsg -> payload_container . iei = PAYLOAD_CONTAINER ; dlmsg -> payload_container_type . iei = 0 ; dlmsg -> payload_container_type . type_val = N1_SM_INFO ; len ++ ; dlmsg -> pdu_session_identity . iei = static_cast < uint8_t > ( M5GIei :: PDU_SESSION_IDENTITY_2 ) ; len ++ ; dlmsg -> pdu_session_identity . pdu_session_id = session_id ; len ++ ; SmfMsg & pdu_sess_est_reject = dlmsg -> payload_container . smf_msg ; pdu_sess_est_reject . header . extended_protocol_discriminator = M5G_SESSION_MANAGEMENT_MESSAGES ; pdu_sess_est_reject . header . pdu_session_id = session_id ; pdu_sess_est_reject . header . message_type = PDU_SESSION_ESTABLISHMENT_REJECT ; pdu_sess_est_reject . header . procedure_transaction_id = pti ; pdu_sess_est_reject . msg . pdu_session_estab_reject . extended_protocol_discriminator . extended_proto_discriminator = M5G_SESSION_MANAGEMENT_MESSAGES ; container_len ++ ; pdu_sess_est_reject . msg . pdu_session_estab_reject . pdu_session_identity . pdu_session_id = session_id ; container_len ++ ; pdu_sess_est_reject . msg . pdu_session_estab_reject . pti . pti = pti ; container_len ++ ; pdu_sess_est_reject . msg . pdu_session_estab_reject . message_type . msg_type = PDU_SESSION_ESTABLISHMENT_REJECT ; container_len ++ ; pdu_sess_est_reject . msg . pdu_session_estab_reject . m5gsm_cause . cause_value = cause ; container_len ++ ; dlmsg -> payload_container . len = container_len ; len += PAYLOAD_CONTAINER_TAG_LENGTH ; len += dlmsg -> payload_container . len ; AMF_GET_BYTE_ALIGNED_LENGTH ( len ) ; if ( SECURITY_HEADER_TYPE_NOT_PROTECTED != msg -> header . security_header_type ) { amf_msg_header * header = & msg -> security_protected . plain . amf . header ; len += NAS_MESSAGE_SECURITY_HEADER_SIZE ; header -> extended_protocol_discriminator = M5G_MOBILITY_MANAGEMENT_MESSAGES ; header -> security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED ; } return len ; }
Name        :  construct_pdu_session_reject_dl_req()
Name : construct_pdu_session_reject_dl_req ()
// Message construction for PDU Establishment Reject // NAS-5GS (NAS) PDU // AmfHeader // SmfMsg // header // Smf NAS message /* Ciphering algorithms, EEA1 and EEA2 expects length to be mode of 4,
   * so length is modified such that it will be mode of 4
   */ /*
     * Expand size of protected NAS message
     */ /*
     * Set header of plain NAS message
     */