diff --git a/cdr.c b/cdr.c index e7972cb..45bde4a 100644 --- a/cdr.c +++ b/cdr.c @@ -545,6 +545,15 @@ static int cdr_parse_srcleg_json(json_object *json, cdr_entry_t *cdr) goto err; } + // header_ppi + if (!cdr_parse_json_get_g_string(json, "ppi", cdr->header_ppi)) { + L_ERROR("Call-Id '%s' does not contain 'ppi' key (P-Preferred-Identity header), '%s'", cdr->call_id->str, json_object_get_string(json)); + /// Simply return 0 in order to avoid issues with ACC records in the OLD format during an upgrade + /// Added in mr12.5, it should be changed to 'err' in mr13.+ + /// goto err; + goto ret; + } + ret: return 0; @@ -1030,6 +1039,19 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = MED_SEP; tmp2 = ++tmp1; + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + L_ERROR("Call-Id '%s' has no separated P-Preferred-Identity header, '%s'", cdr->call_id->str, tmp2); + /// Simply return 0 in order to avoid issues with ACC records in the OLD format during an upgrade + /// Added in mr12.5, it should be changed to -1 in mr13.+ + return 0; + } + *tmp1 = '\0'; + g_string_assign(cdr->header_ppi, tmp2); + *tmp1 = MED_SEP; + tmp2 = ++tmp1; + return 0; } diff --git a/cdr_field_names.inc b/cdr_field_names.inc index 8a03af8..971b591 100644 --- a/cdr_field_names.inc +++ b/cdr_field_names.inc @@ -38,6 +38,7 @@ F(furnished_charging_info) F(header_diversion) F(header_pai) F(header_u2u) +F(header_ppi) F(group) diff --git a/medmysql.c b/medmysql.c index c16462e..7ec484b 100644 --- a/medmysql.c +++ b/medmysql.c @@ -1127,6 +1127,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_source, "concurrent_calls_count_customer", e->source_concurrent_calls_count_customer, e)) return -1; + if (medmysql_tag_cdr(batch, medmysql_tag_provider_customer, medmysql_tag_direction_source, + "header=P-Preferred-Identity", e->header_ppi, e)) + return -1; if (medmysql_tag_cdr(batch, medmysql_tag_provider_customer, medmysql_tag_direction_destination, "furnished_charging_info", e->furnished_charging_info, e))