backport changes from trunk to 3.1 branch for NGCP 2.4 release

* enable milliseconds precision for accounting (kamailio part)
* fix the usage of avps with string names in dialplan replacement (backport from 3.2.0; bug 453)
* db_text(k): init new db text table structure to 0
* Do not consider late requests for dialogs in "deleted"
3.1
Andrew Pogrebennyk 15 years ago
parent cd4fd1eca6
commit 924bcf787d

@ -62,11 +62,22 @@ struct subst_expr* repl_exp_parse(str subst)
int replace_all; int replace_all;
char * p, *end, *repl, *repl_end; char * p, *end, *repl, *repl_end;
int max_pmatch, r; int max_pmatch, r;
str shms;
se = 0; se = 0;
replace_all = 0; replace_all = 0;
p = subst.s; shms.s = NULL;
end = p + subst.len;
if (!(shms.s=shm_malloc((subst.len+1) * sizeof(char))) ){
LM_ERR("out of shm memory\n");
goto error;
}
memcpy(shms.s, subst.s, subst.len);
shms.len = subst.len;
shms.s[shms.len] = '\0';
p = shms.s;
end = p + shms.len;
rw_no = 0; rw_no = 0;
repl = p; repl = p;
@ -85,26 +96,27 @@ struct subst_expr* repl_exp_parse(str subst)
} }
memset((void*)se, 0, sizeof(struct subst_expr)); memset((void*)se, 0, sizeof(struct subst_expr));
se->replacement.s = shms.s;
shms.s = NULL;
se->replacement.len=repl_end-repl; se->replacement.len=repl_end-repl;
if (!(se->replacement.s=shm_malloc(se->replacement.len * sizeof(char))) ){
LM_ERR("out of shm memory \n");
goto error;
}
if(!rw_no){ if(!rw_no){
replace_all = 1; replace_all = 1;
} }
/* start copying */ /* start copying */
memcpy(se->replacement.s, repl, se->replacement.len); LM_DBG("replacement expression is [%.*s]\n", se->replacement.len,
se->replacement.s);
se->re=0; se->re=0;
se->replace_all=replace_all; se->replace_all=replace_all;
se->n_escapes=rw_no; se->n_escapes=rw_no;
se->max_pmatch=max_pmatch; se->max_pmatch=max_pmatch;
/*replace_with is a simple structure, no shm alloc needed*/ /*replace_with is a simple structure, no shm alloc needed*/
for (r=0; r<rw_no; r++) se->replace[r]=rw[r]; for (r=0; r<rw_no; r++) se->replace[r]=rw[r];
return se; return se;
error: error:
if(shms.s != NULL)
shm_free(shms.s);
if (se) { repl_expr_free(se);} if (se) { repl_expr_free(se);}
return NULL; return NULL;
} }

@ -125,6 +125,14 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals)
struct hdr_field *from; struct hdr_field *from;
struct hdr_field *to; struct hdr_field *to;
struct timeval tv;
struct timezone tz;
struct tm *tm;
uint64_t time_hires;
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);
/* method : request/reply - cseq parsed in acc_preparse_req() */ /* method : request/reply - cseq parsed in acc_preparse_req() */
c_vals[0] = get_cseq(req)->method; c_vals[0] = get_cseq(req)->method;
t_vals[0] = TYPE_STR; t_vals[0] = TYPE_STR;
@ -174,6 +182,10 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals)
t_vals[5] = TYPE_STR; t_vals[5] = TYPE_STR;
acc_env.ts = time(NULL); acc_env.ts = time(NULL);
time_hires = (tv.tv_sec * 1000) + tv.tv_usec / 1000;
acc_env.time_hires = time_hires;
return ACC_CORE_LEN; return ACC_CORE_LEN;
} }
@ -306,7 +318,8 @@ static void acc_db_init_keys(void)
db_keys[n++] = &acc_sipcode_col; db_keys[n++] = &acc_sipcode_col;
db_keys[n++] = &acc_sipreason_col; db_keys[n++] = &acc_sipreason_col;
db_keys[n++] = &acc_time_col; db_keys[n++] = &acc_time_col;
time_idx = n-1; db_keys[n++] = &acc_time_hires_col;
time_idx = n-2;
/* init the extra db keys */ /* init the extra db keys */
for(extra=db_extra; extra ; extra=extra->next) for(extra=db_extra; extra ; extra=extra->next)
@ -322,6 +335,7 @@ static void acc_db_init_keys(void)
VAL_NULL(db_vals+i)=0; VAL_NULL(db_vals+i)=0;
} }
VAL_TYPE(db_vals+time_idx)=DB1_DATETIME; VAL_TYPE(db_vals+time_idx)=DB1_DATETIME;
VAL_TYPE(db_vals+time_idx+1)=DB1_DOUBLE;
} }
@ -380,7 +394,8 @@ int acc_db_request( struct sip_msg *rq)
VAL_STR(db_vals+i) = val_arr[i]; VAL_STR(db_vals+i) = val_arr[i];
/* time value */ /* time value */
VAL_TIME(db_vals+(m++)) = acc_env.ts; VAL_TIME(db_vals+(m++)) = acc_env.ts;
VAL_DOUBLE(db_vals+(m++)) = ((double) acc_env.time_hires) / 1000;
i = m;
/* extra columns */ /* extra columns */
m += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m); m += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);

