Commit c80f26ff authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

fix issue for NSSAI/Cause and add PDU Session Release Reject

parent 42c70894
......@@ -73,8 +73,8 @@ SMF =
APN_LIST = (
# IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDN_TYPE choice in {IPv4, IPv6, IPv4v6}
{APN_NI = "carrier.com"; PDN_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1},
{APN_NI = "default"; PDN_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1},
{APN_NI = "default"; PDN_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1},
{APN_NI = "carrier.com"; PDN_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1},
{APN_NI = "apn2"; PDN_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1},
{APN_NI = "apn3"; PDN_TYPE = "IPv4"; IPV4_POOL = 3; IPV6_POOL = -1},
{APN_NI = "apn4"; PDN_TYPE = "IPv4"; IPV4_POOL = 4; IPV6_POOL = -1}
......
......@@ -103,7 +103,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd().c_str());
snssai_t snssai(smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd().c_str());
smContextCreateData.getSNssai().getSd());
sm_context_req_msg.set_snssai(snssai);
//PDU session ID
......
......@@ -526,8 +526,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
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(
"Handle a PDU Session Create SM Context Request message from AMF, supi " SUPI_64_FMT ", dnn %s, snssai_sst %d",
supi64, dnn.c_str(), snssai.sST);
"Handle a PDU Session Create SM Context Request message from AMF, supi " SUPI_64_FMT ", dnn %s, snssai_sst %d, snssai_sd %s",
supi64, dnn.c_str(), snssai.sST, snssai.sD.c_str());
//If no DNN information from UE, set to default value
if (dnn.length() == 0) {
......@@ -581,9 +581,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE); //TODO: should define 5GSM cause in 24.501
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);
//Send response to AMF
smf_n11_inst->send_pdu_session_create_sm_context_response(
smreq->http_response, smContextCreateError,
Pistache::Http::Code::Forbidden, n1_sm_message_hex);
......@@ -617,7 +616,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN);
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(
smreq->http_response, smContextCreateError,
Pistache::Http::Code::Forbidden, n1_sm_message_hex);
......@@ -672,8 +670,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//update dnn_context with subscription info
sc.get()->insert_dnn_subscription(snssai, subscription);
} else {
// Cannot retrieve information from UDM,
//Not accept to establish a PDU session
// Cannot retrieve information from UDM, reject PDU session establishment
Logger::smf_app().warn(
"Received PDU_SESSION_CREATESMCONTEXT_REQUEST, couldn't retrieve the Session Management Subscription from UDM, ignore message!");
problem_details.setCause(
......@@ -681,7 +678,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, with cause "29 User authentication or authorization failed"?
//PDU Session Establishment Reject, with cause "29 User authentication or authorization failed"
smf_n1_n2_inst.create_n1_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
......@@ -712,8 +709,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
Logger::smf_app().debug("Generated a SCID " SCID_FMT " ", scid);
//Step 8. let the context handle the message
//in this step, SMF will send N4 Session Establishment/Modification to UPF (step 10a, section 4.3.2 3GPP 23.502)
//SMF, then, sends response to AMF
sc.get()->handle_pdu_session_create_sm_context_request(smreq);
}
......@@ -733,7 +728,6 @@ void smf_app::handle_pdu_session_update_sm_context_request(
try {
scid = std::stoi(smreq->scid);
} catch (const std::exception &err) {
//TODO: send PDUSession_SMUpdateContext Response to AMF with CAUSE: invalid context
Logger::smf_app().warn(
"Received a PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
......@@ -793,8 +787,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
if (!sc.get()->find_dnn_context(scf.get()->nssai, scf.get()->dnn, sd)) {
if (nullptr == sd.get()) {
//Error, DNN context doesn't exist
// send PDUSession_SMUpdateContext Response to AMF
//Error, DNN context doesn't exist, send PDUSession_SMUpdateContext Response to AMF
Logger::smf_app().warn(
"Received PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
......
......@@ -827,7 +827,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
std::shared_ptr<itti_n11_create_sm_context_request> smreq) {
Logger::smf_app().info(
"Handle a PDU Session Create SM Context Request message from AMF");
pdu_session_create_sm_context_request sm_context_req_msg = smreq->req;
oai::smf_server::model::SmContextCreateError smContextCreateError = { };
oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { };
......@@ -836,12 +836,12 @@ void smf_context::handle_pdu_session_create_sm_context_request(
bool request_accepted = true;
//Step 1. get necessary information
std::string dnn = sm_context_req_msg.get_dnn();
snssai_t snssai = sm_context_req_msg.get_snssai();
std::string request_type = sm_context_req_msg.get_request_type();
supi_t supi = sm_context_req_msg.get_supi();
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
std::string request_type = smreq->req.get_request_type();
supi_t supi = smreq->req.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
uint32_t pdu_session_id = sm_context_req_msg.get_pdu_session_id();
uint32_t pdu_session_id = smreq->req.get_pdu_session_id();
//Step 2. check the validity of the UE request, if valid send PDU Session Accept, otherwise send PDU Session Reject to AMF
if (!verify_sm_context_request(smreq)) {
......@@ -853,9 +853,8 @@ void smf_context::handle_pdu_session_create_sm_context_request(
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(
sm_context_req_msg,
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED);
......@@ -876,13 +875,13 @@ void smf_context::handle_pdu_session_create_sm_context_request(
std::shared_ptr<itti_n11_create_sm_context_response> sm_context_resp_pending =
std::shared_ptr<itti_n11_create_sm_context_response>(sm_context_resp);
sm_context_resp->res.set_supi(supi);
sm_context_resp->res.set_supi_prefix(sm_context_req_msg.get_supi_prefix());
sm_context_resp->res.set_supi_prefix(smreq->req.get_supi_prefix());
sm_context_resp->res.set_cause(REQUEST_ACCEPTED);
sm_context_resp->res.set_pdu_session_id(pdu_session_id);
sm_context_resp->res.set_snssai(snssai);
sm_context_resp->res.set_dnn(dnn);
sm_context_resp->res.set_pdu_session_type(
sm_context_req_msg.get_pdu_session_type());
smreq->req.get_pdu_session_type());
sm_context_resp->res.set_pti(smreq->req.get_pti());
sm_context_resp->set_scid(smreq->scid);
......@@ -912,11 +911,10 @@ void smf_context::handle_pdu_session_create_sm_context_request(
if (nullptr == sp.get()) {
Logger::smf_app().debug("Create a new PDN connection!");
//create a new pdu session
sp = std::shared_ptr<smf_pdu_session>(new smf_pdu_session());
sp.get()->pdn_type.pdn_type = sm_context_req_msg.get_pdu_session_type();
sp.get()->pdn_type.pdn_type = smreq->req.get_pdu_session_type();
sp.get()->pdu_session_id = pdu_session_id;
sp.get()->amf_id = sm_context_req_msg.get_serving_nf_id(); //amf id
sp.get()->amf_id = smreq->req.get_serving_nf_id(); //amf id
sd->insert_pdu_session(sp);
} else {
Logger::smf_app().debug("PDN connection is already existed!");
......@@ -952,7 +950,6 @@ void smf_context::handle_pdu_session_create_sm_context_request(
.ci_ip_address_allocation_via_nas_signalling = 0,
.ci_ipv4_address_allocation_via_dhcpv4 = 0,
.ci_ipv4_link_mtu_request = 0 };
//smf_app_inst->process_pco_request(extended_protocol_options, pco_resp, pco_ids);
//Step 7. Address allocation based on PDN type
......@@ -1018,7 +1015,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
smf_n1_n2_inst.create_n1_sm_container(
sm_context_req_msg, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE);
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_create_sm_context_response(
......@@ -1054,10 +1051,9 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// std::string smContextRef = sm_context_req_msg.get_supi_prefix() + "-" + smf_supi_to_string(sm_context_req_msg.get_supi());
std::string smContextRef = std::to_string(smreq->scid);
//headers: Location: contains the URI of the newly created resource, according to the structure: {apiRoot}/nsmf-pdusession/{apiVersion}/sm-contexts/{smContextRef}
std::string uri = sm_context_req_msg.get_api_root() + "/"
std::string uri = smreq->req.get_api_root() + "/"
+ smContextRef.c_str();
//TODO: disable two following lines to test PDU SESSION ESTABLISHMENT ACCEPT
sm_context_resp->http_response.headers()
.add<Pistache::Http::Header::Location>(uri);
smf_n11_inst->send_pdu_session_create_sm_context_response(
......@@ -1280,6 +1276,15 @@ void smf_context::handle_pdu_session_update_sm_context_request(
*/
//See section 6.4.2 - UE-requested PDU Session modification procedure@ 3GPP TS 24.501
//PDU Session Identity
//check if the PDU Session Release Command is already sent for this message (see section 6.3.3.5 @3GPP TS 24.501)
if (sp.get()->get_pdu_session_status() == pdu_session_status_e::PDU_SESSION_INACTIVE_PENDING) {
//Ignore the message
Logger::smf_app().info("A PDU Session Release Command has been sent for this session (session ID %d), ignore the message!",
decoded_nas_msg.plain.sm.header.pdu_session_identity);
return;
}
//PTI
Logger::smf_app().info(
"PTI %d",
......@@ -1440,6 +1445,30 @@ void smf_context::handle_pdu_session_update_sm_context_request(
!= decoded_nas_msg.plain.sm.header.pdu_session_identity) {
//TODO: PDU Session ID mismatch
}
//Abnormal cases in network side (see section 6.4.3.6 @3GPP TS 24.501)
if (sp.get()->get_pdu_session_status() == pdu_session_status_e::PDU_SESSION_INACTIVE) {
Logger::smf_app().warn("PDU Session status: INACTIVE, send PDU Session Release Reject to UE!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE]); //TODO: which cause?
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
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);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
}
//Abnormal cases in network side (see section 6.3.3.5 @3GPP TS 24.501)
if (sp.get()->get_pdu_session_status() == pdu_session_status_e::PDU_SESSION_INACTIVE_PENDING) {
//Ignore the message
Logger::smf_app().info("A PDU Session Release Command has been sent for this session (session ID %d), ignore the message!",
decoded_nas_msg.plain.sm.header.pdu_session_identity);
return;
}
//PTI
Logger::smf_app().info(
"PTI %d",
......@@ -1457,11 +1486,23 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//find DNN context
std::shared_ptr<dnn_context> sd = { };
if ((!find_dnn_context(sm_context_req_msg.get_snssai(),
sm_context_req_msg.get_dnn(), sd))
or (nullptr == sd.get())) {
//TODO: error cannot find the associated DNN context
Logger::smf_app().warn("Could not find the context for this PDU session");
//create PDU Session Release Reject and send to UE
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);
smf_n1_n2_inst.create_n1_sm_container(
sm_context_req_msg, PDU_SESSION_RELEASE_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_111_PROTOCOL_ERROR_UNSPECIFIED);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
return;
}
......@@ -1470,7 +1511,21 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if ((!sd.get()->find_pdu_session(
sm_context_req_msg.get_pdu_session_id(), ss))
or (nullptr == ss.get())) {
//TODO: error cannot find the corresponding PDU Session
Logger::smf_app().warn("Could not find the context for this PDU session");
//create PDU Session Release Reject and send to UE
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);
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);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
return;
}
//get the associated QoS flows: to be used for PFCP Session Modification procedure
......@@ -1482,8 +1537,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//need to update UPF accordingly
update_upf = true;
//TODO:
}
break;
......@@ -1837,7 +1890,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
Pistache::Http::Code::Forbidden);
return;
}
......
......@@ -192,7 +192,7 @@ void smf_n11::send_n1n2_message_transfer_request(
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
Logger::smf_n11().error("Could not get the cause from the response");
Logger::smf_n11().warn("Could not get the cause from the response");
//Set the default Cause
response_data["cause"] = "504 Gateway Timeout";
}
......
......@@ -109,7 +109,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//Extended Protocol Discriminator
sm_msg->header.extended_protocol_discriminator =
EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
//Message Type
//PDU Session Identity
sm_msg->header.pdu_session_identity = msg.get_pdu_session_id();
switch (n1_msg_type) {
......@@ -131,7 +131,6 @@ 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();
//TODO: to be completed
//get the default QoS profile and assign to the NAS message
......@@ -156,7 +155,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
sm_msg->header.procedure_transaction_identity,
sm_msg->header.message_type);
//Fill the content of PDU Session Establishment Request message
//Fill the content of PDU Session Establishment Accept message
//PDU Session Type
sm_msg->pdu_session_establishment_accept._pdusessiontype
.pdu_session_type_value = sm_context_res.get_pdu_session_type();
......@@ -277,10 +276,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
.get_snssai().sST;
try {
sm_msg->pdu_session_establishment_accept.snssai.sd = std::stoi(
sm_context_res.get_snssai().sD);
sm_msg->pdu_session_establishment_accept.snssai.sd = std::stoul(sm_context_res.get_snssai().sD, nullptr, 16);
} catch (const std::exception &e) {
Logger::smf_app().warn("Error when converting from string to int for snssai.SD, error: %s", e.what());
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, error: %s",
e.what());
//"no SD value associated with the SST"
sm_msg->pdu_session_establishment_accept.snssai.sd = 0xFFFFFF;
}
......@@ -358,7 +359,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//1 - PDU Session Create SM Context Response (PDU Session Establishment procedure - reject)
//2 - N1N2MessageTransfer Request (PDU Session Establishment procedure - reject)
//3- PDU Session Update SM Context Response (PDU Session Establishment procedure - reject)​
//PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE or PDU_SESSION_CREATE_SM_CONTEXT_REQUEST
//PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE or PDU_SESSION_CREATE_SM_CONTEXT_REQUEST
Logger::smf_app().info(
"PDU_SESSION_ESTABLISHMENT_REJECT, encode starting...");
......@@ -386,7 +387,8 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
sm_msg->pdu_session_establishment_reject._5gsmcause =
static_cast<uint8_t>(sm_cause);
//Presence
sm_msg->pdu_session_establishment_reject.presence = 0x00;
sm_msg->pdu_session_establishment_reject.presence =
PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_PRESENCE; //Should be updated according to the following IEs
/*
//GPRSTimer3
sm_msg->pdu_session_establishment_reject.gprstimer3.unit =
......@@ -436,8 +438,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
.is_ssc2_allowed,
sm_msg->pdu_session_establishment_reject.allowedsscmode
.is_ssc3_allowed);
//Logger::smf_app().debug("SM MSG, GPSR Timer3, unit: 0x%x, value: 0x%x",sm_msg->pdu_session_establishment_reject.gprstimer3.unit,sm_msg->pdu_session_establishment_reject.gprstimer3.timeValue);
//Logger::smf_app().debug("SM MSG, 5G SM Congestion Re-attempt Indicator: 0x%x",sm_msg->pdu_session_establishment_reject._5gsmcongestionreattemptindicator.abo);
//Encode NAS message
bytes = nas_message_encode(data, &nas_msg,
......@@ -480,8 +480,8 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//Presence
sm_msg->pdu_session_modification_command.presence = 0xff; //TODO: to be updated
//5GSMCause
sm_msg->pdu_session_modification_command._5gsmcause = sm_context_res
.get_cause();
sm_msg->pdu_session_modification_command._5gsmcause =
static_cast<uint8_t>(sm_cause); //sm_context_res.get_cause();
//SessionAMBR
//TODO: get from subscription DB
......@@ -590,7 +590,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//this IE is included in the following message
//1 - PDU Session Update SM Context Response (PDU Session Release UE-Initiated, step 1)
//2 - N1N2MessageTransfer Request (PDU Session Release SMF-Requested, step 1)
//TODO: to be completed
Logger::smf_app().debug(
"[Create N1 SM Message] PDU Session Release Command");
......@@ -599,26 +598,68 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
static_cast<pdu_session_update_sm_context_response&>(msg);
Logger::smf_app().info("PDU_SESSION_RELEASE_COMMAND, encode starting...");
//Fill the content of PDU Session Release Command (with hardcoded values)
//Message Type
sm_msg->header.message_type = PDU_SESSION_RELEASE_COMMAND;
//Fill the content of PDU Session Release Command
//PDU Session ID
sm_msg->header.pdu_session_identity = sm_context_res.get_pdu_session_id();
//PTI
sm_msg->header.procedure_transaction_identity = sm_context_res.get_pti()
.procedure_transaction_id;
//PDU Session Type
sm_msg->pdu_session_release_command.messagetype = sm_context_res
.get_msg_type();
//Message Type
sm_msg->header.message_type = PDU_SESSION_RELEASE_COMMAND;
//5GSMCause
sm_msg->pdu_session_release_command._5gsmcause =
sm_context_res.get_cause();
static_cast<uint8_t>(sm_cause); //sm_context_res.get_cause();
//Presence
sm_msg->pdu_session_modification_command.presence = 0x00; //TODO: to be updated
sm_msg->pdu_session_release_command.presence = 0x00; //TODO: to be updated when adding the following IEs
//GPRSTimer3
//EAPMessage
//_5GSMCongestionReattemptIndicator
// ExtendedProtocolConfigurationOptions
Logger::smf_app().debug("SM MSG, 5GSM Cause: 0x%x, %d",
sm_msg->pdu_session_release_command._5gsmcause,
static_cast<uint8_t>(sm_cause));
//Encode NAS message
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
}
break;
case PDU_SESSION_RELEASE_REJECT: {
//This IE is included in the PDU Session Update SM Context Response (PDU Session Release UE-Initiated, step 1)
Logger::smf_app().debug(
"[Create N1 SM Message] PDU Session Release Reject");
Logger::smf_app().info("PDU_SESSION_RELEASE_REJECT, encode starting...");
pdu_session_update_sm_context_response &sm_context_res =
static_cast<pdu_session_update_sm_context_response&>(msg);
//Fill the content of PDU Session Release Reject
//PDU Session ID
sm_msg->header.pdu_session_identity = sm_context_res.get_pdu_session_id();
//PTI
sm_msg->header.procedure_transaction_identity = sm_context_res.get_pti()
.procedure_transaction_id;
//Message Type
sm_msg->header.message_type = PDU_SESSION_RELEASE_REJECT;
//5GSMCause
sm_msg->pdu_session_release_reject._5gsmcause =
static_cast<uint8_t>(sm_cause); //sm_context_res.get_cause();
//Presence
sm_msg->pdu_session_release_command.presence = 0x00; //TODO: to be updated when adding the following IE
//Extended protocol configuration options
//Encode NAS message
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
......@@ -1520,8 +1561,8 @@ int smf_n1_n2::decode_n2_sm_information(
//Ngap_PDUSessionResourceModifyResponseTransfer
asn_dec_rval_t rc = asn_decode(
nullptr, ATS_ALIGNED_CANONICAL_PER,
&asn_DEF_Ngap_PDUSessionResourceReleaseResponseTransfer, (void**) &ngap_IE,
(void*) data, data_len);
&asn_DEF_Ngap_PDUSessionResourceReleaseResponseTransfer,
(void**) &ngap_IE, (void*) data, data_len);
//free memory
free_wrapper((void**) &data);
......@@ -1535,4 +1576,3 @@ int smf_n1_n2::decode_n2_sm_information(
}
......@@ -127,6 +127,8 @@ int main(int argc, char* argv[]) {
SubscriptionsCollectionDocumentApiImpl SubscriptionsCollectionDocumentApiserver(router);
SubscriptionsCollectionDocumentApiserver.init();
std::cout << "AMF server is listening on address: " << amf_ip_address.c_str() << std::endl;
httpEndpoint->setHandler(router->handler());
httpEndpoint->serve();
......
......@@ -77,6 +77,7 @@ enum class multipart_related_content_part_e {
NGAP = 2
};
//------------------------------------------------------------------------------
unsigned char* format_string_as_hex(std::string str) {
unsigned int str_len = str.length();
char *data = (char*) malloc(str_len + 1);
......@@ -108,8 +109,8 @@ void create_multipart_related_content(std::string &body, std::string &json_part,
std::string &n2_message) {
//format string as hex
unsigned char *n1_msg_hex = format_string_as_hex(n1_message);
unsigned char *n2_msg_hex = format_string_as_hex(n2_message);
//unsigned char *n1_msg_hex = format_string_as_hex(n1_message);
//unsigned char *n2_msg_hex = format_string_as_hex(n2_message);
std::string CRLF = "\r\n";
body.append("--" + boundary + CRLF);
......@@ -122,15 +123,16 @@ void create_multipart_related_content(std::string &body, std::string &json_part,
"Content-Type: application/vnd.3gpp.5gnas" + CRLF + "Content-Id: n1SmMsg"
+ CRLF);
body.append(CRLF);
body.append(std::string((char*) n1_msg_hex, n1_message.length() / 2) + CRLF);
//body.append(n1_message + CRLF);
//body.append(std::string((char*) n1_msg_hex, n1_message.length() / 2) + CRLF);
body.append(n1_message + CRLF);
body.append("--" + boundary + CRLF);
body.append(
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2SmMsg"
+ CRLF);
body.append(CRLF);
body.append(std::string((char*) n2_msg_hex, n2_message.length() / 2) + CRLF);
//body.append(std::string((char*) n2_msg_hex, n2_message.length() / 2) + CRLF);
body.append(n2_message + CRLF);
body.append("--" + boundary + "--" + CRLF);
}
......@@ -164,6 +166,7 @@ void create_multipart_related_content(
body.append("--" + boundary + "--" + CRLF);
}
//------------------------------------------------------------------------------
void send_pdu_session_establishment_request(std::string smf_ip_address) {
std::cout << "[AMF N11] PDU Session Establishment Request (SM Context Create)"
<< std::endl;
......@@ -270,6 +273,7 @@ void send_pdu_session_establishment_request(std::string smf_ip_address) {
free(buffer);
}
//------------------------------------------------------------------------------
void send_pdu_session_update_sm_context_establishment(
std::string smf_ip_address) {
std::cout << "[AMF N11] PDU Session Establishment Request (SM Context Update)"
......@@ -379,6 +383,7 @@ void send_pdu_session_update_sm_context_establishment(
free(buffer);
}
//------------------------------------------------------------------------------
void send_pdu_session_release_request(std::string smf_ip_address) {
std::cout << "[AMF N11] PDU Session Release Request (SM Context Update)"
......@@ -471,6 +476,7 @@ void send_pdu_session_release_request(std::string smf_ip_address) {
free(buffer);
}
//------------------------------------------------------------------------------
void send_pdu_session_release_resource_release_ack(
std::string smf_ip_address) {
......@@ -559,6 +565,7 @@ void send_pdu_session_release_resource_release_ack(
free(buffer);
}
//------------------------------------------------------------------------------
void send_pdu_session_release_complete(std::string smf_ip_address) {
std::cout
......@@ -653,6 +660,7 @@ void send_pdu_session_release_complete(std::string smf_ip_address) {
free(buffer);
}
//------------------------------------------------------------------------------
int main(int argc, char *argv[]) {
std::string smf_ip_address;
......
......@@ -46,7 +46,7 @@ void SessionManagementSubscriptionDataRetrievalApiImpl::get_sm_data(const std::s
jsonData["singleNssai"]["sd"] = 123;
jsonData["dnnConfigurations"]["default"]["pduSessionTypes"]["defaultSessionType"] = "IPV4";
jsonData["dnnConfigurations"]["default"]["sscModes"]["defaultSscMode"] = "SSC_MODE_1";
jsonData["dnnConfigurations"]["default"]["5gQosProfile"]["5qi"] = 61;
jsonData["dnnConfigurations"]["default"]["5gQosProfile"]["5qi"] = 60;
jsonData["dnnConfigurations"]["default"]["5gQosProfile"]["arp"]["priorityLevel"] = 1;
jsonData["dnnConfigurations"]["default"]["5gQosProfile"]["arp"]["preemptCap"] = "NOT_PREEMPT";
jsonData["dnnConfigurations"]["default"]["5gQosProfile"]["arp"]["preemptVuln"] = "NOT_PREEMPTABLE";
......@@ -55,7 +55,7 @@ void SessionManagementSubscriptionDataRetrievalApiImpl::get_sm_data(const std::s
jsonData["dnnConfigurations"]["carrier.com"]["pduSessionTypes"]["defaultSessionType"] = "IPV4";
jsonData["dnnConfigurations"]["carrier.com"]["sscModes"]["defaultSscMode"] = "SSC_MODE_1";
jsonData["dnnConfigurations"]["carrier.com"]["5gQosProfile"]["5qi"] = 60;
jsonData["dnnConfigurations"]["carrier.com"]["5gQosProfile"]["5qi"] = 61;
jsonData["dnnConfigurations"]["carrier.com"]["5gQosProfile"]["arp"]["priorityLevel"] = 1;
jsonData["dnnConfigurations"]["carrier.com"]["5gQosProfile"]["arp"]["preemptCap"] = "NOT_PREEMPT";
jsonData["dnnConfigurations"]["carrier.com"]["5gQosProfile"]["arp"]["preemptVuln"] = "NOT_PREEMPTABLE";
......
......@@ -117,7 +117,6 @@ int main(int argc, char* argv[]) {
opts.flags(Pistache::Tcp::Options::ReuseAddr);
opts.maxPayload(PISTACHE_SERVER_MAX_PAYLOAD);
httpEndpoint->init(opts);
AccessAndMobilitySubscriptionDataRetrievalApiImpl AccessAndMobilitySubscriptionDataRetrievalApiserver(router);
AccessAndMobilitySubscriptionDataRetrievalApiserver.init();
......@@ -160,9 +159,12 @@ int main(int argc, char* argv[]) {
UEContextInSMSFDataRetrievalApiImpl UEContextInSMSFDataRetrievalApiserver(router);
UEContextInSMSFDataRetrievalApiserver.init();