Commit 43624b7f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'event_exposure_registration_state' into 'develop'

Event exposure registration state

See merge request oai/cn5g/oai-cn5g-amf!79
parents 4b6a5e0d 88db239f
...@@ -21,16 +21,33 @@ ...@@ -21,16 +21,33 @@
/*! \file amf_event.cpp /*! \file amf_event.cpp
\brief \brief
\author Shivam Gandhi \author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company KCL \company
\date 2021 \date 2021
\email: shivam.gandhi@kcl.ac.uk \email: contact@openairinterface.org
*/ */
#include "amf_event.hpp" #include "amf_event.hpp"
using namespace amf_application; using namespace amf_application;
//------------------------------------------------------------------------------
bs2::connection amf_event::subscribe_ue_location_report(
const ue_location_report_sig_t::slot_type& sig) {
return ue_location_report.connect(sig);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection amf_event::subscribe_ue_reachability_status( bs2::connection amf_event::subscribe_ue_reachability_status(
const ue_reachability_status_sig_t::slot_type& sig) { const ue_reachability_status_sig_t::slot_type& sig) {
return ue_reachability_status.connect(sig); return ue_reachability_status.connect(sig);
} }
//------------------------------------------------------------------------------
bs2::connection amf_event::subscribe_ue_registration_state(
const ue_registration_state_sig_t::slot_type& sig) {
return ue_registration_state.connect(sig);
}
bs2::connection amf_event::subscribe_ue_connectivity_state(
const ue_connectivity_state_sig_t::slot_type& sig) {
return ue_connectivity_state.connect(sig);
}
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
/*! \file amf_event.hpp /*! \file amf_event.hpp
\brief \brief
\author Shivam Gandhi \author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company KCL \company
\date 2021 \date 2021
\email: shivam.gandhi@kcl.ac.uk \email: contact@openairinterface.org
*/ */
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
...@@ -50,6 +50,16 @@ class amf_event { ...@@ -50,6 +50,16 @@ class amf_event {
friend class amf_n1; friend class amf_n1;
friend class amf_profile; friend class amf_profile;
/*
* Subscribe to Location Report signal
* @param [const ue_location_report_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_ue_location_report(
const ue_location_report_sig_t::slot_type& sig);
/* /*
* Subscribe to UE Reachability Status Notification signal * Subscribe to UE Reachability Status Notification signal
* @param [const ue_reachability_status_sig_t::slot_type&] sig: slot_type * @param [const ue_reachability_status_sig_t::slot_type&] sig: slot_type
...@@ -60,8 +70,33 @@ class amf_event { ...@@ -60,8 +70,33 @@ class amf_event {
bs2::connection subscribe_ue_reachability_status( bs2::connection subscribe_ue_reachability_status(
const ue_reachability_status_sig_t::slot_type& sig); const ue_reachability_status_sig_t::slot_type& sig);
/*
* Subscribe to UE Registration State Notification signal
* @param [const ue_registration_state_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_ue_registration_state(
const ue_registration_state_sig_t::slot_type& sig);
/*
* Subscribe to UE Connectivity State Notification signal
* @param [const ue_connectivity_state_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_ue_connectivity_state(
const ue_connectivity_state_sig_t::slot_type& sig);
private: private:
ue_location_report_sig_t ue_location_report; // Signal for UE Location Report
ue_reachability_status_sig_t ue_reachability_status_sig_t
ue_reachability_status; // Signal for UE Reachability Report ue_reachability_status; // Signal for UE Reachability Report
ue_registration_state_sig_t
ue_registration_state; // Signal for UE Registration State Report
ue_connectivity_state_sig_t
ue_connectivity_state; // Signal for UE Connectivity State Report
}; };
} // namespace amf_application } // namespace amf_application
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
/*! \file amf_event_sig.hpp /*! \file amf_event_sig.hpp
\brief \brief
\author Shivam Gandhi \author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company KCL \company
\date 2021 \date 2021
\email: shivam.gandhi@kcl.ac.uk \email: contact@openairinterface.org
*/ */
#ifndef FILE_SMF_EVENT_SIG_HPP_SEEN #ifndef FILE_SMF_EVENT_SIG_HPP_SEEN
...@@ -32,17 +32,46 @@ ...@@ -32,17 +32,46 @@
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
#include <string> #include <string>
#include "UserLocation.h"
namespace bs2 = boost::signals2; namespace bs2 = boost::signals2;
namespace amf_application { namespace amf_application {
// Signal for UE Location Report
// SUPI, User Location, HTTP version
typedef bs2::signal_type<
void(std::string, oai::amf::model::UserLocation, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type ue_location_report_sig_t;
// TODO: Presence-In-AOI-Report
// TODO: Time-Zone-Report
// TODO: Access-Type-Report
// Signal for UE Reachability Report // Signal for UE Reachability Report
// SUPI, HTTP version // SUPI, status, HTTP version
typedef bs2::signal_type< typedef bs2::signal_type<
void(std::string, uint8_t), void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ue_reachability_status_sig_t; ue_reachability_status_sig_t;
// Signal for UE Registration State Report
// SUPI, registration state, HTTP version
typedef bs2::signal_type<
void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ue_registration_state_sig_t;
// Signal for Connectivity State Report
// SUPI, connectivity state, HTTP version
typedef bs2::signal_type<
void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ue_connectivity_state_sig_t;
// TODO: Communication-Failure-Report
// TODO: UEs-In-Area-Report
// TODO: Loss-of-Connectivity
} // namespace amf_application } // namespace amf_application
#endif #endif
...@@ -144,13 +144,15 @@ std::string event_notification::get_subs_change_notify_correlation_id() const { ...@@ -144,13 +144,15 @@ std::string event_notification::get_subs_change_notify_correlation_id() const {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::add_report(const amf_event_report_t& report) { void event_notification::add_report(
m_report_list.push_back(report); const oai::amf::model::AmfEventReport& report) {
m_event_report_list.push_back(report);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::vector<amf_event_report_t> event_notification::get_reports() const { void event_notification::get_reports(
return m_report_list; std::vector<oai::amf::model::AmfEventReport>& reports) const {
reports = m_event_report_list;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "amf.hpp" #include "amf.hpp"
#include "3gpp_29.518.h" #include "3gpp_29.518.h"
#include "amf_profile.hpp" #include "amf_profile.hpp"
#include "AmfEventReport.h"
namespace amf_application { namespace amf_application {
...@@ -88,8 +89,8 @@ class event_notification { ...@@ -88,8 +89,8 @@ class event_notification {
std::string get_notify_correlation_id() const; std::string get_notify_correlation_id() const;
void set_subs_change_notify_correlation_id(std::string const& value); void set_subs_change_notify_correlation_id(std::string const& value);
std::string get_subs_change_notify_correlation_id() const; std::string get_subs_change_notify_correlation_id() const;
void add_report(const amf_event_report_t& report); void add_report(const oai::amf::model::AmfEventReport& report);
std::vector<amf_event_report_t> get_reports() const; void get_reports(std::vector<oai::amf::model::AmfEventReport>& reports) const;
private: private:
std::string m_notify_correlation_id; // notifyCorrelationId std::string m_notify_correlation_id; // notifyCorrelationId
...@@ -97,7 +98,8 @@ class event_notification { ...@@ -97,7 +98,8 @@ class event_notification {
std::string std::string
m_subs_change_notify_correlation_id; // SubsChangeNotifyCorrelationId; m_subs_change_notify_correlation_id; // SubsChangeNotifyCorrelationId;
bool m_subs_change_notify_correlation_id_is_set; bool m_subs_change_notify_correlation_id_is_set;
std::vector<amf_event_report_t> m_report_list; // Report List std::vector<oai::amf::model::AmfEventReport>
m_event_report_list; // Report List
bool m_report_list_is_set; bool m_report_list_is_set;
}; };
......
...@@ -65,6 +65,8 @@ ...@@ -65,6 +65,8 @@
#include "comUt.hpp" #include "comUt.hpp"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include "sha256.hpp" #include "sha256.hpp"
#include "AmfEventReport.h"
#include "AmfEventType.h"
extern "C" { extern "C" {
#include "bstrlib.h" #include "bstrlib.h"
...@@ -150,14 +152,38 @@ amf_n1::amf_n1() { ...@@ -150,14 +152,38 @@ amf_n1::amf_n1() {
} }
Logger::amf_n1().startup("amf_n1 started"); Logger::amf_n1().startup("amf_n1 started");
// EventExposure: subscribe to UE Location Report
ee_ue_location_report_connection = event_sub.subscribe_ue_location_report(
boost::bind(&amf_n1::handle_ue_location_change, this, _1, _2, _3));
// EventExposure: subscribe to UE Reachability Status change // EventExposure: subscribe to UE Reachability Status change
ee_ue_reachability_status_connection = ee_ue_reachability_status_connection =
event_sub.subscribe_ue_reachability_status(boost::bind( event_sub.subscribe_ue_reachability_status(boost::bind(
&amf_n1::handle_ue_reachability_status_change, this, _1, _2)); &amf_n1::handle_ue_reachability_status_change, this, _1, _2, _3));
// EventExposure: subscribe to UE Registration State change
ee_ue_registration_state_connection =
event_sub.subscribe_ue_registration_state(boost::bind(
&amf_n1::handle_ue_registration_state_change, this, _1, _2, _3));
// EventExposure: subscribe to UE Connectivity State change
ee_ue_connectivity_state_connection =
event_sub.subscribe_ue_connectivity_state(boost::bind(
&amf_n1::handle_ue_connectivity_state_change, this, _1, _2, _3));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
amf_n1::~amf_n1() {} amf_n1::~amf_n1() {
// Disconnect the boost connection
if (ee_ue_location_report_connection.connected())
ee_ue_location_report_connection.disconnect();
if (ee_ue_reachability_status_connection.connected())
ee_ue_reachability_status_connection.disconnect();
if (ee_ue_registration_state_connection.connected())
ee_ue_registration_state_connection.disconnect();
if (ee_ue_connectivity_state_connection.connected())
ee_ue_connectivity_state_connection.disconnect();
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) { void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...@@ -503,8 +529,7 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -503,8 +529,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
Logger::amf_n1().debug( Logger::amf_n1().debug(
"Signal the UE Reachability Status Event notification for SUPI %s", "Signal the UE Reachability Status Event notification for SUPI %s",
supi.c_str()); supi.c_str());
event_sub.ue_reachability_status(supi, 1); event_sub.ue_reachability_status(supi, CM_CONNECTED, 1);
} else { } else {
// Logger::amf_n1().debug("existing nas_context with amf_ue_ngap_id(0x%x) // Logger::amf_n1().debug("existing nas_context with amf_ue_ngap_id(0x%x)
// --> Update",amf_ue_ngap_id); nc = // --> Update",amf_ue_ngap_id); nc =
...@@ -975,6 +1000,14 @@ void amf_n1::registration_request_handle( ...@@ -975,6 +1000,14 @@ void amf_n1::registration_request_handle(
stacs.update_ue_info(ueItem); stacs.update_ue_info(ueItem);
set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED); set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug(
"Signal the UE Registration State Event notification for SUPI %s",
supi.c_str());
event_sub.ue_registration_state(
supi, _5GMM_COMMON_PROCEDURE_INITIATED, 1);
nc.get()->is_stacs_available = true; nc.get()->is_stacs_available = true;
} }
} }
...@@ -1185,6 +1218,55 @@ void amf_n1::registration_request_handle( ...@@ -1185,6 +1218,55 @@ void amf_n1::registration_request_handle(
"No Optional NAS Container inside Registration Request message"); "No Optional NAS Container inside Registration Request message");
} }
// Trigger UE Location Report
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n1().warn(
"No UE NGAP context with ran_ue_ngap_id (%d)", ran_ue_ngap_id);
} else {
std::shared_ptr<ue_ngap_context> unc =
amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
std::shared_ptr<gnb_context> gc = {};
if (!amf_n2_inst->is_assoc_id_2_gnb_context(unc.get()->gnb_assoc_id)) {
Logger::amf_n2().error(
"No existed gNB context with assoc_id (%d)", unc.get()->gnb_assoc_id);
} else {
gc = amf_n2_inst->assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() && uc.get()) {
oai::amf::model::UserLocation user_location = {};
oai::amf::model::NrLocation nr_location = {};
oai::amf::model::Tai tai = {};
nlohmann::json tai_json = {};
tai_json["plmnId"]["mcc"] = uc.get()->cgi.mcc;
tai_json["plmnId"]["mnc"] = uc.get()->cgi.mnc;
tai_json["tac"] = std::to_string(uc.get()->tai.tac);
from_json(tai_json, tai);
// uc.get()->cgi.nrCellID;
nr_location.setTai(tai);
nlohmann::json global_ran_node_id_json = {};
global_ran_node_id_json["plmnId"]["mcc"] = uc.get()->cgi.mcc;
global_ran_node_id_json["plmnId"]["mnc"] = uc.get()->cgi.mnc;
global_ran_node_id_json["gNbId"]["bitLength"] = 32;
global_ran_node_id_json["gNbId"]["gNBValue"] =
std::to_string(gc->globalRanNodeId);
oai::amf::model::GlobalRanNodeId global_ran_node_id = {};
from_json(global_ran_node_id_json, global_ran_node_id);
nr_location.setGlobalGnbId(global_ran_node_id);
user_location.setNrLocation(nr_location);
// Trigger UE Location Report
string supi = uc.get()->supi;
Logger::amf_n1().debug(
"Signal the UE Location Report Event notification for SUPI %s",
supi.c_str());
event_sub.ue_location_report(supi, user_location, 1);
}
}
}
// Store NAS information into nas_context // Store NAS information into nas_context
// Run the corresponding registration procedure // Run the corresponding registration procedure
switch (reg_type) { switch (reg_type) {
...@@ -2268,6 +2350,12 @@ void amf_n1::security_mode_complete_handle( ...@@ -2268,6 +2350,12 @@ void amf_n1::security_mode_complete_handle(
} }
set_5gmm_state(nc, _5GMM_REGISTERED); set_5gmm_state(nc, _5GMM_REGISTERED);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug(
"Signal the UE Registration State Event notification for SUPI %s",
supi.c_str());
event_sub.ue_registration_state(supi, _5GMM_REGISTERED, 1);
set_guti_2_nas_context(guti, nc); set_guti_2_nas_context(guti, nc);
nc.get()->is_common_procedure_for_security_mode_control_running = false; nc.get()->is_common_procedure_for_security_mode_control_running = false;
nas_secu_ctx* secu = nc.get()->security_ctx; nas_secu_ctx* secu = nc.get()->security_ctx;
...@@ -2647,6 +2735,13 @@ void amf_n1::ue_initiate_de_registration_handle( ...@@ -2647,6 +2735,13 @@ void amf_n1::ue_initiate_de_registration_handle(
itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id); itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id);
set_5gmm_state(nc, _5GMM_DEREGISTERED); set_5gmm_state(nc, _5GMM_DEREGISTERED);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug(
"Signal the UE Registration State Event notification for SUPI %s",
supi.c_str());
event_sub.ue_registration_state(supi, _5GMM_DEREGISTERED, 1);
if (nc.get()->is_stacs_available) { if (nc.get()->is_stacs_available) {
stacs.update_5gmm_state(nc.get()->imsi, "5GMM-DEREGISTERED"); stacs.update_5gmm_state(nc.get()->imsi, "5GMM-DEREGISTERED");
} }
...@@ -3056,9 +3151,65 @@ void amf_n1::get_5gcm_state( ...@@ -3056,9 +3151,65 @@ void amf_n1::get_5gcm_state(
state = nc.get()->nas_status; state = nc.get()->nas_status;
} }
//------------------------------------------------------------------------------
void amf_n1::handle_ue_location_change(
std::string supi, oai::amf::model::UserLocation user_location,
uint8_t http_version) {
Logger::amf_n1().debug(
"Send request to SBI to triger UE Location Report (SUPI "
"%s )",
supi.c_str());
std::vector<std::shared_ptr<amf_subscription>> subscriptions = {};
amf_app_inst->get_ee_subscriptions(
amf_event_type_t::LOCATION_REPORT, subscriptions);
if (subscriptions.size() > 0) {
// Send request to SBI to trigger the notification to the subscribed event
Logger::amf_app().debug(
"Send ITTI msg to AMF SBI to trigger the event notification");
std::shared_ptr<itti_sbi_notify_subscribed_event> itti_msg =
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
event_notification ev_notif = {};
ev_notif.set_notify_correlation_id(i.get()->notify_correlation_id);
// ev_notif.set_subs_change_notify_correlation_id(i.get()->notify_uri);
oai::amf::model::AmfEventReport event_report = {};
oai::amf::model::AmfEventType amf_event_type = {};
amf_event_type.set_value("LOCATION_REPORT");
event_report.setType(amf_event_type);
oai::amf::model::AmfEventState amf_event_state = {};
amf_event_state.setActive(true);
event_report.setState(amf_event_state);
event_report.setLocation(user_location);
event_report.setSupi(supi);
ev_notif.add_report(event_report);
itti_msg->event_notifs.push_back(ev_notif);
}
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name());
}
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::handle_ue_reachability_status_change( void amf_n1::handle_ue_reachability_status_change(
std::string supi, uint8_t http_version) { std::string supi, uint8_t status, uint8_t http_version) {
Logger::amf_n1().debug( Logger::amf_n1().debug(
"Send request to SBI to triger UE Reachability Report (SUPI " "Send request to SBI to triger UE Reachability Report (SUPI "
"%s )", "%s )",
...@@ -3085,14 +3236,161 @@ void amf_n1::handle_ue_reachability_status_change( ...@@ -3085,14 +3236,161 @@ void amf_n1::handle_ue_reachability_status_change(
event_notification ev_notif = {}; event_notification ev_notif = {};
ev_notif.set_notify_correlation_id(i.get()->notify_correlation_id); ev_notif.set_notify_correlation_id(i.get()->notify_correlation_id);
// ev_notif.set_subs_change_notify_correlation_id(i.get()->notify_uri); // ev_notif.set_subs_change_notify_correlation_id(i.get()->notify_uri);
amf_event_report_t report = {};
// TODO oai::amf::model::AmfEventReport event_report = {};
report.m_type = REACHABILITY_REPORT; oai::amf::model::AmfEventType amf_event_type = {};
report.m_reachability_is_set = true; amf_event_type.set_value("REACHABILITY_REPORT");
report.m_reachability = REACHABLE; // TODO event_report.setType(amf_event_type);
report.m_supi_is_set = true;
report.m_supi = supi; oai::amf::model::AmfEventState amf_event_state = {};
ev_notif.add_report(report); amf_event_state.setActive(true);
event_report.setState(amf_event_state);
oai::amf::model::UeReachability ue_reachability = {};
if (status == CM_CONNECTED)
ue_reachability.set_value("REACHABLE");
else
ue_reachability.set_value("UNREACHABLE");
event_report.setReachability(ue_reachability);
event_report.setSupi(supi);
ev_notif.add_report(event_report);
itti_msg->event_notifs.push_back(ev_notif);
}
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name());
}
}
}
//------------------------------------------------------------------------------
void amf_n1::handle_ue_registration_state_change(
std::string supi, uint8_t status, uint8_t http_version) {
Logger::amf_n1().debug(
"Send request to SBI to triger UE Registration State Report (SUPI "
"%s )",
supi.c_str());
std::vector<std::shared_ptr<amf_subscription>> subscriptions = {};
amf_app_inst->get_ee_subscriptions(
amf_event_type_t::REGISTRATION_STATE_REPORT, subscriptions);
if (subscriptions.size() > 0) {
// Send request to SBI to trigger the notification to the subscribed event
Logger::amf_app().debug(
"Send ITTI msg to AMF SBI to trigger the event notification");
std::shared_ptr<itti_sbi_notify_subscribed_event> itti_msg =
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
event_notification ev_notif = {};
ev_notif.set_notify_correlation_id(i.get()->notify_correlation_id);
// ev_notif.set_subs_change_notify_correlation_id(i.get()->notify_uri);
oai::amf::model::AmfEventReport event_report = {};
oai::amf::model::AmfEventType amf_event_type = {};
amf_event_type.set_value("REGISTRATION_STATE_REPORT");
event_report.setType(amf_event_type);
oai::amf::model::AmfEventState amf_event_state = {};
amf_event_state.setActive(true);
event_report.setState(amf_event_state);
std::vector<oai::amf::model::RmInfo> rm_infos;
oai::amf::model::RmInfo rm_info = {};
oai::amf::model::RmState rm_state = {};
rm_state.set_value("REGISTERED");
rm_info.setRmState(rm_state);
oai::amf::model::AccessType access_type = {};
access_type.setValue(AccessType::eAccessType::_3GPP_ACCESS);
rm_info.setAccessType(access_type);
rm_infos.push_back(rm_info);
event_report.setRmInfoList(rm_infos);
event_report.setSupi(supi);
ev_notif.add_report(event_report);
itti_msg->event_notifs.push_back(ev_notif);
}
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name());
}
}
}
//------------------------------------------------------------------------------
void amf_n1::handle_ue_connectivity_state_change(
std::string supi, uint8_t status, uint8_t http_version) {
Logger::amf_n1().debug(
"Send request to SBI to triger UE Connectivity State Report (SUPI "
"%s )",
supi.c_str());
std::vector<std::shared_ptr<amf_subscription>> subscriptions = {};
amf_app_inst->get_ee_subscriptions(
amf_event_type_t::CONNECTIVITY_STATE_REPORT, subscriptions);
if (subscriptions.size() > 0) {
// Send request to SBI to trigger the notification to the subscribed event
Logger::amf_app().debug(
"Send ITTI msg to AMF SBI to trigger the event notification");
std::shared_ptr<itti_sbi_notify_subscribed_event> itti_msg =
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
event_notification ev_notif = {};
ev_notif.set_notify_correlation_id(i.get()->notify_correlation_id);
// ev_notif.set_subs_change_notify_correlation_id(i.get()->notify_uri);
oai::amf::model::AmfEventReport event_report = {};
oai::amf::model::AmfEventType amf_event_type = {};
amf_event_type.set_value("CONNECTIVITY_STATE_REPORT");
event_report.setType(amf_event_type);
oai::amf::model::AmfEventState amf_event_state = {};
amf_event_state.setActive(true);
event_report.setState(amf_event_state);
std::vector<oai::amf::model::CmInfo> cm_infos;
oai::amf::model::CmInfo cm_info = {};
oai::amf::model::CmState cm_state = {};
cm_state.set_value("CONNECTED");
cm_info.setCmState(cm_state);
oai::amf::model::AccessType access_type = {};
access_type.setValue(AccessType::eAccessType::_3GPP_ACCESS);
cm_info.setAccessType(access_type);
cm_infos.push_back(cm_info);
event_report.setCmInfoList(cm_infos);
event_report.setSupi(supi);
ev_notif.add_report(event_report);
itti_msg->event_notifs.push_back(ev_notif); itti_msg->event_notifs.push_back(ev_notif);
} }
......
...@@ -173,8 +173,16 @@ class amf_n1 { ...@@ -173,8 +173,16 @@ class amf_n1 {
void get_5gcm_state( void get_5gcm_state(
const std::shared_ptr<nas_context>& nc, cm_state_t& state) const; const std::shared_ptr<nas_context>& nc, cm_state_t& state) const;
void handle_ue_location_change(
std::string supi, oai::amf::model::UserLocation, uint8_t http_version);
void handle_ue_reachability_status_change( void handle_ue_reachability_status_change(
std::string supi, uint8_t http_version); std::string supi, uint8_t status, uint8_t http_version);
void handle_ue_registration_state_change(
std::string supi, uint8_t status, uint8_t http_version);
void handle_ue_connectivity_state_change(
std::string supi, uint8_t status, uint8_t http_version);
void get_pdu_session_to_be_activated( void get_pdu_session_to_be_activated(
uint16_t pdu_session_status, uint16_t pdu_session_status,
...@@ -244,7 +252,10 @@ class amf_n1 { ...@@ -244,7 +252,10 @@ class amf_n1 {
// for Event Handling // for Event Handling
amf_event event_sub; amf_event event_sub;
bs2::connection ee_ue_location_report_connection;
bs2::connection ee_ue_reachability_status_connection; bs2::connection ee_ue_reachability_status_connection;
bs2::connection ee_ue_registration_state_connection;
bs2::connection ee_ue_connectivity_state_connection;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "conversions.hpp" #include "conversions.hpp"
#include "comUt.hpp" #include "comUt.hpp"
#include "AmfEventReport.h"
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
...@@ -539,16 +540,16 @@ void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) { ...@@ -539,16 +540,16 @@ void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) {
auto report_lists = nlohmann::json::array(); auto report_lists = nlohmann::json::array();
nlohmann::json report = {}; nlohmann::json report = {};
std::vector<amf_event_report_t> reports = i.get_reports(); std::vector<oai::amf::model::AmfEventReport> event_reports = {};
i.get_reports(event_reports);
for (auto r : reports) { for (auto r : event_reports) {
report["type"] = amf_event_type_e2str.at(static_cast<uint8_t>(r.m_type)); report["type"] = r.getType().get_value();
report["state"]["active"] = "TRUE"; report["state"]["active"] = "TRUE";
if (r.m_supi_is_set) { if (r.supiIsSet()) {
report["supi"] = r.m_supi; // TODO report["supi"] = r.getSupi();
} }
if (r.m_reachability_is_set) { if (r.reachabilityIsSet()) {
report["reachability"] = r.m_reachability; report["reachability"] = r.getReachability().get_value();
} }
// timestamp // timestamp
......
...@@ -75,61 +75,6 @@ typedef struct amf_event_s { ...@@ -75,61 +75,6 @@ typedef struct amf_event_s {
} amf_event_t; } amf_event_t;
typedef struct amf_event_state_s {
bool m_active;
int32_t m_remain_reports;
bool m_remain_reports_is_set;
int32_t m_remain_duration;
bool m_remain_duration_is_set;
} amf_event_state_t;
typedef enum ue_reachability_e {
UNREACHABLE = 1,
REACHABLE = 2,
REGULATORY_ONLY = 3
} ue_reachability_t;
typedef struct amf_event_report_s {
amf_event_type_t m_type; // Mandatory
amf_event_state_t m_state; // Mandatory
std::string m_TimeStamp; // Mandatory
ue_reachability_t m_reachability;
bool m_reachability_is_set;
std::string m_supi;
bool m_supi_is_set;
std::string m_subscription_id;
bool m_subscription_id_is_set;
bool m_any_ue;
bool m_any_ue_is_set;
/*
std::vector<AmfEventArea> m_AreaList;
bool m_AreaListIsSet;
int32_t m_RefId;
bool m_RefIdIsSet;
std::string m_Gpsi;
bool m_GpsiIsSet;
std::string m_Pei;
bool m_PeiIsSet;
UserLocation m_Location;
bool m_LocationIsSet;
std::string m_Timezone;
bool m_TimezoneIsSet;
std::vector<AccessType> m_AccessTypeList;
bool m_AccessTypeListIsSet;
std::vector<RmInfo> m_RmInfoList;
bool m_RmInfoListIsSet;
std::vector<CmInfo> m_CmInfoList;
bool m_CmInfoListIsSet;
//CommunicationFailure m_CommFailure;
// bool m_CommFailureIsSet;
// int32_t m_NumberOfUes;
// bool m_NumberOfUesIsSet;
// std::vector<_5GsUserStateInfo> m_r_5gsUserStateList;
// bool m_r_5gsUserStateListIsSet;
*/
} amf_event_report_t;
enum n1_n2_message_transfer_cause_e { enum n1_n2_message_transfer_cause_e {
ATTEMPTING_TO_REACH_UE = 1, ATTEMPTING_TO_REACH_UE = 1,
N1_N2_TRANSFER_INITIATED = 2, N1_N2_TRANSFER_INITIATED = 2,
......
...@@ -49,10 +49,21 @@ bool CmState::operator!=(const CmState& rhs) const { ...@@ -49,10 +49,21 @@ bool CmState::operator!=(const CmState& rhs) const {
return !(*this == rhs); return !(*this == rhs);
} }
void CmState::set_value(std::string value) {
this->value = value;
}
void CmState::get_value(std::string& value) const {
value = this->value;
}
std::string CmState::get_value() const {
return value;
}
void to_json(nlohmann::json& j, const CmState& o) { void to_json(nlohmann::json& j, const CmState& o) {
j = nlohmann::json(); j = o.get_value();
} }
void from_json(const nlohmann::json& j, CmState& o) {} void from_json(const nlohmann::json& j, CmState& o) {
o.set_value(j.get<std::string>());
}
} // namespace oai::amf::model } // namespace oai::amf::model
...@@ -38,6 +38,10 @@ class CmState { ...@@ -38,6 +38,10 @@ class CmState {
/// </summary> /// </summary>
void validate() const; void validate() const;
void set_value(std::string value);
void get_value(std::string& value) const;
std::string get_value() const;
/// <summary> /// <summary>
/// Validate the current data in the model. Returns false on error and writes /// Validate the current data in the model. Returns false on error and writes
/// an error message into the given stringstream. /// an error message into the given stringstream.
...@@ -54,6 +58,7 @@ class CmState { ...@@ -54,6 +58,7 @@ class CmState {
friend void from_json(const nlohmann::json& j, CmState& o); friend void from_json(const nlohmann::json& j, CmState& o);
protected: protected:
std::string value;
// Helper overload for validate. Used when one model stores another model and // Helper overload for validate. Used when one model stores another model and
// calls it's validate. // calls it's validate.
bool validate(std::stringstream& msg, const std::string& pathPrefix) const; bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
......
...@@ -49,10 +49,22 @@ bool RmState::operator!=(const RmState& rhs) const { ...@@ -49,10 +49,22 @@ bool RmState::operator!=(const RmState& rhs) const {
return !(*this == rhs); return !(*this == rhs);
} }
void RmState::set_value(std::string value) {
this->value = value;
}
void RmState::get_value(std::string& value) const {
value = this->value;
}
std::string RmState::get_value() const {
return value;
}
void to_json(nlohmann::json& j, const RmState& o) { void to_json(nlohmann::json& j, const RmState& o) {
j = nlohmann::json(); j = o.get_value();
} }
void from_json(const nlohmann::json& j, RmState& o) {} void from_json(const nlohmann::json& j, RmState& o) {
o.set_value(j.get<std::string>());
}
} // namespace oai::amf::model } // namespace oai::amf::model
...@@ -44,6 +44,10 @@ class RmState { ...@@ -44,6 +44,10 @@ class RmState {
/// </summary> /// </summary>
bool validate(std::stringstream& msg) const; bool validate(std::stringstream& msg) const;
void set_value(std::string value);
void get_value(std::string& value) const;
std::string get_value() const;
bool operator==(const RmState& rhs) const; bool operator==(const RmState& rhs) const;
bool operator!=(const RmState& rhs) const; bool operator!=(const RmState& rhs) const;
...@@ -54,6 +58,7 @@ class RmState { ...@@ -54,6 +58,7 @@ class RmState {
friend void from_json(const nlohmann::json& j, RmState& o); friend void from_json(const nlohmann::json& j, RmState& o);
protected: protected:
std::string value;
// Helper overload for validate. Used when one model stores another model and // Helper overload for validate. Used when one model stores another model and
// calls it's validate. // calls it's validate.
bool validate(std::stringstream& msg, const std::string& pathPrefix) const; bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
......
...@@ -50,10 +50,22 @@ bool UeReachability::operator!=(const UeReachability& rhs) const { ...@@ -50,10 +50,22 @@ bool UeReachability::operator!=(const UeReachability& rhs) const {
return !(*this == rhs); return !(*this == rhs);
} }
void UeReachability::set_value(std::string value) {
this->value = value;
}
void UeReachability::get_value(std::string& value) const {
value = this->value;
}
std::string UeReachability::get_value() const {
return value;
}
void to_json(nlohmann::json& j, const UeReachability& o) { void to_json(nlohmann::json& j, const UeReachability& o) {
j = nlohmann::json(); j = o.get_value();
} }
void from_json(const nlohmann::json& j, UeReachability& o) {} void from_json(const nlohmann::json& j, UeReachability& o) {
o.set_value(j.get<std::string>());
}
} // namespace oai::amf::model } // namespace oai::amf::model
...@@ -50,10 +50,15 @@ class UeReachability { ...@@ -50,10 +50,15 @@ class UeReachability {
///////////////////////////////////////////// /////////////////////////////////////////////
/// UeReachability members /// UeReachability members
void set_value(std::string value);
void get_value(std::string& value) const;
std::string get_value() const;
friend void to_json(nlohmann::json& j, const UeReachability& o); friend void to_json(nlohmann::json& j, const UeReachability& o);
friend void from_json(const nlohmann::json& j, UeReachability& o); friend void from_json(const nlohmann::json& j, UeReachability& o);
protected: protected:
std::string value;
// Helper overload for validate. Used when one model stores another model and // Helper overload for validate. Used when one model stores another model and
// calls it's validate. // calls it's validate.
bool validate(std::stringstream& msg, const std::string& pathPrefix) const; bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
......
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