- added function replace_values
This commit is contained in:
parent
3173235768
commit
8491b29826
3 changed files with 51 additions and 15 deletions
|
@ -116,7 +116,27 @@ static status_t equals (private_ike_sa_id_t *this,private_ike_sa_id_t *other, bo
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
static status_t clone (private_ike_sa_id_t *this,ike_sa_id_t **clone_of_this)
|
||||
/**
|
||||
* @brief implements function replace_values of ike_sa_id_t
|
||||
*/
|
||||
status_t replace_values (private_ike_sa_id_t *this, private_ike_sa_id_t *other)
|
||||
{
|
||||
if ((this == NULL) || (other == NULL))
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
this->initiator_spi = other->initiator_spi;
|
||||
this->responder_spi = other->responder_spi;
|
||||
this->role = other->role;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief implements function clone of ike_sa_id_t
|
||||
*/
|
||||
static status_t clone (private_ike_sa_id_t *this, ike_sa_id_t **clone_of_this)
|
||||
{
|
||||
if ((this == NULL) || (clone_of_this == NULL))
|
||||
{
|
||||
|
@ -153,11 +173,12 @@ ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_
|
|||
}
|
||||
|
||||
/* Public functions */
|
||||
this->public.set_responder_spi = (status_t(*)(ike_sa_id_t*,spi_t))set_responder_spi;
|
||||
this->public.responder_spi_is_set = (bool(*)(ike_sa_id_t*))responder_spi_is_set;
|
||||
this->public.initiator_spi_is_set = (bool(*)(ike_sa_id_t*))initiator_spi_is_set;
|
||||
this->public.equals = (status_t(*)(ike_sa_id_t*,ike_sa_id_t*,bool*))equals;
|
||||
this->public.clone = (status_t(*)(ike_sa_id_t*,ike_sa_id_t**))clone;
|
||||
this->public.set_responder_spi = (status_t(*)(ike_sa_id_t*,spi_t)) set_responder_spi;
|
||||
this->public.responder_spi_is_set = (bool(*)(ike_sa_id_t*)) responder_spi_is_set;
|
||||
this->public.initiator_spi_is_set = (bool(*)(ike_sa_id_t*)) initiator_spi_is_set;
|
||||
this->public.equals = (status_t(*)(ike_sa_id_t*,ike_sa_id_t*,bool*)) equals;
|
||||
this->public.replace_values = (status_t(*)(ike_sa_id_t*,ike_sa_id_t*)) replace_values;
|
||||
this->public.clone = (status_t(*)(ike_sa_id_t*,ike_sa_id_t**)) clone;
|
||||
this->public.destroy = (status_t(*)(ike_sa_id_t*))destroy;
|
||||
|
||||
/* private data */
|
||||
|
|
|
@ -42,7 +42,7 @@ struct ike_sa_id_s {
|
|||
*
|
||||
* This function is called when a request or reply of a IKE_SA_INIT is received.
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param this ike_sa_id_t-object
|
||||
* @param responder_spi SPI of responder to set
|
||||
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ struct ike_sa_id_s {
|
|||
/**
|
||||
* @brief Returns TRUE if the initiator spi is set (not zero)
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param this ike_sa_id_t-object
|
||||
* @return TRUE if the initiator spi is set, FALSE otherwise
|
||||
*/
|
||||
bool (*initiator_spi_is_set) (ike_sa_id_t *this);
|
||||
|
@ -59,7 +59,7 @@ struct ike_sa_id_s {
|
|||
/**
|
||||
* @brief Returns TRUE if the responder spi is set (not zero)
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param this ike_sa_id_t-object
|
||||
* @return TRUE if the responder spi is set, FALSE otherwise
|
||||
*/
|
||||
bool (*responder_spi_is_set) (ike_sa_id_t *this);
|
||||
|
@ -67,7 +67,7 @@ struct ike_sa_id_s {
|
|||
/**
|
||||
* @brief Check if two ike_sa_ids are equal
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param this ike_sa_id_t-object
|
||||
* @param other ike_sa_id object to check if equal
|
||||
* @param are_equal is set to TRUE, if given ike_sa_ids are equal, FALSE otherwise
|
||||
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||
|
@ -75,18 +75,28 @@ struct ike_sa_id_s {
|
|||
status_t (*equals) (ike_sa_id_t *this,ike_sa_id_t *other, bool *are_equal);
|
||||
|
||||
/**
|
||||
* @brief Clones a given ike_sa_id-Object
|
||||
* @brief Replace the values of a given ike_sa_id_t-object with values
|
||||
* from another ike_sa_id_t-Object
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param other ike_sa_id object which will be created
|
||||
* @param this ike_sa_id_t-object
|
||||
* @param other ike_sa_id_t object which values will be taken
|
||||
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||
*/
|
||||
status_t (*replace_values) (ike_sa_id_t *this,ike_sa_id_t *other);
|
||||
|
||||
/**
|
||||
* @brief Clones a given ike_sa_id_t-object
|
||||
*
|
||||
* @param this ike_sa_id_t-object
|
||||
* @param clone_of_this ike_sa_id_t-object which will be created
|
||||
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||
*/
|
||||
status_t (*clone) (ike_sa_id_t *this,ike_sa_id_t **clone_of_this);
|
||||
|
||||
/**
|
||||
* @brief Destroys a ike_sa_id object
|
||||
* @brief Destroys a ike_sa_id_tobject
|
||||
*
|
||||
* @param this ike_sa_id object
|
||||
* @param this ike_sa_id_t-object
|
||||
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||
*/
|
||||
status_t (*destroy) (ike_sa_id_t *this);
|
||||
|
|
|
@ -80,6 +80,11 @@ void test_ike_sa_id(tester_t *tester)
|
|||
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_false(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
tester->assert_true(tester,(other4->replace_values(other4,ike_sa_id) == SUCCESS), "replace values call check");
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_true(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
|
||||
/* check destroy functionality */
|
||||
tester->assert_true(tester,(ike_sa_id->destroy(ike_sa_id) == SUCCESS), "destroy call check");
|
||||
|
|
Loading…
Reference in a new issue