rm dist package and mv ckecksumlist to natmap
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
#!/bin/bash
|
||||
cd lib
|
||||
sh buildalllibs.sh
|
||||
cd ..
|
||||
mkdir -p build/121Natbuild
|
||||
cd build/121Natbuild
|
||||
cmake ../../
|
||||
5
buildAll.bash
Normal file
5
buildAll.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd lib
|
||||
sh buildalllibs.bash
|
||||
cd ..
|
||||
sh build.bash
|
||||
47
dist/package/PKGBUILD
vendored
47
dist/package/PKGBUILD
vendored
@@ -1,47 +0,0 @@
|
||||
pkgname=121Nat
|
||||
pkgver=1.0 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'
|
||||
pkgrel=1
|
||||
pkgdesc="transparent one to one nat"
|
||||
arch=(any)
|
||||
url="http://www.foo.org"
|
||||
license=('MIT')
|
||||
depends=('pth' 'libpcap' 'python2' 'jsoncpp')
|
||||
makedepends=('cmake')
|
||||
source=(./$pkgname-$pkgver.tar.gz)
|
||||
md5sums=('0e1494ebbcf0b0ca1bfa8475c5078f21')
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/${pkgname}"
|
||||
cd lib
|
||||
mkdir -p bin
|
||||
# mkdir -p build/jsoncpp/
|
||||
# cd build/jsoncpp/
|
||||
# cmake ../../src/jsoncpp -DCMAKE_INSTALL_PREFIX=/usr
|
||||
# make
|
||||
# cp src/lib_json/libjsoncpp.a ../../bin
|
||||
# cd ../..
|
||||
mkdir -p build/libtins/
|
||||
cd build/libtins/
|
||||
cmake ../../src/libtins -DLIBTINS_BUILD_SHARED=1 -DLIBTINS_ENABLE_CXX11=1 -DLIBTINS_ENABLE_WPA2=0 -DLIBTINS_ENABLE_DOT11=0 -DHAVE_PCAP_IMMEDIATE_MODE=1 -DCMAKE_INSTALL_PREFIX=/usr
|
||||
make
|
||||
cp lib/libtins.so ../../bin
|
||||
cd ../../..
|
||||
mkdir -p build/121Natbuild
|
||||
cd build/121Natbuild
|
||||
cmake ../../ -DCMAKE_INSTALL_PREFIX=/usr
|
||||
make
|
||||
cp src/121Nat ../
|
||||
}
|
||||
|
||||
package() {
|
||||
#cd ${srcdir}/${pkgname}/lib/build/jsoncpp
|
||||
#make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/${pkgname}/lib/build/libtins"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/${pkgname}/build/121Natbuild"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
mkdir -p "${pkgdir}/etc/${pkgname}"
|
||||
cp "../../src/config.json" "${pkgdir}/etc/${pkgname}/config-example.json"
|
||||
rm -R "${pkgdir}/usr/CMake"
|
||||
}
|
||||
md5sums=('6d9edd32ba681731501820c5330bd692')
|
||||
46
dist/package/PKGBUILD.example
vendored
46
dist/package/PKGBUILD.example
vendored
@@ -1,46 +0,0 @@
|
||||
pkgname=121Nat
|
||||
pkgver=1.0 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'
|
||||
pkgrel=1
|
||||
pkgdesc="transparent one to one nat"
|
||||
arch=(any)
|
||||
url="http://www.foo.org"
|
||||
license=('MIT')
|
||||
depends=('pth' 'libpcap' 'python2' 'jsoncpp')
|
||||
makedepends=('cmake')
|
||||
source=(./$pkgname-$pkgver.tar.gz)
|
||||
md5sums=('0e1494ebbcf0b0ca1bfa8475c5078f21')
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/${pkgname}"
|
||||
cd lib
|
||||
mkdir -p bin
|
||||
# mkdir -p build/jsoncpp/
|
||||
# cd build/jsoncpp/
|
||||
# cmake ../../src/jsoncpp -DCMAKE_INSTALL_PREFIX=/usr
|
||||
# make
|
||||
# cp src/lib_json/libjsoncpp.a ../../bin
|
||||
# cd ../..
|
||||
mkdir -p build/libtins/
|
||||
cd build/libtins/
|
||||
cmake ../../src/libtins -DLIBTINS_BUILD_SHARED=1 -DLIBTINS_ENABLE_CXX11=1 -DLIBTINS_ENABLE_WPA2=0 -DLIBTINS_ENABLE_DOT11=0 -DHAVE_PCAP_IMMEDIATE_MODE=1 -DCMAKE_INSTALL_PREFIX=/usr
|
||||
make
|
||||
cp lib/libtins.so ../../bin
|
||||
cd ../../..
|
||||
mkdir -p build/121Natbuild
|
||||
cd build/121Natbuild
|
||||
cmake ../../ -DCMAKE_INSTALL_PREFIX=/usr
|
||||
make
|
||||
cp src/121Nat ../
|
||||
}
|
||||
|
||||
package() {
|
||||
#cd ${srcdir}/${pkgname}/lib/build/jsoncpp
|
||||
#make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/${pkgname}/lib/build/libtins"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/${pkgname}/build/121Natbuild"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
mkdir -p "${pkgdir}/etc/${pkgname}"
|
||||
cp "../../src/config.json" "${pkgdir}/etc/${pkgname}/config-example.json"
|
||||
rm -R "${pkgdir}/usr/CMake"
|
||||
}
|
||||
20
dist/package/createpackage.sh
vendored
20
dist/package/createpackage.sh
vendored
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
mkdir -p temp/121Nat/lib
|
||||
|
||||
cp -R ../../src/ temp/121Nat/
|
||||
cp -R ../../lib/src/ temp/121Nat/lib/
|
||||
cp ../../lib/*.sh temp/121Nat/lib/
|
||||
cp ../../build.sh temp/121Nat/
|
||||
cp ../../CMakeLists.txt temp/121Nat/
|
||||
cp PKGBUILD.example temp/PKGBUILD
|
||||
|
||||
cd temp
|
||||
tar -cvzf 121Nat-1.0.tar.gz 121Nat/
|
||||
md5=($(md5sum 121Nat-1.0.tar.gz))
|
||||
echo "md5sums=('$md5')" >> PKGBUILD
|
||||
makepkg
|
||||
cp *.pkg.tar.xz ../
|
||||
cp *.tar.gz ../
|
||||
cp -f PKGBUILD ../PKGBUILD
|
||||
cd ..
|
||||
rm -Rf temp
|
||||
3
lib/buildalllibs.bash
Normal file
3
lib/buildalllibs.bash
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
sh buildjsoncpp.bash
|
||||
sh buildlibtins.bash
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
sh buildjsoncpp.sh
|
||||
sh buildlibtins.sh
|
||||
@@ -70,7 +70,7 @@ FFLAGS=
|
||||
ASFLAGS=
|
||||
|
||||
# Link Libraries and Options
|
||||
LDLIBSOPTIONS=-lpthread lib/bin/libjsoncpp.a -ltins
|
||||
LDLIBSOPTIONS=-lpthread lib/bin/libjsoncpp.a lib/bin/libtins.so
|
||||
|
||||
# Build Targets
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
@@ -78,6 +78,8 @@ LDLIBSOPTIONS=-lpthread lib/bin/libjsoncpp.a -ltins
|
||||
|
||||
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/121nat: lib/bin/libjsoncpp.a
|
||||
|
||||
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/121nat: lib/bin/libtins.so
|
||||
|
||||
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/121nat: ${OBJECTFILES}
|
||||
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
|
||||
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/121nat ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<linkerLibItems>
|
||||
<linkerLibLibItem>pthread</linkerLibLibItem>
|
||||
<linkerLibFileItem>lib/bin/libjsoncpp.a</linkerLibFileItem>
|
||||
<linkerLibLibItem>tins</linkerLibLibItem>
|
||||
<linkerLibFileItem>lib/bin/libtins.so</linkerLibFileItem>
|
||||
</linkerLibItems>
|
||||
</linkerTool>
|
||||
</compileType>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
file(GLOB_RECURSE 121Nat_Src_Files "*.h" "*.cpp")
|
||||
add_executable(121Nat ${121Nat_Src_Files})
|
||||
target_link_libraries (121Nat pthread ${CMAKE_SOURCE_DIR}/lib/bin/libtins.so jsoncpp)
|
||||
target_link_libraries (121Nat pthread ${CMAKE_SOURCE_DIR}/lib/bin/libtins.so ${CMAKE_SOURCE_DIR}/lib/bin/libjsoncpp.a)
|
||||
target_compile_features(121Nat PRIVATE cxx_range_for)
|
||||
install(TARGETS 121Nat
|
||||
RUNTIME DESTINATION bin
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace otonat {
|
||||
this->map = map;
|
||||
}
|
||||
|
||||
PduSender::PduSender(const PduSender& orig) : checksumList(orig.checksumList) {
|
||||
PduSender::PduSender(const PduSender& orig) {
|
||||
this->map = orig.map;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace otonat {
|
||||
if (this == &rhs) return *this; // handle self assignment
|
||||
|
||||
this->map = rhs.map;
|
||||
this->checksumList = rhs.checksumList;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -39,37 +38,30 @@ namespace otonat {
|
||||
|
||||
std::cout << "send pdu:" << pdu->size() << std::endl;
|
||||
|
||||
bool isIp = false;
|
||||
NatMap::Checksum ipCheckSum;
|
||||
Tins::IPv4Address dstIp = zeroIp;
|
||||
const Tins::ARP * arp = pdu->find_pdu<Tins::ARP>();
|
||||
bool isArp = false;
|
||||
if (arp != nullptr) {
|
||||
dstIp = arp->target_ip_addr();
|
||||
isArp = true;
|
||||
const Tins::IP * ip = pdu->find_pdu<Tins::IP>();
|
||||
if (ip != nullptr) {
|
||||
dstIp = ip->dst_addr();
|
||||
ipCheckSum = ip->checksum();
|
||||
isIp = true;
|
||||
}
|
||||
|
||||
if (!isArp) {
|
||||
const Tins::IP * ip = pdu->find_pdu<Tins::IP>();
|
||||
if (ip != nullptr) {
|
||||
dstIp = ip->dst_addr();
|
||||
|
||||
unsigned short int checkSum = ip->checksum();
|
||||
ChecksumList::const_iterator endIter = this->checksumList.end();
|
||||
ChecksumList::const_iterator beginIter = this->checksumList.begin();
|
||||
ChecksumList::const_iterator findIter = std::find(beginIter, endIter, checkSum);
|
||||
if (endIter == findIter) {
|
||||
this->checksumList.push_back(checkSum);
|
||||
if (this->checksumList.size() > 10) {
|
||||
this->checksumList.pop_front();
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!isIp) {
|
||||
const Tins::ARP * arp = pdu->find_pdu<Tins::ARP>();
|
||||
if (arp != nullptr) {
|
||||
dstIp = arp->target_ip_addr();
|
||||
}
|
||||
}
|
||||
|
||||
for (NatRange & range : this->map->ranges) {
|
||||
if (range.calcIpRange(true).contains(dstIp)) {
|
||||
std::cout << "send pdu:" << pdu->size() << std::endl;
|
||||
if (isIp) {
|
||||
map->pushCheckSumToList(ipCheckSum);
|
||||
}
|
||||
|
||||
sender.send(*pdu, range.interface);
|
||||
delete pdu;
|
||||
break;
|
||||
|
||||
@@ -17,14 +17,11 @@ namespace otonat {
|
||||
|
||||
class PduSender {
|
||||
public:
|
||||
typedef std::list<unsigned short int> ChecksumList;
|
||||
|
||||
PduSender(NatMap * map);
|
||||
PduSender(const PduSender& orig);
|
||||
PduSender& operator=(const PduSender& rhs);
|
||||
virtual ~PduSender();
|
||||
NatMap * map;
|
||||
ChecksumList checksumList;
|
||||
void SendPdusFromQueue();
|
||||
|
||||
std::thread * SendPdusFromQueueThread();
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace otonat {
|
||||
ranges.clear();
|
||||
transMap.clear();
|
||||
reqIpMap.clear();
|
||||
|
||||
this->checksumListMutex.lock();
|
||||
this->checksumList.clear();
|
||||
this->checksumListMutex.unlock();
|
||||
this->incommingQueueMutex.lock();
|
||||
while (!incommingPduQueue.empty()) {
|
||||
incommingPduQueue.pop();
|
||||
@@ -24,7 +28,7 @@ namespace otonat {
|
||||
this->outgoingQueueMutex.unlock();
|
||||
}
|
||||
|
||||
NatMap::NatMap(const NatMap& other) : ranges(other.ranges), transMap(other.transMap), reqIpMap(other.reqIpMap), incommingPduQueue(other.incommingPduQueue), outgoingPduQueue(other.outgoingPduQueue) {
|
||||
NatMap::NatMap(const NatMap& other) : ranges(other.ranges), transMap(other.transMap), reqIpMap(other.reqIpMap), incommingPduQueue(other.incommingPduQueue), outgoingPduQueue(other.outgoingPduQueue), checksumList(other.checksumList) {
|
||||
}
|
||||
|
||||
NatMap& NatMap::operator=(const NatMap& rhs) {
|
||||
@@ -38,6 +42,9 @@ namespace otonat {
|
||||
this->outgoingQueueMutex.lock();
|
||||
outgoingPduQueue = rhs.outgoingPduQueue;
|
||||
this->outgoingQueueMutex.unlock();
|
||||
this->checksumListMutex.lock();
|
||||
this->checksumList = rhs.checksumList;
|
||||
this->checksumListMutex.unlock();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -58,14 +65,19 @@ namespace otonat {
|
||||
}
|
||||
|
||||
Tins::IP * ip = pduCopy->find_pdu<Tins::IP>();
|
||||
if (ip != nullptr) {
|
||||
if (handleIp(ip, pduCopy)) {
|
||||
this->pushPduToOutgoingPduQueue(pduCopy);
|
||||
}
|
||||
if (ip != nullptr && handleIp(ip, pduCopy)) {
|
||||
|
||||
this->pushPduToOutgoingPduQueue(pduCopy);
|
||||
}
|
||||
}
|
||||
|
||||
bool NatMap::handleIp(Tins::IP * ip, const Tins::PDU * originPDU) {
|
||||
Checksum checksum = ip->checksum();
|
||||
|
||||
if (containChecksumList(checksum)) {
|
||||
this->popCheckSumToList(checksum);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isForMeOrFromMeIp(ip)) {
|
||||
return false;
|
||||
@@ -92,6 +104,7 @@ namespace otonat {
|
||||
} else {
|
||||
const Tins::EthernetII * eth = originPDU->find_pdu<Tins::EthernetII>();
|
||||
if (eth != nullptr) {
|
||||
|
||||
Tins::EthernetII fakeArp = Tins::ARP::make_arp_request(ip->dst_addr(), ip->src_addr(), eth->src_addr());
|
||||
SendTranslatedArpRequest(fakeArp.find_pdu<Tins::ARP>());
|
||||
}
|
||||
@@ -114,6 +127,7 @@ namespace otonat {
|
||||
// set translated src address
|
||||
transSrcAttr = transIpIter->second;
|
||||
} else {
|
||||
|
||||
transSrcAttr = InsertOrUdpateTranslateIpAddress(originSrc, transDstIp, ranges);
|
||||
}
|
||||
|
||||
@@ -131,6 +145,7 @@ namespace otonat {
|
||||
|
||||
const Tins::IPv4Range ipRange = range.calcIpRange(true);
|
||||
if (!ipRange.contains(otherTransSameRangeIp)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -158,12 +173,12 @@ namespace otonat {
|
||||
if (transIpIter != transMap.end()) {
|
||||
transMap[transIp] = originIp;
|
||||
} else {
|
||||
|
||||
transMap.insert(IPv4AddressEntry(transIp, originIp));
|
||||
}
|
||||
}
|
||||
|
||||
bool NatMap::handleArp(Tins::ARP * arp) {
|
||||
|
||||
if (isForMeOrFromMeArp(arp)) {
|
||||
return false;
|
||||
}
|
||||
@@ -178,17 +193,20 @@ namespace otonat {
|
||||
return this->handleArpReq(arp);
|
||||
case Tins::ARP::REPLY:
|
||||
return this->handleArpReply(arp);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool NatMap::isForMeOrFromMeIp(const Tins::IP* ip) const {
|
||||
|
||||
return isForMeOrFromMeIp(ip, ranges);
|
||||
}
|
||||
|
||||
bool NatMap::isForMeOrFromMeArp(const Tins::ARP * arp) const {
|
||||
Tins::IP fakeIp(arp->target_ip_addr(), arp->sender_ip_addr());
|
||||
|
||||
return isForMeOrFromMeIp(&fakeIp);
|
||||
}
|
||||
|
||||
@@ -198,6 +216,7 @@ namespace otonat {
|
||||
for (NatRange range : rangeList) {
|
||||
const Tins::IPv4Address & interfaceAddr = range.interface.info().ip_addr;
|
||||
if (srcAddr == interfaceAddr || dstAddr == interfaceAddr) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -205,12 +224,14 @@ namespace otonat {
|
||||
}
|
||||
|
||||
bool NatMap::isIpInMyRanges(const Tins::IPv4Address & ipAddr) const {
|
||||
|
||||
return isIpInMyRanges(ipAddr, ranges);
|
||||
}
|
||||
|
||||
bool NatMap::isIpInMyRanges(const Tins::IPv4Address & ipAddr, const NatRangeList & rangeList) {
|
||||
for (NatRange range : rangeList) {
|
||||
if (range.calcIpRange(false).contains(ipAddr)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -237,6 +258,7 @@ namespace otonat {
|
||||
if (transSenderIpIter != transMap.end()) {
|
||||
arp->sender_ip_addr(transSenderIpIter->second);
|
||||
this->reqIpMap.insert(IPv4AddressEntry(transTargetIp, targetIp));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -249,7 +271,7 @@ namespace otonat {
|
||||
if (transSenderIpReqIter == reqIpMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const Tins::IPv4Address transTargetIp = TranslateArpIp(targetIp);
|
||||
if (transTargetIp == zeroIp) {
|
||||
return false;
|
||||
@@ -263,6 +285,7 @@ namespace otonat {
|
||||
|
||||
arp->target_ip_addr(transTargetIp);
|
||||
arp->sender_ip_addr(transSenderIp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,6 +302,7 @@ namespace otonat {
|
||||
this->InsertOrUdpateTranslateIpAddress(arpIp, transArpIp);
|
||||
this->InsertOrUdpateTranslateIpAddress(transArpIp, arpIp);
|
||||
this->reqIpMap.erase(transReqArpIpIter);
|
||||
|
||||
return transArpIp;
|
||||
}
|
||||
|
||||
@@ -303,6 +327,7 @@ namespace otonat {
|
||||
|
||||
IpAdressMap::const_iterator transSenderIpReqIter = this->reqIpMap.find(transSenderIp);
|
||||
if (transSenderIpReqIter == reqIpMap.end()) {
|
||||
|
||||
this->reqIpMap.insert(IPv4AddressEntry(transSenderIp, senderIp));
|
||||
}
|
||||
|
||||
@@ -335,6 +360,7 @@ namespace otonat {
|
||||
|
||||
IpAdressMap::const_iterator transTargetIpReqIter = this->reqIpMap.find(transTargetIp);
|
||||
if (transTargetIpReqIter == reqIpMap.end()) {
|
||||
|
||||
this->reqIpMap.insert(IPv4AddressEntry(transTargetIp, targetIp));
|
||||
}
|
||||
|
||||
@@ -344,18 +370,22 @@ namespace otonat {
|
||||
}
|
||||
|
||||
void NatMap::pushPduToIncommingPduQueue(const Tins::PDU* pdu) {
|
||||
|
||||
pushPduToPduQueue(pdu, this->incommingPduQueue, this ->incommingQueueMutex);
|
||||
}
|
||||
|
||||
Tins::PDU * NatMap::popPduIncommingPduQueue() {
|
||||
|
||||
return popPduPduQueue(this->incommingPduQueue, this->incommingQueueMutex);
|
||||
}
|
||||
|
||||
void NatMap::pushPduToOutgoingPduQueue(const Tins::PDU* pdu) {
|
||||
|
||||
pushPduToPduQueue(pdu, this->outgoingPduQueue, this->outgoingQueueMutex);
|
||||
}
|
||||
|
||||
Tins::PDU * NatMap::popPduOutgoingPduQueue() {
|
||||
|
||||
return popPduPduQueue(this->outgoingPduQueue, this->outgoingQueueMutex);
|
||||
}
|
||||
|
||||
@@ -371,10 +401,12 @@ namespace otonat {
|
||||
queue.pop();
|
||||
mtx.unlock();
|
||||
delete result;
|
||||
|
||||
return outPut;
|
||||
}
|
||||
|
||||
void NatMap::pushPduToPduQueue(const Tins::PDU* pdu, PduQueue& queue, std::mutex& mtx) {
|
||||
|
||||
mtx.lock();
|
||||
queue.push(pdu);
|
||||
mtx.unlock();
|
||||
@@ -384,6 +416,7 @@ namespace otonat {
|
||||
while (true) {
|
||||
Tins::PDU * pdu = this->popPduIncommingPduQueue();
|
||||
if (pdu == nullptr) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -391,6 +424,29 @@ namespace otonat {
|
||||
}
|
||||
}
|
||||
|
||||
void NatMap::pushCheckSumToList(Checksum checksum) {
|
||||
checksumListMutex.lock();
|
||||
if (!containChecksumList(checksum)) {
|
||||
|
||||
this->checksumList.push_back(checksum);
|
||||
}
|
||||
|
||||
checksumListMutex.unlock();
|
||||
}
|
||||
|
||||
void NatMap::popCheckSumToList(Checksum checksum) {
|
||||
checksumListMutex.lock();
|
||||
this->checksumList.remove(checksum);
|
||||
checksumListMutex.unlock();
|
||||
}
|
||||
|
||||
bool NatMap::containChecksumList(Checksum checksum) {
|
||||
ChecksumList::const_iterator endIter = this->checksumList.end();
|
||||
ChecksumList::const_iterator beginIter = this->checksumList.begin();
|
||||
ChecksumList::const_iterator findIter = std::find(beginIter, endIter, checksum);
|
||||
return endIter != findIter;
|
||||
}
|
||||
|
||||
std::thread * NatMap::translateThread() {
|
||||
std::thread * newThread = new std::thread(std::bind(&NatMap::translate, this));
|
||||
return newThread;
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace otonat {
|
||||
typedef std::queue<const Tins::PDU *> PduQueue;
|
||||
typedef std::pair<Tins::IPv4Address, Tins::IPv4Address> IPv4AddressEntry;
|
||||
typedef std::map<Tins::IPv4Address, Tins::IPv4Address> IpAdressMap;
|
||||
typedef unsigned short int Checksum;
|
||||
typedef std::list<Checksum> ChecksumList;
|
||||
|
||||
|
||||
NatMap() {
|
||||
}
|
||||
@@ -38,7 +41,8 @@ namespace otonat {
|
||||
Tins::PDU * popPduIncommingPduQueue();
|
||||
void pushPduToOutgoingPduQueue(const Tins::PDU * pdu);
|
||||
Tins::PDU * popPduOutgoingPduQueue();
|
||||
|
||||
void pushCheckSumToList(Checksum checksum);
|
||||
|
||||
static Tins::PDU * popPduPduQueue(PduQueue & queue, std::mutex & mtx);
|
||||
static void pushPduToPduQueue(const Tins::PDU * pdu, PduQueue & queue, std::mutex & mtx);
|
||||
|
||||
@@ -61,9 +65,12 @@ namespace otonat {
|
||||
bool isIpInMyRanges(const Tins::IPv4Address & ipAddr) const;
|
||||
static bool isIpInMyRanges(const Tins::IPv4Address & ipAddr, const NatRangeList & rangeList);
|
||||
void SendTranslatedArpRequest(const Tins::ARP * arp);
|
||||
|
||||
void popCheckSumToList(Checksum checksum);
|
||||
bool containChecksumList(Checksum checksum);
|
||||
std::mutex incommingQueueMutex;
|
||||
std::mutex outgoingQueueMutex;
|
||||
std::mutex checksumListMutex;
|
||||
ChecksumList checksumList;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user