Commit 9891f5a8 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix for PDU Session Create Response message

parent 0061f800
...@@ -118,9 +118,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts( ...@@ -118,9 +118,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
std::string body = {}; std::string body = {};
bool n1_sm_msg_is_set = false; bool n1_sm_msg_is_set = false;
// sm_context_response.get_json_data(json_data);
// sm_context_response.get_json_format(json_format);
int http_code = 408; // TODO: Request_Timeout int http_code = 408; // TODO: Request_Timeout
if (sm_context_response.find("http_code") != sm_context_response.end()) { if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>(); http_code = sm_context_response["http_code"].get<int>();
...@@ -139,6 +136,15 @@ void SMContextsCollectionApiImpl::post_sm_contexts( ...@@ -139,6 +136,15 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
n1_sm_msg_is_set = true; n1_sm_msg_is_set = true;
} }
if (http_code == 201) {
if (sm_context_response.find("smf_context_uri") !=
sm_context_response.end()) {
response.headers().add<Pistache::Http::Header::Location>(
sm_context_response["smf_context_uri"]
.get<std::string>()); // Location header
}
}
if (n1_sm_msg_is_set) { // add N1 container if available if (n1_sm_msg_is_set) { // add N1 container if available
mime_parser::create_multipart_related_content( mime_parser::create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY, body, json_data.dump(), CURL_MIME_BOUNDARY,
...@@ -149,13 +155,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts( ...@@ -149,13 +155,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
"multipart/related; boundary=" + "multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY))); std::string(CURL_MIME_BOUNDARY)));
} else if (!json_data.empty()) { // if not, include json data if available } else if (!json_data.empty()) { // if not, include json data if available
if (sm_context_response.find("smf_context_uri") !=
sm_context_response.end()) {
response.headers().add<Pistache::Http::Header::Location>(
sm_context_response["smf_context_uri"]
.get<std::string>()); // Location header
}
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(json_format)); Pistache::Http::Mime::MediaType(json_format));
body = json_data.dump().c_str(); body = json_data.dump().c_str();
......
...@@ -2371,3 +2371,8 @@ void smf_app::trigger_upf_status_notification_subscribe() { ...@@ -2371,3 +2371,8 @@ void smf_app::trigger_upf_status_notification_subscribe() {
itti_msg->get_msg_name()); itti_msg->get_msg_name());
} }
} }
//------------------------------------------------------------------------------
std::string smf_app::get_smf_instance_id() const {
return smf_instance_id;
}
...@@ -904,6 +904,13 @@ class smf_app { ...@@ -904,6 +904,13 @@ class smf_app {
* @return void * @return void
*/ */
void trigger_upf_status_notification_subscribe(); void trigger_upf_status_notification_subscribe();
/*
* Get the SMF instance ID
* @param [void]
* @return SMF instance ID
*/
std::string get_smf_instance_id() const;
}; };
} // namespace smf } // namespace smf
#include "smf_config.hpp" #include "smf_config.hpp"
......
...@@ -1755,8 +1755,9 @@ void smf_context::handle_pdu_session_create_sm_context_request( ...@@ -1755,8 +1755,9 @@ void smf_context::handle_pdu_session_create_sm_context_request(
cause_value_5gsm_e::CAUSE_255_REQUEST_ACCEPTED)); // TODO cause_value_5gsm_e::CAUSE_255_REQUEST_ACCEPTED)); // TODO
nlohmann::json json_data = {}; nlohmann::json json_data = {};
json_data["cause"] = 0; json_data["smfServiceInstanceId"] = smf_app_inst->get_smf_instance_id();
sm_context_response.set_json_data(json_data); sm_context_response.set_json_data(json_data);
sm_context_response.set_http_code( sm_context_response.set_http_code(
http_status_code_e::HTTP_STATUS_CODE_201_CREATED); http_status_code_e::HTTP_STATUS_CODE_201_CREATED);
......
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