Commit 57e2e0e0 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

First version for Registration State Report

parent 76a8e7d2
...@@ -142,7 +142,7 @@ void event_notification::set_subs_change_notify_correlation_id( ...@@ -142,7 +142,7 @@ void event_notification::set_subs_change_notify_correlation_id(
std::string event_notification::get_subs_change_notify_correlation_id() const { std::string event_notification::get_subs_change_notify_correlation_id() const {
return m_subs_change_notify_correlation_id; return m_subs_change_notify_correlation_id;
} }
/*
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::add_report(const amf_event_report_t& report) { void event_notification::add_report(const amf_event_report_t& report) {
m_report_list.push_back(report); m_report_list.push_back(report);
...@@ -152,6 +152,18 @@ void event_notification::add_report(const amf_event_report_t& report) { ...@@ -152,6 +152,18 @@ void event_notification::add_report(const amf_event_report_t& report) {
std::vector<amf_event_report_t> event_notification::get_reports() const { std::vector<amf_event_report_t> event_notification::get_reports() const {
return m_report_list; return m_report_list;
} }
*/
//-----------------------------------------------------------------------------
void event_notification::add_report(
const oai::amf::model::AmfEventReport& report) {
m_event_report_list.push_back(report);
}
//-----------------------------------------------------------------------------
void event_notification::get_reports(
std::vector<oai::amf::model::AmfEventReport>& reports) const {
reports = m_event_report_list;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void data_notification_msg::set_notification_event_type( void data_notification_msg::set_notification_event_type(
......
...@@ -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,10 @@ class event_notification { ...@@ -88,8 +89,10 @@ 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 amf_event_report_t& report);
std::vector<amf_event_report_t> get_reports() const; // std::vector<amf_event_report_t> get_reports() const;
void add_report(const oai::amf::model::AmfEventReport& report);
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 +100,9 @@ class event_notification { ...@@ -97,7 +100,9 @@ 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<amf_event_report_t> m_report_list; // Report List
std::vector<oai::amf::model::AmfEventReport>
m_event_report_list; // Report List with Pistache template
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"
...@@ -3111,7 +3113,8 @@ void amf_n1::handle_ue_reachability_status_change( ...@@ -3111,7 +3113,8 @@ 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 = {};
/* amf_event_report_t report = {};
// TODO // TODO
report.m_type = REACHABILITY_REPORT; report.m_type = REACHABILITY_REPORT;
report.m_reachability_is_set = true; report.m_reachability_is_set = true;
...@@ -3122,6 +3125,22 @@ void amf_n1::handle_ue_reachability_status_change( ...@@ -3122,6 +3125,22 @@ void amf_n1::handle_ue_reachability_status_change(
report.m_supi_is_set = true; report.m_supi_is_set = true;
report.m_supi = supi; report.m_supi = supi;
ev_notif.add_report(report); ev_notif.add_report(report);
*/
oai::amf::model::AmfEventReport event_report = {};
oai::amf::model::AmfEventType amf_event_type = {};
amf_event_type.set_value("REACHABILITY_REPORT");
event_report.setType(amf_event_type);
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); itti_msg->event_notifs.push_back(ev_notif);
} }
...@@ -3163,6 +3182,7 @@ void amf_n1::handle_ue_registration_state_change( ...@@ -3163,6 +3182,7 @@ void amf_n1::handle_ue_registration_state_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 = {}; amf_event_report_t report = {};
// TODO // TODO
report.m_type = REGISTRATION_STATE_REPORT; report.m_type = REGISTRATION_STATE_REPORT;
...@@ -3170,7 +3190,28 @@ void amf_n1::handle_ue_registration_state_change( ...@@ -3170,7 +3190,28 @@ void amf_n1::handle_ue_registration_state_change(
// report.m_ = UNREACHABLE; // report.m_ = UNREACHABLE;
report.m_supi_is_set = true; report.m_supi_is_set = true;
report.m_supi = supi; report.m_supi = supi;
ev_notif.add_report(report); ev_notif.add_report(report);*/
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");
rm_info.setRmState(rm_state);
oai::amf::model::AccessType access_type = {};
access_type.setValue(AccessType::eAccessType::_3GPP_ACCESS);
rm_info.setAccessType(access_type);
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);
} }
......
...@@ -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,10 +540,13 @@ void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) { ...@@ -539,10 +540,13 @@ 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<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 : reports) {
report["type"] = amf_event_type_e2str.at(static_cast<uint8_t>(r.m_type)); report["type"] =
amf_event_type_e2str.at(static_cast<uint8_t>(r.m_type));
report["state"]["active"] = "TRUE"; report["state"]["active"] = "TRUE";
if (r.m_supi_is_set) { if (r.m_supi_is_set) {
report["supi"] = r.m_supi; // TODO report["supi"] = r.m_supi; // TODO
...@@ -551,6 +555,23 @@ void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) { ...@@ -551,6 +555,23 @@ void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) {
report["reachability"] = r.m_reachability; report["reachability"] = r.m_reachability;
} }
// timestamp
std::time_t time_epoch_ntp = std::time(nullptr);
uint64_t tv_ntp = time_epoch_ntp +
SECONDS_SINCE_FIRST_EPOCH; report["timeStamp"] =
std::to_string(tv_ntp); report_lists.push_back(report);
}
*/
for (auto r : event_reports) {
report["type"] = r.getType().get_value();
report["state"]["active"] = "TRUE";
if (r.supiIsSet()) {
report["supi"] = r.getSupi();
}
if (r.reachabilityIsSet()) {
report["reachability"] = r.getReachability().get_value();
}
// timestamp // timestamp
std::time_t time_epoch_ntp = std::time(nullptr); std::time_t time_epoch_ntp = std::time(nullptr);
uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH; uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH;
......
...@@ -89,6 +89,7 @@ typedef enum ue_reachability_e { ...@@ -89,6 +89,7 @@ typedef enum ue_reachability_e {
REGULATORY_ONLY = 3 REGULATORY_ONLY = 3
} ue_reachability_t; } ue_reachability_t;
/*
typedef struct amf_event_report_s { typedef struct amf_event_report_s {
amf_event_type_t m_type; // Mandatory amf_event_type_t m_type; // Mandatory
amf_event_state_t m_state; // Mandatory amf_event_state_t m_state; // Mandatory
...@@ -101,35 +102,8 @@ typedef struct amf_event_report_s { ...@@ -101,35 +102,8 @@ typedef struct amf_event_report_s {
bool m_subscription_id_is_set; bool m_subscription_id_is_set;
bool m_any_ue; bool m_any_ue;
bool m_any_ue_is_set; 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; } 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,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