Mixe for Privacy and Anonymity in the Internet
CASocketList.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 __CASOCKETLIST__
00029 #define __CASOCKETLIST__
00030 #include "CAMuxSocket.hpp"
00031 #include "CASymCipher.hpp"
00032 #include "CAMutex.hpp"
00033 #include "CAQueue.hpp"
00034 
00035 typedef struct connlist
00036   {
00037     CASymCipher* pCiphers;
00038     CASocket* pSocket;
00039     connlist* next;
00040     HCHANNEL outChannel;
00041     UINT32 currentSendMeCounter;
00042     UINT32 upstreamBytes;
00043   } CONNECTIONLIST,CONNECTION;
00044     
00045 struct t_MEMBLOCK;
00046 
00047 class CASocketList
00048   {
00049     public:
00050       CASocketList();
00051       CASocketList(bool bThreadSafe);
00052       ~CASocketList();
00053       SINT32 add(CASocket* pSocket,CASymCipher* pCiphers);
00054       SINT32 get(HCHANNEL in,CONNECTION* out);
00055       
00056       CASocket* remove(HCHANNEL id);
00057       SINT32 clear();
00062       CONNECTION*  getFirst()
00063         {
00064           m_AktEnumPos=m_Connections;
00065           return m_AktEnumPos;
00066         }
00067 
00072       CONNECTION* getNext()
00073         {
00074           if(m_AktEnumPos!=NULL)
00075             m_AktEnumPos=m_AktEnumPos->next;
00076           return m_AktEnumPos;
00077         }
00078 
00079       UINT32 getSize(){return m_Size;}
00080       SINT32 setThreadSafe(bool b);
00081       SINT32 addSendMeCounter(HCHANNEL in,SINT32 value);
00082     protected:
00083       SINT32 increasePool();
00084       CONNECTIONLIST* m_Connections;
00085       CONNECTIONLIST* m_Pool;
00086       CONNECTIONLIST* m_AktEnumPos;
00087       t_MEMBLOCK* m_Memlist;
00088       CAMutex cs;
00089       bool m_bThreadSafe;
00090       UINT32 m_Size;
00091   };  
00092 #endif