Add support for disconnecting networks first
[connman] / src / device.c
index 6e2575b..74196b7 100644 (file)
@@ -893,6 +893,17 @@ void connman_device_set_mode(struct connman_device *device,
 }
 
 /**
+ * connman_device_get_mode:
+ * @device: device structure
+ *
+ * Get network mode of device
+ */
+enum connman_device_mode connman_device_get_mode(struct connman_device *device)
+{
+       return device->mode;
+}
+
+/**
  * connman_device_set_powered:
  * @device: device structure
  * @powered: powered state
@@ -985,6 +996,25 @@ int connman_device_set_carrier(struct connman_device *device,
        return 0;
 }
 
+void __connman_device_disconnect(struct connman_device *device)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+
+       DBG("device %p", device);
+
+       g_hash_table_iter_init(&iter, device->networks);
+
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               struct connman_network *network = value;
+
+               if (connman_network_get_connected(network) == FALSE)
+                       continue;
+
+               __connman_network_disconnect(network);
+       }
+}
+
 static void connect_known_network(struct connman_device *device)
 {
        struct connman_network *network = NULL;