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 __TYEDEFS__ 00029 #define __TYEDEFS__ 00030 enum NetworkType {UNKNOWN_NETWORKTYPE,RAW_TCP,RAW_UNIX,SSL_TCP,SSL_UNIX, HTTP_TCP}; 00031 00032 typedef UINT32 HCHANNEL; 00033 #define MIX_PAYLOAD_HTTP 0 00034 #define MIX_PAYLOAD_SOCKS 1 00035 00036 00037 #define MIXPACKET_SIZE 998 00038 00039 #define CHANNEL_DATA 0x00 00040 #define CHANNEL_OPEN 0x08 00041 00042 #define CHANNEL_TIMESTAMPS_UP 0x60 00043 #define CHANNEL_TIMESTAMPS_DOWN 0x90 00044 #define CHANNEL_CLOSE 0x01 00045 #define CHANNEL_SUSPEND 0x02 00046 #define CHANNEL_RESUME 0x04 00047 #define CHANNEL_DUMMY 0x10 00048 00049 #ifdef LOG_CRIME 00050 #define CHANNEL_SIG_CRIME 0x20 00051 #define CHANNEL_SIG_CRIME_ID_MASK 0x0000FF00 00052 #define CHANNEL_ALLOWED_FLAGS (CHANNEL_OPEN|CHANNEL_CLOSE|CHANNEL_SUSPEND|CHANNEL_RESUME|CHANNEL_TIMESTAMPS_UP|CHANNEL_TIMESTAMPS_DOWN|CHANNEL_SIG_CRIME|CHANNEL_SIG_CRIME_ID_MASK) 00053 #else 00054 #define CHANNEL_SIG_CRIME 0x0 00055 #define CHANNEL_SIG_CRIME_ID_MASK 0x0 00056 #ifdef NEW_FLOW_CONTROL 00057 #define CHANNEL_ALLOWED_FLAGS (CHANNEL_OPEN|CHANNEL_CLOSE|CHANNEL_TIMESTAMPS_UP|CHANNEL_TIMESTAMPS_DOWN) 00058 #else 00059 #define CHANNEL_ALLOWED_FLAGS (CHANNEL_OPEN|CHANNEL_CLOSE|CHANNEL_SUSPEND|CHANNEL_RESUME|CHANNEL_TIMESTAMPS_UP|CHANNEL_TIMESTAMPS_DOWN) 00060 #endif 00061 #endif 00062 00063 #define NEW_FLOW_CONTROL_FLAG 0x8000 00064 00065 #define INTEGRITY_ERROR_FLAG 0x4000 00066 00067 #define CONNECTION_ERROR_FLAG 0x01 00068 00069 #define DATA_SIZE 992 00070 #ifdef WITH_INTEGRITY_CHECK 00071 #define PAYLOAD_SIZE 973 00072 #else 00073 #define PAYLOAD_SIZE 989 00074 #endif 00075 #define GCM_MAC_SIZE 16 00076 #define PAYLOAD_LEN_MASK 0x03FF; 00077 00078 #if (defined(WIN32) ||defined(__sgi))&&!defined(__GNUC__) 00079 #define DO_PACKED 00080 #else 00081 #define DO_PACKED __attribute__ ((__packed__)) 00082 #endif 00083 00084 00085 #if (defined(WIN32) ||defined(__sgi))&&!defined(__GNUC__) 00086 #pragma pack( push, t_MixPacket ) 00087 #pragma pack(1) 00088 struct t_MixPacketPayload 00089 { 00090 UINT16 len; 00091 UINT8 type; 00092 UINT8 data[PAYLOAD_SIZE]; 00093 }; 00094 struct t_MixPacket 00095 { 00096 HCHANNEL channel; 00097 UINT16 flags; 00098 union 00099 { 00100 UINT8 data[DATA_SIZE]; 00101 struct t_MixPacketPayload payload; 00102 }; 00103 }; 00104 #pragma pack( pop, t_MixPacket ) 00105 #else 00106 struct t_MixPacketPayload 00107 { 00108 UINT16 len; 00109 UINT8 type; 00110 UINT8 data[PAYLOAD_SIZE]; 00111 } __attribute__ ((__packed__)); 00112 struct t_MixPacket 00113 { 00114 HCHANNEL channel; 00115 UINT16 flags; 00116 union 00117 { 00118 UINT8 data[DATA_SIZE]; 00119 struct t_MixPacketPayload payload; 00120 }; 00121 } __attribute__ ((__packed__)); // MUXPACKET __attribute__ ((__packed__)); 00122 #endif //WIN32 00123 00124 typedef t_MixPacket MIXPACKET; 00125 00126 #ifdef DATA_RETENTION_LOG 00127 #if (defined(WIN32) ||defined(__sgi))&&!defined(__GNUC__) 00128 #pragma pack( push, t_DataRetentionLogEntry ) 00129 #pragma pack(1) 00130 #endif 00131 struct __t__data_retention_log_entry 00132 { 00133 UINT32 t_in; 00134 UINT32 t_out; 00135 union t_union_entity 00136 { 00137 struct t_first_mix_data_retention_log_entry 00138 { 00139 HCHANNEL channelid; 00140 UINT8 ip_in[4]; 00141 UINT16 port_in; 00142 } DO_PACKED first; 00143 struct t_last_mix_data_retention_log_entry 00144 { 00145 HCHANNEL channelid; 00146 UINT8 ip_out[4]; 00147 UINT16 port_out; 00148 } DO_PACKED last; 00149 } DO_PACKED entity; 00150 } 00151 #if (defined(WIN32) ||defined(__sgi))&&!defined(__GNUC__) 00152 ; 00153 #pragma pack( pop, t_DataRetentionLogEntry ) 00154 #else 00155 DO_PACKED ; 00156 #endif 00157 00158 typedef struct __t__data_retention_log_entry t_dataretentionLogEntry; 00159 #endif //DATA_RETENION_LOG 00160 00161 00162 00163 //For that we store in our packet queue... 00164 //normally this is just the packet 00165 struct t_queue_entry 00166 { 00167 MIXPACKET packet; 00168 #if defined(DATA_RETENTION_LOG) 00169 t_dataretentionLogEntry dataRetentionLogEntry; 00170 #endif 00171 #if defined (LOG_PACKET_TIMES) || defined (LOG_CHANNEL) 00172 UINT64 timestamp_proccessing_start; 00173 UINT64 timestamp_proccessing_start_OP; 00174 UINT64 timestamp_proccessing_end; 00175 #endif 00176 #if defined (LOG_PACKET_TIMES) 00177 //without send/receive or queueing times 00178 UINT64 timestamp_proccessing_end_OP; 00179 #ifdef USE_POOL 00180 UINT64 pool_timestamp_in; 00181 UINT64 pool_timestamp_out; 00182 #endif 00183 #endif 00184 }; 00185 typedef struct t_queue_entry tQueueEntry; 00186 00187 //for that we store in our pool 00188 //normaly this is just the packet 00189 typedef tQueueEntry tPoolEntry; 00190 00191 /* 00192 struct t_proxytest_log 00193 { 00194 UINT16 len; 00195 time_t time; 00196 }; 00197 00198 typedef struct t_proxytest_log tProxytestLog; 00199 */ 00200 00202 struct t_replay_timestamp 00203 { 00204 UINT interval; //the current interval number 00205 UINT offset; //seconds since start of this interval 00206 }; 00207 00208 typedef struct t_replay_timestamp tReplayTimestamp; 00209 00210 struct t_mix_parameters 00211 { 00212 //stores the mix id of the mix 00213 UINT8* m_strMixID; 00214 // stores the local time in seconds since epoch for interval '0' for this mix 00215 UINT32 m_u32ReplayOffset; 00216 UINT16 m_u32ReplayBase; 00217 }; 00218 typedef struct t_mix_parameters tMixParameters; 00219 00220 00227 #define AUTH_NEW 0x0 00228 00230 #define AUTH_GOT_ACCOUNTCERT 0x1 00231 00233 #define AUTH_ACCOUNT_OK 0x2 00234 00236 #define AUTH_WAITING_FOR_FIRST_SETTLED_CC 0x4 00237 00239 #define AUTH_SENT_CC_REQUEST 0x20 00240 00242 #define AUTH_DATABASE 0x40 00243 00245 #define AUTH_BLOCKED 0x80 00246 00248 #define AUTH_SENT_ACCOUNT_REQUEST 0x100 00249 00250 #define AUTH_HARD_LIMIT_REACHED 0x200 00251 00253 #define AUTH_FAKE 0x400 00254 00256 #define AUTH_CHALLENGE_SENT 0x800 00257 00259 #define AUTH_ACCOUNT_EMPTY 0x1000 00260 00262 #define AUTH_FATAL_ERROR 0x2000 00263 00264 #define AUTH_OUTDATED_CC 0x4000 00265 00267 #define AUTH_INVALID_ACCOUNT 0x8000 00268 00269 // AI is waiting for a necessary message from JAP (e.g. response to challenge) 00270 #define AUTH_TIMEOUT_STARTED 0x10000 00271 00272 #define AUTH_MULTIPLE_LOGIN 0x20000 00273 00274 #define AUTH_UNKNOWN 0x40000 00275 00276 // we settled at least one CC for this account in this session 00277 #define AUTH_SETTLED_ONCE 0x80000 00278 00279 /* 00280 * The user corresponding to this entry has closed the connection. 00281 * Delete the entry as soon as possible. 00282 */ 00283 #define AUTH_DELETE_ENTRY 0x80000 00284 00285 #define AUTH_LOGIN_NOT_FINISHED 0x100000 00286 #define AUTH_LOGIN_FAILED 0x200000 00287 #define AUTH_LOGIN_SKIP_SETTLEMENT 0x400000 00288 00289 class CASignature; 00290 class CAAccountingControlChannel; 00291 class CAMutex; 00292 struct t_fmhashtableentry; 00297 struct t_accountinginfo 00298 { 00299 CAMutex* mutex; 00300 00302 UINT8 * pChallenge; 00303 00305 CASignature * pPublicKey; 00306 00308 UINT64 sessionPackets; 00309 00311 UINT64 transferredBytes; 00312 00314 UINT64 confirmedBytes; 00315 00317 UINT64 bytesToConfirm; 00318 00320 UINT64 accountNumber; 00321 00323 UINT64 userID; 00324 00325 struct t_fmhashtableentry *ownerRef; 00327 CAAccountingControlChannel* pControlChannel; 00328 00330 UINT32 authFlags; 00331 00333 SINT32 lastHardLimitSeconds; 00334 00336 SINT32 challengeSentSeconds; 00337 00339 UINT8* pstrBIID; 00340 00341 //time at which the timeout for waiting for the account certificate has been started 00342 SINT32 authTimeoutStartSeconds; 00343 00344 // the number of references to this entry in the ai queue 00345 UINT32 nrInQueue; 00346 00347 // new JonDo clients will send their version number as during challenge-response. 00348 UINT8* clientVersion; 00349 }; 00350 typedef struct t_accountinginfo tAiAccountingInfo; 00351 00352 #endif
1.5.6