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

fix issue when an internal error happens

parent 86ff6efb
This diff is collapsed.
...@@ -620,6 +620,7 @@ class smf_app { ...@@ -620,6 +620,7 @@ class smf_app {
* @param [const uint32_t &] http_code: Status code of HTTP response * @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const oai::smf_server::model::SmContextCreateError &] smContextCreateError: store the json content of response message * @param [const oai::smf_server::model::SmContextCreateError &] smContextCreateError: store the json content of response message
* @param [uint32_t &] promise_id: Promise Id * @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void * @return void
*/ */
void trigger_http_response( void trigger_http_response(
...@@ -633,6 +634,7 @@ class smf_app { ...@@ -633,6 +634,7 @@ class smf_app {
* @param [const oai::smf_server::model::SmContextUpdateError &] smContextUpdateError: store the json content of response message * @param [const oai::smf_server::model::SmContextUpdateError &] smContextUpdateError: store the json content of response message
* @param [const std::string &] n1_sm_msg: N1 SM message * @param [const std::string &] n1_sm_msg: N1 SM message
* @param [uint32_t &] promise_id: Promise Id * @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void * @return void
*/ */
void trigger_http_response( void trigger_http_response(
...@@ -644,7 +646,7 @@ class smf_app { ...@@ -644,7 +646,7 @@ class smf_app {
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready * To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response * @param [const uint32_t &] http_code: Status code of HTTP response
* @param [uint32_t &] promise_id: Promise Id * @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type * @param [uint8_t] msg_type: Type of HTTP message (Create/Update/Release)
* @return void * @return void
*/ */
void trigger_http_response(const uint32_t &http_code, uint32_t &promise_id, void trigger_http_response(const uint32_t &http_code, uint32_t &promise_id,
......
This diff is collapsed.
...@@ -68,7 +68,7 @@ using namespace smf; ...@@ -68,7 +68,7 @@ using namespace smf;
extern smf_app *smf_app_inst; extern smf_app *smf_app_inst;
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, bool smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
uint8_t n1_msg_type, uint8_t n1_msg_type,
std::string &nas_msg_str, std::string &nas_msg_str,
cause_value_5gsm_e sm_cause) { cause_value_5gsm_e sm_cause) {
...@@ -103,7 +103,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -103,7 +103,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
Logger::smf_app().error( Logger::smf_app().error(
"Cannot create an PDU Session Establishment Accept for this message (type %d)", "Cannot create an PDU Session Establishment Accept for this message (type %d)",
msg.get_msg_type()); msg.get_msg_type());
return; return false;
} }
pdu_session_create_sm_context_response &sm_context_res = pdu_session_create_sm_context_response &sm_context_res =
...@@ -112,6 +112,13 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -112,6 +112,13 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//get default QoS value //get default QoS value
qos_flow_context_updated qos_flow = { }; qos_flow_context_updated qos_flow = { };
qos_flow = sm_context_res.get_qos_flow_context(); qos_flow = sm_context_res.get_qos_flow_context();
//check the QoS Flow
if ((qos_flow.qfi.qfi < QOS_FLOW_IDENTIFIER_FIRST )
or (qos_flow.qfi.qfi > QOS_FLOW_IDENTIFIER_LAST )) {
//error
Logger::smf_app().error("Incorrect QFI %d", qos_flow.qfi.qfi);
return false;
}
Logger::smf_app().info( Logger::smf_app().info(
"PDU_SESSION_ESTABLISHMENT_ACCEPT, encode starting..."); "PDU_SESSION_ESTABLISHMENT_ACCEPT, encode starting...");
...@@ -149,18 +156,21 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -149,18 +156,21 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//authorized QoS rules of the PDU session: QOSRules (Section 6.2.5@3GPP TS 24.501) //authorized QoS rules of the PDU session: QOSRules (Section 6.2.5@3GPP TS 24.501)
//(Section 6.4.1.3@3GPP TS 24.501 V16.1.0) Make sure that the number of the packet filters used in the authorized QoS rules of the PDU Session does not //(Section 6.4.1.3@3GPP TS 24.501 V16.1.0) Make sure that the number of the packet filters used in the authorized QoS rules of the PDU Session does not
// exceed the maximum number of packet filters supported by the UE for the PDU session // exceed the maximum number of packet filters supported by the UE for the PDU session
sm_msg->pdu_session_establishment_accept.qosrules.lengthofqosrulesie = if (qos_flow.qos_rules.size() > 0) {
qos_flow.qos_rules.size(); sm_msg->pdu_session_establishment_accept.qosrules.lengthofqosrulesie =
sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie = qos_flow.qos_rules.size();
(QOSRulesIE*) calloc(qos_flow.qos_rules.size(), sizeof(QOSRulesIE)); sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie =
(QOSRulesIE*) calloc(qos_flow.qos_rules.size(), sizeof(QOSRulesIE));
int i = 0;
for (auto rule : qos_flow.qos_rules) { int i = 0;
sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i] for (auto rule : qos_flow.qos_rules) {
.qosruleidentifer = rule.second.qosruleidentifer; sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i]
memcpy(&sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i], .qosruleidentifer = rule.second.qosruleidentifer;
&rule.second, sizeof(QOSRulesIE)); memcpy(
i++; &sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i],
&rule.second, sizeof(QOSRulesIE));
i++;
}
} }
//SessionAMBR //SessionAMBR
...@@ -179,7 +189,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -179,7 +189,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
} else { } else {
Logger::smf_app().warn( Logger::smf_app().warn(
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64); "SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO: return false;
} }
//Presence //Presence
...@@ -298,8 +308,11 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -298,8 +308,11 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
nas_msg_str = n1Message; nas_msg_str = n1Message;
//free memory //free memory
free_wrapper( if (qos_flow.qos_rules.size() > 0) {
(void**) &sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie); free_wrapper(
(void**) &sm_msg->pdu_session_establishment_accept.qosrules
.qosrulesie);
}
free_wrapper( free_wrapper(
(void**) &sm_msg->pdu_session_establishment_accept.qosflowdescriptions (void**) &sm_msg->pdu_session_establishment_accept.qosflowdescriptions
.qosflowdescriptionscontents); .qosflowdescriptionscontents);
...@@ -434,7 +447,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -434,7 +447,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
} else { } else {
Logger::smf_app().warn( Logger::smf_app().warn(
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64); "SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO: return false;
} }
bool find_dnn = sc.get()->find_dnn_context(sm_context_res.get_snssai(), bool find_dnn = sc.get()->find_dnn_context(sm_context_res.get_snssai(),
...@@ -447,8 +460,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -447,8 +460,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
if (!find_dnn or !find_pdu) { if (!find_dnn or !find_pdu) {
//error //error
Logger::smf_app().warn("DNN or PDU session context does not exist!"); Logger::smf_app().warn("DNN or PDU session context does not exist!");
//TODO: return false;
return;
} }
//PTI //PTI
...@@ -475,6 +487,10 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -475,6 +487,10 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
std::vector<QOSRulesIE> qos_rules; std::vector<QOSRulesIE> qos_rules;
sp.get()->get_qos_rules_to_be_synchronised(qos_rules); sp.get()->get_qos_rules_to_be_synchronised(qos_rules);
if (qos_rules.size() == 0) {
return false;
}
sm_msg->pdu_session_modification_command.qosrules.lengthofqosrulesie = sm_msg->pdu_session_modification_command.qosrules.lengthofqosrulesie =
qos_rules.size(); qos_rules.size();
...@@ -630,7 +646,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -630,7 +646,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, bool smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
uint8_t ngap_msg_type, uint8_t ngap_msg_type,
n2_sm_info_type_e ngap_ie_type, n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str) { std::string &ngap_msg_str) {
...@@ -684,6 +700,10 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -684,6 +700,10 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
qos_flows.begin(); it != qos_flows.end(); ++it) qos_flows.begin(); it != qos_flows.end(); ++it)
Logger::smf_app().debug("QoS Flow context to be updated QFI %d", Logger::smf_app().debug("QoS Flow context to be updated QFI %d",
it->first); it->first);
if (qos_flows.empty()) {
return false;
}
//TODO: support only 1 qos flow //TODO: support only 1 qos flow
qos_flow = qos_flows.begin()->second; qos_flow = qos_flows.begin()->second;
...@@ -703,7 +723,15 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -703,7 +723,15 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
msg.get_msg_type()); msg.get_msg_type());
//TODO: //TODO:
free_wrapper((void**) &ngap_IEs); free_wrapper((void**) &ngap_IEs);
return; return false;
}
//check the QoS Flow
if ((qos_flow.qfi.qfi < QOS_FLOW_IDENTIFIER_FIRST )
or (qos_flow.qfi.qfi > QOS_FLOW_IDENTIFIER_LAST )) {
//error
Logger::smf_app().error("Incorrect QFI %d", qos_flow.qfi.qfi);
return false;
} }
//PDUSessionAggregateMaximumBitRate //PDUSessionAggregateMaximumBitRate
...@@ -734,7 +762,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -734,7 +762,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
} else { } else {
Logger::smf_app().warn( Logger::smf_app().warn(
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64); "SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO: return false;
} }
ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list, ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list,
...@@ -888,7 +916,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -888,7 +916,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Resource Setup Request Transfer encode failed (encode size %d)", "NGAP PDU Session Resource Setup Request Transfer encode failed (encode size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
...@@ -948,6 +976,14 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -948,6 +976,14 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//TODO: support only 1 qos flow //TODO: support only 1 qos flow
qos_flow_context_updated qos_flow = qos_flows.begin()->second; qos_flow_context_updated qos_flow = qos_flows.begin()->second;
//check the QoS Flow
if ((qos_flow.qfi.qfi < QOS_FLOW_IDENTIFIER_FIRST )
or (qos_flow.qfi.qfi > QOS_FLOW_IDENTIFIER_LAST )) {
//error
Logger::smf_app().error("Incorrect QFI %d", qos_flow.qfi.qfi);
return false;
}
Logger::smf_app().debug( Logger::smf_app().debug(
"QoS Flow, UL F-TEID ID " "0x%" PRIx32 ", IP Address %s ", "QoS Flow, UL F-TEID ID " "0x%" PRIx32 ", IP Address %s ",
qos_flow.ul_fteid.teid_gre_key, qos_flow.ul_fteid.teid_gre_key,
...@@ -1164,7 +1200,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1164,7 +1200,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Resource Modify Request Transfer encode failed (encoded size %d)", "NGAP PDU Session Resource Modify Request Transfer encode failed (encoded size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
...@@ -1288,7 +1324,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1288,7 +1324,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Resource Setup Response Transfer encode failed (encoded size %d)", "NGAP PDU Session Resource Setup Response Transfer encode failed (encoded size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
...@@ -1398,7 +1434,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1398,7 +1434,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
" NGAP PDU Session Resource Modify Response Transfer encode failed (encoded size %d)", " NGAP PDU Session Resource Modify Response Transfer encode failed (encoded size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
...@@ -1474,7 +1510,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1474,7 +1510,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Release Command encode failed (encoded size %d)", "NGAP PDU Session Release Command encode failed (encoded size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
...@@ -1518,7 +1554,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1518,7 +1554,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Release Command encode failed (encoded size %d)", "NGAP PDU Session Release Command encode failed (encoded size %d)",
encoded_size); encoded_size);
return; return false;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
......
...@@ -78,9 +78,9 @@ class smf_n1_n2 { ...@@ -78,9 +78,9 @@ class smf_n1_n2 {
* @param [uint8_t] msg_type Type of N1 message * @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string * @param [std::string&] nas_msg_str store NAS message in form of string
* @param [uint8_t] sm_cause store NAS Cause * @param [uint8_t] sm_cause store NAS Cause
* * @return boolean: True if the NAS message has been created successfully, otherwise return false
*/ */
void create_n1_sm_container(pdu_session_msg &msg, uint8_t msg_type, bool create_n1_sm_container(pdu_session_msg &msg, uint8_t msg_type,
std::string &nas_msg_str, std::string &nas_msg_str,
cause_value_5gsm_e sm_cause); cause_value_5gsm_e sm_cause);
...@@ -89,9 +89,10 @@ class smf_n1_n2 { ...@@ -89,9 +89,10 @@ class smf_n1_n2 {
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res * @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N2 message * @param [uint8_t] msg_type Type of N2 message
* @param [std::string&] ngap_msg_str store NGAP message in form of string * @param [std::string&] ngap_msg_str store NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
* *
*/ */
void create_n2_sm_information(pdu_session_msg &msg, uint8_t ngap_msg_type, bool create_n2_sm_information(pdu_session_msg &msg, uint8_t ngap_msg_type,
n2_sm_info_type_e ngap_ie_type, n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str); std::string &ngap_msg_str);
......
...@@ -480,10 +480,10 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -480,10 +480,10 @@ void session_create_sm_context_procedure::handle_itti_msg(
//N1N2MsgTxfrFailureNotification //N1N2MsgTxfrFailureNotification
std::string callback_uri = std::string( std::string callback_uri = std::string(
inet_ntoa(*((struct in_addr*) &smf_cfg.amf_addr.ipv4_addr))) + ":" inet_ntoa(*((struct in_addr*) &smf_cfg.amf_addr.ipv4_addr))) + ":"
+ std::to_string(smf_cfg.amf_addr.port) + std::to_string(smf_cfg.amf_addr.port)
+ fmt::format(NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE, + fmt::format(NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE,
supi_str.c_str()); supi_str.c_str());
json_data["n1n2FailureTxfNotifURI"] = callback_uri.c_str(); json_data["n1n2FailureTxfNotifURI"] = callback_uri.c_str();
//json_data["n1n2FailureTxfNotifURI"] = "http://192.168.122.1/namf-comm/callback/N1N2MsgTxfrFailureNotification/imsi-310410000000001-1"; //json_data["n1n2FailureTxfNotifURI"] = "http://192.168.122.1/namf-comm/callback/N1N2MsgTxfrFailureNotification/imsi-310410000000001-1";
} }
...@@ -1034,6 +1034,7 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1034,6 +1034,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
smf_app_inst->trigger_http_response( smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n11_triggered_pending->pid); smContextUpdateError, n11_triggered_pending->pid);
return;
} }
} }
break; break;
......
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