Commit 7dff323e authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix Cause/PDU session type releated issues for PDU session establishment

parent 451b609a
......@@ -226,7 +226,7 @@ enum class cause_value_5gsm_e {
CAUSE_46_OUT_OF_LAND_SERVICE_AREA = 46,
CAUSE_47_PTI_MISMATCH = 47,
CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED = 50,
CAUSE_51_PDU_SESSION_TYPE_IPV6_ONLY_ALLOWED = 50,
CAUSE_51_PDU_SESSION_TYPE_IPV6_ONLY_ALLOWED = 51,
CAUSE_54_PDU_SESSION_DOES_NOT_EXIST = 54,
CAUSE_67_INSUFFICIENT_RESOURCES_FOR_SPECIFIC_SLICE_AND_DNN = 67,
CAUSE_68_NOT_SUPPORTED_SSC_MODE = 68,
......
......@@ -419,8 +419,8 @@ void smf_app::handle_itti_msg(
Logger::smf_app().info("Process N1N2MessageTransfer Response");
//Update PDU Session accordingly
//TODO: to be completed (process cause)
pdu_session_status_e status = {pdu_session_status_e::PDU_SESSION_INACTIVE};
upCnx_state_e state = {upCnx_state_e::UPCNX_STATE_DEACTIVATED};
pdu_session_status_e status = { pdu_session_status_e::PDU_SESSION_INACTIVE };
upCnx_state_e state = { upCnx_state_e::UPCNX_STATE_DEACTIVATED };
if ((static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_OK)
or (static_cast<http_response_codes_e>(m.response_code)
......@@ -465,6 +465,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
std::string n1_sm_message, n1_sm_message_hex;
smf_n1_n2 smf_n1_n2_inst = { };
nas_message_t decoded_nas_msg = { };
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN };
pdu_session_type_t pdu_session_type = { .pdu_session_type =
PDU_SESSION_TYPE_E_IPV4 };
//Step 1. Decode NAS and get the necessary information
std::string n1_sm_msg = smreq->req.get_n1_sm_message();
......@@ -498,11 +501,17 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//Extended protocol discriminator (Mandatory)
smreq->req.set_epd(decoded_nas_msg.header.extended_protocol_discriminator);
//PDUSessionIdentity
pdu_session_id_t pdu_session_id = decoded_nas_msg.plain.sm.header
.pdu_session_identity;
//ProcedureTransactionIdentity
procedure_transaction_id_t pti = { .procedure_transaction_id = decoded_nas_msg
.plain.sm.header.procedure_transaction_identity };
//Message type (Mandatory)
smreq->req.set_message_type(decoded_nas_msg.plain.sm.header.message_type);
//TODO: Integrity protection maximum data rate (Mandatory)
//PDU session type (Optional)
smreq->req.set_pdu_session_type(PDU_SESSION_TYPE_E_IPV4); //set default value
if (decoded_nas_msg.plain.sm.header.message_type
== PDU_SESSION_ESTABLISHMENT_REQUEST) {
//TODO: Disable this command temporarily since can't get this info from tester
......@@ -510,22 +519,48 @@ void smf_app::handle_pdu_session_create_sm_context_request(
"NAS, pdu_session_type %d",
decoded_nas_msg.plain.sm.pdu_session_establishment_request
._pdusessiontype.pdu_session_type_value);
smreq->req.set_pdu_session_type(
decoded_nas_msg.plain.sm.pdu_session_establishment_request
._pdusessiontype.pdu_session_type_value);
pdu_session_type.pdu_session_type = decoded_nas_msg.plain.sm
.pdu_session_establishment_request._pdusessiontype
.pdu_session_type_value;
}
smreq->req.set_pdu_session_type(pdu_session_type.pdu_session_type);
//TODO: Support IPv4 only for now
if (pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV6) {
cause_n1 = cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
} else if ((pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_ETHERNET)
or (pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_UNSTRUCTURED)) {
cause_n1 = cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE;
}
if (pdu_session_type.pdu_session_type != PDU_SESSION_TYPE_E_IPV4) {
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
smf_n11_inst->send_pdu_session_create_sm_context_response(
smreq->http_response, smContextCreateError,
Pistache::Http::Code::Forbidden, n1_sm_message_hex);
}
//TODO: SSCMode
//TODO: store UE 5GSM Capability
//TODO: MaximumNumberOfSupportedPacketFilters
//TODO: AlwaysonPDUSessionRequested
//TODO: SMPDUDNRequestContainer
//TODO: ExtendedProtocolConfigurationOptions
//Get necessary information
supi_t supi = smreq->req.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
procedure_transaction_id_t pti = { .procedure_transaction_id = decoded_nas_msg
.plain.sm.header.procedure_transaction_identity };
pdu_session_type_t pdu_session_type = { .pdu_session_type = smreq->req
.get_pdu_session_type() };
pdu_session_id_t pdu_session_id = decoded_nas_msg.plain.sm.header
.pdu_session_identity;
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
std::string request_type = smreq->req.get_request_type();
Logger::smf_app().info(
......@@ -599,8 +634,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//return
}
//TODO: store UE 5GSM Capability
//TODO: For the moment, not support PDU session authentication and authorization by the external DN
//Step 3. check if the DNN requested is valid
......@@ -1019,10 +1052,9 @@ void smf_app::update_pdu_session_status(const scid_t scid,
pdu_session_status_e2str[static_cast<int>(status)].c_str());
}
//---------------------------------------------------------------------------------------------
void smf_app::update_pdu_session_upCnx_state(const scid_t scid,
const upCnx_state_e state) {
const upCnx_state_e state) {
Logger::smf_app().info("Update UpCnx_State");
//get the smf context
......@@ -1071,9 +1103,8 @@ void smf_app::update_pdu_session_upCnx_state(const scid_t scid,
"Could not retrieve the corresponding SMF PDU Session context!");
}
sp.get()->set_upCnx_state(state);
Logger::smf_app().info(
"Set PDU Session UpCnxState to %s",
upCnx_state_e2str[static_cast<int>(state)].c_str());
Logger::smf_app().info("Set PDU Session UpCnxState to %s",
upCnx_state_e2str[static_cast<int>(state)].c_str());
}
//---------------------------------------------------------------------------------------------
void smf_app::timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user) {
......
......@@ -1073,7 +1073,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
"PDU Session Establishment Request: Create SM Context Request procedure failed");
remove_procedure(proc);
//Set cause to error to trigger PDU session establishment reject (step 10)
sm_context_resp->res.set_cause(UNKNOWN_ERROR);
//sm_context_resp->res.set_cause(UNKNOWN_ERROR);
}
} else { //if request is rejected
......@@ -1119,9 +1119,14 @@ void smf_context::handle_pdu_session_create_sm_context_request(
//Create PDU Session Establishment Reject and embedded in Namf_Communication_N1N2MessageTransfer Request
Logger::smf_app().debug("Create PDU Session Establishment Reject");
//TODO: Should check Cause for other cases
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE };
if (sm_context_resp->res.get_cause() == NO_RESOURCES_AVAILABLE) {
cause_n1 = cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES;
}
smf_n1_n2_inst.create_n1_sm_container(
sm_context_resp_pending->res, PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message, cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES);
n1_sm_message, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
sm_context_resp_pending->res.set_n1_sm_message(n1_sm_msg_hex);
......
......@@ -298,6 +298,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//EAPMessage
//authorized QoS flow descriptions IE: QoSFlowDescritions
//TODO: we may not need this IE (see section 6.4.1.3 @3GPP TS 24.501)
if (smf_app_inst->is_supi_2_smf_context(supi64)) {
Logger::smf_app().debug("Get SMF context with SUPI " SUPI_64_FMT "",
supi64);
......
......@@ -301,6 +301,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
"session_create_sm_context_procedure handle itti_n4_session_establishment_response: pdu-session-id %d",
n11_trigger.get()->req.get_pdu_session_id());
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN };
pfcp::cause_t cause = { };
resp.pfcp_ies.get(cause);
if (cause.cause_value == pfcp::CAUSE_VALUE_REQUEST_ACCEPTED) {
......@@ -378,19 +379,36 @@ void session_create_sm_context_procedure::handle_itti_msg(
if (n11_triggered_pending->res.get_cause() != REQUEST_ACCEPTED) { //PDU Session Establishment Reject
Logger::smf_app().debug(
"Prepare a PDU Session Establishment Reject message and send to UE");
smf_n1_n2_inst.create_n1_sm_container(
n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_msg, cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE);
cause_n1 = cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE;
//TODO: Support IPv4 only for now
if (n11_triggered_pending->res.get_pdu_session_type()
== PDU_SESSION_TYPE_E_IPV6) {
n11_triggered_pending->res.set_pdu_session_type(PDU_SESSION_TYPE_E_IPV4);
cause_n1 =
cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
}
smf_n1_n2_inst.create_n1_sm_container(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
} else { //PDU Session Establishment Accept
Logger::smf_app().debug(
"Prepare a PDU Session Establishment Accept message and send to UE");
//TODO: Support IPv4 only for now
if (n11_triggered_pending->res.get_pdu_session_type()
== PDU_SESSION_TYPE_E_IPV4V6) {
n11_triggered_pending->res.set_pdu_session_type(PDU_SESSION_TYPE_E_IPV4);
cause_n1 =
cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
}
smf_n1_n2_inst.create_n1_sm_container(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_ACCEPT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_0_UNKNOWN); //TODO: need cause?
PDU_SESSION_ESTABLISHMENT_ACCEPT,
n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
//N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502): PDUSessionRessourceSetupRequestTransfer IE
......@@ -1012,7 +1030,6 @@ void session_update_sm_context_procedure::handle_itti_msg(
//set UpCnxState to DEACTIVATED
ppc->set_upCnx_state(upCnx_state_e::UPCNX_STATE_ACTIVATED);
}
break;
......@@ -1120,11 +1137,11 @@ void session_update_sm_context_procedure::handle_itti_msg(
"PDU_RES_REL_CMD"; //NGAP message
} else {
//fill the content of SmContextUpdatedData
n11_triggered_pending->res.sm_context_updated_data = {};
n11_triggered_pending->res.sm_context_updated_data["n1MessageContainer"]["n1MessageClass"] =
N1N2_MESSAGE_CLASS;
n11_triggered_pending->res.sm_context_updated_data["n1MessageContainer"]["n1MessageContent"]["contentId"] =
N1_SM_CONTENT_ID;
n11_triggered_pending->res.sm_context_updated_data = { };
n11_triggered_pending->res.sm_context_updated_data["n1MessageContainer"]["n1MessageClass"] =
N1N2_MESSAGE_CLASS;
n11_triggered_pending->res.sm_context_updated_data["n1MessageContainer"]["n1MessageContent"]["contentId"] =
N1_SM_CONTENT_ID;
}
//Update PDU session status to PDU_SESSION_INACTIVE_PENDING
......
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