summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/eap_simaka_sql
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
committerYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
commitb34738ed08c2227300d554b139e2495ca5da97d6 (patch)
tree62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libcharon/plugins/eap_simaka_sql
parent0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff)
downloadvyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz
vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libcharon/plugins/eap_simaka_sql')
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/Makefile.am3
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/Makefile.in13
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.c4
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.h6
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_plugin.c114
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.c12
-rw-r--r--src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.h6
7 files changed, 111 insertions, 47 deletions
diff --git a/src/libcharon/plugins/eap_simaka_sql/Makefile.am b/src/libcharon/plugins/eap_simaka_sql/Makefile.am
index 73768be0e..c83267e67 100644
--- a/src/libcharon/plugins/eap_simaka_sql/Makefile.am
+++ b/src/libcharon/plugins/eap_simaka_sql/Makefile.am
@@ -1,6 +1,6 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
- -I$(top_srcdir)/src/libcharon
+ -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
AM_CFLAGS = -rdynamic -DIPSEC_CONFDIR=\"${sysconfdir}\"
@@ -8,6 +8,7 @@ if MONOLITHIC
noinst_LTLIBRARIES = libstrongswan-eap-simaka-sql.la
else
plugin_LTLIBRARIES = libstrongswan-eap-simaka-sql.la
+libstrongswan_eap_simaka_sql_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.la
endif
libstrongswan_eap_simaka_sql_la_SOURCES = \
diff --git a/src/libcharon/plugins/eap_simaka_sql/Makefile.in b/src/libcharon/plugins/eap_simaka_sql/Makefile.in
index 93c7aed03..3639e24e8 100644
--- a/src/libcharon/plugins/eap_simaka_sql/Makefile.in
+++ b/src/libcharon/plugins/eap_simaka_sql/Makefile.in
@@ -74,7 +74,8 @@ am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(plugindir)"
LTLIBRARIES = $(noinst_LTLIBRARIES) $(plugin_LTLIBRARIES)
-libstrongswan_eap_simaka_sql_la_LIBADD =
+@MONOLITHIC_FALSE@libstrongswan_eap_simaka_sql_la_DEPENDENCIES = \
+@MONOLITHIC_FALSE@ $(top_builddir)/src/libsimaka/libsimaka.la
am_libstrongswan_eap_simaka_sql_la_OBJECTS = eap_simaka_sql_plugin.lo \
eap_simaka_sql_card.lo eap_simaka_sql_provider.lo
libstrongswan_eap_simaka_sql_la_OBJECTS = \
@@ -195,6 +196,9 @@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
+attest_plugins = @attest_plugins@
+axis2c_CFLAGS = @axis2c_CFLAGS@
+axis2c_LIBS = @axis2c_LIBS@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@@ -203,6 +207,7 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
@@ -219,11 +224,13 @@ host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
+imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
+ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -267,6 +274,7 @@ sharedstatedir = @sharedstatedir@
soup_CFLAGS = @soup_CFLAGS@
soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
+starter_plugins = @starter_plugins@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@
@@ -278,11 +286,12 @@ urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
- -I$(top_srcdir)/src/libcharon
+ -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
AM_CFLAGS = -rdynamic -DIPSEC_CONFDIR=\"${sysconfdir}\"
@MONOLITHIC_TRUE@noinst_LTLIBRARIES = libstrongswan-eap-simaka-sql.la
@MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-eap-simaka-sql.la
+@MONOLITHIC_FALSE@libstrongswan_eap_simaka_sql_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.la
libstrongswan_eap_simaka_sql_la_SOURCES = \
eap_simaka_sql_plugin.h eap_simaka_sql_plugin.c \
eap_simaka_sql_card.h eap_simaka_sql_card.c \
diff --git a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.c b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.c
index b7590405f..90627b52e 100644
--- a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.c
+++ b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.c
@@ -42,7 +42,7 @@ struct private_eap_simaka_sql_card_t {
bool remove_used;
};
-METHOD(sim_card_t, get_triplet, bool,
+METHOD(simaka_card_t, get_triplet, bool,
private_eap_simaka_sql_card_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
@@ -90,7 +90,7 @@ METHOD(sim_card_t, get_triplet, bool,
return found;
}
-METHOD(sim_card_t, get_quintuplet, status_t,
+METHOD(simaka_card_t, get_quintuplet, status_t,
private_eap_simaka_sql_card_t *this, identification_t *id,
char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN],
char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len)
diff --git a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.h b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.h
index 46b7de25e..760755a56 100644
--- a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.h
+++ b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_card.h
@@ -22,7 +22,7 @@
#define EAP_SIMAKA_SQL_CARD_H_
#include <database/database.h>
-#include <sa/authenticators/eap/sim_manager.h>
+#include <simaka_manager.h>
typedef struct eap_simaka_sql_card_t eap_simaka_sql_card_t;
@@ -32,9 +32,9 @@ typedef struct eap_simaka_sql_card_t eap_simaka_sql_card_t;
struct eap_simaka_sql_card_t {
/**
- * Implements sim_card_t interface
+ * Implements simaka_card_t interface
*/
- sim_card_t card;
+ simaka_card_t card;
/**
* Destroy a eap_simaka_sql_card_t.
diff --git a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_plugin.c b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_plugin.c
index 5a528153d..6e590fae7 100644
--- a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_plugin.c
+++ b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_plugin.c
@@ -53,14 +53,93 @@ METHOD(plugin_t, get_name, char*,
return "eap-simaka-sql";
}
-METHOD(plugin_t, destroy, void,
- private_eap_simaka_sql_t *this)
+/**
+ * Load database
+ */
+static bool load_db(private_eap_simaka_sql_t *this,
+ plugin_feature_t *feature, bool reg, void *data)
{
- charon->sim->remove_card(charon->sim, &this->card->card);
- charon->sim->remove_provider(charon->sim, &this->provider->provider);
+ if (reg)
+ {
+ bool remove_used;
+ char *uri;
+
+ uri = lib->settings->get_str(lib->settings,
+ "charon.plugins.eap-simaka-sql.database", NULL);
+ if (!uri)
+ {
+ DBG1(DBG_CFG, "eap-simaka-sql database URI missing");
+ return FALSE;
+ }
+ this->db = lib->db->create(lib->db, uri);
+ if (!this->db)
+ {
+ DBG1(DBG_CFG, "opening eap-simaka-sql database failed");
+ return FALSE;
+ }
+ remove_used = lib->settings->get_bool(lib->settings,
+ "charon.plugins.eap-simaka-sql.remove_used", FALSE);
+
+ this->provider = eap_simaka_sql_provider_create(this->db, remove_used);
+ this->card = eap_simaka_sql_card_create(this->db, remove_used);
+ return TRUE;
+ }
this->card->destroy(this->card);
this->provider->destroy(this->provider);
this->db->destroy(this->db);
+ this->card = NULL;
+ this->provider = NULL;
+ this->db = NULL;
+ return TRUE;
+}
+
+/**
+ * Callback providing our card to register
+ */
+static simaka_card_t* get_card(private_eap_simaka_sql_t *this)
+{
+ return &this->card->card;
+}
+
+/**
+ * Callback providing our provider to register
+ */
+static simaka_provider_t* get_provider(private_eap_simaka_sql_t *this)
+{
+ return &this->provider->provider;
+}
+
+METHOD(plugin_t, get_features, int,
+ private_eap_simaka_sql_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK((void*)load_db, NULL),
+ PLUGIN_PROVIDE(CUSTOM, "eap-simaka-sql-db"),
+ PLUGIN_DEPENDS(DATABASE, DB_ANY),
+ PLUGIN_SDEPEND(DATABASE, DB_SQLITE),
+ PLUGIN_SDEPEND(DATABASE, DB_MYSQL),
+ PLUGIN_CALLBACK(simaka_manager_register, get_card),
+ PLUGIN_PROVIDE(CUSTOM, "aka-card"),
+ PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-simaka-sql-db"),
+ PLUGIN_PROVIDE(CUSTOM, "sim-card"),
+ PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-simaka-sql-db"),
+ PLUGIN_CALLBACK(simaka_manager_register, get_provider),
+ PLUGIN_PROVIDE(CUSTOM, "aka-provider"),
+ PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-simaka-sql-db"),
+ PLUGIN_PROVIDE(CUSTOM, "sim-provider"),
+ PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-simaka-sql-db"),
+ };
+ *features = f;
+ return countof(f);
+}
+
+METHOD(plugin_t, destroy, void,
+ private_eap_simaka_sql_t *this)
+{
free(this);
}
@@ -70,41 +149,16 @@ METHOD(plugin_t, destroy, void,
plugin_t *eap_simaka_sql_plugin_create()
{
private_eap_simaka_sql_t *this;
- database_t *db;
- bool remove_used;
- char *uri;
-
- uri = lib->settings->get_str(lib->settings,
- "charon.plugins.eap-simaka-sql.database", NULL);
- if (!uri)
- {
- DBG1(DBG_CFG, "eap-simaka-sql database URI missing");
- return NULL;
- }
- db = lib->db->create(lib->db, uri);
- if (!db)
- {
- DBG1(DBG_CFG, "opening eap-simaka-sql database failed");
- return NULL;
- }
- remove_used = lib->settings->get_bool(lib->settings,
- "charon.plugins.eap-simaka-sql.remove_used", FALSE);
INIT(this,
.public = {
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
},
- .db = db,
- .provider = eap_simaka_sql_provider_create(db, remove_used),
- .card = eap_simaka_sql_card_create(db, remove_used),
);
- charon->sim->add_card(charon->sim, &this->card->card);
- charon->sim->add_provider(charon->sim, &this->provider->provider);
-
return &this->public.plugin;
}
diff --git a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.c b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.c
index 73cccf549..21a19655f 100644
--- a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.c
+++ b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.c
@@ -42,7 +42,7 @@ struct private_eap_simaka_sql_provider_t {
bool remove_used;
};
-METHOD(sim_provider_t, get_triplet, bool,
+METHOD(simaka_provider_t, get_triplet, bool,
private_eap_simaka_sql_provider_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
@@ -53,7 +53,7 @@ METHOD(sim_provider_t, get_triplet, bool,
snprintf(buf, sizeof(buf), "%Y", id);
query = this->db->query(this->db,
- "select rand, sres, kc from triplets where id = ? order by use",
+ "select rand, sres, kc from triplets where id = ? order by used",
DB_TEXT, buf, DB_BLOB, DB_BLOB, DB_BLOB);
if (query)
{
@@ -82,7 +82,7 @@ METHOD(sim_provider_t, get_triplet, bool,
else
{
this->db->execute(this->db, NULL,
- "update triplets set use = ? where id = ? and rand = ?",
+ "update triplets set used = ? where id = ? and rand = ?",
DB_UINT, time(NULL), DB_TEXT, buf,
DB_BLOB, chunk_create(rand, SIM_RAND_LEN));
}
@@ -90,7 +90,7 @@ METHOD(sim_provider_t, get_triplet, bool,
return found;
}
-METHOD(sim_provider_t, get_quintuplet, bool,
+METHOD(simaka_provider_t, get_quintuplet, bool,
private_eap_simaka_sql_provider_t *this, identification_t *id,
char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len,
char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN])
@@ -102,7 +102,7 @@ METHOD(sim_provider_t, get_quintuplet, bool,
snprintf(buf, sizeof(buf), "%Y", id);
query = this->db->query(this->db, "select rand, res, ck, ik, autn "
- "from quintuplets where id = ? order by use", DB_TEXT, buf,
+ "from quintuplets where id = ? order by used", DB_TEXT, buf,
DB_BLOB, DB_BLOB, DB_BLOB, DB_BLOB, DB_BLOB);
if (query)
{
@@ -137,7 +137,7 @@ METHOD(sim_provider_t, get_quintuplet, bool,
else
{
this->db->execute(this->db, NULL,
- "update quintuplets set use = ? where id = ? and rand = ?",
+ "update quintuplets set used = ? where id = ? and rand = ?",
DB_UINT, time(NULL), DB_TEXT, buf,
DB_BLOB, chunk_create(rand, AKA_RAND_LEN));
}
diff --git a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.h b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.h
index ecb0c8cb0..88a8b1f24 100644
--- a/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.h
+++ b/src/libcharon/plugins/eap_simaka_sql/eap_simaka_sql_provider.h
@@ -22,7 +22,7 @@
#define EAP_SIMAKA_SQL_PROVIDER_H_
#include <database/database.h>
-#include <sa/authenticators/eap/sim_manager.h>
+#include <simaka_provider.h>
typedef struct eap_simaka_sql_provider_t eap_simaka_sql_provider_t;
@@ -32,9 +32,9 @@ typedef struct eap_simaka_sql_provider_t eap_simaka_sql_provider_t;
struct eap_simaka_sql_provider_t {
/**
- * Implements sim_provider_t interface
+ * Implements simaka_provider_t interface
*/
- sim_provider_t provider;
+ simaka_provider_t provider;
/**
* Destroy a eap_simaka_sql_provider_t.