Commit 2a7d22e4 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Merge branch 'ue_triggered_pdu_session_release' into fix_develop_ue_rel16

parents 1f5369cb cf63eb97
......@@ -65,15 +65,13 @@ void IndividualSMContextApiImpl::release_sm_context(
xgpp_conv::sm_context_release_from_openapi(
smContextReleaseMessage, sm_context_req_msg);
boost::shared_ptr<
boost::promise<smf::pdu_session_release_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_release_sm_context_response> >();
boost::shared_future<smf::pdu_session_release_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -88,19 +86,21 @@ void IndividualSMContextApiImpl::release_sm_context(
boost::future_status status;
// wait for timeout or ready
status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
int http_code = http_status_code_e::HTTP_STATUS_CODE_408_REQUEST_TIMEOUT;
if (status == boost::future_status::ready) {
assert(f.is_ready());
assert(f.has_value());
assert(!f.has_exception());
// 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);
if (sm_context_response.find("http_code") != sm_context_response.end()) {
http_code = sm_context_response["http_code"].get<int>();
}
// 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(
......@@ -128,15 +128,13 @@ void IndividualSMContextApiImpl::update_sm_context(
xgpp_conv::sm_context_update_from_openapi(
smContextUpdateMessage, sm_context_req_msg);
boost::shared_ptr<
boost::promise<smf::pdu_session_update_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_update_sm_context_response> >();
boost::shared_future<smf::pdu_session_update_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -156,40 +154,65 @@ void IndividualSMContextApiImpl::update_sm_context(
assert(f.has_value());
assert(!f.has_exception());
// 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);
nlohmann::json json_data = {};
std::string body = {};
std::string json_format;
bool n1_sm_msg_is_set = false;
bool n2_sm_info_is_set = false;
sm_context_response.get_json_format(json_format);
sm_context_response.get_json_data(json_data);
int http_code = http_status_code_e::HTTP_STATUS_CODE_408_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());
if (sm_context_response.n1_sm_msg_is_set() and
sm_context_response.n2_sm_info_is_set()) {
if (n1_sm_msg_is_set and n2_sm_info_is_set) {
mime_parser::create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY,
sm_context_response.get_n1_sm_message(),
sm_context_response.get_n2_sm_information(), json_format);
sm_context_response["n1_sm_message"].get<std::string>(),
sm_context_response["n2_sm_information"].get<std::string>(),
json_format);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; 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(
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);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; 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(
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);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
......@@ -200,12 +223,10 @@ void IndividualSMContextApiImpl::update_sm_context(
Pistache::Http::Mime::MediaType(json_format));
body = json_data.dump().c_str();
} else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
response.send(Pistache::Http::Code(http_code));
return;
}
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
response.send(Pistache::Http::Code(http_code), body);
} else {
response.send(Pistache::Http::Code::Request_Timeout);
}
......
......@@ -94,9 +94,6 @@ class IndividualSMContextApiImpl
std::string m_address;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
} // namespace api
......
......@@ -84,15 +84,13 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
m_address + base + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr<
boost::promise<smf::pdu_session_create_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_create_sm_context_response> >();
boost::shared_future<smf::pdu_session_create_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -112,40 +110,60 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
assert(f.has_value());
assert(!f.has_exception());
// 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);
nlohmann::json json_data = {};
std::string json_format = {};
std::string body = {};
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 = http_status_code_e::HTTP_STATUS_CODE_408_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.n1_sm_msg_is_set()) { // add N1 container if
// available
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 (http_code == http_status_code_e::HTTP_STATUS_CODE_201_CREATED) {
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
mime_parser::create_multipart_related_content(
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);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY)));
} else if (!json_data.empty()) { // if not, include json data if available
response.headers().add<Pistache::Http::Header::Location>(
sm_context_response.get_smf_context_uri()); // Location header
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(json_format));
body = json_data.dump().c_str();
} 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;
}
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
response.send(Pistache::Http::Code(http_code), body);
} else {
response.send(Pistache::Http::Code::Request_Timeout);
}
......
......@@ -79,9 +79,6 @@ class SMContextsCollectionApiImpl
std::string m_address;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
} // namespace api
......
......@@ -77,9 +77,6 @@ class SubscriptionsCollectionApiImpl
std::string m_address;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
} // namespace api
......
......@@ -373,15 +373,13 @@ void smf_http2_server::create_sm_contexts_handler(
NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr<
boost::promise<smf::pdu_session_create_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_create_sm_context_response> >();
boost::shared_future<smf::pdu_session_create_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -394,27 +392,46 @@ void smf_http2_server::create_sm_contexts_handler(
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
// 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);
nlohmann::json json_data = {};
sm_context_response.get_json_data(json_data);
std::string json_format;
sm_context_response.get_json_format(json_format);
std::string json_format = {};
bool n1_sm_msg_is_set = false;
int http_code = http_status_code_e::HTTP_STATUS_CODE_408_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
header_map h;
// 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(
"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(
"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
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());
}
......@@ -438,15 +455,13 @@ void smf_http2_server::update_sm_context_handler(
xgpp_conv::sm_context_update_from_openapi(
smContextUpdateMessage, sm_context_req_msg);
boost::shared_ptr<
boost::promise<smf::pdu_session_update_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_update_sm_context_response> >();
boost::shared_future<smf::pdu_session_update_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -459,49 +474,74 @@ void smf_http2_server::update_sm_context_handler(
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
// 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);
nlohmann::json json_data = {};
std::string body = {};
header_map h = {};
std::string json_format = {};
bool n1_sm_msg_is_set = false;
bool n2_sm_info_is_set = false;
int http_code = http_status_code_e::HTTP_STATUS_CODE_408_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());
if (sm_context_response.n1_sm_msg_is_set() and
sm_context_response.n2_sm_info_is_set()) {
if (n1_sm_msg_is_set and n2_sm_info_is_set) {
mime_parser::create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY,
sm_context_response.get_n1_sm_message(),
sm_context_response.get_n2_sm_information(), json_format);
sm_context_response["n1_sm_message"].get<std::string>(),
sm_context_response["n2_sm_information"].get<std::string>(),
json_format);
h.emplace(
"content-type", header_value{"multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY)});
} else if (sm_context_response.n1_sm_msg_is_set()) {
"content-type",
header_value{
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else if (n1_sm_msg_is_set) {
mime_parser::create_multipart_related_content(
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);
h.emplace(
"content-type", header_value{"multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY)});
} else if (sm_context_response.n2_sm_info_is_set()) {
"content-type",
header_value{
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else if (n2_sm_info_is_set) {
mime_parser::create_multipart_related_content(
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);
h.emplace(
"content-type", header_value{"multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY)});
"content-type",
header_value{
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)});
} else {
h.emplace("content-type", header_value{json_format});
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);
}
......@@ -519,15 +559,13 @@ void smf_http2_server::release_sm_context_handler(
xgpp_conv::sm_context_release_from_openapi(
smContextReleaseMessage, sm_context_req_msg);
boost::shared_ptr<
boost::promise<smf::pdu_session_release_sm_context_response> >
p = boost::make_shared<
boost::promise<smf::pdu_session_release_sm_context_response> >();
boost::shared_future<smf::pdu_session_release_sm_context_response> f;
boost::shared_ptr<boost::promise<nlohmann::json> > p =
boost::make_shared<boost::promise<nlohmann::json> >();
boost::shared_future<nlohmann::json> f;
f = p->get_future();
// 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);
m_smf_app->add_promise(promise_id, p);
......@@ -544,10 +582,15 @@ void smf_http2_server::release_sm_context_handler(
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
// 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);
response.write_head(sm_context_response.get_http_code());
int http_code = http_status_code_e::HTTP_STATUS_CODE_408_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();
}
......
......@@ -74,9 +74,6 @@ class smf_http2_server {
smf::smf_app* m_smf_app;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
#endif
......@@ -332,9 +332,7 @@ smf_app::smf_app(const std::string& config_file)
: m_seid2smf_context(),
m_supi2smf_context(),
m_scid2smf_context(),
m_sm_context_create_promises(),
m_sm_context_update_promises(),
m_sm_context_release_promises() {
m_sbi_server_promises() {
Logger::smf_app().startup("Starting...");
supi2smf_context = {};
......@@ -736,39 +734,29 @@ void smf_app::handle_itti_msg(
void smf_app::handle_itti_msg(itti_n11_create_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Create SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_create_sm_context_response sm_context_response = {};
std::unique_lock lock(m_sm_context_create_promises);
if (sm_context_create_promises.count(m.pid) > 0) {
sm_context_create_promises[m.pid]->set_value(m.res);
// Remove this promise from list
sm_context_create_promises.erase(m.pid);
}
nlohmann::json response_message_json = {};
m.res.to_json(response_message_json);
trigger_http_response(response_message_json, m.pid);
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_update_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Update SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_update_sm_context_response sm_context_response = {};
std::unique_lock lock(m_sm_context_update_promises);
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);
}
nlohmann::json response_message_json = {};
m.res.to_json(response_message_json);
trigger_http_response(response_message_json, m.pid);
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_release_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Release SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_release_sm_context_response sm_context_response = {};
std::unique_lock lock(m_sm_context_release_promises);
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);
}
nlohmann::json response_message_json = {};
m.res.to_json(response_message_json);
trigger_http_response(response_message_json, m.pid);
}
//------------------------------------------------------------------------------
......@@ -2044,37 +2032,17 @@ bool smf_app::get_session_management_subscription_data(
dnn_configuration->_5g_qos_profile.arp.preempt_vuln = "NOT_PREEMPTABLE";
dnn_configuration->_5g_qos_profile.priority_level = 1;
// Session_ambr
dnn_configuration->session_ambr.uplink = "100Mbps";
dnn_configuration->session_ambr.downlink = "100Mbps";
dnn_configuration->session_ambr.uplink = "1000Mbps";
dnn_configuration->session_ambr.downlink = "1000Mbps";
subscription->insert_dnn_configuration(dnn, dnn_configuration);
return true;
}
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_create_promises);
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);
uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& p) {
std::unique_lock lock(m_sbi_server_promises);
sbi_server_promises.emplace(id, p);
}
//---------------------------------------------------------------------------------------------
......@@ -2145,37 +2113,30 @@ void smf_app::trigger_update_context_error_response(
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(
const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type) {
Logger::smf_app().debug(
"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: {
pdu_session_create_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
trigger_session_create_sm_context_response(
sm_context_response, promise_id);
} break;
nlohmann::json response_message_json = {};
response_message_json["http_code"] = http_code;
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: {
Logger::smf_app().debug("Unknown message type %d", msg_type);
}
}
trigger_http_response(response_message_json, promise_id);
return;
}
//------------------------------------------------------------------------------
......@@ -2187,12 +2148,11 @@ void smf_app::trigger_session_create_sm_context_response(
"%d "
"to ready",
pid);
std::unique_lock lock(m_sm_context_create_promises);
if (sm_context_create_promises.count(pid) > 0) {
sm_context_create_promises[pid]->set_value(sm_context_response);
// Remove this promise from list
sm_context_create_promises.erase(pid);
}
nlohmann::json response_message_json = {};
sm_context_response.to_json(response_message_json);
trigger_http_response(response_message_json, pid);
return;
}
//------------------------------------------------------------------------------
......@@ -2204,29 +2164,10 @@ void smf_app::trigger_session_update_sm_context_response(
"%d "
"to ready",
pid);
std::unique_lock lock(m_sm_context_update_promises);
if (sm_context_update_promises.count(pid) > 0) {
sm_context_update_promises[pid]->set_value(sm_context_response);
// Remove this promise from list
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);
}
nlohmann::json response_message_json = {};
sm_context_response.to_json(response_message_json);
trigger_http_response(response_message_json, pid);
return;
}
//---------------------------------------------------------------------------------------------
......@@ -2434,3 +2375,8 @@ void smf_app::trigger_upf_status_notification_subscribe() {
itti_msg->get_msg_name());
}
}
//------------------------------------------------------------------------------
std::string smf_app::get_smf_instance_id() const {
return smf_instance_id;
}
......@@ -114,22 +114,10 @@ class smf_app {
mutable std::shared_mutex m_scid2smf_context;
mutable std::shared_mutex m_smf_event_subscriptions;
// Store promise IDs for Create/Update session
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;
std::map<
uint32_t,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>>
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>>>
sbi_server_promises;
smf_profile nf_instance_profile; // SMF profile
std::string smf_instance_id; // SMF instance id
......@@ -726,32 +714,25 @@ class smf_app {
p);
/*
* To store a promise of a PDU Session Update SM Contex Response to be
* To store a promise of a SBI Server response message 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
* boost::promise<nlohmann::json> >&] 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);
uint32_t id, boost::shared_ptr<boost::promise<nlohmann::json>>& 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
* To generate promise ID across SMF components
* @param void
* @return generated ID
*/
void add_promise(
uint32_t id,
boost::shared_ptr<
boost::promise<pdu_session_release_sm_context_response>>& p);
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
......@@ -790,6 +771,17 @@ class smf_app {
const uint32_t& http_code, const uint8_t& cause,
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
* corresponding promise to ready
......@@ -825,18 +817,6 @@ class smf_app {
pdu_session_update_sm_context_response& sm_context_response,
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
* @param [const evsub_id_t&] sub_id: Subscription ID
......@@ -924,6 +904,13 @@ class smf_app {
* @return void
*/
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
#include "smf_config.hpp"
......
This diff is collapsed.
......@@ -614,7 +614,7 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
// Subscribe to PDU Session Release (event exposure)
ee_pdu_session_release_connection =
event_sub.subscribe_ee_pdu_session_release(boost::bind(
&smf_context::handle_ee_pdu_session_release, this, _1, _2, _3));
&smf_context::handle_ee_pdu_session_release, this, _1, _2));
// Subscribe to UE IP Change Event
ee_ue_ip_change_connection = event_sub.subscribe_ee_ue_ip_change(
......@@ -885,7 +885,8 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
*/
bool handle_pdu_session_resource_release_response_transfer(
std::string& n2_sm_information,
std::shared_ptr<itti_n11_update_sm_context_request>& sm_context_request);
std::shared_ptr<itti_n11_update_sm_context_request>& sm_context_request,
std::shared_ptr<smf_pdu_session>& sp);
/*
* Handle Xn Handover Patch Switch Request
......@@ -1172,6 +1173,31 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
void get_pdu_sessions(
std::map<pdu_session_id_t, std::shared_ptr<smf_pdu_session>>& sessions);
/*
* Get PDU related information
* @param [const scid_t&] scid: SMF Context ID
* @param [supi64_t&] supi: SUPI
* @param [pdu_session_id_t&] pdu_session_id: PDU Session ID
* @return true if this Context ID exist and can get related info, otherwise,
* return false
*/
bool get_pdu_session_info(
const scid_t& scid, supi64_t& supi,
pdu_session_id_t& pdu_session_id) const;
/*
* Get PDU related information
* @param [const scid_t&] scid: SMF Context ID
* @param [supi64_t&] supi: SUPI
* @param [std::shared_ptr<smf_pdu_session>&] sp: Pointer to the PDU Session
* Info
* @return true if this Context ID exist and can get related info, otherwise,
* return false
*/
bool get_pdu_session_info(
const scid_t& scid, supi64_t& supi,
std::shared_ptr<smf_pdu_session>& sp) const;
/*
* Handle SM Context Status Change (Send notification AMF)
* @param [scid_t] scid: SMF Context ID
......@@ -1180,39 +1206,50 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
* @return void
*/
void handle_sm_context_status_change(
scid_t scid, const std::string& status, uint8_t http_version);
const scid_t& scid, const std::string& status,
const uint8_t& http_version) const;
/*
* Handle SM Context Status Change (Send notification AMF)
* Trigger PDU Session Release Notification (Send notification AMF)
* @param [scid_t] scid: SMF Context ID
* @param [uint32_t] status: Updated status
* @param [uint8_t] http_version: HTTP version
* @return void
*/
void trigger_pdu_session_release(
const scid_t& scid, const uint8_t& http_version) const;
void handle_ee_pdu_session_release(
supi64_t supi, pdu_session_id_t pdu_session_id, uint8_t http_version);
const scid_t& scid, const uint8_t& http_version) const;
void trigger_ue_ip_change(scid_t scid, uint8_t http_version);
void handle_ue_ip_change(scid_t scid, uint8_t http_version);
void trigger_ue_ip_change(
const scid_t& scid, const uint8_t& http_version) const;
void handle_ue_ip_change(
const scid_t& scid, const uint8_t& http_version) const;
void trigger_plmn_change(scid_t scid, uint8_t http_version);
void handle_plmn_change(scid_t scid, uint8_t http_version);
void trigger_plmn_change(
const scid_t& scid, const uint8_t& http_version) const;
void handle_plmn_change(
const scid_t& scid, const uint8_t& http_version) const;
void trigger_ddds(scid_t scid, uint8_t http_version);
void handle_ddds(scid_t scid, uint8_t http_version);
void trigger_ddds(const scid_t& scid, const uint8_t& http_version) const;
void handle_ddds(const scid_t& scid, const uint8_t& http_version) const;
void trigger_pdusesest(scid_t scid, uint8_t http_version);
void handle_pdusesest(scid_t scid, uint8_t http_version);
void trigger_pdusesest(const scid_t& scid, const uint8_t& http_version) const;
void handle_pdusesest(const scid_t& scid, const uint8_t& http_version) const;
void trigger_qos_monitoring(
seid_t seid, oai::smf_server::model::EventNotification ev_notif_model,
uint8_t http_version);
const seid_t& seid,
const oai::smf_server::model::EventNotification& ev_notif_model,
const uint8_t& http_version) const;
void handle_qos_monitoring(
seid_t seid, oai::smf_server::model::EventNotification ev_notif_model,
uint8_t http_version);
const seid_t& seid,
const oai::smf_server::model::EventNotification& ev_notif_model,
const uint8_t& http_version) const;
void trigger_flexcn_event(
const scid_t& scid, const uint8_t& http_version) const;
void handle_flexcn_event(
const scid_t& scid, const uint8_t& http_version) const;
void trigger_flexcn_event(scid_t scid, uint8_t http_version);
void handle_flexcn_event(scid_t scid, uint8_t http_version);
/*
* Update QoS information in the Response message according to the content of
* decoded NAS msg
......@@ -1338,7 +1375,10 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
* @param resp
*/
void send_pdu_session_release_response(
const std::shared_ptr<itti_n11_release_sm_context_response>& resp);
const std::shared_ptr<itti_n11_release_sm_context_request>& req,
const std::shared_ptr<itti_n11_release_sm_context_response>& resp,
const session_management_procedures_type_e& session_procedure_type,
const std::shared_ptr<smf_pdu_session>& sps);
private:
std::vector<std::shared_ptr<smf_procedure>> pending_procedures;
......
......@@ -46,10 +46,9 @@ typedef bs2::signal_type<
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type sm_context_status_sig_t;
// Signal for Event exposure
// PDU session Release, SUPI, PDU SessionID, HTTP version
// PDU session Release, SCID, HTTP version
typedef bs2::signal_type<
void(supi64_t, pdu_session_id_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
void(scid_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_pdu_session_release_sig_t;
// TODO: ee_ue_ip_address_change_sig_t; //UI IP Address, UE ID
......
......@@ -218,6 +218,85 @@ bool pdu_session_msg::n2_sm_info_type_is_set() const {
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
*/
......@@ -291,6 +370,35 @@ void pdu_session_sm_context_response::get_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
*/
......@@ -449,6 +557,31 @@ void pdu_session_create_sm_context_response::get_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
*/
......@@ -689,29 +822,37 @@ std::string pdu_session_update_sm_context_response::get_smf_context_uri()
return m_smf_context_uri;
}
/*
* class: PDU Session Release SM Context Response
*/
//-----------------------------------------------------------------------------
void pdu_session_release_sm_context_response::set_cause(uint8_t cause) {
m_cause = cause;
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;
}
//-----------------------------------------------------------------------------
uint8_t pdu_session_release_sm_context_response::get_cause() {
return m_cause;
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
*/
//-----------------------------------------------------------------------------
void pdu_session_release_sm_context_response::set_http_code(
const uint32_t code) {
m_http_code = code;
void pdu_session_release_sm_context_response::to_json(
nlohmann::json& data) const {
pdu_session_sm_context_response::to_json(data);
}
//-----------------------------------------------------------------------------
uint32_t pdu_session_release_sm_context_response::get_http_code() const {
return m_http_code;
void pdu_session_release_sm_context_response::from_json(
const nlohmann::json& data) {
pdu_session_sm_context_response::from_json(data);
}
/*
......
......@@ -161,6 +161,9 @@ class pdu_session_msg {
void set_n2_sm_info_type(const std::string& value);
bool n2_sm_info_type_is_set() const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private:
pdu_session_msg_type_t m_msg_type;
std::string m_api_root;
......@@ -236,6 +239,9 @@ class pdu_session_sm_context_response : public pdu_session_msg {
void set_json_format(const std::string& format);
void get_json_format(std::string& format) const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private:
uint8_t m_cause;
nlohmann::json m_json_data;
......@@ -323,6 +329,9 @@ class pdu_session_create_sm_context_response
void set_epco(const protocol_configuration_options_t& p);
void get_epco(protocol_configuration_options_t& p) const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private:
paa_t m_paa;
qos_flow_context_updated m_qos_flow_context;
......@@ -440,6 +449,9 @@ class pdu_session_update_sm_context_response
void set_smf_context_uri(const std::string& value);
std::string get_smf_context_uri() const;
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private:
std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds;
std::string m_smf_context_uri;
......@@ -464,21 +476,17 @@ class pdu_session_release_sm_context_request : public pdu_session_msg {
};
//---------------------------------------------------------------------------------------
class pdu_session_release_sm_context_response : public pdu_session_msg {
class pdu_session_release_sm_context_response
: public pdu_session_sm_context_response {
public:
pdu_session_release_sm_context_response()
: pdu_session_msg(PDU_SESSION_RELEASE_SM_CONTEXT_RESPONSE) {
m_cause = 0;
m_http_code = 0;
};
void set_cause(uint8_t cause);
uint8_t get_cause();
void set_http_code(const uint32_t code);
uint32_t get_http_code() const;
: pdu_session_sm_context_response(
PDU_SESSION_RELEASE_SM_CONTEXT_RESPONSE){};
void to_json(nlohmann::json& data) const;
void from_json(const nlohmann::json& data);
private:
uint8_t m_cause;
uint32_t m_http_code;
};
//---------------------------------------------------------------------------------------
......
......@@ -717,6 +717,71 @@ bool smf_n1::create_n1_pdu_session_release_reject(
}
}
//-----------------------------------------------------------------------------------------------------
bool smf_n1::create_n1_pdu_session_release_command(
const std::shared_ptr<pdu_session_msg>& msg, std::string& nas_msg_str,
cause_value_5gsm_e sm_cause) {
Logger::smf_n1().info("Create N1 SM Container, PDU Session Release Command");
int bytes = {0};
unsigned char data[BUF_LEN] = {'\0'};
nas_message_t nas_msg = {};
nas_msg.header.extended_protocol_discriminator =
EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED;
SM_msg* sm_msg = &nas_msg.plain.sm;
// Fill the content of SM header
sm_msg->header.extended_protocol_discriminator =
EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
sm_msg->header.pdu_session_identity = msg->get_pdu_session_id();
Logger::smf_n1().info("PDU_SESSION_RELEASE_COMMAND, encode starting...");
// Fill the content of PDU Session Release Command
sm_msg->header.pdu_session_identity = msg->get_pdu_session_id();
sm_msg->header.procedure_transaction_identity =
msg->get_pti()
.procedure_transaction_id; // TODO: if PDU session release procedure
// is not triggered by a UE-requested PDU
// session release set the PTI IE of the
// PDU SESSION RELEASE COMMAND message
// to "No procedure transaction identity
// assigned"
sm_msg->header.message_type = PDU_SESSION_RELEASE_COMMAND;
sm_msg->pdu_session_release_command._5gsmcause =
static_cast<uint8_t>(sm_cause);
// TODO: to be updated when adding the following IEs
sm_msg->pdu_session_release_command.presence = 0x00;
// GPRSTimer3
// EAPMessage
//_5GSMCongestionReattemptIndicator
// ExtendedProtocolConfigurationOptions
Logger::smf_n1().debug(
"SM message, 5GSM Cause: 0x%x",
sm_msg->pdu_session_release_command._5gsmcause);
// Encode NAS message
bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
if (bytes > 0) {
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
return true;
} else {
return false;
}
}
//-----------------------------------------------------------------------------------------------------
bool smf_n1::create_n1_pdu_session_release_command(
pdu_session_update_sm_context_response& sm_context_res,
......@@ -744,7 +809,13 @@ bool smf_n1::create_n1_pdu_session_release_command(
// Fill the content of PDU Session Release Command
sm_msg->header.pdu_session_identity = sm_context_res.get_pdu_session_id();
sm_msg->header.procedure_transaction_identity =
sm_context_res.get_pti().procedure_transaction_id;
sm_context_res.get_pti()
.procedure_transaction_id; // TODO: if PDU session release procedure
// is not triggered by a UE-requested PDU
// session release set the PTI IE of the
// PDU SESSION RELEASE COMMAND message
// to "No procedure transaction identity
// assigned"
sm_msg->header.message_type = PDU_SESSION_RELEASE_COMMAND;
sm_msg->pdu_session_release_command._5gsmcause =
static_cast<uint8_t>(sm_cause);
......
......@@ -135,6 +135,9 @@ class smf_n1 {
pdu_session_update_sm_context_request& sm_context_res,
std::string& nas_msg_str, cause_value_5gsm_e sm_cause);
bool create_n1_pdu_session_release_command(
const std::shared_ptr<pdu_session_msg>& msg, std::string& nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Release Command
* Included in PDU Session Update SM Context Response (PDU Session Release
......
......@@ -231,7 +231,7 @@ bool smf_n2::create_n2_pdu_session_resource_setup_request_transfer(
.choice.nonDynamic5QI = (Ngap_NonDynamic5QIDescriptor_t*) (calloc(
1, sizeof(Ngap_NonDynamic5QIDescriptor_t)));
ngap_QosFlowSetupRequestItem->qosFlowLevelQosParameters.qosCharacteristics
.choice.nonDynamic5QI->fiveQI = (uint8_t) DEFAULT_5QI;
.choice.nonDynamic5QI->fiveQI = (uint8_t) qos_flow.qfi.qfi;
ngap_QosFlowSetupRequestItem->qosFlowLevelQosParameters
.allocationAndRetentionPriority.priorityLevelARP =
qos_flow.qos_profile.arp.priority_level;
......@@ -845,6 +845,55 @@ bool smf_n2::create_n2_pdu_session_resource_modify_request_transfer(
return result;
}
//------------------------------------------------------------------------------
bool smf_n2::create_n2_pdu_session_resource_release_command_transfer(
const std::shared_ptr<pdu_session_msg>& msg,
n2_sm_info_type_e ngap_info_type, std::string& ngap_msg_str) {
Logger::smf_n2().debug(
"Create N2 SM Information: NGAP PDU Session Resource Release Command "
"Transfer IE");
bool result = false;
Ngap_PDUSessionResourceReleaseCommandTransfer_t*
ngap_resource_release_command_transfer = nullptr;
ngap_resource_release_command_transfer =
(Ngap_PDUSessionResourceReleaseCommandTransfer_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleaseCommandTransfer_t));
// TODO: To be completed, here's an example
ngap_resource_release_command_transfer->cause.present =
Ngap_Cause_PR_radioNetwork;
ngap_resource_release_command_transfer->cause.choice.radioNetwork = 1;
// encode
size_t buffer_size = BUF_LEN;
char* buffer = (char*) calloc(1, buffer_size);
ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceReleaseCommandTransfer, nullptr,
ngap_resource_release_command_transfer, (void**) &buffer);
if (encoded_size < 0) {
Logger::smf_n2().warn(
"NGAP PDU Session Release Command encode failed (encoded size %d)",
encoded_size);
result = false;
} else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: ");
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif
std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message;
result = true;
}
// free memory
free_wrapper((void**) &ngap_resource_release_command_transfer);
free_wrapper((void**) &buffer);
return result;
}
//------------------------------------------------------------------------------
bool smf_n2::create_n2_pdu_session_resource_release_command_transfer(
pdu_session_update_sm_context_response& sm_context_res,
......
......@@ -162,6 +162,10 @@ class smf_n2 {
pdu_session_update_sm_context_response& sm_context_res,
n2_sm_info_type_e ngap_info_type, std::string& ngap_msg_str);
bool create_n2_pdu_session_resource_release_command_transfer(
const std::shared_ptr<pdu_session_msg>& msg,
n2_sm_info_type_e ngap_info_type, std::string& ngap_msg_str);
/*
* Create N2 SM Information: PDU Session Resource Release Command Transfer IE
* This IE is included in the following messages:
......
This diff is collapsed.
......@@ -257,7 +257,8 @@ class session_release_sm_context_procedure : public smf_session_procedure {
: smf_session_procedure(ps),
n4_triggered(),
n11_triggered_pending(),
n11_trigger() {}
n11_trigger(),
session_procedure_type() {}
/*
* Execute N11 Release SM Context Request procedure
......@@ -285,6 +286,7 @@ class session_release_sm_context_procedure : public smf_session_procedure {
std::shared_ptr<itti_n11_release_sm_context_request> n11_trigger;
std::shared_ptr<itti_n11_release_sm_context_response> n11_triggered_pending;
session_management_procedures_type_e session_procedure_type;
private:
smf_procedure_code send_n4_session_deletion_request();
......
......@@ -1392,7 +1392,7 @@ uint32_t smf_sbi::get_available_response(boost::shared_future<uint32_t>& f) {
uint32_t response_code = f.get();
return response_code;
} else {
return 408; // timeout, TODO: remove hardcoded value
return http_status_code_e::HTTP_STATUS_CODE_408_REQUEST_TIMEOUT;
}
}
......
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