Removed auth_cfg_t.replace_value() and replaced usages with add().

replace_value() was used to replace identities. Since for these the latest is
now returned by get(), adding the new identity with add() is sufficient.
This commit is contained in:
Tobias Brunner
2012-04-18 18:50:14 +02:00
parent ebc1ffe451
commit 7e84c4275c
5 changed files with 40 additions and 94 deletions
+1 -5
View File
@@ -1039,11 +1039,7 @@ METHOD(stroke_config_t, set_user_credentials, void,
auth_class = (uintptr_t)auth_cfg->get(auth_cfg, AUTH_RULE_AUTH_CLASS);
if (auth_class == AUTH_CLASS_EAP)
{
identity = id->clone(id);
if (!auth_cfg->replace_value(auth_cfg, AUTH_RULE_EAP_IDENTITY, identity))
{
auth_cfg->add(auth_cfg, AUTH_RULE_EAP_IDENTITY, identity);
}
auth_cfg->add(auth_cfg, AUTH_RULE_EAP_IDENTITY, id->clone(id));
/* if aaa_identity is specified use that as remote ID */
identity = auth_cfg->get(auth_cfg, AUTH_RULE_AAA_IDENTITY);
if (identity && identity->get_type(identity) != ID_ANY)
@@ -223,10 +223,7 @@ static void replace_eap_identity(private_eap_authenticator_t *this)
eap_identity = this->eap_identity->clone(this->eap_identity);
cfg = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
if (!cfg->replace_value(cfg, AUTH_RULE_EAP_IDENTITY, eap_identity))
{
eap_identity->destroy(eap_identity);
}
cfg->add(cfg, AUTH_RULE_EAP_IDENTITY, eap_identity);
}
/**
+2 -8
View File
@@ -425,10 +425,7 @@ METHOD(task_t, build_i, status_t,
DBG1(DBG_CFG, "no IDi configured, fall back on IP address");
me = this->ike_sa->get_my_host(this->ike_sa);
idi = identification_create_from_sockaddr(me->get_sockaddr(me));
if (!cfg->replace_value(cfg, AUTH_RULE_IDENTITY, idi))
{
cfg->add(cfg, AUTH_RULE_IDENTITY, idi);
}
cfg->add(cfg, AUTH_RULE_IDENTITY, idi);
}
this->ike_sa->set_my_id(this->ike_sa, idi->clone(idi));
id_payload = id_payload_create_from_identification(ID_INITIATOR, idi);
@@ -702,10 +699,7 @@ METHOD(task_t, build_r, status_t,
me = this->ike_sa->get_my_host(this->ike_sa);
id_cfg = identification_create_from_sockaddr(
me->get_sockaddr(me));
if (!cfg->replace_value(cfg, AUTH_RULE_IDENTITY, id_cfg))
{
cfg->add(cfg, AUTH_RULE_IDENTITY, id_cfg);
}
cfg->add(cfg, AUTH_RULE_IDENTITY, id_cfg);
}
this->ike_sa->set_my_id(this->ike_sa, id_cfg->clone(id_cfg));
id = id_cfg;