Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
CAFirstMixChannelList Class Reference

Data structure that stores all information about the currently open Mix channels. More...

List of all members.

Public Member Functions

 CAFirstMixChannelList ()
 ~CAFirstMixChannelList ()
fmHashTableEntryadd (CAMuxSocket *pMuxSocket, const UINT8 peerIP[4], CAQueue *pQueueSend, UINT8 *controlChannelKeyRecv, UINT8 *controlChannelKeySent)
 Adds a new TCP/IP connection (a new user) to the channel list.
SINT32 addChannel (CAMuxSocket *pMuxSocket, HCHANNEL channelIn, CASymCipher *pCipher, HCHANNEL *channelOut)
 Adds a new channel for a given connection to the channel list.
fmChannelListEntryget (CAMuxSocket *pMuxSocket, HCHANNEL channelIn)
 Returns the information for a given Input-Channel-ID.
fmHashTableEntrypopTimeoutEntry ()
fmHashTableEntrypopTimeoutEntry (bool a_bForce)
bool isTimedOut (fmHashTableEntry *pHashTableEntry)
bool isKickoutForced (fmHashTableEntry *pHashTableEntry)
void setKickoutForced (fmHashTableEntry *pHashTableEntry, bool kickoutForced)
bool forceKickout (fmHashTableEntry *pHashTableEntry, const XERCES_CPP_NAMESPACE::DOMDocument *pErrDoc)
 forces a kickout for this entry if the entry is still valid and sends an errorMessage via the control channel belonging to the entry.
SINT32 pushTimeoutEntry (fmHashTableEntry *pHashTableEntry, bool kickoutForced=!KICKOUT_FORCED)
 adds the entry to the timeout queue with mutex
SINT32 remove (CAMuxSocket *pMuxSocket)
 Removes all channels, which belongs to the given connection and the connection itself from the list.
SINT32 removeChannel (CAMuxSocket *pMuxSocket, HCHANNEL channelIn)
 Removes a single channel from the list.
fmHashTableEntrygetFirst ()
 Gets the first connection of all connections in the list.
fmHashTableEntrygetNext ()
 Gets the next entry in the connections-list.
fmHashTableEntryget (CAMuxSocket *pMuxSocket)
 Returns the general data stored for a given Socket (user)
fmChannelListEntrygetFirstChannelForSocket (CAMuxSocket *pMuxSocket)
 Gets the first channel for a given connection.
fmChannelListEntrygetNextChannel (fmChannelListEntry *pEntry)
 Gets the next channel for a given connection.
fmChannelListEntryget (HCHANNEL channelOut)
 Gets the in-channel and all associated information for the given out-channel.
void setDelayParameters (UINT32 unlimitTraffic, UINT32 bucketGrow, UINT32 intervall)
void decDelayBuckets (UINT32 delayBucketID)
bool hasDelayBuckets (UINT32 delayBucketID)

Static Public Member Functions

static SINT32 test ()

Private Member Functions

SINT32 removeFromTimeoutList (fmHashTableEntry *pHashTableEntry)
SINT32 pushTimeoutEntry_internal (fmHashTableEntry *pHashTableEntry, bool kickoutForced=!KICKOUT_FORCED)
 adds the entry to the timeout queue
bool isKickoutForced_internal (fmHashTableEntry *pHashTableEntry)
void setKickoutForced_internal (fmHashTableEntry *pHashTableEntry, bool kickoutForced)
fmHashTableEntrypopTimeoutEntry_internal (bool a_bForce)
UINT32 countTimeoutEntries ()
fmChannelListEntryget_intern_without_lock (HCHANNEL channelOut)
 Gets the in-channel and all associated information for the given out-channel.
bool isTimedOut_internal (fmHashTableEntry *pHashTableEntry)

Private Attributes

LP_fmHashTableEntrym_HashTable
 The Hash-Table of all connections.
LP_fmChannelListEntrym_HashTableOutChannels
 The Hash-Table of all out-channels.
fmHashTableEntrym_listHashTableHead
 Pointer to the head of a list of all connections.
fmHashTableEntrym_listHashTableNext
 Next Element in the enumeration of all connections.
fmHashTableEntrym_listTimoutHead
 Pointer to the head of the timout list of all connections.
fmHashTableEntrym_listTimoutFoot
CAMutex m_Mutex
 This mutex is used in all functions and makes them thread safe.
