Use auth_cfg_t.replace_value where appropriate.
This commit is contained in:
@@ -218,23 +218,15 @@ static eap_payload_t* server_initiate_eap(private_eap_authenticator_t *this,
|
|||||||
*/
|
*/
|
||||||
static void replace_eap_identity(private_eap_authenticator_t *this)
|
static void replace_eap_identity(private_eap_authenticator_t *this)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
identification_t *eap_identity;
|
||||||
auth_rule_t rule;
|
|
||||||
auth_cfg_t *cfg;
|
auth_cfg_t *cfg;
|
||||||
void *ptr;
|
|
||||||
|
|
||||||
|
eap_identity = this->eap_identity->clone(this->eap_identity);
|
||||||
cfg = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
|
cfg = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
|
||||||
enumerator = cfg->create_enumerator(cfg);
|
if (!cfg->replace_value(cfg, AUTH_RULE_EAP_IDENTITY, eap_identity))
|
||||||
while (enumerator->enumerate(enumerator, &rule, &ptr))
|
|
||||||
{
|
{
|
||||||
if (rule == AUTH_RULE_EAP_IDENTITY)
|
eap_identity->destroy(eap_identity);
|
||||||
{
|
|
||||||
cfg->replace(cfg, enumerator, AUTH_RULE_EAP_IDENTITY,
|
|
||||||
this->eap_identity->clone(this->eap_identity));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -424,24 +424,11 @@ METHOD(task_t, build_i, status_t,
|
|||||||
}
|
}
|
||||||
else if (idi->get_type(idi) == ID_ANY)
|
else if (idi->get_type(idi) == ID_ANY)
|
||||||
{ /* ID_ANY is invalid as IDi, use local IP address instead */
|
{ /* ID_ANY is invalid as IDi, use local IP address instead */
|
||||||
enumerator_t *enumerator;
|
|
||||||
auth_rule_t rule;
|
|
||||||
host_t *me;
|
host_t *me;
|
||||||
void *data;
|
|
||||||
|
|
||||||
me = this->ike_sa->get_my_host(this->ike_sa);
|
me = this->ike_sa->get_my_host(this->ike_sa);
|
||||||
idi = identification_create_from_sockaddr(me->get_sockaddr(me));
|
idi = identification_create_from_sockaddr(me->get_sockaddr(me));
|
||||||
enumerator = cfg->create_enumerator(cfg);
|
cfg->replace_value(cfg, AUTH_RULE_IDENTITY, idi);
|
||||||
while (enumerator->enumerate(enumerator, &rule, &data))
|
|
||||||
{
|
|
||||||
if (rule == AUTH_RULE_IDENTITY)
|
|
||||||
{
|
|
||||||
cfg->replace(cfg, enumerator, AUTH_RULE_IDENTITY,
|
|
||||||
idi);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
}
|
}
|
||||||
this->ike_sa->set_my_id(this->ike_sa, idi->clone(idi));
|
this->ike_sa->set_my_id(this->ike_sa, idi->clone(idi));
|
||||||
id_payload = id_payload_create_from_identification(ID_INITIATOR, idi);
|
id_payload = id_payload_create_from_identification(ID_INITIATOR, idi);
|
||||||
|
|||||||
Reference in New Issue
Block a user