@ -57,6 +57,7 @@ typedef struct acc_enviroment {
struct hdr_field *to; struct hdr_field *to;
str text; str text;
time_t ts; time_t ts;
uint64_t time_hires;
} acc_enviroment_t; } acc_enviroment_t;
/* acc extra parameter */ /* acc extra parameter */

@ -173,6 +173,7 @@ str acc_callid_col = str_init("callid");
str acc_sipcode_col = str_init("sip_code"); str acc_sipcode_col = str_init("sip_code");
str acc_sipreason_col = str_init("sip_reason"); str acc_sipreason_col = str_init("sip_reason");
str acc_time_col = str_init("time"); str acc_time_col = str_init("time");
str acc_time_hires_col = str_init("time_hires");
#endif #endif
/*@}*/ /*@}*/
@ -256,6 +257,7 @@ static param_export_t params[] = {
{"acc_sip_code_column", STR_PARAM, &acc_sipcode_col.s }, {"acc_sip_code_column", STR_PARAM, &acc_sipcode_col.s },
{"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s }, {"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s },
{"acc_time_column", STR_PARAM, &acc_time_col.s }, {"acc_time_column", STR_PARAM, &acc_time_col.s },
{"acc_time_hires_column",STR_PARAM, &acc_time_hires_col.s },
#endif #endif
{0,0,0} {0,0,0}
}; };
@ -371,6 +373,7 @@ static int mod_init( void )
acc_sipcode_col.len = strlen(acc_sipcode_col.s); acc_sipcode_col.len = strlen(acc_sipcode_col.s);
acc_sipreason_col.len = strlen(acc_sipreason_col.s); acc_sipreason_col.len = strlen(acc_sipreason_col.s);
acc_time_col.len = strlen(acc_time_col.s); acc_time_col.len = strlen(acc_time_col.s);
acc_time_hires_col.len = strlen(acc_time_hires_col.s);
#endif #endif
if (log_facility_str) { if (log_facility_str) {

@ -85,6 +85,7 @@ extern str acc_cseqno_col;
extern str acc_sipcode_col; extern str acc_sipcode_col;
extern str acc_sipreason_col; extern str acc_sipreason_col;
extern str acc_time_col; extern str acc_time_col;
extern str acc_time_hires_col;
#endif /* SQL_ACC */ #endif /* SQL_ACC */

@ -149,6 +149,7 @@ dbt_table_p dbt_table_new(const str *_tbname, const str *_dbname, const char *pa
dtp = (dbt_table_p)shm_malloc(sizeof(dbt_table_t)); dtp = (dbt_table_p)shm_malloc(sizeof(dbt_table_t));
if(!dtp) if(!dtp)
goto done; goto done;
memset(dtp, 0, sizeof(dbt_table_t));
dtp->name.s = (char*)shm_malloc((_tbname->len+1)*sizeof(char)); dtp->name.s = (char*)shm_malloc((_tbname->len+1)*sizeof(char));
if(!dtp->name.s) if(!dtp->name.s)
{ {

@ -739,6 +739,7 @@ void next_state_dlg(struct dlg_cell *dlg, int event,
switch (dlg->state) { switch (dlg->state) {
case DLG_STATE_EARLY: case DLG_STATE_EARLY:
case DLG_STATE_CONFIRMED_NA: case DLG_STATE_CONFIRMED_NA:
case DLG_STATE_DELETED:
break; break;
default: default:
log_next_state_dlg(event, dlg); log_next_state_dlg(event, dlg);
@ -749,6 +750,7 @@ void next_state_dlg(struct dlg_cell *dlg, int event,
case DLG_STATE_EARLY: case DLG_STATE_EARLY:
case DLG_STATE_CONFIRMED_NA: case DLG_STATE_CONFIRMED_NA:
case DLG_STATE_CONFIRMED: case DLG_STATE_CONFIRMED:
case DLG_STATE_DELETED:
break; break;
default: default:
log_next_state_dlg(event, dlg); log_next_state_dlg(event, dlg);

Loading…
Cancel
Save