Mixe for Privacy and Anonymity in the Internet
CAInfoService.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 __CAINFOSERVICE__
29 #define __CAINFOSERVICE__
30 #if !defined ONLY_LOCAL_PROXY
31 //#include "CAMultiSignature.hpp"
32 
33 #include "CAFirstMix.hpp"
34 #include "CAXMLBI.hpp"
35 
36 #endif
37 
38 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
39 #include "CAThread.hpp"
40 #include "CAMutex.hpp"
41 #include "CACmdLnOptions.hpp"
42 
43 #define NR_REQUEST_TYPES 2
44 #define REQUEST_TYPE_POST 0
45 #define REQUEST_TYPE_GET 1
46 
47 #define NR_REQUEST_COMMANDS 7
48 #define REQUEST_COMMAND_CONFIGURE 0
49 #define REQUEST_COMMAND_HELO 1
50 #define REQUEST_COMMAND_MIXINFO 2
51 #define REQUEST_COMMAND_DYNACASCADE 3
52 #define REQUEST_COMMAND_CASCADE 4
53 #define REQUEST_COMMAND_STATUS 5
54 #define REQUEST_COMMAND_TNC_DATA 6
55 
56 #define ATTRIBUTE_SERIAL "serial"
57 
58 #define LOCALE_DEFAULT LOCALE_EN
59 #define LOCALE_EN "en"
60 
62  {
63  #ifdef PAYMENT
64  SINT32 getPaymentInstance(const UINT8* a_pstrPIID,CAXMLBI** pXMLBI,
65  CASocketAddrINet* a_socketAddress);
66  #endif
67 
68  public:
69  CAInfoService();
72  SINT32 sendMixHelo(SINT32 requestCommand=-1,const UINT8* param=NULL);
73  SINT32 sendStatus(bool bIncludeCerts);
74  bool isRunning()
75  {
76  return m_bRun;
77  }
78 
79  void setConfiguring(bool a_configuring)
80  {
81  m_bConfiguring = a_configuring;
82  }
83  // added by ronin <ronin2@web.de>
85  {
86  return m_bConfiguring;
87  }
88  void setSerial(UINT64 a_serial)
89  {
90  m_serial = a_serial;
91  }
92  SINT32 start();
93  SINT32 stop();
94  SINT32 signal();
95  SINT32 setMultiSignature(CAMultiSignature* pMultiSignature);
96 
97 #if !defined ONLY_LOCAL_PROXY
98  //SINT32 sendMixInfo(const UINT8* pMixID);
100 #ifdef PAYMENT
101  SINT32 getPaymentInstance(const UINT8* a_pstrPIID,CAXMLBI** pXMLBI);
102 #endif
103 
104  //remove me
105  /*SINT32 setSignature(CASignature* pSignature, CACertificate* a_ownCert,
106  CACertificate* a_opCert);*/
107 
108 
109 
110 
111 
112 
113 #ifdef DYNAMIC_MIX
115  SINT32 dynamicCascadeConfiguration();
116  bool newCascadeAvailable();
117 #endif
118 
119  private:
120  static THREAD_RETURN TCascadeHelo(void *p);
122  SINT32 sendCascadeHelo(const UINT8* xml,UINT32 len,const CASocketAddrINet* a_socketAddress) const;
123 
124  UINT8 **getOperatorTnCsAsStrings(UINT32 **lengths, UINT32 *nrOfTnCs);
126 
127 
128  // added by ronin <ronin2@web.de>
129  SINT32 handleConfigEvent(XERCES_CPP_NAMESPACE::DOMDocument* doc) const;
130 
131  //CASignature* m_pSignature;
132 #ifdef DYNAMIC_MIX
133  bool m_bReconfig;
134 #endif
135 #endif
136  private:
137  SINT32 sendMixHelo(const UINT8* strMixHeloXML,UINT32 len,SINT32 requestCommand,const UINT8* param,
138  const CASocketAddrINet* a_socketAddress);
140  UINT8 *xmlDocToStringWithSignature(DOMNode *a_node, UINT32& a_len, bool bIncludeCerts);
141  SINT32 sendHelo(UINT8* a_strXML, UINT32 a_len, THREAD_RETURN (*a_thread)(void *), UINT8* a_strThreadName, SINT32 requestCommand, const UINT8* param = NULL);
142  SINT32 getLevel(SINT32* puser,SINT32* prisk,SINT32* ptraffic);
143  SINT32 getMixedPackets(UINT64& ppackets);
144  UINT8* getStatusXMLAsString(bool bIncludeCerts,UINT32& len);
145  SINT32 sendStatus(const UINT8* strStatusXML,UINT32 len,const CASocketAddrINet* a_socketAddress) const;
146  static THREAD_RETURN TCascadeStatus(void *p);
147  static THREAD_RETURN TMixHelo(void *p);
148  static THREAD_RETURN InfoLoop(void *p);
149  volatile bool m_bRun;
159  struct InfoServiceHeloMsg;
160 
161  public:
162  static const UINT64 MINUTE;
163  static const UINT64 SEND_LOOP_SLEEP;
169 };
170 #endif
171 #endif //ONLY_LOCAL_PROXY
#define THREAD_RETURN
Definition: StdAfx.h:540
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
CAThread * m_pthreadRunLoop
CAConditionVariable * m_pLoopCV
SINT32 getPaymentInstance(const UINT8 *a_pstrPIID, CAXMLBI **pXMLBI, CASocketAddrINet *a_socketAddress)
Gets a payment instance from the InfoService.
SINT32 sendHelo(UINT8 *a_strXML, UINT32 a_len, THREAD_RETURN(*a_thread)(void *), UINT8 *a_strThreadName, SINT32 requestCommand, const UINT8 *param=NULL)
SINT32 setMultiSignature(CAMultiSignature *pMultiSignature)
UINT8 * getMixHeloXMLAsString(UINT32 &len)
static const UINT32 REPEAT_ON_STATUS_SENT_ERROR
static THREAD_RETURN TCascadeStatus(void *p)
bool isConfiguring()
SINT32 getMixedPackets(UINT64 &ppackets)
void setConfiguring(bool a_configuring)
SINT32 sendStatus(bool bIncludeCerts)
static const UINT64 SEND_STATUS_INFO_WAIT
CAMultiSignature * m_pMultiSignature
SINT32 sendMixHelo(SINT32 requestCommand=-1, const UINT8 *param=NULL)
SINT32 m_expectedMixRelPos
volatile bool m_bRun
static const UINT64 SEND_MIX_INFO_WAIT
SINT32 sendCascadeHelo()
static const UINT64 SEND_LOOP_SLEEP
UINT8 * getStatusXMLAsString(bool bIncludeCerts, UINT32 &len)
UINT64 m_lastMixedPackets
static const UINT32 SEND_INFO_TIMEOUT_MS
UINT8 ** getOperatorTnCsAsStrings(UINT32 **lengths, UINT32 *nrOfTnCs)
POSTs the MIXINFO message for a mix to the InfoService.
static const UINT64 MINUTE
void setSerial(UINT64 a_serial)
SINT32 sendOperatorTnCData()
SINT32 getLevel(SINT32 *puser, SINT32 *prisk, SINT32 *ptraffic)
static THREAD_RETURN TCascadeHelo(void *p)
UINT8 * xmlDocToStringWithSignature(DOMNode *a_node, UINT32 &a_len, bool bIncludeCerts)
UINT8 * getCascadeHeloXMLAsString(UINT32 &len)
static THREAD_RETURN TMixHelo(void *p)
static const UINT64 SEND_CASCADE_INFO_WAIT
SINT32 handleConfigEvent(XERCES_CPP_NAMESPACE::DOMDocument *doc) const
static THREAD_RETURN InfoLoop(void *p)
Definition: CAMix.hpp:49
This class represents a socket address for Internet (IP) connections.
CAMix * pMix
Definition: proxytest.cpp:75
UINT16 len
Definition: typedefs.hpp:0