- proposal_substructure written and tested
authorJan Hutter <jhutter@hsr.ch>
Mon, 14 Nov 2005 17:24:18 +0000 (17:24 -0000)
committerJan Hutter <jhutter@hsr.ch>
Mon, 14 Nov 2005 17:24:18 +0000 (17:24 -0000)
Source/charon/payloads/proposal_substructure.c
Source/charon/payloads/transform_substructure.c

index e6472ed..ce9e204 100644 (file)
@@ -208,8 +208,20 @@ static status_t create_transform_substructure_iterator (private_proposal_substru
  */
 static status_t add_transform_substructure (private_proposal_substructure_t *this,transform_substructure_t *transform)
 {
-       return (this->transforms->insert_last(this->transforms,(void *) transform));
+       status_t status;
+       if (this->transforms->get_count(this->transforms) > 0)
+       {
+               transform_substructure_t *last_transform;
+               status = this->transforms->get_last(this->transforms,(void **) &last_transform);
+               /* last transform is now not anymore last one */
+               last_transform->set_is_last_transform(last_transform,FALSE);
+
+       }
+       transform->set_is_last_transform(transform,TRUE);
+       
+       status = this->transforms->insert_last(this->transforms,(void *) transform);
        this->compute_length(this);
+       return status;
 }
 
 /**
@@ -313,11 +325,9 @@ static status_t compute_length (private_proposal_substructure_t *this)
                length += current_transform->get_length(current_transform);
                transforms_count++;
        }
-       
+       iterator->destroy(iterator);
        
        length += this->spi.len;
-       
-       
        this->transforms_count= transforms_count;
        this->proposal_length = length; 
 
index b8574e7..995f96e 100644 (file)
@@ -187,9 +187,10 @@ static status_t create_transform_attribute_iterator (private_transform_substruct
  */
 static status_t add_transform_attribute (private_transform_substructure_t *this,transform_attribute_t *attribute)
 {
-       return (this->attributes->insert_last(this->attributes,(void *) attribute));
+       status_t status;
+       status = this->attributes->insert_last(this->attributes,(void *) attribute);
        this->compute_length(this);
-       return SUCCESS;
+       return status;
 }
 
 /**
@@ -198,7 +199,7 @@ static status_t add_transform_attribute (private_transform_substructure_t *this,
  */
 static status_t set_is_last_transform (private_transform_substructure_t *this, bool is_last)
 {
-       this->next_payload = (is_last) ? 0 : TRANSFORM_TYPE_VALUE;
+       this->next_payload = (is_last) ? 0: TRANSFORM_TYPE_VALUE;
        return SUCCESS;
 }
 
@@ -269,6 +270,7 @@ static status_t compute_length (private_transform_substructure_t *this)
                iterator->current(iterator,(void **) &current_attribute);
                length += current_attribute->get_length(current_attribute);
        }
+       iterator->destroy(iterator);
                
        return SUCCESS;
 }