Commit 6bbbb056 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Use 1 common promise/future for Create/Update/Release SM Context

parent 06729cf0
...@@ -65,15 +65,13 @@ void IndividualSMContextApiImpl::release_sm_context( ...@@ -65,15 +65,13 @@ void IndividualSMContextApiImpl::release_sm_context(
xgpp_conv::sm_context_release_from_openapi( xgpp_conv::sm_context_release_from_openapi(
smContextReleaseMessage, sm_context_req_msg); smContextReleaseMessage, sm_context_req_msg);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_release_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_release_sm_context_response> >();
boost::shared_future<smf::pdu_session_release_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -88,19 +86,21 @@ void IndividualSMContextApiImpl::release_sm_context( ...@@ -88,19 +86,21 @@ void IndividualSMContextApiImpl::release_sm_context(
boost::future_status status; boost::future_status status;
// wait for timeout or ready // wait for timeout or ready
status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS)); status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
int http_code = 408; // TODO: Request_Timeout
if (status == boost::future_status::ready) { if (status == boost::future_status::ready) {
assert(f.is_ready()); assert(f.is_ready());
assert(f.has_value()); assert(f.has_value());
assert(!f.has_exception()); assert(!f.has_exception());
// Wait for the result from APP and send reply to NF consumer (e.g., AMF) // Wait for the result from APP and send reply to NF consumer (e.g., AMF)
smf::pdu_session_release_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
// TODO: Process the response // TODO: Process the response
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
} else {
response.send(Pistache::Http::Code::Request_Timeout);
} }
response.send(Pistache::Http::Code(http_code));
} }
void IndividualSMContextApiImpl::retrieve_sm_context( void IndividualSMContextApiImpl::retrieve_sm_context(
...@@ -128,15 +128,13 @@ void IndividualSMContextApiImpl::update_sm_context( ...@@ -128,15 +128,13 @@ void IndividualSMContextApiImpl::update_sm_context(
xgpp_conv::sm_context_update_from_openapi( xgpp_conv::sm_context_update_from_openapi(
smContextUpdateMessage, sm_context_req_msg); smContextUpdateMessage, sm_context_req_msg);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_update_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_update_sm_context_response> >();
boost::shared_future<smf::pdu_session_update_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -156,40 +154,65 @@ void IndividualSMContextApiImpl::update_sm_context( ...@@ -156,40 +154,65 @@ void IndividualSMContextApiImpl::update_sm_context(
assert(f.has_value()); assert(f.has_value());
assert(!f.has_exception()); assert(!f.has_exception());
// Wait for the result from APP and send reply to NF consumer (e.g., AMF) // Wait for the result from APP and send reply to NF consumer (e.g., AMF)
smf::pdu_session_update_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string body = {}; std::string body = {};
std::string json_format; std::string json_format;
bool n1_sm_msg_is_set = false;
bool n2_sm_info_is_set = false;
int http_code = 408; // TODO: Request_Timeout
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
if (sm_context_response.find("json_format") != sm_context_response.end()) {
json_format = sm_context_response["json_format"].get<std::string>();
}
if (sm_context_response.find("json_data") != sm_context_response.end()) {
json_data = sm_context_response["json_data"];
}
if (sm_context_response.find("n1_sm_message") !=
sm_context_response.end()) {
// json_data = sm_context_response["n1_sm_message"].get<std::string>();
n1_sm_msg_is_set = true;
}
sm_context_response.get_json_format(json_format); if (sm_context_response.find("n2_sm_information") !=
sm_context_response.get_json_data(json_data); sm_context_response.end()) {
n2_sm_info_is_set = true;
}
// sm_context_response.get_json_format(json_format);
// sm_context_response.get_json_data(json_data);
Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str()); Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str());
if (sm_context_response.n1_sm_msg_is_set() and if (n1_sm_msg_is_set and n2_sm_info_is_set) {
sm_context_response.n2_sm_info_is_set()) {
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,
sm_context_response.get_n1_sm_message(), sm_context_response["n1_sm_message"].get<std::string>(),
sm_context_response.get_n2_sm_information(), json_format); sm_context_response["n2_sm_information"].get<std::string>(),
json_format);
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + "multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY))); std::string(CURL_MIME_BOUNDARY)));
} else if (sm_context_response.n1_sm_msg_is_set()) { } else if (n1_sm_msg_is_set) {
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,
sm_context_response.get_n1_sm_message(), sm_context_response["n1_sm_message"].get<std::string>(),
multipart_related_content_part_e::NAS, json_format); multipart_related_content_part_e::NAS, json_format);
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + "multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY))); std::string(CURL_MIME_BOUNDARY)));
} else if (sm_context_response.n2_sm_info_is_set()) { } else if (n2_sm_info_is_set) {
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,
sm_context_response.get_n2_sm_information(), sm_context_response["n2_sm_information"].get<std::string>(),
multipart_related_content_part_e::NGAP, json_format); multipart_related_content_part_e::NGAP, json_format);
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( Pistache::Http::Mime::MediaType(
...@@ -200,12 +223,10 @@ void IndividualSMContextApiImpl::update_sm_context( ...@@ -200,12 +223,10 @@ void IndividualSMContextApiImpl::update_sm_context(
Pistache::Http::Mime::MediaType(json_format)); Pistache::Http::Mime::MediaType(json_format));
body = json_data.dump().c_str(); body = json_data.dump().c_str();
} else { } else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code())); response.send(Pistache::Http::Code(http_code));
return; return;
} }
response.send(Pistache::Http::Code(http_code), body);
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
} else { } else {
response.send(Pistache::Http::Code::Request_Timeout); response.send(Pistache::Http::Code::Request_Timeout);
} }
......
...@@ -94,9 +94,6 @@ class IndividualSMContextApiImpl ...@@ -94,9 +94,6 @@ class IndividualSMContextApiImpl
std::string m_address; std::string m_address;
protected: protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
}; };
} // namespace api } // namespace api
......
...@@ -84,15 +84,13 @@ void SMContextsCollectionApiImpl::post_sm_contexts( ...@@ -84,15 +84,13 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
m_address + base + smf_cfg.sbi_api_version + m_address + base + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL); NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_create_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_create_sm_context_response> >();
boost::shared_future<smf::pdu_session_create_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -112,40 +110,61 @@ void SMContextsCollectionApiImpl::post_sm_contexts( ...@@ -112,40 +110,61 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
assert(f.has_value()); assert(f.has_value());
assert(!f.has_exception()); assert(!f.has_exception());
// Wait for the result from APP and send reply to AMF // Wait for the result from APP and send reply to AMF
smf::pdu_session_create_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string json_format = {}; std::string json_format = {};
std::string body = {}; std::string body = {};
bool n1_sm_msg_is_set = false;
sm_context_response.get_json_data(json_data); // sm_context_response.get_json_data(json_data);
sm_context_response.get_json_format(json_format); // sm_context_response.get_json_format(json_format);
if (sm_context_response.n1_sm_msg_is_set()) { // add N1 container if int http_code = 408; // TODO: Request_Timeout
// available if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
if (sm_context_response.find("json_format") != sm_context_response.end()) {
json_format = sm_context_response["json_format"].get<std::string>();
}
if (sm_context_response.find("json_data") != sm_context_response.end()) {
json_data = sm_context_response["json_data"];
}
if (sm_context_response.find("n1_sm_message") !=
sm_context_response.end()) {
// json_data = sm_context_response["n1_sm_message"].get<std::string>();
n1_sm_msg_is_set = true;
}
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,
sm_context_response.get_n1_sm_message(), sm_context_response["n1_sm_message"].get<std::string>(),
multipart_related_content_part_e::NAS, json_format); multipart_related_content_part_e::NAS, json_format);
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( Pistache::Http::Mime::MediaType(
"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>( response.headers().add<Pistache::Http::Header::Location>(
sm_context_response.get_smf_context_uri()); // Location header 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();
} else { // otherwise, send reply without content } else { // otherwise, send reply without content
response.send(Pistache::Http::Code(sm_context_response.get_http_code())); response.send(Pistache::Http::Code(http_code));
return; return;
} }
response.send( response.send(Pistache::Http::Code(http_code), body);
Pistache::Http::Code(sm_context_response.get_http_code()), body);
} else { } else {
response.send(Pistache::Http::Code::Request_Timeout); response.send(Pistache::Http::Code::Request_Timeout);
} }
......
...@@ -79,9 +79,6 @@ class SMContextsCollectionApiImpl ...@@ -79,9 +79,6 @@ class SMContextsCollectionApiImpl
std::string m_address; std::string m_address;
protected: protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
}; };
} // namespace api } // namespace api
......
...@@ -77,9 +77,6 @@ class SubscriptionsCollectionApiImpl ...@@ -77,9 +77,6 @@ class SubscriptionsCollectionApiImpl
std::string m_address; std::string m_address;
protected: protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
}; };
} // namespace api } // namespace api
......
...@@ -373,15 +373,13 @@ void smf_http2_server::create_sm_contexts_handler( ...@@ -373,15 +373,13 @@ void smf_http2_server::create_sm_contexts_handler(
NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL); NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_create_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_create_sm_context_response> >();
boost::shared_future<smf::pdu_session_create_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -394,27 +392,46 @@ void smf_http2_server::create_sm_contexts_handler( ...@@ -394,27 +392,46 @@ void smf_http2_server::create_sm_contexts_handler(
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
// Wait for the result from APP and send reply to AMF // Wait for the result from APP and send reply to AMF
smf::pdu_session_create_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
nlohmann::json json_data = {}; nlohmann::json json_data = {};
sm_context_response.get_json_data(json_data); std::string json_format = {};
std::string json_format; bool n1_sm_msg_is_set = false;
sm_context_response.get_json_format(json_format); int http_code = 408; // TODO: Request_Timeout
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
if (sm_context_response.find("json_format") != sm_context_response.end()) {
json_format = sm_context_response["json_format"].get<std::string>();
}
if (sm_context_response.find("json_data") != sm_context_response.end()) {
json_data = sm_context_response["json_data"];
}
if (sm_context_response.find("n1_sm_message") != sm_context_response.end()) {
// json_data = sm_context_response["n1_sm_message"].get<std::string>();
n1_sm_msg_is_set = true;
}
// Add header // Add header
header_map h; header_map h;
// Location header // Location header
if (sm_context_response.get_smf_context_uri().size() > 0) { if (sm_context_response.find("smf_context_uri") !=
sm_context_response.end()) {
Logger::smf_api_server().debug( Logger::smf_api_server().debug(
"Add location header %s", "Add location header %s",
sm_context_response.get_smf_context_uri().c_str()); sm_context_response["smf_context_uri"].get<std::string>().c_str());
h.emplace( h.emplace(
"location", "location",
header_value{sm_context_response.get_smf_context_uri().c_str()}); header_value{
sm_context_response["smf_context_uri"].get<std::string>().c_str()});
} }
// content-type header // content-type header
h.emplace("content-type", header_value{json_format}); h.emplace("content-type", header_value{json_format});
response.write_head(sm_context_response.get_http_code(), h); response.write_head(http_code, h);
response.end(json_data.dump().c_str()); response.end(json_data.dump().c_str());
} }
...@@ -438,15 +455,13 @@ void smf_http2_server::update_sm_context_handler( ...@@ -438,15 +455,13 @@ void smf_http2_server::update_sm_context_handler(
xgpp_conv::sm_context_update_from_openapi( xgpp_conv::sm_context_update_from_openapi(
smContextUpdateMessage, sm_context_req_msg); smContextUpdateMessage, sm_context_req_msg);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_update_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_update_sm_context_response> >();
boost::shared_future<smf::pdu_session_update_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -459,49 +474,74 @@ void smf_http2_server::update_sm_context_handler( ...@@ -459,49 +474,74 @@ void smf_http2_server::update_sm_context_handler(
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
// Wait for the result from APP and send reply to AMF // Wait for the result from APP and send reply to AMF
smf::pdu_session_update_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string body = {}; std::string body = {};
header_map h = {}; header_map h = {};
std::string json_format = {}; std::string json_format = {};
bool n1_sm_msg_is_set = false;
bool n2_sm_info_is_set = false;
int http_code = 408; // TODO: Request_Timeout
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
if (sm_context_response.find("json_format") != sm_context_response.end()) {
json_format = sm_context_response["json_format"].get<std::string>();
}
if (sm_context_response.find("json_data") != sm_context_response.end()) {
json_data = sm_context_response["json_data"];
}
if (sm_context_response.find("n1_sm_message") != sm_context_response.end()) {
// json_data = sm_context_response["n1_sm_message"].get<std::string>();
n1_sm_msg_is_set = true;
}
if (sm_context_response.find("n2_sm_information") !=
sm_context_response.end()) {
n2_sm_info_is_set = true;
}
sm_context_response.get_json_format(json_format);
sm_context_response.get_json_data(json_data);
Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str()); Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str());
if (sm_context_response.n1_sm_msg_is_set() and if (n1_sm_msg_is_set and n2_sm_info_is_set) {
sm_context_response.n2_sm_info_is_set()) {
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,
sm_context_response.get_n1_sm_message(), sm_context_response["n1_sm_message"].get<std::string>(),
sm_context_response.get_n2_sm_information(), json_format); sm_context_response["n2_sm_information"].get<std::string>(),
json_format);
h.emplace( h.emplace(
"content-type", header_value{"multipart/related; boundary=" + "content-type",
std::string(CURL_MIME_BOUNDARY)}); header_value{
} else if (sm_context_response.n1_sm_msg_is_set()) { "multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else if (n1_sm_msg_is_set) {
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,
sm_context_response.get_n1_sm_message(), sm_context_response["n1_sm_message"].get<std::string>(),
multipart_related_content_part_e::NAS, json_format); multipart_related_content_part_e::NAS, json_format);
h.emplace( h.emplace(
"content-type", header_value{"multipart/related; boundary=" + "content-type",
std::string(CURL_MIME_BOUNDARY)}); header_value{
} else if (sm_context_response.n2_sm_info_is_set()) { "multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else if (n2_sm_info_is_set) {
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,
sm_context_response.get_n2_sm_information(), sm_context_response["n2_sm_information"].get<std::string>(),
multipart_related_content_part_e::NGAP, json_format); multipart_related_content_part_e::NGAP, json_format);
h.emplace( h.emplace(
"content-type", header_value{"multipart/related; boundary=" + "content-type",
std::string(CURL_MIME_BOUNDARY)}); header_value{
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else { } else {
h.emplace("content-type", header_value{json_format}); h.emplace("content-type", header_value{json_format});
body = json_data.dump().c_str(); body = json_data.dump().c_str();
} }
response.write_head(sm_context_response.get_http_code(), h); response.write_head(http_code, h);
response.end(body); response.end(body);
} }
...@@ -519,15 +559,13 @@ void smf_http2_server::release_sm_context_handler( ...@@ -519,15 +559,13 @@ void smf_http2_server::release_sm_context_handler(
xgpp_conv::sm_context_release_from_openapi( xgpp_conv::sm_context_release_from_openapi(
smContextReleaseMessage, sm_context_req_msg); smContextReleaseMessage, sm_context_req_msg);
boost::shared_ptr< boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::promise<smf::pdu_session_release_sm_context_response> > boost::make_shared<boost::promise<nlohmann::json> >();
p = boost::make_shared< boost::shared_future<nlohmann::json> f;
boost::promise<smf::pdu_session_release_sm_context_response> >();
boost::shared_future<smf::pdu_session_release_sm_context_response> f;
f = p->get_future(); f = p->get_future();
// Generate ID for this promise (to be used in SMF-APP) // Generate ID for this promise (to be used in SMF-APP)
uint32_t promise_id = generate_promise_id(); uint32_t promise_id = m_smf_app->generate_promise_id();
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);
...@@ -544,10 +582,15 @@ void smf_http2_server::release_sm_context_handler( ...@@ -544,10 +582,15 @@ void smf_http2_server::release_sm_context_handler(
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
// wait for the result from APP and send reply to AMF // wait for the result from APP and send reply to AMF
smf::pdu_session_release_sm_context_response sm_context_response = f.get(); nlohmann::json 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);
response.write_head(sm_context_response.get_http_code()); int http_code = 408; // TODO: Request_Timeout
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
response.write_head(http_code);
response.end(); response.end();
} }
......
...@@ -74,9 +74,6 @@ class smf_http2_server { ...@@ -74,9 +74,6 @@ class smf_http2_server {
smf::smf_app* m_smf_app; smf::smf_app* m_smf_app;
protected: protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
}; };
#endif #endif
...@@ -332,9 +332,7 @@ smf_app::smf_app(const std::string& config_file) ...@@ -332,9 +332,7 @@ smf_app::smf_app(const std::string& config_file)
: m_seid2smf_context(), : m_seid2smf_context(),
m_supi2smf_context(), m_supi2smf_context(),
m_scid2smf_context(), m_scid2smf_context(),
m_sm_context_create_promises(), m_sm_context_create_promises() {
m_sm_context_update_promises(),
m_sm_context_release_promises() {
Logger::smf_app().startup("Starting..."); Logger::smf_app().startup("Starting...");
supi2smf_context = {}; supi2smf_context = {};
...@@ -749,26 +747,16 @@ void smf_app::handle_itti_msg(itti_n11_create_sm_context_response& m) { ...@@ -749,26 +747,16 @@ void smf_app::handle_itti_msg(itti_n11_create_sm_context_response& m) {
void smf_app::handle_itti_msg(itti_n11_update_sm_context_response& m) { void smf_app::handle_itti_msg(itti_n11_update_sm_context_response& m) {
Logger::smf_app().debug( Logger::smf_app().debug(
"PDU Session Update SM Context: Set promise with ID %d to ready", m.pid); "PDU Session Update SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_update_sm_context_response sm_context_response = {}; trigger_http_response(
std::unique_lock lock(m_sm_context_update_promises); m.res.get_http_code(), m.pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
if (sm_context_update_promises.count(m.pid) > 0) {
sm_context_update_promises[m.pid]->set_value(m.res);
// Remove this promise from list
sm_context_update_promises.erase(m.pid);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_release_sm_context_response& m) { void smf_app::handle_itti_msg(itti_n11_release_sm_context_response& m) {
Logger::smf_app().debug( Logger::smf_app().debug(
"PDU Session Release SM Context: Set promise with ID %d to ready", m.pid); "PDU Session Release SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_release_sm_context_response sm_context_response = {}; trigger_http_response(
std::unique_lock lock(m_sm_context_release_promises); m.res.get_http_code(), m.pid, N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
if (sm_context_release_promises.count(m.pid) > 0) {
sm_context_release_promises[m.pid]->set_value(m.res);
// Remove this promise from list
sm_context_release_promises.erase(m.pid);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -2059,24 +2047,6 @@ void smf_app::add_promise( ...@@ -2059,24 +2047,6 @@ void smf_app::add_promise(
sm_context_create_promises.emplace(id, p); sm_context_create_promises.emplace(id, p);
} }
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_update_promises);
sm_context_update_promises.emplace(id, p);
}
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_release_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_release_promises);
sm_context_release_promises.emplace(id, p);
}
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void smf_app::add_promise( void smf_app::add_promise(
uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& p) { uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& p) {
...@@ -2152,37 +2122,30 @@ void smf_app::trigger_update_context_error_response( ...@@ -2152,37 +2122,30 @@ void smf_app::trigger_update_context_error_response(
trigger_session_update_sm_context_response(sm_context_response, promise_id); trigger_session_update_sm_context_response(sm_context_response, promise_id);
} }
//------------------------------------------------------------------------------
void smf_app::trigger_http_response(
const nlohmann::json& response_message_json, uint32_t& pid) {
Logger::smf_app().debug(
"Trigger the response from SMF: Set promise with ID %ld to ready", pid);
std::unique_lock lock(m_sbi_server_promises);
if (sbi_server_promises.count(pid) > 0) {
sbi_server_promises[pid]->set_value(response_message_json);
// Remove this promise from list
sbi_server_promises.erase(pid);
}
}
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void smf_app::trigger_http_response( void smf_app::trigger_http_response(
const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type) { const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type) {
Logger::smf_app().debug( Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of HTTP Server"); "Send ITTI msg to SMF APP to trigger the response of HTTP Server");
switch (msg_type) {
case N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE: {
pdu_session_release_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
trigger_session_release_sm_context_response(
sm_context_response, promise_id);
} break;
case N11_SESSION_CREATE_SM_CONTEXT_RESPONSE: { nlohmann::json response_message_json = {};
pdu_session_create_sm_context_response sm_context_response = {}; response_message_json["http_code"] = http_code;
sm_context_response.set_http_code(http_code);
trigger_session_create_sm_context_response(
sm_context_response, promise_id);
} break;
case N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE: {
pdu_session_update_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
trigger_session_update_sm_context_response(
sm_context_response, promise_id);
} break;
default: { trigger_http_response(response_message_json, promise_id);
Logger::smf_app().debug("Unknown message type %d", msg_type); return;
}
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -2194,12 +2157,11 @@ void smf_app::trigger_session_create_sm_context_response( ...@@ -2194,12 +2157,11 @@ void smf_app::trigger_session_create_sm_context_response(
"%d " "%d "
"to ready", "to ready",
pid); pid);
std::unique_lock lock(m_sm_context_create_promises);
if (sm_context_create_promises.count(pid) > 0) { nlohmann::json response_message_json = {};
sm_context_create_promises[pid]->set_value(sm_context_response); sm_context_response.to_json(response_message_json);
// Remove this promise from list trigger_http_response(response_message_json, pid);
sm_context_create_promises.erase(pid); return;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -2211,29 +2173,10 @@ void smf_app::trigger_session_update_sm_context_response( ...@@ -2211,29 +2173,10 @@ void smf_app::trigger_session_update_sm_context_response(
"%d " "%d "
"to ready", "to ready",
pid); pid);
std::unique_lock lock(m_sm_context_update_promises); nlohmann::json response_message_json = {};
if (sm_context_update_promises.count(pid) > 0) { sm_context_response.to_json(response_message_json);
sm_context_update_promises[pid]->set_value(sm_context_response); trigger_http_response(response_message_json, pid);
// Remove this promise from list return;
sm_context_update_promises.erase(pid);
}
}
//------------------------------------------------------------------------------
void smf_app::trigger_session_release_sm_context_response(
pdu_session_release_sm_context_response& sm_context_response,
uint32_t& pid) {
Logger::smf_app().debug(
"Trigger PDU Session Release SM Context Response: Set promise with ID "
"%d "
"to ready",
pid);
std::unique_lock lock(m_sm_context_release_promises);
if (sm_context_release_promises.count(pid) > 0) {
sm_context_release_promises[pid]->set_value(sm_context_response);
// Remove this promise from list
sm_context_release_promises.erase(pid);
}
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
......
...@@ -115,23 +115,12 @@ class smf_app { ...@@ -115,23 +115,12 @@ class smf_app {
mutable std::shared_mutex m_smf_event_subscriptions; mutable std::shared_mutex m_smf_event_subscriptions;
// Store promise IDs for Create/Update session // Store promise IDs for Create/Update session
mutable std::shared_mutex m_sm_context_create_promises; mutable std::shared_mutex m_sm_context_create_promises;
mutable std::shared_mutex m_sm_context_update_promises;
mutable std::shared_mutex m_sm_context_release_promises;
mutable std::shared_mutex m_sbi_server_promises; mutable std::shared_mutex m_sbi_server_promises;
std::map< std::map<
uint32_t, uint32_t,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>> boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>>
sm_context_create_promises; sm_context_create_promises;
std::map<
uint32_t,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>>
sm_context_update_promises;
std::map<
uint32_t, boost::shared_ptr<
boost::promise<pdu_session_release_sm_context_response>>>
sm_context_release_promises;
std::map<uint32_t, boost::shared_ptr<boost::promise<nlohmann::json>>> std::map<uint32_t, boost::shared_ptr<boost::promise<nlohmann::json>>>
sbi_server_promises; sbi_server_promises;
...@@ -729,34 +718,6 @@ class smf_app { ...@@ -729,34 +718,6 @@ class smf_app {
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>& boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>&
p); p);
/*
* To store a promise of a PDU Session Update SM Contex Response to be
* triggered when the result is ready
* @param [uint32_t] id: promise id
* @param [boost::shared_ptr<
* boost::promise<pdu_session_update_sm_context_response> >&] p: pointer to
* the promise
* @return void
*/
void add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>&
p);
/*
* To store a promise of a PDU Session Release SM Context Response to be
* triggered when the result is ready
* @param [uint32_t] id: promise id
* @param [boost::shared_ptr<
* boost::promise<pdu_session_release_sm_context_response> >&] p: pointer to
* the promise
* @return void
*/
void add_promise(
uint32_t id,
boost::shared_ptr<
boost::promise<pdu_session_release_sm_context_response>>& p);
/* /*
* To store a promise of a SBI Server response message to be * To store a promise of a SBI Server response message to be
* triggered when the result is ready * triggered when the result is ready
...@@ -769,6 +730,15 @@ class smf_app { ...@@ -769,6 +730,15 @@ class smf_app {
void add_promise( void add_promise(
uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& p); uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& p);
/*
* To generate promise ID across SMF components
* @param void
* @return generated ID
*/
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
/* /*
* To trigger the response to the HTTP server by set the value of the * To trigger the response to the HTTP server by set the value of the
* corresponding promise to ready * corresponding promise to ready
...@@ -806,6 +776,17 @@ class smf_app { ...@@ -806,6 +776,17 @@ class smf_app {
const uint32_t& http_code, const uint8_t& cause, const uint32_t& http_code, const uint8_t& cause,
const std::string& n1_sm_msg, uint32_t& promise_id); const std::string& n1_sm_msg, uint32_t& promise_id);
/*
* To trigger the response to the HTTP server by set the value of the
* corresponding promise to ready
* @param [const nlohmann::json&] response_message_json: response message in
* JSON format
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_http_response(
const nlohmann::json& response_message_json, uint32_t& pid);
/* /*
* To trigger the response to the HTTP server by set the value of the * To trigger the response to the HTTP server by set the value of the
* corresponding promise to ready * corresponding promise to ready
...@@ -841,18 +822,6 @@ class smf_app { ...@@ -841,18 +822,6 @@ class smf_app {
pdu_session_update_sm_context_response& sm_context_response, pdu_session_update_sm_context_response& sm_context_response,
uint32_t& pid); uint32_t& pid);
/*
* To trigger the session release sm context response by set the value of the
* corresponding promise to ready
* @param [pdu_session_release_sm_context_response&] sm_context_response:
* response message
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_session_release_sm_context_response(
pdu_session_release_sm_context_response& sm_context_response,
uint32_t& pid);
/* /*
* Add an Event Subscription to the list * Add an Event Subscription to the list
* @param [const evsub_id_t&] sub_id: Subscription ID * @param [const evsub_id_t&] sub_id: Subscription ID
......
...@@ -218,6 +218,85 @@ bool pdu_session_msg::n2_sm_info_type_is_set() const { ...@@ -218,6 +218,85 @@ bool pdu_session_msg::n2_sm_info_type_is_set() const {
return m_n2_sm_info_type_is_set; return m_n2_sm_info_type_is_set;
} }
//-----------------------------------------------------------------------------
void pdu_session_msg::to_json(nlohmann::json& data) const {
data["msg_type"] = m_msg_type;
data["api_root"] = m_api_root;
std::string supi_str = smf_supi_to_string(m_supi);
data["supi"] = supi_str;
data["supi_prefix"] = m_supi_prefix;
data["pdu_session_id"] = m_pdu_session_id;
data["dnn"] = m_dnn;
data["snssai"]["sst"] = m_snssai.sst;
data["snssai"]["sd"] = m_snssai.sd;
data["pdu_session_type"] = m_pdu_session_type;
data["procedure_transaction_id"] = m_pti.procedure_transaction_id;
if (m_n1_sm_msg_is_set) data["n1_sm_message"] = m_n1_sm_message;
if (m_n2_sm_info_is_set) data["n2_sm_information"] = m_n2_sm_information;
if (m_n2_sm_info_type_is_set) data["n2_sm_info_type"] = m_n2_sm_info_type;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::from_json(const nlohmann::json& data) {
if (data.find("msg_type") != data.end()) {
m_msg_type =
static_cast<pdu_session_msg_type_t>(data["msg_type"].get<int>());
}
if (data.find("api_root") != data.end()) {
m_api_root = data["api_root"].get<std::string>();
}
if (data.find("supi") != data.end()) {
smf_string_to_supi(&m_supi, data["supi"].get<std::string>().c_str());
}
if (data.find("supi_prefix") != data.end()) {
m_supi_prefix = data["supi_prefix"].get<std::string>();
}
if (data.find("pdu_session_id") != data.end()) {
m_pdu_session_id = data["pdu_session_id"].get<int>();
}
if (data.find("dnn") != data.end()) {
m_dnn = data["dnn"].get<std::string>();
}
if (data.find("snssai") != data.end()) {
if (data["snssai"].find("sst") != data["snssai"].end()) {
m_snssai.sst = data["snssai"]["sst"].get<int>();
}
}
if (data.find("snssai") != data.end()) {
if (data["snssai"].find("sd") != data["snssai"].end()) {
m_snssai.sd = data["snssai"]["sd"].get<int>();
}
}
if (data.find("pdu_session_type") != data.end()) {
m_pdu_session_type = data["pdu_session_type"].get<int>();
}
if (data.find("procedure_transaction_id") != data.end()) {
m_pti.procedure_transaction_id =
data["procedure_transaction_id"].get<int>();
}
if (data.find("n1_sm_message") != data.end()) {
m_n1_sm_message = data["n1_sm_message"].get<std::string>();
m_n1_sm_msg_is_set = true;
}
if (data.find("n2_sm_information") != data.end()) {
m_n2_sm_information = data["n2_sm_information"].get<std::string>();
m_n2_sm_info_is_set = true;
}
if (data.find("n2_sm_info_type") != data.end()) {
m_n2_sm_info_type = data["n2_sm_info_type"].get<std::string>();
m_n2_sm_info_type_is_set = true;
}
}
/* /*
* class: PDU Session SM Context Request * class: PDU Session SM Context Request
*/ */
...@@ -291,6 +370,35 @@ void pdu_session_sm_context_response::get_json_format( ...@@ -291,6 +370,35 @@ void pdu_session_sm_context_response::get_json_format(
format = m_json_format; format = m_json_format;
} }
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::to_json(nlohmann::json& data) const {
pdu_session_msg::to_json(data);
data["cause"] = m_cause;
data["json_data"] = m_json_data;
data["json_format"] = m_json_format;
data["http_code"] = m_http_code;
}
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::from_json(const nlohmann::json& data) {
pdu_session_msg::from_json(data);
if (data.find("cause") != data.end()) {
m_cause = data["cause"].get<int>();
}
if (data.find("json_data") != data.end()) {
m_json_data = data["json_data"];
}
if (data.find("json_format") != data.end()) {
m_json_format = data["json_format"];
}
if (data.find("http_code") != data.end()) {
m_http_code = data["http_code"].get<int>();
}
}
/* /*
* class: PDU Session Create SM Context Request * class: PDU Session Create SM Context Request
*/ */
...@@ -449,6 +557,31 @@ void pdu_session_create_sm_context_response::get_epco( ...@@ -449,6 +557,31 @@ void pdu_session_create_sm_context_response::get_epco(
p = m_epco; p = m_epco;
} }
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::to_json(
nlohmann::json& data) const {
pdu_session_sm_context_response::to_json(data);
// TODO: paa_t m_paa
// TODO: qos_flow_context_updated m_qos_flow_context
// TODO: protocol_configuration_options_t m_epco
data["amf_url"] = m_amf_url;
data["smf_context_uri"] = m_smf_context_uri;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::from_json(
const nlohmann::json& data) {
// TODO: paa_t m_paa
// TODO: qos_flow_context_updated m_qos_flow_context
// TODO: protocol_configuration_options_t m_epco
if (data.find("amf_url") != data.end()) {
m_amf_url = data["amf_url"].get<std::string>();
}
if (data.find("smf_context_uri") != data.end()) {
m_smf_context_uri = data["smf_context_uri"].get<std::string>();
}
}
/* /*
* class: PDU Session Update SM Context Request * class: PDU Session Update SM Context Request
*/ */
...@@ -689,6 +822,23 @@ std::string pdu_session_update_sm_context_response::get_smf_context_uri() ...@@ -689,6 +822,23 @@ std::string pdu_session_update_sm_context_response::get_smf_context_uri()
return m_smf_context_uri; return m_smf_context_uri;
} }
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_response::to_json(
nlohmann::json& data) const {
pdu_session_sm_context_response::to_json(data);
// TODO: qos_flow_context_updateds
data["smf_context_uri"] = m_smf_context_uri;
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_response::from_json(
const nlohmann::json& data) {
pdu_session_sm_context_response::from_json(data);
// TODO: qos_flow_context_updateds
if (data.find("smf_context_uri") != data.end()) {
m_smf_context_uri = data["smf_context_uri"].get<std::string>();
}
}
/* /*
* class: PDU Session Release SM Context Response * class: PDU Session Release SM Context Response
*/ */
...@@ -714,6 +864,28 @@ uint32_t pdu_session_release_sm_context_response::get_http_code() const { ...@@ -714,6 +864,28 @@ uint32_t pdu_session_release_sm_context_response::get_http_code() const {
return m_http_code; return m_http_code;
} }
//-----------------------------------------------------------------------------
void pdu_session_release_sm_context_response::to_json(
nlohmann::json& data) const {
pdu_session_msg::to_json(data);
data["cause"] = m_cause;
data["http_code"] = m_http_code;
}
//-----------------------------------------------------------------------------
void pdu_session_release_sm_context_response::from_json(
const nlohmann::json& data) {
pdu_session_msg::from_json(data);
if (data.find("cause") != data.end()) {
m_cause = data["cause"].get<int>();
}
if (data.find("http_code") != data.end()) {
m_http_code = data["http_code"].get<int>();
}
}
/* /*
* class: PDU Session Modification Network Requested * class: PDU Session Modification Network Requested
*/ */
......
...@@ -161,6 +161,9 @@ class pdu_session_msg { ...@@ -161,6 +161,9 @@ class pdu_session_msg {
void set_n2_sm_info_type(const std::string& value); void set_n2_sm_info_type(const std::string& value);
bool n2_sm_info_type_is_set() const; bool n2_sm_info_type_is_set() const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private: private:
pdu_session_msg_type_t m_msg_type; pdu_session_msg_type_t m_msg_type;
std::string m_api_root; std::string m_api_root;
...@@ -236,6 +239,9 @@ class pdu_session_sm_context_response : public pdu_session_msg { ...@@ -236,6 +239,9 @@ class pdu_session_sm_context_response : public pdu_session_msg {
void set_json_format(const std::string& format); void set_json_format(const std::string& format);
void get_json_format(std::string& format) const; void get_json_format(std::string& format) const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private: private:
uint8_t m_cause; uint8_t m_cause;
nlohmann::json m_json_data; nlohmann::json m_json_data;
...@@ -323,6 +329,9 @@ class pdu_session_create_sm_context_response ...@@ -323,6 +329,9 @@ class pdu_session_create_sm_context_response
void set_epco(const protocol_configuration_options_t& p); void set_epco(const protocol_configuration_options_t& p);
void get_epco(protocol_configuration_options_t& p) const; void get_epco(protocol_configuration_options_t& p) const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private: private:
paa_t m_paa; paa_t m_paa;
qos_flow_context_updated m_qos_flow_context; qos_flow_context_updated m_qos_flow_context;
...@@ -440,6 +449,9 @@ class pdu_session_update_sm_context_response ...@@ -440,6 +449,9 @@ class pdu_session_update_sm_context_response
void set_smf_context_uri(const std::string& value); void set_smf_context_uri(const std::string& value);
std::string get_smf_context_uri() const; std::string get_smf_context_uri() const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private: private:
std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds; std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds;
std::string m_smf_context_uri; std::string m_smf_context_uri;
...@@ -476,6 +488,9 @@ class pdu_session_release_sm_context_response : public pdu_session_msg { ...@@ -476,6 +488,9 @@ class pdu_session_release_sm_context_response : public pdu_session_msg {
void set_http_code(const uint32_t code); void set_http_code(const uint32_t code);
uint32_t get_http_code() const; uint32_t get_http_code() const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private: private:
uint8_t m_cause; uint8_t m_cause;
uint32_t m_http_code; uint32_t m_http_code;
......
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