Mixe for Privacy and Anonymity in the Internet
CADatabase.hpp
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 #ifndef ONLY_LOCAL_PROXY
29 #include "CAMutex.hpp"
30 #include "CAThread.hpp"
31 #ifndef __CA_DATABASE__
32 #define __CA_DATABASE__
33 
34 typedef struct _t_database_entry
35  {
39 
40 typedef struct _t_database_info
41  {
42  t_databaseEntry* m_pHashTable[0x100][0x100];
45 
46 
47 #define SECONDS_PER_INTERVALL 30
48 #define FUTURE_TOLERANCE 5
49 
51 
52 /*** Database for dedecting replays.***/
54  {
55  public:
56  CADatabase();
57  ~CADatabase();
58  SINT32 insert(UINT8 key[16],UINT64 timestamp);
59  SINT32 start();
60  SINT32 stop();
61 
62  SINT32 test();
74  static SINT32 measurePerformance(UINT8* strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure);
75 
76  private:
77  friend THREAD_RETURN db_loopMaintenance(void *param);
78 
81 
86 
91 
92  SINT32 nextClock();
96  SINT32 fill(UINT32 nrOfEntries);
97 
101  SINT32 simulateInsert(UINT8 key[16]);
102 
107  volatile bool m_bRun;
108 // UINT32 m_refTime; //the seconds since epoch for the start of interval 0
109  volatile SINT32 m_currentClock; //the current 'interval' since m_refTimer
112  };
113 #endif //__CA_DATABASE__
114 #endif //ONLY_LOCAL_PROXY
THREAD_RETURN db_loopMaintenance(void *param)
Definition: CADatabase.cpp:241
struct _t_database_info t_databaseInfo
struct _t_database_entry t_databaseEntry
#define THREAD_RETURN
Definition: StdAfx.h:540
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 deleteDB(t_databaseInfo *&pDB)
Deletes the whole database pDB.
Definition: CADatabase.cpp:84
t_databaseInfo * m_prevDatabase
Definition: CADatabase.hpp:106
t_databaseInfo * createDBInfo()
Creates and initialises a dbinfo struct.
Definition: CADatabase.cpp:45
friend THREAD_RETURN db_loopMaintenance(void *param)
Definition: CADatabase.cpp:241
UINT64 m_lastSwitch
Definition: CADatabase.hpp:103
t_databaseInfo * m_currDatabase
Definition: CADatabase.hpp:104
SINT32 clearDB(t_databaseInfo *pDB)
clears the whole database pDB - but does not delete the hashtable pDB
Definition: CADatabase.cpp:64
SINT32 stop()
Definition: CADatabase.cpp:228
CAThread * m_pThread
Definition: CADatabase.hpp:111
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.
Definition: CADatabase.cpp:303
SINT32 start()
Definition: CADatabase.cpp:220
CAMutex * m_pMutex
Definition: CADatabase.hpp:110
SINT32 simulateInsert(UINT8 key[16])
This is a modified copy of insert() which simulates the insert() function as close as possible withou...
Definition: CADatabase.cpp:368
t_databaseInfo * m_nextDatabase
Definition: CADatabase.hpp:105
SINT32 insert(UINT8 key[16], UINT64 timestamp)
Inserts this key in the replay DB.
Definition: CADatabase.cpp:93
SINT32 test()
Definition: CADatabase.cpp:277
volatile SINT32 m_currentClock
Definition: CADatabase.hpp:109
SINT32 nextClock()
Definition: CADatabase.cpp:262
volatile bool m_bRun
Definition: CADatabase.hpp:107
SINT32 fill(UINT32 nrOfEntries)
Pre fills the database with nrOfEntries random entries.
Definition: CADatabase.cpp:354
Definition: CADatabase.hpp:35
_t_database_entry * next
Definition: CADatabase.hpp:36
UINT64 key
Definition: CADatabase.hpp:37
t_databaseEntry * m_pHashTable[0x100][0x100]
Definition: CADatabase.hpp:42