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

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

#include <CAPool.hpp>

Collaboration diagram for CAPool:

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::CAPool ( UINT32  poolsize)

Definition at line 33 of file CAPool.cpp.

34  {
35  m_uPoolSize=poolsize;
36  m_uRandMax=0xFFFFFFFF;
42 #ifdef LOG_PACKET_TIMES
43  setZero64(m_pPoolList->poolentry.timestamp_proccessing_start);
44  setZero64(m_pPoolList->poolentry.pool_timestamp_in);
45 #endif
46  m_pPoolList->next=NULL;
48  m_arChannelIDs=new HCHANNEL[poolsize];
49  m_arChannelIDs[0]=0;
50  for(UINT32 i=1;i<poolsize;i++)
51  {
52  tPoolListEntry* tmpEntry=new tPoolListEntry;
56  #ifdef LOG_PACKET_TIMES
57  setZero64(tmpEntry->poolentry.timestamp_proccessing_start);
58  setZero64(tmpEntry->poolentry.pool_timestamp_in);
59  #endif
60  tmpEntry->next=m_pPoolList;
61  m_pPoolList=tmpEntry;
62  m_arChannelIDs[i]=0;
63  }
65  }
t_pool_list tPoolListEntry
Definition: CAPool.hpp:38
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
Definition: CAUtil.cpp:346
void setZero64(UINT64 &op1)
Definition: CAUtil.hpp:355
#define DUMMY_CHANNEL
Definition: StdAfx.h:246
unsigned int UINT32
Definition: basetypedefs.h:131
tPoolListEntry * m_pEntry
Definition: CAPool.hpp:53
tPoolListEntry * m_pPoolList
Definition: CAPool.hpp:51
tPoolListEntry * m_pLastEntry
Definition: CAPool.hpp:52
HCHANNEL * m_arChannelIDs
Definition: CAPool.hpp:54
UINT32 m_uRandMax
Definition: CAPool.hpp:56
UINT32 m_uPoolSize
Definition: CAPool.hpp:55
HCHANNEL channel
Definition: typedefs.hpp:117
UINT8 data[DATA_SIZE]
Definition: typedefs.hpp:121
UINT16 flags
Definition: typedefs.hpp:118
tPoolEntry poolentry
Definition: CAPool.hpp:35
struct t_pool_list * next
Definition: CAPool.hpp:34
MIXPACKET packet
Definition: typedefs.hpp:170
#define CHANNEL_DUMMY
Definition: typedefs.hpp:50
UINT32 HCHANNEL
Definition: typedefs.hpp:34
#define DATA_SIZE
Definition: typedefs.hpp:69

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

Here is the call graph for this function:

◆ ~CAPool()

CAPool::~CAPool ( )

Definition at line 67 of file CAPool.cpp.

68  {
69  tPoolListEntry* tmpEntry;
70  while(m_pPoolList!=NULL)
71  {
72  tmpEntry=m_pPoolList;
74  delete tmpEntry;
75  tmpEntry = NULL;
76  }
77  delete m_pEntry;
78  m_pEntry = NULL;
79  delete[] m_arChannelIDs;
80  m_arChannelIDs = NULL;
81  }

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

Member Function Documentation

◆ pool()

SINT32 CAPool::pool ( tPoolEntry pPoolEntry)

Definition at line 83 of file CAPool.cpp.

84  {
85  UINT32 v;
86  for(;;)
87  {
88  getRandom(&v);
89  if(v<m_uRandMax)
90  {
91  v%=m_uPoolSize;
92  break;
93  }
94  }
96  m_arChannelIDs[v]=pPoolEntry->packet.channel;
97  tPoolListEntry* pPrevEntry=NULL;
98  tPoolListEntry* pEntryOut=m_pPoolList;
99  while(pEntryOut->poolentry.packet.channel!=id)
100  {
101  pPrevEntry=pEntryOut;
102  pEntryOut=pEntryOut->next;
103  }
104 
105  if(pEntryOut==m_pPoolList) //first element to remove)
106  {
107  memcpy(&m_pEntry->poolentry,pPoolEntry,sizeof(tPoolEntry));
108  memcpy(pPoolEntry,&pEntryOut->poolentry,sizeof(tPoolEntry));
112  m_pLastEntry->next=NULL;
113  m_pEntry=pEntryOut;
114  }
115  else
116  {
117  memcpy(&m_pEntry->poolentry,pPoolEntry,sizeof(tPoolEntry));
118  memcpy(pPoolEntry,&pEntryOut->poolentry,sizeof(tPoolEntry));
121  m_pLastEntry->next=NULL;
122  pPrevEntry->next=pEntryOut->next;
123  m_pEntry=pEntryOut;
124  }
125  return E_SUCCESS;
126  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
Definition: typedefs.hpp:169

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.

Here is the call graph for this function:

Member Data Documentation

◆ m_arChannelIDs

HCHANNEL* CAPool::m_arChannelIDs
private

Definition at line 54 of file CAPool.hpp.

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

◆ m_pEntry

tPoolListEntry* CAPool::m_pEntry
private

Definition at line 53 of file CAPool.hpp.

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

◆ m_pLastEntry

tPoolListEntry* CAPool::m_pLastEntry
private

Definition at line 52 of file CAPool.hpp.

Referenced by CAPool(), and pool().

◆ m_pPoolList

tPoolListEntry* CAPool::m_pPoolList
private

Definition at line 51 of file CAPool.hpp.

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

◆ m_uPoolSize

UINT32 CAPool::m_uPoolSize
private

Definition at line 55 of file CAPool.hpp.

Referenced by CAPool(), and pool().

◆ m_uRandMax

UINT32 CAPool::m_uRandMax
private

Definition at line 56 of file CAPool.hpp.

Referenced by CAPool(), and pool().


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