Mixe for Privacy and Anonymity in the Internet
CADatabase.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 ONLY_LOCAL_PROXY
00029 #include "CAMutex.hpp"
00030 #include "CAThread.hpp"
00031 #ifndef __CA_DATABASE__
00032 #define __CA_DATABASE__
00033 
00034 typedef struct _t_database_entry
00035   {
00036     _t_database_entry* next;
00037     UINT64 key;
00038   } t_databaseEntry;
00039 
00040 typedef struct _t_database_info
00041   {
00042     t_databaseEntry*  m_pHashTable[0x100][0x100];
00043     UINT32      m_u32Size;
00044   } t_databaseInfo;
00045 
00046 
00047 #define SECONDS_PER_INTERVALL 30
00048 #define FUTURE_TOLERANCE 5
00049 
00050 THREAD_RETURN db_loopMaintenance(void *param);
00051 
00052 class CADatabase
00053   {
00054     public:
00055       CADatabase();
00056       ~CADatabase();
00057       SINT32 insert(UINT8 key[16],UINT64 timestamp);
00058       SINT32 start();
00059       SINT32 stop();
00060 
00061       SINT32 test();
00073       static SINT32 measurePerformance(UINT8* strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure);
00074 
00075     private:
00076       friend THREAD_RETURN db_loopMaintenance(void *param);
00077 
00079       t_databaseInfo* createDBInfo();
00080       
00084       SINT32 clearDB(t_databaseInfo* pDB);
00085       
00089       SINT32 deleteDB(t_databaseInfo*& pDB);
00090 
00091       SINT32 nextClock();
00095       SINT32 fill(UINT32 nrOfEntries);
00096 
00100       SINT32 simulateInsert(UINT8 key[16]);
00101 
00102       UINT64 m_lastSwitch;
00103       t_databaseInfo* m_currDatabase;
00104       t_databaseInfo* m_nextDatabase;
00105       t_databaseInfo* m_prevDatabase;
00106       volatile bool m_bRun;
00107 //      UINT32 m_refTime; //the seconds since epoch for the start of interval 0
00108       volatile SINT32 m_currentClock; //the current 'interval' since m_refTimer
00109       CAMutex*  m_pMutex;
00110       CAThread* m_pThread;
00111   };
00112 #endif //__CA_DATABASE__
00113 #endif //ONLY_LOCAL_PROXY