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(struct connman_device *device)
546 __sync_fetch_and_add(&device->refcount, 1);
552 * connman_device_unref:
553 * @device: device structure
555 * Decrease reference counter of device
557 void connman_device_unref(struct connman_device *device)
559 if (__sync_fetch_and_sub(&device->refcount, 1) != 1)
562 if (device->driver) {
563 device->driver->remove(device);
564 device->driver = NULL;
567 device_list = g_slist_remove(device_list, device);
569 device_destruct(device);
572 const char *__connman_device_get_type(struct connman_device *device)
574 return type2string(device->type);
578 * connman_device_get_type:
579 * @device: device structure
583 enum connman_device_type connman_device_get_type(struct connman_device *device)
589 * connman_device_set_index:
590 * @device: device structure
591 * @index: index number
593 * Set index number of device
595 void connman_device_set_index(struct connman_device *device, int index)
597 device->index = index;
601 * connman_device_get_index:
602 * @device: device structure
604 * Get index number of device
606 int connman_device_get_index(struct connman_device *device)
608 return device->index;
611 int __connman_device_get_phyindex(struct connman_device *device)
613 return device->phyindex;
616 void __connman_device_set_phyindex(struct connman_device *device,
619 device->phyindex = phyindex;
623 * connman_device_set_interface:
624 * @device: device structure
625 * @interface: interface name
627 * Set interface name of device
629 void connman_device_set_interface(struct connman_device *device,
630 const char *interface)
632 g_free(device->devname);
633 device->devname = g_strdup(interface);
635 g_free(device->interface);
636 device->interface = g_strdup(interface);
638 if (device->name == NULL) {
639 const char *str = type2description(device->type);
640 if (str != NULL && device->interface != NULL)
641 device->name = g_strdup_printf("%s (%s)", str,
647 * connman_device_set_ident:
648 * @device: device structure
649 * @ident: unique identifier
651 * Set unique identifier of device
653 void connman_device_set_ident(struct connman_device *device,
656 g_free(device->ident);
657 device->ident = g_strdup(ident);
660 const char *connman_device_get_ident(struct connman_device *device)
662 return device->ident;
666 * connman_device_set_powered:
667 * @device: device structure
668 * @powered: powered state
670 * Change power state of device
672 int connman_device_set_powered(struct connman_device *device,
673 connman_bool_t powered)
675 enum connman_service_type type;
677 DBG("driver %p powered %d", device, powered);
679 if (device->powered == powered)
682 clear_pending_trigger(device);
684 device->powered_pending = PENDING_NONE;
686 device->powered = powered;
688 type = __connman_device_get_service_type(device);
690 if (device->powered == TRUE)
691 __connman_technology_enabled(type);
693 __connman_technology_disabled(type);
695 if (powered == FALSE)
698 connman_device_set_disconnected(device, FALSE);
699 device->scanning = FALSE;
701 reset_scan_trigger(device);
703 if (device->driver && device->driver->scan_fast)
704 device->driver->scan_fast(device);
705 else if (device->driver && device->driver->scan)
706 device->driver->scan(device);
711 static int device_scan(struct connman_device *device)
713 if (!device->driver || !device->driver->scan)
716 if (device->powered == FALSE)
719 reset_scan_trigger(device);
721 return device->driver->scan(device);
724 int __connman_device_disconnect(struct connman_device *device)
729 DBG("device %p", device);
731 connman_device_set_disconnected(device, TRUE);
733 g_hash_table_iter_init(&iter, device->networks);
735 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
736 struct connman_network *network = value;
738 if (connman_network_get_connecting(network) == TRUE) {
740 * Skip network in the process of connecting.
741 * This is a workaround for WiFi networks serviced
742 * by the supplicant plugin that hold a reference
743 * to the network. If we disconnect the network
744 * here then the referenced object will not be
745 * registered and usage (like launching DHCP client)
746 * will fail. There is nothing to be gained by
747 * removing the network here anyway.
749 connman_warn("Skipping disconnect of %s, network is connecting.",
750 connman_network_get_identifier(network));
754 __connman_network_disconnect(network);
760 static void mark_network_available(gpointer key, gpointer value,
763 struct connman_network *network = value;
765 connman_network_set_available(network, TRUE);
768 static void mark_network_unavailable(gpointer key, gpointer value,
771 struct connman_network *network = value;
773 if (connman_network_get_connected(network) == TRUE)
776 connman_network_set_available(network, FALSE);
779 static gboolean remove_unavailable_network(gpointer key, gpointer value,
782 struct connman_network *network = value;
784 if (connman_network_get_connected(network) == TRUE)
787 if (connman_network_get_available(network) == TRUE)
793 void __connman_device_cleanup_networks(struct connman_device *device)
795 g_hash_table_foreach_remove(device->networks,
796 remove_unavailable_network, NULL);
799 connman_bool_t __connman_device_scanning(struct connman_device *device)
801 return device->scanning;
804 void connman_device_reset_scanning(struct connman_device *device)
806 device->scanning = FALSE;
808 g_hash_table_foreach(device->networks,
809 mark_network_available, NULL);
814 * connman_device_set_scanning:
815 * @device: device structure
816 * @scanning: scanning state
818 * Change scanning state of device
820 int connman_device_set_scanning(struct connman_device *device,
821 connman_bool_t scanning)
823 DBG("device %p scanning %d", device, scanning);
825 if (!device->driver || !device->driver->scan)
828 if (device->scanning == scanning)
831 device->scanning = scanning;
833 if (scanning == TRUE) {
834 reset_scan_trigger(device);
836 g_hash_table_foreach(device->networks,
837 mark_network_unavailable, NULL);
842 __connman_device_cleanup_networks(device);
844 __connman_service_auto_connect();
850 * connman_device_set_disconnected:
851 * @device: device structure
852 * @disconnected: disconnected state
854 * Change disconnected state of device (only for device with networks)
856 int connman_device_set_disconnected(struct connman_device *device,
857 connman_bool_t disconnected)
859 DBG("device %p disconnected %d", device, disconnected);
861 if (device->disconnected == disconnected)
864 device->disconnected = disconnected;
866 if (disconnected == TRUE)
868 force_scan_trigger(device);
869 device->backoff_interval = SCAN_INITIAL_DELAY;
876 * connman_device_get_disconnected:
877 * @device: device structure
879 * Get device disconnected state
881 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
883 return device->disconnected;
887 * connman_device_set_string:
888 * @device: device structure
889 * @key: unique identifier
890 * @value: string value
892 * Set string value for specific key
894 int connman_device_set_string(struct connman_device *device,
895 const char *key, const char *value)
897 DBG("device %p key %s value %s", device, key, value);
899 if (g_str_equal(key, "Address") == TRUE) {
900 g_free(device->address);
901 device->address = g_strdup(value);
902 } else if (g_str_equal(key, "Name") == TRUE) {
903 g_free(device->name);
904 device->name = g_strdup(value);
905 } else if (g_str_equal(key, "Node") == TRUE) {
906 g_free(device->node);
907 device->node = g_strdup(value);
908 } else if (g_str_equal(key, "Path") == TRUE) {
909 g_free(device->path);
910 device->path = g_strdup(value);
919 * connman_device_get_string:
920 * @device: device structure
921 * @key: unique identifier
923 * Get string value for specific key
925 const char *connman_device_get_string(struct connman_device *device,
928 DBG("device %p key %s", device, key);
930 if (g_str_equal(key, "Address") == TRUE)
931 return device->address;
932 else if (g_str_equal(key, "Name") == TRUE)
934 else if (g_str_equal(key, "Node") == TRUE)
936 else if (g_str_equal(key, "Interface") == TRUE)
937 return device->interface;
938 else if (g_str_equal(key, "Path") == TRUE)
945 * connman_device_add_network:
946 * @device: device structure
947 * @network: network structure
949 * Add new network to the device
951 int connman_device_add_network(struct connman_device *device,
952 struct connman_network *network)
954 const char *identifier = connman_network_get_identifier(network);
956 DBG("device %p network %p", device, network);
958 if (identifier == NULL)
961 connman_network_ref(network);
963 __connman_network_set_device(network, device);
965 g_hash_table_insert(device->networks, g_strdup(identifier),
972 * connman_device_get_network:
973 * @device: device structure
974 * @identifier: network identifier
976 * Get network for given identifier
978 struct connman_network *connman_device_get_network(struct connman_device *device,
979 const char *identifier)
981 DBG("device %p identifier %s", device, identifier);
983 return g_hash_table_lookup(device->networks, identifier);
987 * connman_device_remove_network:
988 * @device: device structure
989 * @identifier: network identifier
991 * Remove network for given identifier
993 int connman_device_remove_network(struct connman_device *device,
994 struct connman_network *network)
996 const char *identifier;
998 DBG("device %p network %p", device, network);
1000 if (network == NULL)
1003 identifier = connman_network_get_identifier(network);
1004 g_hash_table_remove(device->networks, identifier);
1009 void connman_device_remove_all_networks(struct connman_device *device)
1011 g_hash_table_remove_all(device->networks);
1014 void __connman_device_set_network(struct connman_device *device,
1015 struct connman_network *network)
1022 if (device->network == network)
1025 if (network != NULL) {
1026 name = connman_network_get_string(network, "Name");
1027 g_free(device->last_network);
1028 device->last_network = g_strdup(name);
1030 device->network = network;
1032 g_free(device->last_network);
1033 device->last_network = NULL;
1035 device->network = NULL;
1039 void __connman_device_set_reconnect(struct connman_device *device,
1040 connman_bool_t reconnect)
1042 device->reconnect = reconnect;
1045 connman_bool_t __connman_device_get_reconnect(
1046 struct connman_device *device)
1048 return device->reconnect;
1051 static gboolean match_driver(struct connman_device *device,
1052 struct connman_device_driver *driver)
1054 if (device->type == driver->type ||
1055 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1062 * connman_device_register:
1063 * @device: device structure
1065 * Register device with the system
1067 int connman_device_register(struct connman_device *device)
1071 DBG("device %p name %s", device, device->name);
1073 if (device->driver != NULL)
1076 for (list = driver_list; list; list = list->next) {
1077 struct connman_device_driver *driver = list->data;
1079 if (match_driver(device, driver) == FALSE)
1082 DBG("driver %p name %s", driver, driver->name);
1084 if (driver->probe(device) == 0) {
1085 device->driver = driver;
1090 if (device->driver == NULL)
1093 return __connman_technology_add_device(device);
1097 * connman_device_unregister:
1098 * @device: device structure
1100 * Unregister device with the system
1102 void connman_device_unregister(struct connman_device *device)
1104 DBG("device %p name %s", device, device->name);
1106 if (device->driver == NULL)
1109 remove_device(device);
1113 * connman_device_get_data:
1114 * @device: device structure
1116 * Get private device data pointer
1118 void *connman_device_get_data(struct connman_device *device)
1120 return device->driver_data;
1124 * connman_device_set_data:
1125 * @device: device structure
1126 * @data: data pointer
1128 * Set private device data pointer
1130 void connman_device_set_data(struct connman_device *device, void *data)
1132 device->driver_data = data;
1135 struct connman_device *__connman_device_find_device(
1136 enum connman_service_type type)
1140 for (list = device_list; list != NULL; list = list->next) {
1141 struct connman_device *device = list->data;
1142 enum connman_service_type service_type =
1143 __connman_device_get_service_type(device);
1145 if (service_type != type)
1154 int __connman_device_request_scan(enum connman_service_type type)
1160 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1161 case CONNMAN_SERVICE_TYPE_SYSTEM:
1162 case CONNMAN_SERVICE_TYPE_ETHERNET:
1163 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1164 case CONNMAN_SERVICE_TYPE_CELLULAR:
1165 case CONNMAN_SERVICE_TYPE_GPS:
1166 case CONNMAN_SERVICE_TYPE_VPN:
1167 case CONNMAN_SERVICE_TYPE_GADGET:
1169 case CONNMAN_SERVICE_TYPE_WIFI:
1170 case CONNMAN_SERVICE_TYPE_WIMAX:
1174 for (list = device_list; list != NULL; list = list->next) {
1175 struct connman_device *device = list->data;
1176 enum connman_service_type service_type =
1177 __connman_device_get_service_type(device);
1179 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1180 service_type != type) {
1184 err = device_scan(device);
1185 if (err < 0 && err != -EINPROGRESS) {
1187 /* XXX maybe only a continue? */
1195 int __connman_device_request_hidden_scan(struct connman_device *device,
1196 const char *ssid, unsigned int ssid_len,
1197 const char *identity, const char *passphrase)
1199 DBG("device %p", device);
1201 if (device == NULL || device->driver == NULL ||
1202 device->driver->scan_hidden == NULL)
1205 if (device->scanning == TRUE)
1208 return device->driver->scan_hidden(device, ssid, ssid_len,
1209 identity, passphrase);
1212 connman_bool_t __connman_device_isfiltered(const char *devname)
1216 if (device_filter == NULL)
1219 for (pattern = device_filter; *pattern; pattern++) {
1220 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1221 DBG("ignoring device %s (match)", devname);
1227 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1228 DBG("ignoring dummy networking devices");
1232 if (nodevice_filter == NULL)
1235 for (pattern = nodevice_filter; *pattern; pattern++) {
1236 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1237 DBG("ignoring device %s (no match)", devname);
1245 int __connman_device_init(const char *device, const char *nodevice)
1250 device_filter = g_strsplit(device, ",", -1);
1252 if (nodevice != NULL)
1253 nodevice_filter = g_strsplit(nodevice, ",", -1);
1258 void __connman_device_cleanup(void)
1262 g_strfreev(nodevice_filter);
1263 g_strfreev(device_filter);