Mixe for Privacy and Anonymity in the Internet
StdAfx.h
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 
00029 // stdafx.h : Include-Datei fuer Standard-System-Include-Dateien,
00030 //  oder projektspezifische Include-Dateien, die haeufig benutzt, aber
00031 //      in unregelmaessigen Abstaenden geaendert werden.
00032 
00033 #if !defined(AFX_STDAFX_H__9A5B051F_FF3A_11D3_9F5E_000001037024__INCLUDED_)
00034 #define AFX_STDAFX_H__9A5B051F_FF3A_11D3_9F5E_000001037024__INCLUDED_
00035 
00036 #define MIX_VERSION "00.11.08"
00037 
00038 // set to "true" if this is a testing/development version which is not meant for prodictive use
00039 #define MIX_VERSION_TESTING true
00040 
00041 #define MIX_VERSION_TESTING_TEXT "This is a testing/development version. Please do not expect it to work in a productive environment, and don't be surprised if you get unpredictive results or segmentation faults. If you don't like experiments, go and get the stable code.\n"
00042 
00043 #include "doxygen.h"
00044 
00045 #if defined(DEBUG)|| defined(_DEBUG)
00046   #undef DEBUG
00047   #undef _DEBUG
00048   #define DEBUG
00049   #define _DEBUG
00050 #endif
00051 
00052 #ifndef DELAY_USERS
00053   #ifndef PAYMENT
00054     #define DELAY_USERS
00055   #endif
00056 #endif
00057 
00058 
00059 //#define LOG_TRAFFIC_PER_USER //Log detail for traffic per user
00060 //#define LOG_CHANNEL //Log detail for traffic per channel
00061 //#define LOG_PACKET_TIMES //computes statistics about the processing time each packet needs
00062 //#define LOG_DIALOG
00063 //#define COMPRESSED_LOGS
00064 //#define DO_TRACE
00065 //#define PSEUDO_LOG
00066 //#define DELAY_CHANNELS //to enable max channel bandwidth
00067 //#define DELAY_USERS //to enable max per user bandwidth
00068 //#define DELAY_CHANNELS_LATENCY //to enable min latency per channel
00069 //#define HAVE_EPOLL //define if you have epoll support on your (Linux) system
00070 //#define MXML_DOM //define this if you wnat to use the Mix-XML library (www.minixml.org) instead of the default Xerces-C library
00071 //#define COUNTRY_STATS //collect stats about countries users come from
00072 //#define ONLY_LOCAL_PROXY //define to build only the local proxy (aka JAP)
00073 /* LERNGRUPPE: define this to get dynamic mixes */
00074 //#define DYNAMIC_MIX
00075 //#define SDTFA // specific logic needed by SDTFA, http://www.sdtfa.com
00076 //#define USE_OPENSSL_GCM //defin if you wnat to use the GCM implementation provided by OpenSSL (>=1.0.1)
00077 
00078 #define NO_INFOSERVICE_TRHEADS
00079 
00080 //#define LASTMIX_CHECK_MEMORY // only for internal debugging purpose
00081 //#define PRINT_THREAD_STACK_TRACE //Usefull for debugging output of stack trace if mix dies...
00082 //#define ENABLE_GPERFTOOLS_CPU_PROFILER //Enables the usage of the Goggle GPerfTools CPU Profiler for profiling the operation of the Mix
00083 //#define ENABLE_GPERFTOOLS_HEAP_CHECKER //Enables the usage of the Goggle GPerfTools heap chekcer for detecting memory leaks
00084 
00085 //#define DATA_RETENTION_LOG //define if you need to store logs according to German data retention
00086 //#define INTEL_IPP_CRYPTO //define if you want to use the crypto routines of the Intel Performance Primitives
00087 //#define __UNIT_TEST__ //define if you want to compile the unit tests
00088 //#define EXPORT_ASYM_PRIVATE_KEY //define if you want to be able to export the private key of an assymetric key (only used for debugging purposes..)
00089 
00090 
00091 #if !defined(PRINT_THREAD_STACK_TRACE) && defined (DEBUG)&& ! defined(ONLY_LOCAL_PROXY)
00092   #define PRINT_THREAD_STACK_TRACE
00093 #endif
00094 
00095 #if defined(LOG_DIALOG)
00096   #ifndef LOG_CHANNEL
00097     #define LOG_CHANNEL
00098   #endif
00099   #ifndef COUNTRY_STATS
00100     #define COUNTRY_STATS
00101   #endif
00102 #endif
00103 #if (defined(LOG_CHANNEL)) && !defined(LOG_TRAFFIC_PER_USER)
00104   #define LOG_TRAFFIC_PER_USER
00105 #endif
00106 
00107 #ifdef COUNTRY_STATS
00108   #define LOG_COUNTRIES_INTERVALL 6 //how often to log the country stats (multiplied by 10 seconds)
00109 #endif
00110 
00111 #ifdef DELAY_CHANNELS
00112   #ifndef DELAY_CHANNEL_TRAFFIC
00113     #define DELAY_CHANNEL_TRAFFIC 10000 //Traffic in bytes after which (download direction) the channel is delayed
00114   #endif
00115   //Delay is at the moment constant and calculate as
00116   // 1000/DELAY_BUCKET_GROW_INTERVALL*DELAY_BUCKET_GROW bytes/s
00117   #ifndef DELAY_CHANNEL_KBYTE_PER_SECOND
00118     #define DELAY_BUCKET_GROW_INTERVALL 100 //Time in ms
00119     #define DELAY_BUCKET_GROW PAYLOAD_SIZE //Grow in bytes
00120   //so we have around 10 KByte/s at the moment
00121   #else
00122     #define DELAY_BUCKET_GROW_INTERVALL (1000/DELAY_CHANNEL_KBYTE_PER_SECOND) //Time in ms
00123     #define DELAY_BUCKET_GROW PAYLOAD_SIZE //Grow in bytes
00124   #endif
00125 #endif
00126 
00127 #ifdef DELAY_USERS
00128   #ifndef DELAY_USERS_TRAFFIC
00129     #define DELAY_USERS_TRAFFIC 0 //Traffic in packets after which (download direction) the user is delayed
00130   #endif
00131   //Delay is at the moment constant and calculate as
00132   // 1000/DELAY_BUCKET_GROW_INTERVALL*DELAY_BUCKET_GROW bytes/s
00133   #ifndef DELAY_USERS_PACKETS_PER_SECOND
00134     #define DELAY_USERS_BUCKET_GROW_INTERVALL 100 //Time in ms
00135     #define DELAY_USERS_BUCKET_GROW 10 //Grow in packets
00136   //so we have around 10 KByte/s at the moment
00137   #else
00138     #define DELAY_USERS_BUCKET_GROW_INTERVALL 1000 //Time in ms
00139     #define DELAY_USERS_BUCKET_GROW DELAY_USERS_PACKETS_PER_SECOND //Grow in bytes
00140   #endif
00141 #endif
00142 #ifdef DELAY_CHANNELS_LATENCY
00143   #define DELAY_CHANNEL_LATENCY 0 //min latency defaults to 0 milliseconds
00144 #endif
00145 
00146 #if defined LASTMIX_CHECK_MEMORY && ! defined(QUEUE_SIZE_LOG)
00147   #define QUEUE_SIZE_LOG
00148 #endif
00149 //#define LOG_CRIME
00150 //#define PAYMENT //to enable payment support, now use configure --enable-payment..
00151 //#define NO_LOOPACCEPTUSER //to disable user accept thread for First Mix
00152 
00153 //#define USE_POOL
00154 //#define NEW_MIX_TYPE // to enable the new 1:x mix protocol
00155 //#define WITH_CONTROL_CHANNELS_TEST //enable a Test control Channel
00156 #define NEW_FLOW_CONTROL //enable for the new flow control mechanism --> now enabled by default (i.e. can not be disbaled anymore!)
00157 #define NEW_CHANNEL_ENCRYPTION //enable the new protcol version which uses RSA-OAEP for key transport and two keys for upstream/downstream channel cryption (--> now enabled by default (i.e. can not be disbaled anymore!)
00158 //#define WITH_INTEGRITY_CHECK //enable AES-GCM encryption for data channels
00159 
00160 //#define REPLAY_DETECTION // enable to prevent replay of mix packets
00161 #define REPLAY_TIMESTAMP_PROPAGATION_INTERVALL 1 //How often (in minutes) should the current replay timestamps be propagate
00162 
00163 #define KEEP_ALIVE_TRAFFIC_RECV_WAIT_TIME  75000 //How long to wait for a Keep-Alive (or any other packet)
00164                                                      //before we believe that the connection is broken (in ms)
00165 #define KEEP_ALIVE_TRAFFIC_SEND_WAIT_TIME 65000 //How long to wait before we sent a dummy a Keep-Alive-Traffic
00166 
00167 //#define ECC
00168 //#define SSL_HACK //???
00169 
00170 #if defined(PAYMENT) && ! defined(SSL_HACK)
00171   #define SSL_HACK
00172 #endif
00173 
00174 //#define REPLAY_DATABASE_PERFORMANCE_TEST //to perform a performance test of the replay db
00175 //Some constants
00176 #define MAX_POLLFD 8192 //How many sockets to support at max
00177 
00178 #define CLIENTS_PER_IP 10 //how many jap connections per IP are allowed?
00179 #define CHANNELS_PER_CLIENT 50 //how many channels per jap client are allowed?
00180 
00181 #define FIRST_MIX_RECEIVE_SYM_KEY_FROM_JAP_TIME_OUT 40000 //Timout in waiting for login information to receive from JAP (10 seconds)
00182 #define LAST_MIX_TO_PROXY_CONNECT_TIMEOUT 2000 //Connection timeout for last mix to proxy connections 2 Seconds...
00183 #define AI_LOGIN_SO_TIMEOUT (UINT32) 10000 //5 Seconds...
00184 #define LAST_MIX_TO_PROXY_SEND_TIMEOUT (UINT32)5000 //5 Seconds...
00185 #define MIX_TO_INFOSERVICE_TIMEOUT 30000 //How long to wait when communicating with the InfoService? (ms)
00186 #define NUM_LOGIN_WORKER_TRHEADS 10//How many working threads for login *do not change this until you really know that you are doing!* ??
00187 #define MAX_LOGIN_QUEUE 500 //how many waiting entries in the login queue *do not change this until you really know that you are doing!*??
00188 
00189 #if defined(PAYMENT) || defined(MANIOQ)
00190   #define MAX_USER_SEND_QUEUE 100000 //How many bytes could be in each User's send queue, before we suspend the belonging channels
00191   #define MAX_DATA_PER_CHANNEL 100000
00192   #define USER_SEND_BUFFER_RESUME 10000
00193 #else
00194   //EXPERIMENTAL: reduce user-buffers for free mixes by factor 10
00195   #define MAX_USER_SEND_QUEUE 10000 //How many bytes could be in each User's send queue, before we suspend the belonging channels
00196   #define MAX_DATA_PER_CHANNEL 10000
00197   #define USER_SEND_BUFFER_RESUME 1000
00198 #endif
00199 
00200 #define PAYMENT_ACCOUNT_CERT_TIMEOUT 180 //Timeout for receiving the Payment certificate in seconds
00201 #define CLEANUP_THREAD_SLEEP_INTERVAL 60 //sleep interval for payment blocked ip list
00202 #define BALANCE_REQUEST_TIMEOUT 60 //Timeout for Balance requests
00203 
00204 #define MAX_SIGNATURE_ELEMENTS 10  // maximum of interpreted XML signature elements
00205 
00206 #define FLOW_CONTROL_SENDME_HARD_LIMIT 160 //last mix stops sending after this unacked packets
00207 #define FLOW_CONTROL_SENDME_SOFT_LIMIT 80 //last mix expect to get a 'SENDME' after this unacked packets
00208 
00209 #if defined(PAYMENT) || defined(MANIOQ)
00210   #define MAX_READ_FROM_PREV_MIX_QUEUE_SIZE 10000000
00211   #define MAX_READ_FROM_NEXT_MIX_QUEUE_SIZE 10000000 //How many bytes could be in the incoming queue ??
00212   #define MAX_MIXIN_SEND_QUEUE_SIZE 10000000
00213   #define MAX_NEXT_MIX_QUEUE_SIZE 10000000
00214 #else
00215   //EXPERIMENTAL: reduce intermix-buffers for free mixes by factor 10
00216   #define MAX_READ_FROM_PREV_MIX_QUEUE_SIZE 1000000
00217   #define MAX_READ_FROM_NEXT_MIX_QUEUE_SIZE 1000000 //How many bytes could be in the incoming queue ??
00218   #define MAX_MIXIN_SEND_QUEUE_SIZE 1000000
00219   #define MAX_NEXT_MIX_QUEUE_SIZE 1000000
00220 #endif
00221 //#define FORCED_DELAY
00222 //#define MIN_LATENCY 250
00223 
00224 #define DEFAULT_INFOSERVICE "141.76.45.37"
00225 
00226 #ifndef MIX_POOL_SIZE
00227   #define MIX_POOL_SIZE 10  //packets in the Mix pool
00228 #endif
00229 #define MIX_POOL_TIMEOUT 200 //home long to wait (in ms) before a dummy is put in the pool
00230 #define DUMMY_CHANNEL 0
00231 
00232 #define FM_PACKET_STATS_LOG_INTERVALL 1 //Intervall in Minutes for loggin packet stats for the first Mix
00233 #define LM_PACKET_STATS_LOG_INTERVALL 1 //Intervall in Minutes for loggin packet stats for the last Mix
00234 
00235 #define MIX_CASCADE_PROTOCOL_VERSION_0_1_2 12  //with integrity check and new channel encryption 
00236 #define MIX_CASCADE_PROTOCOL_VERSION_0_1_1 11  //with integrity check and new channel encryption --> never worked correctly
00237 #define MIX_CASCADE_PROTOCOL_VERSION_0_1_0 10  //with new channel encryption
00238 //#define MIX_CASCADE_PROTOCOL_VERSION_0_9 9  //with new payment protocol
00239 #define MIX_CASCADE_PROTOCOL_VERSION_0_8 8  //with replay detection + control channels + first mix symmetric
00240 #define MIX_CASCADE_PROTOCOL_VERSION_0_7 7  //with replay detection + control channels (obsolete)
00241 //#define MIX_CASCADE_PROTOCOL_VERSION_0_6 6  //with new flow control (not used, because flow control is a last Mix only issue)
00242 #define MIX_CASCADE_PROTOCOL_VERSION_0_5 5  //with control channels (obsolte - allway with control channels)
00243 #define MIX_CASCADE_PROTOCOL_VERSION_0_4 4  //symmetric communication to first mix -> new default protocol
00244 #define MIX_CASCADE_PROTOCOL_VERSION_0_3 3 //with reply detection [deprecated - not in use anymore!]
00245 #define MIX_CASCADE_PROTOCOL_VERSION_0_2 2 //old normal protocol [deprecated - not in use anymore!]
00246 
00247 #ifdef REPLAY_DETECTION
00248   #define MIX_CASCADE_PROTOCOL_VERSION "0.81"
00249 //#elif defined(PAYMENT)
00250   //#define MIX_CASCADE_PROTOCOL_VERSION "0.9"
00251 #elif defined (WITH_INTEGRITY_CHECK)
00252   #define MIX_CASCADE_PROTOCOL_VERSION "0.12"
00253 #else
00254   #define MIX_CASCADE_PROTOCOL_VERSION "0.10" //"0.10tc"
00255 #endif
00256 
00257 
00258 #define PAYMENT_VERSION "2.0"
00259 
00260 #if defined (_WIN32) &&!defined(__CYGWIN__)
00261   //For Visual C++    #if defined(_MSC_VER)
00262   //For Borland C++    #if defined(__BCPLUSPLUS__)
00263   #define _CRT_SECURE_NO_DEPRECATE
00264   #define _CRT_SECURE_NO_WARNINGS
00265   #define WIN32_LEAN_AND_MEAN
00266   #if _MSC_VER > 1000
00267     #pragma once
00268   #endif // _MSC_VER > 1000
00269   #define _WIN32_WINDOWS 0x0410
00270   #include <winsock2.h>
00271   #if defined(_MSC_VER) &&defined (_DEBUG)
00272     #include <crtdbg.h>
00273     #define HAVE_CRTDBG
00274   #endif
00275   #define socklen_t int
00276   #define MSG_NOSIGNAL 0
00277     #include <io.h>
00278   #include <conio.h>
00279   #include <sys/timeb.h>
00280   #include <process.h>
00281   #ifdef _MSC_VER
00282     #define ftime _ftime
00283     #define timeb _timeb
00284   #endif
00285   #include <malloc.h>
00286   #define SET_NET_ERROR(x)
00287   #define GET_NET_ERROR (WSAGetLastError())
00288   #define GET_NET_ERROR_STR(x) ("Unknown error")
00289   #define RESETERROR errno=0;
00290   #define GETERROR (errno)
00291   #define ERR_INTERN_TIMEDOUT WSAETIMEDOUT
00292   #define ERR_INTERN_CONNREFUSED WSAECONNREFUSED
00293   #define ERR_INTERN_WOULDBLOCK WSAEWOULDBLOCK
00294   #define ERR_INTERN_SOCKET_CLOSED WSAENOTSOCK
00295   #define MSG_DONTWAIT 0
00296   #define O_NONBLOCK 0
00297   #define O_BLOCK 0
00298   #define SHUT_RDWR SD_BOTH
00299   #define HAVE_VSNPRINTF
00300   #define HAVE_SNPRINTF
00301   #if _MSC_VER <1500
00302     #define vsnprintf _vsnprintf
00303   #endif
00304   #define snprintf _snprintf
00305   #define getpid _getpid
00306   #define strncasecmp _strnicmp
00307   #define HAVE_PTHREAD_MUTEX_INIT
00308   #define HAVE_PTHREAD_COND_INIT
00309   #define HAVE_SEM_INIT
00310   #define BYTE_ORDER_LITTLE_ENDIAN
00311 #else
00312   //__linux is not defined on power pc so we define our own __linux if __linux__ is defined
00313   #if defined(__linux__) && !defined(__linux)
00314     #define __linux
00315   #endif
00316   #if defined(CWDEBUG)
00317     #include <libcw/sysd.h>
00318     #include <libcw/debug.h>
00319   #endif
00320 
00321   #ifdef HAVE_CONFIG_H
00322     #include "config.h"
00323     #ifndef HAVE_SOCKLEN_T
00324       typedef int socklen_t;
00325     #endif
00326   #else
00327     #define HAVE_UNIX_DOMAIN_PROTOCOL
00328     #define HAVE_VSNPRINTF
00329     #define HAVE_SNPRINTF
00330     #define HAVE_POLL
00331     #define HAVE_O_SYNC
00332     #define HAVE_PTHREAD_MUTEX_INIT
00333     #define HAVE_PTHREAD_COND_INIT
00334     #define HAVE_SEM_INIT
00335     #ifndef __linux
00336       #define HAVE_TCP_KEEPALIVE
00337     #endif
00338     #ifdef __sgi
00339       #undef HAVE_TCP_KEEPALIVE
00340     #endif
00341     #ifdef __FreeBSD__
00342       #undef HAVE_TCP_KEEPALIVE
00343       #undef HAVE_O_SYNC
00344       #define HAVE_O_FSYNC
00345     #endif
00346     #ifdef __CYGWIN__
00347       #undef HAVE_TCP_KEEPALIVE
00348       #define MSG_DONTWAIT 0
00349     #endif
00350     #if !defined(__FreeBSD__)&&!defined(__linux)
00351       typedef int socklen_t;
00352     #endif
00353     #ifndef O_BINARY
00354       #define O_BINARY 0
00355     #endif
00356     #ifndef MAX_PATH
00357       #define MAX_PATH 4096
00358     #endif
00359     #ifdef __sgi
00360       #undef HAVE_VSNPRINTF
00361       #undef HAVE_SNPRINTF
00362       #include <alloca.h>
00363     #endif
00364     #if !defined( __linux) &&!defined(__CYGWIN__)
00365       #include <sys/filio.h>
00366       #define MSG_NOSIGNAL 0
00367     #endif
00368   #endif //Have config.h
00369 
00370   //Byte order defines
00371   #if !defined(BYTE_ORDER_LITTLE_ENDIAN) && ! defined(BYTE_ORDER_BIG_ENDIAN)
00372     #ifndef BYTE_ORDER
00373       #error "You MUST define either BYTE_ORDER_BIG_ENDIAN or BYTE_ORDER_LITTLE_ENDIAN"
00374     #else
00375       #if BYTE_ORDER == BIG_ENDIAN
00376         #define BYTE_ORDER_BIG_ENDIAN
00377       #else
00378         #define BYTE_ORDER_LITTLE_ENDIAN
00379       #endif
00380     #endif // BYTE_ORDER
00381   #endif //not byte order given
00382 
00383   #ifdef HAVE_FILIO
00384     #include <sys/filio.h>
00385   #endif
00386   #ifdef HAVE_POLL
00387     #include <poll.h>
00388   #endif
00389   #ifdef HAVE_EPOLL
00390     #include <sys/epoll.h>
00391   #endif
00392   #ifdef HAVE_MALLOC_H
00393       #include <malloc.h>
00394   #endif
00395   #include <sys/ioctl.h>
00396   #include <sys/types.h>
00397   #include <sys/socket.h>
00398   #include <pwd.h>
00399   #include <sys/un.h>
00400   #include <sys/time.h>
00401   #include <netinet/in.h>
00402   #include <arpa/inet.h>
00403   #include <netdb.h>
00404   #include <unistd.h>
00405   #include <stdlib.h>
00406   #include <strings.h>
00407   #include <syslog.h>
00408   #include <stdarg.h>
00409   #include <memory.h>
00410   #include <sys/resource.h>
00411   #include <sys/wait.h>
00412   #include <termios.h>
00413 
00414   #include <ctype.h>
00415     typedef struct sockaddr SOCKADDR;
00416   typedef SOCKADDR* LPSOCKADDR;
00417   #define SOCKET int
00418   typedef struct hostent HOSTENT;
00419   #define ioctlsocket(a,b,c) ioctl(a,b,c)
00420   #define closesocket(s) close(s)
00421   #define SOCKET_ERROR -1
00422   #define INVALID_SOCKET -1
00423   #define SD_RECEIVE 0
00424   #define SD_SEND 1
00425   #define SD_BOTH 2
00426   #define GET_NET_ERROR (errno)
00427   #define SET_NET_ERROR(x) (errno = x)
00428   #define GET_NET_ERROR_STR(x) (errno == E_TIMEDOUT ? "Connection timed out." : (errno == E_SOCKETCLOSED ? "Socket is closed." : strerror(x)))
00429   #define RESETERROR errno=0;
00430   #define GETERROR (errno)
00431   #define ERR_INTERN_TIMEDOUT ETIMEDOUT
00432   #define ERR_INTERN_CONNREFUSED ECONNREFUSED
00433   #define ERR_INTERN_WOULDBLOCK EAGAIN
00434   #define ERR_INTERN_SOCKET_CLOSED EBADF
00435   #ifndef INADDR_NONE
00436     #define INADDR_NONE -1
00437   #endif
00438   #ifndef AF_LOCAL
00439     #define AF_LOCAL AF_UNIX
00440   #endif
00441   #if !defined(HAVE_MSG_DONTWAIT)&&!defined(MSG_DONTWAIT)
00442     #define MSG_DONTWAIT 0
00443   #endif
00444 #endif //WIn32 ?
00445 
00446 #include "basetypedefs.h"
00447 
00448 #include <assert.h>
00449 
00450 #include <pthread.h>
00451 //the following definition are just for threading support beside pthread
00452 #undef USE_SEMAPHORE //normally we do not need semaphores
00453 #ifdef HAVE_PTHREAD_COND_INIT
00454   #define HAVE_PTHREAD_CV //normally we use the pthread conditional variables
00455 #endif
00456 #ifdef HAVE_PTHREAD_MUTEX_INIT
00457   #define HAVE_PTHREAD_MUTEXES //normally we use the pthread mutexs
00458 #endif
00459 
00460 #if !defined(HAVE_PTHREAD_CV) || !defined (HAVE_PTHREAD_MUTEXES) //if we do not have pthread mutexes or cvs we emulate them with semphores
00461  #define USE_SEMAPHORE
00462 #endif
00463 
00464 #ifdef HAVE_SEM_INIT
00465   #define HAVE_PTHREAD_SEMAPHORE //normally we use pthread semaphores
00466 #endif
00467 
00468 #ifdef USE_SEMAPHORE
00469   #ifdef HAVE_PTHREAD_SEMAPHORE
00470     #include <semaphore.h>
00471   #endif
00472 #endif
00473 
00474 #ifdef OS_TUDOS
00475   #define Assert
00476   #define THREAD_RETURN void
00477   #define THREAD_RETURN_ERROR return
00478   #define THREAD_RETURN_SUCCESS return
00479   #include <l4/thread/thread.h>
00480   #include <l4/util/macros.h>
00481   #include <l4/env/errno.h>
00482   #undef Assert
00483   #undef ASSERT
00484 #else
00485   #define THREAD_RETURN void*
00486   #define THREAD_RETURN_ERROR return(NULL)
00487   #define THREAD_RETURN_SUCCESS return (NULL)
00488 #endif
00489 
00490 #ifndef DEBUG
00491   #define ASSERT(cond,msg)
00492 #else
00493   #define ASSERT(cond,msg) {if(!(cond)){CAMsg::printMsg(LOG_DEBUG,"ASSERT: %s (File: %s, Line: %u)\n",msg,__FILE__,__LINE__);}}
00494 #endif
00495 
00496 
00497 #include <stdio.h>
00498 #include <time.h>
00499 #include <sys/types.h>
00500 #include <fcntl.h>
00501 #include <limits.h>
00502 #include <sys/stat.h>
00503 #include <signal.h>
00504 #include <errno.h>
00505 #include "trio/trio.hpp"
00506 #include "trio/triostr.hpp"
00507 #include "popt/system.h"
00508 #include "popt/popt.h"
00509 #include <openssl/rsa.h>
00510 #include <openssl/aes.h>
00511 #include <openssl/rand.h>
00512 #include <openssl/evp.h>
00513 #ifdef USE_OPENSSL_GCM
00514   extern "C"
00515     {
00516       #include <openssl/modes.h>
00517     }
00518 #endif
00519 #ifndef ONLY_LOCAL_PROXY
00520   #include <openssl/asn1.h>
00521   #include <openssl/pkcs12.h>
00522   #include <openssl/x509v3.h>
00523   #include <openssl/ssl.h>
00524   #include <openssl/dsa.h>
00525   #include <openssl/sha.h>
00526   #include <openssl/md5.h>
00527 #endif
00528 
00529 //For DOM
00530 #ifdef MXML_DOM
00531   #include <mxml.h>
00532   #include "xml/dom/mxml/mxmlDOM.hpp"
00533 #else
00534 #include <util/XercesDefs.hpp>
00535 #include <util/PlatformUtils.hpp>
00536 #include <util/XMLString.hpp>
00537 #include <util/XMLUniDefs.hpp>
00538 #include <framework/XMLFormatter.hpp>
00539 #include <util/TranscodingException.hpp>
00540 #include <framework/MemBufInputSource.hpp>
00541 
00542 /*#if (XERCES_VERSION_MAJOR >1)
00543   #include <dom/deprecated/DOM.hpp>
00544   #include <dom/deprecated/DOMParser.hpp>
00545 #else
00546   #include <dom/DOM.hpp>
00547   #include <parsers/DOMParser.hpp>
00548 #endif
00549 */
00550 #include <dom/DOM.hpp>
00551 #include <parsers/XercesDOMParser.hpp>
00552 
00553 #if (_XERCES_VERSION >= 20200)
00554     XERCES_CPP_NAMESPACE_USE
00555 #endif
00556 
00557 #endif //wich DOM-Implementation to use?
00558 
00559 //For large file support
00560 #ifndef O_LARGEFILE
00561   #define O_LARGEFILE 0
00562 #endif
00563 
00564 //O_SYNC defined ???
00565 #ifndef HAVE_O_SYNC
00566   #ifdef HAVE_O_FSYNC
00567     #define O_SYNC O_FSYNC
00568   #else
00569     #define O_SYNC 0
00570   #endif
00571 #endif
00572 
00573 //The min() macro
00574 #ifndef min
00575   #define min(a,b) (( (a) < (b) ) ? (a):(b) )
00576 #endif
00577 
00578 //The max() macro
00579 #ifndef max
00580   #define max(a,b) (((a) > (b) ) ? (a):(b))
00581 #endif
00582 
00583 //For MySQL
00584 #if defined(COUNTRY_STATS)
00585     #ifdef HAVE_CONFIG_H
00586   #ifdef HAVE_MYSQL_MYSQL_H
00587       #include <mysql/mysql.h>
00588   #else
00589       #include <mysql.h>
00590   #endif
00591     #else //HAVE_CONFIG_H
00592   #include <mysql/mysql.h>
00593     #endif
00594 #endif
00595 
00596 //For Payment
00597 #ifdef PAYMENT
00598   #ifdef HAVE_CONFIG_H
00599     #ifdef HAVE_POSTGRESQL_LIBPQ_FE_H
00600       #include <postgresql/libpq-fe.h>
00601     #elif defined(HAVE_PGSQL_LIBPQ_FE_H)
00602       #include <pgsql/libpq-fe.h>
00603     #else
00604       #include <libpq-fe.h>
00605     #endif
00606   #elif defined(__FreeBSD__) ||defined (_WIN32)
00607     #include <libpq-fe.h>
00608       #else
00609     #include <postgresql/libpq-fe.h>
00610   #endif
00611 #endif
00612 //Compressed Logs
00613 #ifdef COMPRESSED_LOGS
00614 #include <zlib.h>
00615 #endif
00616 
00617 //For CPPUnit Test
00618 #ifdef __UNIT_TEST__
00619   #include <cppunit/ui/text/TestRunner.h>
00620   #include <cppunit/extensions/HelperMacros.h>
00621   #include <cppunit/TestFixture.h>
00622   #include <cppunit/TestResult.h>
00623   #include <cppunit/TestResultCollector.h>
00624   #include <cppunit/BriefTestProgressListener.h>
00625   #include <cppunit/CompilerOutputter.h>
00626   //#include <cppunit/ui/qt/TestRunner.h>
00627 #endif
00628 
00629 //Mix Version Info as multiline String
00630 #ifdef XERCES_FULLVERSIONDOT
00631   #define MY_XERCES_VERSION XERCES_FULLVERSIONDOT
00632 #elif defined(Xerces_DLLVersionStr)
00633   #define MY_XERCES_VERSION Xerces_DLLVersionStr
00634 #else
00635   #define MY_XERCES_VERSION "unknown"
00636 #endif
00637 
00638 #ifdef ENABLE_GPERFTOOLS_CPU_PROFILER
00639   #include <google/profiler.h>
00640 #endif
00641 
00642 #ifdef INTEL_IPP_CRYPTO
00643   #include <ippcp.h>
00644 #endif
00645 
00646 #ifdef PAYMENT
00647   #define PAYMENT_VERSION_INFO " (payment)"
00648   #define PAYMENT_COMPATIBILITY "Payment"
00649 #else
00650   #define PAYMENT_VERSION_INFO
00651   #define PAYMENT_COMPATIBILITY
00652 #endif
00653 
00654 #ifdef DATA_RETENTION_LOG
00655   #define DATA_RETENTION_LOG_INFO " (with data retention log)"
00656 #else
00657   #define DATA_RETENTION_LOG_INFO
00658 #endif
00659 
00660 #define NEW_FLOW_CONTROL_INFO " (with new flow control)"
00661 #define NEW_FLOW_CONTROL_COMPATIBILITY "NewFlowControl"
00662 
00663 #define NEW_CHANNEL_ENCRYPTION_INFO " (with enhanced channel encryption)"
00664 #define NEW_CHANNEL_ENCRYPTION_COMPATIBILITY "NewChannelEncryption"
00665 
00666 #ifdef WITH_INTEGRITY_CHECK
00667   #define WITH_INTEGRITY_CHECK_INFO " (with integrity check for data channels)"
00668   #define WITH_INTEGRITY_CHECK_COMPATIBILITY "WithIntegrityCheck"
00669 #else
00670   #define WITH_INTEGRITY_CHECK_INFO
00671   #define WITH_INTEGRITY_CHECK_COMPATIBILITY
00672 #endif
00673 
00674 #define MIX_VERSION_INFO "Mix-Version: " MIX_VERSION PAYMENT_VERSION_INFO DATA_RETENTION_LOG_INFO NEW_FLOW_CONTROL_INFO NEW_CHANNEL_ENCRYPTION_INFO WITH_INTEGRITY_CHECK_INFO "\nUsing: " OPENSSL_VERSION_TEXT "\nUsing Xerces-C: " MY_XERCES_VERSION "\n"
00675 #define MIX_VERSION_COMPATIBILITY PAYMENT_COMPATIBILITY " " NEW_FLOW_CONTROL_COMPATIBILITY " " NEW_CHANNEL_ENCRYPTION_COMPATIBILITY " " WITH_INTEGRITY_CHECK_COMPATIBILITY
00676 
00677 #include "errorcodes.hpp"
00678 #include "typedefs.hpp"
00679 #include "controlchannelids.h"
00680 #include "gcm/gcm.h"
00681 #ifdef PAYMENT
00682   #define MAX_ACCOUNTNUMBER 999999999999ULL
00683   #define MIN_ACCOUNTNUMBER 100000000000ULL
00684   #define ACCOUNT_NUMBER_SIZE 12
00685 #endif
00686 
00687 #endif // !defined(AFX_STDAFX_H__9A5B051F_FF3A_11D3_9F5E_000001037024__INCLUDED_)