Support installing of quick mode SAs with a specific reqid
authorMartin Willi <martin@revosec.ch>
Mon, 2 Jan 2012 12:36:10 +0000 (13:36 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:31 +0000 (17:31 +0100)
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev1/tasks/quick_mode.h

index 371cdf7..f388bc8 100644 (file)
@@ -1158,7 +1158,12 @@ METHOD(task_manager_t, queue_child, void,
        private_task_manager_t *this, child_cfg_t *cfg, u_int32_t reqid,
        traffic_selector_t *tsi, traffic_selector_t *tsr)
 {
-       queue_task(this, (task_t*)quick_mode_create(this->ike_sa, cfg, tsi, tsr));
+       quick_mode_t *task;
+
+       task = quick_mode_create(this->ike_sa, cfg, tsi, tsr);
+       task->use_reqid(task, reqid);
+
+       queue_task(this, &task->task);
 }
 
 METHOD(task_manager_t, queue_child_rekey, void,
index 017ce97..b9acdb0 100644 (file)
@@ -114,6 +114,11 @@ struct private_quick_mode_t {
         */
        u_int64_t lifebytes;
 
+       /**
+        * Reqid to use, 0 for auto-allocate
+        */
+       u_int32_t reqid;
+
        /** states of quick mode */
        enum {
                QM_INIT,
@@ -552,7 +557,7 @@ METHOD(task_t, build_i, status_t,
                        this->child_sa = child_sa_create(
                                                                        this->ike_sa->get_my_host(this->ike_sa),
                                                                        this->ike_sa->get_other_host(this->ike_sa),
-                                                                       this->config, 0, udp);
+                                                                       this->config, this->reqid, udp);
 
                        list = this->config->get_proposals(this->config, FALSE);
 
@@ -753,7 +758,7 @@ METHOD(task_t, process_r, status_t,
                        this->child_sa = child_sa_create(
                                                                        this->ike_sa->get_my_host(this->ike_sa),
                                                                        this->ike_sa->get_other_host(this->ike_sa),
-                                                                       this->config, 0, udp);
+                                                                       this->config, this->reqid, udp);
                        return NEED_MORE;
                }
                case QM_NEGOTIATED:
@@ -888,6 +893,12 @@ METHOD(task_t, get_type, task_type_t,
        return TASK_QUICK_MODE;
 }
 
+METHOD(quick_mode_t, use_reqid, void,
+       private_quick_mode_t *this, u_int32_t reqid)
+{
+       this->reqid = reqid;
+}
+
 METHOD(task_t, migrate, void,
        private_quick_mode_t *this, ike_sa_t *ike_sa)
 {
@@ -946,6 +957,7 @@ quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
                                .migrate = _migrate,
                                .destroy = _destroy,
                        },
+                       .use_reqid = _use_reqid,
                },
                .ike_sa = ike_sa,
                .initiator = config != NULL,
index 82790c7..88fbe49 100644 (file)
@@ -36,6 +36,13 @@ struct quick_mode_t {
         * Implements the task_t interface
         */
        task_t task;
+
+       /**
+        * Use a specific reqid to install this CHILD_SA.
+        *
+        * @param reqid                 reqid to use
+        */
+       void (*use_reqid)(quick_mode_t *this, u_int32_t reqid);
 };
 
 /**