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 static const char *type2description(enum connman_device_type type)
143 case CONNMAN_DEVICE_TYPE_UNKNOWN:
144 case CONNMAN_DEVICE_TYPE_VENDOR:
146 case CONNMAN_DEVICE_TYPE_ETHERNET:
148 case CONNMAN_DEVICE_TYPE_WIFI:
150 case CONNMAN_DEVICE_TYPE_WIMAX:
152 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
154 case CONNMAN_DEVICE_TYPE_GPS:
156 case CONNMAN_DEVICE_TYPE_CELLULAR:
158 case CONNMAN_DEVICE_TYPE_GADGET:
166 static const char *type2string(enum connman_device_type type)
169 case CONNMAN_DEVICE_TYPE_UNKNOWN:
170 case CONNMAN_DEVICE_TYPE_VENDOR:
172 case CONNMAN_DEVICE_TYPE_ETHERNET:
174 case CONNMAN_DEVICE_TYPE_WIFI:
176 case CONNMAN_DEVICE_TYPE_WIMAX:
178 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
180 case CONNMAN_DEVICE_TYPE_GPS:
182 case CONNMAN_DEVICE_TYPE_CELLULAR:
184 case CONNMAN_DEVICE_TYPE_GADGET:
192 enum connman_service_type __connman_device_get_service_type(struct connman_device *device)
194 enum connman_device_type type = connman_device_get_type(device);
197 case CONNMAN_DEVICE_TYPE_UNKNOWN:
198 case CONNMAN_DEVICE_TYPE_VENDOR:
199 case CONNMAN_DEVICE_TYPE_GPS:
201 case CONNMAN_DEVICE_TYPE_ETHERNET:
202 return CONNMAN_SERVICE_TYPE_ETHERNET;
203 case CONNMAN_DEVICE_TYPE_WIFI:
204 return CONNMAN_SERVICE_TYPE_WIFI;
205 case CONNMAN_DEVICE_TYPE_WIMAX:
206 return CONNMAN_SERVICE_TYPE_WIMAX;
207 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
208 return CONNMAN_SERVICE_TYPE_BLUETOOTH;
209 case CONNMAN_DEVICE_TYPE_CELLULAR:
210 return CONNMAN_SERVICE_TYPE_CELLULAR;
211 case CONNMAN_DEVICE_TYPE_GADGET:
212 return CONNMAN_SERVICE_TYPE_GADGET;
216 return CONNMAN_SERVICE_TYPE_UNKNOWN;
219 static gboolean device_pending_reset(gpointer user_data)
221 struct connman_device *device = user_data;
223 DBG("device %p", device);
225 /* Power request timedout, reset power pending state. */
226 device->pending_timeout = 0;
227 device->powered_pending = PENDING_NONE;
232 int __connman_device_enable(struct connman_device *device)
236 DBG("device %p", device);
238 if (!device->driver || !device->driver->enable)
241 /* There is an ongoing power disable request. */
242 if (device->powered_pending == PENDING_DISABLE)
245 if (device->powered_pending == PENDING_ENABLE)
248 if (device->powered_pending == PENDING_NONE && device->powered == TRUE)
251 device->powered_pending = PENDING_ENABLE;
253 err = device->driver->enable(device);
255 * device gets enabled right away.
256 * Invoke the callback
259 connman_device_set_powered(device, TRUE);
263 if (err == -EALREADY) {
264 /* If device is already powered, but connman is not updated */
265 connman_device_set_powered(device, TRUE);
269 * if err == -EINPROGRESS, then the DBus call to the respective daemon
270 * was successful. We set a 4 sec timeout so if the daemon never
271 * returns a reply, we would reset the pending request.
273 if (err == -EINPROGRESS)
274 device->pending_timeout = g_timeout_add_seconds(4,
275 device_pending_reset, device);
280 int __connman_device_disable(struct connman_device *device)
284 DBG("device %p", device);
286 if (!device->driver || !device->driver->disable)
289 /* Ongoing power enable request */
290 if (device->powered_pending == PENDING_ENABLE)
293 if (device->powered_pending == PENDING_DISABLE)
296 if (device->powered_pending == PENDING_NONE && device->powered == FALSE)
299 device->powered_pending = PENDING_DISABLE;
300 device->reconnect = FALSE;
302 clear_scan_trigger(device);
304 if (device->network) {
305 struct connman_service *service =
306 __connman_service_lookup_from_network(device->network);
309 __connman_service_disconnect(service);
311 connman_network_set_connected(device->network, FALSE);
314 err = device->driver->disable(device);
316 connman_device_set_powered(device, FALSE);
320 if (err == -EALREADY) {
321 connman_device_set_powered(device, FALSE);
325 if (err == -EINPROGRESS)
326 device->pending_timeout = g_timeout_add_seconds(4,
327 device_pending_reset, device);
332 static void probe_driver(struct connman_device_driver *driver)
336 DBG("driver %p name %s", driver, driver->name);
338 for (list = device_list; list != NULL; list = list->next) {
339 struct connman_device *device = list->data;
341 if (device->driver != NULL)
344 if (driver->type != device->type)
347 if (driver->probe(device) < 0)
350 device->driver = driver;
352 __connman_technology_add_device(device);
356 static void remove_device(struct connman_device *device)
358 DBG("device %p", device);
360 __connman_device_disable(device);
362 __connman_technology_remove_device(device);
364 if (device->driver->remove)
365 device->driver->remove(device);
367 device->driver = NULL;
370 static void remove_driver(struct connman_device_driver *driver)
374 DBG("driver %p name %s", driver, driver->name);
376 for (list = device_list; list != NULL; list = list->next) {
377 struct connman_device *device = list->data;
379 if (device->driver == driver)
380 remove_device(device);
384 connman_bool_t __connman_device_has_driver(struct connman_device *device)
386 if (device == NULL || device->driver == NULL)
392 static GSList *driver_list = NULL;
394 static gint compare_priority(gconstpointer a, gconstpointer b)
396 const struct connman_device_driver *driver1 = a;
397 const struct connman_device_driver *driver2 = b;
399 return driver2->priority - driver1->priority;
403 * connman_device_driver_register:
404 * @driver: device driver definition
406 * Register a new device driver
408 * Returns: %0 on success
410 int connman_device_driver_register(struct connman_device_driver *driver)
412 DBG("driver %p name %s", driver, driver->name);
414 driver_list = g_slist_insert_sorted(driver_list, driver,
416 probe_driver(driver);
422 * connman_device_driver_unregister:
423 * @driver: device driver definition
425 * Remove a previously registered device driver
427 void connman_device_driver_unregister(struct connman_device_driver *driver)
429 DBG("driver %p name %s", driver, driver->name);
431 driver_list = g_slist_remove(driver_list, driver);
433 remove_driver(driver);
436 static void free_network(gpointer data)
438 struct connman_network *network = data;
440 DBG("network %p", network);
442 __connman_network_set_device(network, NULL);
444 connman_network_unref(network);
447 static void device_destruct(struct connman_device *device)
449 DBG("device %p name %s", device, device->name);
451 clear_pending_trigger(device);
452 clear_scan_trigger(device);
454 g_free(device->ident);
455 g_free(device->node);
456 g_free(device->name);
457 g_free(device->address);
458 g_free(device->interface);
459 g_free(device->path);
460 g_free(device->devname);
462 g_free(device->last_network);
464 g_hash_table_destroy(device->networks);
465 device->networks = NULL;
471 * connman_device_create:
472 * @node: device node name (for example an address)
475 * Allocate a new device of given #type and assign the #node name to it.
477 * Returns: a newly-allocated #connman_device structure
479 struct connman_device *connman_device_create(const char *node,
480 enum connman_device_type type)
482 struct connman_device *device;
483 connman_bool_t bg_scan;
485 DBG("node %s type %d", node, type);
487 device = g_try_new0(struct connman_device, 1);
491 DBG("device %p", device);
493 device->refcount = 1;
495 bg_scan = connman_setting_get_bool("BackgroundScanning");
498 device->name = g_strdup(type2description(device->type));
500 device->phyindex = -1;
502 device->backoff_interval = SCAN_INITIAL_DELAY;
505 case CONNMAN_DEVICE_TYPE_UNKNOWN:
506 case CONNMAN_DEVICE_TYPE_ETHERNET:
507 case CONNMAN_DEVICE_TYPE_WIMAX:
508 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
509 case CONNMAN_DEVICE_TYPE_CELLULAR:
510 case CONNMAN_DEVICE_TYPE_GPS:
511 case CONNMAN_DEVICE_TYPE_GADGET:
512 case CONNMAN_DEVICE_TYPE_VENDOR:
513 device->scan_interval = 0;
515 case CONNMAN_DEVICE_TYPE_WIFI:
517 device->scan_interval = 300;
519 device->scan_interval = 0;
523 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
524 g_free, free_network);
526 device_list = g_slist_append(device_list, device);
532 * connman_device_ref:
533 * @device: device structure
535 * Increase reference counter of device
537 struct connman_device *connman_device_ref_debug(struct connman_device *device,
538 const char *file, int line, const char *caller)
540 DBG("%p ref %d by %s:%d:%s()", device, device->refcount + 1,
543 __sync_fetch_and_add(&device->refcount, 1);
549 * connman_device_unref:
550 * @device: device structure
552 * Decrease reference counter of device
554 void connman_device_unref_debug(struct connman_device *device,
555 const char *file, int line, const char *caller)
557 DBG("%p ref %d by %s:%d:%s()", device, device->refcount - 1,
560 if (__sync_fetch_and_sub(&device->refcount, 1) != 1)
563 if (device->driver) {
564 device->driver->remove(device);
565 device->driver = NULL;
568 device_list = g_slist_remove(device_list, device);
570 device_destruct(device);
573 const char *__connman_device_get_type(struct connman_device *device)
575 return type2string(device->type);
579 * connman_device_get_type:
580 * @device: device structure
584 enum connman_device_type connman_device_get_type(struct connman_device *device)
590 * connman_device_set_index:
591 * @device: device structure
592 * @index: index number
594 * Set index number of device
596 void connman_device_set_index(struct connman_device *device, int index)
598 device->index = index;
602 * connman_device_get_index:
603 * @device: device structure
605 * Get index number of device
607 int connman_device_get_index(struct connman_device *device)
609 return device->index;
612 int __connman_device_get_phyindex(struct connman_device *device)
614 return device->phyindex;
617 void __connman_device_set_phyindex(struct connman_device *device,
620 device->phyindex = phyindex;
624 * connman_device_set_interface:
625 * @device: device structure
626 * @interface: interface name
628 * Set interface name of device
630 void connman_device_set_interface(struct connman_device *device,
631 const char *interface)
633 g_free(device->devname);
634 device->devname = g_strdup(interface);
636 g_free(device->interface);
637 device->interface = g_strdup(interface);
639 if (device->name == NULL) {
640 const char *str = type2description(device->type);
641 if (str != NULL && device->interface != NULL)
642 device->name = g_strdup_printf("%s (%s)", str,
648 * connman_device_set_ident:
649 * @device: device structure
650 * @ident: unique identifier
652 * Set unique identifier of device
654 void connman_device_set_ident(struct connman_device *device,
657 g_free(device->ident);
658 device->ident = g_strdup(ident);
661 const char *connman_device_get_ident(struct connman_device *device)
663 return device->ident;
667 * connman_device_set_powered:
668 * @device: device structure
669 * @powered: powered state
671 * Change power state of device
673 int connman_device_set_powered(struct connman_device *device,
674 connman_bool_t powered)
676 enum connman_service_type type;
678 DBG("driver %p powered %d", device, powered);
680 if (device->powered == powered)
683 clear_pending_trigger(device);
685 device->powered_pending = PENDING_NONE;
687 device->powered = powered;
689 type = __connman_device_get_service_type(device);
691 if (device->powered == TRUE)
692 __connman_technology_enabled(type);
694 __connman_technology_disabled(type);
696 if (powered == FALSE)
699 connman_device_set_disconnected(device, FALSE);
700 device->scanning = FALSE;
702 reset_scan_trigger(device);
704 if (device->driver && device->driver->scan_fast)
705 device->driver->scan_fast(device);
706 else if (device->driver && device->driver->scan)
707 device->driver->scan(device);
712 static int device_scan(struct connman_device *device)
714 if (!device->driver || !device->driver->scan)
717 if (device->powered == FALSE)
720 reset_scan_trigger(device);
722 return device->driver->scan(device);
725 int __connman_device_disconnect(struct connman_device *device)
730 DBG("device %p", device);
732 connman_device_set_disconnected(device, TRUE);
734 g_hash_table_iter_init(&iter, device->networks);
736 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
737 struct connman_network *network = value;
739 if (connman_network_get_connecting(network) == TRUE) {
741 * Skip network in the process of connecting.
742 * This is a workaround for WiFi networks serviced
743 * by the supplicant plugin that hold a reference
744 * to the network. If we disconnect the network
745 * here then the referenced object will not be
746 * registered and usage (like launching DHCP client)
747 * will fail. There is nothing to be gained by
748 * removing the network here anyway.
750 connman_warn("Skipping disconnect of %s, network is connecting.",
751 connman_network_get_identifier(network));
755 __connman_network_disconnect(network);
761 static void mark_network_available(gpointer key, gpointer value,
764 struct connman_network *network = value;
766 connman_network_set_available(network, TRUE);
769 static void mark_network_unavailable(gpointer key, gpointer value,
772 struct connman_network *network = value;
774 if (connman_network_get_connected(network) == TRUE)
777 connman_network_set_available(network, FALSE);
780 static gboolean remove_unavailable_network(gpointer key, gpointer value,
783 struct connman_network *network = value;
785 if (connman_network_get_connected(network) == TRUE)
788 if (connman_network_get_available(network) == TRUE)
794 void __connman_device_cleanup_networks(struct connman_device *device)
796 g_hash_table_foreach_remove(device->networks,
797 remove_unavailable_network, NULL);
800 connman_bool_t __connman_device_scanning(struct connman_device *device)
802 return device->scanning;
805 void connman_device_reset_scanning(struct connman_device *device)
807 device->scanning = FALSE;
809 g_hash_table_foreach(device->networks,
810 mark_network_available, NULL);
815 * connman_device_set_scanning:
816 * @device: device structure
817 * @scanning: scanning state
819 * Change scanning state of device
821 int connman_device_set_scanning(struct connman_device *device,
822 connman_bool_t scanning)
824 DBG("device %p scanning %d", device, scanning);
826 if (!device->driver || !device->driver->scan)
829 if (device->scanning == scanning)
832 device->scanning = scanning;
834 if (scanning == TRUE) {
835 __connman_technology_scan_started(device);
837 reset_scan_trigger(device);
839 g_hash_table_foreach(device->networks,
840 mark_network_unavailable, NULL);
845 __connman_device_cleanup_networks(device);
847 __connman_technology_scan_stopped(device);
849 __connman_service_auto_connect();
855 * connman_device_set_disconnected:
856 * @device: device structure
857 * @disconnected: disconnected state
859 * Change disconnected state of device (only for device with networks)
861 int connman_device_set_disconnected(struct connman_device *device,
862 connman_bool_t disconnected)
864 DBG("device %p disconnected %d", device, disconnected);
866 if (device->disconnected == disconnected)
869 device->disconnected = disconnected;
871 if (disconnected == TRUE)
873 force_scan_trigger(device);
874 device->backoff_interval = SCAN_INITIAL_DELAY;
881 * connman_device_get_disconnected:
882 * @device: device structure
884 * Get device disconnected state
886 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
888 return device->disconnected;
892 * connman_device_set_string:
893 * @device: device structure
894 * @key: unique identifier
895 * @value: string value
897 * Set string value for specific key
899 int connman_device_set_string(struct connman_device *device,
900 const char *key, const char *value)
902 DBG("device %p key %s value %s", device, key, value);
904 if (g_str_equal(key, "Address") == TRUE) {
905 g_free(device->address);
906 device->address = g_strdup(value);
907 } else if (g_str_equal(key, "Name") == TRUE) {
908 g_free(device->name);
909 device->name = g_strdup(value);
910 } else if (g_str_equal(key, "Node") == TRUE) {
911 g_free(device->node);
912 device->node = g_strdup(value);
913 } else if (g_str_equal(key, "Path") == TRUE) {
914 g_free(device->path);
915 device->path = g_strdup(value);
924 * connman_device_get_string:
925 * @device: device structure
926 * @key: unique identifier
928 * Get string value for specific key
930 const char *connman_device_get_string(struct connman_device *device,
933 DBG("device %p key %s", device, key);
935 if (g_str_equal(key, "Address") == TRUE)
936 return device->address;
937 else if (g_str_equal(key, "Name") == TRUE)
939 else if (g_str_equal(key, "Node") == TRUE)
941 else if (g_str_equal(key, "Interface") == TRUE)
942 return device->interface;
943 else if (g_str_equal(key, "Path") == TRUE)
950 * connman_device_add_network:
951 * @device: device structure
952 * @network: network structure
954 * Add new network to the device
956 int connman_device_add_network(struct connman_device *device,
957 struct connman_network *network)
959 const char *identifier = connman_network_get_identifier(network);
961 DBG("device %p network %p", device, network);
963 if (identifier == NULL)
966 connman_network_ref(network);
968 __connman_network_set_device(network, device);
970 g_hash_table_replace(device->networks, g_strdup(identifier),
977 * connman_device_get_network:
978 * @device: device structure
979 * @identifier: network identifier
981 * Get network for given identifier
983 struct connman_network *connman_device_get_network(struct connman_device *device,
984 const char *identifier)
986 DBG("device %p identifier %s", device, identifier);
988 return g_hash_table_lookup(device->networks, identifier);
992 * connman_device_remove_network:
993 * @device: device structure
994 * @identifier: network identifier
996 * Remove network for given identifier
998 int connman_device_remove_network(struct connman_device *device,
999 struct connman_network *network)
1001 const char *identifier;
1003 DBG("device %p network %p", device, network);
1005 if (network == NULL)
1008 identifier = connman_network_get_identifier(network);
1009 g_hash_table_remove(device->networks, identifier);
1014 void connman_device_remove_all_networks(struct connman_device *device)
1016 g_hash_table_remove_all(device->networks);
1019 void __connman_device_set_network(struct connman_device *device,
1020 struct connman_network *network)
1027 if (device->network == network)
1030 if (network != NULL) {
1031 name = connman_network_get_string(network, "Name");
1032 g_free(device->last_network);
1033 device->last_network = g_strdup(name);
1035 device->network = network;
1037 g_free(device->last_network);
1038 device->last_network = NULL;
1040 device->network = NULL;
1044 void __connman_device_set_reconnect(struct connman_device *device,
1045 connman_bool_t reconnect)
1047 device->reconnect = reconnect;
1050 connman_bool_t __connman_device_get_reconnect(
1051 struct connman_device *device)
1053 return device->reconnect;
1056 static gboolean match_driver(struct connman_device *device,
1057 struct connman_device_driver *driver)
1059 if (device->type == driver->type ||
1060 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1067 * connman_device_register:
1068 * @device: device structure
1070 * Register device with the system
1072 int connman_device_register(struct connman_device *device)
1076 DBG("device %p name %s", device, device->name);
1078 if (device->driver != NULL)
1081 for (list = driver_list; list; list = list->next) {
1082 struct connman_device_driver *driver = list->data;
1084 if (match_driver(device, driver) == FALSE)
1087 DBG("driver %p name %s", driver, driver->name);
1089 if (driver->probe(device) == 0) {
1090 device->driver = driver;
1095 if (device->driver == NULL)
1098 return __connman_technology_add_device(device);
1102 * connman_device_unregister:
1103 * @device: device structure
1105 * Unregister device with the system
1107 void connman_device_unregister(struct connman_device *device)
1109 DBG("device %p name %s", device, device->name);
1111 if (device->driver == NULL)
1114 remove_device(device);
1118 * connman_device_get_data:
1119 * @device: device structure
1121 * Get private device data pointer
1123 void *connman_device_get_data(struct connman_device *device)
1125 return device->driver_data;
1129 * connman_device_set_data:
1130 * @device: device structure
1131 * @data: data pointer
1133 * Set private device data pointer
1135 void connman_device_set_data(struct connman_device *device, void *data)
1137 device->driver_data = data;
1140 struct connman_device *__connman_device_find_device(
1141 enum connman_service_type type)
1145 for (list = device_list; list != NULL; list = list->next) {
1146 struct connman_device *device = list->data;
1147 enum connman_service_type service_type =
1148 __connman_device_get_service_type(device);
1150 if (service_type != type)
1159 int __connman_device_request_scan(enum connman_service_type type)
1161 connman_bool_t success = FALSE;
1162 int last_err = -ENOSYS;
1167 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1168 case CONNMAN_SERVICE_TYPE_SYSTEM:
1169 case CONNMAN_SERVICE_TYPE_ETHERNET:
1170 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1171 case CONNMAN_SERVICE_TYPE_CELLULAR:
1172 case CONNMAN_SERVICE_TYPE_GPS:
1173 case CONNMAN_SERVICE_TYPE_VPN:
1174 case CONNMAN_SERVICE_TYPE_GADGET:
1176 case CONNMAN_SERVICE_TYPE_WIFI:
1177 case CONNMAN_SERVICE_TYPE_WIMAX:
1181 for (list = device_list; list != NULL; list = list->next) {
1182 struct connman_device *device = list->data;
1183 enum connman_service_type service_type =
1184 __connman_device_get_service_type(device);
1186 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1187 service_type != type) {
1191 err = device_scan(device);
1192 if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
1196 DBG("device %p err %d", device, err);
1200 if (success == TRUE)
1206 int __connman_device_request_hidden_scan(struct connman_device *device,
1207 const char *ssid, unsigned int ssid_len,
1208 const char *identity, const char *passphrase)
1210 DBG("device %p", device);
1212 if (device == NULL || device->driver == NULL ||
1213 device->driver->scan_hidden == NULL)
1216 if (device->scanning == TRUE)
1219 return device->driver->scan_hidden(device, ssid, ssid_len,
1220 identity, passphrase);
1223 connman_bool_t __connman_device_isfiltered(const char *devname)
1227 if (device_filter == NULL)
1230 for (pattern = device_filter; *pattern; pattern++) {
1231 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1232 DBG("ignoring device %s (match)", devname);
1238 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1239 DBG("ignoring dummy networking devices");
1243 if (nodevice_filter == NULL)
1246 for (pattern = nodevice_filter; *pattern; pattern++) {
1247 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1248 DBG("ignoring device %s (no match)", devname);
1256 int __connman_device_init(const char *device, const char *nodevice)
1261 device_filter = g_strsplit(device, ",", -1);
1263 if (nodevice != NULL)
1264 nodevice_filter = g_strsplit(nodevice, ",", -1);
1269 void __connman_device_cleanup(void)
1273 g_strfreev(nodevice_filter);
1274 g_strfreev(device_filter);