forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regcache.h
51 lines (39 loc) · 1009 Bytes
/
regcache.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
#ifndef PCAP_REQCACHE_H
#define PCAP_REGCACHE_H
#include <memory.h>
#include <netdb.h>
#include <pthread.h>
#include <pcap.h>
#include <deque>
#include <queue>
#include <map>
#include <string>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <sys/syscall.h>
#include <pthread.h>
using namespace std;
struct regcachenode_t {
unsigned int timestamp;
unsigned int counter;
};
typedef map<string, regcachenode_t> t_regcache_buffer;
class regcache {
public:
t_regcache_buffer regcache_buffer;
pthread_mutex_t buf_lock;
unsigned int lastprune;
int check(unsigned int srcip, unsigned int dstip, unsigned int timestamp, unsigned int *count);
void prune(unsigned int timestamp);
void prunecheck(unsigned int timestmp);
// void lock() { pthread_mutex_lock(&buf_lock); };
// void unlock() { pthread_mutex_unlock(&buf_lock); };
void lock() {}; // do nothing
void unlock() {}; // do nothing
regcache() {
pthread_mutex_init(&buf_lock, NULL);
lastprune = 0;
};
~regcache();
};
#endif