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

First version for Connectivity State Report

parent ff529b87
......@@ -21,10 +21,10 @@
/*! \file amf_event.cpp
\brief
\author Shivam Gandhi
\company KCL
\author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company
\date 2021
\email: shivam.gandhi@kcl.ac.uk
\email: contact@openairinterface.org
*/
#include "amf_event.hpp"
......@@ -40,3 +40,8 @@ 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 @@
/*! \file amf_event.hpp
\brief
\author Shivam Gandhi
\company KCL
\author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company
\date 2021
\email: shivam.gandhi@kcl.ac.uk
\email: contact@openairinterface.org
*/
#include <boost/signals2.hpp>
......@@ -70,11 +70,24 @@ class amf_event {
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:
ue_reachability_status_sig_t
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
......@@ -21,10 +21,10 @@
/*! \file amf_event_sig.hpp
\brief
\author Shivam Gandhi
\company KCL
\author Shivam Gandhi (KCL), Tien-Thinh NGUYEN (EURECOM)
\company
\date 2021
\email: shivam.gandhi@kcl.ac.uk
\email: contact@openairinterface.org
*/
#ifndef FILE_SMF_EVENT_SIG_HPP_SEEN
......@@ -51,5 +51,12 @@ typedef bs2::signal_type<
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;
} // namespace amf_application
#endif
......@@ -161,10 +161,23 @@ amf_n1::amf_n1() {
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_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) {
......@@ -3172,13 +3185,12 @@ void amf_n1::handle_ue_registration_state_change(
// 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);
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");
......@@ -3188,6 +3200,72 @@ void amf_n1::handle_ue_registration_state_change(
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);
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);
......
......@@ -179,6 +179,9 @@ class amf_n1 {
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(
uint16_t pdu_session_status,
std::vector<uint8_t>& pdu_session_to_be_activated);
......@@ -249,6 +252,7 @@ class amf_n1 {
amf_event event_sub;
bs2::connection ee_ue_reachability_status_connection;
bs2::connection ee_ue_registration_state_connection;
bs2::connection ee_ue_connectivity_state_connection;
};
} // namespace amf_application
......
......@@ -49,10 +49,21 @@ bool CmState::operator!=(const CmState& rhs) const {
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) {
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
......@@ -38,6 +38,10 @@ class CmState {
/// </summary>
void validate() const;
void set_value(std::string value);
void get_value(std::string& value) const;
std::string get_value() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes
/// an error message into the given stringstream.
......@@ -54,6 +58,7 @@ class CmState {
friend void from_json(const nlohmann::json& j, CmState& o);
protected:
std::string value;
// Helper overload for validate. Used when one model stores another model and
// calls it's validate.
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