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

Implement SubscriptionsCollectionDocumentApiImplEventExposure

parent 6b5432f1
...@@ -58,8 +58,9 @@ file(GLOB AMF_src_files ...@@ -58,8 +58,9 @@ file(GLOB AMF_src_files
${CMAKE_CURRENT_SOURCE_DIR}/amf_event.cpp ${CMAKE_CURRENT_SOURCE_DIR}/amf_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_profile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/amf_profile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp ${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp ${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mysql_db.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mysql_db.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_msg.cpp
${SRC_TOP_DIR}/nas/msgs/*.cpp ${SRC_TOP_DIR}/nas/msgs/*.cpp
${SRC_TOP_DIR}/nas/ies/*.cpp ${SRC_TOP_DIR}/nas/ies/*.cpp
${SRC_TOP_DIR}/nas/utils/*.c ${SRC_TOP_DIR}/nas/utils/*.c
......
...@@ -407,6 +407,7 @@ evsub_id_t amf_app::handle_event_exposure_subscription( ...@@ -407,6 +407,7 @@ evsub_id_t amf_app::handle_event_exposure_subscription(
std::shared_ptr<amf_subscription> ss = std::shared_ptr<amf_subscription> ss =
std::shared_ptr<amf_subscription>(new amf_subscription()); std::shared_ptr<amf_subscription>(new amf_subscription());
ss.get()->sub_id = evsub_id; ss.get()->sub_id = evsub_id;
// TODO:
// if (msg->event_exposure.is_supi_is_set()) { // if (msg->event_exposure.is_supi_is_set()) {
// supi64_t supi64 = amf_supi_to_u64(msg->event_exposure.get_supi()); // supi64_t supi64 = amf_supi_to_u64(msg->event_exposure.get_supi());
// ss.get()->supi = supi64; // ss.get()->supi = supi64;
...@@ -513,7 +514,8 @@ void amf_app::generate_uuid() { ...@@ -513,7 +514,8 @@ void amf_app::generate_uuid() {
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void amf_app::add_event_subscription( void amf_app::add_event_subscription(
evsub_id_t sub_id, amf_event_t ev, std::shared_ptr<amf_subscription> ss) { evsub_id_t sub_id, amf_event_type_t ev,
std::shared_ptr<amf_subscription> ss) {
Logger::amf_app().debug( Logger::amf_app().debug(
"Add an Event subscription (Sub ID %d, Event %d)", sub_id, (uint8_t) ev); "Add an Event subscription (Sub ID %d, Event %d)", sub_id, (uint8_t) ev);
std::unique_lock lock(m_amf_event_subscriptions); std::unique_lock lock(m_amf_event_subscriptions);
...@@ -522,7 +524,7 @@ void amf_app::add_event_subscription( ...@@ -522,7 +524,7 @@ void amf_app::add_event_subscription(
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void amf_app::get_ee_subscriptions( void amf_app::get_ee_subscriptions(
amf_event_t ev, amf_event_type_t ev,
std::vector<std::shared_ptr<amf_subscription>>& subscriptions) { std::vector<std::shared_ptr<amf_subscription>>& subscriptions) {
for (auto const& i : amf_event_subscriptions) { for (auto const& i : amf_event_subscriptions) {
if ((uint8_t) std::get<1>(i.first) == (uint8_t) ev) { if ((uint8_t) std::get<1>(i.first) == (uint8_t) ev) {
...@@ -547,7 +549,7 @@ void amf_app::get_ee_subscriptions( ...@@ -547,7 +549,7 @@ void amf_app::get_ee_subscriptions(
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void amf_app::get_ee_subscriptions( void amf_app::get_ee_subscriptions(
amf_event_t ev, supi64_t supi, amf_event_type_t ev, supi64_t supi,
std::vector<std::shared_ptr<amf_subscription>>& subscriptions) { std::vector<std::shared_ptr<amf_subscription>>& subscriptions) {
for (auto const& i : amf_event_subscriptions) { for (auto const& i : amf_event_subscriptions) {
if ((i.first.second == ev) && (i.second->supi == supi)) { if ((i.first.second == ev) && (i.second->supi == supi)) {
......
...@@ -71,7 +71,8 @@ class amf_app { ...@@ -71,7 +71,8 @@ class amf_app {
util::uint_generator<uint32_t> evsub_id_generator; util::uint_generator<uint32_t> evsub_id_generator;
std::map< std::map<
std::pair<evsub_id_t, amf_event_t>, std::shared_ptr<amf_subscription>> std::pair<evsub_id_t, amf_event_type_t>,
std::shared_ptr<amf_subscription>>
amf_event_subscriptions; amf_event_subscriptions;
mutable std::shared_mutex m_amf_event_subscriptions; mutable std::shared_mutex m_amf_event_subscriptions;
...@@ -166,7 +167,8 @@ class amf_app { ...@@ -166,7 +167,8 @@ class amf_app {
* @return void * @return void
*/ */
void add_event_subscription( void add_event_subscription(
evsub_id_t sub_id, amf_event_t ev, std::shared_ptr<amf_subscription> ss); evsub_id_t sub_id, amf_event_type_t ev,
std::shared_ptr<amf_subscription> ss);
/* /*
* Get a list of subscription associated with a particular event * Get a list of subscription associated with a particular event
...@@ -176,7 +178,7 @@ class amf_app { ...@@ -176,7 +178,7 @@ class amf_app {
* @return void * @return void
*/ */
void get_ee_subscriptions( void get_ee_subscriptions(
amf_event_t ev, amf_event_type_t ev,
std::vector<std::shared_ptr<amf_subscription>>& subscriptions); std::vector<std::shared_ptr<amf_subscription>>& subscriptions);
/* /*
...@@ -199,7 +201,7 @@ class amf_app { ...@@ -199,7 +201,7 @@ class amf_app {
* @return void * @return void
*/ */
void get_ee_subscriptions( void get_ee_subscriptions(
amf_event_t ev, supi64_t supi, amf_event_type_t ev, supi64_t supi,
std::vector<std::shared_ptr<amf_subscription>>& subscriptions); std::vector<std::shared_ptr<amf_subscription>>& subscriptions);
/* /*
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
#include "amf_msg.hpp" #include "amf_msg.hpp"
namespace amf { using namespace amf_application;
/* /*
* class: Event Exposure * class: Event Exposure
...@@ -50,16 +50,6 @@ bool event_exposure_msg::is_supi_is_set() const { ...@@ -50,16 +50,6 @@ bool event_exposure_msg::is_supi_is_set() const {
return m_supi_is_set; return m_supi_is_set;
} }
//-----------------------------------------------------------------------------
std::string event_exposure_msg::get_supi_prefix() const {
return m_supi_prefix;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_supi_prefix(const std::string& prefix) {
m_supi_prefix = prefix;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_exposure_msg::set_sub_id(std::string const& value) { void event_exposure_msg::set_sub_id(std::string const& value) {
m_sub_id = value; m_sub_id = value;
...@@ -77,118 +67,76 @@ bool event_exposure_msg::is_sub_id_is_set() const { ...@@ -77,118 +67,76 @@ bool event_exposure_msg::is_sub_id_is_set() const {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_exposure_msg::set_notif_uri(std::string const& value) { void event_exposure_msg::set_notify_uri(std::string const& value) {
m_notif_uri = value; m_notify_uri = value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string event_exposure_msg::get_notif_uri() const { std::string event_exposure_msg::get_notify_uri() const {
return m_notif_uri; return m_notify_uri;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_exposure_msg::set_notif_id(std::string const& value) { void event_exposure_msg::set_notify_correlation_id(std::string const& value) {
m_notif_id = value; m_notify_correlation_id = value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string event_exposure_msg::get_notif_id() const { std::string event_exposure_msg::get_notify_correlation_id() const {
return m_notif_id; return m_notify_correlation_id;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::vector<event_subscription_t> event_exposure_msg::get_event_subs() const { void event_exposure_msg::set_nf_id(std::string const& value) {
return m_event_subs; m_nf_id = value;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_event_subs(
std::vector<event_subscription_t> const& value) {
m_event_subs.clear();
for (auto it : value) {
m_event_subs.push_back(it);
}
} }
/*
* class: Event Notification
*/
//-----------------------------------------------------------------------------
void event_notification::set_amf_event(const amf_event_t& ev) {
m_event = ev;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
amf_event_t event_notification::get_amf_event() const { std::string event_exposure_msg::get_nf_id() const {
return m_event; return m_nf_id;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
supi64_t event_notification::get_supi() const { std::vector<amf_event_t> event_exposure_msg::get_event_subs() const {
return m_supi; return m_event_list;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::set_supi(const supi64_t& value) { void event_exposure_msg::set_event_subs(std::vector<amf_event_t> const& value) {
m_supi = value; m_event_list.clear();
m_supi_is_set = true; for (auto it : value) {
} m_event_list.push_back(it);
}
//-----------------------------------------------------------------------------
bool event_notification::is_supi_is_set() const {
return m_supi_is_set;
}
//-----------------------------------------------------------------------------
void event_notification::set_ad_ipv4_addr(std::string const& value) {
m_ad_ipv4_addr = value;
m_ad_ipv4_addr_is_set = true;
}
//-----------------------------------------------------------------------------
std::string event_notification::get_ad_ipv4_addr() const {
return m_ad_ipv4_addr;
}
//-----------------------------------------------------------------------------
bool event_notification::is_ad_ipv4_addr_is_set() const {
return m_ad_ipv4_addr_is_set;
}
//-----------------------------------------------------------------------------
void event_notification::set_re_ipv4_addr(std::string const& value) {
m_re_ipv4_addr = value;
m_re_ipv4_addr_is_set = true;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string event_notification::get_re_ipv4_addr() const { void event_exposure_msg::set_any_ue(bool value) {
return m_re_ipv4_addr; m_any_ue = value;
} }
/*
* class: Event Notification
*/
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool event_notification::is_re_ipv4_addr_is_set() const {
return m_re_ipv4_addr_is_set;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::set_notif_uri(std::string const& value) { void event_notification::set_notify_correlation_id(std::string const& value) {
m_notif_uri = value; m_notify_correlation_id = value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string event_notification::get_notif_uri() const { std::string event_notification::get_notify_correlation_id() const {
return m_notif_uri; return m_notify_correlation_id;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::set_notif_id(std::string const& value) { void event_notification::set_subs_change_notify_correlation_id(
m_notif_id = value; std::string const& value) {
m_subs_change_notify_correlation_id = value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string event_notification::get_notif_id() const { std::string event_notification::get_subs_change_notify_correlation_id() const {
return m_notif_id; return m_subs_change_notify_correlation_id;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -215,11 +163,10 @@ void data_notification_msg::get_nf_instance_uri(std::string& uri) const { ...@@ -215,11 +163,10 @@ void data_notification_msg::get_nf_instance_uri(std::string& uri) const {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void data_notification_msg::set_profile(const std::shared_ptr<nf_profile>& p) { void data_notification_msg::set_profile(const std::shared_ptr<nf_profile>& p) {
profile = p; // profile = p;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void data_notification_msg::get_profile(std::shared_ptr<nf_profile>& p) const { void data_notification_msg::get_profile(std::shared_ptr<nf_profile>& p) const {
p = profile; // p = profile;
} }
} // namespace amf
...@@ -21,136 +21,80 @@ ...@@ -21,136 +21,80 @@
/*! \file amf_msg.hpp /*! \file amf_msg.hpp
\brief \brief
\author Shivam Gandhi \author
\company KCL \company
\date 2021 \date 2021
\email: shivam.gandhi@kcl.ac.uk \email:
*/ */
#ifndef FILE_AMF_MSG_HPP_SEEN #ifndef FILE_AMF_MSG_HPP_SEEN
#define FILE_AMF_MSG_HPP_SEEN #define FILE_AMF_MSG_HPP_SEEN
#include "amf.hpp" #include "amf.hpp"
#include "3gpp_29.518.h" #include "3gpp_29.518.h"
#include "pistache/http.h"
#include "amf_profile.hpp" #include "amf_profile.hpp"
namespace amf { namespace amf_application {
class event_exposure_msg { class event_exposure_msg {
public: public:
supi_t get_supi() const; supi_t get_supi() const;
void set_supi(const supi_t& value); void set_supi(const supi_t& value);
bool is_supi_is_set() const; bool is_supi_is_set() const;
std::string get_supi_prefix() const;
void set_supi_prefix(const std::string& value);
void set_sub_id(std::string const& value); void set_sub_id(std::string const& value);
std::string get_sub_id() const; std::string get_sub_id() const;
bool is_sub_id_is_set() const; bool is_sub_id_is_set() const;
void set_notif_uri(std::string const& value);
std::string get_notif_uri() const;
void set_notif_id(std::string const& value);
std::string get_notif_id() const;
std::vector<event_subscription_t> get_event_subs() const;
void set_event_subs(std::vector<event_subscription_t> const& value);
private: void set_notify_uri(std::string const& value);
supi_t m_supi; // Supi std::string get_notify_uri() const;
bool m_supi_is_set;
std::string m_supi_prefix; void set_notify_correlation_id(std::string const& value);
std::string get_notify_correlation_id() const;
void set_nf_id(std::string const& value);
std::string get_nf_id() const;
std::vector<amf_event_t> get_event_subs() const;
void set_event_subs(std::vector<amf_event_t> const& value);
void set_any_ue(bool value);
private:
std::string m_sub_id; // m_SubId; std::string m_sub_id; // m_SubId;
bool m_sub_id_is_set; bool m_sub_id_is_set;
std::string m_notif_uri; // eventNotifyUri std::vector<amf_event_t> m_event_list; // eventList, Mandatory
std::string m_notify_uri; // eventNotifyUri, Mandatory
std::string m_notify_correlation_id; // notifyCorrelationId, Mandatory
std::string m_nf_id; // nfId, Mandatory
supi_t m_supi; // Supi, Conditional
bool m_supi_is_set;
bool m_any_ue; // anyUE, Conditional
std::string m_notif_id; // notifyCorrelationId
std::vector<event_subscription_t> m_event_subs; // eventList
// nfId:
// subsChangeNotifyUri: // subsChangeNotifyUri:
// subsChangeNotifyCorrelationId: // subsChangeNotifyCorrelationId:
// groupId: // groupId:
// gpsi: // gpsi:
// pei: // pei:
// anyUE:
// options: AmfEventMode // options: AmfEventMode
}; };
class event_notification { class event_notification {
public: public:
void set_amf_event(const amf_event_t& ev); void set_notify_correlation_id(std::string const& value);
amf_event_t get_amf_event() const; std::string get_notify_correlation_id() const;
void set_subs_change_notify_correlation_id(std::string const& value);
void set_supi(const supi64_t& supi); std::string get_subs_change_notify_correlation_id() const;
supi64_t get_supi() const;
bool is_supi_is_set() const;
// m_AdIpv4Addr
void set_ad_ipv4_addr(std::string const& value);
std::string get_ad_ipv4_addr() const;
bool is_ad_ipv4_addr_is_set() const;
// m_ReIpv4Addr
void set_re_ipv4_addr(std::string const& value);
std::string get_re_ipv4_addr() const;
bool is_re_ipv4_addr_is_set() const;
void set_notif_uri(std::string const& value);
std::string get_notif_uri() const;
void set_notif_id(std::string const& value);
std::string get_notif_id() const;
private: private:
std::string m_notif_uri; // m_NotifUri; std::string m_notify_correlation_id; // notifyCorrelationId
std::string m_notif_id; // m_NotifId; bool m_notify_correlation_is_set;
std::string
amf_event_t m_event; // AmfEvent m_subs_change_notify_correlation_id; // SubsChangeNotifyCorrelationId;
// std::string m_TimeStamp; bool m_subs_change_notify_correlation_id_is_set;
// std::vector<AmfEventReport> m_report_list; //Report List
supi64_t m_supi; bool m_report_list_is_set;
bool m_supi_is_set;
// for a UE IP address change
std::string m_ad_ipv4_addr; // m_AdIpv4Addr
bool m_ad_ipv4_addr_is_set; // m_AdIpv4AddrIsSet;
std::string m_re_ipv4_addr; // m_ReIpv4Addr;
bool m_re_ipv4_addr_is_set; // m_ReIpv4AddrIsSet;
// for a PLMN Change
// PlmnId m_PlmnId;
// bool m_PlmnIdIsSet;
// for an access type change
// AccessType m_AccType;
// bool m_AccTypeIsSet;
// std::string m_Gpsi;
// bool m_GpsiIsSet;
// std::string m_SourceDnai;
// bool m_SourceDnaiIsSet;
// std::string m_TargetDnai;
// bool m_TargetDnaiIsSet;
// DnaiChangeType m_DnaiChgType;
// bool m_DnaiChgTypeIsSet;
// std::string m_TargetUeIpv4Addr;
// bool m_TargetUeIpv4AddrIsSet;
// std::string m_SourceUeIpv4Addr;
// bool m_SourceUeIpv4AddrIsSet;
// Ipv6Prefix m_SourceUeIpv6Prefix;
// bool m_SourceUeIpv6PrefixIsSet;
// Ipv6Prefix m_TargetUeIpv6Prefix;
// bool m_TargetUeIpv6PrefixIsSet;
// RouteToLocation m_SourceTraRouting;
// bool m_SourceTraRoutingIsSet;
// RouteToLocation m_TargetTraRouting;
// bool m_TargetTraRoutingIsSet;
// std::string m_UeMac;
// bool m_UeMacIsSet;
// Ipv6Prefix m_AdIpv6Prefix;
// bool m_AdIpv6PrefixIsSet;
// Ipv6Prefix m_ReIpv6Prefix;
// bool m_ReIpv6PrefixIsSet;
// DddStatus m_DddStatus;
// bool m_DddStatusIsSet;
// std::string m_MaxWaitTime;
// bool m_MaxWaitTimeIsSet;
}; };
class data_notification_msg { class data_notification_msg {
...@@ -169,6 +113,6 @@ class data_notification_msg { ...@@ -169,6 +113,6 @@ class data_notification_msg {
// std::vector<ChangeItem> m_ProfileChanges; // std::vector<ChangeItem> m_ProfileChanges;
// bool m_ProfileChangesIsSet; // bool m_ProfileChangesIsSet;
}; };
} // namespace amf } // namespace amf_application
#endif #endif
...@@ -41,7 +41,7 @@ class amf_subscription { ...@@ -41,7 +41,7 @@ class amf_subscription {
public: public:
evsub_id_t sub_id; evsub_id_t sub_id;
amf_event_t ev_type; amf_event_type_t ev_type;
supi64_t supi; supi64_t supi;
std::string notif_id; std::string notif_id;
std::string notif_uri; std::string notif_uri;
......
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
#include "amf.hpp" #include "amf.hpp"
#include <vector> #include <vector>
typedef enum amf_event_e { typedef enum amf_event_type_e {
AMF_EVENT_UNKNOWN = 0,
LOCATION_REPORT = 1, LOCATION_REPORT = 1,
PRESENCE_IN_AOI_REPORT = 2, PRESENCE_IN_AOI_REPORT = 2,
TIMEZONE_REPORT = 3, TIMEZONE_REPORT = 3,
...@@ -38,9 +39,9 @@ typedef enum amf_event_e { ...@@ -38,9 +39,9 @@ typedef enum amf_event_e {
SUBSCRIPTION_ID_CHANGE = 10, SUBSCRIPTION_ID_CHANGE = 10,
SUBSCRIPTION_ID_ADDITION = 11, SUBSCRIPTION_ID_ADDITION = 11,
LOSS_OF_CONNECTIVITY = 12 LOSS_OF_CONNECTIVITY = 12
} amf_event_t; } amf_event_type_t;
static const std::vector<std::string> amf_event_e2str = { static const std::vector<std::string> amf_event_type_e2str = {
"AMF_EVENT_UNKNOWN", "AMF_EVENT_UNKNOWN",
"LOCATION_REPORT", "LOCATION_REPORT",
"PRESENCE_IN_AOI_REPORT", "PRESENCE_IN_AOI_REPORT",
...@@ -65,12 +66,12 @@ static const std::vector<std::string> notification_method_e2str = { ...@@ -65,12 +66,12 @@ static const std::vector<std::string> notification_method_e2str = {
"NOTIFICATION_METHOD_UNKNOWN", "PERIODIC", "ONE_TIME", "NOTIFICATION_METHOD_UNKNOWN", "PERIODIC", "ONE_TIME",
"ON_EVENT_DETECTION"}; "ON_EVENT_DETECTION"};
typedef struct event_subscription_s { typedef struct amf_event_s {
amf_event_t amf_event; amf_event_type_t type;
// immediateFlag: // immediateFlag:
// areaList: // areaList:
// locationFilterList: // locationFilterList:
// refId: // refId:
} event_subscription_t; } amf_event_t;
#endif #endif
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "pistache/http.h" #include "pistache/http.h"
#include "amf_msg.hpp" #include "amf_msg.hpp"
using namespace amf; using namespace amf_application;
class itti_sbi_msg : public itti_msg { class itti_sbi_msg : public itti_msg {
public: public:
......
...@@ -18,6 +18,7 @@ void AMFApiServer::init(size_t thr) { ...@@ -18,6 +18,7 @@ void AMFApiServer::init(size_t thr) {
m_nonUEN2MessagesCollectionDocumentApiImpl->init(); m_nonUEN2MessagesCollectionDocumentApiImpl->init();
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl->init(); m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl->init();
m_subscriptionsCollectionDocumentApiImpl->init(); m_subscriptionsCollectionDocumentApiImpl->init();
m_subscriptionsCollectionDocumentApiImplEventExposure->init();
Logger::amf_server().debug("Initiate AMF server endpoints done!"); Logger::amf_server().debug("Initiate AMF server endpoints done!");
} }
...@@ -57,6 +58,11 @@ void AMFApiServer::start() { ...@@ -57,6 +58,11 @@ void AMFApiServer::start() {
if (m_subscriptionsCollectionDocumentApiImpl != nullptr) if (m_subscriptionsCollectionDocumentApiImpl != nullptr)
Logger::amf_server().debug( Logger::amf_server().debug(
"AMF handler for SubscriptionsCollectionDocumentApiImpl"); "AMF handler for SubscriptionsCollectionDocumentApiImpl");
if (m_subscriptionsCollectionDocumentApiImplEventExposure != nullptr)
Logger::amf_server().debug(
"AMF handler for SubscriptionsCollectionDocumentApiImplEventExposure");
m_httpEndpoint->setHandler(m_router->handler()); m_httpEndpoint->setHandler(m_router->handler());
m_httpEndpoint->serve(); m_httpEndpoint->serve();
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "NonUEN2MessagesCollectionDocumentApiImpl.h" #include "NonUEN2MessagesCollectionDocumentApiImpl.h"
#include "NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl.h" #include "NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl.h"
#include "SubscriptionsCollectionDocumentApiImpl.h" #include "SubscriptionsCollectionDocumentApiImpl.h"
#include "SubscriptionsCollectionDocumentApiImplEventExposure.h"
#define PISTACHE_SERVER_THREADS 2 #define PISTACHE_SERVER_THREADS 2
#define PISTACHE_SERVER_MAX_PAYLOAD 32768 #define PISTACHE_SERVER_MAX_PAYLOAD 32768
...@@ -64,6 +65,9 @@ class AMFApiServer { ...@@ -64,6 +65,9 @@ class AMFApiServer {
m_subscriptionsCollectionDocumentApiImpl = m_subscriptionsCollectionDocumentApiImpl =
std::make_shared<SubscriptionsCollectionDocumentApiImpl>( std::make_shared<SubscriptionsCollectionDocumentApiImpl>(
m_router, amf_app_inst); m_router, amf_app_inst);
m_subscriptionsCollectionDocumentApiImplEventExposure =
std::make_shared<SubscriptionsCollectionDocumentApiImplEventExposure>(
m_router, amf_app_inst);
} }
void init(size_t thr = 1); void init(size_t thr = 1);
...@@ -95,5 +99,8 @@ class AMFApiServer { ...@@ -95,5 +99,8 @@ class AMFApiServer {
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl; m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl;
std::shared_ptr<SubscriptionsCollectionDocumentApiImpl> std::shared_ptr<SubscriptionsCollectionDocumentApiImpl>
m_subscriptionsCollectionDocumentApiImpl; m_subscriptionsCollectionDocumentApiImpl;
std::shared_ptr<SubscriptionsCollectionDocumentApiImplEventExposure>
m_subscriptionsCollectionDocumentApiImplEventExposure;
std::string m_address; std::string m_address;
}; };
...@@ -12,12 +12,19 @@ ...@@ -12,12 +12,19 @@
*/ */
#include "SubscriptionsCollectionDocumentApiImplEventExposure.h" #include "SubscriptionsCollectionDocumentApiImplEventExposure.h"
#include "amf_msg.hpp"
#include "3gpp_conversions.hpp"
#include "amf_config.hpp"
extern amf_config amf_cfg;
namespace oai { namespace oai {
namespace amf { namespace amf {
namespace api { namespace api {
using namespace oai::amf::model; using namespace oai::amf::model;
using namespace amf_application;
using namespace config;
SubscriptionsCollectionDocumentApiImplEventExposure:: SubscriptionsCollectionDocumentApiImplEventExposure::
SubscriptionsCollectionDocumentApiImplEventExposure( SubscriptionsCollectionDocumentApiImplEventExposure(
...@@ -29,7 +36,48 @@ SubscriptionsCollectionDocumentApiImplEventExposure:: ...@@ -29,7 +36,48 @@ SubscriptionsCollectionDocumentApiImplEventExposure::
void SubscriptionsCollectionDocumentApiImplEventExposure::create_subscription( void SubscriptionsCollectionDocumentApiImplEventExposure::create_subscription(
const AmfCreateEventSubscription& amfCreateEventSubscription, const AmfCreateEventSubscription& amfCreateEventSubscription,
Pistache::Http::ResponseWriter& response) { Pistache::Http::ResponseWriter& response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n"); Logger::amf_server().info(
"SubscriptionsCollectionDocumentApiImplEventExposure::create_individual_"
"subcription...");
// Create a message and store the necessary information
Logger::amf_server().debug(
"Create a Event Exposure message and store the necessary information");
amf_application::event_exposure_msg event_exposure = {};
// Convert from AmfCreateEventSubscription to event_exposure_msg
xgpp_conv::amf_event_subscription_from_openapi(
amfCreateEventSubscription, event_exposure);
// Handle the message in amf_app
std::shared_ptr<itti_sbi_event_exposure_request> itti_msg =
std::make_shared<itti_sbi_event_exposure_request>(
TASK_AMF_SBI, TASK_AMF_APP);
itti_msg->event_exposure = event_exposure;
itti_msg->http_version = 1;
evsub_id_t sub_id = m_amf_app->handle_event_exposure_subscription(itti_msg);
// Send response
nlohmann::json json_data = {};
to_json(
json_data["subscription"], amfCreateEventSubscription.getSubscription());
if (sub_id != -1) {
std::string location =
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))) + ":" +
std::to_string(amf_cfg.n11.port) + base + amf_cfg.sbi_api_version +
"/namf_event-exposure/" + std::to_string(sub_id);
json_data["subscriptionId"] = location;
response.headers().add<Pistache::Http::Header::Location>(
location); // Location header
}
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/json"));
response.send(Pistache::Http::Code(201), json_data.dump().c_str());
} }
} // namespace api } // namespace api
......
...@@ -48,10 +48,22 @@ bool AmfEventType::operator!=(const AmfEventType& rhs) const { ...@@ -48,10 +48,22 @@ bool AmfEventType::operator!=(const AmfEventType& rhs) const {
return !(*this == rhs); return !(*this == rhs);
} }
void AmfEventType::set_value(std::string value) {
this->value = value;
}
void AmfEventType::get_value(std::string& value) const {
value = this->value;
}
std::string AmfEventType::get_value() const {
return value;
}
void to_json(nlohmann::json& j, const AmfEventType& o) { void to_json(nlohmann::json& j, const AmfEventType& o) {
j = nlohmann::json(); j = o.get_value();
} }
void from_json(const nlohmann::json& j, AmfEventType& o) {} void from_json(const nlohmann::json& j, AmfEventType& o) {
o.set_value(j.get<std::string>());
}
} // namespace oai::amf::model } // namespace oai::amf::model
...@@ -44,6 +44,10 @@ class AmfEventType { ...@@ -44,6 +44,10 @@ class AmfEventType {
/// </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 AmfEventType& rhs) const; bool operator==(const AmfEventType& rhs) const;
bool operator!=(const AmfEventType& rhs) const; bool operator!=(const AmfEventType& rhs) const;
...@@ -54,6 +58,7 @@ class AmfEventType { ...@@ -54,6 +58,7 @@ class AmfEventType {
friend void from_json(const nlohmann::json& j, AmfEventType& o); friend void from_json(const nlohmann::json& j, AmfEventType& 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;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_conversions.cpp
* \brief
* \author
* \company Eurecom
* \email:
*/
#include "3gpp_conversions.hpp"
void xgpp_conv::amf_event_subscription_from_openapi(
const oai::amf::model::AmfCreateEventSubscription& event_subscription,
amf_application::event_exposure_msg& event_exposure) {
event_exposure.set_notify_uri(
event_subscription.getSubscription().getEventNotifyUri());
event_exposure.set_notify_correlation_id(
event_subscription.getSubscription().getNotifyCorrelationId());
event_exposure.set_nf_id(event_subscription.getSubscription().getNfId());
for (auto e : event_subscription.getSubscription().getEventList()) {
amf_event_t ev = {};
std::string ev_type = e.getType().get_value();
if (ev_type.compare("LOCATION_REPORT") == 0) {
ev.type = amf_event_type_e::LOCATION_REPORT;
} else if (ev_type.compare("PRESENCE_IN_AOI_REPORT") == 0) {
ev.type = amf_event_type_e::PRESENCE_IN_AOI_REPORT;
} else if (ev_type.compare("TIMEZONE_REPORT") == 0) {
ev.type = amf_event_type_e::TIMEZONE_REPORT;
} else if (ev_type.compare("ACCESS_TYPE_REPORT") == 0) {
ev.type = amf_event_type_e::ACCESS_TYPE_REPORT;
} else if (ev_type.compare("REGISTRATION_STATE_REPORT") == 0) {
ev.type = amf_event_type_e::REGISTRATION_STATE_REPORT;
} else if (ev_type.compare("CONNECTIVITY_STATE_REPORT") == 0) {
ev.type = amf_event_type_e::CONNECTIVITY_STATE_REPORT;
} else if (ev_type.compare("REACHABILITY_REPORT") == 0) {
ev.type = amf_event_type_e::REACHABILITY_REPORT;
} else if (ev_type.compare("COMMUNICATION_FAILURE_REPORT") == 0) {
ev.type = amf_event_type_e::COMMUNICATION_FAILURE_REPORT;
} else if (ev_type.compare("UES_IN_AREA_REPORT") == 0) {
ev.type = amf_event_type_e::UES_IN_AREA_REPORT;
} else if (ev_type.compare("SUBSCRIPTION_ID_CHANGE") == 0) {
ev.type = amf_event_type_e::SUBSCRIPTION_ID_CHANGE;
} else if (ev_type.compare("SUBSCRIPTION_ID_ADDITION") == 0) {
ev.type = amf_event_type_e::SUBSCRIPTION_ID_ADDITION;
} else if (ev_type.compare("LOSS_OF_CONNECTIVITY") == 0) {
ev.type = amf_event_type_e::LOSS_OF_CONNECTIVITY;
} else {
ev.type = amf_event_type_e::AMF_EVENT_UNKNOWN;
}
}
if (event_subscription.getSubscription().supiIsSet()) {
supi_t supi = {};
std::string supi_str = event_subscription.getSubscription().getSupi();
amf_string_to_supi(&supi, supi_str.c_str());
event_exposure.set_supi(supi);
}
if (event_subscription.getSubscription().anyUEIsSet()) {
event_exposure.set_any_ue(true);
} else {
event_exposure.set_any_ue(false);
}
// TODO:
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_conversions.hpp
\brief
\author
\company Eurecom
\email:
*/
#ifndef FILE_3GPP_CONVERSIONS_HPP_SEEN
#define FILE_3GPP_CONVERSIONS_HPP_SEEN
#include "amf_msg.hpp"
#include "AmfCreateEventSubscription.h"
using namespace amf_application;
using namespace oai::amf::model;
namespace xgpp_conv {
/*
* Convert AmfCreatedEventSubscription from OpenAPI into Event Exposure Msg
* @param [const oai::amf::model::AmfCreatedEventSubscription&]
* event_subscription: AmfCreatedEventSubscription in OpenAPI
* @param [amf_application::event_exposure_msg&] event_exposure: Event Exposure
* Msg
* @return void
*/
void amf_event_subscription_from_openapi(
const oai::amf::model::AmfCreateEventSubscription& event_subscription,
amf_application::event_exposure_msg& event_exposure);
} // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
...@@ -25,6 +25,10 @@ include_directories(${SRC_TOP_DIR}/common/unicode) ...@@ -25,6 +25,10 @@ include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/common) include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/utils) include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr) include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
add_library (AMF_UTILS STATIC add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/backtrace.c ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.c
...@@ -35,6 +39,7 @@ add_library (AMF_UTILS STATIC ...@@ -35,6 +39,7 @@ add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp ${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp
${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp
) )
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