Commit fe34f952 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup

parent 7f73cb97
...@@ -408,7 +408,11 @@ typedef struct dnn_upf_info_item_s { ...@@ -408,7 +408,11 @@ typedef struct dnn_upf_info_item_s {
s.append("DNAI NW Instance list: {"); s.append("DNAI NW Instance list: {");
for (const auto& dnai_nw : dnai_nw_instance_list) { for (const auto& dnai_nw : dnai_nw_instance_list) {
s.append("(").append(dnai_nw.first).append(", ").append(dnai_nw.second).append("),"); s.append("(")
.append(dnai_nw.first)
.append(", ")
.append(dnai_nw.second)
.append("),");
} }
s.append("}, "); s.append("}, ");
} }
......
...@@ -5008,8 +5008,9 @@ void smf_context::send_pdu_session_update_response( ...@@ -5008,8 +5008,9 @@ void smf_context::send_pdu_session_update_response(
const std::shared_ptr<itti_n11_update_sm_context_response>& resp, const std::shared_ptr<itti_n11_update_sm_context_response>& resp,
const session_management_procedures_type_e& session_procedure_type, const session_management_procedures_type_e& session_procedure_type,
const std::shared_ptr<smf_pdu_session>& sps) { const std::shared_ptr<smf_pdu_session>& sps) {
std::string n1_sm_msg, n1_sm_msg_hex; std::string n1_sm_msg = {};
std::string n2_sm_info, n2_sm_info_hex; std::string n1_sm_msg_hex = {};
std::string n2_sm_info = {} std::string n2_sm_info_hex = {};
// TODO: check we got all responses vs // TODO: check we got all responses vs
// resp->res.flow_context_modified // resp->res.flow_context_modified
...@@ -5110,99 +5111,6 @@ void smf_context::send_pdu_session_update_response( ...@@ -5110,99 +5111,6 @@ void smf_context::send_pdu_session_update_response(
"PDU Session Modification UE-initiated (Step 3)"); "PDU Session Modification UE-initiated (Step 3)");
// TODO: To be completed // TODO: To be completed
} break; } break;
/*
// PDU Session Release UE-initiated (Step 1)
case session_management_procedures_type_e::
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1: {
// N1 SM: PDU Session Release Command​
// N2 SM: PDU Session Resource Release Command Transfer
Logger::smf_app().info("PDU Session Release UE-initiated (Step
1))");
// N1 SM
smf_n1::get_instance().create_n1_pdu_session_release_command(
resp->res, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); //
TODO:
//
check
// Cause
conv::convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
resp->res.set_n1_sm_message(n1_sm_msg_hex);
// include N2 SM Resource Release Request only when User Plane
// connection is activated
if (sps->get_upCnx_state() ==
upCnx_state_e::UPCNX_STATE_ACTIVATED) {
// N2 SM Information
smf_n2::get_instance()
.create_n2_pdu_session_resource_release_command_transfer(
resp->res, n2_sm_info_type_e::PDU_RES_REL_CMD,
n2_sm_info); conv::convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
resp->res.set_n2_sm_information(n2_sm_info_hex);
// Prepare response to send to AMF (N1N2MessageTransfer or
// PDUSession_UpdateSMContextResponse)
nlohmann::json sm_context_updated_data = {};
sm_context_updated_data["n1MessageContainer"]["n1MessageClass"]
= N1N2_MESSAGE_CLASS;
sm_context_updated_data["n1MessageContainer"]["n1MessageContent"]
["contentId"] = N1_SM_CONTENT_ID;
sm_context_updated_data["n2InfoContainer"]["n2InformationClass"]
= N1N2_MESSAGE_CLASS;
sm_context_updated_data["n2InfoContainer"]["smInfo"]["PduSessionId"]
= resp->res.get_pdu_session_id();
sm_context_updated_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]
["ngapData"]["contentId"] =
N2_SM_CONTENT_ID; sm_context_updated_data["n2SmInfoType"] =
//["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"]
= "PDU_RES_REL_CMD"; // NGAP message
resp->res.set_json_data(sm_context_updated_data);
} else {
// fill the content of SmContextUpdatedData
nlohmann::json json_data = {};
json_data["n1MessageContainer"]["n1MessageClass"] =
N1N2_MESSAGE_CLASS;
json_data["n1MessageContainer"]["n1MessageContent"]["contentId"]
= N1_SM_CONTENT_ID; resp->res.set_json_data(json_data);
}
// Update PDU session status to PDU_SESSION_INACTIVE_PENDING
sps->set_pdu_session_status(
pdu_session_status_e::PDU_SESSION_INACTIVE_PENDING);
// set UpCnxState to DEACTIVATED
sps->set_upCnx_state(upCnx_state_e::UPCNX_STATE_DEACTIVATED);
// TODO: To be completed
// TODO: start timer T3592 (see Section 6.3.3@3GPP TS 24.501)
// get smf_pdu_session and set the corresponding timer
scid_t scid = {};
try {
scid = (scid_t) std::stoul(req->scid, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_n1().warn(
"Error when converting from string to int for SCID, "
"error: %s",
e.what());
// TODO Stefan: I could not find a better response code here
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE, resp->pid);
return;
}
// Store the context for the timer handling
sps.get()->set_pending_n11_msg(
std::dynamic_pointer_cast<itti_n11_msg>(resp));
sps->timer_T3592 = itti_inst->timer_setup(
T3592_TIMER_VALUE_SEC, 0, TASK_SMF_APP,
TASK_SMF_APP_TRIGGER_T3592, scid);
} break;
*/
case session_management_procedures_type_e::HO_PATH_SWITCH_REQ: { case session_management_procedures_type_e::HO_PATH_SWITCH_REQ: {
// Create N2 SM Information: Path Switch Request Acknowledge Transfer IE // Create N2 SM Information: Path Switch Request Acknowledge Transfer IE
......
...@@ -374,6 +374,7 @@ pfcp::create_urr smf_session_procedure::pfcp_create_urr( ...@@ -374,6 +374,7 @@ pfcp::create_urr smf_session_procedure::pfcp_create_urr(
return create_urr; return create_urr;
} }
//------------------------------------------------------------------------------
smf_procedure_code smf_session_procedure::get_current_upf( smf_procedure_code smf_session_procedure::get_current_upf(
std::vector<edge>& dl_edges, std::vector<edge>& ul_edges, std::vector<edge>& dl_edges, std::vector<edge>& ul_edges,
std::shared_ptr<pfcp_association>& current_upf) { std::shared_ptr<pfcp_association>& current_upf) {
...@@ -392,6 +393,7 @@ smf_procedure_code smf_session_procedure::get_current_upf( ...@@ -392,6 +393,7 @@ smf_procedure_code smf_session_procedure::get_current_upf(
return smf_procedure_code::OK; return smf_procedure_code::OK;
} }
//------------------------------------------------------------------------------
smf_procedure_code smf_session_procedure::get_next_upf( smf_procedure_code smf_session_procedure::get_next_upf(
std::vector<edge>& dl_edges, std::vector<edge>& ul_edges, std::vector<edge>& dl_edges, std::vector<edge>& ul_edges,
std::shared_ptr<pfcp_association>& next_upf) { std::shared_ptr<pfcp_association>& next_upf) {
...@@ -452,6 +454,7 @@ int n4_session_restore_procedure::run() { ...@@ -452,6 +454,7 @@ int n4_session_restore_procedure::run() {
return RETURNok; return RETURNok;
} }
//------------------------------------------------------------------------------
smf_procedure_code smf_procedure_code
session_create_sm_context_procedure::send_n4_session_establishment_request() { session_create_sm_context_procedure::send_n4_session_establishment_request() {
std::shared_ptr<pfcp_association> current_upf; std::shared_ptr<pfcp_association> current_upf;
...@@ -552,10 +555,10 @@ smf_procedure_code session_create_sm_context_procedure::run( ...@@ -552,10 +555,10 @@ smf_procedure_code session_create_sm_context_procedure::run(
std::shared_ptr<smf::smf_context> sc) { std::shared_ptr<smf::smf_context> sc) {
Logger::smf_app().info("Perform a procedure - Create SM Context Request"); Logger::smf_app().info("Perform a procedure - Create SM Context Request");
// TODO check if compatible with ongoing procedures if any // TODO check if compatible with ongoing procedures if any
snssai_t snssai = sm_context_req->req.get_snssai(); snssai_t snssai = sm_context_req->req.get_snssai();
std::string dnn = sm_context_req->req.get_dnn(); std::string dnn = sm_context_req->req.get_dnn();
pdu_session_id_t pdu_session_id = sm_context_req->req.get_pdu_session_id(); pdu_session_id_t pdu_session_id = sm_context_req->req.get_pdu_session_id();
std::shared_ptr<upf_graph> graph; std::shared_ptr<upf_graph> graph = {};
// Find PDU session // Find PDU session
std::shared_ptr<smf_context_ref> scf = {}; std::shared_ptr<smf_context_ref> scf = {};
...@@ -639,7 +642,7 @@ smf_procedure_code session_create_sm_context_procedure::run( ...@@ -639,7 +642,7 @@ smf_procedure_code session_create_sm_context_procedure::run(
std::vector<edge> dl_edges; std::vector<edge> dl_edges;
std::vector<edge> ul_edges; std::vector<edge> ul_edges;
std::shared_ptr<pfcp_association> upf; std::shared_ptr<pfcp_association> upf = {};
// Get next UPF for the first N4 session establishment // Get next UPF for the first N4 session establishment
get_next_upf(dl_edges, ul_edges, upf); get_next_upf(dl_edges, ul_edges, upf);
...@@ -668,7 +671,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg( ...@@ -668,7 +671,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg(
return smf_procedure_code::ERROR; return smf_procedure_code::ERROR;
} }
std::shared_ptr<pfcp_association> current_upf; std::shared_ptr<pfcp_association> current_upf = {};
std::vector<edge> dl_edges; std::vector<edge> dl_edges;
std::vector<edge> ul_edges; std::vector<edge> ul_edges;
if (get_current_upf(dl_edges, ul_edges, current_upf) != if (get_current_upf(dl_edges, ul_edges, current_upf) !=
...@@ -714,7 +717,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg( ...@@ -714,7 +717,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg(
while (search_upf) { while (search_upf) {
std::vector<edge> next_dl_edges; std::vector<edge> next_dl_edges;
std::vector<edge> next_ul_edges; std::vector<edge> next_ul_edges;
std::shared_ptr<pfcp_association> next_upf; std::shared_ptr<pfcp_association> next_upf = {};
send_n4_res = get_next_upf(next_dl_edges, next_ul_edges, next_upf); send_n4_res = get_next_upf(next_dl_edges, next_ul_edges, next_upf);
if (send_n4_res != smf_procedure_code::CONTINUE) { if (send_n4_res != smf_procedure_code::CONTINUE) {
search_upf = false; search_upf = false;
...@@ -786,7 +789,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg( ...@@ -786,7 +789,7 @@ smf_procedure_code session_create_sm_context_procedure::handle_itti_msg(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
smf_procedure_code smf_procedure_code
session_update_sm_context_procedure::send_n4_session_modification_request() { session_update_sm_context_procedure::send_n4_session_modification_request() {
std::shared_ptr<pfcp_association> current_upf{}; std::shared_ptr<pfcp_association> current_upf = {};
std::vector<edge> dl_edges{}; std::vector<edge> dl_edges{};
std::vector<edge> ul_edges{}; std::vector<edge> ul_edges{};
...@@ -890,7 +893,7 @@ smf_procedure_code session_update_sm_context_procedure::run( ...@@ -890,7 +893,7 @@ smf_procedure_code session_update_sm_context_procedure::run(
smf_qos_flow empty_flow{}; smf_qos_flow empty_flow{};
graph->start_asynch_dfs_procedure(false, empty_flow); graph->start_asynch_dfs_procedure(false, empty_flow);
std::shared_ptr<pfcp_association> current_upf; std::shared_ptr<pfcp_association> current_upf = {};
std::vector<edge> dl_edges; std::vector<edge> dl_edges;
std::vector<edge> ul_edges; std::vector<edge> ul_edges;
...@@ -1138,75 +1141,7 @@ smf_procedure_code session_update_sm_context_procedure::run( ...@@ -1138,75 +1141,7 @@ smf_procedure_code session_update_sm_context_procedure::run(
n11_triggered_pending->res.add_qos_flow_context_updated(qcu); n11_triggered_pending->res.add_qos_flow_context_updated(qcu);
} }
} break; } break;
/*
case session_management_procedures_type_e::
PDU_SESSION_RELEASE_AMF_INITIATED:
case session_management_procedures_type_e::
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1: {
for (const auto& qfi : list_of_qfis_to_be_modified) {
auto flow = dl_edges[0].get_qos_flow(qfi);
if (!flow) { // no QoS flow found
Logger::smf_app().error(
"Update SM Context procedure: could not found QoS flow with
QFI "
"%d",
qfi.qfi);
// Set cause to SYSTEM_FAILURE and send response
qos_flow_context_updated qcu = {};
qcu.set_cause(static_cast<uint8_t>(
cause_value_5gsm_e::CAUSE_31_REQUEST_REJECTED_UNSPECIFIED));
qcu.set_qfi(qfi);
n11_triggered_pending->res.add_qos_flow_context_updated(qcu);
continue;
}
// for DL
if (flow->far_id_dl.first) {
pfcp::update_far far = {};
pfcp::far_id_t far_id = {};
far_id.far_id = flow->far_id_dl.second.far_id;
// apply_action.buff = 1;
pfcp::apply_action_t apply_action = {};
apply_action.nocp = 1; // notify the CP function about the
arrival of
// a first DL packet
far.set(far_id);
far.set(apply_action);
// Add IEs to message
n4_triggered->pfcp_ies.set(far);
send_n4 = true;
} else {
Logger::smf_app().info(
"Update SM Context procedure, could not get FAR ID of QoS
Flow " "ID %d", flow->qfi.qfi);
}
// for UL
if (flow->far_id_ul.first) {
pfcp::update_far far = {};
pfcp::far_id_t far_id = {};
far_id.far_id =
flow->far_id_ul.second.far_id; pfcp::apply_action_t apply_action = {};
apply_action.drop = 1;
far.set(far_id);
far.set(apply_action);
// Add IEs to message
n4_triggered->pfcp_ies.set(far);
send_n4 = true;
}
// update in the PDU Session
flow->mark_as_released();
// TODO can I safely remove that
// sps->add_qos_flow(flow);
}
} break;
*/
default: { default: {
Logger::smf_app().error( Logger::smf_app().error(
"Update SM Context procedure: Unknown session management type %d", "Update SM Context procedure: Unknown session management type %d",
...@@ -1265,7 +1200,7 @@ smf_procedure_code session_update_sm_context_procedure::handle_itti_msg( ...@@ -1265,7 +1200,7 @@ smf_procedure_code session_update_sm_context_procedure::handle_itti_msg(
std::vector<pfcp::qfi_t> list_of_qfis_to_be_modified = {}; std::vector<pfcp::qfi_t> list_of_qfis_to_be_modified = {};
n11_trigger->req.get_qfis(list_of_qfis_to_be_modified); n11_trigger->req.get_qfis(list_of_qfis_to_be_modified);
std::shared_ptr<pfcp_association> current_upf{}; std::shared_ptr<pfcp_association> current_upf = {};
std::vector<edge> dl_edges{}; std::vector<edge> dl_edges{};
std::vector<edge> ul_edges{}; std::vector<edge> ul_edges{};
...@@ -1412,29 +1347,9 @@ smf_procedure_code session_update_sm_context_procedure::handle_itti_msg( ...@@ -1412,29 +1347,9 @@ smf_procedure_code session_update_sm_context_procedure::handle_itti_msg(
return smf_procedure_code::ERROR; return smf_procedure_code::ERROR;
} }
} break; } break;
/*
case session_management_procedures_type_e::
PDU_SESSION_RELEASE_AMF_INITIATED:
case session_management_procedures_type_e::
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1: {
if (cause.cause_value == CAUSE_VALUE_REQUEST_ACCEPTED) {
Logger::smf_app().info(
"PDU Session Update SM Context (PDU Session Release) accepted by "
"UPF");
// clear the resources including addresses allocated to this Session
and
// associated QoS flows
sps->deallocate_ressources(
n11_trigger.get()->req.get_dnn()); // TODO: for IPv6 (only for
Ipv4
// for the moment)
}
}
*/
} }
std::shared_ptr<pfcp_association> next_upf{}; std::shared_ptr<pfcp_association> next_upf = {};
std::vector<edge> next_dl_edges{}; std::vector<edge> next_dl_edges{};
std::vector<edge> next_ul_edges{}; std::vector<edge> next_ul_edges{};
...@@ -1455,7 +1370,7 @@ smf_procedure_code ...@@ -1455,7 +1370,7 @@ smf_procedure_code
session_release_sm_context_procedure::send_n4_session_deletion_request() { session_release_sm_context_procedure::send_n4_session_deletion_request() {
std::vector<edge> dl_edges; std::vector<edge> dl_edges;
std::vector<edge> ul_edges; std::vector<edge> ul_edges;
std::shared_ptr<pfcp_association> current_upf; std::shared_ptr<pfcp_association> current_upf = {};
if (get_current_upf(dl_edges, ul_edges, current_upf) == if (get_current_upf(dl_edges, ul_edges, current_upf) ==
smf_procedure_code::ERROR) { smf_procedure_code::ERROR) {
...@@ -1528,7 +1443,7 @@ smf_procedure_code session_release_sm_context_procedure::run( ...@@ -1528,7 +1443,7 @@ smf_procedure_code session_release_sm_context_procedure::run(
std::vector<edge> dl_edges; std::vector<edge> dl_edges;
std::vector<edge> ul_edges; std::vector<edge> ul_edges;
std::shared_ptr<pfcp_association> current_upf; std::shared_ptr<pfcp_association> current_upf = {};
if (get_next_upf(dl_edges, ul_edges, current_upf) == if (get_next_upf(dl_edges, ul_edges, current_upf) ==
smf_procedure_code::ERROR) { smf_procedure_code::ERROR) {
return smf_procedure_code::ERROR; return smf_procedure_code::ERROR;
......
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