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

fix issue when an internal error happens

parent 86ff6efb
......@@ -552,13 +552,20 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE);
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
smContextCreateError, n1_sm_message_hex,
smreq->pid);
} else {
//trigger to send reply to AMF
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
......@@ -603,13 +610,19 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(smreq->req,
if (smf_n1_n2_inst.create_n1_sm_container(smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message, cause_n1);
n1_sm_message, cause_n1)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
smContextCreateError, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
......@@ -649,13 +662,19 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject including cause "#81 Invalid PTI value" (section 7.3.1 @3GPP TS 24.501)
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE);
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
smContextCreateError, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
smreq->req.set_pti(pti);
......@@ -665,6 +684,10 @@ void smf_app::handle_pdu_session_create_sm_context_request(
|| (pdu_session_id > PDU_SESSION_IDENTITY_LAST )) {
Logger::smf_app().warn("Invalid PDU Session ID value (%d)", pdu_session_id);
//section 7.3.2@3GPP TS 24.501; NAS N1 SM message: ignore the message
//trigger to send reply to AMF
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_406_NOT_ACCEPTABLE, smreq->pid,
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
return;
}
......@@ -679,15 +702,22 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
//(24.501 (section 7.4)) implementation dependent->do similar to UE: response with a 5GSM STATUS message including cause "#98 message type not compatible with protocol state."
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE);
cause_value_5gsm_e::CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
smContextCreateError, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
......@@ -714,13 +744,19 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#27 Missing or unknown DNN"
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN);
cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
smContextCreateError, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
......@@ -796,16 +832,21 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, with cause "29 User authentication or authorization failed"
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED);
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
return;
}
} else {
......@@ -1461,6 +1502,7 @@ void smf_app::trigger_http_response(
uint32_t &promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of API Server");
std::shared_ptr<itti_n11_update_sm_context_response> itti_msg =
std::make_shared<itti_n11_update_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
......@@ -1477,6 +1519,7 @@ void smf_app::trigger_http_response(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
}
//---------------------------------------------------------------------------------------------
......@@ -1487,6 +1530,7 @@ void smf_app::trigger_http_response(
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of HTTP Server");
std::shared_ptr<itti_n11_update_sm_context_response> itti_msg =
std::make_shared<itti_n11_update_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
......@@ -1504,6 +1548,7 @@ void smf_app::trigger_http_response(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
}
//---------------------------------------------------------------------------------------------
......@@ -1529,6 +1574,7 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
}
}
break;
case N11_SESSION_CREATE_SM_CONTEXT_RESPONSE: {
std::shared_ptr<itti_n11_create_sm_context_response> itti_msg =
......@@ -1546,8 +1592,27 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
}
}
break;
default: {
case N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE: {
std::shared_ptr<itti_n11_update_sm_context_response> itti_msg =
std::make_shared<itti_n11_update_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
promise_id);
pdu_session_update_sm_context_response sm_context_response = { };
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
}
break;
default: {
//TODO:
}
}
......
......@@ -620,6 +620,7 @@ class smf_app {
* @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 [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
......@@ -633,6 +634,7 @@ class smf_app {
* @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 [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
......@@ -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
* @param [const uint32_t &] http_code: Status code of HTTP response
* @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
*/
void trigger_http_response(const uint32_t &http_code, uint32_t &promise_id,
......
......@@ -1151,16 +1151,23 @@ void smf_context::handle_pdu_session_create_sm_context_request(
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED);
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_401_UNAUTHORIZED,
smContextCreateError, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
//TODO:
//SMF unsubscribes to the modifications of Session Management Subscription data for (SUPI, DNN, S-NSSAI)
//using Nudm_SDM_Unsubscribe()
......@@ -1225,6 +1232,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_406_NOT_ACCEPTABLE, smreq->pid,
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
return;
}
//TODO: if "Integrity Protection is required", check UE Integrity Protection Maximum Data Rate
......@@ -1317,14 +1325,19 @@ void smf_context::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE);
cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
}
request_accepted = false;
break;
}
......@@ -1471,6 +1484,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
"Could not send ITTI message %s to task TASK_SMF_N11",
sm_context_resp_pending->get_msg_name());
}
}
}
......@@ -1532,7 +1546,8 @@ void smf_context::handle_pdu_session_update_sm_context_request(
sm_context_req_msg.get_pdu_session_id());
n11_sm_context_resp->res.set_snssai(sm_context_req_msg.get_snssai());
n11_sm_context_resp->res.set_dnn(sm_context_req_msg.get_dnn());
n11_sm_context_resp->res.set_pdu_session_type(sp.get()->get_pdn_type().pdn_type);
n11_sm_context_resp->res.set_pdu_session_type(
sp.get()->get_pdn_type().pdn_type);
//Step 2.1. Decode N1 (if content is available)
if (sm_context_req_msg.n1_sm_msg_is_set()) {
......@@ -1770,13 +1785,19 @@ void smf_context::handle_pdu_session_update_sm_context_request(
std::string n1_sm_msg_to_be_created, n1_sm_msg_hex_to_be_created;
std::string n2_sm_info_to_be_created, n2_sm_info_hex_to_be_created;
//N1 SM (PDU Session Modification Command)
smf_n1_n2_inst.create_n1_sm_container(
if (not smf_n1_n2_inst.create_n1_sm_container(
n11_sm_context_resp->res, PDU_SESSION_MODIFICATION_COMMAND,
n1_sm_msg_to_be_created, cause_value_5gsm_e::CAUSE_0_UNKNOWN); //TODO: need cause?
n1_sm_msg_to_be_created, cause_value_5gsm_e::CAUSE_0_UNKNOWN) or //TODO: need cause?
//N2 SM (PDU Session Resource Modify Request Transfer IE)
smf_n1_n2_inst.create_n2_sm_information(
not smf_n1_n2_inst.create_n2_sm_information(
n11_sm_context_resp->res, 1, n2_sm_info_type_e::PDU_RES_MOD_REQ,
n2_sm_info_to_be_created);
n2_sm_info_to_be_created)) {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
return;
}
smf_app_inst->convert_string_2_hex(n1_sm_msg_to_be_created,
n1_sm_msg_hex_to_be_created);
smf_app_inst->convert_string_2_hex(n2_sm_info_to_be_created,
......@@ -1921,14 +1942,21 @@ void smf_context::handle_pdu_session_update_sm_context_request(
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
sm_context_req_msg, PDU_SESSION_RELEASE_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_43_INVALID_PDU_SESSION_IDENTITY);
cause_value_5gsm_e::CAUSE_43_INVALID_PDU_SESSION_IDENTITY)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
}
return;
}
//Abnormal cases in network side (see section 6.3.3.5 @3GPP TS 24.501)
if (sp.get()->get_pdu_session_status()
......@@ -2079,14 +2107,20 @@ void smf_context::handle_pdu_session_update_sm_context_request(
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
//24.501: response with a 5GSM STATUS message including cause "#95 Semantically incorrect message"
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
sm_context_req_msg, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE);
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); //TODO: need N1SM?
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
}
return;
}
......@@ -2165,15 +2199,20 @@ void smf_context::handle_pdu_session_update_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#26 Insufficient resources"
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES);
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n1_sm_msg_hex, smreq->pid);
//TODO: Need release established resources?
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
}
return;
}
break;
......@@ -2390,14 +2429,19 @@ void smf_context::handle_pdu_session_update_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_n2_inst.create_n1_sm_container(
sm_context_req_msg, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE);
cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
}
}
break;
......@@ -2570,6 +2614,7 @@ void smf_context::handle_pdu_session_modification_network_requested(
Logger::smf_app().debug(
"Prepare N1N2MessageTransfer message and send to AMF");
//TODO: handle encode N1, N2 failure
//N1: PDU_SESSION_MODIFICATION_COMMAND
smf_n1_n2_inst.create_n1_sm_container(itti_msg->msg,
PDU_SESSION_MODIFICATION_COMMAND,
......@@ -2582,6 +2627,7 @@ void smf_context::handle_pdu_session_modification_network_requested(
smf_n1_n2_inst.create_n2_sm_information(itti_msg->msg, 1,
n2_sm_info_type_e::PDU_RES_MOD_REQ,
n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
itti_msg->msg.set_n2_sm_information(n2_sm_info_hex);
......
......@@ -68,7 +68,7 @@ using namespace smf;
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,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause) {
......@@ -103,7 +103,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
Logger::smf_app().error(
"Cannot create an PDU Session Establishment Accept for this message (type %d)",
msg.get_msg_type());
return;
return false;
}
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,
//get default QoS value
qos_flow_context_updated qos_flow = { };
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(
"PDU_SESSION_ESTABLISHMENT_ACCEPT, encode starting...");
......@@ -149,6 +156,7 @@ 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)
//(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
if (qos_flow.qos_rules.size() > 0) {
sm_msg->pdu_session_establishment_accept.qosrules.lengthofqosrulesie =
qos_flow.qos_rules.size();
sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie =
......@@ -158,10 +166,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
for (auto rule : qos_flow.qos_rules) {
sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i]
.qosruleidentifer = rule.second.qosruleidentifer;
memcpy(&sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i],
memcpy(
&sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie[i],
&rule.second, sizeof(QOSRulesIE));
i++;
}
}
//SessionAMBR
Logger::smf_app().debug("Get default values for Session-AMBR");
......@@ -179,7 +189,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
} else {
Logger::smf_app().warn(
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO:
return false;
}
//Presence
......@@ -298,8 +308,11 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
nas_msg_str = n1Message;
//free memory
if (qos_flow.qos_rules.size() > 0) {
free_wrapper(
(void**) &sm_msg->pdu_session_establishment_accept.qosrules.qosrulesie);
(void**) &sm_msg->pdu_session_establishment_accept.qosrules
.qosrulesie);
}
free_wrapper(
(void**) &sm_msg->pdu_session_establishment_accept.qosflowdescriptions
.qosflowdescriptionscontents);
......@@ -434,7 +447,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
} else {
Logger::smf_app().warn(
"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(),
......@@ -447,8 +460,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
if (!find_dnn or !find_pdu) {
//error
Logger::smf_app().warn("DNN or PDU session context does not exist!");
//TODO:
return;
return false;
}
//PTI
......@@ -475,6 +487,10 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
std::vector<QOSRulesIE> 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 =
qos_rules.size();
......@@ -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,
n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str) {
......@@ -684,6 +700,10 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
qos_flows.begin(); it != qos_flows.end(); ++it)
Logger::smf_app().debug("QoS Flow context to be updated QFI %d",
it->first);
if (qos_flows.empty()) {
return false;
}
//TODO: support only 1 qos flow
qos_flow = qos_flows.begin()->second;
......@@ -703,7 +723,15 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
msg.get_msg_type());
//TODO:
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
......@@ -734,7 +762,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
} else {
Logger::smf_app().warn(
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO:
return false;
}
ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list,
......@@ -888,7 +916,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
"NGAP PDU Session Resource Setup Request Transfer encode failed (encode size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......@@ -948,6 +976,14 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//TODO: support only 1 qos flow
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(
"QoS Flow, UL F-TEID ID " "0x%" PRIx32 ", IP Address %s ",
qos_flow.ul_fteid.teid_gre_key,
......@@ -1164,7 +1200,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
"NGAP PDU Session Resource Modify Request Transfer encode failed (encoded size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......@@ -1288,7 +1324,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
"NGAP PDU Session Resource Setup Response Transfer encode failed (encoded size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......@@ -1398,7 +1434,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
" NGAP PDU Session Resource Modify Response Transfer encode failed (encoded size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......@@ -1474,7 +1510,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
"NGAP PDU Session Release Command encode failed (encoded size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......@@ -1518,7 +1554,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn(
"NGAP PDU Session Release Command encode failed (encoded size %d)",
encoded_size);
return;
return false;
}
#if DEBUG_IS_ON
......
......@@ -78,9 +78,9 @@ class smf_n1_n2 {
* @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string
* @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,
cause_value_5gsm_e sm_cause);
......@@ -89,9 +89,10 @@ class smf_n1_n2 {
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N2 message
* @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,
std::string &ngap_msg_str);
......
......@@ -1034,6 +1034,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n11_triggered_pending->pid);
return;
}
}
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