Mixes for Privacy and Anonymity in the Internet
|
Data structure that stores all information about the currently open Mix channels. More...
Public Member Functions | |
CAFirstMixChannelList () | |
~CAFirstMixChannelList () | |
fmHashTableEntry * | add (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... | |
fmChannelListEntry * | get (CAMuxSocket *pMuxSocket, HCHANNEL channelIn) |
Returns the information for a given Input-Channel-ID. More... | |
fmHashTableEntry * | popTimeoutEntry () |
fmHashTableEntry * | popTimeoutEntry (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... | |
fmHashTableEntry * | getFirst () |
Gets the first connection of all connections in the list. More... | |
fmHashTableEntry * | getNext () |
Gets the next entry in the connections-list. More... | |
fmHashTableEntry * | get (CAMuxSocket *pMuxSocket) |
Returns the general data stored for a given Socket (user) More... | |
fmChannelListEntry * | getFirstChannelForSocket (CAMuxSocket *pMuxSocket) |
Gets the first channel for a given connection. More... | |
fmChannelListEntry * | getNextChannel (fmChannelListEntry *pEntry) |
Gets the next channel for a given connection. More... | |
fmChannelListEntry * | get (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) |
fmHashTableEntry * | popTimeoutEntry_internal (bool a_bForce) |
UINT32 | countTimeoutEntries () |
fmChannelListEntry * | get_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_fmHashTableEntry * | m_HashTable |
The Hash-Table of all connections. More... | |
LP_fmChannelListEntry * | m_HashTableOutChannels |
The Hash-Table of all out-channels. More... | |
fmHashTableEntry * | m_listHashTableHead |
Pointer to the head of a list of all connections. More... | |
fmHashTableEntry * | m_listHashTableNext |
Next Element in the enumeration of all connections. More... | |
fmHashTableEntry * | m_listTimoutHead |
Pointer to the head of the timout list of all connections. More... | |
fmHashTableEntry * | m_listTimoutFoot |
CAMutex | m_Mutex |
This mutex is used in all functions and makes them thread safe. More... | |
volatile UINT32 ** | m_pDelayBuckets |
CAThread * | m_pThreadDelayBucketsLoop |
CAMutex * | m_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 *) |
Data structure that stores all information about the currently open Mix channels.
See [FirstMixChannelList] for more information.
CAFirstMixChannelList::CAFirstMixChannelList | ( | ) |
References t_fmhashtableentry::cleanupNotifier, DELAY_USERS_BUCKET_GROW, DELAY_USERS_BUCKET_GROW_INTERVALL, DELAY_USERS_TRAFFIC, fml_loopDelayBuckets, m_bDelayBucketsLoopRun, m_HashTable, m_HashTableOutChannels, m_listHashTableHead, m_listHashTableNext, m_listTimoutFoot, m_listTimoutHead, m_pDelayBuckets, m_pMutexDelayChannel, m_pThreadDelayBucketsLoop, m_u32DelayChannelBucketGrow, m_u32DelayChannelBucketGrowIntervall, m_u32DelayChannelUnlimitTraffic, MAX_HASH_KEY, MAX_POLLFD, CAThread::setMainLoop(), and CAThread::start().
Referenced by test().
CAFirstMixChannelList::~CAFirstMixChannelList | ( | ) |
fmHashTableEntry * CAFirstMixChannelList::add | ( | CAMuxSocket * | pMuxSocket, |
const UINT8 | peerIP[4], | ||
CAQueue * | pQueueSend, | ||
UINT8 * | controlChannelKeySent, | ||
UINT8 * | controlChannelKeyRecv | ||
) |
Adds a new TCP/IP connection (a new user) to the channel list.
pMuxSocket | the new connection (from a user) |
peerIP | the IP of the user, so that we can remove it later from the CAIPList |
pQueueSend | the send-queue to use for this connection |
the | fmHashTableEntry of the newly added connection |
NULL | if an error occured |
References BEGIN_STACK, t_fmhashtableentry::bRecoverTimeout, t_fmhashtableentry::cNumberOfChannels, t_fmhashtableentry::delayBucket, t_fmhashtableentry::delayBucketID, FINISH_STACK, CAMuxSocket::getCASocket(), getcurrentTimeMillis(), CAMuxSocket::getHashKey(), CASocket::getPeerPort(), getRandom(), t_fmhashtableentry::id, INIT_STACK, t_fmhashtableentry::kickoutSendRetries, t_fmhashtableentry::list_HashEntries, MAX_HASH_KEY, MAX_KICKOUT_RETRIES, MAX_POLLFD, t_fmhashtableentry::next, t_fmhashtableentry::pAccountingInfo, t_fmhashtableentry::pControlChannelDispatcher, t_fmhashtableentry::pControlMessageQueue, t_fmhashtableentry::peerIP, t_fmhashtableentry::pMuxSocket, t_fmhashtableentry::pQueueSend, t_fmhashtableentry::prev, SAVE_STACK, and t_fmhashtableentry::uAlreadySendPacketSize.
Referenced by CAFirstMix::doUserLogin_internal(), and test().
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.
pMuxSocket | the connection from the user |
channelIn | the channel, which should be added |
pCipher | the symmetric cipher associated with this channel |
channelOut | a pointer to the place, there the new generated out-channel id is stored |
E_SUCCESS | if successful |
E_UNKNOWN | in 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().
|
private |
void CAFirstMixChannelList::decDelayBuckets | ( | UINT32 | delayBucketID | ) |
References CAMutex::lock(), m_pDelayBuckets, m_pMutexDelayChannel, MAX_POLLFD, and CAMutex::unlock().
Referenced by CAFirstMixA::sendToUsers().
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().
fmHashTableEntry * CAFirstMixChannelList::get | ( | CAMuxSocket * | pMuxSocket | ) |
Returns the general data stored for a given Socket (user)
pMuxSocket | the connection from the user |
NULL | if not found |
References CAMuxSocket::getHashKey(), CAMutex::lock(), m_HashTable, m_Mutex, MAX_HASH_KEY, and CAMutex::unlock().
fmChannelListEntry * CAFirstMixChannelList::get | ( | CAMuxSocket * | pMuxSocket, |
HCHANNEL | channelIn | ||
) |
Returns the information for a given Input-Channel-ID.
pMuxSocket | the connection from the user |
channelIn | the channel id |
NULL | if 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().
fmChannelListEntry* CAFirstMixChannelList::get | ( | HCHANNEL | channelOut | ) |
Gets the in-channel and all associated information for the given out-channel.
channelOut | the out-channel id for which the information is requested |
NULL | if not found in list |
References get_intern_without_lock(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().
|
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)
channelOut | the out-channel id for which the information is requested |
NULL | if not found in list |
References t_firstmixchannellist::channelOut, t_firstmixchannellist::list_OutChannelHashTable, m_HashTableOutChannels, and t_firstmixchannellist::next.
Referenced by addChannel(), and get().
fmHashTableEntry * CAFirstMixChannelList::getFirst | ( | ) |
Gets the first connection of all connections in the list.
NULL | if 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().
fmChannelListEntry * CAFirstMixChannelList::getFirstChannelForSocket | ( | CAMuxSocket * | pMuxSocket | ) |
Gets the first channel for a given connection.
pMuxSocket | the connection from the user |
NULL | if 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().
fmHashTableEntry * CAFirstMixChannelList::getNext | ( | ) |
Gets the next entry in the connections-list.
NULL | in 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().
fmChannelListEntry * CAFirstMixChannelList::getNextChannel | ( | fmChannelListEntry * | pEntry | ) |
Gets the next channel for a given connection.
pEntry | a entry returned by a previos call to getFirstChannelForSocket() or getNextChannel() |
NULL | if 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::hasDelayBuckets | ( | UINT32 | delayBucketID | ) |
References CAMutex::lock(), m_pDelayBuckets, m_pMutexDelayChannel, MAX_POLLFD, and CAMutex::unlock().
Referenced by CAFirstMixA::sendToUsers().
bool CAFirstMixChannelList::isKickoutForced | ( | fmHashTableEntry * | pHashTableEntry | ) |
References isKickoutForced_internal(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().
Referenced by CAFirstMixA::checkUserConnections().
|
private |
References t_fmhashtableentry::bRecoverTimeout.
Referenced by isKickoutForced().
bool CAFirstMixChannelList::isTimedOut | ( | fmHashTableEntry * | pHashTableEntry | ) |
References isTimedOut_internal(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().
Referenced by CAFirstMixA::checkUserConnections().
|
private |
References t_fmhashtableentry::list_TimeoutHashEntries, and t_fmhashtableentry::timoutSecs.
Referenced by isTimedOut(), and popTimeoutEntry_internal().
fmHashTableEntry * CAFirstMixChannelList::popTimeoutEntry | ( | ) |
Referenced by CAFirstMixA::checkUserConnections(), and CAFirstMixA::shutDown().
fmHashTableEntry * CAFirstMixChannelList::popTimeoutEntry | ( | bool | a_bForce | ) |
if | set to true, forces to return the next timeout enty or NULL if none are left in the queue |
|
private |
References E_SUCCESS, isTimedOut_internal(), m_listTimoutHead, CAMsg::printMsg(), and removeFromTimeoutList().
SINT32 CAFirstMixChannelList::pushTimeoutEntry | ( | fmHashTableEntry * | pHashTableEntry, |
bool | kickoutForced = !KICKOUT_FORCED |
||
) |
adds the entry to the timeout queue with mutex
References CAMutex::lock(), m_Mutex, pushTimeoutEntry_internal(), and CAMutex::unlock().
Referenced by CAFirstMixA::accountTrafficDownstream(), CAFirstMixA::accountTrafficUpstream(), CAFirstMixA::checkUserConnections(), CAFirstMix::doUserLogin_internal(), and CAFirstMixA::loop().
|
private |
adds the entry to the timeout queue
renews the timestamp for the timeout list does not affect forced kickouts.
References BEGIN_STACK, E_SUCCESS, E_UNKNOWN, EXPIRATION_TIME_SECS, FINISH_STACK, INIT_STACK, t_fmhashtableentry::list_TimeoutHashEntries, m_listTimoutFoot, m_listTimoutHead, t_fmhashtableentry::next, t_fmhashtableentry::prev, removeFromTimeoutList(), setKickoutForced_internal(), and t_fmhashtableentry::timoutSecs.
Referenced by pushTimeoutEntry().
SINT32 CAFirstMixChannelList::remove | ( | CAMuxSocket * | pMuxSocket | ) |
Removes all channels, which belongs to the given connection and the connection itself from the list.
pMuxSocket | the connection from the user |
E_SUCCESS | if successful |
E_UNKNOWN | in case of an error |
References t_firstmixchannellist::channelOut, t_fmhashtableentry::cleanupNotifier, t_fmhashtableentry::delayBucketID, CAControlChannelDispatcher::deleteAllControlChannels(), E_SUCCESS, E_UNKNOWN, CAMuxSocket::getHashKey(), t_fmhashtableentry::list_HashEntries, t_firstmixchannellist::list_InChannelPerSocket, t_firstmixchannellist::list_OutChannelHashTable, CAMutex::lock(), m_HashTable, m_HashTableOutChannels, m_listHashTableHead, m_listHashTableNext, m_Mutex, m_pDelayBuckets, m_pMutexDelayChannel, MAX_HASH_KEY, t_fmhashtableentry::next, t_firstmixchannellist::next, t_fmhashtableentry::pChannelList, t_fmhashtableentry::pControlChannelDispatcher, t_fmhashtableentry::pControlMessageQueue, t_fmhashtableentry::pMuxSocket, t_fmhashtableentry::prev, t_firstmixchannellist::prev, removeFromTimeoutList(), CAConditionVariable::signal(), and CAMutex::unlock().
Referenced by CAFirstMix::clean(), CAFirstMixA::closeConnection(), CAFirstMix::doUserLogin_internal(), CAFirstMixB::loop(), and test().
SINT32 CAFirstMixChannelList::removeChannel | ( | CAMuxSocket * | pMuxSocket, |
HCHANNEL | channelIn | ||
) |
Removes a single channel from the list.
pMuxSocket | the connection from the user |
channelIn | the channel, which should be removed |
E_SUCCESS | if successful |
E_UNKNOWN | in case of an error |
References t_firstmixchannellist::channelIn, t_firstmixchannellist::channelOut, t_fmhashtableentry::cNumberOfChannels, E_SUCCESS, E_UNKNOWN, CAMuxSocket::getHashKey(), t_firstmixchannellist::list_InChannelPerSocket, t_firstmixchannellist::list_OutChannelHashTable, CAMutex::lock(), m_HashTable, m_HashTableOutChannels, m_Mutex, MAX_HASH_KEY, t_firstmixchannellist::next, t_fmhashtableentry::pChannelList, t_fmhashtableentry::pMuxSocket, t_firstmixchannellist::prev, and CAMutex::unlock().
Referenced by CAFirstMixA::finishPacket(), CAFirstMixA::loop(), CAFirstMixB::loop(), and test().
|
private |
void CAFirstMixChannelList::setDelayParameters | ( | UINT32 | unlimitTraffic, |
UINT32 | bucketGrow, | ||
UINT32 | intervall | ||
) |
References CAMutex::lock(), m_pDelayBuckets, m_pMutexDelayChannel, m_u32DelayChannelBucketGrow, m_u32DelayChannelBucketGrowIntervall, m_u32DelayChannelUnlimitTraffic, MAX_POLLFD, CAMsg::printMsg(), and CAMutex::unlock().
Referenced by CAFirstMixA::loop(), CAFirstMixB::loop(), and CAFirstMix::reconfigure().
void CAFirstMixChannelList::setKickoutForced | ( | fmHashTableEntry * | pHashTableEntry, |
bool | kickoutForced | ||
) |
References CAMutex::lock(), m_Mutex, setKickoutForced_internal(), and CAMutex::unlock().
Referenced by CAFirstMixA::accountTrafficDownstream(), and CAFirstMixA::accountTrafficUpstream().
|
private |
References t_fmhashtableentry::bRecoverTimeout, and CAMsg::printMsg().
Referenced by forceKickout(), pushTimeoutEntry_internal(), and setKickoutForced().
|
static |
References add(), addChannel(), CAFirstMixChannelList(), CASocket::create(), E_SUCCESS, CAMuxSocket::getCASocket(), OFB, remove(), and removeChannel().
|
friend |
Referenced by CAFirstMixChannelList().
|
staticprivate |
Referenced by pushTimeoutEntry_internal().
|
private |
Referenced by CAFirstMixChannelList(), and ~CAFirstMixChannelList().
|
private |
The Hash-Table of all connections.
Referenced by addChannel(), CAFirstMixChannelList(), get(), getFirstChannelForSocket(), remove(), removeChannel(), and ~CAFirstMixChannelList().
|
private |
The Hash-Table of all out-channels.
Referenced by addChannel(), CAFirstMixChannelList(), get_intern_without_lock(), remove(), removeChannel(), and ~CAFirstMixChannelList().
|
private |
Pointer to the head of a list of all connections.
Referenced by CAFirstMixChannelList(), getFirst(), and remove().
|
private |
Next Element in the enumeration of all connections.
Referenced by CAFirstMixChannelList(), getFirst(), getNext(), and remove().
|
private |
Referenced by CAFirstMixChannelList(), pushTimeoutEntry_internal(), and removeFromTimeoutList().
|
private |
Pointer to the head of the timout list of all connections.
Referenced by CAFirstMixChannelList(), countTimeoutEntries(), popTimeoutEntry_internal(), pushTimeoutEntry_internal(), and removeFromTimeoutList().
|
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().
|
private |
Referenced by CAFirstMixChannelList(), decDelayBuckets(), hasDelayBuckets(), remove(), setDelayParameters(), and ~CAFirstMixChannelList().
|
private |
Referenced by CAFirstMixChannelList(), decDelayBuckets(), hasDelayBuckets(), remove(), setDelayParameters(), and ~CAFirstMixChannelList().
|
private |
Referenced by CAFirstMixChannelList(), and ~CAFirstMixChannelList().
|
private |
Referenced by CAFirstMixChannelList(), and setDelayParameters().
|
private |
Referenced by CAFirstMixChannelList(), and setDelayParameters().
|
private |
Referenced by CAFirstMixChannelList(), and setDelayParameters().