Merge branch 'android-state-updates'

The GUI reflects the state of the IKE daemon more closely by switching
back to the "connecting" state when the IKE_SA or CHILD_SA is down and
is getting reestablished.

Fixes #616.
This commit is contained in:
Tobias Brunner
2014-07-22 11:06:31 +02:00
3 changed files with 17 additions and 12 deletions
@@ -381,14 +381,8 @@ METHOD(listener_t, child_updown, bool,
} }
else else
{ {
if (ike_sa->has_condition(ike_sa, COND_REAUTHENTICATING))
{ /* we ignore this during reauthentication */
return TRUE;
}
close_tun_device(this);
charonservice->update_status(charonservice, charonservice->update_status(charonservice,
CHARONSERVICE_CHILD_STATE_DOWN); CHARONSERVICE_CHILD_STATE_DOWN);
return FALSE;
} }
} }
return TRUE; return TRUE;
@@ -398,7 +392,8 @@ METHOD(listener_t, ike_updown, bool,
private_android_service_t *this, ike_sa_t *ike_sa, bool up) private_android_service_t *this, ike_sa_t *ike_sa, bool up)
{ {
/* this callback is only registered during initiation, so if the IKE_SA /* this callback is only registered during initiation, so if the IKE_SA
* goes down we assume an authentication error */ * goes down we assume some kind of authentication error, more specific
* errors are catched in the alert() handler */
if (this->ike_sa == ike_sa && !up) if (this->ike_sa == ike_sa && !up)
{ {
charonservice->update_status(charonservice, charonservice->update_status(charonservice,
@@ -458,6 +453,11 @@ METHOD(listener_t, ike_reestablish, bool,
this->ike_sa = new; this->ike_sa = new;
/* re-register hook to detect initiation failures */ /* re-register hook to detect initiation failures */
this->public.listener.ike_updown = _ike_updown; this->public.listener.ike_updown = _ike_updown;
/* if the IKE_SA got deleted by the responder we get the child_down()
* event on the old IKE_SA after this hook has been called, so they
* get ignored and thus we trigger the event here */
charonservice->update_status(charonservice,
CHARONSERVICE_CHILD_STATE_DOWN);
/* the TUN device will be closed when the new CHILD_SA is established */ /* the TUN device will be closed when the new CHILD_SA is established */
} }
return TRUE; return TRUE;
@@ -322,9 +322,8 @@ public class CharonVpnService extends VpnService implements Runnable
} }
/** /**
* Set an error on the state service and disconnect the current connection. * Set an error on the state service. Called by the handler thread and any
* This is not done by calling stopCurrentConnection() above, but instead * of charon's threads.
* is done asynchronously via state service.
* *
* @param error error state * @param error error state
*/ */
@@ -337,7 +336,6 @@ public class CharonVpnService extends VpnService implements Runnable
if (!mIsDisconnecting) if (!mIsDisconnecting)
{ {
mService.setError(error); mService.setError(error);
mService.disconnect();
} }
} }
} }
@@ -354,7 +352,10 @@ public class CharonVpnService extends VpnService implements Runnable
switch (status) switch (status)
{ {
case STATE_CHILD_SA_DOWN: case STATE_CHILD_SA_DOWN:
/* we ignore this as we use closeaction=restart */ if (!mIsDisconnecting)
{
setState(State.CONNECTING);
}
break; break;
case STATE_CHILD_SA_UP: case STATE_CHILD_SA_UP:
setState(State.CONNECTED); setState(State.CONNECTED);
@@ -313,6 +313,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
private void clearError() private void clearError()
{ {
if (mService != null)
{
mService.disconnect();
}
mDismissedConnectionID = mErrorConnectionID; mDismissedConnectionID = mErrorConnectionID;
updateView(); updateView();
} }