- role refactored to is_initiator-boolean
authorMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:04:37 +0000 (16:04 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:04:37 +0000 (16:04 -0000)
- spi_t is a u_int64_t now

Source/charon/ike_sa_id.c
Source/charon/ike_sa_id.h

index 9f83ed5..c498492 100644 (file)
@@ -55,7 +55,7 @@ struct private_ike_sa_id_s {
        /**
         * Role for specific IKE_SA
         */
-       ike_sa_role_t role;
+       bool is_initiator;
 
 };
 
@@ -80,7 +80,7 @@ static status_t set_initiator_spi(private_ike_sa_id_t *this, spi_t initiator_spi
  */
 static bool initiator_spi_is_set (private_ike_sa_id_t *this)
 {
-       return (!((this->initiator_spi.high == 0) && (this->initiator_spi.low == 0)));
+       return (!(this->initiator_spi == 0));
 }
 
 /**
@@ -88,7 +88,7 @@ static bool initiator_spi_is_set (private_ike_sa_id_t *this)
  */
 static bool responder_spi_is_set (private_ike_sa_id_t *this)
 {
-       return (!((this->responder_spi.high == 0) && (this->responder_spi.low == 0)));
+       return (!(this->responder_spi == 0));
 }
 
 /**
@@ -100,11 +100,9 @@ static status_t equals (private_ike_sa_id_t *this,private_ike_sa_id_t *other, bo
        {
                return FAILED;
        }
-       if (    (this->role == other->role) &&
-               (this->initiator_spi.high == other->initiator_spi.high) &&
-               (this->initiator_spi.low == other->initiator_spi.low) &&
-               (this->responder_spi.high == other->responder_spi.high) &&
-               (this->responder_spi.low == other->responder_spi.low))
+       if ((this->is_initiator == other->is_initiator) &&
+               (this->initiator_spi == other->initiator_spi) &&
+               (this->responder_spi == other->responder_spi))
        {
                /* private_ike_sa_id's are equal */
                *are_equal = TRUE;
@@ -130,7 +128,7 @@ status_t replace_values (private_ike_sa_id_t *this, private_ike_sa_id_t *other)
 
        this->initiator_spi = other->initiator_spi;
        this->responder_spi = other->responder_spi;
-       this->role = other->role;
+       this->is_initiator = other->is_initiator;
 
        return SUCCESS;
 }
@@ -138,11 +136,11 @@ status_t replace_values (private_ike_sa_id_t *this, private_ike_sa_id_t *other)
 /**
  * @brief implements function ike_sa_id_t.get_values
  */
-static status_t get_values(private_ike_sa_id_t *this, spi_t *initiator, spi_t *responder, ike_sa_role_t *role)
+static status_t get_values(private_ike_sa_id_t *this, spi_t *initiator, spi_t *responder, bool *is_initiator)
 {
        memcpy(initiator, &(this->initiator_spi), sizeof(initiator));
        memcpy(responder, &(this->responder_spi), sizeof(responder));
-       *role = this->role;
+       *is_initiator = this->is_initiator;
 
        return SUCCESS;
 }
@@ -153,7 +151,7 @@ static status_t get_values(private_ike_sa_id_t *this, spi_t *initiator, spi_t *r
  */
 static status_t clone (private_ike_sa_id_t *this, ike_sa_id_t **clone_of_this)
 {
-       *clone_of_this = ike_sa_id_create(this->initiator_spi, this->responder_spi, this->role);
+       *clone_of_this = ike_sa_id_create(this->initiator_spi, this->responder_spi, this->is_initiator);
 
        return (*clone_of_this == NULL) ? OUT_OF_RES : SUCCESS;
 }
@@ -170,7 +168,7 @@ static status_t destroy (private_ike_sa_id_t *this)
 /*
  * Described in Header-File
  */
-ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_role_t role)
+ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, bool is_initiator)
 {
        private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t);
        if (this == NULL)
@@ -185,14 +183,14 @@ ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_
        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.get_values = (status_t(*)(ike_sa_id_t*,spi_t*,spi_t*,ike_sa_role_t*)) get_values;
+       this->public.get_values = (status_t(*)(ike_sa_id_t*,spi_t*,spi_t*,bool*)) get_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 */
        this->initiator_spi = initiator_spi;
        this->responder_spi = responder_spi;
-       this->role = role;
+       this->is_initiator = is_initiator;
 
        return (&this->public);
 }
index cae7656..403c506 100644 (file)
@@ -100,10 +100,10 @@ struct ike_sa_id_s {
         * @param this ike_sa_id_t object
         * @param initiator address to write initator spi
         * @param responder address to write responder spi
-        * @param role address to write role
+        * @param is_initiator address to write role
         * @return SUCCESSFUL if succeeded, FAILED otherwise
         */
-       status_t (*get_values) (ike_sa_id_t *this, spi_t *initiator, spi_t *responder, ike_sa_role_t *role);
+       status_t (*get_values) (ike_sa_id_t *this, spi_t *initiator, spi_t *responder, bool *is_initiator);
 
        /**
         * @brief Clones a given ike_sa_id_t object
@@ -128,6 +128,6 @@ struct ike_sa_id_s {
  *
  * @warning The initiator SPI and role is not changeable after initiating a ike_sa_id object
  */
-ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi,ike_sa_role_t role);
+ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, bool is_initiaor);
 
 #endif /*IKE_SA_ID_H_*/