Blame tunnel.h

873e9f
#ifndef TUNNEL_H
873e9f
#define TUNNEL_H
873e9f
873e9f
c47604
#include "crypt.h"
873e9f
#include "socket.h"
873e9f
#include "connection.h"
873e9f
873e9f
#include <map></map>
873e9f
#include <set></set>
873e9f
873e9f
873e9f
873e9f
class Tunnel {
873e9f
public:
873e9f
	typedef std::map<connid, connection=""> ConnMap;</connid,>
c47604
	typedef std::map<connid, time=""> ClosedConnMap;</connid,>
873e9f
	typedef std::set<connid> ConnSet;</connid>
873e9f
	
873e9f
public:
873e9f
	Time time;
873e9f
	Time udpSendDuration;
873e9f
	Time udpPartialSendDuration;
873e9f
	Time udpResendDuration;
873e9f
	Time udpConfirmDuration;
c47604
	Time udpSilenceDuration;
c47604
	Time udpKeepAliveDuration;
0f653b
	Time timeQwant;
873e9f
	Time pollDuration;
873e9f
	
873e9f
	ConnMap connections;
c47604
	ClosedConnMap closedConnections;
873e9f
	ConnSet termQueue;
873e9f
	
873e9f
private:
c47604
	Crypt crypt;
873e9f
	Poll poll;
873e9f
	int udpSockId;
873e9f
	int tcpSockId;
873e9f
	Address remoteUdpAddress;
873e9f
	Address remoteTcpAddress;
873e9f
	Time nextTermSendTime;
873e9f
	
873e9f
public:
873e9f
	Tunnel();
873e9f
	~Tunnel();
873e9f
	
1d16df
	void initSpeed(unsigned long long bytesPerSecond);
1d16df
	
c47604
	bool initUdpServer(const Address &address, const Address &remoteTcpAddress, const char *key);
873e9f
	bool initTcpServer(const Address &address, const Address &remoteUdpAddress);
873e9f
	
873e9f
	void closeTcpServer();
873e9f
	void closeUdpServer();
873e9f
	void close();
873e9f
	
873e9f
	bool recvUdpPacket();
873e9f
	void sendUdpPacket(const Address &address, const Packet &packet);
1d16df
	
1d16df
	void initTime();
873e9f
	bool iteration();
873e9f
	
873e9f
	void run();
873e9f
};
873e9f
873e9f
873e9f
#endif