device: Add support functions needed by ethernet tethering
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Thu, 25 Apr 2013 11:47:49 +0000 (14:47 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 26 Apr 2013 09:31:32 +0000 (12:31 +0300)
include/device.h
src/device.c

index b372821f3bd706eb83c0078f7587bdf763ded10d..338257566da7d6d52d91ede3e256d4e7a656c9b7 100644 (file)
@@ -113,6 +113,9 @@ int connman_device_set_regdom(struct connman_device *device,
 void connman_device_regdom_notify(struct connman_device *device,
                                        int result, const char *alpha2);
 struct connman_device *connman_device_create_from_index(int index);
+struct connman_device *connman_device_find_by_index(int index);
+int connman_device_disconnect_service(struct connman_device *device);
+int connman_device_reconnect_service(struct connman_device *device);
 
 struct connman_device_driver {
        const char *name;
index 2e0dbdcaa2fb85fbc95693f3e2c24ab1c9378605..5feeee1264a03fc28a416d6a87e8ad1e3835d973 100644 (file)
@@ -647,6 +647,36 @@ int __connman_device_disconnect(struct connman_device *device)
        return 0;
 }
 
+int connman_device_disconnect_service(struct connman_device *device)
+{
+       DBG("device %p", device);
+
+       device->reconnect = FALSE;
+
+       if (device->network) {
+               struct connman_service *service =
+                       connman_service_lookup_from_network(device->network);
+
+               if (service != NULL)
+                       __connman_service_disconnect(service);
+               else
+                       connman_network_set_connected(device->network, FALSE);
+       }
+
+       return 0;
+}
+
+int connman_device_reconnect_service(struct connman_device *device)
+{
+       DBG("device %p", device);
+
+       device->reconnect = TRUE;
+
+       __connman_service_auto_connect();
+
+       return 0;
+}
+
 static void mark_network_available(gpointer key, gpointer value,
                                                        gpointer user_data)
 {
@@ -1035,6 +1065,19 @@ struct connman_device *__connman_device_find_device(
        return NULL;
 }
 
+struct connman_device *connman_device_find_by_index(int index)
+{
+       GSList *list;
+
+       for (list = device_list; list != NULL; list = list->next) {
+               struct connman_device *device = list->data;
+               if (device->index == index)
+                       return device;
+       }
+
+       return NULL;
+}
+
 /**
  * connman_device_set_regdom
  * @device: device structure