98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) Intel Corporation, 2006 - 2007.
|
|
//
|
|
// File: TunnelManager.h
|
|
//
|
|
// Contents: Class for mapping between full address (including address and
|
|
// port) and tunnels.
|
|
//
|
|
// Notes:
|
|
//----------------------------------------------------------------------------
|
|
#ifndef _TUNNEL_MANAGER_H__
|
|
#define _TUNNEL_MANAGER_H__
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <ace/RW_Thread_Mutex.h>
|
|
#include <ace/Vector_T.h>
|
|
#include <ace/SString.h>
|
|
#include <ace/Null_Mutex.h>
|
|
#include <ace/Thread_Mutex.h>
|
|
|
|
class AMT_Tunnel_Handler;
|
|
|
|
using namespace std;
|
|
// This class provides mapping between sockets, sessions, tunnels and channels.
|
|
// The class is thread safe and support multiple readers but single writer.
|
|
class Port_Address {
|
|
public:
|
|
ACE_CString fqdn;
|
|
ACE_UINT32 port;
|
|
|
|
// constructors
|
|
Port_Address():port() {};
|
|
Port_Address(const ACE_CString &fullAddress);
|
|
Port_Address(const ACE_CString &new_fqdn, ACE_UINT32 new_port);
|
|
|
|
bool operator== (const Port_Address& other);
|
|
};
|
|
|
|
class Tunnel_Manager {
|
|
private:
|
|
|
|
//===================================================
|
|
// CTOR/DTOR
|
|
//===================================================
|
|
Tunnel_Manager(void) {};
|
|
public:
|
|
static Tunnel_Manager& instance() {
|
|
static Tunnel_Manager t;
|
|
return t;
|
|
}
|
|
~Tunnel_Manager(void){};
|
|
|
|
//===================================================
|
|
// Public Function
|
|
//===================================================
|
|
int add_tunnel ( const AMT_Tunnel_Handler* tunnel,
|
|
const ACE_CString &address,
|
|
const ACE_UINT32 port);
|
|
|
|
int delete_tunnel( const ACE_CString &address,
|
|
const ACE_UINT32 port);
|
|
|
|
bool tunnel_exists( const ACE_CString &address,
|
|
const ACE_UINT32 port);
|
|
|
|
AMT_Tunnel_Handler* find_tunnel ( const ACE_CString &address,
|
|
const ACE_UINT32 port);
|
|
|
|
AMT_Tunnel_Handler* find_tunnel ( const ACE_CString &full_address);
|
|
|
|
void get_open_ports(const AMT_Tunnel_Handler* tunnel,
|
|
ACE_Vector<Port_Address> &ports);
|
|
|
|
|
|
// Read/Write guard
|
|
ACE_RW_Thread_Mutex& guard() {return rwmutex_;}
|
|
|
|
private:
|
|
// Read/Write lock of this container
|
|
ACE_RW_Thread_Mutex rwmutex_;
|
|
typedef map<ACE_CString, AMT_Tunnel_Handler*> TUNNEL_MAP;
|
|
|
|
//===================================================
|
|
// Data Members
|
|
//===================================================
|
|
TUNNEL_MAP _tunnel_map;
|
|
|
|
//===================================================
|
|
// Private Function
|
|
//===================================================
|
|
ACE_CString buildFullAddress(const ACE_CString &address, ACE_UINT32 port);
|
|
};
|
|
|
|
#endif // _TUNNEL_MANAGER_H__
|
|
|