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

First version for N2 Handover

parent 17940c21
...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . ...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -66,13 +66,11 @@ amf_app::amf_app(const amf_config& amf_cfg) ...@@ -66,13 +66,11 @@ amf_app::amf_app(const amf_config& amf_cfg)
: m_amf_ue_ngap_id2ue_ctx(), : m_amf_ue_ngap_id2ue_ctx(),
m_ue_ctx_key(), m_ue_ctx_key(),
m_supi2ue_ctx(), m_supi2ue_ctx(),
m_curl_handle_responses(), m_curl_handle_responses_n2_sm() {
m_curl_handle_responses_gtp() {
amf_ue_ngap_id2ue_ctx = {}; amf_ue_ngap_id2ue_ctx = {};
ue_ctx_key = {}; ue_ctx_key = {};
supi2ue_ctx = {}; supi2ue_ctx = {};
curl_handle_responses = {}; curl_handle_responses_n2_sm = {};
curl_handle_responses_gtp = {};
Logger::amf_app().startup("Creating AMF application functionality layer"); Logger::amf_app().startup("Creating AMF application functionality layer");
if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) { if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) {
Logger::amf_app().error("Cannot create task TASK_AMF_APP"); Logger::amf_app().error("Cannot create task TASK_AMF_APP");
...@@ -493,48 +491,21 @@ void amf_app::trigger_nf_deregistration() { ...@@ -493,48 +491,21 @@ void amf_app::trigger_nf_deregistration() {
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void amf_app::add_promise( void amf_app::add_promise(
uint32_t id, boost::shared_ptr<boost::promise<uint32_t>>& p) { uint32_t id, boost::shared_ptr<boost::promise<std::string>>& p) {
std::unique_lock lock(m_curl_handle_responses); std::unique_lock lock(m_curl_handle_responses_n2_sm);
curl_handle_responses.emplace(id, p); curl_handle_responses_n2_sm.emplace(id, p);
}
//---------------------------------------------------------------------------------------------
void amf_app::remove_promise(uint32_t id) {
std::unique_lock lock(m_curl_handle_responses);
curl_handle_responses.erase(id);
}
//------------------------------------------------------------------------------
void amf_app::trigger_process_response(uint32_t pid, uint32_t http_code) {
Logger::amf_app().debug(
"Trigger process response: Set promise with ID %u "
"to ready",
pid);
std::unique_lock lock(m_curl_handle_responses);
if (curl_handle_responses.count(pid) > 0) {
curl_handle_responses[pid]->set_value(http_code);
// Remove this promise from list
curl_handle_responses.erase(pid);
}
}
//---------------------------------------------------------------------------------------------
void amf_app::add_promise(
uint32_t id, boost::shared_ptr<boost::promise<GtpTunnel_t>>& p) {
std::unique_lock lock(m_curl_handle_responses_gtp);
curl_handle_responses_gtp.emplace(id, p);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_app::trigger_process_response(uint32_t pid, GtpTunnel_t gtp_info) { void amf_app::trigger_process_response(uint32_t pid, std::string n2_sm) {
Logger::amf_app().debug( Logger::amf_app().debug(
"Trigger process response: Set promise with ID %u " "Trigger process response: Set promise with ID %u "
"to ready", "to ready",
pid); pid);
std::unique_lock lock(m_curl_handle_responses); std::unique_lock lock(m_curl_handle_responses_n2_sm);
if (curl_handle_responses_gtp.count(pid) > 0) { if (curl_handle_responses_n2_sm.count(pid) > 0) {
curl_handle_responses_gtp[pid]->set_value(gtp_info); curl_handle_responses_n2_sm[pid]->set_value(n2_sm);
// Remove this promise from list // Remove this promise from list
curl_handle_responses_gtp.erase(pid); curl_handle_responses_n2_sm.erase(pid);
} }
} }
...@@ -162,8 +162,8 @@ class amf_app { ...@@ -162,8 +162,8 @@ class amf_app {
void trigger_process_response(uint32_t pid, uint32_t http_code); void trigger_process_response(uint32_t pid, uint32_t http_code);
void add_promise( void add_promise(
uint32_t pid, boost::shared_ptr<boost::promise<GtpTunnel_t>>& p); uint32_t pid, boost::shared_ptr<boost::promise<std::string>>& p);
void trigger_process_response(uint32_t pid, GtpTunnel_t gtp_info); void trigger_process_response(uint32_t pid, std::string n2_sm);
private: private:
// context management // context management
...@@ -175,13 +175,9 @@ class amf_app { ...@@ -175,13 +175,9 @@ class amf_app {
std::map<std::string, std::shared_ptr<ue_context>> supi2ue_ctx; std::map<std::string, std::shared_ptr<ue_context>> supi2ue_ctx;
mutable std::shared_mutex m_supi2ue_ctx; mutable std::shared_mutex m_supi2ue_ctx;
mutable std::shared_mutex m_curl_handle_responses; mutable std::shared_mutex m_curl_handle_responses_n2_sm;
std::map<uint32_t, boost::shared_ptr<boost::promise<uint32_t>>> std::map<uint32_t, boost::shared_ptr<boost::promise<std::string>>>
curl_handle_responses; curl_handle_responses_n2_sm;
mutable std::shared_mutex m_curl_handle_responses_gtp;
std::map<uint32_t, boost::shared_ptr<boost::promise<GtpTunnel_t>>>
curl_handle_responses_gtp;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -215,9 +215,17 @@ void amf_n11::handle_itti_message( ...@@ -215,9 +215,17 @@ void amf_n11::handle_itti_message(
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type; pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg"; pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
std::string json_part = pdu_session_update_request.dump(); std::string json_part = pdu_session_update_request.dump();
std::string n2SmMsg; std::string n2SmMsg = {};
octet_stream_2_hex_stream( octet_stream_2_hex_stream(
(uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg); (uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg);
// For N2 HO
if (itti_msg.n2sm_info_type.compare("HANDOVER_REQUIRED") == 0) {
pdu_session_update_request["hoState"] = "PREPARING";
} else if (itti_msg.n2sm_info_type.compare("HANDOVER_REQ_ACK") == 0) {
pdu_session_update_request["hoState"] = "PREPARED";
}
curl_http_client( curl_http_client(
remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id, remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id,
itti_msg.promise_id); itti_msg.promise_id);
...@@ -579,12 +587,6 @@ void amf_n11::curl_http_client( ...@@ -579,12 +587,6 @@ void amf_n11::curl_http_client(
Logger::amf_n11().debug("Get response with HTTP code (%d)", httpCode); Logger::amf_n11().debug("Get response with HTTP code (%d)", httpCode);
Logger::amf_n11().debug("response body %s", response.c_str()); Logger::amf_n11().debug("response body %s", response.c_str());
// Notify to the result if necessary
// TODO: Notify with the N3 information
if (promise_id > 0) {
amf_app_inst->trigger_process_response(promise_id, httpCode);
}
if (static_cast<http_response_codes_e>(httpCode) == if (static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_0) { http_response_codes_e::HTTP_RESPONSE_CODE_0) {
// TODO: should be removed // TODO: should be removed
...@@ -593,6 +595,8 @@ void amf_n11::curl_http_client( ...@@ -593,6 +595,8 @@ void amf_n11::curl_http_client(
// free curl before returning // free curl before returning
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
return; return;
} }
...@@ -611,9 +615,12 @@ void amf_n11::curl_http_client( ...@@ -611,9 +615,12 @@ void amf_n11::curl_http_client(
Logger::amf_n11().error("There's no content in the response"); Logger::amf_n11().error("There's no content in the response");
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
// TODO: send context response error // TODO: send context response error
return; return;
} }
// TODO: HO
// Transfer N1 to gNB/UE if available // Transfer N1 to gNB/UE if available
if (number_parts > 1) { if (number_parts > 1) {
...@@ -668,10 +675,28 @@ void amf_n11::curl_http_client( ...@@ -668,10 +675,28 @@ void amf_n11::curl_http_client(
"Could not get Json content from the response"); "Could not get Json content from the response");
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
// TODO: // TODO:
return; return;
} }
// For N2 HO
bool is_ho_procedure = false;
if (response_data.find("hoState") != response_data.end()) {
is_ho_procedure = true;
}
// Notify to the result
if ((promise_id > 0) and (is_ho_procedure)) {
amf_app_inst->trigger_process_response(
promise_id, n1sm); // actually, N2 SM Info
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
return;
}
itti_n1n2_message_transfer_request* itti_msg = itti_n1n2_message_transfer_request* itti_msg =
new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP); new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP);
......
This diff is collapsed.
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