Skip to content

Commit

Permalink
Update sipcapture.c
Browse files Browse the repository at this point in the history
added timestamp
  • Loading branch information
adubovikov committed Apr 8, 2015
1 parent c836390 commit ee72109
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions modules/sipcapture/sipcapture.c
Expand Up @@ -1096,6 +1096,10 @@ static int sip_capture_store(struct _sipcapture_object *sco, str *dtable, _captu

str *table = NULL;
_capture_mode_data_t *c = NULL;
str newtable;
char strftime_buf[128];
time_t tvsec_;


c = (cm_data)? cm_data:capture_def;
if (!c){
Expand All @@ -1117,7 +1121,7 @@ static int sip_capture_store(struct _sipcapture_object *sco, str *dtable, _captu
db_keys[0] = &date_column;
db_vals[0].type = DB1_DATETIME;
db_vals[0].nul = 0;
db_vals[0].val.time_val = time(NULL);
db_vals[0].val.time_val = (sco->tmstamp/1000000);

db_keys[1] = &micro_ts_column;
db_vals[1].type = DB1_BIGINT;
Expand Down Expand Up @@ -1332,10 +1336,19 @@ static int sip_capture_store(struct _sipcapture_object *sco, str *dtable, _captu
table = &c->table_names[ii];
}

tvsec_ = (time_t) (sco->tmstamp/1000000);
if(gmtime_r( &tvsec_, &capt_ts) == NULL)
{
LM_ERR("unable to set gmtime for sipcapture\n");
return -1;
}

newtable.len = strftime(strftime_buf, sizeof(strftime_buf), table->s, &capt_ts);
newtable.s = strftime_buf;

/* check dynamic table */
LM_DBG("insert into homer table: [%.*s]\n", table->len, table->s);
c->db_funcs.use_table(c->db_con, table);
LM_DBG("insert into homer table: [%.*s]\n", newtable->len, newtable->s);
c->db_funcs.use_table(c->db_con, newtable);

LM_DBG("storing info...\n");

Expand Down

0 comments on commit ee72109

Please sign in to comment.