summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/eap_sim_file
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_sim_file
parent0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff)
downloadvyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz
vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libcharon/plugins/eap_sim_file')
-rw-r--r--src/libcharon/plugins/eap_sim_file/Makefile.am3
-rw-r--r--src/libcharon/plugins/eap_sim_file/Makefile.in13
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_card.c4
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_card.h6
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_plugin.c79
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.c2
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.h6
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c12
-rw-r--r--src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.h2
9 files changed, 94 insertions, 33 deletions
diff --git a/src/libcharon/plugins/eap_sim_file/Makefile.am b/src/libcharon/plugins/eap_sim_file/Makefile.am
index 2b59a7c88..d76cdc5ca 100644
--- a/src/libcharon/plugins/eap_sim_file/Makefile.am
+++ b/src/libcharon/plugins/eap_sim_file/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-sim-file.la
else
plugin_LTLIBRARIES = libstrongswan-eap-sim-file.la
+libstrongswan_eap_sim_file_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.la
endif
libstrongswan_eap_sim_file_la_SOURCES = \
diff --git a/src/libcharon/plugins/eap_sim_file/Makefile.in b/src/libcharon/plugins/eap_sim_file/Makefile.in
index 5662a1c53..bebf62e5b 100644
--- a/src/libcharon/plugins/eap_sim_file/Makefile.in
+++ b/src/libcharon/plugins/eap_sim_file/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_sim_file_la_LIBADD =
+@MONOLITHIC_FALSE@libstrongswan_eap_sim_file_la_DEPENDENCIES = \
+@MONOLITHIC_FALSE@ $(top_builddir)/src/libsimaka/libsimaka.la
am_libstrongswan_eap_sim_file_la_OBJECTS = eap_sim_file_plugin.lo \
eap_sim_file_card.lo eap_sim_file_provider.lo \
eap_sim_file_triplets.lo
@@ -196,6 +197,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@
@@ -204,6 +208,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@
@@ -220,11 +225,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@
@@ -268,6 +275,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@
@@ -279,11 +287,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-sim-file.la
@MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-eap-sim-file.la
+@MONOLITHIC_FALSE@libstrongswan_eap_sim_file_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.la
libstrongswan_eap_sim_file_la_SOURCES = \
eap_sim_file_plugin.h eap_sim_file_plugin.c \
eap_sim_file_card.h eap_sim_file_card.c \
diff --git a/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.c b/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.c
index 5397c418e..bd47e5085 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.c
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.c
@@ -35,7 +35,7 @@ struct private_eap_sim_file_card_t {
eap_sim_file_triplets_t *triplets;
};
-METHOD(sim_card_t, get_triplet, bool,
+METHOD(simaka_card_t, get_triplet, bool,
private_eap_sim_file_card_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
@@ -66,7 +66,7 @@ METHOD(sim_card_t, get_triplet, bool,
return FALSE;
}
-METHOD(sim_card_t, get_quintuplet, status_t,
+METHOD(simaka_card_t, get_quintuplet, status_t,
private_eap_sim_file_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_sim_file/eap_sim_file_card.h b/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.h
index 1a5470968..45b0e51db 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.h
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_card.h
@@ -23,7 +23,7 @@
#include "eap_sim_file_triplets.h"
-#include <sa/authenticators/eap/sim_manager.h>
+#include <simaka_card.h>
typedef struct eap_sim_file_card_t eap_sim_file_card_t;
@@ -33,9 +33,9 @@ typedef struct eap_sim_file_card_t eap_sim_file_card_t;
struct eap_sim_file_card_t {
/**
- * Implements sim_card_t interface
+ * Implements simaka_card_t interface
*/
- sim_card_t card;
+ simaka_card_t card;
/**
* Destroy a eap_sim_file_card_t.
diff --git a/src/libcharon/plugins/eap_sim_file/eap_sim_file_plugin.c b/src/libcharon/plugins/eap_sim_file/eap_sim_file_plugin.c
index 0ab5a1848..eae76729c 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_plugin.c
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_plugin.c
@@ -56,14 +56,70 @@ METHOD(plugin_t, get_name, char*,
return "eap-sim-file";
}
-METHOD(plugin_t, destroy, void,
- private_eap_sim_file_t *this)
+/**
+ * Load triplet file
+ */
+static bool load_triplets(private_eap_sim_file_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)
+ {
+ this->triplets = eap_sim_file_triplets_create(TRIPLET_FILE);
+ if (!this->triplets)
+ {
+ return FALSE;
+ }
+ this->provider = eap_sim_file_provider_create(this->triplets);
+ this->card = eap_sim_file_card_create(this->triplets);
+ return TRUE;
+ }
this->card->destroy(this->card);
this->provider->destroy(this->provider);
this->triplets->destroy(this->triplets);
+ this->card = NULL;
+ this->provider = NULL;
+ this->triplets = NULL;
+ return TRUE;
+}
+
+/**
+ * Callback providing our card to register
+ */
+static simaka_card_t* get_card(private_eap_sim_file_t *this)
+{
+ return &this->card->card;
+}
+
+/**
+ * Callback providing our provider to register
+ */
+static simaka_provider_t* get_provider(private_eap_sim_file_t *this)
+{
+ return &this->provider->provider;
+}
+
+METHOD(plugin_t, get_features, int,
+ private_eap_sim_file_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK((void*)load_triplets, NULL),
+ PLUGIN_PROVIDE(CUSTOM, "eap-sim-file-triplets"),
+ PLUGIN_CALLBACK(simaka_manager_register, get_card),
+ PLUGIN_PROVIDE(CUSTOM, "sim-card"),
+ PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-sim-file-triplets"),
+ PLUGIN_CALLBACK(simaka_manager_register, get_provider),
+ PLUGIN_PROVIDE(CUSTOM, "sim-provider"),
+ PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-sim-file-triplets"),
+ };
+ *features = f;
+ return countof(f);
+}
+
+METHOD(plugin_t, destroy, void,
+ private_eap_sim_file_t *this)
+{
free(this);
}
@@ -78,25 +134,12 @@ plugin_t *eap_sim_file_plugin_create()
.public = {
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
},
- .triplets = eap_sim_file_triplets_create(TRIPLET_FILE),
);
- this->provider = eap_sim_file_provider_create(this->triplets);
- if (!this->provider)
- {
- this->triplets->destroy(this->triplets);
- free(this);
- return NULL;
- }
- this->card = eap_sim_file_card_create(this->triplets);
-
- 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_sim_file/eap_sim_file_provider.c b/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.c
index 38b651404..4ca1eb93f 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.c
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.c
@@ -35,7 +35,7 @@ struct private_eap_sim_file_provider_t {
eap_sim_file_triplets_t *triplets;
};
-METHOD(sim_provider_t, get_triplet, bool,
+METHOD(simaka_provider_t, get_triplet, bool,
private_eap_sim_file_provider_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
diff --git a/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.h b/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.h
index 10fda282a..577345dbf 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.h
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_provider.h
@@ -23,6 +23,8 @@
#include "eap_sim_file_triplets.h"
+#include <simaka_provider.h>
+
typedef struct eap_sim_file_provider_t eap_sim_file_provider_t;
/**
@@ -31,9 +33,9 @@ typedef struct eap_sim_file_provider_t eap_sim_file_provider_t;
struct eap_sim_file_provider_t {
/**
- * Implements sim_provider_t interface.
+ * Implements simaka_provider_t interface.
*/
- sim_provider_t provider;
+ simaka_provider_t provider;
/**
* Destroy a eap_sim_file_provider_t.
diff --git a/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c b/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c
index c693923fe..de3b69382 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c
@@ -21,6 +21,7 @@
#include <daemon.h>
#include <utils/linked_list.h>
#include <threading/mutex.h>
+#include <simaka_manager.h>
typedef struct private_eap_sim_file_triplets_t private_eap_sim_file_triplets_t;
@@ -149,7 +150,7 @@ static void parse_token(char *to, char *from, size_t len)
/**
* Read the triplets from the file
*/
-static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
+static bool read_triplets(private_eap_sim_file_triplets_t *this, char *path)
{
char line[512];
FILE *file;
@@ -160,7 +161,7 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
{
DBG1(DBG_CFG, "opening triplet file %s failed: %s",
path, strerror(errno));
- return;
+ return FALSE;
}
/* read line by line */
@@ -226,6 +227,7 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
DBG1(DBG_CFG, "read %d triplets from %s",
this->triplets->get_count(this->triplets), path);
+ return TRUE;
}
METHOD(eap_sim_file_triplets_t, destroy, void,
@@ -251,8 +253,12 @@ eap_sim_file_triplets_t *eap_sim_file_triplets_create(char *file)
.triplets = linked_list_create(),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
- read_triplets(this, file);
+ if (!read_triplets(this, file))
+ {
+ destroy(this);
+ return NULL;
+ }
return &this->public;
}
diff --git a/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.h b/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.h
index 8f8130810..c8e9e0359 100644
--- a/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.h
+++ b/src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.h
@@ -21,7 +21,7 @@
#ifndef EAP_SIM_FILE_TRIPLETS_H_
#define EAP_SIM_FILE_TRIPLETS_H_
-#include <sa/authenticators/eap/sim_manager.h>
+#include <utils/enumerator.h>
typedef struct eap_sim_file_triplets_t eap_sim_file_triplets_t;