From: Pekka Pessi <pekka.pe...@nokia.com>

Return error immediately if connection attempts are known to fail.
---
 plugins/ofono.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index fe2a90f..4e225d8 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -471,11 +471,25 @@ static void set_apn(struct connman_network *network)
 
 static int network_connect(struct connman_network *network)
 {
+       struct connman_device *device;
+       struct modem_data *modem;
+
        DBG("network %p", network);
 
        if (connman_network_get_index(network) >= 0)
                return -EISCONN;
 
+       device = connman_network_get_device(network);
+       if (device == NULL)
+               return -ENODEV;
+
+       modem = connman_device_get_data(device);
+       if (modem == NULL)
+               return -ENODEV;
+
+       if (modem->powered == FALSE)
+               return -ENOLINK;
+
        return set_network_active(network, TRUE);
 }
 
-- 
1.7.1

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to