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;
61 unsigned int connections;
63 guint pending_timeout;
65 struct connman_device_driver *driver;
69 struct connman_network *network;
73 #define SCAN_INITIAL_DELAY 10
75 static gboolean device_scan_trigger(gpointer user_data)
77 struct connman_device *device = user_data;
79 DBG("device %p", device);
81 if (device->driver == NULL) {
82 device->scan_timeout = 0;
86 if (device->driver->scan)
87 device->driver->scan(device);
92 static void clear_scan_trigger(struct connman_device *device)
94 if (device->scan_timeout > 0) {
95 g_source_remove(device->scan_timeout);
96 device->scan_timeout = 0;
100 static void reset_scan_trigger(struct connman_device *device)
102 clear_scan_trigger(device);
104 if (device->scan_interval > 0) {
107 if (g_hash_table_size(device->networks) == 0) {
108 if (device->backoff_interval >= device->scan_interval)
109 device->backoff_interval = SCAN_INITIAL_DELAY;
110 interval = device->backoff_interval;
112 interval = device->scan_interval;
114 DBG("interval %d", interval);
116 device->scan_timeout = g_timeout_add_seconds(interval,
117 device_scan_trigger, device);
119 device->backoff_interval *= 2;
120 if (device->backoff_interval > device->scan_interval)
121 device->backoff_interval = device->scan_interval;
125 static void force_scan_trigger(struct connman_device *device)
127 clear_scan_trigger(device);
129 device->scan_timeout = g_timeout_add_seconds(5,
130 device_scan_trigger, device);
133 void connman_device_schedule_scan(struct connman_device *device)
135 reset_scan_trigger(device);
138 static const char *type2description(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 static const char *type2string(enum connman_device_type type)
167 case CONNMAN_DEVICE_TYPE_UNKNOWN:
168 case CONNMAN_DEVICE_TYPE_VENDOR:
170 case CONNMAN_DEVICE_TYPE_ETHERNET:
172 case CONNMAN_DEVICE_TYPE_WIFI:
174 case CONNMAN_DEVICE_TYPE_WIMAX:
176 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
178 case CONNMAN_DEVICE_TYPE_GPS:
180 case CONNMAN_DEVICE_TYPE_CELLULAR:
182 case CONNMAN_DEVICE_TYPE_GADGET:
190 enum connman_service_type __connman_device_get_service_type(struct connman_device *device)
192 enum connman_device_type type = connman_device_get_type(device);
195 case CONNMAN_DEVICE_TYPE_UNKNOWN:
196 case CONNMAN_DEVICE_TYPE_VENDOR:
197 case CONNMAN_DEVICE_TYPE_GPS:
199 case CONNMAN_DEVICE_TYPE_ETHERNET:
200 return CONNMAN_SERVICE_TYPE_ETHERNET;
201 case CONNMAN_DEVICE_TYPE_WIFI:
202 return CONNMAN_SERVICE_TYPE_WIFI;
203 case CONNMAN_DEVICE_TYPE_WIMAX:
204 return CONNMAN_SERVICE_TYPE_WIMAX;
205 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
206 return CONNMAN_SERVICE_TYPE_BLUETOOTH;
207 case CONNMAN_DEVICE_TYPE_CELLULAR:
208 return CONNMAN_SERVICE_TYPE_CELLULAR;
209 case CONNMAN_DEVICE_TYPE_GADGET:
210 return CONNMAN_SERVICE_TYPE_GADGET;
214 return CONNMAN_SERVICE_TYPE_UNKNOWN;
217 static gboolean device_pending_reset(gpointer user_data)
219 struct connman_device *device = user_data;
221 DBG("device %p", device);
223 /* Power request timedout, reset power pending state. */
224 if (device->pending_timeout > 0) {
225 g_source_remove(device->pending_timeout);
226 device->pending_timeout = 0;
227 device->powered_pending = PENDING_NONE;
233 int __connman_device_enable(struct connman_device *device)
237 DBG("device %p", device);
239 if (!device->driver || !device->driver->enable)
242 /* There is an ongoing power disable request. */
243 if (device->powered_pending == PENDING_DISABLE)
246 if (device->powered_pending == PENDING_ENABLE)
249 if (device->powered_pending == PENDING_NONE && device->powered == TRUE)
252 device->powered_pending = PENDING_ENABLE;
254 err = device->driver->enable(device);
256 * device gets enabled right away.
257 * Invoke the callback
260 connman_device_set_powered(device, TRUE);
264 if (err == -EALREADY) {
265 /* If device is already powered, but connman is not updated */
266 connman_device_set_powered(device, TRUE);
270 * if err == -EINPROGRESS, then the DBus call to the respective daemon
271 * was successful. We set a 4 sec timeout so if the daemon never
272 * returns a reply, we would reset the pending request.
274 if (err == -EINPROGRESS)
275 device->pending_timeout = g_timeout_add_seconds(4,
276 device_pending_reset, device);
281 int __connman_device_disable(struct connman_device *device)
285 DBG("device %p", device);
287 if (!device->driver || !device->driver->disable)
290 /* Ongoing power enable request */
291 if (device->powered_pending == PENDING_ENABLE)
294 if (device->powered_pending == PENDING_DISABLE)
297 if (device->powered_pending == PENDING_NONE && device->powered == FALSE)
300 device->reconnect = FALSE;
302 clear_scan_trigger(device);
304 err = device->driver->disable(device);
306 connman_device_set_powered(device, FALSE);
310 if (err == -EALREADY) {
311 connman_device_set_powered(device, FALSE);
315 if (err == -EINPROGRESS)
316 device->pending_timeout = g_timeout_add_seconds(4,
317 device_pending_reset, device);
322 static void probe_driver(struct connman_device_driver *driver)
326 DBG("driver %p name %s", driver, driver->name);
328 for (list = device_list; list != NULL; list = list->next) {
329 struct connman_device *device = list->data;
331 if (device->driver != NULL)
334 if (driver->type != device->type)
337 if (driver->probe(device) < 0)
340 device->driver = driver;
342 __connman_technology_add_device(device);
346 static void remove_device(struct connman_device *device)
348 DBG("device %p", device);
350 __connman_device_disable(device);
352 __connman_technology_remove_device(device);
354 if (device->driver->remove)
355 device->driver->remove(device);
357 device->driver = NULL;
360 static void remove_driver(struct connman_device_driver *driver)
364 DBG("driver %p name %s", driver, driver->name);
366 for (list = device_list; list != NULL; list = list->next) {
367 struct connman_device *device = list->data;
369 if (device->driver == driver)
370 remove_device(device);
374 connman_bool_t __connman_device_has_driver(struct connman_device *device)
376 if (device == NULL || device->driver == NULL)
382 static GSList *driver_list = NULL;
384 static gint compare_priority(gconstpointer a, gconstpointer b)
386 const struct connman_device_driver *driver1 = a;
387 const struct connman_device_driver *driver2 = b;
389 return driver2->priority - driver1->priority;
393 * connman_device_driver_register:
394 * @driver: device driver definition
396 * Register a new device driver
398 * Returns: %0 on success
400 int connman_device_driver_register(struct connman_device_driver *driver)
402 DBG("driver %p name %s", driver, driver->name);
404 driver_list = g_slist_insert_sorted(driver_list, driver,
406 probe_driver(driver);
412 * connman_device_driver_unregister:
413 * @driver: device driver definition
415 * Remove a previously registered device driver
417 void connman_device_driver_unregister(struct connman_device_driver *driver)
419 DBG("driver %p name %s", driver, driver->name);
421 driver_list = g_slist_remove(driver_list, driver);
423 remove_driver(driver);
426 static void free_network(gpointer data)
428 struct connman_network *network = data;
430 DBG("network %p", network);
432 __connman_network_set_device(network, NULL);
434 connman_network_unref(network);
437 static void device_destruct(struct connman_device *device)
439 DBG("device %p name %s", device, device->name);
441 clear_scan_trigger(device);
443 g_free(device->ident);
444 g_free(device->node);
445 g_free(device->name);
446 g_free(device->address);
447 g_free(device->interface);
448 g_free(device->path);
449 g_free(device->devname);
451 g_free(device->last_network);
453 g_hash_table_destroy(device->networks);
454 device->networks = NULL;
460 * connman_device_create:
461 * @node: device node name (for example an address)
464 * Allocate a new device of given #type and assign the #node name to it.
466 * Returns: a newly-allocated #connman_device structure
468 struct connman_device *connman_device_create(const char *node,
469 enum connman_device_type type)
471 struct connman_device *device;
472 connman_bool_t bg_scan;
474 DBG("node %s type %d", node, type);
476 device = g_try_new0(struct connman_device, 1);
480 DBG("device %p", device);
482 device->refcount = 1;
484 bg_scan = connman_setting_get_bool("BackgroundScanning");
487 device->name = g_strdup(type2description(device->type));
489 device->phyindex = -1;
491 device->backoff_interval = SCAN_INITIAL_DELAY;
494 case CONNMAN_DEVICE_TYPE_UNKNOWN:
495 case CONNMAN_DEVICE_TYPE_ETHERNET:
496 case CONNMAN_DEVICE_TYPE_WIMAX:
497 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
498 case CONNMAN_DEVICE_TYPE_CELLULAR:
499 case CONNMAN_DEVICE_TYPE_GPS:
500 case CONNMAN_DEVICE_TYPE_GADGET:
501 case CONNMAN_DEVICE_TYPE_VENDOR:
502 device->scan_interval = 0;
504 case CONNMAN_DEVICE_TYPE_WIFI:
506 device->scan_interval = 300;
508 device->scan_interval = 0;
512 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
513 g_free, free_network);
515 device_list = g_slist_append(device_list, device);
521 * connman_device_ref:
522 * @device: device structure
524 * Increase reference counter of device
526 struct connman_device *connman_device_ref(struct connman_device *device)
530 g_atomic_int_inc(&device->refcount);
536 * connman_device_unref:
537 * @device: device structure
539 * Decrease reference counter of device
541 void connman_device_unref(struct connman_device *device)
543 if (g_atomic_int_dec_and_test(&device->refcount) == FALSE)
546 if (device->driver) {
547 device->driver->remove(device);
548 device->driver = NULL;
551 device_list = g_slist_remove(device_list, device);
553 device_destruct(device);
556 const char *__connman_device_get_type(struct connman_device *device)
558 return type2string(device->type);
562 * connman_device_get_type:
563 * @device: device structure
567 enum connman_device_type connman_device_get_type(struct connman_device *device)
573 * connman_device_set_index:
574 * @device: device structure
575 * @index: index number
577 * Set index number of device
579 void connman_device_set_index(struct connman_device *device, int index)
581 device->index = index;
585 * connman_device_get_index:
586 * @device: device structure
588 * Get index number of device
590 int connman_device_get_index(struct connman_device *device)
592 return device->index;
595 int __connman_device_get_phyindex(struct connman_device *device)
597 return device->phyindex;
600 void __connman_device_set_phyindex(struct connman_device *device,
603 device->phyindex = phyindex;
607 * connman_device_set_interface:
608 * @device: device structure
609 * @interface: interface name
611 * Set interface name of device
613 void connman_device_set_interface(struct connman_device *device,
614 const char *interface)
616 g_free(device->devname);
617 device->devname = g_strdup(interface);
619 g_free(device->interface);
620 device->interface = g_strdup(interface);
622 if (device->name == NULL) {
623 const char *str = type2description(device->type);
624 if (str != NULL && device->interface != NULL)
625 device->name = g_strdup_printf("%s (%s)", str,
631 * connman_device_set_ident:
632 * @device: device structure
633 * @ident: unique identifier
635 * Set unique identifier of device
637 void connman_device_set_ident(struct connman_device *device,
640 g_free(device->ident);
641 device->ident = g_strdup(ident);
644 const char *connman_device_get_ident(struct connman_device *device)
646 return device->ident;
650 * connman_device_set_powered:
651 * @device: device structure
652 * @powered: powered state
654 * Change power state of device
656 int connman_device_set_powered(struct connman_device *device,
657 connman_bool_t powered)
659 enum connman_service_type type;
661 DBG("driver %p powered %d", device, powered);
663 if (device->powered == powered)
666 if (device->pending_timeout) {
667 /* Reset pending request */
668 g_source_remove(device->pending_timeout);
669 device->pending_timeout = 0;
672 device->powered_pending = PENDING_NONE;
674 device->powered = powered;
676 type = __connman_device_get_service_type(device);
678 if (device->powered == TRUE)
679 __connman_technology_enabled(type);
681 __connman_technology_disabled(type);
683 if (powered == FALSE) {
684 device->connections = 0;
688 connman_device_set_disconnected(device, FALSE);
689 device->scanning = FALSE;
691 reset_scan_trigger(device);
693 if (device->driver && device->driver->scan)
694 device->driver->scan(device);
699 static int device_scan(struct connman_device *device)
701 if (!device->driver || !device->driver->scan)
704 if (device->powered == FALSE)
707 reset_scan_trigger(device);
709 return device->driver->scan(device);
712 int __connman_device_disconnect(struct connman_device *device)
717 DBG("device %p", device);
719 connman_device_set_disconnected(device, TRUE);
721 g_hash_table_iter_init(&iter, device->networks);
723 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
724 struct connman_network *network = value;
726 if (connman_network_get_connecting(network) == TRUE) {
728 * Skip network in the process of connecting.
729 * This is a workaround for WiFi networks serviced
730 * by the supplicant plugin that hold a reference
731 * to the network. If we disconnect the network
732 * here then the referenced object will not be
733 * registered and usage (like launching DHCP client)
734 * will fail. There is nothing to be gained by
735 * removing the network here anyway.
737 connman_warn("Skipping disconnect of %s, network is connecting.",
738 connman_network_get_identifier(network));
742 __connman_network_disconnect(network);
748 static void mark_network_available(gpointer key, gpointer value,
751 struct connman_network *network = value;
753 connman_network_set_available(network, TRUE);
756 static void mark_network_unavailable(gpointer key, gpointer value,
759 struct connman_network *network = value;
761 if (connman_network_get_connected(network) == TRUE)
764 connman_network_set_available(network, FALSE);
767 static gboolean remove_unavailable_network(gpointer key, gpointer value,
770 struct connman_network *network = value;
772 if (connman_network_get_connected(network) == TRUE)
775 if (connman_network_get_available(network) == TRUE)
781 void __connman_device_cleanup_networks(struct connman_device *device)
783 g_hash_table_foreach_remove(device->networks,
784 remove_unavailable_network, NULL);
787 connman_bool_t __connman_device_scanning(struct connman_device *device)
789 return device->scanning;
792 void connman_device_reset_scanning(struct connman_device *device)
794 device->scanning = FALSE;
796 g_hash_table_foreach(device->networks,
797 mark_network_available, NULL);
802 * connman_device_set_scanning:
803 * @device: device structure
804 * @scanning: scanning state
806 * Change scanning state of device
808 int connman_device_set_scanning(struct connman_device *device,
809 connman_bool_t scanning)
811 DBG("device %p scanning %d", device, scanning);
813 if (!device->driver || !device->driver->scan)
816 if (device->scanning == scanning)
819 device->scanning = scanning;
821 if (scanning == TRUE) {
822 reset_scan_trigger(device);
824 g_hash_table_foreach(device->networks,
825 mark_network_unavailable, NULL);
830 __connman_device_cleanup_networks(device);
832 if (device->connections > 0)
835 __connman_service_auto_connect();
841 * connman_device_set_disconnected:
842 * @device: device structure
843 * @disconnected: disconnected state
845 * Change disconnected state of device (only for device with networks)
847 int connman_device_set_disconnected(struct connman_device *device,
848 connman_bool_t disconnected)
850 DBG("device %p disconnected %d", device, disconnected);
852 if (device->disconnected == disconnected)
855 device->disconnected = disconnected;
857 if (disconnected == TRUE)
858 force_scan_trigger(device);
864 * connman_device_get_disconnected:
865 * @device: device structure
867 * Get device disconnected state
869 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
871 return device->disconnected;
875 * connman_device_set_string:
876 * @device: device structure
877 * @key: unique identifier
878 * @value: string value
880 * Set string value for specific key
882 int connman_device_set_string(struct connman_device *device,
883 const char *key, const char *value)
885 DBG("device %p key %s value %s", device, key, value);
887 if (g_str_equal(key, "Address") == TRUE) {
888 g_free(device->address);
889 device->address = g_strdup(value);
890 } else if (g_str_equal(key, "Name") == TRUE) {
891 g_free(device->name);
892 device->name = g_strdup(value);
893 } else if (g_str_equal(key, "Node") == TRUE) {
894 g_free(device->node);
895 device->node = g_strdup(value);
896 } else if (g_str_equal(key, "Path") == TRUE) {
897 g_free(device->path);
898 device->path = g_strdup(value);
907 * connman_device_get_string:
908 * @device: device structure
909 * @key: unique identifier
911 * Get string value for specific key
913 const char *connman_device_get_string(struct connman_device *device,
916 DBG("device %p key %s", device, key);
918 if (g_str_equal(key, "Address") == TRUE)
919 return device->address;
920 else if (g_str_equal(key, "Name") == TRUE)
922 else if (g_str_equal(key, "Node") == TRUE)
924 else if (g_str_equal(key, "Interface") == TRUE)
925 return device->interface;
926 else if (g_str_equal(key, "Path") == TRUE)
932 void __connman_device_increase_connections(struct connman_device *device)
937 device->connections++;
940 void __connman_device_decrease_connections(struct connman_device *device)
945 device->connections--;
947 if (device->connections == 0)
948 device->backoff_interval = SCAN_INITIAL_DELAY;
952 * connman_device_add_network:
953 * @device: device structure
954 * @network: network structure
956 * Add new network to the device
958 int connman_device_add_network(struct connman_device *device,
959 struct connman_network *network)
961 const char *identifier = connman_network_get_identifier(network);
963 DBG("device %p network %p", device, network);
965 if (identifier == NULL)
968 connman_network_ref(network);
970 __connman_network_set_device(network, device);
972 g_hash_table_insert(device->networks, g_strdup(identifier),
979 * connman_device_get_network:
980 * @device: device structure
981 * @identifier: network identifier
983 * Get network for given identifier
985 struct connman_network *connman_device_get_network(struct connman_device *device,
986 const char *identifier)
988 DBG("device %p identifier %s", device, identifier);
990 return g_hash_table_lookup(device->networks, identifier);
994 * connman_device_remove_network:
995 * @device: device structure
996 * @identifier: network identifier
998 * Remove network for given identifier
1000 int connman_device_remove_network(struct connman_device *device,
1001 struct connman_network *network)
1003 const char *identifier;
1005 DBG("device %p network %p", device, network);
1007 if (network == NULL)
1010 identifier = connman_network_get_identifier(network);
1011 g_hash_table_remove(device->networks, identifier);
1016 void connman_device_remove_all_networks(struct connman_device *device)
1018 g_hash_table_remove_all(device->networks);
1021 void __connman_device_set_network(struct connman_device *device,
1022 struct connman_network *network)
1029 if (device->network == network)
1032 if (network != NULL) {
1033 name = connman_network_get_string(network, "Name");
1034 g_free(device->last_network);
1035 device->last_network = g_strdup(name);
1037 device->network = network;
1039 g_free(device->last_network);
1040 device->last_network = NULL;
1042 device->network = NULL;
1046 void __connman_device_set_reconnect(struct connman_device *device,
1047 connman_bool_t reconnect)
1049 device->reconnect = reconnect;
1052 connman_bool_t __connman_device_get_reconnect(
1053 struct connman_device *device)
1055 return device->reconnect;
1058 static gboolean match_driver(struct connman_device *device,
1059 struct connman_device_driver *driver)
1061 if (device->type == driver->type ||
1062 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1068 static int device_probe(struct connman_device *device)
1072 DBG("device %p name %s", device, device->name);
1074 if (device->driver != NULL)
1077 for (list = driver_list; list; list = list->next) {
1078 struct connman_device_driver *driver = list->data;
1080 if (match_driver(device, driver) == FALSE)
1083 DBG("driver %p name %s", driver, driver->name);
1085 if (driver->probe(device) == 0) {
1086 device->driver = driver;
1091 if (device->driver == NULL)
1094 return __connman_technology_add_device(device);
1097 static void device_remove(struct connman_device *device)
1099 DBG("device %p name %s", device, device->name);
1101 if (device->driver == NULL)
1104 remove_device(device);
1108 * connman_device_register:
1109 * @device: device structure
1111 * Register device with the system
1113 int connman_device_register(struct connman_device *device)
1115 return device_probe(device);
1119 * connman_device_unregister:
1120 * @device: device structure
1122 * Unregister device with the system
1124 void connman_device_unregister(struct connman_device *device)
1126 device_remove(device);
1130 * connman_device_get_data:
1131 * @device: device structure
1133 * Get private device data pointer
1135 void *connman_device_get_data(struct connman_device *device)
1137 return device->driver_data;
1141 * connman_device_set_data:
1142 * @device: device structure
1143 * @data: data pointer
1145 * Set private device data pointer
1147 void connman_device_set_data(struct connman_device *device, void *data)
1149 device->driver_data = data;
1152 struct connman_device *__connman_device_find_device(
1153 enum connman_service_type type)
1157 for (list = device_list; list != NULL; list = list->next) {
1158 struct connman_device *device = list->data;
1159 enum connman_service_type service_type =
1160 __connman_device_get_service_type(device);
1162 if (service_type != type)
1171 int __connman_device_request_scan(enum connman_service_type type)
1177 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1178 case CONNMAN_SERVICE_TYPE_SYSTEM:
1179 case CONNMAN_SERVICE_TYPE_ETHERNET:
1180 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1181 case CONNMAN_SERVICE_TYPE_CELLULAR:
1182 case CONNMAN_SERVICE_TYPE_GPS:
1183 case CONNMAN_SERVICE_TYPE_VPN:
1184 case CONNMAN_SERVICE_TYPE_GADGET:
1186 case CONNMAN_SERVICE_TYPE_WIFI:
1187 case CONNMAN_SERVICE_TYPE_WIMAX:
1191 for (list = device_list; list != NULL; list = list->next) {
1192 struct connman_device *device = list->data;
1193 enum connman_service_type service_type =
1194 __connman_device_get_service_type(device);
1196 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1197 service_type != type) {
1201 err = device_scan(device);
1202 if (err < 0 && err != -EINPROGRESS) {
1204 /* XXX maybe only a continue? */
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);