check outgoing packet , depends of source mac
This commit is contained in:
47
src/main.cpp
47
src/main.cpp
@@ -1,19 +1,29 @@
|
||||
#include <iostream>
|
||||
#include <tins/tins.h>
|
||||
#include <thread>
|
||||
#include "map/natmap.h"
|
||||
#include "natmap.h"
|
||||
#include "PduSniffer.h"
|
||||
#include "PduSender.h"
|
||||
#include <json/json.h>
|
||||
#include <json/value.h>
|
||||
#include <fstream>
|
||||
|
||||
template<typename Container>
|
||||
void delete_them(Container& c)
|
||||
{
|
||||
while(!c.empty()) {
|
||||
delete c.back(), c.pop_back();
|
||||
}
|
||||
c.clear();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2){
|
||||
return 0;
|
||||
}
|
||||
|
||||
otonat::NatMap::NatRangeList list;
|
||||
|
||||
otonat::NatMap::NatRangeList interfaceList;
|
||||
std::ifstream config_doc(argv[1], std::ifstream::binary);
|
||||
Json::Value root;
|
||||
config_doc >> root;
|
||||
@@ -26,20 +36,29 @@ int main(int argc, char** argv)
|
||||
|
||||
const Tins::NetworkInterface net(name);
|
||||
const otonat::NatRange netRange(net, Tins::IPv4Address(ipStr), Tins::IPv4Address(maskStr));
|
||||
list.push_back(netRange);
|
||||
interfaceList.push_back(netRange);
|
||||
}
|
||||
|
||||
otonat::NatMap natMap = otonat::NatMap(list);
|
||||
otonat::PduSniffer sniffer(&natMap);
|
||||
|
||||
otonat::NatMap natMap = otonat::NatMap(interfaceList);
|
||||
otonat::PduSender sender(&natMap);
|
||||
std::thread * mapThread = natMap.translateThread();
|
||||
std::thread * senderThread = sender.SendPdusFromQueueThread();
|
||||
for (otonat::NatRange & net : list) {
|
||||
sniffer.SniffInterfaceInNewThread(net.interface);
|
||||
std::vector<otonat::PduSniffer* > snifferList;
|
||||
std::vector<std::thread * > threadList;
|
||||
threadList.push_back(natMap.translateThread());
|
||||
threadList.push_back(sender.SendPdusFromQueueThread());
|
||||
for (otonat::NatRange & net : interfaceList) {
|
||||
otonat::PduSniffer * sniffer = new otonat::PduSniffer(&natMap);
|
||||
snifferList.push_back(sniffer);
|
||||
threadList.push_back(sniffer->SniffInterfaceInNewThread(net.interface));
|
||||
}
|
||||
|
||||
mapThread->join();
|
||||
senderThread->join();
|
||||
|
||||
for (std::thread * thread: threadList) {
|
||||
thread->join();
|
||||
}
|
||||
|
||||
delete_them(threadList);
|
||||
delete_them(snifferList);
|
||||
threadList.clear();
|
||||
snifferList.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user