Commit eb6477b3 authored by ferrerod's avatar ferrerod

Draft: Add Trigger to Event Report

parent deb6de9e
......@@ -5,6 +5,7 @@
*/
#include "UsageReport.h"
// #include <sstream>
namespace oai {
namespace smf_server {
......@@ -29,6 +30,8 @@ UsageReport::UsageReport() {
m_ulVolIsSet = false;
m_dlVol = 0;
m_dlVolIsSet = false;
m_urTrig = {};
m_urTrigIsSet = false;
}
UsageReport::~UsageReport() {}
......@@ -43,6 +46,37 @@ void to_json(nlohmann::json& j, const UsageReport& o) {
j["SEID"] = o.m_SEndID;
if (o.urSeqNIsSet())
j["UR-SEQN"] = o.m_urSeqN;
if (o.urTriggerIsSet()) {
if (o.m_urTrig.perio)
j["Trigger"] = "Periodic Reporting";
if (o.m_urTrig.volth)
j["Trigger"] = "Volume Threshold";
if (o.m_urTrig.timth)
j["Trigger"] = "Time Threshold";
if (o.m_urTrig.volqu)
j["Trigger"] = "Volume Quota";
if (o.m_urTrig.timqu)
j["Trigger"] = "Time Quota";
/*
switch (o.m_urTrig) {
case :
j["Trigger"] = "Periodic Reporting";
break;
case UsageReportTrigger::VOLTH:
j["Trigger"] = "Volume Threshold";
break;
case UsageReportTrigger::TIMTH:
j["Trigger"] = "Time Threshold";
break;
case UsageReportTrigger::VOLQU:
j["Trigger"] = "Volume Quota";
break;
case UsageReportTrigger::TIMQU:
j["Trigger"] = "Time Quota";
break;
}
*/
}
if (o.durationIsSet())
j["Duration"] = o.m_duration;
if (o.totNoPIsSet())
......@@ -68,6 +102,25 @@ void from_json(const nlohmann::json& j, UsageReport& o) {
j.at("UR-SEQN").get_to(o.m_urSeqN);
o.m_urSeqNIsSet = true;
}
if (j.find("Trigger") != j.end()) {
o.m_urTrigIsSet = true;
auto s = j.get<std::string>();
s = j.at("Trigger");
if (s == "Periodic Reporting")
o.m_urTrig.perio = 1;
if (s == "Volume Threshold")
o.m_urTrig.volth = 1;
if (s == "Time Threshold")
o.m_urTrig.timth = 1;
if (s == "Volume Quota")
o.m_urTrig.volqu = 1;
if (s == "Time Quota")
o.m_urTrig.timqu = 1;
else {
o.m_urTrigIsSet = false;
// TODO: Handle invalid JSON
}
}
if (j.find("Duration") != j.end()) {
j.at("Duration").get_to(o.m_duration);
o.m_durationIsSet = true;
......@@ -219,7 +272,19 @@ bool UsageReport::dlVolIsSet() const {
void UsageReport::unsetDlVol() {
m_dlVolIsSet = false;
}
pfcp::usage_report_trigger_t UsageReport::getURTrigger() const {
return m_urTrig;
}
void UsageReport::setURTrigger(pfcp::usage_report_trigger_t const& value) {
m_urTrig = value;
m_urTrigIsSet = true;
}
bool UsageReport::urTriggerIsSet() const {
return m_urTrigIsSet;
}
void UsageReport::unsetURTrigger() {
m_urTrigIsSet = false;
}
} // namespace model
} // namespace smf_server
......
......@@ -14,6 +14,16 @@ namespace oai {
namespace smf_server {
namespace model {
// TODO: Redefine in separate files
enum UsageReportTrigger {
PERIO = 1,
VOLTH,
TIMTH,
VOLQU,
TIMQU
};
/// <summary>
///
/// </summary>
......@@ -99,18 +109,18 @@ class UsageReport {
bool dlVolIsSet() const;
void unsetDlVol();
/// <summary>
///
/// </summary>
pfcp::usage_report_trigger_t getURTrigger() const;
void setURTrigger(pfcp::usage_report_trigger_t const& value);
bool urTriggerIsSet() const;
void unsetURTrigger();
friend void to_json(nlohmann::json& j, const UsageReport& o);
friend void from_json(const nlohmann::json& j, UsageReport& o);
protected:
pfcp::usage_report_within_pfcp_session_deletion_response m_URSessDel;
bool m_URSessDelIsSet;
pfcp::usage_report_within_pfcp_session_modification_response m_URSessMod;
bool m_URSessModIsSet;
pfcp::usage_report_within_pfcp_session_report_request m_URRequest;
bool m_URRequestIsSet;
int64_t m_SEndID;
bool m_SEndIDIsSet;
int32_t m_urSeqN;
......@@ -129,11 +139,9 @@ class UsageReport {
bool m_ulVolIsSet;
int64_t m_dlVol;
bool m_dlVolIsSet;
// pfcp::usage_report_trigger_t m_urTrig;
// bool m_urTrigIsSet;
// pfcp::usage_report_within_pfcp_session_modification_response m_urSessMod;
// bool m_urSessModIsSet;
// UsageReportTrigger m_urTrig;
pfcp::usage_report_trigger_t m_urTrig;
bool m_urTrigIsSet;
};
} // namespace model
......
......@@ -989,25 +989,11 @@ void smf_context::handle_itti_msg(
if (ur.get(seqn))
Logger::smf_app().info("\t\t UR-SEQN -> %ld", seqn.ur_seqn);
if (ur.get(trig))
if (trig.droth) Logger::smf_app().info("\t\t Trigger -> Dropped DL Traffic Threshold");
if (trig.envcl) Logger::smf_app().info("\t\t Trigger -> Envelope Closure");
if (trig.evequ) Logger::smf_app().info("\t\t Trigger -> Event Quota");
if (trig.eveth) Logger::smf_app().info("\t\t Trigger -> Event Threshold");
if (trig.immer) Logger::smf_app().info("\t\t Trigger -> Immediate Report");
if (trig.liusa) Logger::smf_app().info("\t\t Trigger -> Linked Usage Reporting");
if (trig.macar) Logger::smf_app().info("\t\t Trigger -> MAC Addresses Reporting");
if (trig.monit) Logger::smf_app().info("\t\t Trigger -> Monitoring Time");
if (trig.perio) Logger::smf_app().info("\t\t Trigger -> Periodic Reporting");
if (trig.quhti) Logger::smf_app().info("\t\t Trigger -> Quota Holding Time");
if (trig.start) Logger::smf_app().info("\t\t Trigger -> Start of Traffic");
if (trig.stop) Logger::smf_app().info("\t\t Trigger -> Stop of Traffic");
if (trig.tebur) Logger::smf_app().info("\t\t Trigger -> Termination by UP Function Report");
if (trig.termr) Logger::smf_app().info("\t\t Trigger -> Termination Report");
if (trig.timqu) Logger::smf_app().info("\t\t Trigger -> Time Quota");
if (trig.timth) Logger::smf_app().info("\t\t Trigger -> Time Threshold");
if (trig.volqu) Logger::smf_app().info("\t\t Trigger -> Volume Quota");
if (trig.volth) Logger::smf_app().info("\t\t Trigger -> Volume Threshold");
if (ur.get(dm))
Logger::smf_app().info("\t\t Duration -> %ld", dm.duration);
Logger::smf_app().info("\t\t NoP Total -> %lld", vm.total_nop);
......@@ -1040,6 +1026,8 @@ void smf_context::handle_itti_msg(
ur_model.setUlVol(vm.uplink_volume);
ur_model.setDlVol(vm.downlink_volume);
}
if (ur.usage_report_trigger.first)
ur_model.setURTrigger(ur.usage_report_trigger.second);
ev_notif.setUsageReport(ur_model);
pc.get()->trigger_qos_monitoring(req->seid, ev_notif, 1);
} else {
......
......@@ -321,38 +321,31 @@ int session_create_sm_context_procedure::run(
pfcp::measurement_period_t measurement_Period = {};
pfcp::reporting_triggers_t reporting_triggers = {};
pfcp::volume_threshold_t volume_threshold = {};
pfcp::volume_quota_t volume_quota = {};
pfcp::time_threshold_t time_threshold = {};
pfcp::time_quota_t time_quota = {};
// Hardcoded values for the moment
// measurement_method.volum = 1; // Volume based usage report
measurement_method.volum = 1; // Volume based usage report
measurement_method.durat = 1;
// measurement_Period.measurement_period = 10; // Every 10 Sec
reporting_triggers.perio = 0; // Periodic usage report
reporting_triggers.volth = 0;
measurement_Period.measurement_period = 10; // Every 10 Sec
reporting_triggers.perio = 1; // Periodic usage report
reporting_triggers.volth = 1;
reporting_triggers.timth = 1;
reporting_triggers.volqu = 0;
reporting_triggers.timth = 0;
reporting_triggers.timqu = 1;
// volume_quota.tovol = 1;
// volume_threshold.dlvol = 1;
// volume_threshold.ulvol = 1;
// volume_threshold.tovol = 0;
// volume_threshold.downlink_volume = 10;
// volume_threshold.uplink_volume = 10;
// volume_quota.total_volume = 1000;
// time_threshold.time_threshold = 30;
time_quota.time_quota = 15;
reporting_triggers.timqu = 0;
volume_threshold.dlvol = 1;
volume_threshold.ulvol = 0;
volume_threshold.tovol = 0;
volume_threshold.downlink_volume = 1000;
time_threshold.time_threshold = 30;
create_urr.set(urr_id);
create_urr.set(measurement_method);
// create_urr.set(measurement_Period);
create_urr.set(measurement_Period);
create_urr.set(reporting_triggers);
create_urr.set(time_quota);
// create_urr.set(time_threshold);
// create_urr.set(volume_threshold);
// create_urr.set(volume_quota);
create_urr.set(time_threshold);
create_urr.set(volume_threshold);
n4_triggered->pfcp_ies.set(create_urr);
}
......
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