Mixe for Privacy and Anonymity in the Internet
CAMiddleMix.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 __CAMIDDLEMIX__
29 #define __CAMIDDLEMIX__
30 
31 #include "CAMix.hpp"
32 #include "CAMuxSocket.hpp"
33 #include "CAASymCipher.hpp"
35 #include "CAQueue.hpp"
36 #include "CAInfoService.hpp"
37 #include "CAMixWithReplayDB.hpp"
38 
39 class CAMiddleMix:public
40 #ifdef REPLAY_DETECTION
42 #else
43  CAMix
44 #endif
45 {
46  public:
48  {
50  m_pMuxOut=NULL;m_pMuxIn=NULL;m_pRSA=NULL;
51  //m_pSignature=NULL;
52  m_pMultiSignature=NULL;
53  m_pInfoService=NULL;
55  upstreamPreBuffer=NULL;
56  upstreamPostBuffer=NULL;
57  m_bShMemConfigured=false;
58 #ifdef DYNAMIC_MIX
59  m_bBreakNeeded = false;
60 #endif
61 #ifdef LOG_PACKET_TIMES
62  m_pLogPacketStats = NULL;
63 #endif
64  }
65 
66  virtual ~CAMiddleMix(){clean();};
67  tMixType getType() const
68  {
69  return CAMix::MIDDLE_MIX;
70  }
71 
76  //friend THREAD_RETURN mm_loopDownStream(void *);
77 
78  private:
79  SINT32 loop();
80  SINT32 init();
81  SINT32 initOnce();
82  SINT32 clean();
83  SINT32 connectToNextMix(CASocketAddr* a_pAddrNext);
84 
86 
87 #ifdef DYNAMIC_MIX
88  bool m_bBreakNeeded;
89 #endif
90 
96  virtual SINT32 initMixCascadeInfo(DOMElement* )
97  {
98  return E_SUCCESS;
99  }
100 
101  virtual SINT32 processKeyExchange();
102 
103 protected:
106 private:
108 
109  //CASignature* m_pSignature;
110  volatile bool m_bRun;
112  //CAInfoService* m_pInfoService;
113 // friend THREAD_RETURN mm_loopDownStream(void *p);
114 
115 
116  /*shared memory*/
117  const char *upstreamMemoryPreName="upstreamshmempre";
118  const char *upstreamMemoryPostName="upstreamshmempost";
119  const char *downstreamMemoryPreName="downstreamshmempre";
120  const char *downstreamMemoryPostName="downstreamshmempost";
121 
126 
127  /*shared memory semaphors*/
131 
132  int accessSharedMemory(int semId, tPoolEntry* destination, tPoolEntry* source);
133 
134 protected:
137 
140 #ifdef LOG_PACKET_TIMES
141  CALogPacketStats *m_pLogPacketStats;
142 #endif
143 
144 #ifdef DYNAMIC_MIX
145  void stopCascade()
146  {
147  m_bRun = false;
148  }
149 #endif
150  };
151 
152 #ifdef LOG_CRIME
153  static void crimeSurveillanceUpstream(MIXPACKET *pMixPacket, HCHANNEL prevMixChannel);
154 #endif
155 
156 #endif
#define THREAD_RETURN
Definition: StdAfx.h:540
signed int SINT32
Definition: basetypedefs.h:132
unsigned int UINT32
Definition: basetypedefs.h:131
Data structure that stores all information about the currently open Mix channels.
UINT32 m_u32KeepAliveSendInterval2
int accessSharedMemory(int semId, tPoolEntry *destination, tPoolEntry *source)
CAQueue * m_pQueueSendToMixAfter
void * upstreamPreBuffer
friend THREAD_RETURN mm_loopReadFromMixAfter(void *)
friend THREAD_RETURN mm_loopSendToMixAfter(void *)
UPSTREAM (to WEB) Take the packets from the Queue and write them to the Socket.
SINT32 init()
int upstreamSemPreId
UINT32 m_u32KeepAliveRecvInterval2
virtual SINT32 initMixCascadeInfo(DOMElement *)
This method is not applicable to middle mixes; it does nothing.
Definition: CAMiddleMix.hpp:96
virtual ~CAMiddleMix()
Definition: CAMiddleMix.hpp:66
const char * downstreamMemoryPreName
CAASymCipher * m_pRSA
int upstreamSemPostId
virtual SINT32 processKeyExchange()
Processes key exchange with Mix n+1 and Mix n-1.
Definition: CAMiddleMix.cpp:84
SINT32 loop()
Processes Upstream-MixPackets.
const char * downstreamMemoryPostName
void * downstreamPreBuffer
SINT32 connectToNextMix(CASocketAddr *a_pAddrNext)
SINT32 clean()
const char * upstreamMemoryPreName
int downstreamSemPostId
CAQueue * m_pQueueSendToMixBefore
volatile bool m_bRun
bool m_bShMemConfigured
friend THREAD_RETURN mm_loopReadFromMixBefore(void *)
friend THREAD_RETURN mm_loopSendToMixBefore(void *)
DOWNSTREAM (to Client) Take the packets from the Queue and write them to the Socket.
const char * upstreamMemoryPostName
tMixType getType() const
Definition: CAMiddleMix.hpp:67
int downstreamSemPreId
void * downstreamPostBuffer
CAMuxSocket * m_pMuxOut
CAMiddleMixChannelList * m_pMiddleMixChannelList
SINT32 initOnce()
Definition: CAMiddleMix.cpp:51
SINT32 putMixPacketIntoQueueSendToMixBefore(tPoolEntry *pPoolEntry)
void * upstreamPostBuffer
CAMuxSocket * m_pMuxIn
Definition: CAMix.hpp:49
CAInfoService * m_pInfoService
Definition: CAMix.hpp:184
CAMultiSignature * m_pMultiSignature
Definition: CAMix.hpp:183
tMixType
Definition: CAMix.hpp:52
@ MIDDLE_MIX
Definition: CAMix.hpp:54
This class (interface) adds the functionality used by last and middle mixes to detecte replays.
This is a simple FIFO-Queue.
Definition: CAQueue.hpp:50
This is an abstract class for representing a socket address used in CASocket, CADatagramSocket and CA...
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
Definition: typedefs.hpp:169
UINT32 HCHANNEL
Definition: typedefs.hpp:34