From e078b33f0c4d6f34d8991f8ad211dd2d9ea977a0 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 5 Apr 2024 14:07:21 +0200 Subject: [PATCH] [SMF] Fix Volume/Time Threshold conversion Gy->PFCP AS shown in 3GPP TS 29.244 C.2.1.1 diagram, the meaning of Threshold value is different in Diameter Gy and in PFCP interfaces. In Diameter Gy the value sets the trigger for the "remaining credit", while in PFCP the value sets the trigger for the "used credit". ThresholdPFCP = Quota - ThresholdGy --- src/smf/gy-handler.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/smf/gy-handler.c b/src/smf/gy-handler.c index 63b780a50..14ef79d86 100644 --- a/src/smf/gy-handler.c +++ b/src/smf/gy-handler.c @@ -47,12 +47,14 @@ static void urr_update_volume(smf_sess_t *sess, ogs_pfcp_urr_t *urr, ogs_diam_gy urr->vol_quota.total_volume = 0; } - /* Volume Threshold */ - if (gy_message->cca.volume_threshold) { + /* Volume Threshold, requires Volume Quota for calculations */ + if (gy_message->cca.volume_threshold && + gy_message->cca.granted.cc_total_octets >= gy_message->cca.volume_threshold) { ogs_debug("Adding Volume Threshold total_octets=%" PRIu32, gy_message->cca.volume_threshold); urr->rep_triggers.volume_threshold = 1; urr->vol_threshold.tovol = 1; - urr->vol_threshold.total_volume = gy_message->cca.volume_threshold; + urr->vol_threshold.total_volume = (gy_message->cca.granted.cc_total_octets - + gy_message->cca.volume_threshold); } else { urr->rep_triggers.volume_threshold = 0; urr->vol_threshold.tovol = 0; @@ -94,6 +96,7 @@ static void urr_update_time(smf_sess_t *sess, ogs_pfcp_urr_t *urr, ogs_diam_gy_m urr->meas_method &= ~OGS_PFCP_MEASUREMENT_METHOD_DURATION; } + /* Time Quota */ if (time_quota) { ogs_debug("Adding Time Quota secs=%" PRIu32, time_quota); urr->rep_triggers.time_quota = 1; @@ -103,10 +106,12 @@ static void urr_update_time(smf_sess_t *sess, ogs_pfcp_urr_t *urr, ogs_diam_gy_m urr->time_quota = 0; } - if (gy_message->cca.time_threshold) { + /* Time Threshold, requires Time Quota for calculations */ + if (gy_message->cca.time_threshold && + time_quota >= gy_message->cca.time_threshold) { ogs_debug("Adding Time Threshold secs=%" PRIu32, gy_message->cca.time_threshold); urr->rep_triggers.time_threshold = 1; - urr->time_threshold = gy_message->cca.time_threshold; + urr->time_threshold = (time_quota - gy_message->cca.time_threshold); } else { urr->rep_triggers.time_threshold = 0; urr->time_threshold = 0;