add support for sigscale ocs

added several changes to correctly work with sigscal ocs offline charging
This commit is contained in:
Abdelmuhaimen Seaudi 2023-04-12 22:31:01 +02:00
parent 77c92eb37b
commit 69831c43f5
3 changed files with 29 additions and 8 deletions

View File

@ -40,6 +40,7 @@ extern "C" {
#define OGS_DIAM_AUTHORIZATION_REJECTED 5003 #define OGS_DIAM_AUTHORIZATION_REJECTED 5003
#define OGS_DIAM_MISSING_AVP 5004 #define OGS_DIAM_MISSING_AVP 5004
#define OGS_DIAM_INVALID_AVP_VALUE 5005 #define OGS_DIAM_INVALID_AVP_VALUE 5005
#define OGS_DIAM_USER_UNKNOWN 5030
extern struct dict_object *ogs_diam_session_id; extern struct dict_object *ogs_diam_session_id;
extern struct dict_object *ogs_diam_termination_cause; extern struct dict_object *ogs_diam_termination_cause;

View File

@ -197,10 +197,13 @@ void smf_gy_handle_cca_update_request(
urr_update_time(sess, urr, gy_message); urr_update_time(sess, urr, gy_message);
urr_update_volume(sess, urr, gy_message); urr_update_volume(sess, urr, gy_message);
/* Associate accounting URR each direction PDR: */
ogs_pfcp_pdr_associate_urr(bearer->ul_pdr, urr); ogs_pfcp_pdr_associate_urr(bearer->ul_pdr, urr);
ogs_pfcp_pdr_associate_urr(bearer->dl_pdr, urr);
if (urr->meas_method != prev_meas_method) if (urr->meas_method != prev_meas_method)
modify_flags |= OGS_PFCP_MODIFY_URR_MEAS_METHOD; modify_flags |= OGS_PFCP_MODIFY_URR_MEAS_METHOD;
if (urr->rep_triggers.quota_validity_time != prev_rep_triggers.quota_validity_time || if (urr->rep_triggers.quota_validity_time != prev_rep_triggers.quota_validity_time ||
urr->rep_triggers.time_quota != prev_rep_triggers.time_quota || urr->rep_triggers.time_quota != prev_rep_triggers.time_quota ||
urr->rep_triggers.volume_quota != prev_rep_triggers.volume_quota || urr->rep_triggers.volume_quota != prev_rep_triggers.volume_quota ||
@ -214,8 +217,7 @@ void smf_gy_handle_cca_update_request(
if (urr->time_quota != prev_time_quota) if (urr->time_quota != prev_time_quota)
modify_flags |= OGS_PFCP_MODIFY_URR_TIME_QUOTA; modify_flags |= OGS_PFCP_MODIFY_URR_TIME_QUOTA;
if (urr->vol_quota.tovol != prev_vol_quota.tovol || if (urr->vol_quota.tovol || urr->vol_quota.total_volume)
urr->vol_quota.total_volume != prev_vol_quota.total_volume)
modify_flags |= OGS_PFCP_MODIFY_URR_VOLUME_QUOTA; modify_flags |= OGS_PFCP_MODIFY_URR_VOLUME_QUOTA;
if (urr->time_threshold != prev_time_threshold) if (urr->time_threshold != prev_time_threshold)

View File

@ -98,7 +98,16 @@ static void fill_multiple_services_credit_control_ccr(smf_sess_t *sess,
/* CC-Time, RFC4006 8.21 */ /* CC-Time, RFC4006 8.21 */
/* CC-Money, RFC4006 8.22. Not used in 3GPP. */ /* CC-Money, RFC4006 8.22. Not used in 3GPP. */
/* CC-Total-Octets, RFC4006 8.23 */ /* CC-Total-Octets, RFC4006 8.23 */
ret = fd_msg_avp_new(ogs_diam_gy_cc_total_octets, 0, &avpch2);
ogs_assert(ret == 0);
val.u64 = 1000000;
ret = fd_msg_avp_setvalue (avpch2, &val);
ogs_assert(ret == 0);
ret = fd_msg_avp_add (avpch1, MSG_BRW_LAST_CHILD, avpch2);
ogs_assert(ret == 0);
/* CC-Input-Octets, RFC4006 8.24 */ /* CC-Input-Octets, RFC4006 8.24 */
/* CC-Output-Octets, RFC4006 8.25 */ /* CC-Output-Octets, RFC4006 8.25 */
/* CC-Service-Specific-Units, RFC4006 8.26 */ /* CC-Service-Specific-Units, RFC4006 8.26 */
@ -107,6 +116,8 @@ static void fill_multiple_services_credit_control_ccr(smf_sess_t *sess,
ogs_assert(ret == 0); ogs_assert(ret == 0);
} }
if (cc_request_type != OGS_DIAM_GY_CC_REQUEST_TYPE_INITIAL_REQUEST) {
/* Used-Service-Unit, RFC4006 8.18 */ /* Used-Service-Unit, RFC4006 8.18 */
ret = fd_msg_avp_new(ogs_diam_gy_used_service_unit, 0, &avpch1); ret = fd_msg_avp_new(ogs_diam_gy_used_service_unit, 0, &avpch1);
ogs_assert(ret == 0); ogs_assert(ret == 0);
@ -170,6 +181,7 @@ static void fill_multiple_services_credit_control_ccr(smf_sess_t *sess,
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1); ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
ogs_assert(ret == 0); ogs_assert(ret == 0);
//bypass USU if we are in CCR INITIAL
/* Service-Identifier, RFC4006 8.28. Not used in Gy. */ /* Service-Identifier, RFC4006 8.28. Not used in Gy. */
/* Rating-Group */ /* Rating-Group */
@ -284,7 +296,7 @@ static void fill_multiple_services_credit_control_ccr(smf_sess_t *sess,
ogs_assert(ret == 0); ogs_assert(ret == 0);
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1); ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
ogs_assert(ret == 0); ogs_assert(ret == 0);
}
/* Multiple Services AVP add to req: */ /* Multiple Services AVP add to req: */
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp); ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
ogs_assert(ret == 0); ogs_assert(ret == 0);
@ -294,6 +306,7 @@ static void fill_multiple_services_credit_control_ccr(smf_sess_t *sess,
static void fill_service_information_ccr(smf_sess_t *sess, static void fill_service_information_ccr(smf_sess_t *sess,
uint32_t cc_request_type, struct msg *req) uint32_t cc_request_type, struct msg *req)
{ {
int ret; int ret;
union avp_value val; union avp_value val;
struct avp *avp; struct avp *avp;
@ -546,6 +559,7 @@ static void fill_service_information_ccr(smf_sess_t *sess,
void smf_gy_send_ccr(smf_sess_t *sess, void *xact, void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
uint32_t cc_request_type) uint32_t cc_request_type)
{ {
int ret; int ret;
smf_ue_t *smf_ue = NULL; smf_ue_t *smf_ue = NULL;
@ -556,7 +570,7 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
struct sess_state *sess_data = NULL, *svg; struct sess_state *sess_data = NULL, *svg;
struct session *session = NULL; struct session *session = NULL;
int new; int new;
const char *service_context_id = "open5gs-smfd@open5gs.org"; const char *service_context_id = "32251@3gpp.org";
uint32_t timestamp; uint32_t timestamp;
ogs_assert(xact); ogs_assert(xact);
@ -587,7 +601,6 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
ogs_assert(new == 0); ogs_assert(new == 0);
ogs_debug(" Found Gy Session-Id: [%s]", sess->gy_sid); ogs_debug(" Found Gy Session-Id: [%s]", sess->gy_sid);
/* Add Session-Id to the message */ /* Add Session-Id to the message */
ret = ogs_diam_message_session_id_set(req, (os0_t)sess->gy_sid, sidlen); ret = ogs_diam_message_session_id_set(req, (os0_t)sess->gy_sid, sidlen);
ogs_assert(ret == 0); ogs_assert(ret == 0);
@ -618,12 +631,10 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
ogs_assert(sess_data); ogs_assert(sess_data);
ogs_debug(" Allocate new Gy session: [%s]", sess_data->gy_sid); ogs_debug(" Allocate new Gy session: [%s]", sess_data->gy_sid);
/* Save Session-Id to SMF Session Context */ /* Save Session-Id to SMF Session Context */
sess->gy_sid = (char *)sess_data->gy_sid; sess->gy_sid = (char *)sess_data->gy_sid;
} else } else
ogs_debug(" Retrieve Gy session: [%s]", sess_data->gy_sid); ogs_debug(" Retrieve Gy session: [%s]", sess_data->gy_sid);
/* /*
* 8.2. CC-Request-Number AVP * 8.2. CC-Request-Number AVP
* *
@ -647,16 +658,20 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
ogs_debug(" CC Request Type[%d] Number[%d]", ogs_debug(" CC Request Type[%d] Number[%d]",
sess_data->cc_request_type, sess_data->cc_request_number); sess_data->cc_request_type, sess_data->cc_request_number);
ogs_assert(sess_data->cc_request_number <= MAX_CC_REQUEST_NUMBER);
ogs_assert(sess_data->cc_request_number < MAX_CC_REQUEST_NUMBER);
/* Update session state */ /* Update session state */
sess_data->sess = sess; sess_data->sess = sess;
if (cc_request_type == OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST) if (cc_request_type == OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST)
sess_data->xact_data[sess_data->cc_request_number].pfcp = true; sess_data->xact_data[sess_data->cc_request_number].pfcp = true;
else else
sess_data->xact_data[sess_data->cc_request_number].pfcp = false; sess_data->xact_data[sess_data->cc_request_number].pfcp = false;
sess_data->xact_data[sess_data->cc_request_number].ptr = xact; sess_data->xact_data[sess_data->cc_request_number].ptr = xact;
/* Origin-Host & Origin-Realm */ /* Origin-Host & Origin-Realm */
ret = fd_msg_add_origin(req, 0); ret = fd_msg_add_origin(req, 0);
ogs_assert(ret == 0); ogs_assert(ret == 0);
@ -707,6 +722,8 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp); ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
ogs_assert(ret == 0); ogs_assert(ret == 0);
/* Set the Destination-Host AVP */ /* Set the Destination-Host AVP */
if (sess_data->peer_host) { if (sess_data->peer_host) {
ret = fd_msg_avp_new(ogs_diam_destination_host, 0, &avp); ret = fd_msg_avp_new(ogs_diam_destination_host, 0, &avp);
@ -868,6 +885,7 @@ void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
ret = fd_msg_send(&req, smf_gy_cca_cb, svg); ret = fd_msg_send(&req, smf_gy_cca_cb, svg);
ogs_assert(ret == 0); ogs_assert(ret == 0);
/* Increment the counter */ /* Increment the counter */
ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0);
ogs_diam_logger_self()->stats.nb_sent++; ogs_diam_logger_self()->stats.nb_sent++;