diff --git a/cdr.c b/cdr.c index ec5cf39..19b1ea6 100644 --- a/cdr.c +++ b/cdr.c @@ -256,13 +256,23 @@ static int cdr_parse_srcleg(char *srcleg, cdr_entry_t *cdr) cdr->source_clir = atoi(tmp2); tmp2 = ++tmp1; - if(len < tmp2 - srcleg + 1) + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) { syslog(LOG_WARNING, "Call-Id '%s' has no separated call type, '%s'", cdr->call_id, tmp2); return -1; } + *tmp1 = '\0'; g_strlcpy(cdr->call_type, tmp2, sizeof(cdr->call_type)); - + tmp2 = ++tmp1; + + if(len < tmp2 - srcleg + 1) + { + syslog(LOG_WARNING, "Call-Id '%s' has no separated init time, '%s'", cdr->call_id, tmp2); + return -1; + } + cdr->init_time = g_strtod(tmp2, NULL); + return 0; } diff --git a/cdr.h b/cdr.h index 49aa814..1950f15 100644 --- a/cdr.h +++ b/cdr.h @@ -47,6 +47,7 @@ typedef struct { char peer_auth_user[256]; char peer_auth_realm[256]; + double init_time; double start_time; double duration; diff --git a/debian/changelog b/debian/changelog index 96062cb..6d2966e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +ngcp-mediator (1.3.6) unstable; urgency=low + + * Fixes wrong merging/tagging. + + -- Andrew Pogrebennyk Mon, 05 Mar 2012 16:25:42 +0100 + +ngcp-mediator (1.3.5) unstable; urgency=low + + * Parse and insert init_time. + + -- Andrew Pogrebennyk Mon, 05 Mar 2012 15:15:38 +0100 + ngcp-mediator (1.3.4) unstable; urgency=low * Increase call-id string size. diff --git a/medmysql.c b/medmysql.c index 7187a58..25a5f34 100644 --- a/medmysql.c +++ b/medmysql.c @@ -322,12 +322,13 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ "source_cli, source_clir, "\ "destination_user_id, destination_provider_id, destination_external_subscriber_id, destination_external_contract_id, destination_account_id, destination_user, destination_domain, " \ "destination_user_in, destination_domain_in, destination_user_dialed, " \ - "peer_auth_user, peer_auth_realm, call_type, call_status, call_code, start_time, duration, call_id, " \ + "peer_auth_user, peer_auth_realm, call_type, call_status, call_code, init_time, start_time, duration, call_id, " \ "carrier_cost, reseller_cost, customer_cost) values "); } cdr_entry_t *e = &(entries[i]); char str_source_clir[2] = ""; + char str_init_time[32] = ""; char str_start_time[32] = ""; char str_duration[32] = ""; char str_carrier_cost[32] = ""; @@ -336,6 +337,7 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ char str_source_accid[32] = ""; char str_dest_accid[32] = ""; snprintf(str_source_clir, sizeof(str_source_clir), "%u", e->source_clir); + snprintf(str_init_time, sizeof(str_init_time), "%f", e->init_time); snprintf(str_start_time, sizeof(str_start_time), "%f", e->start_time); snprintf(str_duration, sizeof(str_duration), "%f", e->duration); snprintf(str_carrier_cost, sizeof(str_carrier_cost), "%u", e->carrier_cost); @@ -395,6 +397,8 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ CDRPRINT("','"); CDRESCAPE(e->call_code); CDRPRINT("',"); + CDRESCAPE(str_init_time); + CDRPRINT(","); CDRESCAPE(str_start_time); CDRPRINT(","); CDRESCAPE(str_duration);