ike-cfg: Pass arguments as struct
This commit is contained in:
@@ -742,6 +742,13 @@ static job_requeue_t initiate(private_android_service_t *this)
|
||||
proposal_t *proposal;
|
||||
ike_sa_t *ike_sa;
|
||||
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 = {
|
||||
.cert_policy = CERT_ALWAYS_SEND,
|
||||
.unique = UNIQUE_REPLACE,
|
||||
@@ -761,23 +768,20 @@ static job_requeue_t initiate(private_android_service_t *this)
|
||||
.dpd_action = ACTION_RESTART,
|
||||
.close_action = ACTION_RESTART,
|
||||
};
|
||||
char *type, *server, *remote_id;
|
||||
int port;
|
||||
bool certreq;
|
||||
char *type, *remote_id;
|
||||
|
||||
if (android_sdk_version >= ANDROID_LOLLIPOP)
|
||||
{ /* only try once and notify the GUI on Android 5+ where we have a blocking TUN device */
|
||||
peer.keyingtries = 1;
|
||||
}
|
||||
|
||||
server = this->settings->get_str(this->settings, "connection.server", NULL);
|
||||
port = this->settings->get_int(this->settings, "connection.port",
|
||||
IKEV2_UDP_PORT);
|
||||
certreq = this->settings->get_bool(this->settings, "connection.certreq",
|
||||
TRUE);
|
||||
ike_cfg = ike_cfg_create(IKEV2, certreq, TRUE, "0.0.0.0",
|
||||
charon->socket->get_port(charon->socket, FALSE),
|
||||
server, port, FRAGMENTATION_YES, 0);
|
||||
ike.remote = this->settings->get_str(this->settings, "connection.server",
|
||||
NULL);
|
||||
ike.remote_port = this->settings->get_int(this->settings, "connection.port",
|
||||
IKEV2_UDP_PORT);
|
||||
ike.no_certreq = !this->settings->get_bool(this->settings,
|
||||
"connection.certreq", TRUE);
|
||||
ike_cfg = ike_cfg_create(&ike);
|
||||
proposal = parse_proposal(this, PROTO_IKE, "connection.ike_proposal");
|
||||
if (proposal)
|
||||
{
|
||||
|
||||
@@ -78,6 +78,14 @@ static peer_cfg_t* create_peer_cfg(char *name, char *host)
|
||||
ike_cfg_t *ike_cfg;
|
||||
peer_cfg_t *peer_cfg;
|
||||
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 = {
|
||||
.cert_policy = CERT_SEND_IF_ASKED,
|
||||
.unique = UNIQUE_REPLACE,
|
||||
@@ -88,13 +96,12 @@ static peer_cfg_t* create_peer_cfg(char *name, char *host)
|
||||
.dpd = 30,
|
||||
};
|
||||
|
||||
local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||
if (local_port != IKEV2_UDP_PORT)
|
||||
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||
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,
|
||||
host, remote_port, FRAGMENTATION_NO, 0);
|
||||
ike_cfg = ike_cfg_create(&ike);
|
||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
|
||||
ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
|
||||
peer_cfg = peer_cfg_create(name, ike_cfg, &peer);
|
||||
|
||||
Reference in New Issue
Block a user