Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Member Functions | Private Attributes
CALastMixBChannelList Class Reference

#include <CALastMixBChannelList.hpp>

Collaboration diagram for CALastMixBChannelList:
[legend]

List of all members.

Public Member Functions

 CALastMixBChannelList ()
 ~CALastMixBChannelList ()
t_lastMixBChannelListEntryadd (HCHANNEL a_channelId, CASymCipher *a_channelCipher, CAChain *a_associatedChain)
t_lastMixBChannelListEntryget (HCHANNEL a_channelId)
void removeFromTable (t_lastMixBChannelListEntry *a_channelEntry)

Private Member Functions

t_lastMixBChannelListEntrygetEntryInternal (HCHANNEL a_channelId)

Private Attributes

UINT32 m_channelTableSize
t_lastMixBChannelListEntry ** m_pChannelTable
CAMutexm_pMutex

Detailed Description

Definition at line 60 of file CALastMixBChannelList.hpp.


Constructor & Destructor Documentation

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;
}

Member Function Documentation

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;
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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;
}

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();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 70 of file CALastMixBChannelList.hpp.

Referenced by add(), and CALastMixBChannelList().


The documentation for this class was generated from the following files: