From 9e13374cdddd539cd2c32fdfe93c2bec50ee0e6f Mon Sep 17 00:00:00 2001 From: Alessio Garzi Date: Tue, 18 Apr 2023 16:40:59 +0200 Subject: [PATCH] MT#57110 New field r_ua (responder_user_agent) New field "r_ua" is now managed and inserted into cdr_tag_data mysql table. This field will store into the aggregated cdr data the user agent relative to the first 2xx response of an INVITE. Change-Id: Icf8e80d0d2b63f4b9db006c8a224335989057e86 --- cdr.c | 16 ++++++++++++++++ cdr_field_names.inc | 1 + medmysql.c | 3 +++ 3 files changed, 20 insertions(+) diff --git a/cdr.c b/cdr.c index 5743c51..b95917f 100644 --- a/cdr.c +++ b/cdr.c @@ -731,6 +731,11 @@ static int cdr_parse_dstleg_json(json_object *json, cdr_entry_t *cdr) L_DEBUG("Call-Id '%s' does not contain 'r_user' key, '%s'", cdr->call_id->str, json_object_get_string(json)); } + // responder_number + if (!cdr_parse_json_get_g_string(json, "r_ua", cdr->r_ua)) { + L_DEBUG("Call-Id '%s' does not contain 'r_ua' key, '%s'", cdr->call_id->str, json_object_get_string(json)); + } + ret: return 0; @@ -1309,6 +1314,17 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) *tmp1 = MED_SEP; tmp2 = ++tmp1; + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + L_DEBUG("Call-Id '%s' has no separated response user agent, '%s'", cdr->call_id->str, tmp2); + return 0; + } + *tmp1 = '\0'; + g_string_assign(cdr->r_ua, tmp2); + *tmp1 = MED_SEP; + tmp2 = ++tmp1; + return 0; } diff --git a/cdr_field_names.inc b/cdr_field_names.inc index c651e7b..8a03af8 100644 --- a/cdr_field_names.inc +++ b/cdr_field_names.inc @@ -49,6 +49,7 @@ F(destination_concurrent_calls_count) F(destination_concurrent_calls_count_customer) F(hg_ext_response) F(r_user) +F(r_ua) F(source_last_hih) F(acc_ref) diff --git a/medmysql.c b/medmysql.c index 8dcac97..8c5c10c 100644 --- a/medmysql.c +++ b/medmysql.c @@ -1148,6 +1148,9 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, uint64_t count, struct medmysql_b if (medmysql_tag_cdr(batch, medmysql_tag_provider_customer, medmysql_tag_direction_destination, "r_user", e->r_user, e)) return -1; + if (medmysql_tag_cdr(batch, medmysql_tag_provider_customer, medmysql_tag_direction_destination, + "r_ua", e->r_ua, e)) + return -1; if (medmysql_tag_cdr(batch, medmysql_tag_provider_customer, medmysql_tag_direction_source, "header=History-Info", e->source_last_hih, e)) return -1;