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);
310 connman_network_set_connected(device->network, FALSE);
312 err = device->driver->disable(device);
314 connman_device_set_powered(device, FALSE);
318 if (err == -EALREADY) {
319 connman_device_set_powered(device, FALSE);
323 if (err == -EINPROGRESS)
324 device->pending_timeout = g_timeout_add_seconds(4,
325 device_pending_reset, device);
330 static void probe_driver(struct connman_device_driver *driver)
334 DBG("driver %p name %s", driver, driver->name);
336 for (list = device_list; list != NULL; list = list->next) {
337 struct connman_device *device = list->data;
339 if (device->driver != NULL)
342 if (driver->type != device->type)
345 if (driver->probe(device) < 0)
348 device->driver = driver;
350 __connman_technology_add_device(device);
354 static void remove_device(struct connman_device *device)
356 DBG("device %p", device);
358 __connman_device_disable(device);
360 __connman_technology_remove_device(device);
362 if (device->driver->remove)
363 device->driver->remove(device);
365 device->driver = NULL;
368 static void remove_driver(struct connman_device_driver *driver)
372 DBG("driver %p name %s", driver, driver->name);
374 for (list = device_list; list != NULL; list = list->next) {
375 struct connman_device *device = list->data;
377 if (device->driver == driver)
378 remove_device(device);
382 connman_bool_t __connman_device_has_driver(struct connman_device *device)
384 if (device == NULL || device->driver == NULL)
390 static GSList *driver_list = NULL;
392 static gint compare_priority(gconstpointer a, gconstpointer b)
394 const struct connman_device_driver *driver1 = a;
395 const struct connman_device_driver *driver2 = b;
397 return driver2->priority - driver1->priority;
401 * connman_device_driver_register:
402 * @driver: device driver definition
404 * Register a new device driver
406 * Returns: %0 on success
408 int connman_device_driver_register(struct connman_device_driver *driver)
410 DBG("driver %p name %s", driver, driver->name);
412 driver_list = g_slist_insert_sorted(driver_list, driver,
414 probe_driver(driver);
420 * connman_device_driver_unregister:
421 * @driver: device driver definition
423 * Remove a previously registered device driver
425 void connman_device_driver_unregister(struct connman_device_driver *driver)
427 DBG("driver %p name %s", driver, driver->name);
429 driver_list = g_slist_remove(driver_list, driver);
431 remove_driver(driver);
434 static void free_network(gpointer data)
436 struct connman_network *network = data;
438 DBG("network %p", network);
440 __connman_network_set_device(network, NULL);
442 connman_network_unref(network);
445 static void device_destruct(struct connman_device *device)
447 DBG("device %p name %s", device, device->name);
449 clear_pending_trigger(device);
450 clear_scan_trigger(device);
452 g_free(device->ident);
453 g_free(device->node);
454 g_free(device->name);
455 g_free(device->address);
456 g_free(device->interface);
457 g_free(device->path);
458 g_free(device->devname);
460 g_free(device->last_network);
462 g_hash_table_destroy(device->networks);
463 device->networks = NULL;
469 * connman_device_create:
470 * @node: device node name (for example an address)
473 * Allocate a new device of given #type and assign the #node name to it.
475 * Returns: a newly-allocated #connman_device structure
477 struct connman_device *connman_device_create(const char *node,
478 enum connman_device_type type)
480 struct connman_device *device;
481 connman_bool_t bg_scan;
483 DBG("node %s type %d", node, type);
485 device = g_try_new0(struct connman_device, 1);
489 DBG("device %p", device);
491 device->refcount = 1;
493 bg_scan = connman_setting_get_bool("BackgroundScanning");
496 device->name = g_strdup(type2description(device->type));
498 device->phyindex = -1;
500 device->backoff_interval = SCAN_INITIAL_DELAY;
503 case CONNMAN_DEVICE_TYPE_UNKNOWN:
504 case CONNMAN_DEVICE_TYPE_ETHERNET:
505 case CONNMAN_DEVICE_TYPE_WIMAX:
506 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
507 case CONNMAN_DEVICE_TYPE_CELLULAR:
508 case CONNMAN_DEVICE_TYPE_GPS:
509 case CONNMAN_DEVICE_TYPE_GADGET:
510 case CONNMAN_DEVICE_TYPE_VENDOR:
511 device->scan_interval = 0;
513 case CONNMAN_DEVICE_TYPE_WIFI:
515 device->scan_interval = 300;
517 device->scan_interval = 0;
521 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
522 g_free, free_network);
524 device_list = g_slist_append(device_list, device);
530 * connman_device_ref:
531 * @device: device structure
533 * Increase reference counter of device
535 struct connman_device *connman_device_ref(struct connman_device *device)
539 __sync_fetch_and_add(&device->refcount, 1);
545 * connman_device_unref:
546 * @device: device structure
548 * Decrease reference counter of device
550 void connman_device_unref(struct connman_device *device)
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 == TRUE)
684 __connman_technology_enabled(type);
686 __connman_technology_disabled(type);
688 if (powered == FALSE)
691 connman_device_set_disconnected(device, FALSE);
692 device->scanning = FALSE;
694 reset_scan_trigger(device);
696 if (device->driver && device->driver->scan_fast)
697 device->driver->scan_fast(device);
698 else if (device->driver && device->driver->scan)
699 device->driver->scan(device);
704 static int device_scan(struct connman_device *device)
706 if (!device->driver || !device->driver->scan)
709 if (device->powered == FALSE)
712 reset_scan_trigger(device);
714 return device->driver->scan(device);
717 int __connman_device_disconnect(struct connman_device *device)
722 DBG("device %p", device);
724 connman_device_set_disconnected(device, TRUE);
726 g_hash_table_iter_init(&iter, device->networks);
728 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
729 struct connman_network *network = value;
731 if (connman_network_get_connecting(network) == TRUE) {
733 * Skip network in the process of connecting.
734 * This is a workaround for WiFi networks serviced
735 * by the supplicant plugin that hold a reference
736 * to the network. If we disconnect the network
737 * here then the referenced object will not be
738 * registered and usage (like launching DHCP client)
739 * will fail. There is nothing to be gained by
740 * removing the network here anyway.
742 connman_warn("Skipping disconnect of %s, network is connecting.",
743 connman_network_get_identifier(network));
747 __connman_network_disconnect(network);
753 static void mark_network_available(gpointer key, gpointer value,
756 struct connman_network *network = value;
758 connman_network_set_available(network, TRUE);
761 static void mark_network_unavailable(gpointer key, gpointer value,
764 struct connman_network *network = value;
766 if (connman_network_get_connected(network) == TRUE)
769 connman_network_set_available(network, FALSE);
772 static gboolean remove_unavailable_network(gpointer key, gpointer value,
775 struct connman_network *network = value;
777 if (connman_network_get_connected(network) == TRUE)
780 if (connman_network_get_available(network) == TRUE)
786 void __connman_device_cleanup_networks(struct connman_device *device)
788 g_hash_table_foreach_remove(device->networks,
789 remove_unavailable_network, NULL);
792 connman_bool_t __connman_device_scanning(struct connman_device *device)
794 return device->scanning;
797 void connman_device_reset_scanning(struct connman_device *device)
799 device->scanning = FALSE;
801 g_hash_table_foreach(device->networks,
802 mark_network_available, NULL);
807 * connman_device_set_scanning:
808 * @device: device structure
809 * @scanning: scanning state
811 * Change scanning state of device
813 int connman_device_set_scanning(struct connman_device *device,
814 connman_bool_t scanning)
816 DBG("device %p scanning %d", device, scanning);
818 if (!device->driver || !device->driver->scan)
821 if (device->scanning == scanning)
824 device->scanning = scanning;
826 if (scanning == TRUE) {
827 reset_scan_trigger(device);
829 g_hash_table_foreach(device->networks,
830 mark_network_unavailable, NULL);
835 __connman_device_cleanup_networks(device);
837 __connman_service_auto_connect();
843 * connman_device_set_disconnected:
844 * @device: device structure
845 * @disconnected: disconnected state
847 * Change disconnected state of device (only for device with networks)
849 int connman_device_set_disconnected(struct connman_device *device,
850 connman_bool_t disconnected)
852 DBG("device %p disconnected %d", device, disconnected);
854 if (device->disconnected == disconnected)
857 device->disconnected = disconnected;
859 if (disconnected == TRUE)
861 force_scan_trigger(device);
862 device->backoff_interval = SCAN_INITIAL_DELAY;
869 * connman_device_get_disconnected:
870 * @device: device structure
872 * Get device disconnected state
874 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
876 return device->disconnected;
880 * connman_device_set_string:
881 * @device: device structure
882 * @key: unique identifier
883 * @value: string value
885 * Set string value for specific key
887 int connman_device_set_string(struct connman_device *device,
888 const char *key, const char *value)
890 DBG("device %p key %s value %s", device, key, value);
892 if (g_str_equal(key, "Address") == TRUE) {
893 g_free(device->address);
894 device->address = g_strdup(value);
895 } else if (g_str_equal(key, "Name") == TRUE) {
896 g_free(device->name);
897 device->name = g_strdup(value);
898 } else if (g_str_equal(key, "Node") == TRUE) {
899 g_free(device->node);
900 device->node = g_strdup(value);
901 } else if (g_str_equal(key, "Path") == TRUE) {
902 g_free(device->path);
903 device->path = g_strdup(value);
912 * connman_device_get_string:
913 * @device: device structure
914 * @key: unique identifier
916 * Get string value for specific key
918 const char *connman_device_get_string(struct connman_device *device,
921 DBG("device %p key %s", device, key);
923 if (g_str_equal(key, "Address") == TRUE)
924 return device->address;
925 else if (g_str_equal(key, "Name") == TRUE)
927 else if (g_str_equal(key, "Node") == TRUE)
929 else if (g_str_equal(key, "Interface") == TRUE)
930 return device->interface;
931 else if (g_str_equal(key, "Path") == TRUE)
938 * connman_device_add_network:
939 * @device: device structure
940 * @network: network structure
942 * Add new network to the device
944 int connman_device_add_network(struct connman_device *device,
945 struct connman_network *network)
947 const char *identifier = connman_network_get_identifier(network);
949 DBG("device %p network %p", device, network);
951 if (identifier == NULL)
954 connman_network_ref(network);
956 __connman_network_set_device(network, device);
958 g_hash_table_insert(device->networks, g_strdup(identifier),
965 * connman_device_get_network:
966 * @device: device structure
967 * @identifier: network identifier
969 * Get network for given identifier
971 struct connman_network *connman_device_get_network(struct connman_device *device,
972 const char *identifier)
974 DBG("device %p identifier %s", device, identifier);
976 return g_hash_table_lookup(device->networks, identifier);
980 * connman_device_remove_network:
981 * @device: device structure
982 * @identifier: network identifier
984 * Remove network for given identifier
986 int connman_device_remove_network(struct connman_device *device,
987 struct connman_network *network)
989 const char *identifier;
991 DBG("device %p network %p", device, network);
996 identifier = connman_network_get_identifier(network);
997 g_hash_table_remove(device->networks, identifier);
1002 void connman_device_remove_all_networks(struct connman_device *device)
1004 g_hash_table_remove_all(device->networks);
1007 void __connman_device_set_network(struct connman_device *device,
1008 struct connman_network *network)
1015 if (device->network == network)
1018 if (network != NULL) {
1019 name = connman_network_get_string(network, "Name");
1020 g_free(device->last_network);
1021 device->last_network = g_strdup(name);
1023 device->network = network;
1025 g_free(device->last_network);
1026 device->last_network = NULL;
1028 device->network = NULL;
1032 void __connman_device_set_reconnect(struct connman_device *device,
1033 connman_bool_t reconnect)
1035 device->reconnect = reconnect;
1038 connman_bool_t __connman_device_get_reconnect(
1039 struct connman_device *device)
1041 return device->reconnect;
1044 static gboolean match_driver(struct connman_device *device,
1045 struct connman_device_driver *driver)
1047 if (device->type == driver->type ||
1048 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1055 * connman_device_register:
1056 * @device: device structure
1058 * Register device with the system
1060 int connman_device_register(struct connman_device *device)
1064 DBG("device %p name %s", device, device->name);
1066 if (device->driver != NULL)
1069 for (list = driver_list; list; list = list->next) {
1070 struct connman_device_driver *driver = list->data;
1072 if (match_driver(device, driver) == FALSE)
1075 DBG("driver %p name %s", driver, driver->name);
1077 if (driver->probe(device) == 0) {
1078 device->driver = driver;
1083 if (device->driver == NULL)
1086 return __connman_technology_add_device(device);
1090 * connman_device_unregister:
1091 * @device: device structure
1093 * Unregister device with the system
1095 void connman_device_unregister(struct connman_device *device)
1097 DBG("device %p name %s", device, device->name);
1099 if (device->driver == NULL)
1102 remove_device(device);
1106 * connman_device_get_data:
1107 * @device: device structure
1109 * Get private device data pointer
1111 void *connman_device_get_data(struct connman_device *device)
1113 return device->driver_data;
1117 * connman_device_set_data:
1118 * @device: device structure
1119 * @data: data pointer
1121 * Set private device data pointer
1123 void connman_device_set_data(struct connman_device *device, void *data)
1125 device->driver_data = data;
1128 struct connman_device *__connman_device_find_device(
1129 enum connman_service_type type)
1133 for (list = device_list; list != NULL; list = list->next) {
1134 struct connman_device *device = list->data;
1135 enum connman_service_type service_type =
1136 __connman_device_get_service_type(device);
1138 if (service_type != type)
1147 int __connman_device_request_scan(enum connman_service_type type)
1153 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1154 case CONNMAN_SERVICE_TYPE_SYSTEM:
1155 case CONNMAN_SERVICE_TYPE_ETHERNET:
1156 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1157 case CONNMAN_SERVICE_TYPE_CELLULAR:
1158 case CONNMAN_SERVICE_TYPE_GPS:
1159 case CONNMAN_SERVICE_TYPE_VPN:
1160 case CONNMAN_SERVICE_TYPE_GADGET:
1162 case CONNMAN_SERVICE_TYPE_WIFI:
1163 case CONNMAN_SERVICE_TYPE_WIMAX:
1167 for (list = device_list; list != NULL; list = list->next) {
1168 struct connman_device *device = list->data;
1169 enum connman_service_type service_type =
1170 __connman_device_get_service_type(device);
1172 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1173 service_type != type) {
1177 err = device_scan(device);
1178 if (err < 0 && err != -EINPROGRESS) {
1180 /* XXX maybe only a continue? */
1188 int __connman_device_request_hidden_scan(struct connman_device *device,
1189 const char *ssid, unsigned int ssid_len,
1190 const char *identity, const char *passphrase)
1192 DBG("device %p", device);
1194 if (device == NULL || device->driver == NULL ||
1195 device->driver->scan_hidden == NULL)
1198 if (device->scanning == TRUE)
1201 return device->driver->scan_hidden(device, ssid, ssid_len,
1202 identity, passphrase);
1205 connman_bool_t __connman_device_isfiltered(const char *devname)
1209 if (device_filter == NULL)
1212 for (pattern = device_filter; *pattern; pattern++) {
1213 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1214 DBG("ignoring device %s (match)", devname);
1220 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1221 DBG("ignoring dummy networking devices");
1225 if (nodevice_filter == NULL)
1228 for (pattern = nodevice_filter; *pattern; pattern++) {
1229 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1230 DBG("ignoring device %s (no match)", devname);
1238 int __connman_device_init(const char *device, const char *nodevice)
1243 device_filter = g_strsplit(device, ",", -1);
1245 if (nodevice != NULL)
1246 nodevice_filter = g_strsplit(nodevice, ",", -1);
1251 void __connman_device_cleanup(void)
1255 g_strfreev(nodevice_filter);
1256 g_strfreev(device_filter);