diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c index da3ce7cbfdd..a25224318cd 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -2932,6 +2932,8 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) str mop = {NULL, 0}; str mval = {NULL, 0}; str sval = {NULL, 0}; + unsigned int ival = 0; + unsigned int mival = 0; int n = 0; int m = 0; int vkey = 0; @@ -2960,6 +2962,8 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) vkey = 2; } else if(mkey.len==6 && strncmp(mkey.s, "callid", mkey.len)==0) { vkey = 3; + } else if(mkey.len==8 && strncmp(mkey.s, "start_ts", mkey.len)==0) { + vkey = 4; } else { LM_ERR("invalid key %.*s\n", mkey.len, mkey.s); rpc->fault(c, 500, "Invalid matching key parameter"); @@ -2983,6 +2987,10 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) } } else if(strncmp(mop.s, "sw", 2)==0) { vop = 2; + } else if(strncmp(mop.s, "gt", 2)==0) { + vop = 3; + } else if(strncmp(mop.s, "lt", 2)==0) { + vop = 4; } else { LM_ERR("invalid matching operator %.*s\n", mop.len, mop.s); rpc->fault(c, 500, "Invalid matching operator parameter"); @@ -2992,6 +3000,18 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) n = 0; } + if (vkey == 4 && vop <= 2) { + LM_ERR("Matching operator %.*s not supported with start_ts key\n", mop.len, mop.s); + rpc->fault(c, 500, "Matching operator not supported with start_ts key"); + return; + } + + if (vkey != 4 && vop >= 3) { + LM_ERR("Matching operator %.*s not supported with key %.*s\n", mop.len, mop.s, mkey.len, mkey.s); + rpc->fault(c, 500, "Matching operator not supported"); + return; + } + for(i=0; isize; i++) { dlg_lock(d_table, &(d_table->entries[i])); for(dlg=d_table->entries[i].first; dlg!=NULL; dlg=dlg->next) { @@ -3009,6 +3029,9 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) case 3: sval = dlg->callid; break; + case 4: + ival = dlg->start_ts; + break; } switch(vop) { case 0: @@ -3031,6 +3054,17 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context) matched = 1; } break; + case 3: + /* greater than */ + if (str2int(&mval, &mival) == 0 && ival > mival) { + matched = 1; + } + break; + case 4: + if (str2int(&mval, &mival) == 0 && ival < mival) { + matched = 1; + } + break; } if (matched==1) { m++; diff --git a/src/modules/dialog/doc/dialog_admin.xml b/src/modules/dialog/doc/dialog_admin.xml index d456d545ef5..290e68d4d63 100644 --- a/src/modules/dialog/doc/dialog_admin.xml +++ b/src/modules/dialog/doc/dialog_admin.xml @@ -2500,12 +2500,16 @@ dlg_reset_property("timeout-noreset"); mkey - matching key. It can be: 'ruri' - match against R-URI of the dialog; 'furi' - match against From header URI of the dialog; 'turi' - match against the To header - URI of the dialog; 'callid' - match against Call-Id value. + URI of the dialog; 'callid' - match against Call-Id value; + 'start_ts' - match against start timestamp. mop - matching operator. It can be: 'eq' - match using string comparison; 're' - match using regular - expression; 'sw' - match using starts-with (prefix) comparison. + expression; 'sw' - match using starts-with (prefix) comparison; + 'gt' - match using integer greater comparison; 'lt' - match + using integer lesser comparison. Integer comparison can be used + only with 'start_ts' key. mval - matching value. @@ -2517,6 +2521,8 @@ dlg_reset_property("timeout-noreset"); &kamcmd; dlg.list_match furi eq sip:alice@test.com 2 ... &kamcmd; dlg.list_match furi sw sip:alice@ +... +&kamcmd; dlg.list_match start_ts gt s:1641550904 ...