5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 static GSList *device_list = NULL;
32 static gchar **device_filter = NULL;
33 static gchar **nodevice_filter = NULL;
35 enum connman_pending_type {
41 struct connman_device {
43 enum connman_device_type type;
44 enum connman_pending_type powered_pending; /* Indicates a pending
45 enable/disable request */
46 connman_bool_t powered;
47 connman_bool_t scanning;
48 connman_bool_t disconnected;
49 connman_bool_t reconnect;
50 connman_uint16_t scan_interval;
51 connman_uint16_t backoff_interval;
62 guint pending_timeout;
64 struct connman_device_driver *driver;
68 struct connman_network *network;
72 #define SCAN_INITIAL_DELAY 10
74 static gboolean device_scan_trigger(gpointer user_data)
76 struct connman_device *device = user_data;
78 DBG("device %p", device);
80 if (device->driver == NULL) {
81 device->scan_timeout = 0;
85 if (device->driver->scan)
86 device->driver->scan(device);
91 static void clear_scan_trigger(struct connman_device *device)
93 if (device->scan_timeout > 0) {
94 g_source_remove(device->scan_timeout);
95 device->scan_timeout = 0;
99 static void clear_pending_trigger(struct connman_device *device)
101 if (device->pending_timeout > 0) {
102 g_source_remove(device->pending_timeout);
103 device->pending_timeout = 0;
107 static void reset_scan_trigger(struct connman_device *device)
109 clear_scan_trigger(device);
111 if (device->scan_interval > 0) {
114 if (g_hash_table_size(device->networks) == 0) {
115 if (device->backoff_interval >= device->scan_interval)
116 device->backoff_interval = SCAN_INITIAL_DELAY;
117 interval = device->backoff_interval;
119 interval = device->scan_interval;
121 DBG("interval %d", interval);
123 device->scan_timeout = g_timeout_add_seconds(interval,
124 device_scan_trigger, device);
126 device->backoff_interval *= 2;
127 if (device->backoff_interval > device->scan_interval)
128 device->backoff_interval = device->scan_interval;
132 static void force_scan_trigger(struct connman_device *device)
134 clear_scan_trigger(device);
136 device->scan_timeout = g_timeout_add_seconds(5,
137 device_scan_trigger, device);
140 void connman_device_schedule_scan(struct connman_device *device)
142 reset_scan_trigger(device);
145 static const char *type2description(enum connman_device_type type)
148 case CONNMAN_DEVICE_TYPE_UNKNOWN:
149 case CONNMAN_DEVICE_TYPE_VENDOR:
151 case CONNMAN_DEVICE_TYPE_ETHERNET:
153 case CONNMAN_DEVICE_TYPE_WIFI:
155 case CONNMAN_DEVICE_TYPE_WIMAX:
157 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
159 case CONNMAN_DEVICE_TYPE_GPS:
161 case CONNMAN_DEVICE_TYPE_CELLULAR:
163 case CONNMAN_DEVICE_TYPE_GADGET:
171 static const char *type2string(enum connman_device_type type)
174 case CONNMAN_DEVICE_TYPE_UNKNOWN:
175 case CONNMAN_DEVICE_TYPE_VENDOR:
177 case CONNMAN_DEVICE_TYPE_ETHERNET:
179 case CONNMAN_DEVICE_TYPE_WIFI:
181 case CONNMAN_DEVICE_TYPE_WIMAX:
183 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
185 case CONNMAN_DEVICE_TYPE_GPS:
187 case CONNMAN_DEVICE_TYPE_CELLULAR:
189 case CONNMAN_DEVICE_TYPE_GADGET:
197 enum connman_service_type __connman_device_get_service_type(struct connman_device *device)
199 enum connman_device_type type = connman_device_get_type(device);
202 case CONNMAN_DEVICE_TYPE_UNKNOWN:
203 case CONNMAN_DEVICE_TYPE_VENDOR:
204 case CONNMAN_DEVICE_TYPE_GPS:
206 case CONNMAN_DEVICE_TYPE_ETHERNET:
207 return CONNMAN_SERVICE_TYPE_ETHERNET;
208 case CONNMAN_DEVICE_TYPE_WIFI:
209 return CONNMAN_SERVICE_TYPE_WIFI;
210 case CONNMAN_DEVICE_TYPE_WIMAX:
211 return CONNMAN_SERVICE_TYPE_WIMAX;
212 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
213 return CONNMAN_SERVICE_TYPE_BLUETOOTH;
214 case CONNMAN_DEVICE_TYPE_CELLULAR:
215 return CONNMAN_SERVICE_TYPE_CELLULAR;
216 case CONNMAN_DEVICE_TYPE_GADGET:
217 return CONNMAN_SERVICE_TYPE_GADGET;
221 return CONNMAN_SERVICE_TYPE_UNKNOWN;
224 static gboolean device_pending_reset(gpointer user_data)
226 struct connman_device *device = user_data;
228 DBG("device %p", device);
230 /* Power request timedout, reset power pending state. */
231 device->pending_timeout = 0;
232 device->powered_pending = PENDING_NONE;
237 int __connman_device_enable(struct connman_device *device)
241 DBG("device %p", device);
243 if (!device->driver || !device->driver->enable)
246 /* There is an ongoing power disable request. */
247 if (device->powered_pending == PENDING_DISABLE)
250 if (device->powered_pending == PENDING_ENABLE)
253 if (device->powered_pending == PENDING_NONE && device->powered == TRUE)
256 device->powered_pending = PENDING_ENABLE;
258 err = device->driver->enable(device);
260 * device gets enabled right away.
261 * Invoke the callback
264 connman_device_set_powered(device, TRUE);
268 if (err == -EALREADY) {
269 /* If device is already powered, but connman is not updated */
270 connman_device_set_powered(device, TRUE);
274 * if err == -EINPROGRESS, then the DBus call to the respective daemon
275 * was successful. We set a 4 sec timeout so if the daemon never
276 * returns a reply, we would reset the pending request.
278 if (err == -EINPROGRESS)
279 device->pending_timeout = g_timeout_add_seconds(4,
280 device_pending_reset, device);
285 int __connman_device_disable(struct connman_device *device)
289 DBG("device %p", device);
291 if (!device->driver || !device->driver->disable)
294 /* Ongoing power enable request */
295 if (device->powered_pending == PENDING_ENABLE)
298 if (device->powered_pending == PENDING_DISABLE)
301 if (device->powered_pending == PENDING_NONE && device->powered == FALSE)
304 device->powered_pending = PENDING_DISABLE;
305 device->reconnect = FALSE;
307 clear_scan_trigger(device);
309 if (device->network) {
310 struct connman_service *service =
311 __connman_service_lookup_from_network(device->network);
314 __connman_service_disconnect(service);
316 connman_network_set_connected(device->network, FALSE);
319 err = device->driver->disable(device);
321 connman_device_set_powered(device, FALSE);
325 if (err == -EALREADY) {
326 connman_device_set_powered(device, FALSE);
330 if (err == -EINPROGRESS)
331 device->pending_timeout = g_timeout_add_seconds(4,
332 device_pending_reset, device);
337 static void probe_driver(struct connman_device_driver *driver)
341 DBG("driver %p name %s", driver, driver->name);
343 for (list = device_list; list != NULL; list = list->next) {
344 struct connman_device *device = list->data;
346 if (device->driver != NULL)
349 if (driver->type != device->type)
352 if (driver->probe(device) < 0)
355 device->driver = driver;
357 __connman_technology_add_device(device);
361 static void remove_device(struct connman_device *device)
363 DBG("device %p", device);
365 __connman_device_disable(device);
367 __connman_technology_remove_device(device);
369 if (device->driver->remove)
370 device->driver->remove(device);
372 device->driver = NULL;
375 static void remove_driver(struct connman_device_driver *driver)
379 DBG("driver %p name %s", driver, driver->name);
381 for (list = device_list; list != NULL; list = list->next) {
382 struct connman_device *device = list->data;
384 if (device->driver == driver)
385 remove_device(device);
389 connman_bool_t __connman_device_has_driver(struct connman_device *device)
391 if (device == NULL || device->driver == NULL)
397 static GSList *driver_list = NULL;
399 static gint compare_priority(gconstpointer a, gconstpointer b)
401 const struct connman_device_driver *driver1 = a;
402 const struct connman_device_driver *driver2 = b;
404 return driver2->priority - driver1->priority;
408 * connman_device_driver_register:
409 * @driver: device driver definition
411 * Register a new device driver
413 * Returns: %0 on success
415 int connman_device_driver_register(struct connman_device_driver *driver)
417 DBG("driver %p name %s", driver, driver->name);
419 driver_list = g_slist_insert_sorted(driver_list, driver,
421 probe_driver(driver);
427 * connman_device_driver_unregister:
428 * @driver: device driver definition
430 * Remove a previously registered device driver
432 void connman_device_driver_unregister(struct connman_device_driver *driver)
434 DBG("driver %p name %s", driver, driver->name);
436 driver_list = g_slist_remove(driver_list, driver);
438 remove_driver(driver);
441 static void free_network(gpointer data)
443 struct connman_network *network = data;
445 DBG("network %p", network);
447 __connman_network_set_device(network, NULL);
449 connman_network_unref(network);
452 static void device_destruct(struct connman_device *device)
454 DBG("device %p name %s", device, device->name);
456 clear_pending_trigger(device);
457 clear_scan_trigger(device);
459 g_free(device->ident);
460 g_free(device->node);
461 g_free(device->name);
462 g_free(device->address);
463 g_free(device->interface);
464 g_free(device->path);
465 g_free(device->devname);
467 g_free(device->last_network);
469 g_hash_table_destroy(device->networks);
470 device->networks = NULL;
476 * connman_device_create:
477 * @node: device node name (for example an address)
480 * Allocate a new device of given #type and assign the #node name to it.
482 * Returns: a newly-allocated #connman_device structure
484 struct connman_device *connman_device_create(const char *node,
485 enum connman_device_type type)
487 struct connman_device *device;
488 connman_bool_t bg_scan;
490 DBG("node %s type %d", node, type);
492 device = g_try_new0(struct connman_device, 1);
496 DBG("device %p", device);
498 device->refcount = 1;
500 bg_scan = connman_setting_get_bool("BackgroundScanning");
503 device->name = g_strdup(type2description(device->type));
505 device->phyindex = -1;
507 device->backoff_interval = SCAN_INITIAL_DELAY;
510 case CONNMAN_DEVICE_TYPE_UNKNOWN:
511 case CONNMAN_DEVICE_TYPE_ETHERNET:
512 case CONNMAN_DEVICE_TYPE_WIMAX:
513 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
514 case CONNMAN_DEVICE_TYPE_CELLULAR:
515 case CONNMAN_DEVICE_TYPE_GPS:
516 case CONNMAN_DEVICE_TYPE_GADGET:
517 case CONNMAN_DEVICE_TYPE_VENDOR:
518 device->scan_interval = 0;
520 case CONNMAN_DEVICE_TYPE_WIFI:
522 device->scan_interval = 300;
524 device->scan_interval = 0;
528 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
529 g_free, free_network);
531 device_list = g_slist_append(device_list, device);
537 * connman_device_ref:
538 * @device: device structure
540 * Increase reference counter of device
542 struct connman_device *connman_device_ref_debug(struct connman_device *device,
543 const char *file, int line, const char *caller)
545 DBG("%p ref %d by %s:%d:%s()", device, device->refcount + 1,
548 __sync_fetch_and_add(&device->refcount, 1);
554 * connman_device_unref:
555 * @device: device structure
557 * Decrease reference counter of device
559 void connman_device_unref_debug(struct connman_device *device,
560 const char *file, int line, const char *caller)
562 DBG("%p ref %d by %s:%d:%s()", device, device->refcount - 1,
565 if (__sync_fetch_and_sub(&device->refcount, 1) != 1)
568 if (device->driver) {
569 device->driver->remove(device);
570 device->driver = NULL;
573 device_list = g_slist_remove(device_list, device);
575 device_destruct(device);
578 const char *__connman_device_get_type(struct connman_device *device)
580 return type2string(device->type);
584 * connman_device_get_type:
585 * @device: device structure
589 enum connman_device_type connman_device_get_type(struct connman_device *device)
595 * connman_device_set_index:
596 * @device: device structure
597 * @index: index number
599 * Set index number of device
601 void connman_device_set_index(struct connman_device *device, int index)
603 device->index = index;
607 * connman_device_get_index:
608 * @device: device structure
610 * Get index number of device
612 int connman_device_get_index(struct connman_device *device)
614 return device->index;
617 int __connman_device_get_phyindex(struct connman_device *device)
619 return device->phyindex;
622 void __connman_device_set_phyindex(struct connman_device *device,
625 device->phyindex = phyindex;
629 * connman_device_set_interface:
630 * @device: device structure
631 * @interface: interface name
633 * Set interface name of device
635 void connman_device_set_interface(struct connman_device *device,
636 const char *interface)
638 g_free(device->devname);
639 device->devname = g_strdup(interface);
641 g_free(device->interface);
642 device->interface = g_strdup(interface);
644 if (device->name == NULL) {
645 const char *str = type2description(device->type);
646 if (str != NULL && device->interface != NULL)
647 device->name = g_strdup_printf("%s (%s)", str,
653 * connman_device_set_ident:
654 * @device: device structure
655 * @ident: unique identifier
657 * Set unique identifier of device
659 void connman_device_set_ident(struct connman_device *device,
662 g_free(device->ident);
663 device->ident = g_strdup(ident);
666 const char *connman_device_get_ident(struct connman_device *device)
668 return device->ident;
672 * connman_device_set_powered:
673 * @device: device structure
674 * @powered: powered state
676 * Change power state of device
678 int connman_device_set_powered(struct connman_device *device,
679 connman_bool_t powered)
681 enum connman_service_type type;
683 DBG("driver %p powered %d", device, powered);
685 if (device->powered == powered)
688 clear_pending_trigger(device);
690 device->powered_pending = PENDING_NONE;
692 device->powered = powered;
694 type = __connman_device_get_service_type(device);
696 if (device->powered == TRUE)
697 __connman_technology_enabled(type);
699 __connman_technology_disabled(type);
701 if (powered == FALSE)
704 connman_device_set_disconnected(device, FALSE);
705 device->scanning = FALSE;
707 reset_scan_trigger(device);
709 if (device->driver && device->driver->scan_fast)
710 device->driver->scan_fast(device);
711 else if (device->driver && device->driver->scan)
712 device->driver->scan(device);
717 static int device_scan(struct connman_device *device)
719 if (!device->driver || !device->driver->scan)
722 if (device->powered == FALSE)
725 reset_scan_trigger(device);
727 return device->driver->scan(device);
730 int __connman_device_disconnect(struct connman_device *device)
735 DBG("device %p", device);
737 connman_device_set_disconnected(device, TRUE);
739 g_hash_table_iter_init(&iter, device->networks);
741 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
742 struct connman_network *network = value;
744 if (connman_network_get_connecting(network) == TRUE) {
746 * Skip network in the process of connecting.
747 * This is a workaround for WiFi networks serviced
748 * by the supplicant plugin that hold a reference
749 * to the network. If we disconnect the network
750 * here then the referenced object will not be
751 * registered and usage (like launching DHCP client)
752 * will fail. There is nothing to be gained by
753 * removing the network here anyway.
755 connman_warn("Skipping disconnect of %s, network is connecting.",
756 connman_network_get_identifier(network));
760 __connman_network_disconnect(network);
766 static void mark_network_available(gpointer key, gpointer value,
769 struct connman_network *network = value;
771 connman_network_set_available(network, TRUE);
774 static void mark_network_unavailable(gpointer key, gpointer value,
777 struct connman_network *network = value;
779 if (connman_network_get_connected(network) == TRUE)
782 connman_network_set_available(network, FALSE);
785 static gboolean remove_unavailable_network(gpointer key, gpointer value,
788 struct connman_network *network = value;
790 if (connman_network_get_connected(network) == TRUE)
793 if (connman_network_get_available(network) == TRUE)
799 void __connman_device_cleanup_networks(struct connman_device *device)
801 g_hash_table_foreach_remove(device->networks,
802 remove_unavailable_network, NULL);
805 connman_bool_t __connman_device_scanning(struct connman_device *device)
807 return device->scanning;
810 void connman_device_reset_scanning(struct connman_device *device)
812 device->scanning = FALSE;
814 g_hash_table_foreach(device->networks,
815 mark_network_available, NULL);
820 * connman_device_set_scanning:
821 * @device: device structure
822 * @scanning: scanning state
824 * Change scanning state of device
826 int connman_device_set_scanning(struct connman_device *device,
827 connman_bool_t scanning)
829 DBG("device %p scanning %d", device, scanning);
831 if (!device->driver || !device->driver->scan)
834 if (device->scanning == scanning)
837 device->scanning = scanning;
839 if (scanning == TRUE) {
840 __connman_technology_scan_started(device);
842 reset_scan_trigger(device);
844 g_hash_table_foreach(device->networks,
845 mark_network_unavailable, NULL);
850 __connman_device_cleanup_networks(device);
852 __connman_technology_scan_stopped(device);
854 __connman_service_auto_connect();
860 * connman_device_set_disconnected:
861 * @device: device structure
862 * @disconnected: disconnected state
864 * Change disconnected state of device (only for device with networks)
866 int connman_device_set_disconnected(struct connman_device *device,
867 connman_bool_t disconnected)
869 DBG("device %p disconnected %d", device, disconnected);
871 if (device->disconnected == disconnected)
874 device->disconnected = disconnected;
876 if (disconnected == TRUE)
878 force_scan_trigger(device);
879 device->backoff_interval = SCAN_INITIAL_DELAY;
886 * connman_device_get_disconnected:
887 * @device: device structure
889 * Get device disconnected state
891 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
893 return device->disconnected;
897 * connman_device_set_string:
898 * @device: device structure
899 * @key: unique identifier
900 * @value: string value
902 * Set string value for specific key
904 int connman_device_set_string(struct connman_device *device,
905 const char *key, const char *value)
907 DBG("device %p key %s value %s", device, key, value);
909 if (g_str_equal(key, "Address") == TRUE) {
910 g_free(device->address);
911 device->address = g_strdup(value);
912 } else if (g_str_equal(key, "Name") == TRUE) {
913 g_free(device->name);
914 device->name = g_strdup(value);
915 } else if (g_str_equal(key, "Node") == TRUE) {
916 g_free(device->node);
917 device->node = g_strdup(value);
918 } else if (g_str_equal(key, "Path") == TRUE) {
919 g_free(device->path);
920 device->path = g_strdup(value);
929 * connman_device_get_string:
930 * @device: device structure
931 * @key: unique identifier
933 * Get string value for specific key
935 const char *connman_device_get_string(struct connman_device *device,
938 DBG("device %p key %s", device, key);
940 if (g_str_equal(key, "Address") == TRUE)
941 return device->address;
942 else if (g_str_equal(key, "Name") == TRUE)
944 else if (g_str_equal(key, "Node") == TRUE)
946 else if (g_str_equal(key, "Interface") == TRUE)
947 return device->interface;
948 else if (g_str_equal(key, "Path") == TRUE)
955 * connman_device_add_network:
956 * @device: device structure
957 * @network: network structure
959 * Add new network to the device
961 int connman_device_add_network(struct connman_device *device,
962 struct connman_network *network)
964 const char *identifier = connman_network_get_identifier(network);
966 DBG("device %p network %p", device, network);
968 if (identifier == NULL)
971 connman_network_ref(network);
973 __connman_network_set_device(network, device);
975 g_hash_table_insert(device->networks, g_strdup(identifier),
982 * connman_device_get_network:
983 * @device: device structure
984 * @identifier: network identifier
986 * Get network for given identifier
988 struct connman_network *connman_device_get_network(struct connman_device *device,
989 const char *identifier)
991 DBG("device %p identifier %s", device, identifier);
993 return g_hash_table_lookup(device->networks, identifier);
997 * connman_device_remove_network:
998 * @device: device structure
999 * @identifier: network identifier
1001 * Remove network for given identifier
1003 int connman_device_remove_network(struct connman_device *device,
1004 struct connman_network *network)
1006 const char *identifier;
1008 DBG("device %p network %p", device, network);
1010 if (network == NULL)
1013 identifier = connman_network_get_identifier(network);
1014 g_hash_table_remove(device->networks, identifier);
1019 void connman_device_remove_all_networks(struct connman_device *device)
1021 g_hash_table_remove_all(device->networks);
1024 void __connman_device_set_network(struct connman_device *device,
1025 struct connman_network *network)
1032 if (device->network == network)
1035 if (network != NULL) {
1036 name = connman_network_get_string(network, "Name");
1037 g_free(device->last_network);
1038 device->last_network = g_strdup(name);
1040 device->network = network;
1042 g_free(device->last_network);
1043 device->last_network = NULL;
1045 device->network = NULL;
1049 void __connman_device_set_reconnect(struct connman_device *device,
1050 connman_bool_t reconnect)
1052 device->reconnect = reconnect;
1055 connman_bool_t __connman_device_get_reconnect(
1056 struct connman_device *device)
1058 return device->reconnect;
1061 static gboolean match_driver(struct connman_device *device,
1062 struct connman_device_driver *driver)
1064 if (device->type == driver->type ||
1065 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1072 * connman_device_register:
1073 * @device: device structure
1075 * Register device with the system
1077 int connman_device_register(struct connman_device *device)
1081 DBG("device %p name %s", device, device->name);
1083 if (device->driver != NULL)
1086 for (list = driver_list; list; list = list->next) {
1087 struct connman_device_driver *driver = list->data;
1089 if (match_driver(device, driver) == FALSE)
1092 DBG("driver %p name %s", driver, driver->name);
1094 if (driver->probe(device) == 0) {
1095 device->driver = driver;
1100 if (device->driver == NULL)
1103 return __connman_technology_add_device(device);
1107 * connman_device_unregister:
1108 * @device: device structure
1110 * Unregister device with the system
1112 void connman_device_unregister(struct connman_device *device)
1114 DBG("device %p name %s", device, device->name);
1116 if (device->driver == NULL)
1119 remove_device(device);
1123 * connman_device_get_data:
1124 * @device: device structure
1126 * Get private device data pointer
1128 void *connman_device_get_data(struct connman_device *device)
1130 return device->driver_data;
1134 * connman_device_set_data:
1135 * @device: device structure
1136 * @data: data pointer
1138 * Set private device data pointer
1140 void connman_device_set_data(struct connman_device *device, void *data)
1142 device->driver_data = data;
1145 struct connman_device *__connman_device_find_device(
1146 enum connman_service_type type)
1150 for (list = device_list; list != NULL; list = list->next) {
1151 struct connman_device *device = list->data;
1152 enum connman_service_type service_type =
1153 __connman_device_get_service_type(device);
1155 if (service_type != type)
1164 int __connman_device_request_scan(enum connman_service_type type)
1166 connman_bool_t success = FALSE;
1167 int last_err = -ENOSYS;
1172 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1173 case CONNMAN_SERVICE_TYPE_SYSTEM:
1174 case CONNMAN_SERVICE_TYPE_ETHERNET:
1175 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1176 case CONNMAN_SERVICE_TYPE_CELLULAR:
1177 case CONNMAN_SERVICE_TYPE_GPS:
1178 case CONNMAN_SERVICE_TYPE_VPN:
1179 case CONNMAN_SERVICE_TYPE_GADGET:
1181 case CONNMAN_SERVICE_TYPE_WIFI:
1182 case CONNMAN_SERVICE_TYPE_WIMAX:
1186 for (list = device_list; list != NULL; list = list->next) {
1187 struct connman_device *device = list->data;
1188 enum connman_service_type service_type =
1189 __connman_device_get_service_type(device);
1191 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1192 service_type != type) {
1196 err = device_scan(device);
1197 if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
1201 DBG("device %p err %d", device, err);
1205 if (success == TRUE)
1211 int __connman_device_request_hidden_scan(struct connman_device *device,
1212 const char *ssid, unsigned int ssid_len,
1213 const char *identity, const char *passphrase)
1215 DBG("device %p", device);
1217 if (device == NULL || device->driver == NULL ||
1218 device->driver->scan_hidden == NULL)
1221 if (device->scanning == TRUE)
1224 return device->driver->scan_hidden(device, ssid, ssid_len,
1225 identity, passphrase);
1228 connman_bool_t __connman_device_isfiltered(const char *devname)
1232 if (device_filter == NULL)
1235 for (pattern = device_filter; *pattern; pattern++) {
1236 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1237 DBG("ignoring device %s (match)", devname);
1243 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1244 DBG("ignoring dummy networking devices");
1248 if (nodevice_filter == NULL)
1251 for (pattern = nodevice_filter; *pattern; pattern++) {
1252 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1253 DBG("ignoring device %s (no match)", devname);
1261 int __connman_device_init(const char *device, const char *nodevice)
1266 device_filter = g_strsplit(device, ",", -1);
1268 if (nodevice != NULL)
1269 nodevice_filter = g_strsplit(nodevice, ",", -1);
1274 void __connman_device_cleanup(void)
1278 g_strfreev(nodevice_filter);
1279 g_strfreev(device_filter);