summaryrefslogtreecommitdiff
path: root/plugins/vpn.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-12-10 12:42:04 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-12-10 13:01:08 +0200
commit477bcfe9d54a71b5e0c93ac1bf38d62db705625d (patch)
tree9a141064aa7e803005af1adafbd149f30b34933d /plugins/vpn.c
parent14f573d3bef14157f54541e614d8a6bca906b28d (diff)
downloadconnman-477bcfe9d54a71b5e0c93ac1bf38d62db705625d.tar.gz
connman-477bcfe9d54a71b5e0c93ac1bf38d62db705625d.tar.bz2
connman-477bcfe9d54a71b5e0c93ac1bf38d62db705625d.zip
vpn-plugin: Propagate most common errors to callback function
Instead of always setting the create callback function error to -ECONNREFUSED, create a helper function to detect the two most often emitted errors.
Diffstat (limited to 'plugins/vpn.c')
-rw-r--r--plugins/vpn.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/vpn.c b/plugins/vpn.c
index ff4d7251..65a4853d 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -449,6 +449,16 @@ static int extract_nameservers(DBusMessageIter *array,
return 0;
}
+static int errorstr2val(const char *error) {
+ if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".InProgress") == 0)
+ return -EINPROGRESS;
+
+ if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".AlreadyConnected") == 0)
+ return -EISCONN;
+
+ return -ECONNREFUSED;
+}
+
static void connect_reply(DBusPendingCall *call, void *user_data)
{
DBusMessage *reply;
@@ -466,15 +476,15 @@ static void connect_reply(DBusPendingCall *call, void *user_data)
dbus_error_init(&error);
if (dbus_set_error_from_message(&error, reply) == TRUE) {
- if (dbus_error_has_name(&error, CONNMAN_ERROR_INTERFACE
- ".InProgress") == FALSE) {
+ int err = errorstr2val(error.name);
+ if (err != -EINPROGRESS) {
connman_error("Connect reply: %s (%s)", error.message,
error.name);
dbus_error_free(&error);
+ DBG("data %p cb_data %p", data, cb_data);
if (cb_data != NULL) {
- cb_data->callback(cb_data->message,
- ECONNREFUSED, NULL);
+ cb_data->callback(cb_data->message, err, NULL);
free_config_cb_data(cb_data);
data->cb_data = NULL;
}