/*
|
|
* NATRouter.h
|
|
*
|
|
* Created on: 11-01-2017
|
|
* Author: Piotr Dergun
|
|
*/
|
|
|
|
#ifndef NATROUTER_H_
|
|
#define NATROUTER_H_
|
|
|
|
#include "common.h"
|
|
#include "Node.h"
|
|
#include "NATItem.h"
|
|
|
|
class NATRouter : public Node
|
|
{
|
|
NATItem *natTable = NULL; // tablica z zaalokowanymi portami na zewnątrz
|
|
map<string, int> natHelper; // mapa pomocnicza pozwalajaca szybko znalezc wpis
|
|
NetConf netWanConf; // konfiguracja sieciowa na zewnątrz
|
|
void initalizeNatTable();
|
|
int getFreePort();
|
|
int lastUsedPort = 0;
|
|
int getAllocatedPort(string srcIp, int srcPort);
|
|
void sNAT(Packet *packet);
|
|
void dNAT(Packet *packet);
|
|
void setWanNetwork();
|
|
|
|
public:
|
|
NATRouter();
|
|
NATRouter(string hostname);
|
|
NATRouter(string hostname, string ip, string mask);
|
|
NATRouter(string hostname, string ip, string mask, string gatewayIp);
|
|
~NATRouter();
|
|
|
|
virtual void onRecv();
|
|
void freePorts();
|
|
|
|
// settery
|
|
void setWanIp(string wanIp);
|
|
void setWanMask(string wanMask);
|
|
void setWanGatewayIp(string wanGatewayIp);
|
|
|
|
// gettery
|
|
string getWanIp();
|
|
string getWanMask();
|
|
string getWanNetwork();
|
|
string getWanGatewayIp();
|
|
};
|
|
|
|
#define NAT_TABLE_LEN 65536
|
|
|
|
#endif /* NATROUTER_H_ */
|