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

update Release SM Context procedure

parent 076b8645
...@@ -87,25 +87,61 @@ void IndividualSMContextApi::setupRoutes() { ...@@ -87,25 +87,61 @@ void IndividualSMContextApi::setupRoutes() {
void IndividualSMContextApi::release_sm_context_handler( void IndividualSMContextApi::release_sm_context_handler(
const Pistache::Rest::Request &request, const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response) { Pistache::Http::ResponseWriter response) {
// Getting the path params
auto smContextRef = request.param(":smContextRef").as<std::string>();
// Getting the body param Logger::smf_api_server().debug("");
Logger::smf_api_server().info(
"Received a SM context Release request from AMF.");
Logger::smf_api_server().debug("Request body: %s\n", request.body().c_str());
SmContextReleaseMessage smContextReleaseMessage = { };
//simple parser
mime_parser sp = { };
sp.parse(request.body());
SmContextReleaseData smContextReleaseData; std::vector<mime_part> parts = { };
sp.get_mime_parts(parts);
uint8_t size = parts.size();
Logger::smf_api_server().debug("Number of MIME parts %d", size);
// Getting the body param
SmContextReleaseData smContextReleaseData = { };
try { try {
nlohmann::json::parse(request.body()).get_to(smContextReleaseData); if (size > 0) {
this->release_sm_context(smContextRef, smContextReleaseData, response); nlohmann::json::parse(parts[0].body.c_str()).get_to(smContextReleaseData);
} else {
nlohmann::json::parse(request.body().c_str()).get_to(
smContextReleaseData);
}
smContextReleaseMessage.setJsonData(smContextReleaseData);
for (int i = 1; i < size; i++) {
if (parts[i].content_type.compare("application/vnd.3gpp.ngap") == 0) {
smContextReleaseMessage.setBinaryDataN2SmInformation(parts[i].body);
Logger::smf_api_server().debug("N2 SM information is set");
}
}
// Getting the path params
auto smContextRef = request.param(":smContextRef").as<std::string>();
this->release_sm_context(smContextRef, smContextReleaseMessage, response);
} catch (nlohmann::detail::exception &e) { } catch (nlohmann::detail::exception &e) {
//send a 400 error //send a 400 error
Logger::smf_api_server().warn(
"Error in parsing json (error: %s), send a msg with a 400 error code to AMF",
e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what()); response.send(Pistache::Http::Code::Bad_Request, e.what());
return; return;
} catch (std::exception &e) { } catch (std::exception &e) {
//send a 500 error //send a 500 error
Logger::smf_api_server().warn(
"Error (%s ), send a msg with a 500 error code to AMF", e.what());
response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return; return;
} }
} }
void IndividualSMContextApi::retrieve_sm_context_handler( void IndividualSMContextApi::retrieve_sm_context_handler(
......
...@@ -98,7 +98,7 @@ class IndividualSMContextApi { ...@@ -98,7 +98,7 @@ class IndividualSMContextApi {
/// <param name="smContextReleaseData">representation of the data to be sent to the SMF when releasing the SM context (optional)</param> /// <param name="smContextReleaseData">representation of the data to be sent to the SMF when releasing the SM context (optional)</param>
virtual void release_sm_context( virtual void release_sm_context(
const std::string &smContextRef, const std::string &smContextRef,
const SmContextReleaseData &smContextReleaseData, const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response) = 0; Pistache::Http::ResponseWriter &response) = 0;
/// <summary> /// <summary>
......
...@@ -52,13 +52,41 @@ IndividualSMContextApiImpl::IndividualSMContextApiImpl( ...@@ -52,13 +52,41 @@ IndividualSMContextApiImpl::IndividualSMContextApiImpl(
void IndividualSMContextApiImpl::release_sm_context( void IndividualSMContextApiImpl::release_sm_context(
const std::string &smContextRef, const std::string &smContextRef,
const SmContextReleaseData &smContextReleaseData, const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
//TODO: to be updated as update_sm_context_handler //Get the SmContextReleaseData from this message and process in smf_app
Logger::smf_api_server().info("release_sm_context..."); Logger::smf_api_server().info(
"Received a PDUSession_ReleaseSMContext Request from AMF.");
smf::pdu_session_release_sm_context_request sm_context_req_msg = { };
SmContextReleaseData smContextReleaseData = smContextReleaseMessage
.getJsonData();
if (smContextReleaseData.n2SmInfoIsSet()) {
//N2 SM (for Session establishment)
std::string n2_sm_information = smContextReleaseMessage
.getBinaryDataN2SmInformation();
Logger::smf_api_server().debug("N2 SM Information %s",
n2_sm_information.c_str());
boost::shared_ptr<boost::promise<smf::pdu_session_release_sm_context_response> > p = std::string n2_sm_info_type = smContextReleaseData.getN2SmInfoType();
sm_context_req_msg.set_n2_sm_information(n2_sm_information);
sm_context_req_msg.set_n2_sm_info_type(n2_sm_info_type);
}
//Step 2. TODO: initialize necessary values for sm context req from smContextReleaseData
// cause:
// ngApCause:
// 5gMmCauseValue:
// ueLocation:
//ueTimeZone:
//addUeLocation:
//vsmfReleaseOnly:
//ismfReleaseOnly:
boost::shared_ptr
< boost::promise<smf::pdu_session_release_sm_context_response> > p =
boost::make_shared< boost::make_shared<
boost::promise<smf::pdu_session_release_sm_context_response> >(); boost::promise<smf::pdu_session_release_sm_context_response> >();
boost::shared_future<smf::pdu_session_release_sm_context_response> f; boost::shared_future<smf::pdu_session_release_sm_context_response> f;
...@@ -69,16 +97,11 @@ void IndividualSMContextApiImpl::release_sm_context( ...@@ -69,16 +97,11 @@ void IndividualSMContextApiImpl::release_sm_context(
Logger::smf_api_server().debug("Promise ID generated %d", promise_id); Logger::smf_api_server().debug("Promise ID generated %d", promise_id);
m_smf_app->add_promise(promise_id, p); m_smf_app->add_promise(promise_id, p);
//handle Nsmf_PDUSession_UpdateSMContext Request //Step 3. Handle the itti_n11_release_sm_context_request message in smf_app
Logger::smf_api_server().info(
"Received a PDUSession_ReleaseSMContext Request: PDU Session Release request from AMF.");
std::shared_ptr<itti_n11_release_sm_context_request> itti_msg = std::shared_ptr<itti_n11_release_sm_context_request> itti_msg =
std::make_shared<itti_n11_release_sm_context_request>(TASK_SMF_N11, std::make_shared < itti_n11_release_sm_context_request
TASK_SMF_APP, > (TASK_SMF_N11, TASK_SMF_APP, promise_id, smContextRef);
promise_id, itti_msg->req = sm_context_req_msg;
smContextRef);
itti_msg->scid = smContextRef;
itti_msg->http_version = 1; itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
...@@ -86,7 +109,9 @@ void IndividualSMContextApiImpl::release_sm_context( ...@@ -86,7 +109,9 @@ void IndividualSMContextApiImpl::release_sm_context(
smf::pdu_session_release_sm_context_response sm_context_response = f.get(); smf::pdu_session_release_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id); Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
//TODO: process the response
response.send(Pistache::Http::Code(sm_context_response.get_http_code())); response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
} }
void IndividualSMContextApiImpl::retrieve_sm_context( void IndividualSMContextApiImpl::retrieve_sm_context(
......
...@@ -76,7 +76,7 @@ class IndividualSMContextApiImpl : ...@@ -76,7 +76,7 @@ class IndividualSMContextApiImpl :
void release_sm_context( void release_sm_context(
const std::string &smContextRef, const std::string &smContextRef,
const SmContextReleaseData &smContextReleaseData, const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response); Pistache::Http::ResponseWriter &response);
void retrieve_sm_context(const std::string &smContextRef, void retrieve_sm_context(const std::string &smContextRef,
const SmContextRetrieveData &smContextRetrieveData, const SmContextRetrieveData &smContextRetrieveData,
......
...@@ -417,6 +417,15 @@ class pdu_session_release_sm_context_request : public pdu_session_msg { ...@@ -417,6 +417,15 @@ class pdu_session_release_sm_context_request : public pdu_session_msg {
} }
; ;
private: private:
//From smContextReleaseData
// cause:
// ngApCause:
// 5gMmCauseValue:
// ueLocation:
//ueTimeZone:
//addUeLocation:
//vsmfReleaseOnly:
//ismfReleaseOnly:
}; };
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
......
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