threadcontrollerimpl.h

00001 /***************************************************************************
00002 *   Copyright (C) 2005 by                                                 *
00003 *   Pedro J. Fernandez Ruiz    pedroj.fernandez@dif.um.es                 *
00004 *   Alejandro Perez Mendez     alejandro_perez@dif.um.es                  *
00005 *                                                                         *
00006 *   This library is free software; you can redistribute it and/or         *
00007 *   modify it under the terms of the GNU Lesser General Public            *
00008 *   License as published by the Free Software Foundation; either          *
00009 *   version 2.1 of the License, or (at your option) any later version.    *
00010 *                                                                         *
00011 *   This library is distributed in the hope that it will be useful,       *
00012 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014 *   Lesser General Public License for more details.                       *
00015 *                                                                         *
00016 *   You should have received a copy of the GNU Lesser General Public      *
00017 *   License along with this library; if not, write to the Free Software   *
00018 *   Foundation, Inc., 51 Franklin St, Fifth Floor,                        *
00019 *   Boston, MA  02110-1301  USA                                           *
00020 ***************************************************************************/
00021 #ifndef THREADCONTROLLERIMPL_H
00022 #define THREADCONTROLLERIMPL_H
00023 
00024 #include "runnable.h"
00025 #include "condition.h"
00026 #include "mutex.h"
00027 #include "semaphore.h"
00028 #include "ikesaexecuter.h"
00029 #include "ikesacontroller.h"
00030 #include "command.h"
00031 #include "payload_tsi.h"
00032 #include "payload_tsr.h"
00033 
00034 using namespace std;
00035 
00036 namespace openikev2 {
00037 
00042     class ThreadControllerImpl {
00043 
00044             /****************************** ATTRIBUTES ******************************/
00045         protected:
00046             map <uint64_t, IkeSaController*> ike_sa_collection;   
00047             auto_ptr<Mutex> mutex_ike_sa_collection;                
00048             deque<IkeSaController*> waiting_ike_sa_controller;    
00049             auto_ptr<Condition> condition_ike_sa_executer;          
00050             bool exiting;                                           
00051             uint32_t half_open_counter;                             
00052             auto_ptr<Mutex> mutex_half_open_counter;                
00054             /****************************** METHODS ******************************/
00055         public:
00056 
00061             virtual void initialize( uint16_t num_command_executers );
00062 
00067             virtual void startThread( Runnable& runnable ) = 0;
00068 
00073             virtual auto_ptr<Condition> getCondition() = 0;
00074 
00079             virtual auto_ptr<Mutex> getMutex() = 0;
00080 
00085             virtual auto_ptr<Semaphore> getSemaphore( uint32_t initial_value ) = 0;
00086 
00090             virtual void incHalfOpenCounter();
00091 
00095             virtual void decHalfOpenCounter();
00096 
00101             virtual bool useCookies();
00102 
00107             virtual IkeSaController& getWaitingIkeSaController();
00108 
00113             virtual void addWaitingIkeSaController( IkeSaController& ike_sa_controller );
00114 
00119             virtual uint64_t nextSpi() = 0;
00120 
00125             virtual void addIkeSaController( auto_ptr<IkeSaController> ike_sa_controller );
00126 
00134             virtual void requestChildSa( IpAddress& src_addr, IpAddress& dst_addr, auto_ptr<ChildSa> child_sa );
00135             
00136             virtual void requestChildSa( IpAddress& src_addr, IpAddress& dst_addr, Enums::PROTOCOL_ID ipsec_protocol, Enums::IPSEC_MODE mode, auto_ptr<Payload_TSi> payload_ts_i, auto_ptr<Payload_TSr> payload_ts_r, uint32_t request_id );
00137 
00142             virtual void deleteIkeSaController( IkeSaController& ike_sa_controller );
00143 
00151             virtual bool pushCommandBySpi( uint64_t spi, auto_ptr<Command> command, bool priority );
00152 
00161             virtual bool pushCommandByAddress( const IpAddress& addr, const IpAddress& peer_addr, auto_ptr<Command> command, bool priority );
00162 
00166             virtual void closeAllSas();
00167 
00171             virtual void exit();
00172 
00177             virtual bool isExiting();
00178 
00179             virtual ~ThreadControllerImpl();
00180     };
00181 };
00182 #endif

Generated on Fri Jul 27 11:04:45 2007 for libopenikev2 by  doxygen 1.5.1