forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_call_info.h
95 lines (85 loc) · 1.86 KB
/
send_call_info.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef SEND_CALL_INFO_H
#define SEND_CALL_INFO_H
#include "tools.h"
#include "sql_db.h"
struct sSciInfo {
enum eTypeSci {
sci_18X,
sci_200
};
sSciInfo() {
typeSci = (eTypeSci)0;
caller_ip = 0;
called_ip = 0;
at = 0;
}
eTypeSci typeSci;
string callid;
string caller_number;
string called_number;
u_int32_t caller_ip;
u_int32_t called_ip;
u_int64_t at;
};
class SendCallInfoItem {
public:
enum eInfoOn {
infoOn_183_180,
infoOn_200,
infoOn_183_180_200
};
enum eRequestType {
rt_get,
rt_post
};
public:
SendCallInfoItem(unsigned int dbId);
bool load();
void evSci(sSciInfo *sci);
private:
unsigned int dbId;
SqlDb_row dbRow;
string name;
eInfoOn infoOn;
string requestUrl;
eRequestType requestType;
ListIP_wb ipCallerFilter;
ListIP_wb ipCalledFilter;
ListPhoneNumber_wb phoneNumberCallerFilter;
ListPhoneNumber_wb phoneNumberCalledFilter;
};
class SendCallInfo {
public:
SendCallInfo();
~SendCallInfo();
void load(bool lock = true);
void clear(bool lock = true);
void refresh();
void stopPopCallInfoThread(bool wait = false);
void evCall(Call *call, sSciInfo::eTypeSci typeSci, u_int64_t at);
private:
void initPopCallInfoThread();
void popCallInfoThread();
void getSciFromCall(sSciInfo *sciInfo, Call *call,
sSciInfo::eTypeSci typeSci, u_int64_t at);
void lock() {
while(__sync_lock_test_and_set(&this->_sync, 1));
}
void unlock() {
__sync_lock_release(&this->_sync);
}
private:
list<SendCallInfoItem*> listSci;
SafeAsyncQueue<sSciInfo> sciQueue;
pthread_t threadPopCallInfo;
bool runPopCallInfoThread;
bool termPopCallInfoThread;
volatile int _sync;
friend void *_SendCallInfo_popCallInfoThread(void *arg);
};
void initSendCallInfo();
void termSendCallInfo();
void refreshSendCallInfo();
void sendCallInfoEvCall(Call *call, sSciInfo::eTypeSci typeSci, struct timeval tv);
bool isExistsSendCallInfo();
#endif