*/
char *remote;
+ /**
+ * Local address
+ */
+ char *local;
+
/**
* IP address pool
*/
*/
char *responder_auth;
+ /**
+ * Initiator ID to enforce
+ */
+ char *initiator_id;
+
+ /**
+ * Responder ID to enforce
+ */
+ char *responder_id;
+
/**
* IKE_SA rekeying delay
*/
*/
u_int child_rekey;
+ /**
+ * DPD check delay
+ */
+ u_int dpd_delay;
+
+ /**
+ * DPD timeout (IKEv1 only)
+ */
+ u_int dpd_timeout;
+
/**
* incremental numbering of generated configs
*/
enumerator = enumerator_create_token(str, "|", " ");
while (enumerator->enumerate(enumerator, &str))
{
+ id = NULL;
auth = auth_cfg_create();
rnd++;
- if (streq(str, "psk"))
- { /* PSK authentication, use FQDNs */
- class = AUTH_CLASS_PSK;
- if ((local && !num) || (!local && num))
+ if (this->initiator_id)
+ {
+ if ((local && num) || (!local && !num))
{
- id = identification_create_from_string("srv.strongswan.org");
+ snprintf(buf, sizeof(buf), this->initiator_id, num, rnd);
+ id = identification_create_from_string(buf);
}
- else if (local)
+ }
+ if (this->responder_id)
+ {
+ if ((local && !num) || (!local && num))
{
- snprintf(buf, sizeof(buf), "c%d-r%d.strongswan.org", num, rnd);
+ snprintf(buf, sizeof(buf), this->responder_id, num, rnd);
id = identification_create_from_string(buf);
}
- else
+ }
+
+ if (streq(str, "psk"))
+ { /* PSK authentication, use FQDNs */
+ class = AUTH_CLASS_PSK;
+ if (!id)
{
- id = identification_create_from_string("*.strongswan.org");
+ if ((local && !num) || (!local && num))
+ {
+ id = identification_create_from_string("srv.strongswan.org");
+ }
+ else if (local)
+ {
+ snprintf(buf, sizeof(buf), "c%d-r%d.strongswan.org",
+ num, rnd);
+ id = identification_create_from_string(buf);
+ }
+ else
+ {
+ id = identification_create_from_string("*.strongswan.org");
+ }
}
}
else if (strneq(str, "eap", strlen("eap")))
auth->add(auth, AUTH_RULE_EAP_TYPE, type);
}
}
- if (local && num)
- {
- snprintf(buf, sizeof(buf), "1%.10d%.4d@strongswan.org", num, rnd);
- id = identification_create_from_string(buf);
- }
- else
+ if (!id)
{
- id = identification_create_from_encoding(ID_ANY, chunk_empty);
+ if (local && num)
+ {
+ snprintf(buf, sizeof(buf), "1%.10d%.4d@strongswan.org",
+ num, rnd);
+ id = identification_create_from_string(buf);
+ }
+ else
+ {
+ id = identification_create_from_encoding(ID_ANY, chunk_empty);
+ }
}
}
else
}
/* certificate authentication, use distinguished names */
class = AUTH_CLASS_PUBKEY;
- if ((local && !num) || (!local && num))
- {
- id = identification_create_from_string(
- "CN=srv, OU=load-test, O=strongSwan");
- }
- else if (local)
- {
- snprintf(buf, sizeof(buf),
- "CN=c%d-r%d, OU=load-test, O=strongSwan", num, rnd);
- id = identification_create_from_string(buf);
- }
- else
+ if (!id)
{
- id = identification_create_from_string(
- "CN=*, OU=load-test, O=strongSwan");
+ if ((local && !num) || (!local && num))
+ {
+ id = identification_create_from_string(
+ "CN=srv, OU=load-test, O=strongSwan");
+ }
+ else if (local)
+ {
+ snprintf(buf, sizeof(buf),
+ "CN=c%d-r%d, OU=load-test, O=strongSwan", num, rnd);
+ id = identification_create_from_string(buf);
+ }
+ else
+ {
+ id = identification_create_from_string(
+ "CN=*, OU=load-test, O=strongSwan");
+ }
}
}
auth->add(auth, AUTH_RULE_AUTH_CLASS, class);
if (this->port && num)
{
ike_cfg = ike_cfg_create(FALSE, FALSE,
- "0.0.0.0", this->port + num - 1, this->remote, IKEV2_NATT_PORT);
+ this->local, FALSE, this->port + num - 1,
+ this->remote, FALSE, IKEV2_NATT_PORT);
}
else
{
ike_cfg = ike_cfg_create(FALSE, FALSE,
- "0.0.0.0", IKEV2_UDP_PORT, this->remote, IKEV2_UDP_PORT);
+ this->local, FALSE, charon->socket->get_port(charon->socket, FALSE),
+ this->remote, FALSE, IKEV2_UDP_PORT);
}
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
- peer_cfg = peer_cfg_create("load-test", 2, ike_cfg,
+ peer_cfg = peer_cfg_create("load-test", IKEV2, ike_cfg,
CERT_SEND_IF_ASKED, UNIQUE_NO, 1, /* keytries */
this->ike_rekey, 0, /* rekey, reauth */
0, this->ike_rekey, /* jitter, overtime */
- FALSE, 0, /* mobike, dpddelay */
+ FALSE, FALSE, /* mobike, aggressive mode */
+ this->dpd_delay, /* dpd_delay */
+ this->dpd_timeout, /* dpd_timeout */
this->vip ? this->vip->clone(this->vip) : NULL,
this->pool, FALSE, NULL, NULL);
if (num)
}
child_cfg = child_cfg_create("load-test", &lifetime, NULL, TRUE, MODE_TUNNEL,
- ACTION_NONE, ACTION_NONE, FALSE, 0, 0,
- NULL, NULL);
+ ACTION_NONE, ACTION_NONE, ACTION_NONE, FALSE,
+ 0, 0, NULL, NULL, 0);
proposal = proposal_create_from_string(PROTO_ESP, "aes128-sha1");
child_cfg->add_proposal(child_cfg, proposal);
ts = traffic_selector_create_dynamic(0, 0, 65535);
return peer_cfg;
}
-/**
- * Implementation of backend_t.create_peer_cfg_enumerator.
- */
-static enumerator_t* create_peer_cfg_enumerator(private_load_tester_config_t *this,
- identification_t *me,
- identification_t *other)
+METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
+ private_load_tester_config_t *this,
+ identification_t *me, identification_t *other)
{
return enumerator_create_single(this->peer_cfg, NULL);
}
-/**
- * Implementation of backend_t.create_ike_cfg_enumerator.
- */
-static enumerator_t* create_ike_cfg_enumerator(private_load_tester_config_t *this,
- host_t *me, host_t *other)
+METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
+ private_load_tester_config_t *this, host_t *me, host_t *other)
{
ike_cfg_t *ike_cfg;
return enumerator_create_single(ike_cfg, NULL);
}
-/**
- * implements backend_t.get_peer_cfg_by_name.
- */
-static peer_cfg_t *get_peer_cfg_by_name(private_load_tester_config_t *this,
- char *name)
+METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
+ private_load_tester_config_t *this, char *name)
{
if (streq(name, "load-test"))
{
return NULL;
}
-/**
- * Implementation of load_tester_config_t.destroy.
- */
-static void destroy(private_load_tester_config_t *this)
+METHOD(load_tester_config_t, destroy, void,
+ private_load_tester_config_t *this)
{
this->peer_cfg->destroy(this->peer_cfg);
DESTROY_IF(this->proposal);
*/
load_tester_config_t *load_tester_config_create()
{
- private_load_tester_config_t *this = malloc_thing(private_load_tester_config_t);
-
- this->public.backend.create_peer_cfg_enumerator = (enumerator_t*(*)(backend_t*, identification_t *me, identification_t *other))create_peer_cfg_enumerator;
- this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
- this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
- this->public.destroy = (void(*)(load_tester_config_t*))destroy;
+ private_load_tester_config_t *this;
+
+ INIT(this,
+ .public = {
+ .backend = {
+ .create_peer_cfg_enumerator = _create_peer_cfg_enumerator,
+ .create_ike_cfg_enumerator = _create_ike_cfg_enumerator,
+ .get_peer_cfg_by_name = _get_peer_cfg_by_name,
+ },
+ .destroy = _destroy,
+ },
+ .num = 1,
+ );
- this->vip = NULL;
if (lib->settings->get_bool(lib->settings,
- "charon.plugins.load-tester.request_virtual_ip", FALSE))
+ "%s.plugins.load-tester.request_virtual_ip", FALSE, charon->name))
{
this->vip = host_create_from_string("0.0.0.0", 0);
}
this->pool = lib->settings->get_str(lib->settings,
- "charon.plugins.load-tester.pool", NULL);
+ "%s.plugins.load-tester.pool", NULL, charon->name);
this->remote = lib->settings->get_str(lib->settings,
- "charon.plugins.load-tester.remote", "127.0.0.1");
+ "%s.plugins.load-tester.remote", "127.0.0.1", charon->name);
+ this->local = lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.local", "0.0.0.0", charon->name);
this->proposal = proposal_create_from_string(PROTO_IKE,
- lib->settings->get_str(lib->settings,
- "charon.plugins.load-tester.proposal", "aes128-sha1-modp768"));
+ lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.proposal", "aes128-sha1-modp768",
+ charon->name));
if (!this->proposal)
{ /* fallback */
this->proposal = proposal_create_from_string(PROTO_IKE,
"aes128-sha1-modp768");
}
this->ike_rekey = lib->settings->get_int(lib->settings,
- "charon.plugins.load-tester.ike_rekey", 0);
+ "%s.plugins.load-tester.ike_rekey", 0, charon->name);
this->child_rekey = lib->settings->get_int(lib->settings,
- "charon.plugins.load-tester.child_rekey", 600);
+ "%s.plugins.load-tester.child_rekey", 600, charon->name);
+ this->dpd_delay = lib->settings->get_int(lib->settings,
+ "%s.plugins.load-tester.dpd_delay", 0, charon->name);
+ this->dpd_timeout = lib->settings->get_int(lib->settings,
+ "%s.plugins.load-tester.dpd_timeout", 0, charon->name);
this->initiator_auth = lib->settings->get_str(lib->settings,
- "charon.plugins.load-tester.initiator_auth", "pubkey");
+ "%s.plugins.load-tester.initiator_auth", "pubkey", charon->name);
this->responder_auth = lib->settings->get_str(lib->settings,
- "charon.plugins.load-tester.responder_auth", "pubkey");
+ "%s.plugins.load-tester.responder_auth", "pubkey", charon->name);
+ this->initiator_id = lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.initiator_id", NULL, charon->name);
+ this->responder_id = lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.responder_id", NULL, charon->name);
this->port = lib->settings->get_int(lib->settings,
- "charon.plugins.load-tester.dynamic_port", 0);
+ "%s.plugins.load-tester.dynamic_port", 0, charon->name);
- this->num = 1;
this->peer_cfg = generate_config(this, 0);
return &this->public;