Commit 53809d88 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

PDU session estblishment procedure - ready to be testbed with TESTER

parent 8fc1cc06
......@@ -930,6 +930,7 @@ typedef struct indication_s {
uint8_t enbcpi :1;
uint8_t tspcmi :1;
} indication_t;
//-------------------------------------
// 8.13 Protocol Configuration Options (PCO)
//-------------------------------------
......@@ -940,6 +941,7 @@ enum pdn_type_e {
PDN_TYPE_E_IPV4V6 = 3,
PDN_TYPE_E_NON_IP = 4,
};
static const std::vector<std::string> pdn_type_e2str = { "Error", "IPV4",
"IPV6", "IPV4V6", "NON_IP" };
......
......@@ -180,7 +180,8 @@ static const std::vector<std::string> session_management_procedures_type_e2str =
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP1",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP2",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP3",
"PDU_SESSION_RELEASE_NETWORK_REQUESTED"
"PDU_SESSION_RELEASE_NETWORK_REQUESTED",
"PDU_SESSION_TEST"
};
......
......@@ -61,8 +61,6 @@ extern "C" {
#include "nas_message.h"
}
#define BUF_LEN 512
using namespace smf;
#define SYSTEM_CMD_MAX_STR_SIZE 512
......@@ -447,7 +445,7 @@ void smf_app::handle_itti_msg(
void smf_app::handle_itti_msg(itti_n11_update_pdu_session_status &m) {
Logger::smf_app().info(
"Set PDU Session Status to %s",
pdu_session_status_e2str[static_cast<int>(m.pdu_session_status)]);
pdu_session_status_e2str[static_cast<int>(m.pdu_session_status)].c_str());
update_pdu_session_status(m.scid, m.pdu_session_status);
}
......@@ -484,7 +482,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//24.501: response with a 5GSM STATUS message including cause "#95 Semantically incorrect message"
smf_n1_n2_inst.create_n1_sm_container(
context_req_msg, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE); //TODO: should define 5GSM cause in 24.501
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//Send response to AMF
smf_n11_inst->send_pdu_session_create_sm_context_response(
......@@ -506,6 +504,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smreq->req.set_message_type(decoded_nas_msg.plain.sm.header.message_type);
//Integrity protection maximum data rate (Mandatory)
//TODO:
//PDU session type (Optional)
smreq->req.set_pdu_session_type(PDU_SESSION_TYPE_E_IPV4); //set default value
......@@ -516,7 +515,7 @@ 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);
//sm_context_req_msg.set_pdu_session_type(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);
}
//Get necessary information
......@@ -556,7 +555,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//(24.501 (section 7.3.1)) NAS N1 SM message: response with a 5GSM STATUS message including cause "#81 Invalid PTI value"
smf_n1_n2_inst.create_n1_sm_container(
context_req_msg, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE); //TODO: should define 5GSM cause in 24.501
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//Send response to AMF
smf_n11_inst->send_pdu_session_create_sm_context_response(
......@@ -742,23 +741,16 @@ void smf_app::handle_pdu_session_update_sm_context_request(
scid_t scid = { };
try {
scid = std::stoi(smreq->scid);
}
/*catch (const std::out_of_range& err){
} catch (const std::invalid_argument& err){
}*/
catch (const std::exception &err) {
} catch (const std::exception &err) {
//TODO: send PDUSession_SMUpdateContext Response (including PDU Session EStablishment Reject) to AMF with CAUSE: invalid context
Logger::smf_app().warn(
"Received PDU_SESSION_UPDATESMCONTEXT_REQUEST, couldn't retrieve the corresponding SMF context, ignore message!");
"Received a PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Update Reject
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_54_PDU_SESSION_DOES_NOT_EXIST);
......@@ -776,7 +768,19 @@ void smf_app::handle_pdu_session_update_sm_context_request(
} else {
Logger::smf_app().warn(
"Context associated with this id " SCID_FMT " does not exit!", scid);
//TODO: send reject to AMF
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_54_PDU_SESSION_DOES_NOT_EXIST);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_message_hex);
return;
}
......@@ -793,9 +797,9 @@ void smf_app::handle_pdu_session_update_sm_context_request(
smreq->req.set_pdu_session_id(pdu_session_id);
pdu_session_update_sm_context_request context_req_msg = smreq->req;
//Step 2. find the smf context
std::shared_ptr<smf_context> sc = { };
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
......@@ -803,7 +807,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
} else {
//send PDUSession_SMUpdateContext Response (including PDU Session EStablishment Reject) to AMF
Logger::smf_app().warn(
"Received PDU_SESSION_UPDATESMCONTEXT_REQUEST with Supi " SUPI_64_FMT "couldn't retrieve the corresponding SMF context, ignore message!",
"Received PDU Session Update SM Context Request with Supi " SUPI_64_FMT "couldn't retrieve the corresponding SMF context, ignore message!",
supi64);
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
......@@ -815,7 +819,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
context_req_msg,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED);
cause_value_5gsm_e::CAUSE_54_PDU_SESSION_DOES_NOT_EXIST);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
......@@ -831,7 +835,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
//Error, DNN context doesn't exist
// send PDUSession_SMUpdateContext Response (including PDU Session EStablishment Reject) to AMF
Logger::smf_app().warn(
"Received PDU_SESSION_UPDATESMCONTEXT_REQUEST, couldn't retrieve the corresponding SMF context, ignore message!");
"Received PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
......
This diff is collapsed.
......@@ -83,7 +83,7 @@ void 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) {
//TODO: should work with BUPT to finish this function
Logger::smf_app().info("Create N1 SM Container, n1 message type %d",
n1_msg_type);
......@@ -99,11 +99,8 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
nas_msg.header.extended_protocol_discriminator =
EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED;
//TODO: Should be updated
uint8_t sequencenumber = 0xfe;
uint32_t mac = 0xffee;
//nas_msg.header.sequence_number = sequencenumber;
//nas_msg.header.message_authentication_code= mac;
//nas_msg.header.sequence_number = 0xfe;
//nas_msg.header.message_authentication_code = 0xffee;
SM_msg *sm_msg = &nas_msg.plain.sm;
sm_msg->header.extended_protocol_discriminator =
......@@ -115,14 +112,13 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//PDU Session Establishment Accept
case PDU_SESSION_ESTABLISHMENT_ACCEPT: {
//PDU Session Establishment Accept is including in the N1N2MessageTransfer Request sent from SMF to AMF (PDU Session Establishment procedure)
//PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE
if (msg.get_msg_type() != PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE) {
Logger::smf_app().error(
"Cannot create an PDU Session Establishment Accept for this message (type %d)",
msg.get_msg_type());
return;
}
pdu_session_create_sm_context_response &sm_context_res =
static_cast<pdu_session_create_sm_context_response&>(msg);
......@@ -141,11 +137,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//Fill the content of PDU Session Establishment Request message with hardcoded values (to be completed)
//PTI
sm_msg->header.procedure_transaction_identity = sm_context_res.get_pti()
.procedure_transaction_id;
Logger::smf_app().debug(
"Procedure_transaction_id %d",
sm_context_res.get_pti().procedure_transaction_id);
sm_msg->header.procedure_transaction_identity = sm_context_res.get_pti()
.procedure_transaction_id;
Logger::smf_app().debug(
"NAS header, encode extended_protocol_discriminator: 0x%x, security_header_type: 0x%x",
nas_msg.header.extended_protocol_discriminator,
......@@ -164,10 +161,10 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
"PDUSessionType: %#0x",
sm_msg->pdu_session_establishment_accept._pdusessiontype
.pdu_session_type_value);
//SSC Mode
//TODO: should get from sm_context_res
sm_msg->pdu_session_establishment_accept.sscmode.ssc_mode_value =
SSC_MODE_1; //TODO:
SSC_MODE_1; //TODO: get from sm_context_res
Logger::smf_app().debug(
"SSC Mode: %#0x",
sm_msg->pdu_session_establishment_accept.sscmode.ssc_mode_value);
......@@ -268,7 +265,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
sm_msg->pdu_session_establishment_accept.pduaddress
.pdu_address_information = bfromcstralloc(4, "\0");
;
sm_msg->pdu_session_establishment_accept.pduaddress
.pdu_address_information->slen = 4;
......@@ -291,10 +287,18 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
sm_msg->pdu_session_establishment_accept.snssai.len = SST_AND_SD_LENGHT;
sm_msg->pdu_session_establishment_accept.snssai.sst = sm_context_res
.get_snssai().sST;
sm_msg->pdu_session_establishment_accept.snssai.sd = 0x0009; //TODO: sm_context_res.get_snssai().sD; <--- String
try {
sm_msg->pdu_session_establishment_accept.snssai.sd = std::stoi(
sm_context_res.get_snssai().sD);
} catch (const std::exception &e) {
Logger::smf_app().warn("Undefined error: %s", e.what());
//"no SD value associated with the SST"
sm_msg->pdu_session_establishment_accept.snssai.sd = 0xFFFFFF;
}
Logger::smf_app().debug(
"SNSSAI, len: %#0x, sst: %#0x, sd: %#0x",
sm_msg->pdu_session_establishment_accept.snssai.len,
"SNSSAI SST: %#0x, SD: %#0x",
sm_msg->pdu_session_establishment_accept.snssai.sst,
sm_msg->pdu_session_establishment_accept.snssai.sd);
......@@ -372,14 +376,14 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
static_cast<uint8_t>(sm_cause);
sm_msg->pdu_session_establishment_reject.presence = 0x02;
sm_msg->pdu_session_establishment_reject.gprstimer3.unit =
GPRSTIMER3_VALUE_IS_INCREMENTED_IN_MULTIPLES_OF_1_HOUR;
GPRSTIMER3_VALUE_IS_INCREMENTED_IN_MULTIPLES_OF_1_HOUR;
sm_msg->pdu_session_establishment_reject.gprstimer3.timeValue = 0;
sm_msg->pdu_session_establishment_reject.allowedsscmode.is_ssc1_allowed =
SSC_MODE1_ALLOWED;
SSC_MODE1_ALLOWED;
sm_msg->pdu_session_establishment_reject.allowedsscmode.is_ssc2_allowed =
SSC_MODE2_NOT_ALLOWED;
SSC_MODE2_NOT_ALLOWED;
sm_msg->pdu_session_establishment_reject.allowedsscmode.is_ssc3_allowed =
SSC_MODE3_NOT_ALLOWED;
SSC_MODE3_NOT_ALLOWED;
/*
unsigned char bitStream_eapmessage[2] = {0x01,0x02};
......@@ -479,7 +483,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
sm_msg->pdu_session_modification_command.qosrules.qosrulesie[0]
.ruleoperationcode = CREATE_NEW_QOS_RULE;
sm_msg->pdu_session_modification_command.qosrules.qosrulesie[0].dqrbit =
THE_QOS_RULE_IS_DEFAULT_QOS_RULE;
THE_QOS_RULE_IS_DEFAULT_QOS_RULE;
sm_msg->pdu_session_modification_command.qosrules.qosrulesie[0]
.numberofpacketfilters = 1;
//1st rule
......@@ -670,7 +674,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
(Ngap_PDUSessionResourceSetupRequestTransferIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceSetupRequestTransferIEs_t));
pduSessionAggregateMaximumBitRate->id =
Ngap_ProtocolIE_ID_id_PDUSessionAggregateMaximumBitRate;
Ngap_ProtocolIE_ID_id_PDUSessionAggregateMaximumBitRate;
pduSessionAggregateMaximumBitRate->criticality = Ngap_Criticality_reject;
pduSessionAggregateMaximumBitRate->value.present =
Ngap_PDUSessionResourceSetupRequestTransferIEs__value_PR_PDUSessionAggregateMaximumBitRate;
......@@ -702,7 +706,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
(Ngap_PDUSessionResourceSetupRequestTransferIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceSetupRequestTransferIEs_t));
upTransportLayerInformation->id =
Ngap_ProtocolIE_ID_id_UL_NGU_UP_TNLInformation;
Ngap_ProtocolIE_ID_id_UL_NGU_UP_TNLInformation;
upTransportLayerInformation->criticality = Ngap_Criticality_reject;
upTransportLayerInformation->value.present =
Ngap_PDUSessionResourceSetupRequestTransferIEs__value_PR_UPTransportLayerInformation;
......@@ -769,7 +773,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
(Ngap_PDUSessionResourceSetupRequestTransferIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceSetupRequestTransferIEs_t));
qosFlowSetupRequestList->id =
Ngap_ProtocolIE_ID_id_QosFlowSetupRequestList;
Ngap_ProtocolIE_ID_id_QosFlowSetupRequestList;
qosFlowSetupRequestList->criticality = Ngap_Criticality_reject;
qosFlowSetupRequestList->value.present =
Ngap_PDUSessionResourceSetupRequestTransferIEs__value_PR_QosFlowSetupRequestList;
......@@ -879,7 +883,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
(Ngap_PDUSessionResourceModifyRequestTransferIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceModifyRequestTransferIEs_t));
pduSessionAggregateMaximumBitRate->id =
Ngap_ProtocolIE_ID_id_PDUSessionAggregateMaximumBitRate;
Ngap_ProtocolIE_ID_id_PDUSessionAggregateMaximumBitRate;
pduSessionAggregateMaximumBitRate->criticality = Ngap_Criticality_reject;
pduSessionAggregateMaximumBitRate->value.present =
Ngap_PDUSessionResourceModifyRequestTransferIEs__value_PR_PDUSessionAggregateMaximumBitRate;
......@@ -910,7 +914,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
(Ngap_PDUSessionResourceModifyRequestTransferIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceModifyRequestTransferIEs_t));
ul_NGU_UP_TNLModifyList->id =
Ngap_ProtocolIE_ID_id_UL_NGU_UP_TNLModifyList;
Ngap_ProtocolIE_ID_id_UL_NGU_UP_TNLModifyList;
ul_NGU_UP_TNLModifyList->criticality = Ngap_Criticality_reject;
ul_NGU_UP_TNLModifyList->value.present =
Ngap_PDUSessionResourceModifyRequestTransferIEs__value_PR_UL_NGU_UP_TNLModifyList;
......@@ -983,7 +987,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
1, sizeof(Ngap_PDUSessionResourceModifyRequestTransferIEs_t));
qosFlowAddOrModifyRequestList->id =
Ngap_ProtocolIE_ID_id_QosFlowAddOrModifyRequestList;
Ngap_ProtocolIE_ID_id_QosFlowAddOrModifyRequestList;
qosFlowAddOrModifyRequestList->criticality = Ngap_Criticality_reject;
qosFlowAddOrModifyRequestList->value.present =
Ngap_PDUSessionResourceModifyRequestTransferIEs__value_PR_QosFlowAddOrModifyRequestList;
......
This diff is collapsed.
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