volatile UINT32 ** m_pDelayBuckets
CAThreadm_pThreadDelayBucketsLoop
CAMutexm_pMutexDelayChannel
bool m_bDelayBucketsLoopRun
volatile UINT32 m_u32DelayChannelUnlimitTraffic
volatile UINT32 m_u32DelayChannelBucketGrow
volatile UINT32 m_u32DelayChannelBucketGrowIntervall

Static Private Attributes

static const SINT32 EXPIRATION_TIME_SECS = 300

Friends

THREAD_RETURN fml_loopDelayBuckets (void *)

Detailed Description

Data structure that stores all information about the currently open Mix channels.

See [FirstMixChannelList] for more information.


Constructor & Destructor Documentation


Member Function Documentation

fmHashTableEntry * CAFirstMixChannelList::add ( CAMuxSocket pMuxSocket,
const UINT8  peerIP[4],
CAQueue pQueueSend,
UINT8 controlChannelKeySent,
UINT8 controlChannelKeyRecv 
)
SINT32 CAFirstMixChannelList::addChannel ( CAMuxSocket pMuxSocket,
HCHANNEL  channelIn,
CASymCipher pCipher,
HCHANNEL channelOut 
)

Adds a new channel for a given connection to the channel list.

Also a new out-channel id is generated and returned.

Parameters:
pMuxSocketthe connection from the user
channelInthe channel, which should be added
pCipherthe symmetric cipher associated with this channel
channelOuta pointer to the place, there the new generated out-channel id is stored
Return values:
E_SUCCESSif successful
E_UNKNOWNin case of an error

References t_firstmixchannellist::bIsSuspended, t_firstmixchannellist::channelIn, t_firstmixchannellist::channelOut, t_fmhashtableentry::cNumberOfChannels, E_SUCCESS, E_UNKNOWN, get_intern_without_lock(), CAMuxSocket::getHashKey(), getRandom(), t_firstmixchannellist::list_InChannelPerSocket, t_firstmixchannellist::list_OutChannelHashTable, CAMutex::lock(), m_HashTable, m_HashTableOutChannels, m_Mutex, MAX_HASH_KEY, MAX_NUMBER_OF_CHANNELS, t_firstmixchannellist::next, t_fmhashtableentry::pChannelList, t_firstmixchannellist::pCipher, t_firstmixchannellist::pHead, t_fmhashtableentry::pMuxSocket, t_firstmixchannellist::prev, CAMsg::printMsg(), and CAMutex::unlock().

Referenced by CAFirstMixB::loop(), CAFirstMixA::loop(), and test().

bool CAFirstMixChannelList::forceKickout ( fmHashTableEntry pHashTableEntry,
const XERCES_CPP_NAMESPACE::DOMDocument *  pErrDoc 
)

forces a kickout for this entry if the entry is still valid and sends an errorMessage via the control channel belonging to the entry.

returns true if pHashTableEntry is still valid, false otherwise

References KICKOUT_FORCED, CAMutex::lock(), m_Mutex, t_fmhashtableentry::pAccountingInfo, t_accountinginfo::pControlChannel, t_fmhashtableentry::pMuxSocket, CAAbstractControlChannel::sendXMLMessage(), setKickoutForced_internal(), and CAMutex::unlock().

Referenced by CAFirstMix::forceKickout().

Returns the information for a given Input-Channel-ID.

Parameters:
pMuxSocketthe connection from the user
channelInthe channel id
Returns:
all channel associated information (output-channel id, cipher etc.)
Return values:
NULLif not found

References t_firstmixchannellist::channelIn, CAMuxSocket::getHashKey(), t_firstmixchannellist::list_InChannelPerSocket, CAMutex::lock(), m_HashTable, m_Mutex, MAX_HASH_KEY, t_firstmixchannellist::next, t_fmhashtableentry::pChannelList, and CAMutex::unlock().

Referenced by CAFirstMix::doUserLogin_internal(), CAFirstMixA::finishPacket(), CAFirstMixB::loop(), and CAFirstMixA::loop().

Returns the general data stored for a given Socket (user)

Parameters:
pMuxSocketthe connection from the user
Returns:
general data for the given user
Return values:
NULLif not found

References CAMuxSocket::getHashKey(), CAMutex::lock(), m_HashTable, m_Mutex, MAX_HASH_KEY, and CAMutex::unlock().

Gets the in-channel and all associated information for the given out-channel.

Parameters:
channelOutthe out-channel id for which the information is requested
Returns:
the in-channel and all associated information
Return values:
NULLif not found in list

