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);
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;
}
}
-/**
- * Replace the type and value of the given entry.
- */
-static void replace_entry(entry_t *entry, auth_rule_t type, va_list args)
-{
- destroy_entry_value(entry);
- entry->type = type;
- switch (type)
- {
- case AUTH_RULE_AUTH_CLASS:
- case AUTH_RULE_EAP_TYPE:
- case AUTH_RULE_EAP_VENDOR:
- case AUTH_RULE_CRL_VALIDATION:
- case AUTH_RULE_OCSP_VALIDATION:
- case AUTH_RULE_RSA_STRENGTH:
- case AUTH_RULE_ECDSA_STRENGTH:
- /* integer type */
- entry->value = (void*)(uintptr_t)va_arg(args, u_int);
- break;
- case AUTH_RULE_IDENTITY:
- case AUTH_RULE_EAP_IDENTITY:
- case AUTH_RULE_AAA_IDENTITY:
- case AUTH_RULE_GROUP:
- case AUTH_RULE_CA_CERT:
- case AUTH_RULE_IM_CERT:
- case AUTH_RULE_SUBJECT_CERT:
- case AUTH_RULE_CERT_POLICY:
- case AUTH_HELPER_IM_CERT:
- case AUTH_HELPER_SUBJECT_CERT:
- case AUTH_HELPER_IM_HASH_URL:
- case AUTH_HELPER_SUBJECT_HASH_URL:
- case AUTH_HELPER_REVOCATION_CERT:
- /* pointer type */
- entry->value = va_arg(args, void*);
- break;
- case AUTH_RULE_MAX:
- entry->value = NULL;
- break;
- }
-}
-
/**
* Implementation of auth_cfg_t.replace.
*/
{
if (enumerator->current)
{
+ entry_t *entry;
va_list args;
va_start(args, type);
- replace_entry(enumerator->current, type, args);
- va_end(args);
- }
-}
-
-METHOD(auth_cfg_t, replace_value, bool,
- private_auth_cfg_t *this, auth_rule_t type, ...)
-{
- enumerator_t *enumerator;
- entry_t *entry;
- bool found = FALSE;
-
- enumerator = this->entries->create_enumerator(this->entries);
- while (enumerator->enumerate(enumerator, &entry))
- {
- if (type == entry->type)
+ entry = enumerator->current;
+ destroy_entry_value(entry);
+ entry->type = type;
+ switch (type)
{
- va_list args;
-
- va_start(args, type);
- replace_entry(entry, type, args);
- va_end(args);
- found = TRUE;
- break;
+ case AUTH_RULE_AUTH_CLASS:
+ case AUTH_RULE_EAP_TYPE:
+ case AUTH_RULE_EAP_VENDOR:
+ case AUTH_RULE_CRL_VALIDATION:
+ case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
+ /* integer type */
+ entry->value = (void*)(uintptr_t)va_arg(args, u_int);
+ break;
+ case AUTH_RULE_IDENTITY:
+ case AUTH_RULE_EAP_IDENTITY:
+ case AUTH_RULE_AAA_IDENTITY:
+ case AUTH_RULE_GROUP:
+ case AUTH_RULE_CA_CERT:
+ case AUTH_RULE_IM_CERT:
+ case AUTH_RULE_SUBJECT_CERT:
+ case AUTH_RULE_CERT_POLICY:
+ case AUTH_HELPER_IM_CERT:
+ case AUTH_HELPER_SUBJECT_CERT:
+ case AUTH_HELPER_IM_HASH_URL:
+ case AUTH_HELPER_SUBJECT_HASH_URL:
+ case AUTH_HELPER_REVOCATION_CERT:
+ /* pointer type */
+ entry->value = va_arg(args, void*);
+ break;
+ case AUTH_RULE_MAX:
+ entry->value = NULL;
+ break;
}
+ va_end(args);
}
- enumerator->destroy(enumerator);
- return found;
}
METHOD(auth_cfg_t, get, void*,
.get = _get,
.create_enumerator = _create_enumerator,
.replace = (void(*)(auth_cfg_t*,enumerator_t*,auth_rule_t,...))replace,
- .replace_value = _replace_value,
.complies = _complies,
.merge = (void(*)(auth_cfg_t*,auth_cfg_t*,bool))merge,
.purge = _purge,