Symulacja NAT na przedmiot Symulacje Komputerowe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.0 KiB

/*
* 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
NetConf netWanConf; // konfiguracja sieciowa na zewnątrz
void initalizeNatTable();
int getFreePort();
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_ */