childsa.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 CHILDSA_H
00022 #define CHILDSA_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027 
00028 #include "printable.h"
00029 #include "proposal.h"
00030 #include "enums.h"
00031 #include "diffiehellman.h"
00032 #include "keyring.h"
00033 #include "payload_ts.h"
00034 #include "payload_nonce.h"
00035 #include "ipsecconfiguration.h"
00036 #include "attributemap.h"
00037 
00038 using namespace std;
00039 
00040 namespace openikev2 {
00041 
00046     class ChildSa: public Printable {
00047 
00048             /****************************** ENUMS ******************************/
00049         public:
00051             enum CHILD_SA_STATE{
00052                 CHILD_SA_CREATING,           
00053                 CHILD_SA_ESTABLISHED,        
00054                 CHILD_SA_DELETING,           
00055                 CHILD_SA_REKEYED,            
00056                 CHILD_SA_REKEYING,           
00057         };
00058 
00059             /****************************** ATTRIBUTES ******************************/
00060         protected:
00061             auto_ptr<IpsecConfiguration> ipsec_configuration;      
00062             CHILD_SA_STATE state;                                  
00064         public:
00065             uint32_t inbound_spi;                       
00066             uint32_t outbound_spi;                      
00067             bool child_sa_initiator;                    
00068             auto_ptr<Payload_TS> my_traffic_selector;   
00069             auto_ptr<Payload_TS> peer_traffic_selector; 
00070             auto_ptr<ByteArray> my_nonce;               
00071             auto_ptr<ByteArray> peer_nonce;             
00072             auto_ptr<KeyRing> keyring;                  
00073             auto_ptr<DiffieHellman> pfs_dh;             
00074             Enums::IPSEC_MODE mode;                     
00075             Enums::PROTOCOL_ID ipsec_protocol;          
00076             uint32_t reqid;                             
00077             auto_ptr<AttributeMap> attributemap;        
00079             /****************************** METHODS ******************************/
00080         protected:
00086             static string CHILD_SA_STATE_STR( CHILD_SA_STATE state );
00087 
00088         public:
00093             ChildSa( bool child_sa_initiator );
00094 
00103             ChildSa( uint32_t spi_in, uint32_t spi_out, Enums::IPSEC_MODE mode, Enums::PROTOCOL_ID ipsec_protocol, bool child_sa_initiator );
00104 
00111             static ChildSa& hasMinNonce( const ChildSa& child_sa1, const ChildSa& child_sa2 );
00112 
00117             virtual Proposal& getProposal() const;
00118             
00123             virtual IpsecConfiguration& getIpsecConfiguration() const;
00124 
00129             virtual void setProposal( auto_ptr<Proposal> new_proposal );
00130             
00135             virtual void setIpsecConfiguration(auto_ptr<IpsecConfiguration> ipsec_configuration);
00136             
00142             virtual bool equals( const ChildSa& other ) const;
00143 
00148             virtual auto_ptr<ChildSa> clone() const;
00149 
00154             virtual void setState( CHILD_SA_STATE next_state );
00155             
00160             virtual auto_ptr<ByteArray> getId() const;
00161 
00166             virtual CHILD_SA_STATE getState() const;
00167 
00168             virtual string toStringTab( uint8_t tabs ) const;
00169 
00170             virtual ~ChildSa();
00171 
00172     };
00173 }
00174 
00175 #endif

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