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_v1.c sa/task_manager_v1.h \
-sa/keymat.h sa/keymat_v2.c sa/keymat_v2.h \
+sa/keymat.h sa/keymat.c sa/keymat_v2.c sa/keymat_v2.h \
sa/keymat_v1.c sa/keymat_v1.h \
sa/shunt_manager.c sa/shunt_manager.h \
sa/trap_manager.c sa/trap_manager.h \
#include <daemon.h>
#include <utils/linked_list.h>
#include <utils/lexparser.h>
-#include <sa/keymat_v2.h>
#include <sa/task_manager_v2.h>
#include <sa/tasks/ike_init.h>
#include <sa/tasks/ike_natd.h>
flush_auth_cfgs(this);
this->keymat->destroy(this->keymat);
- this->keymat = &(keymat_v2_create(this->ike_sa_id->is_initiator(this->ike_sa_id))->keymat);
+ this->keymat = keymat_create(this->version,
+ this->ike_sa_id->is_initiator(this->ike_sa_id));
this->task_manager->reset(this->task_manager, 0, 0);
}
.other_host = host_create_any(AF_INET),
.my_id = identification_create_from_encoding(ID_ANY, chunk_empty),
.other_id = identification_create_from_encoding(ID_ANY, chunk_empty),
+ .keymat = keymat_create(version, ike_sa_id->is_initiator(ike_sa_id)),
.state = IKE_CREATED,
.stats[STAT_INBOUND] = time_monotonic(NULL),
.stats[STAT_OUTBOUND] = time_monotonic(NULL),
.keepalive_interval = lib->settings->get_time(lib->settings,
"charon.keep_alive", KEEPALIVE_INTERVAL),
);
- this->keymat = &(keymat_v2_create(ike_sa_id->is_initiator(ike_sa_id))->keymat);
+
this->task_manager = &(task_manager_v2_create(&this->public)->task_manager);
this->my_host->set_port(this->my_host, IKEV2_UDP_PORT);
--- /dev/null
+/*
+ * 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 "keymat.h"
+#include "keymat_v1.h"
+#include "keymat_v2.h"
+
+/**
+ * See header
+ */
+keymat_t *keymat_create(ike_version_t version, bool initiator)
+{
+ switch (version)
+ {
+ case IKEV1:
+ return &keymat_v1_create(initiator)->keymat;
+ case IKEV2:
+ return &keymat_v2_create(initiator)->keymat;
+ }
+ return NULL;
+}
#ifndef KEYMAT_H_
#define KEYMAT_H_
+typedef struct keymat_t keymat_t;
+
#include <library.h>
#include <utils/identification.h>
#include <crypto/prfs/prf.h>
#include <crypto/aead.h>
#include <config/proposal.h>
+#include <config/peer_cfg.h> /* for ike_version_t */
#include <sa/ike_sa_id.h>
-typedef struct keymat_t keymat_t;
-
/**
* Derivation an management of sensitive keying material.
*/
void (*destroy)(keymat_t *this);
};
+/**
+ * Create the appropriate keymat_t implementation based on the IKE version.
+ *
+ * @param version requested IKE version
+ * @param initiator TRUE if we are initiator
+ * @return keymat_t implmenetation
+ */
+keymat_t *keymat_create(ike_version_t version, bool initiator);
+
#endif /** KEYMAT_H_ @}*/