Commit 747640d2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Reroute NAS to the target AMF via AN tunnel

parent 6be0c2f9
...@@ -4340,5 +4340,19 @@ bool amf_n1::reroute_nas_via_an( ...@@ -4340,5 +4340,19 @@ bool amf_n1::reroute_nas_via_an(
Logger::amf_n1().debug( Logger::amf_n1().debug(
"Send a request to Reroute NAS message to the target AMF via AN"); "Send a request to Reroute NAS message to the target AMF via AN");
std::shared_ptr<itti_rereoute_nas> itti_msg =
std::make_shared<itti_rereoute_nas>(TASK_AMF_N1, TASK_AMF_N2);
itti_msg->ran_ue_ngap_id = nc->ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = nc->amf_ue_ngap_id;
itti_msg->amf_set_id = target_amf_set;
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
itti_msg->get_msg_name());
}
return true; return true;
} }
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "UEContextReleaseCommand.hpp" #include "UEContextReleaseCommand.hpp"
#include "HandoverPreparationFailure.hpp" #include "HandoverPreparationFailure.hpp"
#include "Paging.hpp" #include "Paging.hpp"
#include "RerouteNASRequest.hpp"
#include "amf_app.hpp" #include "amf_app.hpp"
#include "amf_config.hpp" #include "amf_config.hpp"
#include "amf_n1.hpp" #include "amf_n1.hpp"
...@@ -211,6 +212,11 @@ void amf_n2_task(void* args_p) { ...@@ -211,6 +212,11 @@ void amf_n2_task(void* args_p) {
itti_paging* m = dynamic_cast<itti_paging*>(msg); itti_paging* m = dynamic_cast<itti_paging*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); amf_n2_inst->handle_itti_message(ref(*m));
} break; } break;
case REROUTE_NAS_REQ: {
Logger::amf_n2().info("Received Reroute NAS Req message, handling");
itti_rereoute_nas* m = dynamic_cast<itti_rereoute_nas*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
} break;
case TERMINATE: { case TERMINATE: {
if (itti_msg_terminate* terminate = if (itti_msg_terminate* terminate =
dynamic_cast<itti_msg_terminate*>(msg)) { dynamic_cast<itti_msg_terminate*>(msg)) {
...@@ -676,6 +682,10 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) { ...@@ -676,6 +682,10 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
} }
} }
// Store InitialUEMessage for Rereoute NAS later
unc.get()->initialUEMsg.size = init_ue_msg.initUeMsg->encode2buffer(
unc.get()->initialUEMsg.buf, BUFFER_SIZE_1024);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = -1; itti_msg->amf_ue_ngap_id = -1;
std::shared_ptr<itti_nas_signalling_establishment_request> i = std::shared_ptr<itti_nas_signalling_establishment_request> i =
...@@ -2020,6 +2030,43 @@ void amf_n2::handle_itti_message(itti_uplink_ran_status_transfer& itti_msg) { ...@@ -2020,6 +2030,43 @@ void amf_n2::handle_itti_message(itti_uplink_ran_status_transfer& itti_msg) {
sctp_s_38412.sctp_send_msg(unc.get()->target_gnb_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(unc.get()->target_gnb_assoc_id, 0, &b);
} }
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_rereoute_nas& itti_msg) {
Logger::amf_n2().debug("Handle Reroute NAS Request message...");
std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id)) {
Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (%d)", itti_msg.ran_ue_ngap_id);
return;
}
unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != itti_msg.amf_ue_ngap_id) {
Logger::amf_n2().error(
"The requested UE (amf_ue_ngap_id: 0x%x) is not valid, existed UE "
"which's amf_ue_ngap_id (0x%x)",
itti_msg.amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
}
RerouteNASRequest rerouteNASRequest = {};
rerouteNASRequest.setMessageType();
rerouteNASRequest.setRanUeNgapId(itti_msg.ran_ue_ngap_id);
rerouteNASRequest.setAmfUeNgapId(itti_msg.amf_ue_ngap_id);
rerouteNASRequest.setAMFSetID(itti_msg.amf_set_id);
rerouteNASRequest.setNgapMessage(
unc->initialUEMsg); // Include InitialUEMessage
// TODO: AllowedNSSAI (Optional)
uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = rerouteNASRequest.encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
amf_n2_inst->sctp_s_38412.sctp_send_msg(
unc.get()->gnb_assoc_id, unc.get()->sctp_stream_send, &b);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::send_handover_preparation_failure( void amf_n2::send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id, const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
......
...@@ -62,6 +62,7 @@ class amf_n2 : public ngap::ngap_app { ...@@ -62,6 +62,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_handover_request_Ack& itti_msg); void handle_itti_message(itti_handover_request_Ack& itti_msg);
void handle_itti_message(itti_handover_notify& itti_msg); void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplink_ran_status_transfer& itti_msg); void handle_itti_message(itti_uplink_ran_status_transfer& itti_msg);
void handle_itti_message(itti_rereoute_nas& itti_msg);
void send_handover_preparation_failure( void send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id, const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id); const sctp_assoc_id_t& gnb_assoc_id);
......
...@@ -68,6 +68,8 @@ class ue_ngap_context { ...@@ -68,6 +68,8 @@ class ue_ngap_context {
// state management, ue status over the air // state management, ue status over the air
ng_ue_state_t ng_ue_state; ng_ue_state_t ng_ue_state;
uint8_t ncc; // Next Hop Chaining Counter uint8_t ncc; // Next Hop Chaining Counter
OCTET_STRING_t initialUEMsg;
}; };
#endif #endif
...@@ -79,6 +79,7 @@ typedef enum { ...@@ -79,6 +79,7 @@ typedef enum {
DOWNLINK_NAS_TRANSFER, DOWNLINK_NAS_TRANSFER,
NAS_SIG_ESTAB_REQ, // task amf_app NAS_SIG_ESTAB_REQ, // task amf_app
N1N2_MESSAGE_TRANSFER_REQ, N1N2_MESSAGE_TRANSFER_REQ,
REROUTE_NAS_REQ,
NSMF_PDU_SESSION_CREATE_SM_CTX, NSMF_PDU_SESSION_CREATE_SM_CTX,
NSMF_PDU_SESSION_UPDATE_SM_CTX, NSMF_PDU_SESSION_UPDATE_SM_CTX,
N11_REGISTER_NF_INSTANCE_REQUEST, N11_REGISTER_NF_INSTANCE_REQUEST,
......
...@@ -297,4 +297,15 @@ class itti_uplink_ran_status_transfer : public itti_msg_n2 { ...@@ -297,4 +297,15 @@ class itti_uplink_ran_status_transfer : public itti_msg_n2 {
UplinkRANStatusTransfer* uplinkrantransfer; UplinkRANStatusTransfer* uplinkrantransfer;
}; };
class itti_rereoute_nas : public itti_msg_n2 {
public:
itti_rereoute_nas(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(REROUTE_NAS_REQ, origin, destination) {}
itti_rereoute_nas(const itti_rereoute_nas& i) : itti_msg_n2(i) {}
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
std::string amf_set_id;
};
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment