-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (42 loc) · 1.44 KB
/
main.cpp
File metadata and controls
56 lines (42 loc) · 1.44 KB
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
//
// Created by mingj on 18-12-18.
//
#include "NDNHelper.h"
#include "JSONCPPHelper.h"
#include "LibPcapHelper.h"
#include <execinfo.h>
using namespace std;
boost::lockfree::queue<tuple_p,boost::lockfree::capacity<40000>> LibPcapHelper::queuelist[10];
bool LibPcapHelper::threadUsage[MAX_THREAD_NUM] = {false};
void dealNDN(void *arg) {
auto *ndnHelper = (NDNHelper *) arg;
ndnHelper->start();
}
int main(int argc, char *argv[]) {
try {
NDNHelper ndnHelper;
MapCacheHelper<tuple_p> cacheHelper;
MapCacheHelper<long> pendingInterestMap;
MapCacheHelper<int> sequenceTable;
SetHelper<string> prefixRequestTable;
LibPcapHelper libPcapHelper(argv[1]);
ndnHelper.bindCacheHelper(&cacheHelper);
ndnHelper.bindPendingInterestMap(&pendingInterestMap);
ndnHelper.bindPrefixGuestTable(&prefixRequestTable);
libPcapHelper.bindCacheHelper(&cacheHelper);
libPcapHelper.bindPendingInterestTable(&pendingInterestMap);
libPcapHelper.bindSequenceTable(&sequenceTable);
libPcapHelper.bindNDNHelper(&ndnHelper);
ndnHelper.initNDN(argv[1]);
//在另一个线程处理NDN事件
boost::thread t(bind(&dealNDN, &ndnHelper));
//开始抓包
libPcapHelper.start();
t.join();
ndnHelper.join();
libPcapHelper.close();
} catch (std::exception &e) {
cerr << e.what() << endl;
}
return 0;
}