From 86c017a4ad22f9b56918e097e023eac130620d41 Mon Sep 17 00:00:00 2001 From: Abdelmuhaimen Seaudi Date: Wed, 13 Sep 2023 10:18:39 +0300 Subject: [PATCH] add cdrs to smf --- configs/open5gs/smf.yaml.in | 6 ++++++ src/smf/n4-handler.c | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in index 51120d51bf..00acdd4073 100644 --- a/configs/open5gs/smf.yaml.in +++ b/configs/open5gs/smf.yaml.in @@ -624,6 +624,12 @@ smf: mtu: 1400 ctf: enabled: auto + cdr: + enabled: True + file_capture_period_sec: 1800 + reporting_period_sec: 10 + log_dir: /var/log/open5gs + sgw_name: PGW-01 freeDiameter: @sysconfdir@/freeDiameter/smf.conf # diff --git a/src/smf/n4-handler.c b/src/smf/n4-handler.c index c92409304f..80ed37b1ab 100644 --- a/src/smf/n4-handler.c +++ b/src/smf/n4-handler.c @@ -27,6 +27,13 @@ #include "ngap-path.h" #include "fd-path.h" +static void log_usage_reports(sgwc_sess_t *sess, ogs_pfcp_session_report_request_t *pfcp_req); +static void log_deletion_usage_reports(sgwc_sess_t *sess, ogs_pfcp_session_deletion_response_t *pfcp_rsp); +static void log_start_usage_reports(sgwc_sess_t *sess); +static UsageLoggerData build_usage_logger_data(sgwc_sess_t *sess, char const* event, uint64_t octets_in, uint64_t octets_out); +static void log_usage_logger_data(UsageLoggerData usageLoggerData); +static bool hex_array_to_string(uint8_t* hex_array, size_t hex_array_len, char* hex_string, size_t hex_string_len); + uint8_t gtp_cause_from_pfcp(uint8_t pfcp_cause, uint8_t gtp_version) { switch (gtp_version) { @@ -184,6 +191,10 @@ uint8_t smf_5gc_n4_handle_session_establishment_response( if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) return cause_value; + if (ogs_pfcp_self()->usageLoggerState.enabled) { + log_start_usage_reports(sess); + } + for (i = 0; i < OGS_MAX_NUM_OF_PDR; i++) { pdr = ogs_pfcp_handle_created_pdr( &sess->pfcp, &rsp->created_pdr[i],