|
Mixe for Privacy and Anonymity in the Internet
|
#include <CALastMixBChannelList.hpp>
Public Member Functions | |
| CALastMixBChannelList () | |
| ~CALastMixBChannelList () | |
| t_lastMixBChannelListEntry * | add (HCHANNEL a_channelId, CASymCipher *a_channelCipher, CAChain *a_associatedChain) |
| t_lastMixBChannelListEntry * | get (HCHANNEL a_channelId) |
| void | removeFromTable (t_lastMixBChannelListEntry *a_channelEntry) |
Private Member Functions | |
| t_lastMixBChannelListEntry * | getEntryInternal (HCHANNEL a_channelId) |
Private Attributes | |
| UINT32 | m_channelTableSize |
| t_lastMixBChannelListEntry ** | m_pChannelTable |
| CAMutex * | m_pMutex |
Definition at line 60 of file CALastMixBChannelList.hpp.
Definition at line 36 of file CALastMixBChannelList.cpp.
References m_channelTableSize, m_pChannelTable, and m_pMutex.
{
m_pChannelTable=new (t_lastMixBChannelListEntry*[0x10000]);
for (UINT32 i = 0; i < 0x10000; i++) {
m_pChannelTable[i] = NULL;
}
m_channelTableSize = 0;
m_pMutex = new CAMutex();
}
Definition at line 45 of file CALastMixBChannelList.cpp.
References m_pChannelTable, and m_pMutex.
{
delete m_pMutex;
m_pMutex = NULL;
delete []m_pChannelTable;
m_pChannelTable = NULL;
}
| t_lastMixBChannelListEntry * CALastMixBChannelList::add | ( | HCHANNEL | a_channelId, |
| CASymCipher * | a_channelCipher, | ||
| CAChain * | a_associatedChain | ||
| ) |
Definition at line 52 of file CALastMixBChannelList.cpp.
References t_lastMixBChannelListEntry::associatedChain, t_lastMixBChannelListEntry::associatedChannelList, t_lastMixBChannelListEntry::channelCipher, t_lastMixBChannelListEntry::channelId, t_lastMixBChannelListEntry::firstResponseDeadline, getEntryInternal(), CAMutex::lock(), m_channelTableSize, m_pChannelTable, m_pMutex, t_lastMixBChannelListEntry::rightEntry, t_lastMixBChannelListEntry::rightEntryPointerOfLeftEntry, and CAMutex::unlock().
Referenced by CALastMixB::loop().
{
m_pMutex->lock();
/* check whether we have not already an entry with the same ID */
if (getEntryInternal(a_channelId) != NULL) {
m_pMutex->unlock();
return NULL;
}
t_lastMixBChannelListEntry* newEntry = new t_lastMixBChannelListEntry;
newEntry->channelId = a_channelId;
newEntry->channelCipher = a_channelCipher;
newEntry->associatedChain = a_associatedChain;
newEntry->associatedChannelList = this;
newEntry->firstResponseDeadline = NULL;
/* take the lower 16 bits of the ID as key for the hashtable */
UINT16 hashKey = (UINT16)(a_channelId & 0x0000FFFF);
/* now add the entry at the begin of the hashtable-line */
newEntry->rightEntry = m_pChannelTable[hashKey];
newEntry->rightEntryPointerOfLeftEntry = &(m_pChannelTable[hashKey]);
m_pChannelTable[hashKey] = newEntry;
if (newEntry->rightEntry != NULL) {
newEntry->rightEntry->rightEntryPointerOfLeftEntry = &(newEntry->rightEntry);
}
m_channelTableSize++;
m_pMutex->unlock();
return newEntry;
}
| t_lastMixBChannelListEntry * CALastMixBChannelList::get | ( | HCHANNEL | a_channelId | ) |
Definition at line 94 of file CALastMixBChannelList.cpp.
References getEntryInternal(), CAMutex::lock(), m_pMutex, and CAMutex::unlock().
Referenced by CALastMixB::loop().
{
t_lastMixBChannelListEntry* returnedEntry = NULL;
m_pMutex->lock();
returnedEntry = getEntryInternal(a_channelId);
m_pMutex->unlock();
return returnedEntry;
}
| t_lastMixBChannelListEntry * CALastMixBChannelList::getEntryInternal | ( | HCHANNEL | a_channelId | ) | [private] |
Definition at line 103 of file CALastMixBChannelList.cpp.
References t_lastMixBChannelListEntry::channelId, m_pChannelTable, and t_lastMixBChannelListEntry::rightEntry.
Referenced by add(), and get().
{
/* mutex must be already locked */
/* take the lower 16 bits of the ID as key for the hashtable */
UINT16 hashKey = (UINT16)(a_channelId & 0x0000FFFF);
bool entryFound = false;
t_lastMixBChannelListEntry* currentEntry = m_pChannelTable[hashKey];
while ((currentEntry != NULL) && !entryFound) {
/* compare the Channel-IDs */
if (currentEntry->channelId == a_channelId) {
/* we have found the entry */
entryFound = true;
}
else {
currentEntry = currentEntry->rightEntry;
}
}
return currentEntry;
}
| void CALastMixBChannelList::removeFromTable | ( | t_lastMixBChannelListEntry * | a_channelEntry | ) |
Definition at line 79 of file CALastMixBChannelList.cpp.
References t_lastMixBChannelListEntry::associatedChannelList, CAMutex::lock(), m_pMutex, t_lastMixBChannelListEntry::rightEntry, t_lastMixBChannelListEntry::rightEntryPointerOfLeftEntry, and CAMutex::unlock().
Referenced by CAChain::processDownstream(), and CAChain::~CAChain().
{
m_pMutex->lock();
if (a_channelEntry->associatedChannelList == this) {
/* only remove entries which are in the table */
*(a_channelEntry->rightEntryPointerOfLeftEntry) = a_channelEntry->rightEntry;
if (a_channelEntry->rightEntry != NULL) {
a_channelEntry->rightEntry->rightEntryPointerOfLeftEntry = a_channelEntry->rightEntryPointerOfLeftEntry;
}
a_channelEntry->rightEntry = NULL;
a_channelEntry->rightEntryPointerOfLeftEntry = NULL;
a_channelEntry->associatedChannelList = NULL;
}
m_pMutex->unlock();
}
Definition at line 70 of file CALastMixBChannelList.hpp.
Referenced by add(), and CALastMixBChannelList().
Definition at line 71 of file CALastMixBChannelList.hpp.
Referenced by add(), CALastMixBChannelList(), getEntryInternal(), and ~CALastMixBChannelList().
CAMutex* CALastMixBChannelList::m_pMutex [private] |
Definition at line 72 of file CALastMixBChannelList.hpp.
Referenced by add(), CALastMixBChannelList(), get(), removeFromTable(), and ~CALastMixBChannelList().
1.7.6.1