1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
#include "load_tester_config.h"
#include <daemon.h>
typedef struct private_load_tester_config_t private_load_tester_config_t;
/**
* Private data of an load_tester_config_t object
*/
struct private_load_tester_config_t {
/**
* Public part
*/
load_tester_config_t public;
/**
* peer config
*/
peer_cfg_t *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)
{
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)
{
ike_cfg_t *ike_cfg;
ike_cfg = this->peer_cfg->get_ike_cfg(this->peer_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)
{
return this->peer_cfg->get_ref(this->peer_cfg);;
}
/**
* Implementation of load_tester_config_t.destroy.
*/
static void destroy(private_load_tester_config_t *this)
{
this->peer_cfg->destroy(this->peer_cfg);
free(this);
}
/**
* Described in header.
*/
load_tester_config_t *load_tester_config_create()
{
private_load_tester_config_t *this = malloc_thing(private_load_tester_config_t);
ike_cfg_t *ike_cfg;
child_cfg_t *child_cfg;
proposal_t *proposal;
traffic_selector_t *ts;
auth_info_t *auth;
auth_class_t class;
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;
ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", "127.0.0.1");
proposal = proposal_create_from_string(PROTO_IKE,
lib->settings->get_str(lib->settings,
"charon.plugins.load_tester.proposal", "aes128-sha1-modp768"));
if (!proposal)
{ /* fallback */
proposal = proposal_create_from_string(PROTO_IKE, "aes128-sha1-modp768");
}
ike_cfg->add_proposal(ike_cfg, proposal);
this->peer_cfg = peer_cfg_create("load-test", 2, ike_cfg,
identification_create_from_string("load-test@strongswan.org"),
identification_create_from_string("load-test@strongswan.org"),
CERT_SEND_IF_ASKED, UNIQUE_NO, 1, 0, 0, /* keytries, rekey, reauth */
0, 0, TRUE, 60, /* jitter, overtime, mobike, dpddelay */
NULL, NULL, FALSE, NULL, NULL); /* vip, pool, mediation */
auth = this->peer_cfg->get_auth(this->peer_cfg);
class = AUTH_CLASS_PUBKEY;
auth->add_item(auth, AUTHN_AUTH_CLASS, &class);
child_cfg = child_cfg_create("load-test", 0, 0, 300, NULL, TRUE,
MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
proposal = proposal_create_from_string(PROTO_ESP, "aes128-sha1");
child_cfg->add_proposal(child_cfg, proposal);
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
this->peer_cfg->add_child_cfg(this->peer_cfg, child_cfg);
return &this->public;
}
|