Added add_segment() method to TCG/SEG attributes
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 5 Oct 2014 17:14:38 +0000 (19:14 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 5 Oct 2014 17:14:38 +0000 (19:14 +0200)
src/libimcv/tcg/seg/tcg_seg_attr_max_size.c
src/libimcv/tcg/seg/tcg_seg_attr_next_seg.c
src/libimcv/tcg/seg/tcg_seg_attr_seg_env.c

index 017bf2c..010eaf8 100644 (file)
@@ -148,14 +148,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
        return SUCCESS;
 }
 
-METHOD(pa_tnc_attr_t, destroy, void,
-       private_tcg_seg_attr_max_size_t *this)
+METHOD(pa_tnc_attr_t, add_segment, void,
+       private_tcg_seg_attr_max_size_t *this, chunk_t segment)
 {
-       if (ref_put(&this->ref))
-       {
-               free(this->value.ptr);
-               free(this);
-       }
+       this->value = chunk_cat("mc", this->value, segment);
 }
 
 METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
@@ -165,6 +161,16 @@ METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
        return &this->public.pa_tnc_attribute;
 }
 
+METHOD(pa_tnc_attr_t, destroy, void,
+       private_tcg_seg_attr_max_size_t *this)
+{
+       if (ref_put(&this->ref))
+       {
+               free(this->value.ptr);
+               free(this);
+       }
+}
+
 METHOD(tcg_seg_attr_max_size_t, get_attr_size, void,
        private_tcg_seg_attr_max_size_t *this, uint32_t *max_attr_size,
                                                                                   uint32_t *max_seg_size)
@@ -197,6 +203,7 @@ pa_tnc_attr_t* tcg_seg_attr_max_size_create(uint32_t max_attr_size,
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },
@@ -230,6 +237,7 @@ pa_tnc_attr_t *tcg_seg_attr_max_size_create_from_data(size_t length,
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },
index c2dcad3..995f64c 100644 (file)
@@ -157,14 +157,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
        return SUCCESS;
 }
 
-METHOD(pa_tnc_attr_t, destroy, void,
-       private_tcg_seg_attr_next_seg_t *this)
+METHOD(pa_tnc_attr_t, add_segment, void,
+       private_tcg_seg_attr_next_seg_t *this, chunk_t segment)
 {
-       if (ref_put(&this->ref))
-       {
-               free(this->value.ptr);
-               free(this);
-       }
+       this->value = chunk_cat("mc", this->value, segment);
 }
 
 METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
@@ -174,6 +170,16 @@ METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
        return &this->public.pa_tnc_attribute;
 }
 
+METHOD(pa_tnc_attr_t, destroy, void,
+       private_tcg_seg_attr_next_seg_t *this)
+{
+       if (ref_put(&this->ref))
+       {
+               free(this->value.ptr);
+               free(this);
+       }
+}
+
 METHOD(tcg_seg_attr_next_seg_t, get_base_attr_id, uint32_t,
        private_tcg_seg_attr_next_seg_t *this)
 {
@@ -202,6 +208,7 @@ pa_tnc_attr_t* tcg_seg_attr_next_seg_create(uint32_t base_attr_id, bool cancel)
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },
@@ -234,6 +241,7 @@ pa_tnc_attr_t *tcg_seg_attr_next_seg_create_from_data(size_t length,
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },
index fb53212..4f76753 100644 (file)
@@ -127,14 +127,14 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        if (this->value.len < this->length)
        {
-               DBG1(DBG_TNC, "segmentation not allowed for %N", tcg_attr_names,
-                                                                                                                this->type.type);
+               DBG1(DBG_TNC, "segmentation not allowed for %N/%N", pen_names, PEN_TCG,
+                                          tcg_attr_names, this->type.type);
                return FAILED;
        }
        if (this->value.len < TCG_SEG_ATTR_SEG_ENV_HEADER)
        {
-               DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names,
-                                                                                                 this->type.type);
+               DBG1(DBG_TNC, "insufficient data for %N/%N", pen_names, PEN_TCG,
+                                          tcg_attr_names, this->type.type);
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -145,14 +145,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
        return SUCCESS;
 }
 
-METHOD(pa_tnc_attr_t, destroy, void,
-       private_tcg_seg_attr_seg_env_t *this)
+METHOD(pa_tnc_attr_t, add_segment, void,
+       private_tcg_seg_attr_seg_env_t *this, chunk_t segment)
 {
-       if (ref_put(&this->ref))
-       {
-               free(this->value.ptr);
-               free(this);
-       }
+       /* no segments are expected */
 }
 
 METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
@@ -162,6 +158,16 @@ METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
        return &this->public.pa_tnc_attribute;
 }
 
+METHOD(pa_tnc_attr_t, destroy, void,
+       private_tcg_seg_attr_seg_env_t *this)
+{
+       if (ref_put(&this->ref))
+       {
+               free(this->value.ptr);
+               free(this);
+       }
+}
+
 METHOD(tcg_seg_attr_seg_env_t, get_segment, chunk_t,
        private_tcg_seg_attr_seg_env_t *this, uint8_t *flags)
 {
@@ -195,6 +201,7 @@ pa_tnc_attr_t* tcg_seg_attr_seg_env_create(chunk_t segment, uint8_t flags,
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },
@@ -233,6 +240,7 @@ pa_tnc_attr_t *tcg_seg_attr_seg_env_create_from_data(size_t length,
                                .set_noskip_flag = _set_noskip_flag,
                                .build = _build,
                                .process = _process,
+                               .add_segment = _add_segment,
                                .get_ref = _get_ref,
                                .destroy = _destroy,
                        },