Commit a0a3314a authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

First version for Paging procedures

parent b5fc3a28
...@@ -238,6 +238,19 @@ bool amf_app::get_pdu_sessions_context( ...@@ -238,6 +238,19 @@ bool amf_app::get_pdu_sessions_context(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_app::handle_itti_message( void amf_app::handle_itti_message(
itti_n1n2_message_transfer_request& itti_msg) { itti_n1n2_message_transfer_request& itti_msg) {
if (itti_msg.is_ppi_set) { // Paging procedure
std::shared_ptr<itti_paging> i =
std::make_shared<itti_paging>(TASK_AMF_APP, TASK_AMF_N2);
i.get()->amf_ue_ngap_id = amf_n1_inst->supi2amfId.at(itti_msg.supi);
i.get()->ran_ue_ngap_id = amf_n1_inst->supi2ranId.at(itti_msg.supi);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
} else {
// Encode DL NAS TRANSPORT message(NAS message) // Encode DL NAS TRANSPORT message(NAS message)
DLNASTransport* dl = new DLNASTransport(); DLNASTransport* dl = new DLNASTransport();
dl->setHeader(PLAIN_5GS_MSG); dl->setHeader(PLAIN_5GS_MSG);
...@@ -246,8 +259,8 @@ void amf_app::handle_itti_message( ...@@ -246,8 +259,8 @@ void amf_app::handle_itti_message(
(uint8_t*) bdata(itti_msg.n1sm), blength(itti_msg.n1sm)); (uint8_t*) bdata(itti_msg.n1sm), blength(itti_msg.n1sm));
dl->setPDUSessionId(itti_msg.pdu_session_id); dl->setPDUSessionId(itti_msg.pdu_session_id);
uint8_t nas[1024]; uint8_t nas[BUFFER_SIZE_1024];
int encoded_size = dl->encode2buffer(nas, 1024); int encoded_size = dl->encode2buffer(nas, BUFFER_SIZE_1024);
print_buffer("amf_app", "n1n2 transfer", nas, encoded_size); print_buffer("amf_app", "n1n2 transfer", nas, encoded_size);
bstring dl_nas = blk2bstr(nas, encoded_size); bstring dl_nas = blk2bstr(nas, encoded_size);
...@@ -272,6 +285,7 @@ void amf_app::handle_itti_message( ...@@ -272,6 +285,7 @@ void amf_app::handle_itti_message(
"Could not send ITTI message %s to task TASK_AMF_N1", "Could not send ITTI message %s to task TASK_AMF_N1",
i->get_msg_name()); i->get_msg_name());
} }
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -412,7 +412,7 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -412,7 +412,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc); set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false; nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED // change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED"; nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id; nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id; nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn; nc.get()->serving_network = snn;
...@@ -582,7 +582,7 @@ void amf_n1::identity_response_handle( ...@@ -582,7 +582,7 @@ void amf_n1::identity_response_handle(
nc.get()->ctx_avaliability_ind = false; nc.get()->ctx_avaliability_ind = false;
} }
nc.get()->ctx_avaliability_ind = true; nc.get()->ctx_avaliability_ind = true;
nc.get()->nas_status = "CM-CONNECTED"; nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id; nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id; nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->is_imsi_present = true; nc.get()->is_imsi_present = true;
...@@ -847,7 +847,7 @@ void amf_n1::registration_request_handle( ...@@ -847,7 +847,7 @@ void amf_n1::registration_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc); set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false; nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED // change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED"; nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id; nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id; nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn; nc.get()->serving_network = snn;
...@@ -925,7 +925,7 @@ void amf_n1::registration_request_handle( ...@@ -925,7 +925,7 @@ void amf_n1::registration_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc); set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false; nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED // change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED"; nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id; nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id; nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn; nc.get()->serving_network = snn;
......
...@@ -494,6 +494,7 @@ void amf_n11::handle_post_sm_context_response_error( ...@@ -494,6 +494,7 @@ void amf_n11::handle_post_sm_context_response_error(
itti_msg->is_n2sm_set = false; itti_msg->is_n2sm_set = false;
itti_msg->supi = supi; itti_msg->supi = supi;
itti_msg->pdu_session_id = pdu_session_id; itti_msg->pdu_session_id = pdu_session_id;
itti_msg->is_ppi_set = false;
std::shared_ptr<itti_n1n2_message_transfer_request> i = std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg); std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
...@@ -718,6 +719,8 @@ void amf_n11::curl_http_client( ...@@ -718,6 +719,8 @@ void amf_n11::curl_http_client(
itti_msg->is_n1sm_set = false; itti_msg->is_n1sm_set = false;
itti_msg->is_n2sm_set = false; itti_msg->is_n2sm_set = false;
itti_msg->is_ppi_set = false;
if (n1sm.size() > 0) { if (n1sm.size() > 0) {
msg_str_2_msg_hex(n1sm, n1sm_hex); msg_str_2_msg_hex(n1sm, n1sm_hex);
print_buffer( print_buffer(
......
...@@ -243,10 +243,7 @@ void amf_n2::handle_itti_message(itti_paging& itti_msg) { ...@@ -243,10 +243,7 @@ void amf_n2::handle_itti_message(itti_paging& itti_msg) {
itti_msg.amf_ue_ngap_id, unc.get()->amf_ue_ngap_id); itti_msg.amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
} }
if (unc.get()->ng_ue_state == NGAP_UE_CONNECTED) { // TODO: check UE reachability status
Logger::amf_n2().warn("Received NGAP PAGING while UE in CONNECTED MODE");
// return;
}
PagingMsg paging_msg = {}; PagingMsg paging_msg = {};
paging_msg.setMessageType(); paging_msg.setMessageType();
...@@ -746,7 +743,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) { ...@@ -746,7 +743,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
std::shared_ptr<ue_ngap_context> unc; std::shared_ptr<ue_ngap_context> unc = {};
unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id); unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get() == nullptr) { if (unc.get() == nullptr) {
Logger::amf_n2().error( Logger::amf_n2().error(
...@@ -754,7 +751,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -754,7 +751,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
return; return;
} }
unc.get()->ncc = 1; unc.get()->ncc = 1;
std::shared_ptr<gnb_context> gc; std::shared_ptr<gnb_context> gc = {};
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id); gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) { if (gc.get() == nullptr) {
Logger::amf_n2().error( Logger::amf_n2().error(
...@@ -866,8 +863,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -866,8 +863,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
} }
} }
uint8_t buffer[20000]; // TODO: remove hardcoded value uint8_t buffer[BUFFER_SIZE_2048];
int encoded_size = msg->encode2buffer(buffer, 10000); int encoded_size = msg->encode2buffer(buffer, BUFFER_SIZE_2048);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg( sctp_s_38412.sctp_send_msg(
gc.get()->sctp_assoc_id, unc.get()->sctp_stream_send, &b); gc.get()->sctp_assoc_id, unc.get()->sctp_stream_send, &b);
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this * the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the *file except in compliance with the License. You may obtain a copy of the
* License at *License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -19,11 +19,27 @@ ...@@ -19,11 +19,27 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file gNB_context.cpp #ifndef FILE_3GPP_29_518_SEEN
\brief #define FILE_3GPP_29_518_SEEN
\author Keliang DU, BUPT
\date 2020 #include <vector>
\email: contact@openairinterface.org
*/ enum n1_n2_message_transfer_cause_e {
ATTEMPTING_TO_REACH_UE = 1,
N1_N2_TRANSFER_INITIATED = 2,
WAITING_FOR_ASYNCHRONOUS_TRANSFER = 3,
UE_NOT_RESPONDING = 4,
N1_MSG_NOT_TRANSFERRED = 5,
UE_NOT_REACHABLE_FOR_SESSION = 6
};
static const std::vector<std::string> n1_n2_message_transfer_cause_e2str = {
"UNKNOWN ERROR",
"ATTEMPTING_TO_REACH_UE",
"N1_N2_TRANSFER_INITIATED",
"WAITING_FOR_ASYNCHRONOUS_TRANSFER",
"UE_NOT_RESPONDING",
"N1_MSG_NOT_TRANSFERRED",
"UE_NOT_REACHABLE_FOR_SESSION"};
#include "gNB_context.hpp" #endif
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#define __AMF_HPP #define __AMF_HPP
#include "3gpp_23.003.h" #include "3gpp_23.003.h"
#include "3gpp_29.518.h"
/* /*
typedef struct { typedef struct {
std::string mcc; std::string mcc;
......
...@@ -37,7 +37,6 @@ include_directories(${SRC_TOP_DIR}/utils) ...@@ -37,7 +37,6 @@ include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr) include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (CONTEXTS STATIC add_library (CONTEXTS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/gNB_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nas_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nas_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pdu_session_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/pdu_session_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ue_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ue_context.cpp
......
...@@ -45,10 +45,15 @@ extern "C" { ...@@ -45,10 +45,15 @@ extern "C" {
using namespace sctp; using namespace sctp;
using namespace ngap; using namespace ngap;
enum amf_ng_gnb_state_s { NGAP_INIT, NGAP_RESETING, NGAP_READY, NGAP_SHUTDOWN }; typedef enum {
NGAP_INIT,
NGAP_RESETING,
NGAP_READY,
NGAP_SHUTDOWN
} amf_ng_gnb_state_t;
class gnb_context { class gnb_context {
public: public:
enum amf_ng_gnb_state_s ng_state; amf_ng_gnb_state_t ng_state;
std::string gnb_name; std::string gnb_name;
long globalRanNodeId; long globalRanNodeId;
......
...@@ -56,6 +56,11 @@ static const std::vector<std::string> _5gmm_state_e2str = { ...@@ -56,6 +56,11 @@ static const std::vector<std::string> _5gmm_state_e2str = {
"_5GMM_COMMON_PROCEDURE_INITIATED", "_5GMM_COMMON_PROCEDURE_INITIATED",
"_5GMM_STATE_MAX"}; "_5GMM_STATE_MAX"};
typedef enum { CM_IDLE = 0, CM_CONNECTED } cm_state_t;
static const std::vector<std::string> cm_state_e2str = {"CM_IDLE",
"CM_CONNECTED"};
class nas_context { class nas_context {
public: public:
nas_context(); nas_context();
...@@ -64,7 +69,7 @@ class nas_context { ...@@ -64,7 +69,7 @@ class nas_context {
bool is_stacs_available; bool is_stacs_available;
long amf_ue_ngap_id; long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id; uint32_t ran_ue_ngap_id;
std::string nas_status; cm_state_t nas_status;
_5gmm_state_t _5gmm_state; _5gmm_state_t _5gmm_state;
// parameters from Registration request // parameters from Registration request
......
...@@ -86,9 +86,11 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app { ...@@ -86,9 +86,11 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
: itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination), : itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination),
supi(), supi(),
pdu_session_id(0), pdu_session_id(0),
n2sm_info_type() { n2sm_info_type(),
ppi(0) {
is_n2sm_set = false; is_n2sm_set = false;
is_n1sm_set = false; is_n1sm_set = false;
is_ppi_set = false;
} }
itti_n1n2_message_transfer_request( itti_n1n2_message_transfer_request(
const itti_n1n2_message_transfer_request& i) const itti_n1n2_message_transfer_request& i)
...@@ -100,6 +102,8 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app { ...@@ -100,6 +102,8 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
is_n1sm_set = i.is_n1sm_set; is_n1sm_set = i.is_n1sm_set;
pdu_session_id = i.pdu_session_id; pdu_session_id = i.pdu_session_id;
n2sm_info_type = i.n2sm_info_type; n2sm_info_type = i.n2sm_info_type;
ppi = i.ppi;
is_ppi_set = i.is_ppi_set;
} }
std::string supi; std::string supi;
...@@ -109,6 +113,8 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app { ...@@ -109,6 +113,8 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
bool is_n1sm_set; bool is_n1sm_set;
uint8_t pdu_session_id; uint8_t pdu_session_id;
std::string n2sm_info_type; std::string n2sm_info_type;
bool is_ppi_set;
uint8_t ppi;
// other parameters // other parameters
}; };
......
...@@ -72,7 +72,11 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer( ...@@ -72,7 +72,11 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Pistache::Http::ResponseWriter& response) { Pistache::Http::ResponseWriter& response) {
Logger::amf_server().debug( Logger::amf_server().debug(
"Receive N1N2MessageTransfer Request, handling..."); "Receive N1N2MessageTransfer Request, handling...");
response.send(Pistache::Http::Code::Ok, "OK");
nlohmann::json response_json = {};
response_json["cause"] =
n1_n2_message_transfer_cause_e2str[N1_N2_TRANSFER_INITIATED];
Pistache::Http::Code code = Pistache::Http::Code::Ok;
std::string supi = ueContextId; std::string supi = ueContextId;
Logger::amf_server().debug( Logger::amf_server().debug(
...@@ -108,6 +112,20 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer( ...@@ -108,6 +112,20 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
itti_msg->is_n2sm_set = true; itti_msg->is_n2sm_set = true;
itti_msg->pdu_session_id = itti_msg->pdu_session_id =
(uint8_t) n1N2MessageTransferReqData.getPduSessionId(); (uint8_t) n1N2MessageTransferReqData.getPduSessionId();
// For Paging
if (n1N2MessageTransferReqData.ppiIsSet()) {
itti_msg->is_ppi_set = true;
itti_msg->ppi = n1N2MessageTransferReqData.getPpi();
response_json["cause"] =
n1_n2_message_transfer_cause_e2str[ATTEMPTING_TO_REACH_UE];
code = Pistache::Http::Code::Accepted;
}
// Send response to the NF Service Consumer (e.g., SMF)
response.send(code, response_json.dump().c_str());
// Process N1N2 Message Transfer Request
std::shared_ptr<itti_n1n2_message_transfer_request> i = std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg); std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
......
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