00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
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
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