ike-rekey: Add method to check if there was a rekey collision
authorTobias Brunner <tobias@strongswan.org>
Tue, 31 May 2016 10:19:53 +0000 (12:19 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 17 Jun 2016 16:48:06 +0000 (18:48 +0200)
src/libcharon/sa/ikev2/tasks/ike_rekey.c
src/libcharon/sa/ikev2/tasks/ike_rekey.h

index 828e739..2d0b8f2 100644 (file)
@@ -380,6 +380,13 @@ METHOD(task_t, get_type, task_type_t,
        return TASK_IKE_REKEY;
 }
 
+METHOD(ike_rekey_t, did_collide, bool,
+       private_ike_rekey_t *this)
+{
+       return this->collision &&
+                  this->collision->get_type(this->collision) == TASK_IKE_REKEY;
+}
+
 METHOD(ike_rekey_t, collide, void,
        private_ike_rekey_t* this, task_t *other)
 {
@@ -444,6 +451,7 @@ ike_rekey_t *ike_rekey_create(ike_sa_t *ike_sa, bool initiator)
                                .migrate = _migrate,
                                .destroy = _destroy,
                        },
+                       .did_collide = _did_collide,
                        .collide = _collide,
                },
                .ike_sa = ike_sa,
index 6a12e90..86b512c 100644 (file)
@@ -1,6 +1,7 @@
 /*
+ * Copyright (C) 2016 Tobias Brunner
  * Copyright (C) 2007 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -38,6 +39,13 @@ struct ike_rekey_t {
        task_t task;
 
        /**
+        * Check if there was a rekey collision.
+        *
+        * @return                      TRUE if there was a rekey collision before
+        */
+       bool (*did_collide)(ike_rekey_t *this);
+
+       /**
         * Register a rekeying task which collides with this one.
         *
         * If two peers initiate rekeying at the same time, the collision must