Mixe for Privacy and Anonymity in the Internet
CALastMixBChannelList.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2006, The JAP-Team 
00003  * All rights reserved.
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, 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
00011  *     notice, this list of conditions and the following disclaimer in the
00012  *     documentation and/or other materials provided with the distribution.
00013  *
00014  *   - Neither the name of the University of Technology Dresden, Germany nor
00015  *     the names of its contributors may be used to endorse or promote
00016  *     products derived from this software without specific prior written
00017  *     permission. 
00018  *
00019  *  
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00022  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00023  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE
00031  */
00032 #ifndef __CALASTMIXBCHANNELLIST__
00033 #define __CALASTMIXBCHANNELLIST__
00034 
00035 #include "../CAMuxSocket.hpp"
00036 #include "../CASymCipher.hpp"
00037 #include "../CAMutex.hpp"
00038 #include "CAChain.hpp"
00039 
00040 struct t_deadlineEntry {
00041   timespec deadline;
00042   t_deadlineEntry* nextDeadline;
00043 };
00044 
00045 struct t_lastMixBChannelListEntry {
00046   HCHANNEL channelId;   
00047   CASymCipher* channelCipher;
00048   class CAChain* associatedChain;
00049   UINT16 remainingDownstreamPackets;
00050 
00051   t_deadlineEntry* firstResponseDeadline;
00052 
00053   class CALastMixBChannelList* associatedChannelList;
00054 
00055   t_lastMixBChannelListEntry* rightEntry;
00056   t_lastMixBChannelListEntry** rightEntryPointerOfLeftEntry;
00057 };
00058 
00059 
00060 class CALastMixBChannelList {
00061   public:
00062     CALastMixBChannelList();
00063     ~CALastMixBChannelList();
00064 
00065     t_lastMixBChannelListEntry* add(HCHANNEL a_channelId, CASymCipher* a_channelCipher, CAChain* a_associatedChain);
00066     t_lastMixBChannelListEntry* get(HCHANNEL a_channelId);
00067     void removeFromTable(t_lastMixBChannelListEntry* a_channelEntry);
00068 
00069   private:
00070     UINT32 m_channelTableSize;
00071     t_lastMixBChannelListEntry** m_pChannelTable;    
00072     CAMutex* m_pMutex;
00073 
00074     t_lastMixBChannelListEntry* getEntryInternal(HCHANNEL a_channelId);
00075 
00076 };
00077 #endif //__CALASTMIXBCHANNELLIST__