Install quick mode CHILD_SAs with negotiated encapsulation mode
This commit is contained in:
@@ -119,6 +119,11 @@ struct private_quick_mode_t {
|
|||||||
*/
|
*/
|
||||||
u_int32_t reqid;
|
u_int32_t reqid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Negotiated mode, tunnel or transport
|
||||||
|
*/
|
||||||
|
ipsec_mode_t mode;
|
||||||
|
|
||||||
/** states of quick mode */
|
/** states of quick mode */
|
||||||
enum {
|
enum {
|
||||||
QM_INIT,
|
QM_INIT,
|
||||||
@@ -137,7 +142,7 @@ static bool install(private_quick_mode_t *this)
|
|||||||
|
|
||||||
this->child_sa->set_proposal(this->child_sa, this->proposal);
|
this->child_sa->set_proposal(this->child_sa, this->proposal);
|
||||||
this->child_sa->set_state(this->child_sa, CHILD_INSTALLING);
|
this->child_sa->set_state(this->child_sa, CHILD_INSTALLING);
|
||||||
this->child_sa->set_mode(this->child_sa, MODE_TUNNEL);
|
this->child_sa->set_mode(this->child_sa, this->mode);
|
||||||
this->child_sa->set_protocol(this->child_sa,
|
this->child_sa->set_protocol(this->child_sa,
|
||||||
this->proposal->get_protocol(this->proposal));
|
this->proposal->get_protocol(this->proposal));
|
||||||
|
|
||||||
@@ -550,10 +555,10 @@ METHOD(task_t, build_i, status_t,
|
|||||||
sa_payload_t *sa_payload;
|
sa_payload_t *sa_payload;
|
||||||
linked_list_t *list;
|
linked_list_t *list;
|
||||||
proposal_t *proposal;
|
proposal_t *proposal;
|
||||||
ipsec_mode_t mode;
|
|
||||||
diffie_hellman_group_t group;
|
diffie_hellman_group_t group;
|
||||||
bool udp = this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY);
|
bool udp;
|
||||||
|
|
||||||
|
udp = this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY);
|
||||||
this->child_sa = child_sa_create(
|
this->child_sa = child_sa_create(
|
||||||
this->ike_sa->get_my_host(this->ike_sa),
|
this->ike_sa->get_my_host(this->ike_sa),
|
||||||
this->ike_sa->get_other_host(this->ike_sa),
|
this->ike_sa->get_other_host(this->ike_sa),
|
||||||
@@ -574,8 +579,8 @@ METHOD(task_t, build_i, status_t,
|
|||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
mode = this->config->get_mode(this->config);
|
this->mode = this->config->get_mode(this->config);
|
||||||
if (udp && mode == MODE_TRANSPORT)
|
if (udp && this->mode == MODE_TRANSPORT)
|
||||||
{
|
{
|
||||||
/* TODO-IKEv1: disable NAT-T for TRANSPORT mode by default? */
|
/* TODO-IKEv1: disable NAT-T for TRANSPORT mode by default? */
|
||||||
add_nat_oa_payloads(this, message);
|
add_nat_oa_payloads(this, message);
|
||||||
@@ -584,7 +589,7 @@ METHOD(task_t, build_i, status_t,
|
|||||||
get_lifetimes(this);
|
get_lifetimes(this);
|
||||||
sa_payload = sa_payload_create_from_proposals_v1(list,
|
sa_payload = sa_payload_create_from_proposals_v1(list,
|
||||||
this->lifetime, this->lifebytes, AUTH_NONE,
|
this->lifetime, this->lifebytes, AUTH_NONE,
|
||||||
mode, udp);
|
this->mode, udp);
|
||||||
list->destroy_offset(list, offsetof(proposal_t, destroy));
|
list->destroy_offset(list, offsetof(proposal_t, destroy));
|
||||||
message->add_payload(message, &sa_payload->payload_interface);
|
message->add_payload(message, &sa_payload->payload_interface);
|
||||||
|
|
||||||
@@ -709,7 +714,7 @@ METHOD(task_t, process_r, status_t,
|
|||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
host_t *me, *other;
|
host_t *me, *other;
|
||||||
u_int16_t group;
|
u_int16_t group;
|
||||||
bool udp = this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY);
|
bool udp;
|
||||||
|
|
||||||
if (!get_ts(this, message))
|
if (!get_ts(this, message))
|
||||||
{
|
{
|
||||||
@@ -760,6 +765,7 @@ METHOD(task_t, process_r, status_t,
|
|||||||
|
|
||||||
get_lifetimes(this);
|
get_lifetimes(this);
|
||||||
apply_lifetimes(this, sa_payload);
|
apply_lifetimes(this, sa_payload);
|
||||||
|
this->mode = sa_payload->get_encap_mode(sa_payload, &udp);
|
||||||
|
|
||||||
if (!this->proposal)
|
if (!this->proposal)
|
||||||
{
|
{
|
||||||
@@ -829,8 +835,7 @@ METHOD(task_t, build_r, status_t,
|
|||||||
case QM_INIT:
|
case QM_INIT:
|
||||||
{
|
{
|
||||||
sa_payload_t *sa_payload;
|
sa_payload_t *sa_payload;
|
||||||
ipsec_mode_t mode;
|
bool udp;
|
||||||
bool udp = this->child_sa->has_encap(this->child_sa);
|
|
||||||
|
|
||||||
this->spi_r = this->child_sa->alloc_spi(this->child_sa, PROTO_ESP);
|
this->spi_r = this->child_sa->alloc_spi(this->child_sa, PROTO_ESP);
|
||||||
if (!this->spi_r)
|
if (!this->spi_r)
|
||||||
@@ -840,8 +845,8 @@ METHOD(task_t, build_r, status_t,
|
|||||||
}
|
}
|
||||||
this->proposal->set_spi(this->proposal, this->spi_r);
|
this->proposal->set_spi(this->proposal, this->spi_r);
|
||||||
|
|
||||||
mode = this->config->get_mode(this->config);
|
udp = this->child_sa->has_encap(this->child_sa);
|
||||||
if (udp && mode == MODE_TRANSPORT)
|
if (udp && this->mode == MODE_TRANSPORT)
|
||||||
{
|
{
|
||||||
/* TODO-IKEv1: disable NAT-T for TRANSPORT mode by default? */
|
/* TODO-IKEv1: disable NAT-T for TRANSPORT mode by default? */
|
||||||
add_nat_oa_payloads(this, message);
|
add_nat_oa_payloads(this, message);
|
||||||
@@ -849,7 +854,7 @@ METHOD(task_t, build_r, status_t,
|
|||||||
|
|
||||||
sa_payload = sa_payload_create_from_proposal_v1(this->proposal,
|
sa_payload = sa_payload_create_from_proposal_v1(this->proposal,
|
||||||
this->lifetime, this->lifebytes, AUTH_NONE,
|
this->lifetime, this->lifebytes, AUTH_NONE,
|
||||||
mode, udp);
|
this->mode, udp);
|
||||||
message->add_payload(message, &sa_payload->payload_interface);
|
message->add_payload(message, &sa_payload->payload_interface);
|
||||||
|
|
||||||
if (!add_nonce(this, &this->nonce_r, message))
|
if (!add_nonce(this, &this->nonce_r, message))
|
||||||
|
|||||||
Reference in New Issue
Block a user