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

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

#include <CAMiddleMixChannelList.hpp>

Collaboration diagram for CAMiddleMixChannelList:

Public Member Functions

 CAMiddleMixChannelList ()
 
 ~CAMiddleMixChannelList ()
 
SINT32 add (HCHANNEL channelIn, CASymChannelCipher *pCipher, HCHANNEL *channelOut)
 Adds a new Channel to the Channellist. More...
 
SINT32 getInToOut (HCHANNEL channelIn, HCHANNEL *channelOut, CASymChannelCipher **ppCipher)
 
SINT32 remove (HCHANNEL channelIn)
 Removes a channel form the channellist. More...
 
SINT32 getOutToIn (HCHANNEL *channelIn, HCHANNEL channelOut, CASymChannelCipher **ppCipher)
 

Static Public Member Functions

static SINT32 test ()
 

Private Member Functions

SINT32 getOutToIn_intern_without_lock (HCHANNEL *channelIn, HCHANNEL channelOut, CASymChannelCipher **ppCipher)
 

Private Attributes

LP_mmHashTableEntrym_pHashTableIn
 
LP_mmHashTableEntrym_pHashTableOut
 
CAMutex m_Mutex
 

Detailed Description

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

See [MiddleMixChannelList] for more information.

Definition at line 101 of file CAMiddleMixChannelList.hpp.

Constructor & Destructor Documentation

◆ CAMiddleMixChannelList()

CAMiddleMixChannelList::CAMiddleMixChannelList ( )
inline

Definition at line 104 of file CAMiddleMixChannelList.hpp.

105  {
106  m_pHashTableIn=new LP_mmHashTableEntry[0x10000];
107  memset(m_pHashTableIn,0,0x10000*sizeof(LP_mmHashTableEntry));
109  memset(m_pHashTableOut,0,0x10000*sizeof(LP_mmHashTableEntry));
110  }
LP_mmHashTableEntry * m_pHashTableOut
LP_mmHashTableEntry * m_pHashTableIn

References m_pHashTableIn, and m_pHashTableOut.

◆ ~CAMiddleMixChannelList()

CAMiddleMixChannelList::~CAMiddleMixChannelList ( )

Definition at line 7 of file CAMiddleMixChannelList.cpp.

8  {
9  m_Mutex.lock();
10  for(UINT32 i=0;i<0x10000;i++)
11  {
13  mmChannelListEntry* pTmpEntry;
14  while(pEntry!=NULL)
15  {
16  pTmpEntry=pEntry;
17  pEntry=pEntry->list_HashTableIn.next;
18  delete pTmpEntry->pCipher;
19  pTmpEntry->pCipher = NULL;
20  delete pTmpEntry;
21  pTmpEntry = NULL;
22  }
23  }
24  delete m_pHashTableIn;
25  m_pHashTableIn = NULL;
26  delete m_pHashTableOut;
27  m_pHashTableOut = NULL;
28  m_Mutex.unlock();
29  }
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
struct t_middlemixchannellist * next
CASymChannelCipher * pCipher
struct t_middlemixchannellist::dl_in list_HashTableIn

References t_middlemixchannellist::list_HashTableIn, CAMutex::lock(), m_Mutex, m_pHashTableIn, m_pHashTableOut, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::pCipher, and CAMutex::unlock().

Here is the call graph for this function:

Member Function Documentation

◆ add()

SINT32 CAMiddleMixChannelList::add ( HCHANNEL  channelIn,
CASymChannelCipher pCipher,
HCHANNEL channelOut 
)

Adds a new Channel to the Channellist.

Parameters
channelInincoming Channel-ID
pCipherCipher for recoding
channelOuton return holds a newly created random outgoing Channel-ID
Return values
E_SUCCESSif Channel was successfully added to the list

Definition at line 38 of file CAMiddleMixChannelList.cpp.

