diff --git a/cdr.c b/cdr.c index 19b1ea6..fc819fd 100644 --- a/cdr.c +++ b/cdr.c @@ -266,6 +266,16 @@ static int cdr_parse_srcleg(char *srcleg, cdr_entry_t *cdr) g_strlcpy(cdr->call_type, tmp2, sizeof(cdr->call_type)); tmp2 = ++tmp1; + tmp1 = strchr(tmp2, MED_SEP); + if(tmp1 == NULL) + { + syslog(LOG_WARNING, "Call-Id '%s' has no separated source ip, '%s'", cdr->call_id, tmp2); + return -1; + } + *tmp1 = '\0'; + g_strlcpy(cdr->source_ip, tmp2, sizeof(cdr->source_ip)); + tmp2 = ++tmp1; + if(len < tmp2 - srcleg + 1) { syslog(LOG_WARNING, "Call-Id '%s' has no separated init time, '%s'", cdr->call_id, tmp2); diff --git a/cdr.h b/cdr.h index 1950f15..9005f4b 100644 --- a/cdr.h +++ b/cdr.h @@ -27,6 +27,7 @@ typedef struct { char source_user[256]; char source_domain[256]; char source_cli[65]; + char source_ip[65]; u_int8_t source_clir; char destination_user_id[37]; diff --git a/medmysql.c b/medmysql.c index 25a5f34..1a52b97 100644 --- a/medmysql.c +++ b/medmysql.c @@ -319,7 +319,7 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ if (batches->cdrs.len == 0) { batches->cdrs.len = sprintf(batches->cdrs.str, "insert into cdr (id, update_time, " \ "source_user_id, source_provider_id, source_external_subscriber_id, source_external_contract_id, source_account_id, source_user, source_domain, " \ - "source_cli, source_clir, "\ + "source_cli, source_clir, source_ip, "\ "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, init_time, start_time, duration, call_id, " \ @@ -367,6 +367,8 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_ CDRPRINT("',"); CDRESCAPE(str_source_clir); CDRPRINT(",'"); + CDRESCAPE(e->source_ip); + CDRPRINT("','"); CDRESCAPE(e->destination_user_id); CDRPRINT("','"); CDRESCAPE(e->destination_provider_id);