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

fix PTI mismatch, add function to decode PDUSessionResourceReleaseResponseTransfer

parent 64f0b314
......@@ -566,7 +566,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
Pistache::Http::Code::Forbidden, n1_sm_message_hex);
}
context_req_msg.set_pti(pti);
smreq->req.set_pti(pti);
//check pdu session id
if ((pdu_session_id == PDU_SESSION_IDENTITY_UNASSIGNED )
......
......@@ -47,6 +47,7 @@
extern "C" {
#include "Ngap_PDUSessionResourceSetupResponseTransfer.h"
#include "Ngap_PDUSessionResourceModifyResponseTransfer.h"
#include "Ngap_PDUSessionResourceReleaseResponseTransfer.h"
#include "Ngap_GTPTunnel.h"
#include "Ngap_AssociatedQosFlowItem.h"
#include "Ngap_QosFlowAddOrModifyResponseList.h"
......@@ -289,7 +290,7 @@ void smf_pdu_session::deallocate_ressources(const std::string &apn) {
if (ipv4) {
paa_dynamic::get_instance().release_paa(apn, ipv4_address);
}
clear(); //including qos_flows.clear()
clear(); //including qos_flows.clear()
Logger::smf_app().info(
"Resources associated with this PDU Session have been released");
}
......@@ -880,7 +881,9 @@ void smf_context::handle_pdu_session_create_sm_context_request(
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());
sm_context_resp->res.set_pdu_session_type(
sm_context_req_msg.get_pdu_session_type());
sm_context_resp->res.set_pti(smreq->req.get_pti());
sm_context_resp->set_scid(smreq->scid);
//Step 3. find pdu_session
......@@ -1450,11 +1453,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//5GSM Cause
//Extended Protocol Configuration Options
//Release the resources related to this PDU Session
//The SMF releases the IP address / Prefix(es) that were allocated to the PDU Session and releases the
//corresponding User Plane resources
//SMF releases the IP address / Prefix(es) that were allocated to the PDU Session
//Release the resources related to this PDU Session (in Procedure)
//find DNN context
std::shared_ptr<dnn_context> sd = { };
......@@ -1523,8 +1522,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
itti_inst->timer_remove(sp.get()->timer_T3592);
//send response to AMF
//Verify, do we need this?
oai::smf_server::model::SmContextCreatedData smContextCreatedData;
oai::smf_server::model::SmContextCreatedData smContextCreatedData; //Verify, do we need this?
smf_n11_inst->send_pdu_session_create_sm_context_response(
smreq->http_response, smContextCreatedData,
Pistache::Http::Code::Ok);
......@@ -1756,15 +1754,30 @@ void smf_context::handle_pdu_session_update_sm_context_request(
procedure_type =
session_management_procedures_type_e::PDU_SESSION_RELEASE_UE_REQUESTED_STEP2;
//TODO: SMF does nothing (Step 7, section 4.3.4.2@3GPP TS 23.502)
//SMF send response to AMF
//Verify, do we need this?
oai::smf_server::model::SmContextCreatedData smContextCreatedData;
//Ngap_PDUSessionResourceReleaseResponseTransfer
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> decoded_msg =
std::make_shared<Ngap_PDUSessionResourceReleaseResponseTransfer_t>();
int decode_status = smf_n1_n2_inst.decode_n2_sm_information(
decoded_msg, n2_sm_information);
if (decode_status == RETURNerror) {
Logger::smf_api_server().warn("asn_decode failed");
//send error to AMF
Logger::smf_app().warn(
"Decode N2 SM (Ngap_PDUSessionResourceReleaseResponseTransfer) failed!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR]);
smContextUpdateError.setError(problem_details);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden);
return;
}
//SMF send response to AMF
oai::smf_server::model::SmContextCreatedData smContextCreatedData; //Verify, do we need this?
smf_n11_inst->send_pdu_session_create_sm_context_response(
smreq->http_response, smContextCreatedData,
Pistache::Http::Code::Ok);
}
break;
......
......@@ -1505,3 +1505,34 @@ int smf_n1_n2::decode_n2_sm_information(
}
//---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info) {
Logger::smf_app().info(
"Decode NGAP message (Ngap_PDUSessionResourceReleaseResponseTransfer) from N2 SM Information");
unsigned int data_len = n2_sm_info.length();
unsigned char *data = (unsigned char*) malloc(data_len + 1);
memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n2_sm_info.c_str(), data_len);
//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);
//free memory
free_wrapper((void**) &data);
if (rc.code != RC_OK) {
Logger::smf_api_server().warn("asn_decode failed with code %d", rc.code);
return RETURNerror ;
}
return RETURNok ;
}
......@@ -56,6 +56,7 @@ extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceSetupResponseTransfer.h"
#include "Ngap_PDUSessionResourceModifyResponseTransfer.h"
#include "Ngap_PDUSessionResourceReleaseResponseTransfer.h"
}
namespace smf {
......@@ -121,6 +122,16 @@ class smf_n1_n2 {
std::shared_ptr<Ngap_PDUSessionResourceModifyResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceReleaseResponseTransfer_t
* @param [std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t>&] ngap_IE Store decoded NGAP message
* @param [std::string&] n2_sm_info N2 SM Information
* @return status of the decode process
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info);
};
} // namespace smf
......
......@@ -1100,6 +1100,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); //TODO: check Cause
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
smf_n1_n2_inst.create_n2_sm_information(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_REL_CMD,
......
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