android: For keyingtries > 0 notify the GUI if the limit is reached when reestablishing
authorTobias Brunner <tobias@strongswan.org>
Thu, 17 Jul 2014 13:39:29 +0000 (15:39 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 22 Jul 2014 09:10:36 +0000 (11:10 +0200)
The IKE_SA is destroyed anyway, so letting the GUI remain in
"connecting" state would be incorrect.

We still use keyingtries=0 for now, though. And we still abort after the
first failed attempt initially, in case there is a configuration error.

src/frontends/android/jni/libandroidbridge/backend/android_service.c

index 5a85d30..e60c491 100644 (file)
@@ -502,6 +502,23 @@ METHOD(listener_t, alert, bool,
                                                        (callback_job_cb_t)terminate, id, free,
                                                        (callback_job_cancel_t)return_false, JOB_PRIO_HIGH));
                                }
+                               else
+                               {
+                                       peer_cfg_t *peer_cfg;
+                                       u_int32_t tries, try;
+
+                                       /* when reestablishing and if keyingtries is not %forever
+                                        * the IKE_SA is destroyed after the set number of tries,
+                                        * so notify the GUI */
+                                       peer_cfg = ike_sa->get_peer_cfg(ike_sa);
+                                       tries = peer_cfg->get_keyingtries(peer_cfg);
+                                       try = va_arg(args, u_int32_t);
+                                       if (tries != 0 && try == tries-1)
+                                       {
+                                               charonservice->update_status(charonservice,
+                                                                                       CHARONSERVICE_UNREACHABLE_ERROR);
+                                       }
+                               }
                                this->lock->unlock(this->lock);
                                break;
                        default: