Skip to content

Commit

Permalink
[fraud_detection] Backend is now functional
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-datcu committed Sep 5, 2014
1 parent 4ddf3a1 commit 8d497dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
26 changes: 26 additions & 0 deletions modules/fraud_detection/fraud_detection.c
Expand Up @@ -72,12 +72,24 @@ static mi_export_t mi_cmds[] = {
{0,0,0,0,0,0}
};

static dep_export_t deps = {
{
{MOD_TYPE_SQLDB, NULL, DEP_ABORT},
{MOD_TYPE_DEFAULT, "drouting", DEP_ABORT},
{MOD_TYPE_NULL, NULL, 0},
},
{
{NULL, NULL},
},
};

/** module exports */
struct module_exports exports= {
"fraud_detection", /* module name */
MOD_TYPE_DEFAULT,
MODULE_VERSION,
DEFAULT_DLFLAGS, /* dlopen flags */
&deps,
cmds, /* exported functions */
params, /* exported parameters */
0, /* exported statistics */
Expand Down Expand Up @@ -131,6 +143,20 @@ static int mod_init(void)

frd_init_db();
frd_reload_data();

str number = str_init("0754565");
rt_info_t *test = drb.match_number(dr_head, 1, &number);

if (test) {
frd_thresholds_t *thr = (frd_thresholds_t*)test->attrs.s;

LM_INFO("xxx - <%u> matched: %d %d %d %d %d\n", test->id, thr->cpm_thr.warning,
thr->call_duration_thr.critical, thr->total_calls_thr.warning,
thr->concurrent_calls_thr.critical, thr->seq_calls_thr.warning);
}
else
LM_INFO("no match\n");

return 0;
}

Expand Down
6 changes: 4 additions & 2 deletions modules/fraud_detection/frd_load.c
Expand Up @@ -210,6 +210,8 @@ static int create_time_rec(const str *time_start, const str *time_end,

trec->duration = (end_h * 3600 + end_m * 60) -
(trec->ts.tm_hour * 3600 + trec->ts.tm_min * 60);
trec->ts.tm_isdst = -1 /*daylight*/;
trec->dtstart = trec->duration;
trec->freq = FREQ_DAILY;

unsigned short day_set = 0;
Expand Down Expand Up @@ -243,7 +245,7 @@ static int frd_load_data(dr_head_p drp, free_list_t **fl)
{
static const size_t col_count = 16;
db_res_t *res = NULL;
unsigned int no_rows, row_count, i;
unsigned int no_rows = 0, row_count, i;
db_row_t *rows;
db_val_t *values;

Expand Down Expand Up @@ -350,7 +352,7 @@ static int frd_load_data(dr_head_p drp, free_list_t **fl)
}

/* Rule OK, time to put it in DR */
if (drb.add_rule(drp, &prefix, pid, 0, fl_it->trec + 1,
if (drb.add_rule(drp, rid, &prefix, pid, 0, fl_it->trec + i,
(void*)(&fl_it->thr[i])) != 0) {

LM_ERR("Cannot add rule in dr <%u>. Skipping...\n", rid);
Expand Down

0 comments on commit 8d497dc

Please sign in to comment.