diff --git a/cdr.c b/cdr.c index ca6e190..ec04e82 100644 --- a/cdr.c +++ b/cdr.c @@ -328,17 +328,13 @@ static int cdr_parse_srcleg(char *srcleg, cdr_entry_t *cdr) tmp1 = strchr(tmp2, MED_SEP); if(tmp1 == NULL) { - - syslog(LOG_WARNING, "Call-Id '%s' has no separated source gpp, skipping those fields", cdr->call_id); - cdr->init_time = g_strtod(tmp2, NULL); - return 0; - + syslog(LOG_WARNING, "Call-Id '%s' has no separated source init time, '%s'", cdr->call_id, tmp2); + return -1; } *tmp1 = '\0'; cdr->init_time = g_strtod(tmp2, NULL); tmp2 = ++tmp1; - int i; for(i = 0; i < 10; ++i) { @@ -353,6 +349,16 @@ static int cdr_parse_srcleg(char *srcleg, cdr_entry_t *cdr) tmp2 = ++tmp1; } + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + syslog(LOG_WARNING, "Call-Id '%s' has no separated source lnp prefix, '%s'", cdr->call_id, tmp2); + return -1; + } + *tmp1 = '\0'; + g_strlcpy(cdr->source_lnp_prefix, tmp2, sizeof(cdr->source_lnp_prefix)); + tmp2 = ++tmp1; + return 0; } @@ -467,9 +473,8 @@ static int cdr_parse_dstleg(char *dstleg, cdr_entry_t *cdr) tmp1 = strchr(tmp2, MED_SEP); if(tmp1 == NULL) { - syslog(LOG_WARNING, "Call-Id '%s' has no separated destination gpp, skipping those fields", cdr->call_id); - cdr->destination_lcr_id = atoll(tmp2); - return 0; + syslog(LOG_WARNING, "Call-Id '%s' has no separated destination lcr id, '%s'", cdr->call_id, tmp2); + return -1; } *tmp1 = '\0'; cdr->destination_lcr_id = atoll(tmp2); @@ -489,6 +494,16 @@ static int cdr_parse_dstleg(char *dstleg, cdr_entry_t *cdr) tmp2 = ++tmp1; } + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + syslog(LOG_WARNING, "Call-Id '%s' has no separated destination lnp prefix, '%s'", cdr->call_id, tmp2); + return -1; + } + *tmp1 = '\0'; + g_strlcpy(cdr->destination_lnp_prefix, tmp2, sizeof(cdr->destination_lnp_prefix)); + tmp2 = ++tmp1; + return 0; } diff --git a/cdr.h b/cdr.h index fada1b4..ea03035 100644 --- a/cdr.h +++ b/cdr.h @@ -30,6 +30,7 @@ typedef struct { char source_ip[65]; u_int8_t source_clir; char source_gpp[10][255]; + char source_lnp_prefix[256]; char destination_user_id[37]; char destination_provider_id[256]; @@ -43,6 +44,7 @@ typedef struct { char destination_dialed[256]; u_int64_t destination_lcr_id; char destination_gpp[10][255]; + char destination_lnp_prefix[256]; char call_type[8]; char call_status[16]; diff --git a/medmysql.c b/medmysql.c index 4f27053..8611b41 100644 --- a/medmysql.c +++ b/medmysql.c @@ -364,7 +364,8 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ "source_gpp0, source_gpp1, source_gpp2, source_gpp3, source_gpp4, " \ "source_gpp5, source_gpp6, source_gpp7, source_gpp8, source_gpp9, " \ "destination_gpp0, destination_gpp1, destination_gpp2, destination_gpp3, destination_gpp4, " \ - "destination_gpp5, destination_gpp6, destination_gpp7, destination_gpp8, destination_gpp9" \ + "destination_gpp5, destination_gpp6, destination_gpp7, destination_gpp8, destination_gpp9, " \ + "source_lnp_prefix, destination_lnp_prefix" \ ") values "); } @@ -497,6 +498,10 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ } } + CDRPRINT(","); + CDRESCAPE(e->source_lnp_prefix); + CDRPRINT(","); + CDRESCAPE(e->destination_lnp_prefix); CDRPRINT("),");