|
Mixe for Privacy and Anonymity in the Internet
|
Data structure that stores all information about the currently open Mix channels. More...
#include <CAMiddleMixChannelList.hpp>
Public Member Functions | |
| CAMiddleMixChannelList () | |
| ~CAMiddleMixChannelList () | |
| SINT32 | add (HCHANNEL channelIn, CASymCipher *pCipher, HCHANNEL *channelOut) |
| Adds a new Channel to the Channellist. | |
| SINT32 | getInToOut (HCHANNEL channelIn, HCHANNEL *channelOut, CASymCipher **ppCipher) |
| SINT32 | remove (HCHANNEL channelIn) |
| Removes a channel form the channellist. | |
| SINT32 | getOutToIn (HCHANNEL *channelIn, HCHANNEL channelOut, CASymCipher **ppCipher) |
Static Public Member Functions | |
| static SINT32 | test () |
Private Member Functions | |
| SINT32 | getOutToIn_intern_without_lock (HCHANNEL *channelIn, HCHANNEL channelOut, CASymCipher **ppCipher) |
Private Attributes | |
| LP_mmHashTableEntry * | m_pHashTableIn |
| LP_mmHashTableEntry * | m_pHashTableOut |
| CAMutex | m_Mutex |
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.
| CAMiddleMixChannelList::CAMiddleMixChannelList | ( | ) | [inline] |
Definition at line 104 of file CAMiddleMixChannelList.hpp.
References m_pHashTableIn, and m_pHashTableOut.
{
m_pHashTableIn=new LP_mmHashTableEntry[0x10000];
memset(m_pHashTableIn,0,0x10000*sizeof(LP_mmHashTableEntry));
m_pHashTableOut=new LP_mmHashTableEntry[0x10000];
memset(m_pHashTableOut,0,0x10000*sizeof(LP_mmHashTableEntry));
}
Definition at line 7 of file CAMiddleMixChannelList.cpp.
References t_middlemixchannellist::list_HashTableIn, CAMutex::lock(), m_Mutex, m_pHashTableIn, m_pHashTableOut, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::pCipher, and CAMutex::unlock().
{
m_Mutex.lock();
for(UINT32 i=0;i<0x10000;i++)
{
mmChannelListEntry* pEntry=m_pHashTableIn[i];
mmChannelListEntry* pTmpEntry;
while(pEntry!=NULL)
{
pTmpEntry=pEntry;
pEntry=pEntry->list_HashTableIn.next;
delete pTmpEntry->pCipher;
pTmpEntry->pCipher = NULL;
delete pTmpEntry;
pTmpEntry = NULL;
}
}
delete m_pHashTableIn;
m_pHashTableIn = NULL;
delete m_pHashTableOut;
m_pHashTableOut = NULL;
m_Mutex.unlock();
}
| SINT32 CAMiddleMixChannelList::add | ( | HCHANNEL | channelIn, |
| CASymCipher * | pCipher, | ||
| HCHANNEL * | channelOut | ||
| ) |
Adds a new Channel to the Channellist.
| channelIn | incoming Channel-ID |
| pCipher | Cipher for recoding |
| channelOut | on return holds a newly created random outgoing Channel-ID |
| E_SUCCESS | if Channel was successfully added to the list |
Definition at line 38 of file CAMiddleMixChannelList.cpp.
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 mm_loopReadFromMixBefore(), and test().
{
m_Mutex.lock();
mmChannelListEntry* pEntry=new mmChannelListEntry;
pEntry->pCipher=pCipher;
pEntry->channelIn=channelIn;
pEntry->list_HashTableIn.prev=NULL;
pEntry->list_HashTableOut.prev=NULL;
do
{
getRandom(channelOut);
}while(*channelOut<256||getOutToIn_intern_without_lock(NULL,*channelOut,NULL)==E_SUCCESS);
pEntry->channelOut=*channelOut;
mmChannelListEntry* pTmpEntry=m_pHashTableIn[channelIn&0x0000FFFF];
pEntry->list_HashTableIn.next=pTmpEntry;
if(pTmpEntry!=NULL)
pTmpEntry->list_HashTableIn.prev=pEntry;
m_pHashTableIn[channelIn&0x0000FFFF]=pEntry;
pTmpEntry=m_pHashTableOut[(*channelOut)&0x0000FFFF];
pEntry->list_HashTableOut.next=pTmpEntry;
if(pTmpEntry!=NULL)
pTmpEntry->list_HashTableOut.prev=pEntry;
m_pHashTableOut[(*channelOut)&0x0000FFFF]=pEntry;
m_Mutex.unlock();
return E_SUCCESS;
}
| SINT32 CAMiddleMixChannelList::getInToOut | ( | HCHANNEL | channelIn, |
| HCHANNEL * | channelOut, | ||
| CASymCipher ** | ppCipher | ||
| ) |
Definition at line 68 of file CAMiddleMixChannelList.cpp.
References t_middlemixchannellist::channelIn, t_middlemixchannellist::channelOut, E_SUCCESS, E_UNKNOWN, t_middlemixchannellist::list_HashTableIn, CAMutex::lock(), CALockAble::lock(), m_Mutex, m_pHashTableIn, t_middlemixchannellist::dl_in::next, t_middlemixchannellist::pCipher, and CAMutex::unlock().
Referenced by mm_loopReadFromMixBefore().
{
m_Mutex.lock();
mmChannelListEntry* pEntry=m_pHashTableIn[channelIn&0x0000FFFF];
while(pEntry!=NULL)
{
if(pEntry->channelIn==channelIn)
{
if(channelOut!=NULL)
*channelOut=pEntry->channelOut;
if(ppCipher!=NULL)
{
*ppCipher=pEntry->pCipher;
(*ppCipher)->lock();
}
m_Mutex.unlock();
return E_SUCCESS;
}
pEntry=pEntry->list_HashTableIn.next;
}
m_Mutex.unlock();
return E_UNKNOWN;
}
| SINT32 CAMiddleMixChannelList::getOutToIn | ( | HCHANNEL * | channelIn, |
| HCHANNEL | channelOut, | ||
| CASymCipher ** | ppCipher | ||
| ) | [inline] |
Definition at line 141 of file CAMiddleMixChannelList.hpp.
References getOutToIn_intern_without_lock(), CAMutex::lock(), m_Mutex, and CAMutex::unlock().
Referenced by mm_loopReadFromMixAfter().
{
m_Mutex.lock();
SINT32 ret=getOutToIn_intern_without_lock(channelIn,channelOut,ppCipher);
m_Mutex.unlock();
return ret;
}
| SINT32 CAMiddleMixChannelList::getOutToIn_intern_without_lock | ( | HCHANNEL * | channelIn, |
| HCHANNEL | channelOut, | ||
| CASymCipher ** | ppCipher | ||
| ) | [inline, private] |
Definition at line 120 of file CAMiddleMixChannelList.hpp.
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().
{
mmChannelListEntry* pEntry=m_pHashTableOut[channelOut&0x0000FFFF];
while(pEntry!=NULL)
{
if(pEntry->channelOut==channelOut)
{
if(channelIn!=NULL)
*channelIn=pEntry->channelIn;
if(ppCipher!=NULL)
{
*ppCipher=pEntry->pCipher;
(*ppCipher)->lock();
}
return E_SUCCESS;
}
pEntry=pEntry->list_HashTableOut.next;
}
return E_UNKNOWN;
}
| SINT32 CAMiddleMixChannelList::remove | ( | HCHANNEL | channelIn | ) |
Removes a channel form the channellist.
| channelIn | incoming Channel-ID of the channel which should be removed |
| E_SUCCESS | if channel was successfully removed from the list |
| E_UNKNOWN | otherwise |
Definition at line 97 of file CAMiddleMixChannelList.cpp.
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 mm_loopReadFromMixAfter(), mm_loopReadFromMixBefore(), and test().
{
m_Mutex.lock();
mmChannelListEntry* pEntry=m_pHashTableIn[channelIn&0x0000FFFF];
while(pEntry!=NULL)
{
if(pEntry->channelIn==channelIn)
{
delete pEntry->pCipher;
pEntry->pCipher = NULL;
if(pEntry->list_HashTableIn.prev==NULL)
{
if(pEntry->list_HashTableIn.next==NULL)
{
m_pHashTableIn[channelIn&0x0000FFFF]=NULL;
}
else
{
m_pHashTableIn[channelIn&0x0000FFFF]=pEntry->list_HashTableIn.next;
pEntry->list_HashTableIn.next->list_HashTableIn.prev=NULL;
}
}
else
{
if(pEntry->list_HashTableIn.next==NULL)
{
pEntry->list_HashTableIn.prev->list_HashTableIn.next=NULL;
}
else
{
pEntry->list_HashTableIn.prev->list_HashTableIn.next=pEntry->list_HashTableIn.next;
pEntry->list_HashTableIn.next->list_HashTableIn.prev=pEntry->list_HashTableIn.prev;
}
}
if(pEntry->list_HashTableOut.prev==NULL)
{
if(pEntry->list_HashTableOut.next==NULL)
{
m_pHashTableOut[pEntry->channelOut&0x0000FFFF]=NULL;
}
else
{
m_pHashTableOut[pEntry->channelOut&0x0000FFFF]=pEntry->list_HashTableOut.next;
pEntry->list_HashTableOut.next->list_HashTableOut.prev=NULL;
}
}
else
{
if(pEntry->list_HashTableOut.next==NULL)
{
pEntry->list_HashTableOut.prev->list_HashTableOut.next=NULL;
}
else
{
pEntry->list_HashTableOut.prev->list_HashTableOut.next=pEntry->list_HashTableOut.next;
pEntry->list_HashTableOut.next->list_HashTableOut.prev=pEntry->list_HashTableOut.prev;
}
}
delete pEntry;
pEntry = NULL;
m_Mutex.unlock();
return E_SUCCESS;
}
pEntry=pEntry->list_HashTableIn.next;
}
m_Mutex.unlock();
return E_UNKNOWN;
}
| SINT32 CAMiddleMixChannelList::test | ( | ) | [static] |
Definition at line 166 of file CAMiddleMixChannelList.cpp.
References add(), getRandom(), and remove().
{
CAMiddleMixChannelList oList;
UINT32 c;
UINT32 d;
UINT32 rand;
int i,j;
for(i=0;i<1000;i++)
{
getRandom(&c);
oList.add(c,NULL,&d);
}
for(i=0;i<100;i++)
{
getRandom(&rand);
if(rand<0x0FFFFFFF)
for(j=0;j<5;j++)
{
getRandom(&c);
oList.add(c,NULL,&d);
}
getRandom(&rand);
if(rand<0x7FFFFFFF)
for(int j=0;j<100000;j++)
{
getRandom(&c);
oList.remove(c);
}
}
return 0;
}
CAMutex CAMiddleMixChannelList::m_Mutex [private] |
Definition at line 152 of file CAMiddleMixChannelList.hpp.
Referenced by add(), getInToOut(), getOutToIn(), remove(), and ~CAMiddleMixChannelList().
Definition at line 150 of file CAMiddleMixChannelList.hpp.
Referenced by add(), CAMiddleMixChannelList(), getInToOut(), remove(), and ~CAMiddleMixChannelList().
Definition at line 151 of file CAMiddleMixChannelList.hpp.
Referenced by add(), CAMiddleMixChannelList(), getOutToIn_intern_without_lock(), remove(), and ~CAMiddleMixChannelList().
1.7.6.1