aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-11-08 10:03:40 +0000
committerJan Hutter <jhutter@hsr.ch>2005-11-08 10:03:40 +0000
commit8491b29826d8235679c6bfab585feb8edf24a6a7 (patch)
tree841112e715261d3f1f9aaf377296514c3e78c377
parent31732357685298c7bd3a395c6317fe5a66a86da4 (diff)
downloadstrongswan-8491b29826d8235679c6bfab585feb8edf24a6a7.tar.bz2
strongswan-8491b29826d8235679c6bfab585feb8edf24a6a7.tar.xz
- added function replace_values
-rw-r--r--Source/charon/ike_sa_id.c33
-rw-r--r--Source/charon/ike_sa_id.h28
-rw-r--r--Source/charon/tests/ike_sa_id_test.c5
3 files changed, 51 insertions, 15 deletions
diff --git a/Source/charon/ike_sa_id.c b/Source/charon/ike_sa_id.c
index 8a882a7ca..c8065e875 100644
--- a/Source/charon/ike_sa_id.c
+++ b/Source/charon/ike_sa_id.c
@@ -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 */
diff --git a/Source/charon/ike_sa_id.h b/Source/charon/ike_sa_id.h
index fce7fc54d..8b911a57b 100644
--- a/Source/charon/ike_sa_id.h
+++ b/Source/charon/ike_sa_id.h
@@ -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);
diff --git a/Source/charon/tests/ike_sa_id_test.c b/Source/charon/tests/ike_sa_id_test.c
index d822bb58a..b8147c1b3 100644
--- a/Source/charon/tests/ike_sa_id_test.c
+++ b/Source/charon/tests/ike_sa_id_test.c
@@ -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");