39  {
40  m_Mutex.lock();
42  pEntry->pCipher=pCipher;
43  pEntry->channelIn=channelIn;
44  pEntry->list_HashTableIn.prev=NULL;
45  pEntry->list_HashTableOut.prev=NULL;
46  do
47  {
48  getRandom(channelOut);
49  }while(*channelOut<256||getOutToIn_intern_without_lock(NULL,*channelOut,NULL)==E_SUCCESS);
50  pEntry->channelOut=*channelOut;
51 
52  mmChannelListEntry* pTmpEntry=m_pHashTableIn[channelIn&0x0000FFFF];
53  pEntry->list_HashTableIn.next=pTmpEntry;
54  if(pTmpEntry!=NULL)
55  pTmpEntry->list_HashTableIn.prev=pEntry;
56  m_pHashTableIn[channelIn&0x0000FFFF]=pEntry;
57 
58  pTmpEntry=m_pHashTableOut[(*channelOut)&0x0000FFFF];
59  pEntry->list_HashTableOut.next=pTmpEntry;
60  if(pTmpEntry!=NULL)
61  pTmpEntry->list_HashTableOut.prev=pEntry;
62  m_pHashTableOut[(*channelOut)&0x0000FFFF]=pEntry;
63 
64  m_Mutex.unlock();
65  return E_SUCCESS;
66  }
struct t_middlemixchannellist mmChannelListEntry
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
Definition: CAUtil.cpp:346
SINT32 getOutToIn_intern_without_lock(HCHANNEL *channelIn, HCHANNEL channelOut, CASymChannelCipher **ppCipher)
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
struct t_middlemixchannellist * prev
struct t_middlemixchannellist * prev
struct t_middlemixchannellist * next
struct t_middlemixchannellist::dl_out list_HashTableOut

References t_middlemixchannellist::channelIn, t_middlemixchannellist::channelOut, E_SUCCESS, getOutToIn_intern_without_lock(), getRandom(), t_middlemixchannellist::list_HashTableIn, t_middlemixchannellist::list_HashTableOut, CAMutex::lock(), m_Mutex, m_pHashTableIn, m_pHashTableOut, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::dl_out::next, t_middlemixchannellist::pCipher, t_middlemixchannellist::dl_in::prev, t_middlemixchannellist::dl_out::prev, and CAMutex::unlock().

Referenced by test().

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

◆ getInToOut()

SINT32 CAMiddleMixChannelList::getInToOut ( HCHANNEL  channelIn,
HCHANNEL channelOut,
CASymChannelCipher **  ppCipher 
)

Definition at line 68 of file CAMiddleMixChannelList.cpp.

69  {
70  m_Mutex.lock();
71  mmChannelListEntry* pEntry=m_pHashTableIn[channelIn&0x0000FFFF];
72  while(pEntry!=NULL)
73  {
74  if(pEntry->channelIn==channelIn)
75  {
76  if(channelOut!=NULL)
77  *channelOut=pEntry->channelOut;
78  if(ppCipher!=NULL)
79  {
80  *ppCipher=pEntry->pCipher;
81  (*ppCipher)->lock();
82  }
83  m_Mutex.unlock();
84  return E_SUCCESS;
85  }
86  pEntry=pEntry->list_HashTableIn.next;
87  }
88  m_Mutex.unlock();
89  return E_UNKNOWN;
90  }
SINT32 lock()
Locks the lockable object by threadsafe incrementing a reference counter.
Definition: CALockAble.hpp:55
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References t_middlemixchannellist::channelIn, t_middlemixchannellist::channelOut, E_SUCCESS, E_UNKNOWN, t_middlemixchannellist::list_HashTableIn, CALockAble::lock(), CAMutex::lock(), m_Mutex, m_pHashTableIn, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::pCipher, and CAMutex::unlock().

Here is the call graph for this function:

◆ getOutToIn()

SINT32 CAMiddleMixChannelList::getOutToIn ( HCHANNEL channelIn,
HCHANNEL  channelOut,
CASymChannelCipher **  ppCipher 
)
inline

Definition at line 141 of file CAMiddleMixChannelList.hpp.

142  {
143  m_Mutex.lock();
144  SINT32 ret=getOutToIn_intern_without_lock(channelIn,channelOut,ppCipher);
145  m_Mutex.unlock();
146  return ret;
147  }
signed int SINT32
Definition: basetypedefs.h:132

