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.
 
 

64 lines
826 B

/**
* @file NATItem.cpp
*
* Created on: 10-01-2017
* @author Piotr Dergun
*/
#include "NATItem.h"
NATItem::NATItem()
{
this->ip = "0.0.0.0";
this->port = 0;
this->timeout = time(NULL);
}
const string& NATItem::getIp() const
{
return ip;
}
void NATItem::setIp(const string& ip)
{
this->ip = ip;
}
int NATItem::getPort() const
{
return port;
}
void NATItem::setPort(int port)
{
this->port = port;
}
unsigned long NATItem::getTimeout() const
{
long t = this->timeout - time(NULL);
if (t < 0)
return 0;
return t;
}
bool NATItem::isFree()
{
return (this->getTimeout() == 0);
}
void NATItem::setTimeout(int timeout)
{
this->timeout = time(NULL) + timeout;
}
void NATItem::free()
{
this->setTimeout(0);
}
void NATItem::increaseTimeout(int timeout)
{
this->setTimeout(this->getTimeout() + timeout);
}