nl.openfortress.socket6bed4
Class ConnectionPool

java.lang.Object
  extended by nl.openfortress.socket6bed4.ConnectionPool

public class ConnectionPool
extends Object

The ConnectionPool links IPv4 sockets for 6bed4 with the implementations of IPv6 sockets. Each IPv4 socket may have multiple IPv6 sockets, as a result of these variation factors: - the router supplies a range of IPv6 addresses - the IPv6 DatagramSockets can listen to multiple ports - the IPv6 DatagramSockets could receive from multiple ports Incoming traffic is mapped based on an InetSocketAddress; if an exact match is not available, then the zero address is tried instead. The sender information is stored in a Datagrampacket's SocketAddress.


Field Summary
protected  Hashtable<Inet6Address,InetSocketAddress> addressmap
           
protected  Hashtable<InetSocketAddress,DatagramSocket6bed4> clients
           
protected  InetSocketAddress default_server
           
protected static byte[] serveripbytes
           
protected static int serverport
           
protected  Hashtable<InetSocketAddress,ServerNode> servers
           
 
Constructor Summary
ConnectionPool()
          Construct a ServerPool with nothing but the default server.
 
Method Summary
 void closeServer(InetSocketAddress isa)
          Stop using a server, possibly removing it.
 InetSocketAddress getDefaultServer()
          Return the default 6bed4 tunnel server.
 ServerNode getDefaultServerNode()
          Return the ServerNode for the default 6bed4 tunnel server.
 ServerNode getServerNode(InetAddress ia)
          Returns the ServerNode for a given InetAddress, which is then assumed to match an Inet6Address in the hash tables.
 ServerNode getServerNode(InetSocketAddress isa)
          Return the ServerNode for a given InetSocketAddress, holding the server's IPv4 address and UDP port.
static ConnectionPool getSharedConnectionPool()
          Return the connection pool intended to be shared.
 ServerNode openServer(InetSocketAddress isa)
          Start using a server, possibly introducing it.
 void setDefaultServer(InetSocketAddress isa)
          Change the server that counts as the default tunnel server for future connection attempts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serveripbytes

protected static final byte[] serveripbytes

serverport

protected static final int serverport
See Also:
Constant Field Values

default_server

protected InetSocketAddress default_server

clients

protected Hashtable<InetSocketAddress,DatagramSocket6bed4> clients

servers

protected Hashtable<InetSocketAddress,ServerNode> servers

addressmap

protected Hashtable<Inet6Address,InetSocketAddress> addressmap
Constructor Detail

ConnectionPool

public ConnectionPool()
               throws SocketException
Construct a ServerPool with nothing but the default server. There are no clients yet, of course.

Throws:
SocketException
Method Detail

getSharedConnectionPool

public static ConnectionPool getSharedConnectionPool()
Return the connection pool intended to be shared.


openServer

public ServerNode openServer(InetSocketAddress isa)
                      throws UnknownHostException,
                             SocketException
Start using a server, possibly introducing it. Return the ServerNode that is herewith opened.

Throws:
UnknownHostException
SocketException

closeServer

public void closeServer(InetSocketAddress isa)
                 throws UnknownHostException
Stop using a server, possibly removing it.

Throws:
UnknownHostException

getDefaultServer

public InetSocketAddress getDefaultServer()
Return the default 6bed4 tunnel server.


getDefaultServerNode

public ServerNode getDefaultServerNode()
Return the ServerNode for the default 6bed4 tunnel server.


getServerNode

public ServerNode getServerNode(InetSocketAddress isa)
Return the ServerNode for a given InetSocketAddress, holding the server's IPv4 address and UDP port. Returns null if not found. TODO: WHAT IS THE PURPOSE HERE?!?


getServerNode

public ServerNode getServerNode(InetAddress ia)
Returns the ServerNode for a given InetAddress, which is then assumed to match an Inet6Address in the hash tables. Returns null if not found.


setDefaultServer

public void setDefaultServer(InetSocketAddress isa)
                      throws UnknownHostException,
                             SocketException
Change the server that counts as the default tunnel server for future connection attempts. Existing connections are not influenced.

Throws:
UnknownHostException
SocketException


Copyright © 2012. All Rights Reserved.