Mixe for Privacy and Anonymity in the Internet
CAMiddleMixChannelList.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 #ifndef __CAMIDDLEMIXCHANNELLIST__
29 #define __CAMIDDLEMIXCHANNELLIST__
30 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
31 #include "CASymChannelCipher.hpp"
32 #include "CAMuxSocket.hpp"
33 #include "CAMutex.hpp"
34 
35 
37  {
41  struct dl_in
42  {
45 
46  struct dl_out
47  {
50 
51  };
56 
102  {
103  public:
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  }
111 
113 
114  SINT32 add(HCHANNEL channelIn,CASymChannelCipher* pCipher,HCHANNEL* channelOut);
115 
116  SINT32 getInToOut(HCHANNEL channelIn, HCHANNEL* channelOut,CASymChannelCipher** ppCipher);
117  SINT32 remove(HCHANNEL channelIn);
118  static SINT32 test();
119  private:
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  }
140  public:
141  SINT32 getOutToIn(HCHANNEL* channelIn, HCHANNEL channelOut,CASymChannelCipher** ppCipher)
142  {
143  m_Mutex.lock();
144  SINT32 ret=getOutToIn_intern_without_lock(channelIn,channelOut,ppCipher);
145  m_Mutex.unlock();
146  return ret;
147  }
148 
149  private:
153  };
154 #endif
155 #endif //ONLY_LOCAL_PROXY
struct t_middlemixchannellist * LP_mmHashTableEntry
signed int SINT32
Definition: basetypedefs.h:132
SINT32 lock()
Locks the lockable object by threadsafe incrementing a reference counter.
Definition: CALockAble.hpp:55
Data structure that stores all information about the currently open Mix channels.
LP_mmHashTableEntry * m_pHashTableOut
LP_mmHashTableEntry * m_pHashTableIn
SINT32 add(HCHANNEL channelIn, CASymChannelCipher *pCipher, HCHANNEL *channelOut)
Adds a new Channel to the Channellist.
SINT32 getOutToIn(HCHANNEL *channelIn, HCHANNEL channelOut, CASymChannelCipher **ppCipher)
SINT32 getInToOut(HCHANNEL channelIn, HCHANNEL *channelOut, CASymChannelCipher **ppCipher)
SINT32 getOutToIn_intern_without_lock(HCHANNEL *channelIn, HCHANNEL channelOut, CASymChannelCipher **ppCipher)
SINT32 remove(HCHANNEL channelIn)
Removes a channel form the channellist.
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3
struct t_middlemixchannellist * prev
struct t_middlemixchannellist * next
struct t_middlemixchannellist * prev
struct t_middlemixchannellist * next
CASymChannelCipher * pCipher
struct t_middlemixchannellist::dl_out list_HashTableOut
struct t_middlemixchannellist::dl_in list_HashTableIn
UINT32 HCHANNEL
Definition: typedefs.hpp:34