Commit bda05ffa authored by Hung Nguyen's avatar Hung Nguyen

[feature] support ddds event exposure | still missing data for this feature

parent 1e2f4413
...@@ -3119,49 +3119,81 @@ void smf_context::trigger_ddds(scid_t scid, uint8_t http_version) { ...@@ -3119,49 +3119,81 @@ void smf_context::trigger_ddds(scid_t scid, uint8_t http_version) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_context::handle_ddds( scid_t scid, uint8_t http_version) { void smf_context::handle_ddds( scid_t scid, uint8_t http_version) {
// Logger::smf_app().debug( Logger::smf_app().debug(
// "Send request to N11 to triger PDU Session Release Notification (Event " "Send request to N11 to triger FlexCN, "
// "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "SMF Context ID " SCID_FMT " ",
// supi, pdu_session_id, http_version); scid);
// std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; // get the smf context
// smf_app_inst->get_ee_subscriptions( std::shared_ptr<smf_context_ref> scf = {};
// smf_event_t::SMF_EVENT_PDU_SES_REL, subscriptions);
if (smf_app_inst->is_scid_2_smf_context(scid)) {
// if (subscriptions.size() > 0) { scf = smf_app_inst->scid_2_smf_context(scid);
// // Send request to N11 to trigger the notification to the subscribed event } else {
// Logger::smf_app().debug( Logger::smf_app().warn(
// "Send ITTI msg to SMF N11 to trigger the event notification"); "Context associated with this id " SCID_FMT " does not exit!", scid);
// std::shared_ptr<itti_n11_notify_subscribed_event> itti_msg = return;
// std::make_shared<itti_n11_notify_subscribed_event>( }
// TASK_SMF_APP, TASK_SMF_SBI);
supi_t supi = scf.get()->supi;
// for (auto i : subscriptions) { supi64_t supi64 = smf_supi_to_u64(supi);
// event_notification ev_notif = {}; // pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id;
// ev_notif.set_supi(supi);
// ev_notif.set_pdu_session_id(pdu_session_id); std::shared_ptr<smf_context> sc = {};
// ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PDU_SES_REL);
// ev_notif.set_supi(supi); if (smf_app_inst->is_supi_2_smf_context(supi64)) {
// ev_notif.set_notif_uri(i.get()->notif_uri); sc = smf_app_inst->supi_2_smf_context(supi64);
// ev_notif.set_notif_id(i.get()->notif_id); Logger::smf_app().debug(
// // custom json e.g., for FlexCN "Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
// // nlohmann::json cj = {}; } else {
// // cj["ue_ipv4_addr"] = "12.1.1.2"; Logger::smf_app().warn(
// // cj[""] "Could not retrieve the corresponding SMF context with "
// itti_msg->event_notifs.push_back(ev_notif); "Supi " SUPI_64_FMT "!",
// } supi64);
}
// itti_msg->http_version = http_version;
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
// int ret = itti_inst->send_msg(itti_msg); smf_app_inst->get_ee_subscriptions(
// if (RETURNok != ret) { smf_event_t::SMF_EVENT_DDDS, subscriptions);
// Logger::smf_app().error(
// "Could not send ITTI message %s to task TASK_SMF_SBI", if (subscriptions.size() > 0) {
// itti_msg->get_msg_name()); // Send request to N11 to trigger the notification to the subscribed event
// } Logger::smf_app().debug(
// } else { "Send ITTI msg to SMF N11 to trigger the event notification");
// Logger::smf_app().debug("No subscription available for this event"); std::shared_ptr<itti_n11_notify_subscribed_event> itti_msg =
// } std::make_shared<itti_n11_notify_subscribed_event>(
TASK_SMF_APP, TASK_SMF_SBI);
for (auto i : subscriptions) {
event_notification ev_notif = {};
ev_notif.set_supi(supi64); // SUPI
// ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_DDDS);
ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id);
// timestamp
std::time_t time_epoch_ntp = std::time(nullptr);
uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH;
ev_notif.set_timestamp(std::to_string(tv_ntp));
// DDDS Status
// TODO: where to get this information in SMF???
oai::smf_server::model::DddStatus ddds = oai::smf_server::model::DddStatus();
ev_notif.set_Ddds(ddds);
itti_msg->event_notifs.push_back(ev_notif);
}
itti_msg->http_version = http_version;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_SBI",
itti_msg->get_msg_name());
}
} else {
Logger::smf_app().debug("No subscription available for this event");
}
} }
...@@ -3484,7 +3516,7 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -3484,7 +3516,7 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
supi_t supi = scf.get()->supi; supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi); supi64_t supi64 = smf_supi_to_u64(supi);
pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id; // pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id;
std::shared_ptr<smf_context> sc = {}; std::shared_ptr<smf_context> sc = {};
...@@ -3499,31 +3531,6 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -3499,31 +3531,6 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
supi64); supi64);
} }
// get dnn context
std::shared_ptr<dnn_context> sd = {};
if (!sc.get()->find_dnn_context(scf.get()->nssai, scf.get()->dnn, sd)) {
if (nullptr == sd.get()) {
Logger::smf_app().warn(
"Could not retrieve the corresponding DNN context!");
return;
}
}
// get smf_pdu_session
std::shared_ptr<smf_pdu_session> sp = {};
bool find_pdn = sd.get()->find_pdu_session(pdu_session_id, sp);
if (nullptr == sp.get()) {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF PDU Session context!");
return;
}
Logger::smf_app().debug(
"Send request to N11 to triger FlexCN (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d",
supi, pdu_session_id, http_version);
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
smf_event_t::SMF_EVENT_FLEXCN, subscriptions); smf_event_t::SMF_EVENT_FLEXCN, subscriptions);
...@@ -3539,8 +3546,8 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -3539,8 +3546,8 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
for (auto i : subscriptions) { for (auto i : subscriptions) {
event_notification ev_notif = {}; event_notification ev_notif = {};
ev_notif.set_supi(supi64); // SUPI ev_notif.set_supi(supi64); // SUPI
ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID // ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_FLEXCN); ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PLMN_CH);
ev_notif.set_notif_uri(i.get()->notif_uri); ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id); ev_notif.set_notif_id(i.get()->notif_id);
// timestamp // timestamp
...@@ -3548,73 +3555,15 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -3548,73 +3555,15 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH; uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH;
ev_notif.set_timestamp(std::to_string(tv_ntp)); ev_notif.set_timestamp(std::to_string(tv_ntp));
// custom json e.g., for FlexCN
nlohmann::json cj = {};
// PLMN // PLMN
plmn_t plmn = {}; plmn_t plmn = {};
std::string mcc, mnc; std::string mcc, mnc;
sc->get_plmn(plmn); sc->get_plmn(plmn);
conv::plmnToMccMnc(plmn, mcc, mnc); conv::plmnToMccMnc(plmn, mcc, mnc);
cj["plmn"]["mcc"] = mcc; oai::smf_server::model::PlmnId plmnid;
cj["plmn"]["mnc"] = mnc; plmnid.setMcc(mcc);
// UE IPv4 plmnid.setMnc(mnc);
if (sp->ipv4) { ev_notif.set_PlmnId(plmnid);
cj["ue_ipv4_addr"] = conv::toString(sp->ipv4_address);
}
// UE IPv6
if (sp->ipv6) {
char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(
AF_INET6, &sp->ipv6_address, str_addr6, sizeof(str_addr6))) {
cj["ue_ipv6_prefix"] = str_addr6;
}
}
// PDU Session Type
cj["pdu_session_type"] = sp->pdu_session_type.toString();
// NSSAI
cj["snssai"]["sst"] = scf->nssai.sST;
cj["snssai"]["sd"] = scf->nssai.sD;
// DNN
cj["dnn"] = scf->dnn;
// Serving AMF addr
cj["amf_addr"] = scf->amf_addr;
// QoS flows associated with this session
std::vector<smf_qos_flow> flows = {};
sp->get_qos_flows(flows);
if (flows.size() > 0) {
cj["qos_flow"] = nlohmann::json::array();
for (auto f : flows) {
nlohmann::json tmp = {};
tmp["qfi"] = (uint8_t) f.qfi.qfi;
// UL FTeid IPv4/IPv6 (UPF)
if (f.ul_fteid.v4)
tmp["upf_addr"]["ipv4"] = inet_ntoa(f.ul_fteid.ipv4_address);
if (f.ul_fteid.v6) {
char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(
AF_INET6, &f.ul_fteid.ipv6_address, str_addr6,
sizeof(str_addr6))) {
tmp["upf_addr"]["ipv6"] = str_addr6;
}
}
// DL FTeid Ipv4/v6 (AN)
if (f.dl_fteid.v4)
tmp["an_addr"]["ipv4"] = inet_ntoa(f.dl_fteid.ipv4_address);
if (f.dl_fteid.v6) {
char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(
AF_INET6, &f.dl_fteid.ipv6_address, str_addr6,
sizeof(str_addr6))) {
tmp["an_addr"]["ipv6"] = str_addr6;
}
}
cj["qos_flow"].push_back(tmp);
}
}
ev_notif.set_custom_info(cj);
itti_msg->event_notifs.push_back(ev_notif); itti_msg->event_notifs.push_back(ev_notif);
} }
......
...@@ -62,12 +62,12 @@ typedef bs2::signal_type< ...@@ -62,12 +62,12 @@ typedef bs2::signal_type<
// TODO: UP Path Change // TODO: UP Path Change
// TODO: PLMN Change // TODO: PLMN Change
typedef bs2::signal_type< typedef bs2::signal_type<
void(supi64_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(scid_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_plmn_change_sig_t; ee_plmn_change_sig_t;
// TODO: Downlink data delivery status // TODO: Downlink data delivery status
typedef bs2::signal_type< typedef bs2::signal_type<
void(supi64_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(scid_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_ddds_sig_t; ee_ddds_sig_t;
// Signal for FlexCN event (for Event Exposure) // Signal for FlexCN event (for Event Exposure)
......
...@@ -883,6 +883,21 @@ smf_event_t event_notification::get_smf_event() const { ...@@ -883,6 +883,21 @@ smf_event_t event_notification::get_smf_event() const {
return m_event; return m_event;
} }
//-----------------------------------------------------------------------------
// ddds change
void event_notification::set_Ddds(oai::smf_server::model::DddStatus const& value){
m_DddStatus = value;
m_DddStatusIsSet = true;
}
oai::smf_server::model::DddStatus event_notification::get_ddds() const{
return m_DddStatus;
}
bool event_notification::is_ddds_is_set() const{
return m_DddStatusIsSet;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void event_notification::set_timestamp(const std::string& ss) { void event_notification::set_timestamp(const std::string& ss) {
m_timestamp = ss; m_timestamp = ss;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "pistache/http.h" #include "pistache/http.h"
#include "smf_profile.hpp" #include "smf_profile.hpp"
#include "PlmnId.h" #include "PlmnId.h"
#include "DddStatus.h"
extern "C" { extern "C" {
#include "QOSRules.h" #include "QOSRules.h"
...@@ -589,6 +590,12 @@ class event_notification { ...@@ -589,6 +590,12 @@ class event_notification {
oai::smf_server::model::PlmnId get_plmnid() const; oai::smf_server::model::PlmnId get_plmnid() const;
bool is_plmnid_is_set() const; bool is_plmnid_is_set() const;
// ddds change
void set_Ddds(oai::smf_server::model::DddStatus const& value);
oai::smf_server::model::DddStatus get_ddds() const;
bool is_ddds_is_set() const;
void set_pdu_session_id(const pdu_session_id_t value); void set_pdu_session_id(const pdu_session_id_t value);
pdu_session_id_t get_pdu_session_id() const; pdu_session_id_t get_pdu_session_id() const;
bool is_psi_is_set() const; bool is_psi_is_set() const;
...@@ -621,6 +628,10 @@ class event_notification { ...@@ -621,6 +628,10 @@ class event_notification {
oai::smf_server::model::PlmnId m_PlmnId; oai::smf_server::model::PlmnId m_PlmnId;
bool m_PlmnIdIsSet; bool m_PlmnIdIsSet;
// for ddds change
oai::smf_server::model::DddStatus m_DddStatus;
bool m_DddStatusIsSet;
// for an access type change // for an access type change
// AccessType m_AccType; // AccessType m_AccType;
// bool m_AccTypeIsSet; // bool m_AccTypeIsSet;
...@@ -655,8 +666,6 @@ class event_notification { ...@@ -655,8 +666,6 @@ class event_notification {
// bool m_AdIpv6PrefixIsSet; // bool m_AdIpv6PrefixIsSet;
// Ipv6Prefix m_ReIpv6Prefix; // Ipv6Prefix m_ReIpv6Prefix;
// bool m_ReIpv6PrefixIsSet; // bool m_ReIpv6PrefixIsSet;
// DddStatus m_DddStatus;
// bool m_DddStatusIsSet;
// std::string m_MaxWaitTime; // std::string m_MaxWaitTime;
// bool m_MaxWaitTimeIsSet; // bool m_MaxWaitTimeIsSet;
}; };
......
...@@ -1138,6 +1138,8 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1138,6 +1138,8 @@ void session_update_sm_context_procedure::handle_itti_msg(
// Trigger Event_exposure event // Trigger Event_exposure event
scid_t scid = sc.get()->get_scid(); scid_t scid = sc.get()->get_scid();
sc.get()->trigger_ue_ip_change(scid, 1); sc.get()->trigger_ue_ip_change(scid, 1);
sc.get()->trigger_plmn_change(scid, 1);
sc.get()->trigger_ddds(scid, 1);
sc.get()->trigger_flexcn_event(scid, 1); sc.get()->trigger_flexcn_event(scid, 1);
} break; } break;
......
...@@ -583,13 +583,16 @@ void smf_sbi::notify_subscribed_event( ...@@ -583,13 +583,16 @@ void smf_sbi::notify_subscribed_event(
// add support for plmn change. // add support for plmn change.
if (i.is_plmnid_is_set()) { if (i.is_plmnid_is_set()) {
oai::smf_server::model::PlmnId plmnid = i.get_plmnid(); event_notif["plmnId"] = i.get_plmnid();
nlohmann::json plmnid_data = {};
//oai::smf_server::model::
to_json(plmnid_data, plmnid);
event_notif["plmnId"] = plmnid_data;
} }
// add support for ddds
if (i.is_ddds_is_set()) {
//TODO: change this one to the real value when finished the event for ddds
// event_notif["dddStatus"] = i.get_ddds();
event_notif["dddStatus"] = "TRANSMITTED";
}
// customized data // customized data
nlohmann::json customized_data = {}; nlohmann::json customized_data = {};
i.get_custom_info(customized_data); i.get_custom_info(customized_data);
......
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