Commit 1e2f4413 authored by Hung Nguyen's avatar Hung Nguyen

[feature] add new events to smf exposure services

parent 0ed39237
......@@ -3,33 +3,33 @@
INSTANCE=1
PREFIX='/usr/local/etc/oai'
sudo mkdir -m 0777 -p $PREFIX
mkdir -m 0777 -p $PREFIX
cp ../../etc/smf.conf $PREFIX
declare -A SMF_CONF
SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX
# SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='enx0050b6f4b8f0'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='enx0050b6f4b8f0'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='eth0'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='eth0'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80'
SMF_CONF[@SMF_INTERFACE_HTTP2_PORT_FOR_SBI@]='9090'
SMF_CONF[@SMF_API_VERSION@]='v1'
SMF_CONF[@UDM_IPV4_ADDRESS@]='172.16.1.103'
SMF_CONF[@UDM_IPV4_ADDRESS@]='192.168.74.194'
SMF_CONF[@UDM_PORT@]='80'
SMF_CONF[@UDM_API_VERSION@]='v2'
SMF_CONF[@AMF_IPV4_ADDRESS@]='192.168.122.183'
SMF_CONF[@AMF_IPV4_ADDRESS@]='192.168.74.195'
SMF_CONF[@AMF_PORT@]='80'
SMF_CONF[@AMF_API_VERSION@]='v1'
SMF_CONF[@UPF_IPV4_ADDRESS@]='192.168.12.245'
SMF_CONF[@UPF_IPV4_ADDRESS@]='192.168.74.202'
SMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
SMF_CONF[@NRF_IPV4_ADDRESS@]='127.0.0.1'
SMF_CONF[@NRF_PORT@]='8080'
SMF_CONF[@NRF_API_VERSION@]='v1'
......
......@@ -3112,6 +3112,59 @@ void smf_context::handle_ee_pdu_session_release(
}
}
//------------------------------------------------------------------------------
void smf_context::trigger_ddds(scid_t scid, uint8_t http_version) {
event_sub.ee_ddds(scid, http_version);
}
//------------------------------------------------------------------------------
void smf_context::handle_ddds( scid_t scid, uint8_t http_version) {
// Logger::smf_app().debug(
// "Send request to N11 to triger PDU Session Release Notification (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 = {};
// smf_app_inst->get_ee_subscriptions(
// smf_event_t::SMF_EVENT_PDU_SES_REL, subscriptions);
// if (subscriptions.size() > 0) {
// // Send request to N11 to trigger the notification to the subscribed event
// Logger::smf_app().debug(
// "Send ITTI msg to SMF N11 to trigger the event notification");
// 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(supi);
// ev_notif.set_pdu_session_id(pdu_session_id);
// ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PDU_SES_REL);
// ev_notif.set_supi(supi);
// ev_notif.set_notif_uri(i.get()->notif_uri);
// ev_notif.set_notif_id(i.get()->notif_id);
// // custom json e.g., for FlexCN
// // nlohmann::json cj = {};
// // cj["ue_ipv4_addr"] = "12.1.1.2";
// // cj[""]
// 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");
// }
}
//------------------------------------------------------------------------------
void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) {
Logger::smf_app().debug(
......@@ -3406,6 +3459,179 @@ void smf_context::trigger_flexcn_event(scid_t scid, uint8_t http_version) {
event_sub.ee_flexcn(scid, http_version);
}
////------------------------------------------------------------------------------
void smf_context::trigger_plmn_change(scid_t scid, uint8_t http_version) {
event_sub.ee_plmn_change(scid, http_version);
}
//------------------------------------------------------------------------------
void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
Logger::smf_app().debug(
"Send request to N11 to triger FlexCN, "
"SMF Context ID " SCID_FMT " ",
scid);
// get the smf context
std::shared_ptr<smf_context_ref> scf = {};
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
} else {
Logger::smf_app().warn(
"Context associated with this id " SCID_FMT " does not exit!", scid);
return;
}
supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id;
std::shared_ptr<smf_context> sc = {};
if (smf_app_inst->is_supi_2_smf_context(supi64)) {
sc = smf_app_inst->supi_2_smf_context(supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF context with "
"Supi " SUPI_64_FMT "!",
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 = {};
smf_app_inst->get_ee_subscriptions(
smf_event_t::SMF_EVENT_FLEXCN, subscriptions);
if (subscriptions.size() > 0) {
// Send request to N11 to trigger the notification to the subscribed event
Logger::smf_app().debug(
"Send ITTI msg to SMF N11 to trigger the event notification");
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_FLEXCN);
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));
// custom json e.g., for FlexCN
nlohmann::json cj = {};
// PLMN
plmn_t plmn = {};
std::string mcc, mnc;
sc->get_plmn(plmn);
conv::plmnToMccMnc(plmn, mcc, mnc);
cj["plmn"]["mcc"] = mcc;
cj["plmn"]["mnc"] = mnc;
// UE IPv4
if (sp->ipv4) {
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->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");
}
}
//------------------------------------------------------------------------------
void smf_context::update_qos_info(
std::shared_ptr<smf_pdu_session>& sp,
......
......@@ -582,6 +582,14 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
ee_ue_ip_change_connection = event_sub.subscribe_ee_ue_ip_change(
boost::bind(&smf_context::handle_ue_ip_change, this, _1, _2));
// Subscribe to PLMN Change Event
ee_plmn_change_connection = event_sub.subscribe_ee_plmn_change(
boost::bind(&smf_context::handle_plmn_change, this, _1, _2));
// Subscribe to DDDS event
ee_ddds_connection = event_sub.subscribe_ee_ddds(
boost::bind(&smf_context::handle_ddds, this, _1, _2));
// Subscribe to FlexCN event
ee_flexcn = event_sub.subscribe_ee_flexcn_event(
boost::bind(&smf_context::handle_flexcn_event, this, _1, _2));
......@@ -598,6 +606,10 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
ee_pdu_session_release_connection.disconnect();
if (ee_ue_ip_change_connection.connected())
ee_ue_ip_change_connection.disconnect();
if (ee_plmn_change_connection.connected())
ee_plmn_change_connection.disconnect();
if (ee_ddds_connection.connected())
ee_ddds_connection.disconnect();
if (ee_flexcn.connected()) ee_flexcn.disconnect();
}
......@@ -1046,6 +1058,12 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
void trigger_ue_ip_change(scid_t scid, uint8_t http_version);
void handle_ue_ip_change(scid_t scid, uint8_t http_version);
void trigger_plmn_change(scid_t scid, uint8_t http_version);
void handle_plmn_change(scid_t scid, uint8_t http_version);
void trigger_ddds(scid_t scid, uint8_t http_version);
void handle_ddds(scid_t scid, uint8_t http_version);
void trigger_flexcn_event(scid_t scid, uint8_t http_version);
void handle_flexcn_event(scid_t scid, uint8_t http_version);
/*
......@@ -1100,6 +1118,8 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
bs2::connection sm_context_status_connection;
bs2::connection ee_pdu_session_release_connection;
bs2::connection ee_ue_ip_change_connection;
bs2::connection ee_plmn_change_connection;
bs2::connection ee_ddds_connection;
bs2::connection ee_flexcn;
};
} // namespace smf
......
......@@ -54,6 +54,18 @@ bs2::connection smf_event::subscribe_ee_ue_ip_change(
return ee_ue_ip_change.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection smf_event::subscribe_ee_plmn_change(
const ee_plmn_change_sig_t::slot_type& sig) {
return ee_plmn_change.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection smf_event::subscribe_ee_ddds(
const ee_ddds_sig_t::slot_type& sig) {
return ee_ddds.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection smf_event::subscribe_ee_flexcn_event(
const ee_flexcn_sig_t::slot_type& sig) {
......
......@@ -76,6 +76,13 @@ class smf_event {
bs2::connection subscribe_ee_ue_ip_change(
const ee_ue_ip_change_sig_t::slot_type& sig);
bs2::connection subscribe_ee_plmn_change(
const ee_plmn_change_sig_t::slot_type& sig);
// download link data status
bs2::connection subscribe_ee_ddds(
const ee_ddds_sig_t::slot_type& sig);
bs2::connection subscribe_ee_flexcn_event(
const ee_flexcn_sig_t::slot_type& sig);
......@@ -85,6 +92,8 @@ class smf_event {
ee_pdu_session_release_sig_t
ee_pdu_session_release; // Signal for PDU Session Release
ee_ue_ip_change_sig_t ee_ue_ip_change; // Signal for UE IP Addr change
ee_plmn_change_sig_t ee_plmn_change; // Signal for UE IP Addr change
ee_ddds_sig_t ee_ddds;
ee_flexcn_sig_t ee_flexcn; // Signal for FlexCN Event
};
} // namespace smf
......
......@@ -61,7 +61,14 @@ typedef bs2::signal_type<
// TODO: Access Type Change
// TODO: UP Path Change
// TODO: PLMN Change
typedef bs2::signal_type<
void(supi64_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_plmn_change_sig_t;
// TODO: Downlink data delivery status
typedef bs2::signal_type<
void(supi64_t, uint8_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_ddds_sig_t;
// Signal for FlexCN event (for Event Exposure)
// SCID, HTTP version
......
......@@ -946,6 +946,20 @@ bool event_notification::is_re_ipv4_addr_is_set() const {
return m_re_ipv4_addr_is_set;
}
// m_PlmnId
void event_notification::set_PlmnId(oai::smf_server::model::PlmnId const& value){
m_PlmnId = value;
m_PlmnIdIsSet = true;
}
oai::smf_server::model::PlmnId event_notification::get_plmnid() const{
return m_PlmnId;
}
bool event_notification::is_plmnid_is_set() const{
return m_PlmnIdIsSet;
}
//-----------------------------------------------------------------------------
void event_notification::set_pdu_session_id(const pdu_session_id_t value) {
m_pdu_session_id = value;
......
......@@ -39,11 +39,14 @@
#include "NgRanTargetId.h"
#include "pistache/http.h"
#include "smf_profile.hpp"
#include "PlmnId.h"
extern "C" {
#include "QOSRules.h"
}
// using namespace oai::smf_server::model;
typedef enum {
PDU_SESSION_MSG_TYPE_NONE = -1,
PDU_SESSION_MSG_TYPE_FIRST = 0,
......@@ -581,6 +584,11 @@ class event_notification {
std::string get_re_ipv4_addr() const;
bool is_re_ipv4_addr_is_set() const;
// m_PlmnId
void set_PlmnId(oai::smf_server::model::PlmnId const& value);
oai::smf_server::model::PlmnId get_plmnid() const;
bool is_plmnid_is_set() const;
void set_pdu_session_id(const pdu_session_id_t value);
pdu_session_id_t get_pdu_session_id() const;
bool is_psi_is_set() const;
......@@ -610,8 +618,8 @@ class event_notification {
bool m_re_ipv4_addr_is_set; // m_ReIpv4AddrIsSet;
// for a PLMN Change
// PlmnId m_PlmnId;
// bool m_PlmnIdIsSet;
oai::smf_server::model::PlmnId m_PlmnId;
bool m_PlmnIdIsSet;
// for an access type change
// AccessType m_AccType;
......
......@@ -43,6 +43,7 @@
#include "smf.h"
#include "smf_app.hpp"
#include "smf_config.hpp"
#include "PlmnId.h"
extern "C" {
#include "dynamic_memory_check.h"
......@@ -579,6 +580,16 @@ void smf_sbi::notify_subscribed_event(
if (i.is_re_ipv4_addr_is_set()) {
event_notif["reIpv4Addr"] = i.get_re_ipv4_addr();
}
// add support for plmn change.
if (i.is_plmnid_is_set()) {
oai::smf_server::model::PlmnId plmnid = i.get_plmnid();
nlohmann::json plmnid_data = {};
//oai::smf_server::model::
to_json(plmnid_data, plmnid);
event_notif["plmnId"] = plmnid_data;
}
// customized data
nlohmann::json 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