From: Martin Willi Date: Tue, 11 Feb 2014 09:12:24 +0000 (+0100) Subject: ike: Create an enumerator for (un-)handled configuration attributes on IKE_SA X-Git-Tag: 5.2.0rc1~54^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d257034d86c6ed47dbd0d6d0e0c6f618dd0a6af;p=thirdparty%2Fstrongswan.git ike: Create an enumerator for (un-)handled configuration attributes on IKE_SA --- diff --git a/src/libcharon/sa/ike_sa.c b/src/libcharon/sa/ike_sa.c index 3ef9801e09..8c7817520a 100644 --- a/src/libcharon/sa/ike_sa.c +++ b/src/libcharon/sa/ike_sa.c @@ -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, diff --git a/src/libcharon/sa/ike_sa.h b/src/libcharon/sa/ike_sa.h index 5dc7326a4c..15fb474842 100644 --- a/src/libcharon/sa/ike_sa.h +++ b/src/libcharon/sa/ike_sa.h @@ -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. *