References get_intern_without_lock(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().

Gets the in-channel and all associated information for the given out-channel.

This method is NOT thread safe (and so only for internal use)

See also:
get()
Parameters:
channelOutthe out-channel id for which the information is requested
Returns:
the in-channel and all associated information
Return values:
NULLif not found in list

References t_firstmixchannellist::channelOut, t_firstmixchannellist::list_OutChannelHashTable, m_HashTableOutChannels, and t_firstmixchannellist::next.

Referenced by addChannel(), and get().

Gets the first connection of all connections in the list.

See also:
getNext()
Returns:
first connection in the list
Return values:
NULLif no connection is in the list

References t_fmhashtableentry::list_HashEntries, CAMutex::lock(), m_listHashTableHead, m_listHashTableNext, m_Mutex, t_fmhashtableentry::next, and CAMutex::unlock().

Referenced by CAFirstMix::clean(), CAFirstMixB::loop(), CAFirstMixA::loop(), and CAFirstMixA::sendToUsers().

Gets the first channel for a given connection.

See also:
getNextChannel()
Parameters:
pMuxSocketthe connection from the user
Returns:
the channel and the associated information
Return values:
NULLif no channel for this connection exists at the moment

References CAMuxSocket::getHashKey(), m_HashTable, MAX_HASH_KEY, and t_fmhashtableentry::pChannelList.

Referenced by CAFirstMix::clean(), CAFirstMixA::closeConnection(), CAFirstMixB::loop(), and CAFirstMixA::notifyAllUserChannels().

Gets the next entry in the connections-list.

See also:
getFirst()
Returns:
next entry in the connection list
Return values:
NULLin case of an error

References t_fmhashtableentry::list_HashEntries, CAMutex::lock(), m_listHashTableNext, m_Mutex, t_fmhashtableentry::next, and CAMutex::unlock().

Referenced by CAFirstMix::clean(), CAFirstMixB::loop(), CAFirstMixA::loop(), and CAFirstMixA::sendToUsers().

Gets the next channel for a given connection.

See also:
getFirstChannelForSocket()
Parameters:
pEntrya entry returned by a previos call to getFirstChannelForSocket() or getNextChannel()
Returns:
the next channel and all associated information
Return values:
NULLif there are no more channels for this connection

References t_firstmixchannellist::list_InChannelPerSocket, and t_firstmixchannellist::next.

Referenced by CAFirstMix::clean(), CAFirstMixA::closeConnection(), CAFirstMixB::loop(), and CAFirstMixA::notifyAllUserChannels().

bool CAFirstMixChannelList::isTimedOut_internal ( fmHashTableEntry pHashTableEntry) [private]
Returns:
pops the next expired entry from the queue or returns NULL if there are no exired entries

Referenced by CAFirstMixA::checkUserConnections(), and CAFirstMixA::shutDown().

Parameters:
ifset to true, forces to return the next timeout enty or NULL if none are left in the queue
Returns:
if set to true, forces to return the next timeout enty or NULL if none are left in the queue

References CAMutex::lock(), m_Mutex, popTimeoutEntry_internal(), and CAMutex::unlock().

SINT32 CAFirstMixChannelList::pushTimeoutEntry ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced = !KICKOUT_FORCED 
)
SINT32 CAFirstMixChannelList::pushTimeoutEntry_internal ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced = !KICKOUT_FORCED 
) [private]
void CAFirstMixChannelList::setDelayParameters ( UINT32  unlimitTraffic,
UINT32  bucketGrow,
UINT32  intervall 
)
void CAFirstMixChannelList::setKickoutForced ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced 
)
void CAFirstMixChannelList::setKickoutForced_internal ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced 
) [private]

Friends And Related Function Documentation

THREAD_RETURN fml_loopDelayBuckets ( void *  ) [friend]

Referenced by CAFirstMixChannelList().


Member Data Documentation

const SINT32 CAFirstMixChannelList::EXPIRATION_TIME_SECS = 300 [static, private]

Pointer to the head of a list of all connections.

Referenced by CAFirstMixChannelList(), getFirst(), and remove().

Next Element in the enumeration of all connections.

Referenced by CAFirstMixChannelList(), getFirst(), getNext(), and remove().

Pointer to the head of the timout list of all connections.

Referenced by CAFirstMixChannelList(), countTimeoutEntries(), popTimeoutEntry_internal(), pushTimeoutEntry_internal(), and removeFromTimeoutList().

This mutex is used in all functions and makes them thread safe.

Referenced by addChannel(), forceKickout(), get(), getFirst(), getNext(), isKickoutForced(), isTimedOut(), popTimeoutEntry(), pushTimeoutEntry(), remove(), removeChannel(), and setKickoutForced().