diff options
author | Martin Willi <martin@revosec.ch> | 2011-12-07 17:51:35 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-03-20 17:31:14 +0100 |
commit | 1755ac0617b340f1ba10bc43e96f8bee874db539 (patch) | |
tree | cc29224994dce9c57880b5f7d7b825762d3196d3 /src/libcharon/sa/tasks/quick_mode.c | |
parent | 5adf855e3dd2484715082d3d612c051e6a5f78bb (diff) | |
download | strongswan-1755ac0617b340f1ba10bc43e96f8bee874db539.tar.bz2 strongswan-1755ac0617b340f1ba10bc43e96f8bee874db539.tar.xz |
Cleaned up quick mode notify processing
Diffstat (limited to 'src/libcharon/sa/tasks/quick_mode.c')
-rw-r--r-- | src/libcharon/sa/tasks/quick_mode.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/libcharon/sa/tasks/quick_mode.c b/src/libcharon/sa/tasks/quick_mode.c index dedcd66a2..6b6a93505 100644 --- a/src/libcharon/sa/tasks/quick_mode.c +++ b/src/libcharon/sa/tasks/quick_mode.c @@ -595,24 +595,45 @@ METHOD(task_t, build_i, status_t, } } -status_t process_notify(notify_payload_t *notify) +/** + * Check for notify errors, return TRUE if error found + */ +static bool has_notify_errors(private_quick_mode_t *this, message_t *message) { - if(notify->get_notify_type(notify) < 16384) + enumerator_t *enumerator; + payload_t *payload; + bool err = FALSE; + + enumerator = message->create_payload_enumerator(message); + while (enumerator->enumerate(enumerator, &payload)) { - DBG1(DBG_IKE, "Received %N error notification.", notify_type_names, notify->get_notify_type(notify)); - return FAILED; + if (payload->get_type(payload) == NOTIFY_V1) + { + notify_payload_t *notify; + notify_type_t type; + + notify = (notify_payload_t*)payload; + type = notify->get_notify_type(notify); + if (type < 16384) + { + DBG1(DBG_IKE, "received %N error notify", + notify_type_names, type); + err = TRUE; + } + else + { + DBG1(DBG_IKE, "received %N notify", notify_type_names, type); + } + } } - DBG1(DBG_IKE, "Received %N notification.", notify_type_names, notify->get_notify_type(notify)); - return SUCCESS; + enumerator->destroy(enumerator); + + return err; } METHOD(task_t, process_r, status_t, private_quick_mode_t *this, message_t *message) { - enumerator_t *enumerator; - payload_t *payload; - status_t status; - switch (this->state) { case QM_INIT: @@ -705,19 +726,10 @@ METHOD(task_t, process_r, status_t, } case QM_NEGOTIATED: { - enumerator = message->create_payload_enumerator(message); - while(enumerator->enumerate(enumerator, &payload)) + if (has_notify_errors(this, message)) { - if(payload->get_type(payload) == NOTIFY_V1) - { - status = process_notify((notify_payload_t *)payload); - if(status != SUCCESS) - { - return status; - } - } + return FAILED; } - enumerator->destroy(enumerator); if (!install(this)) { return FAILED; |