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

#include <CALastMixBChannelList.hpp>

Collaboration diagram for CALastMixBChannelList:

Public Member Functions

 CALastMixBChannelList ()
 
 ~CALastMixBChannelList ()
 
t_lastMixBChannelListEntryadd (HCHANNEL a_channelId, CASymChannelCipher *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

◆ CALastMixBChannelList()

CALastMixBChannelList::CALastMixBChannelList ( )

Definition at line 36 of file CALastMixBChannelList.cpp.

36  {
38  for (UINT32 i = 0; i < 0x10000; i++) {
39  m_pChannelTable[i] = NULL;
40  }
42  m_pMutex = new CAMutex();
43 }
unsigned int UINT32
Definition: basetypedefs.h:131
t_lastMixBChannelListEntry ** m_pChannelTable

References m_channelTableSize, m_pChannelTable, and m_pMutex.

◆ ~CALastMixBChannelList()

CALastMixBChannelList::~CALastMixBChannelList ( )

Definition at line 45 of file CALastMixBChannelList.cpp.

45  {
46  delete m_pMutex;
47  m_pMutex = NULL;
48  delete []m_pChannelTable;
49  m_pChannelTable = NULL;
50 }

References m_pChannelTable, and m_pMutex.

Member Function Documentation

◆ add()

t_lastMixBChannelListEntry * CALastMixBChannelList::add ( HCHANNEL  a_channelId,
CASymChannelCipher a_channelCipher,
CAChain a_associatedChain 
)

Definition at line 52 of file CALastMixBChannelList.cpp.

52  {
53  m_pMutex->lock();
54  /* check whether we have not already an entry with the same ID */
55  if (getEntryInternal(a_channelId) != NULL) {
56  m_pMutex->unlock();
57  return NULL;
58  }
60  newEntry->channelId = a_channelId;
61  newEntry->channelCipher = a_channelCipher;
62  newEntry->associatedChain = a_associatedChain;
63  newEntry->associatedChannelList = this;
64  newEntry->firstResponseDeadline = NULL;
65  /* take the lower 16 bits of the ID as key for the hashtable */
66  UINT16 hashKey = (UINT16)(a_channelId & 0x0000FFFF);
67  /* now add the entry at the begin of the hashtable-line */
68  newEntry->rightEntry = m_pChannelTable[hashKey];
69  newEntry->rightEntryPointerOfLeftEntry = &(m_pChannelTable[hashKey]);
70  m_pChannelTable[hashKey] = newEntry;
71  if (newEntry->rightEntry != NULL) {
72  newEntry->rightEntry->rightEntryPointerOfLeftEntry = &(newEntry->rightEntry);
73  }
75  m_pMutex->unlock();
76  return newEntry;
77 }
unsigned short UINT16
Definition: basetypedefs.h:133
t_lastMixBChannelListEntry * getEntryInternal(HCHANNEL a_channelId)
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
class CAChain * associatedChain
t_deadlineEntry * firstResponseDeadline
HCHANNEL channelId
t_lastMixBChannelListEntry * rightEntry
t_lastMixBChannelListEntry ** rightEntryPointerOfLeftEntry
class CALastMixBChannelList * associatedChannelList
CASymChannelCipher * channelCipher

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

t_lastMixBChannelListEntry * CALastMixBChannelList::get ( HCHANNEL  a_channelId)

Definition at line 94 of file CALastMixBChannelList.cpp.

94  {
95  t_lastMixBChannelListEntry* returnedEntry = NULL;
96  m_pMutex->lock();
97  returnedEntry = getEntryInternal(a_channelId);
98  m_pMutex->unlock();
99  return returnedEntry;
100 }

References getEntryInternal(), CAMutex::lock(), m_pMutex, and CAMutex::unlock().

Referenced by CALastMixB::loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEntryInternal()

t_lastMixBChannelListEntry * CALastMixBChannelList::getEntryInternal ( HCHANNEL  a_channelId)
private

Definition at line 103 of file CALastMixBChannelList.cpp.

103  {
104  /* mutex must be already locked */
105  /* take the lower 16 bits of the ID as key for the hashtable */
106  UINT16 hashKey = (UINT16)(a_channelId & 0x0000FFFF);
107  bool entryFound = false;
108  t_lastMixBChannelListEntry* currentEntry = m_pChannelTable[hashKey];
109  while ((currentEntry != NULL) && !entryFound) {
110  /* compare the Channel-IDs */
111  if (currentEntry->channelId == a_channelId) {
112  /* we have found the entry */
113  entryFound = true;
114  }
115  else {
116  currentEntry = currentEntry->rightEntry;
117  }
118  }
119  return currentEntry;
120 }

References t_lastMixBChannelListEntry::channelId, m_pChannelTable, and t_lastMixBChannelListEntry::rightEntry.

Referenced by add(), and get().

Here is the caller graph for this function:

◆ removeFromTable()

void CALastMixBChannelList::removeFromTable ( t_lastMixBChannelListEntry a_channelEntry)

Definition at line 79 of file CALastMixBChannelList.cpp.

79  {
80  m_pMutex->lock();
81  if (a_channelEntry->associatedChannelList == this) {
82  /* only remove entries which are in the table */
83  *(a_channelEntry->rightEntryPointerOfLeftEntry) = a_channelEntry->rightEntry;
84  if (a_channelEntry->rightEntry != NULL) {
85  a_channelEntry->rightEntry->rightEntryPointerOfLeftEntry = a_channelEntry->rightEntryPointerOfLeftEntry;
86  }
87  a_channelEntry->rightEntry = NULL;
88  a_channelEntry->rightEntryPointerOfLeftEntry = NULL;
89  a_channelEntry->associatedChannelList = NULL;
90  }
91  m_pMutex->unlock();
92 }

References t_lastMixBChannelListEntry::associatedChannelList, CAMutex::lock(), m_pMutex, t_lastMixBChannelListEntry::rightEntry, t_lastMixBChannelListEntry::rightEntryPointerOfLeftEntry, and CAMutex::unlock().

Referenced by CAChain::processDownstream(), and CAChain::~CAChain().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_channelTableSize

UINT32 CALastMixBChannelList::m_channelTableSize
private

Definition at line 70 of file CALastMixBChannelList.hpp.

Referenced by add(), and CALastMixBChannelList().

◆ m_pChannelTable

t_lastMixBChannelListEntry** CALastMixBChannelList::m_pChannelTable
private

◆ m_pMutex

CAMutex* CALastMixBChannelList::m_pMutex
private

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