Send different notifies if quick mode fails

This commit is contained in:
Martin Willi
2012-03-20 17:31:24 +01:00
parent b64d6423b1
commit bf5b1d9e73
+14 -13
View File
@@ -645,6 +645,7 @@ static bool has_notify_errors(private_quick_mode_t *this, message_t *message)
type = notify->get_notify_type(notify); type = notify->get_notify_type(notify);
if (type < 16384) if (type < 16384)
{ {
DBG1(DBG_IKE, "received %N error notify", DBG1(DBG_IKE, "received %N error notify",
notify_type_names, type); notify_type_names, type);
err = TRUE; err = TRUE;
@@ -703,7 +704,7 @@ METHOD(task_t, process_r, status_t,
if (!this->config) if (!this->config)
{ {
DBG1(DBG_IKE, "no child config found"); DBG1(DBG_IKE, "no child config found");
return FAILED; return send_notify(this, NO_PROPOSAL_CHOSEN);
} }
sa_payload = (sa_payload_t*)message->get_payload(message, sa_payload = (sa_payload_t*)message->get_payload(message,
@@ -711,7 +712,7 @@ METHOD(task_t, process_r, status_t,
if (!sa_payload) if (!sa_payload)
{ {
DBG1(DBG_IKE, "sa payload missing"); DBG1(DBG_IKE, "sa payload missing");
return FAILED; return send_notify(this, INVALID_PAYLOAD_TYPE);
} }
list = sa_payload->get_proposals(sa_payload); list = sa_payload->get_proposals(sa_payload);
this->proposal = this->config->select_proposal(this->config, this->proposal = this->config->select_proposal(this->config,
@@ -731,7 +732,7 @@ METHOD(task_t, process_r, status_t,
if (!get_nonce(this, &this->nonce_i, message)) if (!get_nonce(this, &this->nonce_i, message))
{ {
return FAILED; return send_notify(this, INVALID_PAYLOAD_TYPE);
} }
if (this->proposal->get_algorithm(this->proposal, if (this->proposal->get_algorithm(this->proposal,
@@ -743,11 +744,11 @@ METHOD(task_t, process_r, status_t,
{ {
DBG1(DBG_IKE, "negotiated DH group %N not supported", DBG1(DBG_IKE, "negotiated DH group %N not supported",
diffie_hellman_group_names, group); diffie_hellman_group_names, group);
return FAILED; return send_notify(this, INVALID_KEY_INFORMATION);
} }
if (!get_ke(this, message)) if (!get_ke(this, message))
{ {
return FAILED; return send_notify(this, INVALID_PAYLOAD_TYPE);
} }
} }
@@ -761,7 +762,7 @@ METHOD(task_t, process_r, status_t,
{ {
if (has_notify_errors(this, message)) if (has_notify_errors(this, message))
{ {
return FAILED; return SUCCESS;
} }
if (!install(this)) if (!install(this))
{ {
@@ -793,7 +794,7 @@ METHOD(task_t, build_r, status_t,
if (!this->spi_r) if (!this->spi_r)
{ {
DBG1(DBG_IKE, "allocating SPI from kernel failed"); DBG1(DBG_IKE, "allocating SPI from kernel failed");
return FAILED; return send_notify(this, NO_PROPOSAL_CHOSEN);
} }
this->proposal->set_spi(this->proposal, this->spi_r); this->proposal->set_spi(this->proposal, this->spi_r);
@@ -843,7 +844,7 @@ METHOD(task_t, process_i, status_t,
if (!sa_payload) if (!sa_payload)
{ {
DBG1(DBG_IKE, "sa payload missing"); DBG1(DBG_IKE, "sa payload missing");
return FAILED; return send_notify(this, NO_PROPOSAL_CHOSEN);
} }
list = sa_payload->get_proposals(sa_payload); list = sa_payload->get_proposals(sa_payload);
this->proposal = this->config->select_proposal(this->config, this->proposal = this->config->select_proposal(this->config,
@@ -852,7 +853,7 @@ METHOD(task_t, process_i, status_t,
if (!this->proposal) if (!this->proposal)
{ {
DBG1(DBG_IKE, "no matching proposal found"); DBG1(DBG_IKE, "no matching proposal found");
return FAILED; return send_notify(this, NO_PROPOSAL_CHOSEN);
} }
this->spi_r = this->proposal->get_spi(this->proposal); this->spi_r = this->proposal->get_spi(this->proposal);
@@ -860,19 +861,19 @@ METHOD(task_t, process_i, status_t,
if (!get_nonce(this, &this->nonce_r, message)) if (!get_nonce(this, &this->nonce_r, message))
{ {
return FAILED; return send_notify(this, INVALID_PAYLOAD_TYPE);
} }
if (this->dh && !get_ke(this, message)) if (this->dh && !get_ke(this, message))
{ {
return FAILED; return send_notify(this, INVALID_KEY_INFORMATION);
} }
if (!get_ts(this, message)) if (!get_ts(this, message))
{ {
return FAILED; return send_notify(this, INVALID_PAYLOAD_TYPE);
} }
if (!install(this)) if (!install(this))
{ {
return FAILED; return send_notify(this, NO_PROPOSAL_CHOSEN);
} }
this->state = QM_NEGOTIATED; this->state = QM_NEGOTIATED;
return NEED_MORE; return NEED_MORE;