Mixe for Privacy and Anonymity in the Internet
proxytest.cpp
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 // proxytest.cpp : Definiert den Einsprungpunkt fuer die Konsolenanwendung.
29 //
30 
31 #include "StdAfx.h"
32 
33 #include "CACmdLnOptions.hpp"
34 #include "CAMsg.hpp"
35 #include "CALocalProxy.hpp"
36 #include "CAQueue.hpp"
37 #include "CAThreadList.hpp"
38 #include "CAStatusManager.hpp"
39 #include "CALibProxytest.hpp"
40 #include "CACryptoBenchmark.hpp"
41 #include "UDPMix/CAUDPMixMiddle.hpp"
42 
43 #ifdef _DEBUG //For FreeBSD memory checking functionality
44  const char* _malloc_options="AX";
45 #endif
46 
47 #ifdef REPLAY_DATABASE_PERFORMANCE_TEST
48 #include "CAReplayDatabase.hpp"
49 #endif
50 
51 #ifdef DO_MIDDLE_MIX_BENCHMARK
52 #include "benchmarking/CAMiddleMixBenchmarkDummy.hpp"
53 #endif
54 
55 
56 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INLUDE_LAST_MIX
57 
58 #ifdef INCLUDE_MIDDLE_MIX
59 #include "CAMiddleMix.hpp"
60 #endif
61 
62 #ifdef INCLUDE_LAST_MIX
63  #ifdef NEW_MIX_TYPE
64  /* use TypeB mixes */
65  #include "TypeB/CAFirstMixB.hpp"
66  #include "TypeB/CALastMixB.hpp"
67  #else
68  #include "TypeA/CAFirstMixA.hpp"
69  #include "TypeA/CALastMixA.hpp"
70  #endif
71 #endif
72 
73 
74 // The Mix....
75 CAMix* pMix=NULL;
76 
77 
78 
79 #endif
80 
81 #ifndef ONLY_LOCAL_PROXY
82  #include "xml/DOM_Output.hpp"
83  #include "CAMix.hpp"
84  #ifdef LOG_CRIME
85  #include "tre/tre.h"
86  #endif
87  #ifdef NEW_MIX_TYPE
88  /* use TypeB mixes */
89  #include "TypeB/CAFirstMixB.hpp"
90  #include "TypeB/CALastMixB.hpp"
91  #else
92  #include "TypeA/CAFirstMixA.hpp"
93  #include "TypeA/CALastMixA.hpp"
94  #endif
95  #include "CALogPacketStats.hpp"
96  #include "CATLSClientSocket.hpp"
97 
98 #ifdef REPLAY_DATABASE_PERFORMANCE_TEST
99  #include "CAReplayDatabase.hpp"
100 #endif
101 #endif
102 
103 bool bTriedTermination = false;
104 
105 #if defined(HAVE_CRTDBG)
106  _CrtMemState* s1;
107  _CrtMemState s2, s3;
108 #endif
109 
110 #ifndef _WIN32
111  #ifdef _DEBUG
112  void signal_broken_pipe( int sig)
113  {
114  CAMsg::printMsg(LOG_INFO,"Hm.. Broken Pipe.... Who cares!\n");
115  signal(SIGPIPE,signal_broken_pipe);
116  }
117  #endif
118 #endif
119 
120 
123  {
124  if(CALibProxytest::getOptions()==NULL)
125  {
126  return;
127  }
128  UINT8 strPidFile[512];
129  if(CALibProxytest::getOptions()->getPidFile(strPidFile,512)==E_SUCCESS)
130  {
131  if(::remove((char*)strPidFile)!=0)
132  {
133 #ifndef _WIN32
134  int old_uid=geteuid(); //old uid... stored if we have to switch to root
135  seteuid(0);
136  ::remove((char*)strPidFile);
137  seteuid(old_uid);
138 #endif
139  }
140  }
141  }
142 
143 
145 void init()
146  {
148  }
149 
151 void cleanup()
152  {
153 #ifdef ENABLE_GPERFTOOLS_CPU_PROFILER
154  ProfilerFlush();
155  ProfilerStop();
156 #endif
157 // delete pRTT;
158 #ifndef ONLY_LOCAL_PROXY
159  if(pMix!=NULL)
160  delete pMix;
161  pMix=NULL;
162 #endif
163  CAMsg::printMsg(LOG_CRIT,"Terminating Programm!\n");
164  removePidFile();
166 #if defined(HAVE_CRTDBG)
167  _CrtMemCheckpoint( &s2 );
168  if ( _CrtMemDifference( &s3, s1, &s2 ) )
169  _CrtMemDumpStatistics( &s3 );
170  else
171  {
172  printf("Memory leak check clean!\n");
173  }
174  delete s1;
175 #endif
176 #ifdef CWDEBUG
177  Debug(list_allocations_on(libcw_do));
178 #endif
179  }
180 
182 void my_terminate(void)
183 {
184  if(!bTriedTermination)
185  {
186  bTriedTermination = true;
187 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
188  if(pMix!=NULL)
189  {
190  pMix->shutDown();
191  for (UINT32 i = 0; i < 200 && !(pMix->isShutDown()); i++)
192  {
193  msSleep(1000);
194  }
195  delete pMix;
196  pMix=NULL;
197  }
198 #endif
199  cleanup();
200  }
201 }
202 
203 
204 void signal_segv( int )
205 {
206  signal(SIGSEGV,SIG_DFL); //otherwise we might end up in endless loops...
207 
209  CAMsg::printMsg(LOG_CRIT,"Oops ... caught SIG_SEGV! Exiting...\n");
210 
211  // wait 1 second so that log files may still be written
212  sSleep(1);
213 
214 #ifdef PRINT_THREAD_STACK_TRACE
215  METHOD_STACK* stack = CAThread::getCurrentStack();
216  if (stack != NULL)
217  {
218  CAMsg::printMsg( LOG_CRIT, "Stack trace: %s, \"%s\"\n", stack->strMethodName, stack->strPosition);
219 
220  }
221  else
222  {
223  CAMsg::printMsg( LOG_CRIT, "Stack trace: none available\n");
224  }
225 #endif
226  // my_terminate(); temporarily disabled
227  exit(1);
228 }
229 
230 
231 
232 
233 void signal_term( int )
234  {
236  CAMsg::printMsg(LOG_INFO,"Hm.. Signal SIG_TERM received... exiting!\n");
237  my_terminate();
238  exit(0);
239  }
240 
242  {
244  CAMsg::printMsg(LOG_INFO,"Hm.. Strg+C pressed... exiting!\n");
245 #if defined _DEBUG && ! defined (ONLY_LOCAL_PROXY)
246  CAMsg::printMsg(LOG_INFO,"%d threads listed.\n",CALibProxytest::getThreadList()->getSize());
247  CALibProxytest::getThreadList()->showAll();
248 #endif
249  my_terminate();
250  exit(0);
251  }
252 
253 #ifndef ONLY_LOCAL_PROXY
254 void signal_hup(int)
255  {
257  }
258 #endif
259 
260 
263  {
264 #ifdef _MSC_VER
265  #pragma warning( push )
266  #pragma warning( disable : 4127 ) //Disable: Bedingter Ausdruck ist konstant
267 #endif
268  if(sizeof(SINT8)!=1)
269  {
270  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT8) != 1 --> maybe a compiler (optimization) problem!\n");
271  exit(-1);
272  }
273  if(sizeof(UINT8)!=1)
274  {
275  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT8) != 1 --> maybe a compiler (optimization) problem!\n");
276  exit(-1);
277  }
278  if(sizeof(SINT16)!=2)
279  {
280  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT16) != 2 --> maybe a compiler (optimization) problem!\n");
281  exit(-1);
282  }
283  if(sizeof(UINT16)!=2)
284  {
285  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT16) != 2 --> maybe a compiler (optimization) problem!\n");
286  exit(-1);
287  }
288  if(sizeof(SINT32)!=4)
289  {
290  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT32) != 4 --> maybe a compiler (optimization) problem!\n");
291  exit(-1);
292  }
293  if(sizeof(UINT32)!=4)
294  {
295  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT32) != 4 --> maybe a compiler (optimization) problem!\n");
296  exit(-1);
297  }
298  #ifdef HAVE_NATIVE_UINT64
299  if(sizeof(UINT64)!=8)
300  {
301  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT64) != 8 --> maybe a compiler (optimization) problem!\n");
302  exit(-1);
303  }
304  #endif
305 
306 #ifdef _MSC_VER
307  #pragma warning( pop )
308 #endif
309 
310  #ifndef NEW_MIX_TYPE
311  if (MIXPACKET_SIZE != sizeof(MIXPACKET))
312  {
313  CAMsg::printMsg(LOG_CRIT, "MIXPACKET_SIZE [%u] != sizeof(MUXPACKET) [%u] --> maybe a compiler (optimization) problem!\n", MIXPACKET_SIZE, sizeof(MIXPACKET));
314  CAMsg::printMsg(LOG_CRIT, "Offsets:\n");
315  MIXPACKET oPacket;
316  UINT8 *p = (UINT8 *)&oPacket;
317  UINT32 soffsets[7] = { 0, 4, 6, 6, 6, 8, 9 };
318  UINT32 hoffsets[7];
319  CAMsg::printMsg(LOG_CRIT, ".channel %u (should be 0)\n", hoffsets[0] = (UINT8 *)&(oPacket.channel) - p);
320  CAMsg::printMsg(LOG_CRIT, ".flags: %u (should be 4)\n", hoffsets[1] = (UINT8 *)&oPacket.flags - p);
321  CAMsg::printMsg(LOG_CRIT, ".data: %u (should be 6)\n", hoffsets[2] = (UINT8 *)&oPacket.data - p);
322  CAMsg::printMsg(LOG_CRIT, ".payload: %u (should be 6)\n", hoffsets[3] = (UINT8 *)&oPacket.payload - p);
323  CAMsg::printMsg(LOG_CRIT, ".payload.len: %u (should be 6)\n", hoffsets[4] = (UINT8 *)&oPacket.payload.len - p);
324  CAMsg::printMsg(LOG_CRIT, ".payload.type: %u (should be 8)\n", hoffsets[5] = (UINT8 *)&oPacket.payload.type - p);
325  CAMsg::printMsg(LOG_CRIT, ".payload.data: %u (should be 9)\n", hoffsets[6] = (UINT8 *)&oPacket.payload.data - p);
326  for (int i = 0; i < 7; i++)
327  if (soffsets[i] != hoffsets[i])
328  exit(EXIT_FAILURE);
329  CAMsg::printMsg(LOG_CRIT, "Hm, The Offsets seams to be ok - so we try to continue - hope that works...\n");
330  }
331 #endif
332  if (UDPMIXPACKET_SIZE != sizeof(UDPMIXPACKET))
333  {
334  CAMsg::printMsg(LOG_CRIT, "UDPMIXPACKET_SIZE [%u] != sizeof(UDPMUXPACKET) [%u] --> maybe a compiler (optimization) problem!\n", UDPMIXPACKET_SIZE, sizeof(UDPMIXPACKET));
335  }
336  if (UDPMIXPACKET_LINKHEADER_TYPE_SIZE != sizeof(UDPMIXPACKET_LINKHEADER))
337  {
338  CAMsg::printMsg(LOG_CRIT, "UDPMIXPACKET_LINKHEADER_TYPE_SIZE [%u] != sizeof(UDPMIXPACKET_LINKHEADER) [%u] --> maybe a compiler (optimization) problem!\n", UDPMIXPACKET_LINKHEADER_TYPE_SIZE, sizeof(UDPMIXPACKET_LINKHEADER));
339  }
340 
341  }
342 
343 
519 int main(int argc, const char* argv[])
520  {
521  SINT32 exitCode=0;
522 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INLUDE_LAST_MIX|| defined INLUDE_FIRST_MIX
523  pMix=NULL;
524 #endif
525 #if defined(HAVE_CRTDBG)
526 // _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
527  _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
528 // _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
529  _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
530 // _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
531  _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
532 
533  UINT32 tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
534  tmpDbgFlag |= _CRTDBG_ALLOC_MEM_DF;
535  tmpDbgFlag |=_CRTDBG_LEAK_CHECK_DF;
536  _CrtSetDbgFlag(tmpDbgFlag);
537  s1=new _CrtMemState;
538  _CrtMemCheckpoint( s1 );
539 #endif
540 //Switch on debug infos
541 #ifdef CWDEBUG
542  Debug(libcw_do.on());
543  Debug(dc::malloc.on());
544 #endif
545  init();
547 #ifdef LOG_CRIME
548 // testTre();
549 #endif
550 
551 #ifdef REPLAY_DATABASE_PERFORMANCE_TEST
552  CAReplayDatabase::measurePerformance((UINT8*)"dbperformace.log",1,10000001,500000,10,100000);
553  exit(0);
554 #endif
555 
556 
557 #ifdef DATA_RETENTION_LOG
558  if(sizeof(t_dataretentionLogEntry)!=18)
559  {
560  CAMsg::printMsg(LOG_CRIT,"sizeof(tDataRetentionLogEntry) [%u] != 18 --> maybe a compiler (optimization) problem!\n",sizeof(t_dataretentionLogEntry));
561  exit(EXIT_FAILURE);
562  }
563 #endif
564 
565 #ifdef _DEBUG
566  UINT32 start;
567 #endif
568  /*
569  CAUDPMiddleMix *pM = new CAUDPMiddleMix();
570 pM->start();
571 exit(0);
572 */
573  if(CALibProxytest::getOptions()->parse(argc,argv) != E_SUCCESS)
574  {
575  CAMsg::printMsg(LOG_CRIT,"An error occurred before we could finish parsing the configuration file. Exiting...\n");
576  exitCode=EXIT_FAILURE;
577  goto EXIT;
578  }
579 
580  if (CALibProxytest::getOptions()->getCryptoBenchmark())
581  {
582  CACryptoBenchmark* pCryptoBenchmark = new CACryptoBenchmark();
583  pCryptoBenchmark->doBenchmark();
584  exit(0);
585  }
586 
587 
588 
589  if(!( CALibProxytest::getOptions()->isFirstMix()||
590  CALibProxytest::getOptions()->isMiddleMix()||
591  CALibProxytest::getOptions()->isLastMix()||
592  CALibProxytest::getOptions()->isLocalProxy()))
593  {
594  CAMsg::printMsg(LOG_CRIT,"You must specify which kind of Mix you want to run!\n");
595  CAMsg::printMsg(LOG_CRIT,"Use -j or -c\n");
596  CAMsg::printMsg(LOG_CRIT,"Or try --help for more options.\n");
597  CAMsg::printMsg(LOG_CRIT,"Exiting...\n");
598  exitCode=EXIT_FAILURE;
599  goto EXIT;
600  }
601 
602 #ifndef _WIN32
603  if(CALibProxytest::getOptions()->getDaemon())
604  {
605  CAMsg::printMsg(LOG_DEBUG,"Starting mix process as daemon...\n");
606  CAMsg::cleanup();
607  CAMsg::init();
608  pid_t pid;
609  pid=fork();
610  if(pid!=0)
611  {
612  CAMsg::printMsg(LOG_INFO,"Exiting parent shell process...\n");
613  exit(EXIT_SUCCESS);
614  }
615  setsid();
616  #ifndef DO_TRACE
617  chdir("/");
618  umask(0);
619  #endif
620  // Close out the standard file descriptors
621  close(STDIN_FILENO);
622  close(STDOUT_FILENO);
623  close(STDERR_FILENO);
624  }
625 #endif
626 
627 
628  if (CALibProxytest::getOptions()->initLogging() != E_SUCCESS)
629  {
630  exitCode=EXIT_FAILURE;
631  goto EXIT;
632  }
633 
634 
635 
636  CAMsg::printMsg(LOG_CRIT,"Anon proxy started!\n");
637  CAMsg::printMsg(LOG_CRIT, "LogLevel: %s\n", CAMsg::getLogLevelStr());
638 
639 #ifdef ENABLE_GPERFTOOLS_CPU_PROFILER
640  ProfilerStart("gperf.cpuprofiler.data");
641  ProfilerRegisterThread();
642 #endif
643 
644 #ifndef _WIN32
645  #ifdef _DEBUG
646  signal(SIGPIPE,signal_broken_pipe);
647  #else
648  signal(SIGPIPE,SIG_IGN);
649  #endif
650  #ifndef ONLY_LOCAL_PROXY
651  struct sigaction newAction;
652  memset(&newAction,0,sizeof(newAction));
653  newAction.sa_handler=signal_hup;
654  newAction.sa_flags=0;
655  sigaction(SIGHUP,&newAction,NULL);
656  #endif
657 #endif
658  signal(SIGINT,signal_interrupt);
659  signal(SIGTERM,signal_term);
660 #if !defined (_DEBUG) && !defined(NO_SIGSEV_CATCH)
661  signal(SIGSEGV,signal_segv);
662 #endif
663  //Try to write pidfile....
664  UINT8 strPidFile[512];
665  if(CALibProxytest::getOptions()->getPidFile(strPidFile,512)==E_SUCCESS)
666  {
667  #ifndef _WIN32
668  int old_uid=geteuid(); //old uid... stored if we have to switch to root
669  #endif
670  pid_t pid=getpid();
671  UINT8 thePid[10];
672  sprintf((char*)thePid,"%i",pid);
673  int len=strlen((char*)thePid);
674  int hFile=open((char*)strPidFile,O_TRUNC|O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
675 #ifndef _WIN32
676  if(hFile==-1&&seteuid(0)!=-1) //probably we do not have enough rights (because we have already switch to an other uid --> try to go back temporaly..
677  {
678  hFile=open((char*)strPidFile,O_TRUNC|O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
679  }
680 #endif
681  if(hFile==-1||len!=write(hFile,thePid,len))
682  {
683  #ifndef _WIN32
684  seteuid(old_uid);
685  #endif
686  CAMsg::printMsg(LOG_CRIT,"Could not write pidfile - exiting!\n");
687  exitCode=EXIT_FAILURE;
688  goto EXIT;
689  }
690  close(hFile);
691 #ifndef _WIN32
692  seteuid(old_uid);
693 #endif
694  }
695 
696  if(CALibProxytest::getOptions()->isLocalProxy())
697  {
698  #ifndef NEW_MIX_TYPE
699  CALocalProxy* pProxy=new CALocalProxy();
700  CAMsg::printMsg(LOG_INFO,"Starting LocalProxy...\n");
701  if(pProxy->start()!=E_SUCCESS)
702  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
703  delete pProxy;
704  pProxy = NULL;
705  #else
706  CAMsg::printMsg(LOG_CRIT,"Compiled without LocalProxy support!\n");
707  exit(EXIT_FAILURE);
708  #endif
709  }
710  else
711  {
712 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INCLUDE_LAST_MIX
713  SINT32 s32MaxSockets=10000;//CASocket::getMaxOpenSockets();
714  CAMsg::printMsg(LOG_INFO,"Max Number of sockets we can open: %i\n",s32MaxSockets);
715 
716 #ifdef SERVER_MONITORING
718 #endif
719 
720  if(s32MaxSockets>100&&s32MaxSockets<10000)
721  {
722  CASocket::setMaxNormalSockets(s32MaxSockets-10);
723  }
725 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_FIRST_MIX
726  if(CALibProxytest::getOptions()->isFirstMix())
727  {
728  CAMsg::printMsg(LOG_INFO,"I am the First MIX...\n");
729  #if !defined(NEW_MIX_TYPE)
730  pMix=new CAFirstMixA();
731  #else
732  pMix=new CAFirstMixB();
733  #endif
735  }
736  else
737 #endif
738 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
739  if(CALibProxytest::getOptions()->isMiddleMix())
740  {
741  CAMsg::printMsg(LOG_INFO,"I am a Middle MIX...\n");
742  pMix=new CAMiddleMix();
744  }
745 #endif
746 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_LAST_MIX
747  if (CALibProxytest::getOptions()->isLastMix())
748  {
749  CAMsg::printMsg(LOG_INFO,"I am the Last MIX...\n");
750  #if !defined(NEW_MIX_TYPE)
751  pMix=new CALastMixA();
752  #else
753  pMix=new CALastMixB();
754  #endif
756  }
757 #endif
758 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_LAST_MIX
759  if (CALibProxytest::getOptions()->isLastMix())
760  {
761  CAMsg::printMsg(LOG_INFO,"I am the Last MIX...\n");
762  #if !defined(NEW_MIX_TYPE)
763  pMix=new CALastMixA();
764  #else
765  pMix=new CALastMixB();
766  #endif
768  }
769 #else
770  CAMsg::printMsg(LOG_ERR,"this Mix is compiled to work only as local proxy!\n");
771  exit(EXIT_FAILURE);
772 #endif
773  }
774 #ifdef DO_MIDDLE_MIX_BENCHMARK
775  pMix = new CAMiddleMixBenchmarkDummy();
776 #endif
777 #ifndef DYNAMIC_MIX
778  CAMsg::printMsg(LOG_INFO,"Starting MIX...\n");
779  if(pMix->start()!=E_SUCCESS)
780  {
781  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
782  exitCode=EXIT_FAILURE;
783  goto EXIT;
784  }
785 #else
786  // LERNGRUPPE
787 while(true)
788 {
789  CAMsg::printMsg(LOG_INFO,"Starting MIX...\n");
790  if(pMix->start()!=E_SUCCESS)
791  {
793  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
794  exit(EXIT_FAILURE);
795  }
796 
798  delete pMix;
799  pMix = NULL;
800 
801  if(CALibProxytest::getOptions()->isFirstMix())
802  {
803  CAMsg::printMsg(LOG_INFO,"I am now the First MIX..\n");
804 #if !defined(NEW_MIX_TYPE)
805  pMix=new CAFirstMixA();
806 #else
807  pMix=new CAFirstMixB();
808 #endif
809  }
810  else if(CALibProxytest::getOptions()->isMiddleMix())
811  {
812  CAMsg::printMsg(LOG_INFO,"I am now a Middle MIX..\n");
813  pMix=new CAMiddleMix();
814  }
815  else
816  {
818  CAMsg::printMsg( LOG_ERR, "Tried to reconfigure a former first/middle-Mix to a LastMix -> impossible!\n");
819  exit(EXIT_FAILURE);
820  }
821 }
822 #endif //DYNAMIC_MIX
823 #endif //ONLY_LOCAL_PROXY
824 EXIT:
825  cleanup();
826 
827  return exitCode;
828  }
#define MONITORING_FIRE_SYS_EVENT(e_type)
#define MONITORING_FIRE_NET_EVENT(e_type)
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
Definition: CAUtil.cpp:425
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
Definition: CAUtil.cpp:406
#define S_IWRITE
Definition: StdAfx.h:491
#define S_IREAD
Definition: StdAfx.h:488
unsigned short UINT16
Definition: basetypedefs.h:133
signed short SINT16
Definition: basetypedefs.h:134
signed int SINT32
Definition: basetypedefs.h:132
signed char SINT8
Definition: basetypedefs.h:136
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 reread(CAMix *pMix)
Rereads the configuration file (if one was given on startup) and reconfigures the mix according to th...
static CACmdLnOptions * getOptions()
static SINT32 cleanup()
do necessary cleanups of libraries etc.
static SINT32 init()
do necessary initialisations of libraries etc.
SINT32 start()
Definition: CAMix.hpp:49
virtual void shutDown()
Definition: CAMix.hpp:71
SINT32 start()
Definition: CAMix.cpp:104
virtual bool isShutDown()
Definition: CAMix.hpp:77
static SINT32 init()
Definition: CAMsg.hpp:69
static const char *const getLogLevelStr()
Definition: CAMsg.cpp:143
static SINT32 cleanup()
Definition: CAMsg.hpp:77
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
static SINT32 measurePerformance(UINT8 *strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure)
This mehtod can be used to measure the performance of the Replay database.
static SINT32 setMaxNormalSockets(UINT32 u)
Sets the max number of allowed "normal" sockets.
Definition: CASocket.hpp:116
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
@ ev_sys_sigSegV
@ ev_sys_sigTerm
@ ev_net_middleMixInited
@ ev_sys_start
@ ev_sys_sigInt
@ ev_net_lastMixInited
@ ev_net_firstMixInited
void init()
do necessary initialisations of libraries etc.
Definition: proxytest.cpp:145
CAMix * pMix
Definition: proxytest.cpp:75
void signal_interrupt(int)
Definition: proxytest.cpp:241
bool bTriedTermination
Definition: proxytest.cpp:103
void checkSizesOfTypes()
Check what the sizes of (base) types are as expected – if not kill the programm.
Definition: proxytest.cpp:262
void cleanup()
do necessary cleanups of libraries etc.
Definition: proxytest.cpp:151
void signal_segv(int)
Definition: proxytest.cpp:204
void signal_term(int)
Definition: proxytest.cpp:233
void removePidFile()
Removes the stored PID (file)
Definition: proxytest.cpp:122
void my_terminate(void)
Remark: terminate() might be already defined by the c lib – do not use this name.....
Definition: proxytest.cpp:182
int main(int argc, const char *argv[])
Definition: proxytest.cpp:519
void signal_hup(int)
Definition: proxytest.cpp:254
HCHANNEL channel
Definition: typedefs.hpp:117
struct t_MixPacketPayload payload
Definition: typedefs.hpp:122
UINT8 data[DATA_SIZE]
Definition: typedefs.hpp:121
UINT16 flags
Definition: typedefs.hpp:118
UINT8 data[PAYLOAD_SIZE]
Definition: typedefs.hpp:113
#define MIXPACKET_SIZE
Definition: typedefs.hpp:40
UINT16 len
Definition: typedefs.hpp:0