- changed allocation behavior
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa.c
|
||||
*
|
||||
* @brief Class ike_sa_t. An object of this type is managed by an
|
||||
* ike_sa_manager_t object and represents an IKE_SA
|
||||
* @brief Implementation of ike_sa_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -57,7 +56,6 @@ struct private_ike_sa_t {
|
||||
*/
|
||||
protected_ike_sa_t protected;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a job to delete the given IKE_SA.
|
||||
*
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
/**
|
||||
* Nonce size in bytes of all sent nonces
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
#define NONCE_SIZE 16
|
||||
|
||||
@@ -46,6 +48,8 @@ typedef struct ike_sa_t ike_sa_t;
|
||||
/**
|
||||
* @brief Class ike_sa_t. An object of this type is managed by an
|
||||
* ike_sa_manager_t object and represents an IKE_SA.
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
struct ike_sa_t {
|
||||
|
||||
@@ -90,6 +94,8 @@ typedef struct protected_ike_sa_t protected_ike_sa_t;
|
||||
*
|
||||
* This members should only be accessed from
|
||||
* the varius state classes.
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
struct protected_ike_sa_t {
|
||||
|
||||
@@ -239,6 +245,8 @@ struct protected_ike_sa_t {
|
||||
* e.g. when a IKE_SA_INIT has been finished.
|
||||
*
|
||||
* @return created ike_sa_t object
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id);
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ struct private_ike_sa_id_t {
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* implements ike_sa_id_t.set_responder_spi.
|
||||
*/
|
||||
@@ -94,7 +93,7 @@ static u_int64_t get_responder_spi (private_ike_sa_id_t *this)
|
||||
*/
|
||||
static bool equals (private_ike_sa_id_t *this, private_ike_sa_id_t *other)
|
||||
{
|
||||
if ((this == NULL)||(other == NULL))
|
||||
if (other == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ typedef struct ike_sa_id_t ike_sa_id_t;
|
||||
* An IKE_SA is identified by its initiator and responder spi's.
|
||||
* Additionaly it contains the role of the actual running IKEv2-Daemon
|
||||
* for the specific IKE_SA.
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
struct ike_sa_id_t {
|
||||
|
||||
@@ -131,6 +133,8 @@ struct ike_sa_id_t {
|
||||
* @param responder_spi responders spi
|
||||
* @param is_initiator TRUE if we are the original initiator
|
||||
* @return created ike_sa_id_t object
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiaor);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa_manager.c
|
||||
*
|
||||
* @brief Central point for managing IKE-SAs (creation, locking, deleting...)
|
||||
* @brief Implementation of ike_sa_mananger_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
typedef struct ike_sa_entry_t ike_sa_entry_t;
|
||||
|
||||
/**
|
||||
* @brief An entry in the linked list, contains IKE_SA, locking and lookup data.
|
||||
* An entry in the linked list, contains IKE_SA, locking and lookup data.
|
||||
*/
|
||||
struct ike_sa_entry_t {
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ struct ike_sa_entry_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* @see ike_sa_entry_t.destroy
|
||||
* Implements ike_sa_entry_t.destroy.
|
||||
*/
|
||||
static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
|
||||
/**
|
||||
* @brief creates a new entry for the ike_sa list
|
||||
*
|
||||
* This constructor additionaly creates a new and empty SA
|
||||
* This constructor additionaly creates a new and empty SA.
|
||||
*
|
||||
* @param ike_sa_id the associated ike_sa_id_t, will be cloned
|
||||
* @return created entry, with ike_sa and ike_sa_id
|
||||
@@ -130,7 +130,7 @@ struct private_ike_sa_manager_t {
|
||||
/**
|
||||
* @brief get next spi
|
||||
*
|
||||
* we give out SPIs incremental
|
||||
* we give out SPIs incremental.
|
||||
*
|
||||
* @param this the ike_sa_manager
|
||||
* @return the next spi
|
||||
@@ -138,7 +138,7 @@ struct private_ike_sa_manager_t {
|
||||
u_int64_t (*get_next_spi) (private_ike_sa_manager_t *this);
|
||||
|
||||
/**
|
||||
* @brief find the ike_sa_entry in the list by SPIs
|
||||
* @brief find the ike_sa_entry in the list by SPIs.
|
||||
*
|
||||
* This function simply iterates over the linked list. A hash-table
|
||||
* would be more efficient when storing a lot of IKE_SAs...
|
||||
@@ -199,7 +199,6 @@ struct private_ike_sa_manager_t {
|
||||
u_int64_t next_spi;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Implements private_ike_sa_manager_t.get_entry_by_id.
|
||||
*/
|
||||
@@ -468,8 +467,7 @@ static status_t checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements ike_sa_manager_t-function checkin.
|
||||
* @see ike_sa_manager_t.checkin.
|
||||
* Implements ike_sa_manager_t.checkin.
|
||||
*/
|
||||
static status_t checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
|
||||
{
|
||||
@@ -506,8 +504,7 @@ static status_t checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
|
||||
|
||||
|
||||
/**
|
||||
* Implements ike_sa_manager_t-function checkin_and_delete.
|
||||
* @see ike_sa_manager_t.checkin_and_delete.
|
||||
* Implements ike_sa_manager_t.checkin_and_delete.
|
||||
*/
|
||||
static status_t checkin_and_delete(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,8 @@ typedef struct ike_sa_manager_t ike_sa_manager_t;
|
||||
*
|
||||
* @todo checking of double-checkouts from the same threads would be nice.
|
||||
* This could be by comparing thread-ids via pthread_self()...
|
||||
*
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
struct ike_sa_manager_t {
|
||||
/**
|
||||
@@ -128,6 +129,8 @@ struct ike_sa_manager_t {
|
||||
* @brief Create a manager
|
||||
*
|
||||
* @returns the created manager
|
||||
*
|
||||
* @ingroup sa
|
||||
*/
|
||||
ike_sa_manager_t *ike_sa_manager_create();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_auth_requested.c
|
||||
*
|
||||
* @brief State of an IKE_SA, which has requested an IKE_AUTH.
|
||||
* @brief Implementation of ike_auth_requested_t.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_auth_requested.h
|
||||
*
|
||||
* @brief State of an IKE_SA, which has requested an IKE_AUTH.
|
||||
* @brief Interface of ike_auth_requested_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,8 @@ typedef struct ike_auth_requested_t ike_auth_requested_t;
|
||||
|
||||
/**
|
||||
* @brief This class represents an IKE_SA, which has requested an IKE_AUTH.
|
||||
*
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct ike_auth_requested_t {
|
||||
/**
|
||||
@@ -45,6 +46,9 @@ struct ike_auth_requested_t {
|
||||
* Constructor of class ike_auth_requested_t
|
||||
*
|
||||
* @param ike_sa assigned ike_sa object
|
||||
* @return created ike_auth_requested_t object
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa_established.c
|
||||
*
|
||||
* @brief State of an established IKE_SA.
|
||||
* @brief Implementation of ike_sa_established_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,6 @@ typedef struct private_ike_sa_established_t private_ike_sa_established_t;
|
||||
|
||||
/**
|
||||
* Private data of a ike_sa_established_t object.
|
||||
*
|
||||
*/
|
||||
struct private_ike_sa_established_t {
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa_established.h
|
||||
*
|
||||
* @brief State of an established IKE_SA.
|
||||
* @brief Interface of ike_sa_established_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
typedef struct ike_sa_established_t ike_sa_established_t;
|
||||
|
||||
/**
|
||||
* @brief This class represents an the state of an established.
|
||||
* @brief This class represents an the state of an established
|
||||
* IKE_SA.
|
||||
*
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct ike_sa_established_t {
|
||||
/**
|
||||
@@ -44,7 +45,10 @@ struct ike_sa_established_t {
|
||||
/**
|
||||
* Constructor of class ike_sa_established_t
|
||||
*
|
||||
* @param ike_sa assigned ike_sa
|
||||
* @param ike_sa assigned ike_sa
|
||||
* @return created ike_sa_established_t object
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa_init_requested.c
|
||||
*
|
||||
* @brief State of a IKE_SA after requesting an IKE_SA_INIT
|
||||
* @brief Implementation of ike_sa_init_requested_t.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ike_sa_init_requested.h
|
||||
*
|
||||
* @brief State of a IKE_SA after requesting an IKE_SA_INIT
|
||||
* @brief Interface of ike_sa_init_requestet_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,22 +33,25 @@ typedef struct ike_sa_init_requested_t ike_sa_init_requested_t;
|
||||
|
||||
/**
|
||||
* @brief This class represents an IKE_SA state when requested an IKE_SA_INIT.
|
||||
*
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct ike_sa_init_requested_t {
|
||||
/**
|
||||
* methods of the state_t interface
|
||||
*/
|
||||
state_t state_interface;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor of class ike_sa_init_responded_t
|
||||
*
|
||||
* @param ike_sa assigned ike_sa
|
||||
* @param ike_sa assigned ike_sa
|
||||
* @param diffie_hellman diffie_hellman object use to retrieve shared secret
|
||||
* @param sent_nonce Sent nonce value
|
||||
* @return created ike_sa_init_request_t object
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa, u_int16_t dh_group_priority, diffie_hellman_t *diffie_hellman, chunk_t sent_nonce);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ static ike_sa_state_t get_state(private_ike_sa_init_responded_t *this)
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t destroy(private_ike_sa_init_responded_t *this)
|
||||
static void destroy(private_ike_sa_init_responded_t *this)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL | MORE, "Going to destroy ike_sa_init_responded_t state object");
|
||||
|
||||
@@ -101,7 +101,6 @@ static status_t destroy(private_ike_sa_init_responded_t *this)
|
||||
allocator_free(this->received_nonce.ptr);
|
||||
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
typedef struct ike_sa_init_responded_t ike_sa_init_responded_t;
|
||||
|
||||
/**
|
||||
* @brief This class represents an IKE_SA state when responded to an IKE_SA_INIT request.
|
||||
*
|
||||
* @brief This class represents an IKE_SA state when
|
||||
* responded to an IKE_SA_INIT request.
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct ike_sa_init_responded_t {
|
||||
/**
|
||||
@@ -41,9 +43,12 @@ struct ike_sa_init_responded_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor of class ike_sa_init_responded_t
|
||||
* @brief Constructor of class ike_sa_init_responded_t
|
||||
*
|
||||
* @param ike_sa assigned IKE_SA
|
||||
* @param ike_sa assigned IKE_SA
|
||||
* @todo Params description
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa, chunk_t shared_secret, chunk_t received_nonce, chunk_t sent_nonce);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file initiator_init.h
|
||||
*
|
||||
* @brief Start state of a IKE_SA as initiator
|
||||
* @brief Interface of initiator_init_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,8 @@ typedef struct initiator_init_t initiator_init_t;
|
||||
/**
|
||||
* @brief This class represents an IKE_SA state when initializing.
|
||||
* a connection as initiator
|
||||
*
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct initiator_init_t {
|
||||
/**
|
||||
@@ -52,9 +53,11 @@ struct initiator_init_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor of class initiator_init_t
|
||||
* @brief Constructor of class initiator_init_t
|
||||
*
|
||||
* @param ike_sa assigned IKE_SA
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa);
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ typedef struct responder_init_t responder_init_t;
|
||||
/**
|
||||
* @brief This class represents an IKE_SA state when initializing.
|
||||
* a connection as responder.
|
||||
*
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct responder_init_t {
|
||||
/**
|
||||
@@ -48,6 +49,8 @@ struct responder_init_t {
|
||||
* @param ike_sa assigned IKE_SA
|
||||
*
|
||||
* @return responder_init state
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file state.c
|
||||
*
|
||||
* @brief Interface for a specific IKE_SA state
|
||||
* @brief Interface additions to ike_sa_sate_t.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file state.h
|
||||
*
|
||||
* @brief Interface for a specific IKE_SA state.
|
||||
* @brief Interface ike_sa_sate_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,8 @@ typedef enum ike_sa_state_t ike_sa_state_t;
|
||||
|
||||
/**
|
||||
* States in which a IKE_SA can actually be
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
enum ike_sa_state_t {
|
||||
|
||||
@@ -79,6 +81,8 @@ typedef struct state_t state_t;
|
||||
|
||||
/**
|
||||
* @brief This interface represents an IKE_SA state
|
||||
*
|
||||
* @ingroup states
|
||||
*/
|
||||
struct state_t {
|
||||
|
||||
@@ -109,5 +113,4 @@ struct state_t {
|
||||
void (*destroy) (state_t *this);
|
||||
};
|
||||
|
||||
|
||||
#endif /*STATE_H_*/
|
||||
|
||||
Reference in New Issue
Block a user