diff options
author | Jussi Laakkonen <jussi.laakkonen@jolla.com> | 2021-08-30 12:24:05 +0300 |
---|---|---|
committer | Daniel Wagner <wagi@monom.org> | 2021-08-30 19:01:23 +0200 |
commit | 3d0961ecff8d133875b3b61375f945bbf0d634d4 (patch) | |
tree | 8728db0aa3bc5fd7219a1336697f9e61158e3c13 /plugins | |
parent | b2ffe8a24d6a2b9ed82a05da5ba84cbd4fb0d7d1 (diff) | |
download | connman-3d0961ecff8d133875b3b61375f945bbf0d634d4.tar.gz |
vpn: Refactor connect_reply() and handle NoCarrier -> ENOLINK error
Refactor connect_reply() to be extendable for more fine grained error
handling.
Add handling of ENOLINK error that is reported back by vpnd when a VPN
cannot be connected because connmand is in offline state. ENOLINK is to
be handled as any other error causing the VPN state not to change later
on that in turn would cause the cb_data->callback() never getting
called.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/vpn.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/vpn.c b/plugins/vpn.c index d708d1ff..387447c3 100644 --- a/plugins/vpn.c +++ b/plugins/vpn.c @@ -491,6 +491,9 @@ static int errorstr2val(const char *error) { if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".AlreadyConnected") == 0) return -EISCONN; + if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".NoCarrier") == 0) + return -ENOLINK; + if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".OperationCanceled") == 0) return -ECANCELED; @@ -529,16 +532,23 @@ static void connect_reply(DBusPendingCall *call, void *user_data) if (dbus_set_error_from_message(&error, reply)) { int err = errorstr2val(error.name); + switch (err) { + case -EINPROGRESS: + break; /* * ECANCELED means that user has canceled authentication * dialog. That's not really an error, it's part of a normal * workflow. We also take it as a request to turn autoconnect * off, in case if it was on. */ - if (err == -ECANCELED) { + case -ECANCELED: DBG("%s connect canceled", data->path); connman_provider_set_autoconnect(data->provider, false); - } else if (err != -EINPROGRESS) { + break; + case -ENOLINK: /* vpnd reports that connmand is not online. */ + case -EISCONN: + case -ECONNREFUSED: + default: connman_error("Connect reply: %s (%s)", error.message, error.name); DBG("data %p cb_data %p", data, cb_data); |