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

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

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. More...
 
SINT32 addChannel (CAMuxSocket *pMuxSocket, HCHANNEL channelIn, CASymChannelCipher *pCipher, HCHANNEL *channelOut)
 Adds a new channel for a given connection to the channel list. More...
 
fmChannelListEntryget (CAMuxSocket *pMuxSocket, HCHANNEL channelIn)
 Returns the information for a given Input-Channel-ID. More...
 
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. More...
 
SINT32 pushTimeoutEntry (fmHashTableEntry *pHashTableEntry, bool kickoutForced=!KICKOUT_FORCED)
 adds the entry to the timeout queue with mutex More...
 
SINT32 remove (CAMuxSocket *pMuxSocket)
 Removes all channels, which belongs to the given connection and the connection itself from the list. More...
 
SINT32 removeChannel (CAMuxSocket *pMuxSocket, HCHANNEL channelIn)
 Removes a single channel from the list. More...
 
fmHashTableEntrygetFirst ()
 Gets the first connection of all connections in the list. More...
 
fmHashTableEntrygetNext ()
 Gets the next entry in the connections-list. More...
 
fmHashTableEntryget (CAMuxSocket *pMuxSocket)
 Returns the general data stored for a given Socket (user) More...
 
fmChannelListEntrygetFirstChannelForSocket (CAMuxSocket *pMuxSocket)
 Gets the first channel for a given connection. More...
 
fmChannelListEntrygetNextChannel (fmChannelListEntry *pEntry)
 Gets the next channel for a given connection. More...
 
fmChannelListEntryget (HCHANNEL channelOut)
 Gets the in-channel and all associated information for the given out-channel. More...
 
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 More...
 
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. More...
 
bool isTimedOut_internal (fmHashTableEntry *pHashTableEntry)
 

Private Attributes

LP_fmHashTableEntrym_HashTable
 The Hash-Table of all connections. More...
 
LP_fmChannelListEntrym_HashTableOutChannels
 The Hash-Table of all out-channels. More...
 
fmHashTableEntrym_listHashTableHead
 Pointer to the head of a list of all connections. More...
 
fmHashTableEntrym_listHashTableNext
 Next Element in the enumeration of all connections. More...
 
fmHashTableEntrym_listTimoutHead
 Pointer to the head of the timout list of all connections. More...
 
fmHashTableEntrym_listTimoutFoot
 
CAMutex m_Mutex
 This mutex is used in all functions and makes them thread safe. More...
 
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

◆ CAFirstMixChannelList()

CAFirstMixChannelList::CAFirstMixChannelList ( )

◆ ~CAFirstMixChannelList()

CAFirstMixChannelList::~CAFirstMixChannelList ( )

Member Function Documentation

◆ add()

fmHashTableEntry * CAFirstMixChannelList::add ( CAMuxSocket pMuxSocket,
const UINT8  peerIP[4],
CAQueue pQueueSend,
UINT8 controlChannelKeySent,
UINT8 controlChannelKeyRecv 
)

◆ addChannel()

SINT32 CAFirstMixChannelList::addChannel ( CAMuxSocket pMuxSocket,
HCHANNEL  channelIn,
CASymChannelCipher 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, ERR_MSG_TO_MANY_CHANNELS, 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 CAFirstMixA::loop(), CAFirstMixB::loop(), and test().

◆ countTimeoutEntries()

UINT32 CAFirstMixChannelList::countTimeoutEntries ( )
private

◆ decDelayBuckets()

void CAFirstMixChannelList::decDelayBuckets ( UINT32  delayBucketID)

◆ forceKickout()

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().

◆ get() [1/3]

fmHashTableEntry * CAFirstMixChannelList::get ( CAMuxSocket pMuxSocket)

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().

◆ get() [2/3]

fmChannelListEntry * CAFirstMixChannelList::get ( CAMuxSocket pMuxSocket,
HCHANNEL  channelIn 
)

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(), CAFirstMixA::loop(), and CAFirstMixB::loop().

◆ get() [3/3]

fmChannelListEntry* CAFirstMixChannelList::get ( HCHANNEL  channelOut)

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().

◆ get_intern_without_lock()

fmChannelListEntry* CAFirstMixChannelList::get_intern_without_lock ( HCHANNEL  channelOut)
private

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().

◆ getFirst()

fmHashTableEntry * CAFirstMixChannelList::getFirst ( )

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(), CAFirstMixA::loop(), CAFirstMixB::loop(), and CAFirstMixA::sendToUsers().

◆ getFirstChannelForSocket()

fmChannelListEntry * CAFirstMixChannelList::getFirstChannelForSocket ( CAMuxSocket pMuxSocket)

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().

◆ getNext()

fmHashTableEntry * CAFirstMixChannelList::getNext ( )

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(), CAFirstMixA::loop(), CAFirstMixB::loop(), and CAFirstMixA::sendToUsers().

◆ getNextChannel()

fmChannelListEntry * CAFirstMixChannelList::getNextChannel ( fmChannelListEntry pEntry)

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().

◆ hasDelayBuckets()

bool CAFirstMixChannelList::hasDelayBuckets ( UINT32  delayBucketID)

◆ isKickoutForced()

bool CAFirstMixChannelList::isKickoutForced ( fmHashTableEntry pHashTableEntry)

◆ isKickoutForced_internal()

bool CAFirstMixChannelList::isKickoutForced_internal ( fmHashTableEntry pHashTableEntry)
private

◆ isTimedOut()

bool CAFirstMixChannelList::isTimedOut ( fmHashTableEntry pHashTableEntry)

◆ isTimedOut_internal()

bool CAFirstMixChannelList::isTimedOut_internal ( fmHashTableEntry pHashTableEntry)
private

◆ popTimeoutEntry() [1/2]

fmHashTableEntry * CAFirstMixChannelList::popTimeoutEntry ( )
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().

◆ popTimeoutEntry() [2/2]

fmHashTableEntry * CAFirstMixChannelList::popTimeoutEntry ( bool  a_bForce)
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

◆ popTimeoutEntry_internal()

fmHashTableEntry * CAFirstMixChannelList::popTimeoutEntry_internal ( bool  a_bForce)
private

◆ pushTimeoutEntry()

SINT32 CAFirstMixChannelList::pushTimeoutEntry ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced = !KICKOUT_FORCED 
)

