ike-cfg: Pass arguments as struct
This commit is contained in:
@@ -142,9 +142,13 @@ static peer_cfg_t* create_peer_cfg(private_cmd_connection_t *this)
|
|||||||
{
|
{
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
uint16_t local_port, remote_port = IKEV2_UDP_PORT;
|
|
||||||
ike_version_t version = IKE_ANY;
|
|
||||||
proposal_t *proposal;
|
proposal_t *proposal;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.remote = this->host,
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.fragmentation = FRAGMENTATION_YES,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_SEND_IF_ASKED,
|
.cert_policy = CERT_SEND_IF_ASKED,
|
||||||
.unique = UNIQUE_REPLACE,
|
.unique = UNIQUE_REPLACE,
|
||||||
@@ -161,7 +165,7 @@ static peer_cfg_t* create_peer_cfg(private_cmd_connection_t *this)
|
|||||||
case PROF_V2_PUB:
|
case PROF_V2_PUB:
|
||||||
case PROF_V2_EAP:
|
case PROF_V2_EAP:
|
||||||
case PROF_V2_PUB_EAP:
|
case PROF_V2_PUB_EAP:
|
||||||
version = IKEV2;
|
ike.version = IKEV2;
|
||||||
break;
|
break;
|
||||||
case PROF_V1_PUB_AM:
|
case PROF_V1_PUB_AM:
|
||||||
case PROF_V1_XAUTH_AM:
|
case PROF_V1_XAUTH_AM:
|
||||||
@@ -173,17 +177,16 @@ static peer_cfg_t* create_peer_cfg(private_cmd_connection_t *this)
|
|||||||
case PROF_V1_XAUTH:
|
case PROF_V1_XAUTH:
|
||||||
case PROF_V1_XAUTH_PSK:
|
case PROF_V1_XAUTH_PSK:
|
||||||
case PROF_V1_HYBRID:
|
case PROF_V1_HYBRID:
|
||||||
version = IKEV1;
|
ike.version = IKEV1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
local_port = charon->socket->get_port(charon->socket, FALSE);
|
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||||
if (local_port != IKEV2_UDP_PORT)
|
if (ike.local_port != IKEV2_UDP_PORT)
|
||||||
{
|
{
|
||||||
remote_port = IKEV2_NATT_PORT;
|
ike.remote_port = IKEV2_NATT_PORT;
|
||||||
}
|
}
|
||||||
ike_cfg = ike_cfg_create(version, TRUE, FALSE, "0.0.0.0", local_port,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
this->host, remote_port, FRAGMENTATION_NO, 0);
|
|
||||||
if (this->ike_proposals->get_count(this->ike_proposals))
|
if (this->ike_proposals->get_count(this->ike_proposals))
|
||||||
{
|
{
|
||||||
while (this->ike_proposals->remove_first(this->ike_proposals,
|
while (this->ike_proposals->remove_first(this->ike_proposals,
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
NMSettingVpn *vpn;
|
NMSettingVpn *vpn;
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
identification_t *user = NULL, *gateway = NULL;
|
identification_t *user = NULL, *gateway = NULL;
|
||||||
const char *address, *str;
|
const char *str;
|
||||||
bool virtual, encap, proposal;
|
bool virtual, proposal;
|
||||||
proposal_t *prop;
|
proposal_t *prop;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
@@ -394,6 +394,13 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
certificate_t *cert = NULL;
|
certificate_t *cert = NULL;
|
||||||
x509_t *x509;
|
x509_t *x509;
|
||||||
bool agent = FALSE, smartcard = FALSE, loose_gateway_id = FALSE;
|
bool agent = FALSE, smartcard = FALSE, loose_gateway_id = FALSE;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "%any",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.fragmentation = FRAGMENTATION_YES,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_SEND_IF_ASKED,
|
.cert_policy = CERT_SEND_IF_ASKED,
|
||||||
.unique = UNIQUE_REPLACE,
|
.unique = UNIQUE_REPLACE,
|
||||||
@@ -430,8 +437,8 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
priv->name);
|
priv->name);
|
||||||
DBG4(DBG_CFG, "%s",
|
DBG4(DBG_CFG, "%s",
|
||||||
nm_setting_to_string(NM_SETTING(vpn)));
|
nm_setting_to_string(NM_SETTING(vpn)));
|
||||||
address = nm_setting_vpn_get_data_item(vpn, "address");
|
ike.remote = (char*)nm_setting_vpn_get_data_item(vpn, "address");
|
||||||
if (!address || !*address)
|
if (!ike.remote || !*ike.remote)
|
||||||
{
|
{
|
||||||
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
|
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
|
||||||
"Gateway address missing.");
|
"Gateway address missing.");
|
||||||
@@ -440,7 +447,7 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
str = nm_setting_vpn_get_data_item(vpn, "virtual");
|
str = nm_setting_vpn_get_data_item(vpn, "virtual");
|
||||||
virtual = streq(str, "yes");
|
virtual = streq(str, "yes");
|
||||||
str = nm_setting_vpn_get_data_item(vpn, "encap");
|
str = nm_setting_vpn_get_data_item(vpn, "encap");
|
||||||
encap = streq(str, "yes");
|
ike.force_encap = streq(str, "yes");
|
||||||
str = nm_setting_vpn_get_data_item(vpn, "ipcomp");
|
str = nm_setting_vpn_get_data_item(vpn, "ipcomp");
|
||||||
child.options |= streq(str, "yes") ? OPT_IPCOMP : 0;
|
child.options |= streq(str, "yes") ? OPT_IPCOMP : 0;
|
||||||
str = nm_setting_vpn_get_data_item(vpn, "method");
|
str = nm_setting_vpn_get_data_item(vpn, "method");
|
||||||
@@ -503,7 +510,7 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
* of the gateway as its identity. This identity will be used for
|
* of the gateway as its identity. This identity will be used for
|
||||||
* certificate lookup and requires the configured IP/DNS to be
|
* certificate lookup and requires the configured IP/DNS to be
|
||||||
* included in the gateway certificate. */
|
* included in the gateway certificate. */
|
||||||
gateway = identification_create_from_string((char*)address);
|
gateway = identification_create_from_string(ike.remote);
|
||||||
DBG1(DBG_CFG, "using CA certificate, gateway identity '%Y'", gateway);
|
DBG1(DBG_CFG, "using CA certificate, gateway identity '%Y'", gateway);
|
||||||
loose_gateway_id = TRUE;
|
loose_gateway_id = TRUE;
|
||||||
}
|
}
|
||||||
@@ -634,10 +641,7 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
/**
|
/**
|
||||||
* Set up configurations
|
* Set up configurations
|
||||||
*/
|
*/
|
||||||
ike_cfg = ike_cfg_create(IKEV2, TRUE, encap, "%any",
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
(char*)address, IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_YES, 0);
|
|
||||||
|
|
||||||
str = nm_setting_vpn_get_data_item(vpn, "proposal");
|
str = nm_setting_vpn_get_data_item(vpn, "proposal");
|
||||||
proposal = streq(str, "yes");
|
proposal = streq(str, "yes");
|
||||||
|
|||||||
+14
-7
@@ -107,14 +107,21 @@ static ike_cfg_t *load_ike_config(private_config_t *this,
|
|||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
proposal_t *proposal;
|
proposal_t *proposal;
|
||||||
char *token;
|
char *token;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = settings->get_str(settings, "configs.%s.lhost",
|
||||||
|
"%any", config),
|
||||||
|
.local_port = settings->get_int(settings, "configs.%s.lport",
|
||||||
|
500, config),
|
||||||
|
.remote = settings->get_str(settings, "configs.%s.rhost",
|
||||||
|
"%any", config),
|
||||||
|
.remote_port = settings->get_int(settings, "configs.%s.rport",
|
||||||
|
500, config),
|
||||||
|
.force_encap = settings->get_bool(settings, "configs.%s.fake_nat",
|
||||||
|
FALSE, config),
|
||||||
|
};
|
||||||
|
|
||||||
ike_cfg = ike_cfg_create(IKEV2, TRUE,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
settings->get_bool(settings, "configs.%s.fake_nat", FALSE, config),
|
|
||||||
settings->get_str(settings, "configs.%s.lhost", "%any", config),
|
|
||||||
settings->get_int(settings, "configs.%s.lport", 500, config),
|
|
||||||
settings->get_str(settings, "configs.%s.rhost", "%any", config),
|
|
||||||
settings->get_int(settings, "configs.%s.rport", 500, config),
|
|
||||||
FRAGMENTATION_NO, 0);
|
|
||||||
token = settings->get_str(settings, "configs.%s.proposal", NULL, config);
|
token = settings->get_str(settings, "configs.%s.proposal", NULL, config);
|
||||||
if (token)
|
if (token)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -742,6 +742,13 @@ static job_requeue_t initiate(private_android_service_t *this)
|
|||||||
proposal_t *proposal;
|
proposal_t *proposal;
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.foce_encap = TRUE,
|
||||||
|
.fragmentation = FRAGMENTATION_YES,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_ALWAYS_SEND,
|
.cert_policy = CERT_ALWAYS_SEND,
|
||||||
.unique = UNIQUE_REPLACE,
|
.unique = UNIQUE_REPLACE,
|
||||||
@@ -761,23 +768,20 @@ static job_requeue_t initiate(private_android_service_t *this)
|
|||||||
.dpd_action = ACTION_RESTART,
|
.dpd_action = ACTION_RESTART,
|
||||||
.close_action = ACTION_RESTART,
|
.close_action = ACTION_RESTART,
|
||||||
};
|
};
|
||||||
char *type, *server, *remote_id;
|
char *type, *remote_id;
|
||||||
int port;
|
|
||||||
bool certreq;
|
|
||||||
|
|
||||||
if (android_sdk_version >= ANDROID_LOLLIPOP)
|
if (android_sdk_version >= ANDROID_LOLLIPOP)
|
||||||
{ /* only try once and notify the GUI on Android 5+ where we have a blocking TUN device */
|
{ /* only try once and notify the GUI on Android 5+ where we have a blocking TUN device */
|
||||||
peer.keyingtries = 1;
|
peer.keyingtries = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = this->settings->get_str(this->settings, "connection.server", NULL);
|
ike.remote = this->settings->get_str(this->settings, "connection.server",
|
||||||
port = this->settings->get_int(this->settings, "connection.port",
|
NULL);
|
||||||
IKEV2_UDP_PORT);
|
ike.remote_port = this->settings->get_int(this->settings, "connection.port",
|
||||||
certreq = this->settings->get_bool(this->settings, "connection.certreq",
|
IKEV2_UDP_PORT);
|
||||||
TRUE);
|
ike.no_certreq = !this->settings->get_bool(this->settings,
|
||||||
ike_cfg = ike_cfg_create(IKEV2, certreq, TRUE, "0.0.0.0",
|
"connection.certreq", TRUE);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
server, port, FRAGMENTATION_YES, 0);
|
|
||||||
proposal = parse_proposal(this, PROTO_IKE, "connection.ike_proposal");
|
proposal = parse_proposal(this, PROTO_IKE, "connection.ike_proposal");
|
||||||
if (proposal)
|
if (proposal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,6 +78,14 @@ static peer_cfg_t* create_peer_cfg(char *name, char *host)
|
|||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
uint16_t local_port, remote_port = IKEV2_UDP_PORT;
|
uint16_t local_port, remote_port = IKEV2_UDP_PORT;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.remote = host,
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
.fragmentation = FRAGMENTATION_YES,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_SEND_IF_ASKED,
|
.cert_policy = CERT_SEND_IF_ASKED,
|
||||||
.unique = UNIQUE_REPLACE,
|
.unique = UNIQUE_REPLACE,
|
||||||
@@ -88,13 +96,12 @@ static peer_cfg_t* create_peer_cfg(char *name, char *host)
|
|||||||
.dpd = 30,
|
.dpd = 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
local_port = charon->socket->get_port(charon->socket, FALSE);
|
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||||
if (local_port != IKEV2_UDP_PORT)
|
if (ike.local_port != IKEV2_UDP_PORT)
|
||||||
{
|
{
|
||||||
remote_port = IKEV2_NATT_PORT;
|
ike.remote_port = IKEV2_NATT_PORT;
|
||||||
}
|
}
|
||||||
ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0", local_port,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
host, remote_port, FRAGMENTATION_NO, 0);
|
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
||||||
peer_cfg = peer_cfg_create(name, ike_cfg, &peer);
|
peer_cfg = peer_cfg_create(name, ike_cfg, &peer);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2018 Tobias Brunner
|
* Copyright (C) 2012-2019 Tobias Brunner
|
||||||
* Copyright (C) 2005-2007 Martin Willi
|
* Copyright (C) 2005-2007 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
* HSR Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
@@ -609,13 +609,10 @@ bool ike_cfg_has_address(ike_cfg_t *cfg, host_t *addr, bool local)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Described in header.
|
* Described in header
|
||||||
*/
|
*/
|
||||||
ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data)
|
||||||
char *me, uint16_t my_port,
|
|
||||||
char *other, uint16_t other_port,
|
|
||||||
fragmentation_t fragmentation, uint8_t dscp)
|
|
||||||
{
|
{
|
||||||
private_ike_cfg_t *this;
|
private_ike_cfg_t *this;
|
||||||
|
|
||||||
@@ -644,24 +641,24 @@ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
|||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
},
|
},
|
||||||
.refcount = 1,
|
.refcount = 1,
|
||||||
.version = version,
|
.version = data->version,
|
||||||
.certreq = certreq,
|
.certreq = !data->no_certreq,
|
||||||
.force_encap = force_encap,
|
.force_encap = data->force_encap,
|
||||||
.fragmentation = fragmentation,
|
.fragmentation = data->fragmentation,
|
||||||
.me = strdup(me),
|
.me = strdup(data->local),
|
||||||
.my_ranges = linked_list_create(),
|
.my_ranges = linked_list_create(),
|
||||||
.my_hosts = linked_list_create(),
|
.my_hosts = linked_list_create(),
|
||||||
.other = strdup(other),
|
.other = strdup(data->remote),
|
||||||
.other_ranges = linked_list_create(),
|
.other_ranges = linked_list_create(),
|
||||||
.other_hosts = linked_list_create(),
|
.other_hosts = linked_list_create(),
|
||||||
.my_port = my_port,
|
.my_port = data->local_port,
|
||||||
.other_port = other_port,
|
.other_port = data->remote_port,
|
||||||
.dscp = dscp,
|
.dscp = data->dscp,
|
||||||
.proposals = linked_list_create(),
|
.proposals = linked_list_create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
parse_addresses(me, this->my_hosts, this->my_ranges);
|
parse_addresses(data->local, this->my_hosts, this->my_ranges);
|
||||||
parse_addresses(other, this->other_hosts, this->other_ranges);
|
parse_addresses(data->remote, this->other_hosts, this->other_ranges);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2018 Tobias Brunner
|
* Copyright (C) 2012-2019 Tobias Brunner
|
||||||
* Copyright (C) 2005-2007 Martin Willi
|
* Copyright (C) 2005-2007 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
* HSR Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
typedef enum ike_version_t ike_version_t;
|
typedef enum ike_version_t ike_version_t;
|
||||||
typedef enum fragmentation_t fragmentation_t;
|
typedef enum fragmentation_t fragmentation_t;
|
||||||
typedef struct ike_cfg_t ike_cfg_t;
|
typedef struct ike_cfg_t ike_cfg_t;
|
||||||
|
typedef struct ike_cfg_create_t ike_cfg_create_t;
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <networking/host.h>
|
#include <networking/host.h>
|
||||||
@@ -241,30 +242,41 @@ struct ike_cfg_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ike_cfg_t object.
|
* Data passed to the constructor of an ike_cfg_t object.
|
||||||
*
|
*
|
||||||
* Supplied hosts become owned by ike_cfg, strings get cloned.
|
* local and remote are comma separated lists of IP addresses, DNS names,
|
||||||
|
* IP ranges or subnets. When initiating, the first non-range/subnet address is
|
||||||
|
* used as address. When responding, a match is performed against all items in
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
struct ike_cfg_create_t {
|
||||||
|
/** IKE major version to use for this config */
|
||||||
|
ike_version_t version;
|
||||||
|
/** Address/DNS name of local peer (cloned) */
|
||||||
|
char *local;
|
||||||
|
/** IKE port to use as source, 500 uses IKEv2 port floating */
|
||||||
|
uint16_t local_port;
|
||||||
|
/** Address/DNS name of remote peer (cloned) */
|
||||||
|
char *remote;
|
||||||
|
/** IKE port to use as dest, 500 uses IKEv2 port floating */
|
||||||
|
uint16_t remote_port;
|
||||||
|
/** TRUE to not send any certificate requests */
|
||||||
|
bool no_certreq;
|
||||||
|
/** Enforce UDP encapsulation by faking NATD notify */
|
||||||
|
bool force_encap;
|
||||||
|
/** Use IKE fragmentation */
|
||||||
|
fragmentation_t fragmentation;
|
||||||
|
/** DSCP value to send IKE packets with */
|
||||||
|
uint8_t dscp;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an ike_cfg_t object.
|
||||||
*
|
*
|
||||||
* me and other are comma separated lists of IP addresses, DNS names, IP ranges
|
* @param data data for this ike_cfg
|
||||||
* or subnets. When initiating, the first non-range/subnet address is used
|
|
||||||
* as address. When responding, a match is performed against all items in the
|
|
||||||
* list.
|
|
||||||
*
|
|
||||||
* @param version IKE major version to use for this config
|
|
||||||
* @param certreq TRUE to send a certificate request
|
|
||||||
* @param force_encap enforce UDP encapsulation by faking NATD notify
|
|
||||||
* @param me address/DNS name of local peer
|
|
||||||
* @param my_port IKE port to use as source, 500 uses IKEv2 port floating
|
|
||||||
* @param other address/DNS name of remote peer
|
|
||||||
* @param other_port IKE port to use as dest, 500 uses IKEv2 port floating
|
|
||||||
* @param fragmentation use IKEv1 fragmentation
|
|
||||||
* @param dscp DSCP value to send IKE packets with
|
|
||||||
* @return ike_cfg_t object.
|
* @return ike_cfg_t object.
|
||||||
*/
|
*/
|
||||||
ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data);
|
||||||
char *me, uint16_t my_port,
|
|
||||||
char *other, uint16_t other_port,
|
|
||||||
fragmentation_t fragmentation, uint8_t dscp);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the address family of the local or remote address(es). If multiple
|
* Determine the address family of the local or remote address(es). If multiple
|
||||||
|
|||||||
@@ -190,6 +190,14 @@ static void setup_tunnel(private_ha_tunnel_t *this,
|
|||||||
auth_cfg_t *auth_cfg;
|
auth_cfg_t *auth_cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
traffic_selector_t *ts;
|
traffic_selector_t *ts;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = local,
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = remote,
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_NEVER_SEND,
|
.cert_policy = CERT_NEVER_SEND,
|
||||||
.unique = UNIQUE_KEEP,
|
.unique = UNIQUE_KEEP,
|
||||||
@@ -222,9 +230,7 @@ static void setup_tunnel(private_ha_tunnel_t *this,
|
|||||||
lib->credmgr->add_set(lib->credmgr, &this->creds.public);
|
lib->credmgr->add_set(lib->credmgr, &this->creds.public);
|
||||||
|
|
||||||
/* create config and backend */
|
/* create config and backend */
|
||||||
ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, local,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
remote, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
|
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
||||||
peer_cfg = peer_cfg_create(HA_CFG_NAME, ike_cfg, &peer);
|
peer_cfg = peer_cfg_create(HA_CFG_NAME, ike_cfg, &peer);
|
||||||
|
|||||||
@@ -686,8 +686,12 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
|
|||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
char local[32], *remote;
|
char local[32];
|
||||||
host_t *addr;
|
host_t *addr;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = this->version,
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_SEND_IF_ASKED,
|
.cert_policy = CERT_SEND_IF_ASKED,
|
||||||
.unique = UNIQUE_NO,
|
.unique = UNIQUE_NO,
|
||||||
@@ -726,28 +730,25 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
|
|||||||
{
|
{
|
||||||
snprintf(local, sizeof(local), "%s", this->initiator);
|
snprintf(local, sizeof(local), "%s", this->initiator);
|
||||||
}
|
}
|
||||||
remote = this->responder;
|
ike.remote = this->responder;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(local, sizeof(local), "%s", this->responder);
|
snprintf(local, sizeof(local), "%s", this->responder);
|
||||||
remote = this->initiator;
|
ike.remote = this->initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ike.local = local;
|
||||||
if (this->port && num)
|
if (this->port && num)
|
||||||
{
|
{
|
||||||
ike_cfg = ike_cfg_create(this->version, TRUE, FALSE,
|
ike.local_port = this->port + num - 1;
|
||||||
local, this->port + num - 1,
|
ike.remote_port = IKEV2_NATT_PORT;
|
||||||
remote, IKEV2_NATT_PORT,
|
|
||||||
FRAGMENTATION_NO, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ike_cfg = ike_cfg_create(this->version, TRUE, FALSE, local,
|
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
remote, IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_NO, 0);
|
|
||||||
}
|
}
|
||||||
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
|
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
|
||||||
peer_cfg = peer_cfg_create("load-test", ike_cfg, &peer);
|
peer_cfg = peer_cfg_create("load-test", ike_cfg, &peer);
|
||||||
|
|
||||||
|
|||||||
@@ -87,9 +87,15 @@ static peer_cfg_t *build_mediation_config(private_medcli_config_t *this,
|
|||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
peer_cfg_t *med_cfg;
|
peer_cfg_t *med_cfg;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = *defaults;
|
peer_cfg_create_t peer = *defaults;
|
||||||
chunk_t me, other;
|
chunk_t me, other;
|
||||||
char *address;
|
|
||||||
|
|
||||||
/* query mediation server config:
|
/* query mediation server config:
|
||||||
* - build ike_cfg/peer_cfg for mediation connection on-the-fly
|
* - build ike_cfg/peer_cfg for mediation connection on-the-fly
|
||||||
@@ -98,14 +104,12 @@ static peer_cfg_t *build_mediation_config(private_medcli_config_t *this,
|
|||||||
"SELECT Address, ClientConfig.KeyId, MediationServerConfig.KeyId "
|
"SELECT Address, ClientConfig.KeyId, MediationServerConfig.KeyId "
|
||||||
"FROM MediationServerConfig JOIN ClientConfig",
|
"FROM MediationServerConfig JOIN ClientConfig",
|
||||||
DB_TEXT, DB_BLOB, DB_BLOB);
|
DB_TEXT, DB_BLOB, DB_BLOB);
|
||||||
if (!e || !e->enumerate(e, &address, &me, &other))
|
if (!e || !e->enumerate(e, &ike.remote, &me, &other))
|
||||||
{
|
{
|
||||||
DESTROY_IF(e);
|
DESTROY_IF(e);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0",
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
address, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
|
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
||||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
||||||
|
|
||||||
@@ -397,6 +401,14 @@ METHOD(medcli_config_t, destroy, void,
|
|||||||
medcli_config_t *medcli_config_create(database_t *db)
|
medcli_config_t *medcli_config_create(database_t *db)
|
||||||
{
|
{
|
||||||
private_medcli_config_t *this;
|
private_medcli_config_t *this;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = "0.0.0.0",
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
@@ -410,10 +422,7 @@ medcli_config_t *medcli_config_create(database_t *db)
|
|||||||
.db = db,
|
.db = db,
|
||||||
.rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200),
|
.rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200),
|
||||||
.dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300),
|
.dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300),
|
||||||
.ike = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0",
|
.ike = ike_cfg_create(&ike),
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
"0.0.0.0", IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_NO, 0),
|
|
||||||
);
|
);
|
||||||
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
|
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
|
||||||
this->ike->add_proposal(this->ike, proposal_create_default_aead(PROTO_IKE));
|
this->ike->add_proposal(this->ike, proposal_create_default_aead(PROTO_IKE));
|
||||||
|
|||||||
@@ -130,6 +130,14 @@ METHOD(medsrv_config_t, destroy, void,
|
|||||||
medsrv_config_t *medsrv_config_create(database_t *db)
|
medsrv_config_t *medsrv_config_create(database_t *db)
|
||||||
{
|
{
|
||||||
private_medsrv_config_t *this;
|
private_medsrv_config_t *this;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = "0.0.0.0",
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
@@ -143,10 +151,7 @@ medsrv_config_t *medsrv_config_create(database_t *db)
|
|||||||
.db = db,
|
.db = db,
|
||||||
.rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200),
|
.rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200),
|
||||||
.dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300),
|
.dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300),
|
||||||
.ike = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0",
|
.ike = ike_cfg_create(&ike),
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
"0.0.0.0", IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_NO, 0),
|
|
||||||
);
|
);
|
||||||
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
|
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
|
||||||
this->ike->add_proposal(this->ike, proposal_create_default_aead(PROTO_IKE));
|
this->ike->add_proposal(this->ike, proposal_create_default_aead(PROTO_IKE));
|
||||||
|
|||||||
@@ -272,10 +272,18 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
|
|||||||
while (e->enumerate(e, &id, &certreq, &force_encap, &local, &remote))
|
while (e->enumerate(e, &id, &certreq, &force_encap, &local, &remote))
|
||||||
{
|
{
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = local,
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = remote,
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = !certreq,
|
||||||
|
.force_encap = force_encap,
|
||||||
|
.fragmentation = FRAGMENTATION_YES,
|
||||||
|
};
|
||||||
|
|
||||||
ike_cfg = ike_cfg_create(IKEV2, certreq, force_encap, local,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
remote, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
|
|
||||||
add_ike_proposals(this, ike_cfg, id);
|
add_ike_proposals(this, ike_cfg, id);
|
||||||
return ike_cfg;
|
return ike_cfg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,36 +260,40 @@ static void swap_ends(stroke_msg_t *msg)
|
|||||||
*/
|
*/
|
||||||
static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg)
|
static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg)
|
||||||
{
|
{
|
||||||
|
ike_cfg_create_t ike;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
uint16_t ikeport;
|
|
||||||
char me[256], other[256];
|
char me[256], other[256];
|
||||||
|
|
||||||
swap_ends(msg);
|
swap_ends(msg);
|
||||||
|
|
||||||
|
ike = (ike_cfg_create_t){
|
||||||
|
.version = msg->add_conn.version,
|
||||||
|
.local = msg->add_conn.me.address,
|
||||||
|
.local_port = msg->add_conn.me.ikeport,
|
||||||
|
.remote = msg->add_conn.other.address,
|
||||||
|
.remote_port = msg->add_conn.other.ikeport,
|
||||||
|
.no_certreq = msg->add_conn.other.sendcert == CERT_NEVER_SEND,
|
||||||
|
.force_encap = msg->add_conn.force_encap,
|
||||||
|
.fragmentation = msg->add_conn.fragmentation,
|
||||||
|
.dscp = msg->add_conn.ikedscp,
|
||||||
|
};
|
||||||
if (msg->add_conn.me.allow_any)
|
if (msg->add_conn.me.allow_any)
|
||||||
{
|
{
|
||||||
snprintf(me, sizeof(me), "%s,0.0.0.0/0,::/0",
|
snprintf(me, sizeof(me), "%s,0.0.0.0/0,::/0",
|
||||||
msg->add_conn.me.address);
|
msg->add_conn.me.address);
|
||||||
|
ike.local = me;
|
||||||
}
|
}
|
||||||
if (msg->add_conn.other.allow_any)
|
if (msg->add_conn.other.allow_any)
|
||||||
{
|
{
|
||||||
snprintf(other, sizeof(other), "%s,0.0.0.0/0,::/0",
|
snprintf(other, sizeof(other), "%s,0.0.0.0/0,::/0",
|
||||||
msg->add_conn.other.address);
|
msg->add_conn.other.address);
|
||||||
|
ike.remote = other;
|
||||||
}
|
}
|
||||||
ikeport = msg->add_conn.me.ikeport;
|
if (ike.local_port == IKEV2_UDP_PORT)
|
||||||
ikeport = (ikeport == IKEV2_UDP_PORT) ?
|
{
|
||||||
charon->socket->get_port(charon->socket, FALSE) : ikeport;
|
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||||
ike_cfg = ike_cfg_create(msg->add_conn.version,
|
}
|
||||||
msg->add_conn.other.sendcert != CERT_NEVER_SEND,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
msg->add_conn.force_encap,
|
|
||||||
msg->add_conn.me.allow_any ?
|
|
||||||
me : msg->add_conn.me.address,
|
|
||||||
ikeport,
|
|
||||||
msg->add_conn.other.allow_any ?
|
|
||||||
other : msg->add_conn.other.address,
|
|
||||||
msg->add_conn.other.ikeport,
|
|
||||||
msg->add_conn.fragmentation,
|
|
||||||
msg->add_conn.ikedscp);
|
|
||||||
|
|
||||||
if (!add_proposals(this, msg->add_conn.algorithms.ike, ike_cfg,
|
if (!add_proposals(this, msg->add_conn.algorithms.ike, ike_cfg,
|
||||||
NULL, PROTO_IKE))
|
NULL, PROTO_IKE))
|
||||||
|
|||||||
@@ -121,12 +121,19 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
|||||||
peer_enumerator_t *this, va_list args)
|
peer_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
char *name, *ike_proposal, *esp_proposal, *ike_rekey, *esp_rekey;
|
char *name, *ike_proposal, *esp_proposal, *ike_rekey, *esp_rekey;
|
||||||
char *local_id, *local_addr, *local_net;
|
char *local_id, *local_net, *remote_id, *remote_net;
|
||||||
char *remote_id, *remote_addr, *remote_net;
|
|
||||||
peer_cfg_t **cfg;
|
peer_cfg_t **cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = "0.0.0.0",
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
.cert_policy = CERT_SEND_IF_ASKED,
|
.cert_policy = CERT_SEND_IF_ASKED,
|
||||||
.unique = UNIQUE_NO,
|
.unique = UNIQUE_NO,
|
||||||
@@ -152,8 +159,6 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
|||||||
name = "unnamed";
|
name = "unnamed";
|
||||||
local_id = NULL;
|
local_id = NULL;
|
||||||
remote_id = NULL;
|
remote_id = NULL;
|
||||||
local_addr = "0.0.0.0";
|
|
||||||
remote_addr = "0.0.0.0";
|
|
||||||
local_net = NULL;
|
local_net = NULL;
|
||||||
remote_net = NULL;
|
remote_net = NULL;
|
||||||
ike_proposal = NULL;
|
ike_proposal = NULL;
|
||||||
@@ -162,14 +167,12 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
|||||||
esp_rekey = NULL;
|
esp_rekey = NULL;
|
||||||
|
|
||||||
if (this->inner->enumerate(this->inner, &name, &local_id, &remote_id,
|
if (this->inner->enumerate(this->inner, &name, &local_id, &remote_id,
|
||||||
&local_addr, &remote_addr, &local_net, &remote_net,
|
&ike.local, &ike.remote, &local_net, &remote_net,
|
||||||
&ike_proposal, &esp_proposal, &ike_rekey, &esp_rekey))
|
&ike_proposal, &esp_proposal, &ike_rekey, &esp_rekey))
|
||||||
{
|
{
|
||||||
|
|
||||||
DESTROY_IF(this->peer_cfg);
|
DESTROY_IF(this->peer_cfg);
|
||||||
ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, local_addr,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
remote_addr, IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_NO, 0);
|
|
||||||
ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE));
|
ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE));
|
||||||
peer.rekey_time = create_rekey(ike_rekey);
|
peer.rekey_time = create_rekey(ike_rekey);
|
||||||
this->peer_cfg = peer_cfg_create(name, ike_cfg, &peer);
|
this->peer_cfg = peer_cfg_create(name, ike_cfg, &peer);
|
||||||
@@ -248,23 +251,26 @@ METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
|||||||
ike_enumerator_t *this, va_list args)
|
ike_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
ike_cfg_t **cfg;
|
ike_cfg_t **cfg;
|
||||||
char *local_addr, *remote_addr, *ike_proposal;
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "0.0.0.0",
|
||||||
|
.local_port = charon->socket->get_port(charon->socket, FALSE),
|
||||||
|
.remote = "0.0.0.0",
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
.no_certreq = TRUE,
|
||||||
|
};
|
||||||
|
char *ike_proposal;
|
||||||
|
|
||||||
VA_ARGS_VGET(args, cfg);
|
VA_ARGS_VGET(args, cfg);
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
local_addr = "0.0.0.0";
|
|
||||||
remote_addr = "0.0.0.0";
|
|
||||||
ike_proposal = NULL;
|
ike_proposal = NULL;
|
||||||
|
|
||||||
if (this->inner->enumerate(this->inner, NULL,
|
if (this->inner->enumerate(this->inner, NULL,
|
||||||
&local_addr, &remote_addr, &ike_proposal))
|
&ike.local, &ike.remote, &ike_proposal))
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->ike_cfg);
|
DESTROY_IF(this->ike_cfg);
|
||||||
this->ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, local_addr,
|
this->ike_cfg = ike_cfg_create(&ike);
|
||||||
charon->socket->get_port(charon->socket, FALSE),
|
|
||||||
remote_addr, IKEV2_UDP_PORT,
|
|
||||||
FRAGMENTATION_NO, 0);
|
|
||||||
this->ike_cfg->add_proposal(this->ike_cfg,
|
this->ike_cfg->add_proposal(this->ike_cfg,
|
||||||
create_proposal(ike_proposal, PROTO_IKE));
|
create_proposal(ike_proposal, PROTO_IKE));
|
||||||
|
|
||||||
|
|||||||
@@ -2382,6 +2382,7 @@ CALLBACK(config_sn, bool,
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
peer_cfg_create_t cfg;
|
peer_cfg_create_t cfg;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
|
ike_cfg_create_t ike;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
auth_data_t *auth;
|
auth_data_t *auth;
|
||||||
@@ -2509,10 +2510,18 @@ CALLBACK(config_sn, bool,
|
|||||||
|
|
||||||
log_peer_data(&peer);
|
log_peer_data(&peer);
|
||||||
|
|
||||||
ike_cfg = ike_cfg_create(peer.version, peer.send_certreq, peer.encap,
|
ike = (ike_cfg_create_t){
|
||||||
peer.local_addrs, peer.local_port,
|
.version = peer.version,
|
||||||
peer.remote_addrs, peer.remote_port,
|
.local = peer.local_addrs,
|
||||||
peer.fragmentation, peer.dscp);
|
.local_port = peer.local_port,
|
||||||
|
.remote = peer.remote_addrs,
|
||||||
|
.remote_port = peer.remote_port,
|
||||||
|
.no_certreq = !peer.send_certreq,
|
||||||
|
.force_encap = peer.encap,
|
||||||
|
.fragmentation = peer.fragmentation,
|
||||||
|
.dscp = peer.dscp,
|
||||||
|
};
|
||||||
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
|
|
||||||
cfg = (peer_cfg_create_t){
|
cfg = (peer_cfg_create_t){
|
||||||
.cert_policy = peer.send_cert,
|
.cert_policy = peer.send_cert,
|
||||||
|
|||||||
@@ -19,11 +19,17 @@
|
|||||||
|
|
||||||
static void assert_family(int expected, char *addr, bool local)
|
static void assert_family(int expected, char *addr, bool local)
|
||||||
{
|
{
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = local ? addr : "%any",
|
||||||
|
.local_port = 500,
|
||||||
|
.remote = local ? "%any" : addr,
|
||||||
|
.remote_port = 500,
|
||||||
|
};
|
||||||
ike_cfg_t *cfg;
|
ike_cfg_t *cfg;
|
||||||
int family;
|
int family;
|
||||||
|
|
||||||
cfg = ike_cfg_create(IKEV2, FALSE, FALSE, local ? addr : "%any", 500,
|
cfg = ike_cfg_create(&ike);
|
||||||
local ? "%any" : addr, 500, FRAGMENTATION_NO, 0);
|
|
||||||
family = ike_cfg_get_family(cfg, local);
|
family = ike_cfg_get_family(cfg, local);
|
||||||
ck_assert_msg(expected == family, "expected family %d != %d (addr: '%s')",
|
ck_assert_msg(expected == family, "expected family %d != %d (addr: '%s')",
|
||||||
expected, family, addr);
|
expected, family, addr);
|
||||||
|
|||||||
@@ -23,8 +23,14 @@
|
|||||||
*/
|
*/
|
||||||
static ike_cfg_t *create_ike_cfg()
|
static ike_cfg_t *create_ike_cfg()
|
||||||
{
|
{
|
||||||
return ike_cfg_create(IKEV2, TRUE, FALSE, "127.0.0.1", 500,
|
ike_cfg_create_t ike = {
|
||||||
"127.0.0.1", 500, FRAGMENTATION_NO, 0);
|
.version = IKEV2,
|
||||||
|
.local = "127.0.0.1",
|
||||||
|
.local_port = 500,
|
||||||
|
.remote = "127.0.0.1",
|
||||||
|
.remote_port = 500,
|
||||||
|
};
|
||||||
|
return ike_cfg_create(&ike);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,11 +85,17 @@ exchange_test_helper_t *exchange_test_helper;
|
|||||||
|
|
||||||
static ike_cfg_t *create_ike_cfg(bool initiator, exchange_test_sa_conf_t *conf)
|
static ike_cfg_t *create_ike_cfg(bool initiator, exchange_test_sa_conf_t *conf)
|
||||||
{
|
{
|
||||||
|
ike_cfg_create_t ike = {
|
||||||
|
.version = IKEV2,
|
||||||
|
.local = "127.0.0.1",
|
||||||
|
.local_port = IKEV2_UDP_PORT,
|
||||||
|
.remote = "127.0.0.1",
|
||||||
|
.remote_port = IKEV2_UDP_PORT,
|
||||||
|
};
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
char *proposal = NULL;
|
char *proposal = NULL;
|
||||||
|
|
||||||
ike_cfg = ike_cfg_create(IKEV2, TRUE, FALSE, "127.0.0.1", IKEV2_UDP_PORT,
|
ike_cfg = ike_cfg_create(&ike);
|
||||||
"127.0.0.1", IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
|
|
||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
proposal = initiator ? conf->initiator.ike : conf->responder.ike;
|
proposal = initiator ? conf->initiator.ike : conf->responder.ike;
|
||||||
|
|||||||
Reference in New Issue
Block a user