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