◆ pushTimeoutEntry_internal()

SINT32 CAFirstMixChannelList::pushTimeoutEntry_internal ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced = !KICKOUT_FORCED 
)
private

◆ remove()

SINT32 CAFirstMixChannelList::remove ( CAMuxSocket pMuxSocket)

◆ removeChannel()

SINT32 CAFirstMixChannelList::removeChannel ( CAMuxSocket pMuxSocket,
HCHANNEL  channelIn 
)

◆ removeFromTimeoutList()

SINT32 CAFirstMixChannelList::removeFromTimeoutList ( fmHashTableEntry pHashTableEntry)
private

◆ setDelayParameters()

void CAFirstMixChannelList::setDelayParameters ( UINT32  unlimitTraffic,
UINT32  bucketGrow,
UINT32  intervall 
)

◆ setKickoutForced()

void CAFirstMixChannelList::setKickoutForced ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced 
)

◆ setKickoutForced_internal()

void CAFirstMixChannelList::setKickoutForced_internal ( fmHashTableEntry pHashTableEntry,
bool  kickoutForced 
)
private

◆ test()

SINT32 CAFirstMixChannelList::test ( )
static

Friends And Related Function Documentation

◆ fml_loopDelayBuckets

THREAD_RETURN fml_loopDelayBuckets ( void *  )
friend

Referenced by CAFirstMixChannelList().

Member Data Documentation

◆ EXPIRATION_TIME_SECS

const SINT32 CAFirstMixChannelList::EXPIRATION_TIME_SECS = 300
staticprivate

◆ m_bDelayBucketsLoopRun

bool CAFirstMixChannelList::m_bDelayBucketsLoopRun
private

◆ m_HashTable

LP_fmHashTableEntry* CAFirstMixChannelList::m_HashTable
private

◆ m_HashTableOutChannels

LP_fmChannelListEntry* CAFirstMixChannelList::m_HashTableOutChannels
private

◆ m_listHashTableHead

fmHashTableEntry* CAFirstMixChannelList::m_listHashTableHead
private

Pointer to the head of a list of all connections.

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

◆ m_listHashTableNext

fmHashTableEntry* CAFirstMixChannelList::m_listHashTableNext
private

Next Element in the enumeration of all connections.

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

◆ m_listTimoutFoot

fmHashTableEntry* CAFirstMixChannelList::m_listTimoutFoot
private

◆ m_listTimoutHead

fmHashTableEntry* CAFirstMixChannelList::m_listTimoutHead
private

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

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

◆ m_Mutex

CAMutex CAFirstMixChannelList::m_Mutex
private

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

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

◆ m_pDelayBuckets

volatile UINT32** CAFirstMixChannelList::m_pDelayBuckets
private

◆ m_pMutexDelayChannel

CAMutex* CAFirstMixChannelList::m_pMutexDelayChannel
private

◆ m_pThreadDelayBucketsLoop

CAThread* CAFirstMixChannelList::m_pThreadDelayBucketsLoop
private

◆ m_u32DelayChannelBucketGrow

volatile UINT32 CAFirstMixChannelList::m_u32DelayChannelBucketGrow
private

◆ m_u32DelayChannelBucketGrowIntervall

volatile UINT32 CAFirstMixChannelList::m_u32DelayChannelBucketGrowIntervall
private

◆ m_u32DelayChannelUnlimitTraffic

volatile UINT32 CAFirstMixChannelList::m_u32DelayChannelUnlimitTraffic
private