#include <daemon.h>
#include <utils/linked_list.h>
+#include <threading/rwlock.h>
typedef struct private_sim_manager_t private_sim_manager_t;
* list of added hooks
*/
linked_list_t *hooks;
+
+ /**
+ * lock for lists above
+ */
+ rwlock_t *lock;
};
/**
*/
static void add_card(private_sim_manager_t *this, sim_card_t *card)
{
+ this->lock->write_lock(this->lock);
this->cards->insert_last(this->cards, card);
+ this->lock->unlock(this->lock);
}
/**
*/
static void remove_card(private_sim_manager_t *this, sim_card_t *card)
{
+ this->lock->write_lock(this->lock);
this->cards->remove(this->cards, card, NULL);
+ this->lock->unlock(this->lock);
}
/**
sim_card_t *card;
int tried = 0;
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
if (card->get_triplet(card, id, rand, sres, kc))
{
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return TRUE;
}
tried++;
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
DBG1(DBG_IKE, "tried %d SIM cards, but none has triplets for '%Y'",
tried, id);
return FALSE;
status_t status = NOT_FOUND;
int tried = 0;
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
case SUCCESS:
case INVALID_STATE:
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return status;
case NOT_SUPPORTED:
case FAILED:
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
DBG1(DBG_IKE, "tried %d SIM cards, but none has quintuplets for '%Y'",
tried, id);
return status;
enumerator_t *enumerator;
sim_card_t *card;
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
if (card->resync(card, id, rand, auts))
{
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return TRUE;
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return FALSE;
}
DBG1(DBG_IKE, "storing pseudonym '%Y' for '%Y'", pseudonym, id);
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
card->set_pseudonym(card, id, pseudonym);
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
/**
sim_card_t *card;
identification_t *pseudonym = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return pseudonym;
}
DBG1(DBG_IKE, "storing next reauthentication identity '%Y' for '%Y'",
next, id);
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
card->set_reauth(card, id, next, mk, counter);
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
/**
sim_card_t *card;
identification_t *reauth = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->cards->create_enumerator(this->cards);
while (enumerator->enumerate(enumerator, &card))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return reauth;
}
*/
static void add_provider(private_sim_manager_t *this, sim_provider_t *provider)
{
+ this->lock->write_lock(this->lock);
this->providers->insert_last(this->providers, provider);
+ this->lock->unlock(this->lock);
}
/**
static void remove_provider(private_sim_manager_t *this,
sim_provider_t *provider)
{
+ this->lock->write_lock(this->lock);
this->providers->remove(this->providers, provider, NULL);
+ this->lock->unlock(this->lock);
}
/**
sim_provider_t *provider;
int tried = 0;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
if (provider->get_triplet(provider, id, rand, sres, kc))
{
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return TRUE;
}
tried++;
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
DBG1(DBG_IKE, "tried %d SIM providers, but none had a triplet for '%Y'",
tried, id);
return FALSE;
sim_provider_t *provider;
int tried = 0;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
ck, ik, autn))
{
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return TRUE;
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
DBG1(DBG_IKE, "tried %d SIM providers, but none had a quintuplet for '%Y'",
tried, id);
return FALSE;
enumerator_t *enumerator;
sim_provider_t *provider;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
if (provider->resync(provider, id, rand, auts))
{
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return TRUE;
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return FALSE;
}
sim_provider_t *provider;
identification_t *permanent = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return permanent;
}
sim_provider_t *provider;
identification_t *pseudonym = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return pseudonym;
}
sim_provider_t *provider;
identification_t *permanent = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return permanent;
}
sim_provider_t *provider;
identification_t *reauth = NULL;
+ this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers);
while (enumerator->enumerate(enumerator, &provider))
{
}
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
return reauth;
}
*/
static void add_hooks(private_sim_manager_t *this, sim_hooks_t *hooks)
{
+ this->lock->write_lock(this->lock);
this->hooks->insert_last(this->hooks, hooks);
+ this->lock->unlock(this->lock);
}
/**
*/
static void remove_hooks(private_sim_manager_t *this, sim_hooks_t *hooks)
{
+ this->lock->write_lock(this->lock);
this->hooks->remove(this->hooks, hooks, NULL);
+ this->lock->unlock(this->lock);
}
/**
enumerator_t *enumerator;
sim_hooks_t *hooks;
+ this->lock->read_lock(this->lock);
enumerator = this->hooks->create_enumerator(this->hooks);
while (enumerator->enumerate(enumerator, &hooks))
{
hooks->message(hooks, message, inbound, decrypted);
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
/**
enumerator_t *enumerator;
sim_hooks_t *hooks;
+ this->lock->read_lock(this->lock);
enumerator = this->hooks->create_enumerator(this->hooks);
while (enumerator->enumerate(enumerator, &hooks))
{
hooks->keys(hooks, k_encr, k_auth);
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
/**
this->cards->destroy(this->cards);
this->providers->destroy(this->providers);
this->hooks->destroy(this->hooks);
+ this->lock->destroy(this->lock);
free(this);
}
this->cards = linked_list_create();
this->providers = linked_list_create();
this->hooks = linked_list_create();
+ this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
return &this->public;
}