removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -21,17 +21,17 @@ typedef struct private_eap_sim_file_card_t private_eap_sim_file_card_t;
|
||||
* Private data of an eap_sim_file_card_t object.
|
||||
*/
|
||||
struct private_eap_sim_file_card_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public eap_sim_file_card_t interface.
|
||||
*/
|
||||
eap_sim_file_card_t public;
|
||||
|
||||
|
||||
/**
|
||||
* IMSI, is ID_ANY for file implementation
|
||||
*/
|
||||
identification_t *imsi;
|
||||
|
||||
|
||||
/**
|
||||
* source of triplets
|
||||
*/
|
||||
@@ -49,9 +49,9 @@ static bool get_triplet(private_eap_sim_file_card_t *this,
|
||||
enumerator_t *enumerator;
|
||||
identification_t *id;
|
||||
char *c_rand, *c_sres, *c_kc;
|
||||
|
||||
|
||||
DBG2(DBG_CFG, "looking for rand: %b", rand, RAND_LEN);
|
||||
|
||||
|
||||
enumerator = this->triplets->create_enumerator(this->triplets);
|
||||
while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
|
||||
{
|
||||
@@ -92,15 +92,15 @@ static void destroy(private_eap_sim_file_card_t *this)
|
||||
eap_sim_file_card_t *eap_sim_file_card_create(eap_sim_file_triplets_t *triplets)
|
||||
{
|
||||
private_eap_sim_file_card_t *this = malloc_thing(private_eap_sim_file_card_t);
|
||||
|
||||
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, char *rand, char *sres, char *kc))get_triplet;
|
||||
this->public.card.get_imsi = (identification_t*(*)(sim_card_t*))get_imsi;
|
||||
this->public.destroy = (void(*)(eap_sim_file_card_t*))destroy;
|
||||
|
||||
|
||||
/* this SIM card implementation does not have an ID, serve ID_ANY */
|
||||
this->imsi = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
this->triplets = triplets;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ struct eap_sim_file_card_t {
|
||||
* Implements sim_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a eap_sim_file_card_t.
|
||||
*/
|
||||
|
||||
@@ -28,22 +28,22 @@ typedef struct private_eap_sim_file_t private_eap_sim_file_t;
|
||||
* Private data of an eap_sim_file_t object.
|
||||
*/
|
||||
struct private_eap_sim_file_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public eap_sim_file_plugin_t interface.
|
||||
*/
|
||||
eap_sim_file_plugin_t public;
|
||||
|
||||
|
||||
/**
|
||||
* SIM card
|
||||
*/
|
||||
eap_sim_file_card_t *card;
|
||||
|
||||
|
||||
/**
|
||||
* SIM provider
|
||||
*/
|
||||
eap_sim_file_provider_t *provider;
|
||||
|
||||
|
||||
/**
|
||||
* Triplet source
|
||||
*/
|
||||
@@ -69,16 +69,16 @@ static void destroy(private_eap_sim_file_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_eap_sim_file_t *this = malloc_thing(private_eap_sim_file_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
this->triplets = eap_sim_file_triplets_create(TRIPLET_FILE);
|
||||
this->card = eap_sim_file_card_create(this->triplets);
|
||||
this->provider = eap_sim_file_provider_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ typedef struct private_eap_sim_file_provider_t private_eap_sim_file_provider_t;
|
||||
* Private data of an eap_sim_file_provider_t object.
|
||||
*/
|
||||
struct private_eap_sim_file_provider_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public eap_sim_file_provider_t interface.
|
||||
*/
|
||||
eap_sim_file_provider_t public;
|
||||
|
||||
|
||||
/**
|
||||
* source of triplets
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ static bool get_triplet(private_eap_sim_file_provider_t *this,
|
||||
enumerator_t *enumerator;
|
||||
identification_t *id;
|
||||
char *c_rand, *c_sres, *c_kc;
|
||||
|
||||
|
||||
enumerator = this->triplets->create_enumerator(this->triplets);
|
||||
while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
|
||||
{
|
||||
@@ -75,12 +75,12 @@ eap_sim_file_provider_t *eap_sim_file_provider_create(
|
||||
eap_sim_file_triplets_t *triplets)
|
||||
{
|
||||
private_eap_sim_file_provider_t *this = malloc_thing(private_eap_sim_file_provider_t);
|
||||
|
||||
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *imsi, char rand[16], char sres[4], char kc[8]))get_triplet;
|
||||
this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
|
||||
|
||||
|
||||
this->triplets = triplets;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ struct eap_sim_file_provider_t {
|
||||
* Implements sim_provider_t interface.
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a eap_sim_file_provider_t.
|
||||
*/
|
||||
|
||||
@@ -28,17 +28,17 @@ typedef struct private_eap_sim_file_triplets_t private_eap_sim_file_triplets_t;
|
||||
* Private data of an eap_sim_file_triplets_t object.
|
||||
*/
|
||||
struct private_eap_sim_file_triplets_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public eap_sim_file_triplets_t interface.
|
||||
*/
|
||||
eap_sim_file_triplets_t public;
|
||||
|
||||
|
||||
/**
|
||||
* List of triplets, as triplet_t
|
||||
*/
|
||||
linked_list_t *triplets;
|
||||
|
||||
|
||||
/**
|
||||
* mutex to lock triplets list
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
|
||||
char **rand, char **sres, char **kc)
|
||||
{
|
||||
triplet_t *triplet;
|
||||
|
||||
|
||||
if (e->inner->enumerate(e->inner, &triplet))
|
||||
{
|
||||
e->current = triplet;
|
||||
@@ -123,14 +123,14 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
|
||||
static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
|
||||
{
|
||||
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator->public.enumerate = (void*)enumerator_enumerate;
|
||||
enumerator->public.destroy = (void*)enumerator_destroy;
|
||||
enumerator->inner = this->triplets->create_enumerator(this->triplets);
|
||||
enumerator->current = NULL;
|
||||
enumerator->this = this;
|
||||
|
||||
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
|
||||
static void parse_token(char *to, char *from, size_t len)
|
||||
{
|
||||
chunk_t chunk;
|
||||
|
||||
|
||||
chunk = chunk_create(from, min(strlen(from), len * 2));
|
||||
chunk = chunk_from_hex(chunk, NULL);
|
||||
memset(to, 0, len);
|
||||
@@ -156,22 +156,22 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
char line[512];
|
||||
FILE *file;
|
||||
int i, nr = 0;
|
||||
|
||||
|
||||
file = fopen(path, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
DBG1(DBG_CFG, "opening triplet file %s failed: %s",
|
||||
DBG1(DBG_CFG, "opening triplet file %s failed: %s",
|
||||
path, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* read line by line */
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
triplet_t *triplet;
|
||||
enumerator_t *enumerator;
|
||||
char *token;
|
||||
|
||||
|
||||
nr++;
|
||||
/* skip comments, empty lines */
|
||||
switch (line[0])
|
||||
@@ -186,7 +186,7 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
}
|
||||
triplet = malloc_thing(triplet_t);
|
||||
memset(triplet, 0, sizeof(triplet_t));
|
||||
|
||||
|
||||
i = 0;
|
||||
enumerator = enumerator_create_token(line, ",", " \n\r#");
|
||||
while (enumerator->enumerate(enumerator, &token))
|
||||
@@ -217,15 +217,15 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
triplet_destroy(triplet);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
DBG2(DBG_CFG, "triplet: imsi %Y\nrand %b\nsres %b\nkc %b",
|
||||
triplet->imsi, triplet->rand, RAND_LEN,
|
||||
triplet->sres, SRES_LEN, triplet->kc, KC_LEN);
|
||||
|
||||
|
||||
this->triplets->insert_last(this->triplets, triplet);
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
|
||||
DBG1(DBG_CFG, "read %d triplets from %s",
|
||||
this->triplets->get_count(this->triplets), path);
|
||||
}
|
||||
@@ -246,15 +246,15 @@ static void destroy(private_eap_sim_file_triplets_t *this)
|
||||
eap_sim_file_triplets_t *eap_sim_file_triplets_create(char *file)
|
||||
{
|
||||
private_eap_sim_file_triplets_t *this = malloc_thing(private_eap_sim_file_triplets_t);
|
||||
|
||||
|
||||
this->public.create_enumerator = (enumerator_t*(*)(eap_sim_file_triplets_t*))create_enumerator;
|
||||
this->public.destroy = (void(*)(eap_sim_file_triplets_t*))destroy;
|
||||
|
||||
|
||||
this->triplets = linked_list_create();
|
||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
||||
|
||||
|
||||
read_triplets(this, file);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user