forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_call.h
79 lines (71 loc) · 1.93 KB
/
filter_call.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef FILTER_CALL_H
#define FILTER_CALL_H
#include "filter_record.h"
#include "calltable.h"
#include "country_detect.h"
class cRecordFilterItem_CallProxy : public cRecordFilterItem_IP {
public:
cRecordFilterItem_CallProxy(cRecordFilter *parent)
: cRecordFilterItem_IP(parent, 0) {
}
bool check(void *rec, bool *findInBlackList = NULL) {
if(findInBlackList) {
*findInBlackList = false;
}
Call *call = (Call*)rec;
if(call->is_set_proxies()) {
set<unsigned int> proxies;
call->proxies_undup(&proxies);
for(set<unsigned int>::iterator iter = proxies.begin(); iter != proxies.end(); iter++) {
bool _findInBlackList = false;
if(check_ip(htonl(*iter), &_findInBlackList)) {
return(true);
} else if(_findInBlackList) {
if(findInBlackList) {
*findInBlackList = _findInBlackList;
}
return(false);
}
}
}
return(false);
}
};
class cCallFilter : public cRecordFilter {
public:
cCallFilter(const char *filter);
void setFilter(const char *filter);
int64_t getField_int(void *rec, unsigned registerFieldIndex) {
switch(registerFieldIndex) {
case cf_calldate:
return(((Call*)rec)->calltime());
case cf_callerip:
return(htonl(((Call*)rec)->getSipcallerip()));
case cf_calledip:
return(htonl(((Call*)rec)->getSipcalledip()));
case cf_id_sensor:
return(((Call*)rec)->useSensorId);
case cf_connect_duration:
return(((Call*)rec)->connect_duration_active());
case cf_called_international:
return(!isLocalByPhoneNumber(((Call*)rec)->called));
}
return(0);
}
const char *getField_string(void *rec, unsigned registerFieldIndex) {
switch(registerFieldIndex) {
case cf_caller:
return(((Call*)rec)->caller);
case cf_called:
return(((Call*)rec)->called);
case cf_callerdomain:
return(((Call*)rec)->caller_domain);
case cf_calleddomain:
return(((Call*)rec)->called_domain);
case cf_callid:
return(((Call*)rec)->fbasename);
}
return("");
}
};
#endif