Merge branch 'android-ndk'
This branch comes with some preliminary changes for the user-land IPsec implementation and the Android App. One important change is that the UDP ports used by the socket-default plugin were made configurable (either via ./configure or strongswan.conf). Also, the plugin does randomly allocate a port if it is configured to 0, which is useful for client implementations. A consequence of these changes is that the local UDP port used when creating ike_cfg_t objects has to be fetched from the socket.
This commit is contained in:
@@ -489,7 +489,7 @@ METHOD(ike_sa_t, send_keepalive, void,
|
||||
data.len = 1;
|
||||
packet->set_data(packet, data);
|
||||
DBG1(DBG_IKE, "sending keep alive");
|
||||
charon->sender->send(charon->sender, packet);
|
||||
charon->sender->send_no_marker(charon->sender, packet);
|
||||
diff = 0;
|
||||
}
|
||||
job = send_keepalive_job_create(this->ike_sa_id);
|
||||
@@ -845,9 +845,11 @@ METHOD(ike_sa_t, float_ports, void,
|
||||
private_ike_sa_t *this)
|
||||
{
|
||||
/* do not switch if we have a custom port from MOBIKE/NAT */
|
||||
if (this->my_host->get_port(this->my_host) == IKEV2_UDP_PORT)
|
||||
if (this->my_host->get_port(this->my_host) ==
|
||||
charon->socket->get_port(charon->socket, FALSE))
|
||||
{
|
||||
this->my_host->set_port(this->my_host, IKEV2_NATT_PORT);
|
||||
this->my_host->set_port(this->my_host,
|
||||
charon->socket->get_port(charon->socket, TRUE));
|
||||
}
|
||||
if (this->other_host->get_port(this->other_host) == IKEV2_UDP_PORT)
|
||||
{
|
||||
@@ -1054,7 +1056,7 @@ static void resolve_hosts(private_ike_sa_t *this)
|
||||
if (this->local_host)
|
||||
{
|
||||
host = this->local_host->clone(this->local_host);
|
||||
host->set_port(host, IKEV2_UDP_PORT);
|
||||
host->set_port(host, charon->socket->get_port(charon->socket, FALSE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2239,7 +2241,8 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
|
||||
}
|
||||
|
||||
this->task_manager = task_manager_create(&this->public);
|
||||
this->my_host->set_port(this->my_host, IKEV2_UDP_PORT);
|
||||
this->my_host->set_port(this->my_host,
|
||||
charon->socket->get_port(charon->socket, FALSE));
|
||||
|
||||
if (!this->task_manager || !this->keymat)
|
||||
{
|
||||
|
||||
@@ -116,7 +116,8 @@ METHOD(task_t, process_r, status_t,
|
||||
notify_type_names, type, redirect);
|
||||
/* Cisco boxes reject the first message from 4500 */
|
||||
me = this->ike_sa->get_my_host(this->ike_sa);
|
||||
me->set_port(me, IKEV2_UDP_PORT);
|
||||
me->set_port(me, charon->socket->get_port(
|
||||
charon->socket, FALSE));
|
||||
this->ike_sa->set_other_host(this->ike_sa, redirect);
|
||||
this->ike_sa->reauth(this->ike_sa);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
@@ -271,13 +271,17 @@ static void update_children(private_ike_mobike_t *this)
|
||||
/**
|
||||
* Apply the port of the old host, if its ip equals the new, use port otherwise.
|
||||
*/
|
||||
static void apply_port(host_t *host, host_t *old, u_int16_t port)
|
||||
static void apply_port(host_t *host, host_t *old, u_int16_t port, bool local)
|
||||
{
|
||||
if (host->ip_equals(host, old))
|
||||
{
|
||||
port = old->get_port(old);
|
||||
}
|
||||
else if (port == IKEV2_UDP_PORT)
|
||||
else if (local && port == charon->socket->get_port(charon->socket, FALSE))
|
||||
{
|
||||
port = charon->socket->get_port(charon->socket, TRUE);
|
||||
}
|
||||
else if (!local && port == IKEV2_UDP_PORT)
|
||||
{
|
||||
port = IKEV2_NATT_PORT;
|
||||
}
|
||||
@@ -314,9 +318,9 @@ METHOD(ike_mobike_t, transmit, void,
|
||||
continue;
|
||||
}
|
||||
/* reuse port for an active address, 4500 otherwise */
|
||||
apply_port(me, me_old, ike_cfg->get_my_port(ike_cfg));
|
||||
apply_port(me, me_old, ike_cfg->get_my_port(ike_cfg), TRUE);
|
||||
other = other->clone(other);
|
||||
apply_port(other, other_old, ike_cfg->get_other_port(ike_cfg));
|
||||
apply_port(other, other_old, ike_cfg->get_other_port(ike_cfg), FALSE);
|
||||
DBG1(DBG_IKE, "checking path %#H - %#H", me, other);
|
||||
copy = packet->clone(packet);
|
||||
copy->set_source(copy, me);
|
||||
|
||||
Reference in New Issue
Block a user