Added factory function to create task_manager_t implementations.
authorTobias Brunner <tobias@strongswan.org>
Thu, 17 Nov 2011 15:54:25 +0000 (16:54 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 20 Mar 2012 16:30:43 +0000 (17:30 +0100)
src/libcharon/Makefile.am
src/libcharon/sa/ike_sa.c
src/libcharon/sa/task_manager.c [new file with mode: 0644]

index 5defff6..9b9bac0 100644 (file)
@@ -67,7 +67,7 @@ sa/child_sa.c sa/child_sa.h \
 sa/ike_sa.c sa/ike_sa.h \
 sa/ike_sa_id.c sa/ike_sa_id.h \
 sa/ike_sa_manager.c sa/ike_sa_manager.h \
 sa/ike_sa.c sa/ike_sa.h \
 sa/ike_sa_id.c sa/ike_sa_id.h \
 sa/ike_sa_manager.c sa/ike_sa_manager.h \
-sa/task_manager.h sa/task_manager_v2.c sa/task_manager_v2.h \
+sa/task_manager.h sa/task_manager.c sa/task_manager_v2.c sa/task_manager_v2.h \
 sa/task_manager_v1.c sa/task_manager_v1.h \
 sa/keymat.h sa/keymat.c sa/keymat_v2.c sa/keymat_v2.h \
 sa/keymat_v1.c sa/keymat_v1.h \
 sa/task_manager_v1.c sa/task_manager_v1.h \
 sa/keymat.h sa/keymat.c sa/keymat_v2.c sa/keymat_v2.h \
 sa/keymat_v1.c sa/keymat_v1.h \
index e060c5a..36ceea1 100644 (file)
@@ -28,7 +28,6 @@
 #include <daemon.h>
 #include <utils/linked_list.h>
 #include <utils/lexparser.h>
 #include <daemon.h>
 #include <utils/linked_list.h>
 #include <utils/lexparser.h>
-#include <sa/task_manager_v2.h>
 #include <sa/tasks/ike_init.h>
 #include <sa/tasks/ike_natd.h>
 #include <sa/tasks/ike_mobike.h>
 #include <sa/tasks/ike_init.h>
 #include <sa/tasks/ike_natd.h>
 #include <sa/tasks/ike_mobike.h>
@@ -2225,7 +2224,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, ike_version_t version)
                                                                        "charon.keep_alive", KEEPALIVE_INTERVAL),
        );
 
                                                                        "charon.keep_alive", KEEPALIVE_INTERVAL),
        );
 
-       this->task_manager = &(task_manager_v2_create(&this->public)->task_manager);
+       this->task_manager = task_manager_create(&this->public);
        this->my_host->set_port(this->my_host, IKEV2_UDP_PORT);
 
        return &this->public;
        this->my_host->set_port(this->my_host, IKEV2_UDP_PORT);
 
        return &this->public;
diff --git a/src/libcharon/sa/task_manager.c b/src/libcharon/sa/task_manager.c
new file mode 100644 (file)
index 0000000..eea2320
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 Tobias Brunner
+ * 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "task_manager.h"
+#include "task_manager_v1.h"
+#include "task_manager_v2.h"
+
+/**
+ * See header
+ */
+task_manager_t *task_manager_create(ike_sa_t *ike_sa)
+{
+       switch (ike_sa->get_version(ike_sa))
+       {
+               case IKEV1:
+                       return &task_manager_v1_create(ike_sa)->task_manager;
+               case IKEV2:
+                       return &task_manager_v2_create(ike_sa)->task_manager;
+       }
+       return NULL;
+}