5 * Copyright (C) 2007-2012 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
32 #define SIG_WIFI_REFCOUNT_NAME "connman_significant_wifi_profile_refcount"
35 static GSList *device_list = NULL;
36 static gchar **device_filter = NULL;
37 static gchar **nodevice_filter = NULL;
39 enum connman_pending_type {
45 struct connman_device {
47 enum connman_device_type type;
48 enum connman_pending_type powered_pending; /* Indicates a pending
49 enable/disable request */
50 connman_bool_t powered;
51 connman_bool_t scanning;
52 connman_bool_t disconnected;
53 connman_bool_t reconnect;
63 guint pending_timeout;
65 struct connman_device_driver *driver;
69 struct connman_network *network;
73 /* It contains number of favorite Wi-Fi profile.
74 * If significant wifi profile is 0,Wi-Fi device does not trigger scan.
76 gint significant_wifi_profile_refcount;
81 static void __connman_device_set_sig_wifi_profile_refcount(
82 struct connman_device *device, gint refcount)
84 g_atomic_int_set(&device->significant_wifi_profile_refcount, refcount);
87 void connman_device_sig_wifi_profile_ref(struct connman_device *device)
89 g_atomic_int_inc(&device->significant_wifi_profile_refcount);
92 connman_bool_t connman_device_sig_wifi_profile_unref_and_test(
93 struct connman_device *device)
95 if (device->significant_wifi_profile_refcount > 0)
96 return (connman_bool_t)g_atomic_int_dec_and_test(
97 &device->significant_wifi_profile_refcount);
104 static void clear_pending_trigger(struct connman_device *device)
106 if (device->pending_timeout > 0) {
107 g_source_remove(device->pending_timeout);
108 device->pending_timeout = 0;
112 static const char *type2description(enum connman_device_type type)
115 case CONNMAN_DEVICE_TYPE_UNKNOWN:
116 case CONNMAN_DEVICE_TYPE_VENDOR:
118 case CONNMAN_DEVICE_TYPE_ETHERNET:
120 case CONNMAN_DEVICE_TYPE_WIFI:
122 case CONNMAN_DEVICE_TYPE_WIMAX:
124 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
126 case CONNMAN_DEVICE_TYPE_GPS:
128 case CONNMAN_DEVICE_TYPE_CELLULAR:
130 case CONNMAN_DEVICE_TYPE_GADGET:
138 static const char *type2string(enum connman_device_type type)
141 case CONNMAN_DEVICE_TYPE_UNKNOWN:
142 case CONNMAN_DEVICE_TYPE_VENDOR:
144 case CONNMAN_DEVICE_TYPE_ETHERNET:
146 case CONNMAN_DEVICE_TYPE_WIFI:
148 case CONNMAN_DEVICE_TYPE_WIMAX:
150 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
152 case CONNMAN_DEVICE_TYPE_GPS:
154 case CONNMAN_DEVICE_TYPE_CELLULAR:
156 case CONNMAN_DEVICE_TYPE_GADGET:
164 enum connman_service_type __connman_device_get_service_type(struct connman_device *device)
166 enum connman_device_type type = connman_device_get_type(device);
169 case CONNMAN_DEVICE_TYPE_UNKNOWN:
170 case CONNMAN_DEVICE_TYPE_VENDOR:
171 case CONNMAN_DEVICE_TYPE_GPS:
173 case CONNMAN_DEVICE_TYPE_ETHERNET:
174 return CONNMAN_SERVICE_TYPE_ETHERNET;
175 case CONNMAN_DEVICE_TYPE_WIFI:
176 return CONNMAN_SERVICE_TYPE_WIFI;
177 case CONNMAN_DEVICE_TYPE_WIMAX:
178 return CONNMAN_SERVICE_TYPE_WIMAX;
179 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
180 return CONNMAN_SERVICE_TYPE_BLUETOOTH;
181 case CONNMAN_DEVICE_TYPE_CELLULAR:
182 return CONNMAN_SERVICE_TYPE_CELLULAR;
183 case CONNMAN_DEVICE_TYPE_GADGET:
184 return CONNMAN_SERVICE_TYPE_GADGET;
188 return CONNMAN_SERVICE_TYPE_UNKNOWN;
191 static gboolean device_pending_reset(gpointer user_data)
193 struct connman_device *device = user_data;
195 DBG("device %p", device);
197 /* Power request timedout, reset power pending state. */
198 device->pending_timeout = 0;
199 device->powered_pending = PENDING_NONE;
204 int __connman_device_enable(struct connman_device *device)
208 DBG("device %p", device);
210 if (!device->driver || !device->driver->enable)
213 /* There is an ongoing power disable request. */
214 if (device->powered_pending == PENDING_DISABLE)
217 if (device->powered_pending == PENDING_ENABLE)
220 if (device->powered_pending == PENDING_NONE && device->powered == TRUE)
223 device->powered_pending = PENDING_ENABLE;
225 err = device->driver->enable(device);
227 * device gets enabled right away.
228 * Invoke the callback
231 connman_device_set_powered(device, TRUE);
235 if (err == -EALREADY) {
236 /* If device is already powered, but connman is not updated */
237 connman_device_set_powered(device, TRUE);
241 * if err == -EINPROGRESS, then the DBus call to the respective daemon
242 * was successful. We set a 4 sec timeout so if the daemon never
243 * returns a reply, we would reset the pending request.
245 if (err == -EINPROGRESS)
246 device->pending_timeout = g_timeout_add_seconds(4,
247 device_pending_reset, device);
252 int __connman_device_disable(struct connman_device *device)
256 DBG("device %p", device);
258 if (!device->driver || !device->driver->disable)
261 /* Ongoing power enable request */
262 if (device->powered_pending == PENDING_ENABLE)
265 if (device->powered_pending == PENDING_DISABLE)
268 if (device->powered_pending == PENDING_NONE && device->powered == FALSE)
271 device->powered_pending = PENDING_DISABLE;
272 device->reconnect = FALSE;
274 if (device->network) {
275 struct connman_service *service =
276 __connman_service_lookup_from_network(device->network);
279 __connman_service_disconnect(service);
281 connman_network_set_connected(device->network, FALSE);
284 err = device->driver->disable(device);
285 if (err == 0 || err == -EALREADY) {
286 connman_device_set_powered(device, FALSE);
290 if (err == -EINPROGRESS)
291 device->pending_timeout = g_timeout_add_seconds(4,
292 device_pending_reset, device);
297 static void probe_driver(struct connman_device_driver *driver)
301 DBG("driver %p name %s", driver, driver->name);
303 for (list = device_list; list != NULL; list = list->next) {
304 struct connman_device *device = list->data;
306 if (device->driver != NULL)
309 if (driver->type != device->type)
312 if (driver->probe(device) < 0)
315 device->driver = driver;
317 __connman_technology_add_device(device);
321 static void remove_device(struct connman_device *device)
323 DBG("device %p", device);
325 __connman_device_disable(device);
327 __connman_technology_remove_device(device);
329 if (device->driver->remove)
330 device->driver->remove(device);
332 device->driver = NULL;
335 static void remove_driver(struct connman_device_driver *driver)
339 DBG("driver %p name %s", driver, driver->name);
341 for (list = device_list; list != NULL; list = list->next) {
342 struct connman_device *device = list->data;
344 if (device->driver == driver)
345 remove_device(device);
349 connman_bool_t __connman_device_has_driver(struct connman_device *device)
351 if (device == NULL || device->driver == NULL)
357 static GSList *driver_list = NULL;
359 static gint compare_priority(gconstpointer a, gconstpointer b)
361 const struct connman_device_driver *driver1 = a;
362 const struct connman_device_driver *driver2 = b;
364 return driver2->priority - driver1->priority;
368 * connman_device_driver_register:
369 * @driver: device driver definition
371 * Register a new device driver
373 * Returns: %0 on success
375 int connman_device_driver_register(struct connman_device_driver *driver)
377 DBG("driver %p name %s", driver, driver->name);
379 driver_list = g_slist_insert_sorted(driver_list, driver,
381 probe_driver(driver);
387 * connman_device_driver_unregister:
388 * @driver: device driver definition
390 * Remove a previously registered device driver
392 void connman_device_driver_unregister(struct connman_device_driver *driver)
394 DBG("driver %p name %s", driver, driver->name);
396 driver_list = g_slist_remove(driver_list, driver);
398 remove_driver(driver);
401 static void free_network(gpointer data)
403 struct connman_network *network = data;
405 DBG("network %p", network);
407 __connman_network_set_device(network, NULL);
409 connman_network_unref(network);
412 static void device_destruct(struct connman_device *device)
414 DBG("device %p name %s", device, device->name);
416 clear_pending_trigger(device);
418 g_free(device->ident);
419 g_free(device->node);
420 g_free(device->name);
421 g_free(device->address);
422 g_free(device->interface);
423 g_free(device->path);
424 g_free(device->devname);
426 g_free(device->last_network);
428 g_hash_table_destroy(device->networks);
429 device->networks = NULL;
434 #if defined TIZEN_EXT
435 connman_bool_t connman_device_load_sig_wifi_profile_refcount_from_storage(
436 struct connman_device *device)
438 GKeyFile *keyfile = NULL;
440 keyfile = __connman_storage_load_global();
442 if (g_key_file_has_group(keyfile, SIG_WIFI_REFCOUNT_NAME) == FALSE) {
443 g_key_file_free(keyfile);
447 __connman_device_set_sig_wifi_profile_refcount(device,
448 g_key_file_get_integer(keyfile, SIG_WIFI_REFCOUNT_NAME,
449 "ReferenceCount", NULL));
451 g_key_file_free(keyfile);
455 connman_bool_t connman_device_save_sig_wifi_profile_refcount2storage(
456 struct connman_device *device)
458 GKeyFile *keyfile = NULL;
460 keyfile = __connman_storage_load_global();
462 g_key_file_set_integer(keyfile, SIG_WIFI_REFCOUNT_NAME,
464 device->significant_wifi_profile_refcount);
466 __connman_storage_save_global(keyfile);
468 g_key_file_free(keyfile);
474 * connman_device_create:
475 * @node: device node name (for example an address)
478 * Allocate a new device of given #type and assign the #node name to it.
480 * Returns: a newly-allocated #connman_device structure
482 struct connman_device *connman_device_create(const char *node,
483 enum connman_device_type type)
485 struct connman_device *device;
487 DBG("node %s type %d", node, type);
489 device = g_try_new0(struct connman_device, 1);
493 DBG("device %p", device);
495 device->refcount = 1;
497 #if defined TIZEN_EXT
498 if (type == CONNMAN_DEVICE_TYPE_WIFI) {
499 /* Load significant_wifi_profile_refcount */
500 if (connman_device_load_sig_wifi_profile_refcount_from_storage
502 __connman_device_set_sig_wifi_profile_refcount(
504 connman_device_save_sig_wifi_profile_refcount2storage(
508 __connman_device_set_sig_wifi_profile_refcount(device, 0);
511 device->name = g_strdup(type2description(device->type));
513 device->phyindex = -1;
515 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
516 g_free, free_network);
518 device_list = g_slist_append(device_list, device);
524 * connman_device_ref:
525 * @device: device structure
527 * Increase reference counter of device
529 struct connman_device *connman_device_ref_debug(struct connman_device *device,
530 const char *file, int line, const char *caller)
532 DBG("%p ref %d by %s:%d:%s()", device, device->refcount + 1,
535 __sync_fetch_and_add(&device->refcount, 1);
541 * connman_device_unref:
542 * @device: device structure
544 * Decrease reference counter of device
546 void connman_device_unref_debug(struct connman_device *device,
547 const char *file, int line, const char *caller)
549 DBG("%p ref %d by %s:%d:%s()", device, device->refcount - 1,
552 if (__sync_fetch_and_sub(&device->refcount, 1) != 1)
555 if (device->driver) {
556 device->driver->remove(device);
557 device->driver = NULL;
560 device_list = g_slist_remove(device_list, device);
562 device_destruct(device);
565 const char *__connman_device_get_type(struct connman_device *device)
567 return type2string(device->type);
571 * connman_device_get_type:
572 * @device: device structure
576 enum connman_device_type connman_device_get_type(struct connman_device *device)
582 * connman_device_set_index:
583 * @device: device structure
584 * @index: index number
586 * Set index number of device
588 void connman_device_set_index(struct connman_device *device, int index)
590 device->index = index;
594 * connman_device_get_index:
595 * @device: device structure
597 * Get index number of device
599 int connman_device_get_index(struct connman_device *device)
601 return device->index;
604 int __connman_device_get_phyindex(struct connman_device *device)
606 return device->phyindex;
609 void __connman_device_set_phyindex(struct connman_device *device,
612 device->phyindex = phyindex;
616 * connman_device_set_interface:
617 * @device: device structure
618 * @interface: interface name
620 * Set interface name of device
622 void connman_device_set_interface(struct connman_device *device,
623 const char *interface)
625 g_free(device->devname);
626 device->devname = g_strdup(interface);
628 g_free(device->interface);
629 device->interface = g_strdup(interface);
631 if (device->name == NULL) {
632 const char *str = type2description(device->type);
633 if (str != NULL && device->interface != NULL)
634 device->name = g_strdup_printf("%s (%s)", str,
640 * connman_device_set_ident:
641 * @device: device structure
642 * @ident: unique identifier
644 * Set unique identifier of device
646 void connman_device_set_ident(struct connman_device *device,
649 g_free(device->ident);
650 device->ident = g_strdup(ident);
653 const char *connman_device_get_ident(struct connman_device *device)
655 return device->ident;
659 * connman_device_set_powered:
660 * @device: device structure
661 * @powered: powered state
663 * Change power state of device
665 int connman_device_set_powered(struct connman_device *device,
666 connman_bool_t powered)
668 enum connman_service_type type;
670 DBG("driver %p powered %d", device, powered);
672 if (device->powered == powered)
675 clear_pending_trigger(device);
677 device->powered_pending = PENDING_NONE;
679 device->powered = powered;
681 type = __connman_device_get_service_type(device);
683 if (device->powered == FALSE) {
684 __connman_technology_disabled(type);
688 __connman_technology_enabled(type);
690 connman_device_set_disconnected(device, FALSE);
691 device->scanning = FALSE;
693 if (device->driver && device->driver->scan_fast)
694 device->driver->scan_fast(device);
695 else if (device->driver && device->driver->scan)
696 device->driver->scan(device);
701 #if defined TIZEN_EXT
702 static gboolean allow_wifi_scan(struct connman_device *device)
707 g_hash_table_iter_init(&iter, device->networks);
709 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
710 struct connman_network *network = value;
712 if (connman_network_get_connecting(network) == TRUE)
715 if (connman_network_get_associating(network) == TRUE)
723 static int device_scan(struct connman_device *device)
725 if (!device->driver || !device->driver->scan)
728 if (device->powered == FALSE)
731 #if defined TIZEN_EXT
732 if (device->type == CONNMAN_DEVICE_TYPE_WIFI &&
733 allow_wifi_scan(device) == FALSE)
736 return device->driver->scan(device);
739 int __connman_device_disconnect(struct connman_device *device)
744 DBG("device %p", device);
746 connman_device_set_disconnected(device, TRUE);
748 g_hash_table_iter_init(&iter, device->networks);
750 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
751 struct connman_network *network = value;
753 if (connman_network_get_connecting(network) == TRUE) {
755 * Skip network in the process of connecting.
756 * This is a workaround for WiFi networks serviced
757 * by the supplicant plugin that hold a reference
758 * to the network. If we disconnect the network
759 * here then the referenced object will not be
760 * registered and usage (like launching DHCP client)
761 * will fail. There is nothing to be gained by
762 * removing the network here anyway.
764 connman_warn("Skipping disconnect of %s, network is connecting.",
765 connman_network_get_identifier(network));
769 __connman_network_disconnect(network);
775 static void mark_network_available(gpointer key, gpointer value,
778 struct connman_network *network = value;
780 connman_network_set_available(network, TRUE);
783 static void mark_network_unavailable(gpointer key, gpointer value,
786 struct connman_network *network = value;
788 if (connman_network_get_connected(network) == TRUE)
791 connman_network_set_available(network, FALSE);
794 static gboolean remove_unavailable_network(gpointer key, gpointer value,
797 struct connman_network *network = value;
799 if (connman_network_get_connected(network) == TRUE)
802 if (connman_network_get_available(network) == TRUE)
808 void __connman_device_cleanup_networks(struct connman_device *device)
810 g_hash_table_foreach_remove(device->networks,
811 remove_unavailable_network, NULL);
814 connman_bool_t connman_device_get_scanning(struct connman_device *device)
816 return device->scanning;
819 void connman_device_reset_scanning(struct connman_device *device)
821 g_hash_table_foreach(device->networks,
822 mark_network_available, NULL);
826 * connman_device_set_scanning:
827 * @device: device structure
828 * @scanning: scanning state
830 * Change scanning state of device
832 int connman_device_set_scanning(struct connman_device *device,
833 connman_bool_t scanning)
835 DBG("device %p scanning %d", device, scanning);
837 if (!device->driver || !device->driver->scan)
840 if (device->scanning == scanning)
843 device->scanning = scanning;
845 if (scanning == TRUE) {
846 __connman_technology_scan_started(device);
848 g_hash_table_foreach(device->networks,
849 mark_network_unavailable, NULL);
854 __connman_device_cleanup_networks(device);
856 __connman_technology_scan_stopped(device);
858 __connman_service_auto_connect();
864 * connman_device_set_disconnected:
865 * @device: device structure
866 * @disconnected: disconnected state
868 * Change disconnected state of device (only for device with networks)
870 int connman_device_set_disconnected(struct connman_device *device,
871 connman_bool_t disconnected)
873 DBG("device %p disconnected %d", device, disconnected);
875 if (device->disconnected == disconnected)
878 device->disconnected = disconnected;
884 * connman_device_get_disconnected:
885 * @device: device structure
887 * Get device disconnected state
889 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
891 return device->disconnected;
895 * connman_device_set_string:
896 * @device: device structure
897 * @key: unique identifier
898 * @value: string value
900 * Set string value for specific key
902 int connman_device_set_string(struct connman_device *device,
903 const char *key, const char *value)
905 DBG("device %p key %s value %s", device, key, value);
907 if (g_str_equal(key, "Address") == TRUE) {
908 g_free(device->address);
909 device->address = g_strdup(value);
910 } else if (g_str_equal(key, "Name") == TRUE) {
911 g_free(device->name);
912 device->name = g_strdup(value);
913 } else if (g_str_equal(key, "Node") == TRUE) {
914 g_free(device->node);
915 device->node = g_strdup(value);
916 } else if (g_str_equal(key, "Path") == TRUE) {
917 g_free(device->path);
918 device->path = g_strdup(value);
927 * connman_device_get_string:
928 * @device: device structure
929 * @key: unique identifier
931 * Get string value for specific key
933 const char *connman_device_get_string(struct connman_device *device,
936 DBG("device %p key %s", device, key);
938 if (g_str_equal(key, "Address") == TRUE)
939 return device->address;
940 else if (g_str_equal(key, "Name") == TRUE)
942 else if (g_str_equal(key, "Node") == TRUE)
944 else if (g_str_equal(key, "Interface") == TRUE)
945 return device->interface;
946 else if (g_str_equal(key, "Path") == TRUE)
953 * connman_device_add_network:
954 * @device: device structure
955 * @network: network structure
957 * Add new network to the device
959 int connman_device_add_network(struct connman_device *device,
960 struct connman_network *network)
962 const char *identifier = connman_network_get_identifier(network);
964 DBG("device %p network %p", device, network);
966 if (identifier == NULL)
969 connman_network_ref(network);
971 __connman_network_set_device(network, device);
973 g_hash_table_replace(device->networks, g_strdup(identifier),
980 * connman_device_get_network:
981 * @device: device structure
982 * @identifier: network identifier
984 * Get network for given identifier
986 struct connman_network *connman_device_get_network(struct connman_device *device,
987 const char *identifier)
989 DBG("device %p identifier %s", device, identifier);
991 return g_hash_table_lookup(device->networks, identifier);
995 * connman_device_remove_network:
996 * @device: device structure
997 * @identifier: network identifier
999 * Remove network for given identifier
1001 int connman_device_remove_network(struct connman_device *device,
1002 struct connman_network *network)
1004 const char *identifier;
1006 DBG("device %p network %p", device, network);
1008 if (network == NULL)
1011 identifier = connman_network_get_identifier(network);
1012 g_hash_table_remove(device->networks, identifier);
1017 void connman_device_remove_all_networks(struct connman_device *device)
1019 g_hash_table_remove_all(device->networks);
1022 void __connman_device_set_network(struct connman_device *device,
1023 struct connman_network *network)
1030 if (device->network == network)
1033 if (network != NULL) {
1034 name = connman_network_get_string(network, "Name");
1035 g_free(device->last_network);
1036 device->last_network = g_strdup(name);
1038 device->network = network;
1040 g_free(device->last_network);
1041 device->last_network = NULL;
1043 device->network = NULL;
1047 void __connman_device_set_reconnect(struct connman_device *device,
1048 connman_bool_t reconnect)
1050 device->reconnect = reconnect;
1053 connman_bool_t __connman_device_get_reconnect(
1054 struct connman_device *device)
1056 return device->reconnect;
1059 static gboolean match_driver(struct connman_device *device,
1060 struct connman_device_driver *driver)
1062 if (device->type == driver->type ||
1063 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1070 * connman_device_register:
1071 * @device: device structure
1073 * Register device with the system
1075 int connman_device_register(struct connman_device *device)
1079 DBG("device %p name %s", device, device->name);
1081 if (device->driver != NULL)
1084 for (list = driver_list; list; list = list->next) {
1085 struct connman_device_driver *driver = list->data;
1087 if (match_driver(device, driver) == FALSE)
1090 DBG("driver %p name %s", driver, driver->name);
1092 if (driver->probe(device) == 0) {
1093 device->driver = driver;
1098 if (device->driver == NULL)
1101 return __connman_technology_add_device(device);
1105 * connman_device_unregister:
1106 * @device: device structure
1108 * Unregister device with the system
1110 void connman_device_unregister(struct connman_device *device)
1112 DBG("device %p name %s", device, device->name);
1114 if (device->driver == NULL)
1117 remove_device(device);
1121 * connman_device_get_data:
1122 * @device: device structure
1124 * Get private device data pointer
1126 void *connman_device_get_data(struct connman_device *device)
1128 return device->driver_data;
1132 * connman_device_set_data:
1133 * @device: device structure
1134 * @data: data pointer
1136 * Set private device data pointer
1138 void connman_device_set_data(struct connman_device *device, void *data)
1140 device->driver_data = data;
1143 struct connman_device *__connman_device_find_device(
1144 enum connman_service_type type)
1148 for (list = device_list; list != NULL; list = list->next) {
1149 struct connman_device *device = list->data;
1150 enum connman_service_type service_type =
1151 __connman_device_get_service_type(device);
1153 if (service_type != type)
1162 int __connman_device_request_scan(enum connman_service_type type)
1164 connman_bool_t success = FALSE;
1165 int last_err = -ENOSYS;
1170 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1171 case CONNMAN_SERVICE_TYPE_SYSTEM:
1172 case CONNMAN_SERVICE_TYPE_ETHERNET:
1173 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1174 case CONNMAN_SERVICE_TYPE_CELLULAR:
1175 case CONNMAN_SERVICE_TYPE_GPS:
1176 case CONNMAN_SERVICE_TYPE_VPN:
1177 case CONNMAN_SERVICE_TYPE_GADGET:
1179 case CONNMAN_SERVICE_TYPE_WIFI:
1180 case CONNMAN_SERVICE_TYPE_WIMAX:
1184 for (list = device_list; list != NULL; list = list->next) {
1185 struct connman_device *device = list->data;
1186 enum connman_service_type service_type =
1187 __connman_device_get_service_type(device);
1189 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1190 service_type != type) {
1194 err = device_scan(device);
1195 if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
1199 DBG("device %p err %d", device, err);
1203 if (success == TRUE)
1209 int __connman_device_request_hidden_scan(struct connman_device *device,
1210 const char *ssid, unsigned int ssid_len,
1211 const char *identity, const char *passphrase,
1214 DBG("device %p", device);
1216 if (device == NULL || device->driver == NULL ||
1217 device->driver->scan_hidden == NULL)
1220 if (device->scanning == TRUE)
1223 return device->driver->scan_hidden(device, ssid, ssid_len,
1224 identity, passphrase, user_data);
1227 connman_bool_t __connman_device_isfiltered(const char *devname)
1230 char **blacklisted_interfaces;
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);
1259 blacklisted_interfaces =
1260 connman_setting_get_string_list("NetworkInterfaceBlacklist");
1261 if (blacklisted_interfaces == NULL)
1264 for (pattern = blacklisted_interfaces; *pattern; pattern++) {
1265 if (g_str_has_prefix(devname, *pattern) == TRUE) {
1266 DBG("ignoring device %s (blacklist)", devname);
1274 int __connman_device_init(const char *device, const char *nodevice)
1279 device_filter = g_strsplit(device, ",", -1);
1281 if (nodevice != NULL)
1282 nodevice_filter = g_strsplit(nodevice, ",", -1);
1287 void __connman_device_cleanup(void)
1291 g_strfreev(nodevice_filter);
1292 g_strfreev(device_filter);