clear reason strings after delivering them
authorAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 15 Jun 2011 11:53:53 +0000 (13:53 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 15 Jun 2011 11:53:53 +0000 (13:53 +0200)
src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/tnc/imv/imv_recommendations.h

index 3459619..5311696 100644 (file)
@@ -360,6 +360,21 @@ METHOD(recommendations_t, create_reason_enumerator, enumerator_t*,
                                        (void*)reason_filter, NULL, NULL);
 }
 
+METHOD(recommendations_t, clear_reasons, void,
+       private_tnc_imv_recommendations_t *this)
+{
+       enumerator_t *enumerator;
+       recommendation_entry_t *entry;
+
+       enumerator = this->recs->create_enumerator(this->recs);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               chunk_clear(&entry->reason);
+               chunk_clear(&entry->reason_language);
+       }
+       enumerator->destroy(enumerator);
+}
+
 METHOD(recommendations_t, destroy, void,
        private_tnc_imv_recommendations_t *this)
 {
@@ -395,6 +410,7 @@ recommendations_t* tnc_imv_recommendations_create(linked_list_t *imv_list)
                        .set_reason_string = _set_reason_string,
                        .set_reason_language = _set_reason_language,
                        .create_reason_enumerator = _create_reason_enumerator,
+                       .clear_reasons = _clear_reasons,
                        .destroy = _destroy,
                },
                .recs = linked_list_create(),
index 9d47437..97a8bb4 100644 (file)
@@ -351,6 +351,7 @@ static void check_and_build_recommendation(private_tnccs_11_t *this)
                        this->batch->add_msg(this->batch, msg);
                }
                enumerator->destroy(enumerator);
+               this->recs->clear_reasons(this->recs);
 
                /* we have reache the final state */
                this->delete_state = TRUE;
index 721429d..2038a9a 100644 (file)
@@ -521,6 +521,7 @@ static void check_and_build_recommendation(private_tnccs_20_t *this)
                        this->batch->add_msg(this->batch, msg);
                }
                enumerator->destroy(enumerator);
+               this->recs->clear_reasons(this->recs);
        }
 }
 
index 071b6b3..d694e16 100644 (file)
@@ -108,6 +108,12 @@ struct recommendations_t {
         * @return                              enumerator
         */
        enumerator_t* (*create_reason_enumerator)(recommendations_t *this);
+
+       /**
+        * Clears all reason entries
+        */
+       void (*clear_reasons)(recommendations_t *this);
+
        /**
         * Destroys an imv_t object.
         */