|
Mixe for Privacy and Anonymity in the Internet
|
00001 /* 00002 Copyright (c) 2000, The JAP-Team 00003 All rights reserved. 00004 Redistribution and use in source and binary forms, with or without modification, 00005 are permitted provided that the following conditions are met: 00006 00007 - Redistributions of source code must retain the above copyright notice, 00008 this list of conditions and the following disclaimer. 00009 00010 - Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation and/or 00012 other materials provided with the distribution. 00013 00014 - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors 00015 may be used to endorse or promote products derived from this software without specific 00016 prior written permission. 00017 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00021 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS 00022 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00025 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00027 */ 00028 #ifndef __CAINFOSERVICE__ 00029 #define __CAINFOSERVICE__ 00030 #ifndef ONLY_LOCAL_PROXY 00031 //#include "CAMultiSignature.hpp" 00032 #include "CAFirstMix.hpp" 00033 #include "CAThread.hpp" 00034 #include "CAMutex.hpp" 00035 #include "CACmdLnOptions.hpp" 00036 #include "CAXMLBI.hpp" 00037 00038 #define NR_REQUEST_TYPES 2 00039 #define REQUEST_TYPE_POST 0 00040 #define REQUEST_TYPE_GET 1 00041 00042 #define NR_REQUEST_COMMANDS 7 00043 #define REQUEST_COMMAND_CONFIGURE 0 00044 #define REQUEST_COMMAND_HELO 1 00045 #define REQUEST_COMMAND_MIXINFO 2 00046 #define REQUEST_COMMAND_DYNACASCADE 3 00047 #define REQUEST_COMMAND_CASCADE 4 00048 #define REQUEST_COMMAND_STATUS 5 00049 #define REQUEST_COMMAND_TNC_DATA 6 00050 00051 #define ATTRIBUTE_SERIAL "serial" 00052 00053 #define LOCALE_DEFAULT LOCALE_EN 00054 #define LOCALE_EN "en" 00055 00056 class CAInfoService 00057 { 00058 #ifdef PAYMENT 00059 SINT32 getPaymentInstance(const UINT8* a_pstrPIID,CAXMLBI** pXMLBI, 00060 CASocketAddrINet* a_socketAddress); 00061 #endif 00062 00063 public: 00064 CAInfoService(); 00065 CAInfoService(CAMix* pMix); 00066 ~CAInfoService(); 00067 SINT32 sendMixHelo(SINT32 requestCommand=-1,const UINT8* param=NULL); 00068 //SINT32 sendMixInfo(const UINT8* pMixID); 00069 SINT32 sendCascadeHelo(); 00070 SINT32 sendStatus(bool bIncludeCerts); 00071 SINT32 start(); 00072 SINT32 stop(); 00073 SINT32 signal(); 00074 SINT32 getLevel(SINT32* puser,SINT32* prisk,SINT32* ptraffic); 00075 SINT32 getMixedPackets(UINT64& ppackets); 00076 #ifdef PAYMENT 00077 SINT32 getPaymentInstance(const UINT8* a_pstrPIID,CAXMLBI** pXMLBI); 00078 #endif 00079 bool isRunning() 00080 { 00081 return m_bRun; 00082 } 00083 //remove me 00084 /*SINT32 setSignature(CASignature* pSignature, CACertificate* a_ownCert, 00085 CACertificate* a_opCert);*/ 00086 SINT32 setMultiSignature(CAMultiSignature* pMultiSignature); 00087 00088 // added by ronin <ronin2@web.de> 00089 bool isConfiguring() 00090 { 00091 return m_bConfiguring; 00092 } 00093 00094 void setConfiguring(bool a_configuring) 00095 { 00096 m_bConfiguring = a_configuring; 00097 } 00098 00099 void setSerial(UINT64 a_serial) 00100 { 00101 m_serial = a_serial; 00102 } 00103 00104 UINT8* getStatusXMLAsString(bool bIncludeCerts,UINT32& len); 00105 00106 #ifdef DYNAMIC_MIX 00107 00108 SINT32 dynamicCascadeConfiguration(); 00109 bool newCascadeAvailable(); 00110 #endif 00111 public: 00112 static const UINT64 MINUTE; 00113 static const UINT64 SEND_LOOP_SLEEP; 00114 static const UINT64 SEND_CASCADE_INFO_WAIT; 00115 static const UINT64 SEND_MIX_INFO_WAIT; 00116 static const UINT64 SEND_STATUS_INFO_WAIT; 00117 static const UINT32 SEND_INFO_TIMEOUT_MS; 00118 static const UINT32 REPEAT_ON_STATUS_SENT_ERROR; 00119 private: 00120 static THREAD_RETURN TCascadeHelo(void *p); 00121 static THREAD_RETURN TCascadeStatus(void *p); 00122 static THREAD_RETURN TMixHelo(void *p); 00123 static THREAD_RETURN InfoLoop(void *p); 00124 SINT32 sendHelo(UINT8* a_strXML, UINT32 a_len, THREAD_RETURN (*a_thread)(void *), UINT8* a_strThreadName, SINT32 requestCommand, const UINT8* param = NULL); 00125 UINT8* getCascadeHeloXMLAsString(UINT32& len); 00126 SINT32 sendCascadeHelo(const UINT8* xml,UINT32 len,const CASocketAddrINet* a_socketAddress) const; 00127 00128 SINT32 sendStatus(const UINT8* strStatusXML,UINT32 len,const CASocketAddrINet* a_socketAddress) const; 00129 UINT8 **getOperatorTnCsAsStrings(UINT32 **lengths, XMLSize_t *nrOfTnCs); 00130 SINT32 sendOperatorTnCData(); 00131 00132 UINT8 *getMixHeloXMLAsString(UINT32& len); 00133 UINT8 *xmlDocToStringWithSignature(DOMNode *a_node, UINT32& a_len, bool bIncludeCerts); 00134 00135 SINT32 sendMixHelo(const UINT8* strMixHeloXML,UINT32 len,SINT32 requestCommand,const UINT8* param, 00136 const CASocketAddrINet* a_socketAddress); 00137 // added by ronin <ronin2@web.de> 00138 SINT32 handleConfigEvent(XERCES_CPP_NAMESPACE::DOMDocument* doc) const; 00139 00140 struct InfoServiceHeloMsg; 00141 volatile bool m_bRun; 00142 //CASignature* m_pSignature; 00143 CAMultiSignature* m_pMultiSignature; 00144 CAMix* m_pMix; 00145 CAThread* m_pthreadRunLoop; 00146 CAConditionVariable * m_pLoopCV; 00147 UINT64 m_lastMixedPackets; 00148 UINT64 m_serial; 00149 UINT32 m_minuts; 00150 SINT32 m_expectedMixRelPos; 00151 bool m_bConfiguring; 00152 #ifdef DYNAMIC_MIX 00153 bool m_bReconfig; 00154 #endif 00155 }; 00156 #endif 00157 #endif //ONLY_LOCAL_PROXY
1.7.6.1