}
/**
- * Implementation of auth_info_t.destroy
+ * Implementation of auth_info_t.purge
*/
-static void destroy(private_auth_info_t *this)
+static void purge(private_auth_info_t *this)
{
item_t *item;
destroy_item_value(item);
free(item);
}
+}
+
+/**
+ * Implementation of auth_info_t.destroy
+ */
+static void destroy(private_auth_info_t *this)
+{
+ purge(this);
this->items->destroy(this->items);
free(this);
}
this->public.create_item_enumerator = (enumerator_t*(*)(auth_info_t*))create_item_enumerator;
this->public.complies = (bool(*)(auth_info_t*, auth_info_t *))complies;
this->public.merge = (void(*)(auth_info_t*, auth_info_t *other))merge;
+ this->public.purge = (void(*)(auth_info_t*))purge;
this->public.equals = (bool(*)(auth_info_t*, auth_info_t *other))equals;
this->public.destroy = (void(*)(auth_info_t*))destroy;
*/
void (*merge)(auth_info_t *this, auth_info_t *other);
+ /**
+ * Purge all items in auth_info.
+ */
+ void (*purge)(auth_info_t *this);
+
/**
* Check two auth_infos for equality.
*
break;
}
charon->bus->ike_state_change(charon->bus, &this->public, state);
+ if (state == IKE_ESTABLISHED)
+ { /* purge auth items after hook invocation, as they contain certs
+ * and other memory wasting elements */
+ this->my_auth->purge(this->my_auth);
+ this->other_auth->purge(this->other_auth);
+ }
this->state = state;
}