References getOutToIn_intern_without_lock(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().

Here is the call graph for this function:

◆ getOutToIn_intern_without_lock()

SINT32 CAMiddleMixChannelList::getOutToIn_intern_without_lock ( HCHANNEL channelIn,
HCHANNEL  channelOut,
CASymChannelCipher **  ppCipher 
)
inlineprivate

Definition at line 120 of file CAMiddleMixChannelList.hpp.

121  {
122  mmChannelListEntry* pEntry=m_pHashTableOut[channelOut&0x0000FFFF];
123  while(pEntry!=NULL)
124  {
125  if(pEntry->channelOut==channelOut)
126  {
127  if(channelIn!=NULL)
128  *channelIn=pEntry->channelIn;
129  if(ppCipher!=NULL)
130  {
131  *ppCipher=pEntry->pCipher;
132  (*ppCipher)->lock();
133  }
134  return E_SUCCESS;
135  }
136  pEntry=pEntry->list_HashTableOut.next;
137  }
138  return E_UNKNOWN;
139  }

References t_middlemixchannellist::channelIn, t_middlemixchannellist::channelOut, E_SUCCESS, E_UNKNOWN, t_middlemixchannellist::list_HashTableOut, CALockAble::lock(), m_pHashTableOut, t_middlemixchannellist::dl_out::next, and t_middlemixchannellist::pCipher.

Referenced by add(), and getOutToIn().

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

◆ remove()

SINT32 CAMiddleMixChannelList::remove ( HCHANNEL  channelIn)

Removes a channel form the channellist.

Parameters
channelInincoming Channel-ID of the channel which should be removed
Return values
E_SUCCESSif channel was successfully removed from the list
E_UNKNOWNotherwise

Definition at line 97 of file CAMiddleMixChannelList.cpp.

98  {
99  m_Mutex.lock();
100  mmChannelListEntry* pEntry=m_pHashTableIn[channelIn&0x0000FFFF];
101  while(pEntry!=NULL)
102  {
103  if(pEntry->channelIn==channelIn)
104  {
105  delete pEntry->pCipher;
106  pEntry->pCipher = NULL;
107  if(pEntry->list_HashTableIn.prev==NULL)
108  {
109  if(pEntry->list_HashTableIn.next==NULL)
110  {
111  m_pHashTableIn[channelIn&0x0000FFFF]=NULL;
112  }
113  else
114  {
115  m_pHashTableIn[channelIn&0x0000FFFF]=pEntry->list_HashTableIn.next;
117  }
118  }
119  else
120  {
121  if(pEntry->list_HashTableIn.next==NULL)
122  {
124  }
125  else
126  {
129  }
130  }
131  if(pEntry->list_HashTableOut.prev==NULL)
132  {
133  if(pEntry->list_HashTableOut.next==NULL)
134  {
135  m_pHashTableOut[pEntry->channelOut&0x0000FFFF]=NULL;
136  }
137  else
138  {
139  m_pHashTableOut[pEntry->channelOut&0x0000FFFF]=pEntry->list_HashTableOut.next;
141  }
142  }
143  else
144  {
145  if(pEntry->list_HashTableOut.next==NULL)
146  {
148  }
149  else
150  {
153  }
154  }
155  delete pEntry;
156  pEntry = NULL;
157  m_Mutex.unlock();
158  return E_SUCCESS;
159  }
160  pEntry=pEntry->list_HashTableIn.next;
161  }
162  m_Mutex.unlock();
163  return E_UNKNOWN;
164  }

References t_middlemixchannellist::channelIn, t_middlemixchannellist::channelOut, E_SUCCESS, E_UNKNOWN, t_middlemixchannellist::list_HashTableIn, t_middlemixchannellist::list_HashTableOut, CAMutex::lock(), m_Mutex, m_pHashTableIn, m_pHashTableOut, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::dl_out::next, t_middlemixchannellist::pCipher, t_middlemixchannellist::dl_in::prev, t_middlemixchannellist::dl_out::prev, and CAMutex::unlock().

Referenced by test().

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

◆ test()

SINT32 CAMiddleMixChannelList::test ( )
static

Definition at line 166 of file CAMiddleMixChannelList.cpp.

167  {
169  UINT32 c;
170  UINT32 d;
171  UINT32 rand;
172  int i,j;
173  for(i=0;i<1000;i++)
174  {
175  getRandom(&c);
176  oList.add(c,NULL,&d);
177  }
178  for(i=0;i<100;i++)
179  {
180  getRandom(&rand);
181  if(rand<0x0FFFFFFF)
182  for(j=0;j<5;j++)
183  {
184  getRandom(&c);
185  oList.add(c,NULL,&d);
186  }
187  getRandom(&rand);
188  if(rand<0x7FFFFFFF)
189  for(int j=0;j<100000;j++)
190  {
191  getRandom(&c);
192  oList.remove(c);
193  }
194  }
195  return 0;
196  }
Data structure that stores all information about the currently open Mix channels.
SINT32 add(HCHANNEL channelIn, CASymChannelCipher *pCipher, HCHANNEL *channelOut)
Adds a new Channel to the Channellist.
SINT32 remove(HCHANNEL channelIn)
Removes a channel form the channellist.

References add(), getRandom(), and remove().

Here is the call graph for this function:

Member Data Documentation

◆ m_Mutex

CAMutex CAMiddleMixChannelList::m_Mutex
private

◆ m_pHashTableIn

LP_mmHashTableEntry* CAMiddleMixChannelList::m_pHashTableIn
private

◆ m_pHashTableOut

LP_mmHashTableEntry* CAMiddleMixChannelList::m_pHashTableOut
private

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