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

This class implements the pool strategie of a Mix. More...

#include <CAPool.hpp>

Collaboration diagram for CAPool:
[legend]

List of all members.

Public Member Functions

 CAPool (UINT32 poolsize)
 ~CAPool ()
SINT32 pool (tPoolEntry *pPoolEntry)

Private Attributes

tPoolListEntrym_pPoolList
tPoolListEntrym_pLastEntry
tPoolListEntrym_pEntry
HCHANNELm_arChannelIDs
UINT32 m_uPoolSize
UINT32 m_uRandMax

Detailed Description

This class implements the pool strategie of a Mix.

See [Message Pool] for more information.

Definition at line 42 of file CAPool.hpp.


Constructor & Destructor Documentation

CAPool::CAPool ( UINT32  poolsize)

Definition at line 33 of file CAPool.cpp.

References t_MixPacket::channel, CHANNEL_DUMMY, t_MixPacket::data, DATA_SIZE, DUMMY_CHANNEL, t_MixPacket::flags, getRandom(), m_arChannelIDs, m_pEntry, m_pLastEntry, m_pPoolList, m_uPoolSize, m_uRandMax, t_pool_list::next, t_queue_entry::packet, t_pool_list::poolentry, and setZero64().

  {
    m_uPoolSize=poolsize;
    m_uRandMax=0xFFFFFFFF;
    m_uRandMax-=m_uRandMax%m_uPoolSize;
    m_pPoolList=new tPoolListEntry;
    getRandom(m_pPoolList->poolentry.packet.data,DATA_SIZE);
    m_pPoolList->poolentry.packet.flags=CHANNEL_DUMMY;
    m_pPoolList->poolentry.packet.channel=DUMMY_CHANNEL;
#ifdef LOG_PACKET_TIMES
    setZero64(m_pPoolList->poolentry.timestamp_proccessing_start);
    setZero64(m_pPoolList->poolentry.pool_timestamp_in);
#endif        
    m_pPoolList->next=NULL;
    m_pLastEntry=m_pPoolList;
    m_arChannelIDs=new HCHANNEL[poolsize];
    m_arChannelIDs[0]=0;
    for(UINT32 i=1;i<poolsize;i++)
      {
        tPoolListEntry* tmpEntry=new tPoolListEntry;
        getRandom(tmpEntry->poolentry.packet.data,DATA_SIZE);
        tmpEntry->poolentry.packet.flags=CHANNEL_DUMMY;
        tmpEntry->poolentry.packet.channel=DUMMY_CHANNEL;
        #ifdef LOG_PACKET_TIMES
          setZero64(tmpEntry->poolentry.timestamp_proccessing_start);
          setZero64(tmpEntry->poolentry.pool_timestamp_in);
        #endif        
        tmpEntry->next=m_pPoolList;
        m_pPoolList=tmpEntry;
        m_arChannelIDs[i]=0;
      }
    m_pEntry=new tPoolListEntry;  
  }

Here is the call graph for this function:

Definition at line 67 of file CAPool.cpp.

References m_arChannelIDs, m_pEntry, m_pPoolList, and t_pool_list::next.

  {
    tPoolListEntry* tmpEntry;
    while(m_pPoolList!=NULL)
      {
        tmpEntry=m_pPoolList;
        m_pPoolList=m_pPoolList->next;
        delete tmpEntry;
        tmpEntry = NULL;
      }
    delete m_pEntry;
    m_pEntry = NULL;
    delete[] m_arChannelIDs;
    m_arChannelIDs = NULL;
  }

Member Function Documentation

SINT32 CAPool::pool ( tPoolEntry pPoolEntry)

Definition at line 83 of file CAPool.cpp.

References t_MixPacket::channel, E_SUCCESS, getRandom(), m_arChannelIDs, m_pEntry, m_pLastEntry, m_pPoolList, m_uPoolSize, m_uRandMax, t_pool_list::next, t_queue_entry::packet, and t_pool_list::poolentry.

Referenced by fm_loopReadFromMix(), fm_loopSendToMix(), lm_loopReadFromMix(), lm_loopSendToMix(), mm_loopReadFromMixAfter(), and mm_loopReadFromMixBefore().

  {
    UINT32 v;
    for(;;)
      {
        getRandom(&v);
        if(v<m_uRandMax)
          {
            v%=m_uPoolSize;
            break;
          }
      }
    HCHANNEL id=m_arChannelIDs[v];
    m_arChannelIDs[v]=pPoolEntry->packet.channel;
    tPoolListEntry* pPrevEntry=NULL;    
    tPoolListEntry* pEntryOut=m_pPoolList;
    while(pEntryOut->poolentry.packet.channel!=id)
      {
        pPrevEntry=pEntryOut;
        pEntryOut=pEntryOut->next;  
      }

    if(pEntryOut==m_pPoolList) //first element to remove)
      {
        memcpy(&m_pEntry->poolentry,pPoolEntry,sizeof(tPoolEntry));
        memcpy(pPoolEntry,&pEntryOut->poolentry,sizeof(tPoolEntry));
        m_pPoolList=m_pPoolList->next;
        m_pLastEntry->next=m_pEntry;
        m_pLastEntry=m_pEntry;
        m_pLastEntry->next=NULL;
        m_pEntry=pEntryOut;
      }
    else
      {
        memcpy(&m_pEntry->poolentry,pPoolEntry,sizeof(tPoolEntry));
        memcpy(pPoolEntry,&pEntryOut->poolentry,sizeof(tPoolEntry));
        m_pLastEntry->next=m_pEntry;
        m_pLastEntry=m_pEntry;
        m_pLastEntry->next=NULL;
        pPrevEntry->next=pEntryOut->next;
        m_pEntry=pEntryOut;   
      }   
    return E_SUCCESS;
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 54 of file CAPool.hpp.

Referenced by CAPool(), pool(), and ~CAPool().

Definition at line 53 of file CAPool.hpp.

Referenced by CAPool(), pool(), and ~CAPool().

Definition at line 52 of file CAPool.hpp.

Referenced by CAPool(), and pool().

Definition at line 51 of file CAPool.hpp.

Referenced by CAPool(), pool(), and ~CAPool().

Definition at line 55 of file CAPool.hpp.

Referenced by CAPool(), and pool().

Definition at line 56 of file CAPool.hpp.

Referenced by CAPool(), and pool().


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