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