merged multi-auth branch back into trunk
This commit is contained in:
@@ -65,9 +65,9 @@ struct private_eap_manager_t {
|
||||
linked_list_t *methods;
|
||||
|
||||
/**
|
||||
* mutex to lock methods
|
||||
* rwlock to lock methods
|
||||
*/
|
||||
mutex_t *mutex;
|
||||
rwlock_t *lock;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,9 +84,9 @@ static void add_method(private_eap_manager_t *this, eap_type_t type,
|
||||
entry->role = role;
|
||||
entry->constructor = constructor;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
this->lock->write_lock(this->lock);
|
||||
this->methods->insert_last(this->methods, entry);
|
||||
this->mutex->unlock(this->mutex);
|
||||
this->lock->unlock(this->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ static void remove_method(private_eap_manager_t *this, eap_constructor_t constru
|
||||
enumerator_t *enumerator;
|
||||
eap_entry_t *entry;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->methods->create_enumerator(this->methods);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static void remove_method(private_eap_manager_t *this, eap_constructor_t constru
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
this->lock->unlock(this->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ static eap_method_t* create_instance(private_eap_manager_t *this,
|
||||
eap_entry_t *entry;
|
||||
eap_method_t *method = NULL;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->methods->create_enumerator(this->methods);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
@@ -138,7 +138,7 @@ static eap_method_t* create_instance(private_eap_manager_t *this,
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
this->lock->unlock(this->lock);
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ static eap_method_t* create_instance(private_eap_manager_t *this,
|
||||
static void destroy(private_eap_manager_t *this)
|
||||
{
|
||||
this->methods->destroy_function(this->methods, free);
|
||||
this->mutex->destroy(this->mutex);
|
||||
this->lock->destroy(this->lock);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ eap_manager_t *eap_manager_create()
|
||||
this->public.destroy = (void(*)(eap_manager_t*))destroy;
|
||||
|
||||
this->methods = linked_list_create();
|
||||
this->mutex = mutex_create(MUTEX_DEFAULT);
|
||||
this->lock = rwlock_create(RWLOCK_DEFAULT);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,36 @@ ENUM_NEXT(eap_type_names, EAP_RADIUS, EAP_EXPERIMENTAL, EAP_MSCHAPV2,
|
||||
"EAP_EXPERIMENTAL");
|
||||
ENUM_END(eap_type_names, EAP_EXPERIMENTAL);
|
||||
|
||||
/*
|
||||
* See header
|
||||
*/
|
||||
eap_type_t eap_type_from_string(char *name)
|
||||
{
|
||||
int i;
|
||||
static struct {
|
||||
char *name;
|
||||
eap_type_t type;
|
||||
} types[] = {
|
||||
{"identity", EAP_IDENTITY},
|
||||
{"md5", EAP_MD5},
|
||||
{"otp", EAP_OTP},
|
||||
{"gtc", EAP_GTC},
|
||||
{"sim", EAP_SIM},
|
||||
{"aka", EAP_AKA},
|
||||
{"mschapv2", EAP_MSCHAPV2},
|
||||
{"radius", EAP_RADIUS},
|
||||
};
|
||||
|
||||
for (i = 0; i < countof(types); i++)
|
||||
{
|
||||
if (strcasecmp(name, types[i].name) == 0)
|
||||
{
|
||||
return types[i].type;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ENUM(eap_code_names, EAP_REQUEST, EAP_FAILURE,
|
||||
"EAP_REQUEST",
|
||||
"EAP_RESPONSE",
|
||||
@@ -48,3 +78,6 @@ ENUM(eap_role_names, EAP_SERVER, EAP_PEER,
|
||||
"EAP_PEER",
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -68,6 +68,14 @@ enum eap_type_t {
|
||||
*/
|
||||
extern enum_name_t *eap_type_names;
|
||||
|
||||
/**
|
||||
* Lookup the EAP method type from a string.
|
||||
*
|
||||
* @param name EAP method name (such as "md5", "aka")
|
||||
* @return method type, 0 if unkown
|
||||
*/
|
||||
eap_type_t eap_type_from_string(char *name);
|
||||
|
||||
/**
|
||||
* EAP code, type of an EAP message
|
||||
*/
|
||||
@@ -83,7 +91,6 @@ enum eap_code_t {
|
||||
*/
|
||||
extern enum_name_t *eap_code_names;
|
||||
|
||||
|
||||
/**
|
||||
* Interface of an EAP method for server and client side.
|
||||
*
|
||||
|
||||
@@ -39,7 +39,7 @@ struct sim_card_t {
|
||||
* The returned identity owned by the sim_card and not destroyed outside.
|
||||
* The SIM card may return ID_ANY if it does not support/use an IMSI.
|
||||
*
|
||||
* @return identity of type ID_EAP/ID_ANY
|
||||
* @return identity
|
||||
*/
|
||||
identification_t* (*get_imsi)(sim_card_t *this);
|
||||
|
||||
@@ -63,7 +63,7 @@ struct sim_provider_t {
|
||||
/**
|
||||
* Get a single triplet to authenticate a EAP client.
|
||||
*
|
||||
* @param imsi client identity of type ID_EAP
|
||||
* @param imsi client identity
|
||||
* @param rand RAND output buffer, fixed size 16 bytes
|
||||
* @param sres SRES output buffer, fixed size 4 byte
|
||||
* @param kc KC output buffer, fixed size 8 bytes
|
||||
|
||||
Reference in New Issue
Block a user