Skip to content

Commit

Permalink
fraud_detection: Do not raise call-duration alerts for CANCEL/487 calls
Browse files Browse the repository at this point in the history
(cherry picked from commit 1c4a8a5)
  • Loading branch information
liviuchircu committed Mar 2, 2022
1 parent e6ed91f commit d82fd36
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/fraud_detection/frd_events.c
Expand Up @@ -151,29 +151,33 @@ void dialog_terminate_CB(struct dlg_cell *dlg, int type,
extern str call_dur_name;
frd_dlg_param *frdparam = (frd_dlg_param*) *(params->param);

if (frdparam->dlg_terminated ||
!(type & (DLGCB_FAILED|DLGCB_TERMINATED|DLGCB_EXPIRED)))
if (!(type & (DLGCB_FAILED|DLGCB_TERMINATED|DLGCB_EXPIRED)))
return;
frdparam->dlg_terminated = 1;

unsigned int duration = time(NULL) - dlg->start_ts;
LM_DBG("call-duration: %u sec (warn: %u, crit: %u), dlgcb: %d\n",
duration, frdparam->calldur_warn, frdparam->calldur_crit, type);

if (frdparam->calldur_crit && duration >= frdparam->calldur_crit)
/* avoid generating alerts on CANCEL/487 calls, but decrement the CC */
if (!(type & DLGCB_FAILED) && frdparam->calldur_crit
&& duration >= frdparam->calldur_crit)
raise_critical_event(&call_dur_name, &duration,
&frdparam->calldur_crit,
&frdparam->user, &frdparam->number, &frdparam->ruleid);

else if (frdparam->calldur_warn && duration >= frdparam->calldur_warn)
else if (!(type & DLGCB_FAILED) && frdparam->calldur_warn
&& duration >= frdparam->calldur_warn)
raise_warning_event(&call_dur_name, &duration,
&frdparam->calldur_warn,
&frdparam->user, &frdparam->number, &frdparam->ruleid);

lock_get(&frdparam->stats->lock);
if (frdparam->interval_id == frdparam->stats->interval_id)
if (!frdparam->dlg_terminated
&& frdparam->interval_id == frdparam->stats->interval_id)
--frdparam->stats->stats.concurrent_calls;
lock_release(&frdparam->stats->lock);

frdparam->dlg_terminated = 1;
}

void free_dialog_CB_param(void *param)
Expand Down

0 comments on commit d82fd36

Please sign in to comment.