]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike: Create an enumerator for (un-)handled configuration attributes on IKE_SA
authorMartin Willi <martin@revosec.ch>
Tue, 11 Feb 2014 09:12:24 +0000 (10:12 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 16 Jun 2014 13:59:17 +0000 (15:59 +0200)
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ike_sa.h

index 3ef9801e093cc48bb6590813f3b5f07497be3f46..8c7817520afa3d63a5d1debb8fa67ac9212c2b35 100644 (file)
@@ -2001,6 +2001,26 @@ METHOD(ike_sa_t, add_configuration_attribute, void,
        array_insert(this->attributes, ARRAY_TAIL, &entry);
 }
 
+/**
+ * Enumerator filter for attributes
+ */
+static bool filter_attribute(void *null, attribute_entry_t **in,
+                                                        configuration_attribute_type_t *type, void *in2,
+                                                        chunk_t *data, void *in3, bool *handled)
+{
+       *type = (*in)->type;
+       *data = (*in)->data;
+       *handled = (*in)->handler != NULL;
+       return TRUE;
+}
+
+METHOD(ike_sa_t, create_attribute_enumerator, enumerator_t*,
+       private_ike_sa_t *this)
+{
+       return enumerator_create_filter(array_create_enumerator(this->attributes),
+                                                                       (void*)filter_attribute, NULL, NULL);
+}
+
 METHOD(ike_sa_t, create_task_enumerator, enumerator_t*,
        private_ike_sa_t *this, task_queue_t queue)
 {
@@ -2317,6 +2337,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
                        .clear_virtual_ips = _clear_virtual_ips,
                        .create_virtual_ip_enumerator = _create_virtual_ip_enumerator,
                        .add_configuration_attribute = _add_configuration_attribute,
+                       .create_attribute_enumerator = _create_attribute_enumerator,
                        .set_kmaddress = _set_kmaddress,
                        .create_task_enumerator = _create_task_enumerator,
                        .flush_queue = _flush_queue,
index 5dc7326a4c611308927c0b49b416d1303abf61c1..15fb474842f44b7b60c694ba16c9348d39a4562e 100644 (file)
@@ -989,6 +989,17 @@ struct ike_sa_t {
                                                        attribute_handler_t *handler,
                                                        configuration_attribute_type_t type, chunk_t data);
 
+       /**
+        * Create an enumerator over received configuration attributes.
+        *
+        * The resulting enumerator is over the configuration_attribute_type_t type,
+        * a value chunk_t followed by a bool flag. The boolean flag indicates if
+        * the attribute has been handled by an attribute handler.
+        *
+        * @return                              enumerator over type, value and the "handled" flag.
+        */
+       enumerator_t* (*create_attribute_enumerator)(ike_sa_t *this);
+
        /**
         * Set local and remote host addresses to be used for IKE.
         *