From 5b3ee7cf34af3521b0f484704fb53ec9450969ac Mon Sep 17 00:00:00 2001 From: Marco Capetta Date: Fri, 15 Nov 2019 17:31:22 +0100 Subject: [PATCH] TT#70855 Read source_lcr_id from acc record and use it to generate CDR Tha value is readed from the last field of the the ACC srcleg. It contains the ID of the peer_host from where the call was received. Mediator uses it to find the correct peering_contract_id to write in the CDR. Change-Id: I2cfb7d0fadb5ade265fde3c1778475eda431a453 (cherry picked from commit 87ec80a5533b4c46f29a2c19722c76692bb146ef) --- cdr.c | 16 ++++++++++++++++ cdr.h | 1 + 2 files changed, 17 insertions(+) diff --git a/cdr.c b/cdr.c index 0f262ad..6da6f78 100644 --- a/cdr.c +++ b/cdr.c @@ -476,6 +476,16 @@ static int cdr_parse_srcleg(char *srcleg, cdr_entry_t *cdr) g_strlcpy(cdr->header_u2u, tmp2, sizeof(cdr->header_u2u)); tmp2 = ++tmp1; + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + L_WARNING("Call-Id '%s' has no separated source lcr id, '%s'", cdr->call_id, tmp2); + return -1; + } + *tmp1 = '\0'; + cdr->source_lcr_id = atoll(tmp2); + tmp2 = ++tmp1; + return 0; } @@ -905,6 +915,12 @@ void cdr_set_provider(cdr_entry_t *cdr) g_strlcpy(cdr->source_provider_id, "0", sizeof(cdr->source_provider_id)); } } + else if (cdr->source_lcr_id) { + snprintf(cdr->source_provider_id, sizeof(cdr->source_provider_id), + "%llu", (unsigned long long) cdr->source_lcr_id); + val = g_hash_table_lookup(med_peer_id_table, cdr->source_provider_id); + g_strlcpy(cdr->source_provider_id, val ? : "0", sizeof(cdr->source_provider_id)); + } else if((val = g_hash_table_lookup(med_peer_ip_table, cdr->source_domain)) != NULL) { g_strlcpy(cdr->source_provider_id, val, sizeof(cdr->source_provider_id)); diff --git a/cdr.h b/cdr.h index a1a5119..31901c6 100644 --- a/cdr.h +++ b/cdr.h @@ -37,6 +37,7 @@ typedef struct { char source_cli[65]; char source_ip[65]; uint8_t source_clir; + uint64_t source_lcr_id; char source_gpp[10][255]; char source_lnp_prefix[256]; char source_user_out[256];