anon.client
Class ChannelTable

java.lang.Object
  extended by anon.client.ChannelTable
All Implemented Interfaces:
IDataChannelCreator

public class ChannelTable
extends java.lang.Object
implements IDataChannelCreator

Author:
Stefan Lieske

Field Summary
static int CONTROL_CHANNEL_ID_DUMMY
           
static int CONTROL_CHANNEL_ID_PAY
           
static int CONTROL_CHANNEL_ID_REPLAY
           
private  int m_availableDataChannels
           
private  java.security.SecureRandom m_channelIdGenerator
           
private  java.util.Hashtable m_channelTable
           
private  IDataChannelFactory m_dataChannelFactory
           
private  boolean m_tableClosed
           
private static int MAX_OPEN_DATACHANNELS
           
private static int MAX_RESERVED_CHANNEL_ID
          The maximum Channel-ID in the reserved area for ControlChannels (those Channel-IDs are not available for DataChannels).
private static int MIN_RESERVED_CHANNEL_ID
          The minimum Channel-ID in the reserved area for ControlChannels (those Channel-IDs are not available for DataChannels).
 
Constructor Summary
ChannelTable(IDataChannelFactory a_dataChannelFactory, java.security.SecureRandom a_channelIdGenerator)
           
 
Method Summary
 void closeChannelTable()
           
 AbstractDataChannel createDataChannel(AbstractDataChain a_parentDataChain)
           
 AbstractChannel getChannel(int a_channelId)
           
private  int getFreeChannelId()
          Returns an available DataChannel-ID.
 boolean isControlChannelId(int a_channelId)
           
 void registerControlChannel(int a_channelId, AbstractControlChannel a_controlChannel)
           
 void removeChannel(int a_channelId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_CHANNEL_ID_PAY

public static final int CONTROL_CHANNEL_ID_PAY
See Also:
Constant Field Values

CONTROL_CHANNEL_ID_REPLAY

public static final int CONTROL_CHANNEL_ID_REPLAY
See Also:
Constant Field Values

CONTROL_CHANNEL_ID_DUMMY

public static final int CONTROL_CHANNEL_ID_DUMMY
See Also:
Constant Field Values

MAX_OPEN_DATACHANNELS

private static final int MAX_OPEN_DATACHANNELS
See Also:
Constant Field Values

MIN_RESERVED_CHANNEL_ID

private static final int MIN_RESERVED_CHANNEL_ID
The minimum Channel-ID in the reserved area for ControlChannels (those Channel-IDs are not available for DataChannels). Attention: ChannelID 0 is also not available for ControlChannels (it is used mix-internal for filling the pool with dummies, if no real packet is received).

See Also:
Constant Field Values

MAX_RESERVED_CHANNEL_ID

private static final int MAX_RESERVED_CHANNEL_ID
The maximum Channel-ID in the reserved area for ControlChannels (those Channel-IDs are not available for DataChannels).

See Also:
Constant Field Values

m_dataChannelFactory

private IDataChannelFactory m_dataChannelFactory

m_channelTable

private java.util.Hashtable m_channelTable

m_availableDataChannels

private volatile int m_availableDataChannels

m_channelIdGenerator

private java.security.SecureRandom m_channelIdGenerator

m_tableClosed

private volatile boolean m_tableClosed
Constructor Detail

ChannelTable

public ChannelTable(IDataChannelFactory a_dataChannelFactory,
                    java.security.SecureRandom a_channelIdGenerator)
Method Detail

getChannel

public AbstractChannel getChannel(int a_channelId)

removeChannel

public void removeChannel(int a_channelId)

registerControlChannel

public void registerControlChannel(int a_channelId,
                                   AbstractControlChannel a_controlChannel)

isControlChannelId

public boolean isControlChannelId(int a_channelId)

createDataChannel

public AbstractDataChannel createDataChannel(AbstractDataChain a_parentDataChain)
Specified by:
createDataChannel in interface IDataChannelCreator

closeChannelTable

public void closeChannelTable()

getFreeChannelId

private int getFreeChannelId()
Returns an available DataChannel-ID. The returned value is an ID which is not in the reserved area for control-channels and also not already in use by a datachannel. The returned ID can be negative because the mix simply expects a 32 bit value (unsigned). Synchronization with the channel-table has to be done by the caller.

Returns:
An available DataChannel-ID (maybe negative).