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 device->pending_timeout = 0;
225 device->powered_pending = PENDING_NONE;
230 int __connman_device_enable(struct connman_device *device)
234 DBG("device %p", device);
236 if (!device->driver || !device->driver->enable)
239 /* There is an ongoing power disable request. */
240 if (device->powered_pending == PENDING_DISABLE)
243 if (device->powered_pending == PENDING_ENABLE)
246 if (device->powered_pending == PENDING_NONE && device->powered == TRUE)
249 device->powered_pending = PENDING_ENABLE;
251 err = device->driver->enable(device);
253 * device gets enabled right away.
254 * Invoke the callback
257 connman_device_set_powered(device, TRUE);
261 if (err == -EALREADY) {
262 /* If device is already powered, but connman is not updated */
263 connman_device_set_powered(device, TRUE);
267 * if err == -EINPROGRESS, then the DBus call to the respective daemon
268 * was successful. We set a 4 sec timeout so if the daemon never
269 * returns a reply, we would reset the pending request.
271 if (err == -EINPROGRESS)
272 device->pending_timeout = g_timeout_add_seconds(4,
273 device_pending_reset, device);
278 int __connman_device_disable(struct connman_device *device)
282 DBG("device %p", device);
284 if (!device->driver || !device->driver->disable)
287 /* Ongoing power enable request */
288 if (device->powered_pending == PENDING_ENABLE)
291 if (device->powered_pending == PENDING_DISABLE)
294 if (device->powered_pending == PENDING_NONE && device->powered == FALSE)
297 device->powered_pending = PENDING_DISABLE;
298 device->reconnect = FALSE;
300 clear_scan_trigger(device);
302 err = device->driver->disable(device);
304 connman_device_set_powered(device, FALSE);
308 if (err == -EALREADY) {
309 connman_device_set_powered(device, FALSE);
313 if (err == -EINPROGRESS)
314 device->pending_timeout = g_timeout_add_seconds(4,
315 device_pending_reset, device);
320 static void probe_driver(struct connman_device_driver *driver)
324 DBG("driver %p name %s", driver, driver->name);
326 for (list = device_list; list != NULL; list = list->next) {
327 struct connman_device *device = list->data;
329 if (device->driver != NULL)
332 if (driver->type != device->type)
335 if (driver->probe(device) < 0)
338 device->driver = driver;
340 __connman_technology_add_device(device);
344 static void remove_device(struct connman_device *device)
346 DBG("device %p", device);
348 __connman_device_disable(device);
350 __connman_technology_remove_device(device);
352 if (device->driver->remove)
353 device->driver->remove(device);
355 device->driver = NULL;
358 static void remove_driver(struct connman_device_driver *driver)
362 DBG("driver %p name %s", driver, driver->name);
364 for (list = device_list; list != NULL; list = list->next) {
365 struct connman_device *device = list->data;
367 if (device->driver == driver)
368 remove_device(device);
372 connman_bool_t __connman_device_has_driver(struct connman_device *device)
374 if (device == NULL || device->driver == NULL)
380 static GSList *driver_list = NULL;
382 static gint compare_priority(gconstpointer a, gconstpointer b)
384 const struct connman_device_driver *driver1 = a;
385 const struct connman_device_driver *driver2 = b;
387 return driver2->priority - driver1->priority;
391 * connman_device_driver_register:
392 * @driver: device driver definition
394 * Register a new device driver
396 * Returns: %0 on success
398 int connman_device_driver_register(struct connman_device_driver *driver)
400 DBG("driver %p name %s", driver, driver->name);
402 driver_list = g_slist_insert_sorted(driver_list, driver,
404 probe_driver(driver);
410 * connman_device_driver_unregister:
411 * @driver: device driver definition
413 * Remove a previously registered device driver
415 void connman_device_driver_unregister(struct connman_device_driver *driver)
417 DBG("driver %p name %s", driver, driver->name);
419 driver_list = g_slist_remove(driver_list, driver);
421 remove_driver(driver);
424 static void free_network(gpointer data)
426 struct connman_network *network = data;
428 DBG("network %p", network);
430 __connman_network_set_device(network, NULL);
432 connman_network_unref(network);
435 static void device_destruct(struct connman_device *device)
437 DBG("device %p name %s", device, device->name);
439 clear_scan_trigger(device);
441 g_free(device->ident);
442 g_free(device->node);
443 g_free(device->name);
444 g_free(device->address);
445 g_free(device->interface);
446 g_free(device->path);
447 g_free(device->devname);
449 g_free(device->last_network);
451 g_hash_table_destroy(device->networks);
452 device->networks = NULL;
458 * connman_device_create:
459 * @node: device node name (for example an address)
462 * Allocate a new device of given #type and assign the #node name to it.
464 * Returns: a newly-allocated #connman_device structure
466 struct connman_device *connman_device_create(const char *node,
467 enum connman_device_type type)
469 struct connman_device *device;
470 connman_bool_t bg_scan;
472 DBG("node %s type %d", node, type);
474 device = g_try_new0(struct connman_device, 1);
478 DBG("device %p", device);
480 device->refcount = 1;
482 bg_scan = connman_setting_get_bool("BackgroundScanning");
485 device->name = g_strdup(type2description(device->type));
487 device->phyindex = -1;
489 device->backoff_interval = SCAN_INITIAL_DELAY;
492 case CONNMAN_DEVICE_TYPE_UNKNOWN:
493 case CONNMAN_DEVICE_TYPE_ETHERNET:
494 case CONNMAN_DEVICE_TYPE_WIMAX:
495 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
496 case CONNMAN_DEVICE_TYPE_CELLULAR:
497 case CONNMAN_DEVICE_TYPE_GPS:
498 case CONNMAN_DEVICE_TYPE_GADGET:
499 case CONNMAN_DEVICE_TYPE_VENDOR:
500 device->scan_interval = 0;
502 case CONNMAN_DEVICE_TYPE_WIFI:
504 device->scan_interval = 300;
506 device->scan_interval = 0;
510 device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
511 g_free, free_network);
513 device_list = g_slist_append(device_list, device);
519 * connman_device_ref:
520 * @device: device structure
522 * Increase reference counter of device
524 struct connman_device *connman_device_ref(struct connman_device *device)
528 g_atomic_int_inc(&device->refcount);
534 * connman_device_unref:
535 * @device: device structure
537 * Decrease reference counter of device
539 void connman_device_unref(struct connman_device *device)
541 if (g_atomic_int_dec_and_test(&device->refcount) == FALSE)
544 if (device->driver) {
545 device->driver->remove(device);
546 device->driver = NULL;
549 device_list = g_slist_remove(device_list, device);
551 device_destruct(device);
554 const char *__connman_device_get_type(struct connman_device *device)
556 return type2string(device->type);
560 * connman_device_get_type:
561 * @device: device structure
565 enum connman_device_type connman_device_get_type(struct connman_device *device)
571 * connman_device_set_index:
572 * @device: device structure
573 * @index: index number
575 * Set index number of device
577 void connman_device_set_index(struct connman_device *device, int index)
579 device->index = index;
583 * connman_device_get_index:
584 * @device: device structure
586 * Get index number of device
588 int connman_device_get_index(struct connman_device *device)
590 return device->index;
593 int __connman_device_get_phyindex(struct connman_device *device)
595 return device->phyindex;
598 void __connman_device_set_phyindex(struct connman_device *device,
601 device->phyindex = phyindex;
605 * connman_device_set_interface:
606 * @device: device structure
607 * @interface: interface name
609 * Set interface name of device
611 void connman_device_set_interface(struct connman_device *device,
612 const char *interface)
614 g_free(device->devname);
615 device->devname = g_strdup(interface);
617 g_free(device->interface);
618 device->interface = g_strdup(interface);
620 if (device->name == NULL) {
621 const char *str = type2description(device->type);
622 if (str != NULL && device->interface != NULL)
623 device->name = g_strdup_printf("%s (%s)", str,
629 * connman_device_set_ident:
630 * @device: device structure
631 * @ident: unique identifier
633 * Set unique identifier of device
635 void connman_device_set_ident(struct connman_device *device,
638 g_free(device->ident);
639 device->ident = g_strdup(ident);
642 const char *connman_device_get_ident(struct connman_device *device)
644 return device->ident;
648 * connman_device_set_powered:
649 * @device: device structure
650 * @powered: powered state
652 * Change power state of device
654 int connman_device_set_powered(struct connman_device *device,
655 connman_bool_t powered)
657 enum connman_service_type type;
659 DBG("driver %p powered %d", device, powered);
661 if (device->powered == powered)
664 if (device->pending_timeout) {
665 /* Reset pending request */
666 g_source_remove(device->pending_timeout);
667 device->pending_timeout = 0;
670 device->powered_pending = PENDING_NONE;
672 device->powered = powered;
674 type = __connman_device_get_service_type(device);
676 if (device->powered == TRUE)
677 __connman_technology_enabled(type);
679 __connman_technology_disabled(type);
681 if (powered == FALSE) {
682 device->connections = 0;
686 connman_device_set_disconnected(device, FALSE);
687 device->scanning = FALSE;
689 reset_scan_trigger(device);
691 if (device->driver && device->driver->scan)
692 device->driver->scan(device);
697 static int device_scan(struct connman_device *device)
699 if (!device->driver || !device->driver->scan)
702 if (device->powered == FALSE)
705 reset_scan_trigger(device);
707 return device->driver->scan(device);
710 int __connman_device_disconnect(struct connman_device *device)
715 DBG("device %p", device);
717 connman_device_set_disconnected(device, TRUE);
719 g_hash_table_iter_init(&iter, device->networks);
721 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
722 struct connman_network *network = value;
724 if (connman_network_get_connecting(network) == TRUE) {
726 * Skip network in the process of connecting.
727 * This is a workaround for WiFi networks serviced
728 * by the supplicant plugin that hold a reference
729 * to the network. If we disconnect the network
730 * here then the referenced object will not be
731 * registered and usage (like launching DHCP client)
732 * will fail. There is nothing to be gained by
733 * removing the network here anyway.
735 connman_warn("Skipping disconnect of %s, network is connecting.",
736 connman_network_get_identifier(network));
740 __connman_network_disconnect(network);
746 static void mark_network_available(gpointer key, gpointer value,
749 struct connman_network *network = value;
751 connman_network_set_available(network, TRUE);
754 static void mark_network_unavailable(gpointer key, gpointer value,
757 struct connman_network *network = value;
759 if (connman_network_get_connected(network) == TRUE)
762 connman_network_set_available(network, FALSE);
765 static gboolean remove_unavailable_network(gpointer key, gpointer value,
768 struct connman_network *network = value;
770 if (connman_network_get_connected(network) == TRUE)
773 if (connman_network_get_available(network) == TRUE)
779 void __connman_device_cleanup_networks(struct connman_device *device)
781 g_hash_table_foreach_remove(device->networks,
782 remove_unavailable_network, NULL);
785 connman_bool_t __connman_device_scanning(struct connman_device *device)
787 return device->scanning;
790 void connman_device_reset_scanning(struct connman_device *device)
792 device->scanning = FALSE;
794 g_hash_table_foreach(device->networks,
795 mark_network_available, NULL);
800 * connman_device_set_scanning:
801 * @device: device structure
802 * @scanning: scanning state
804 * Change scanning state of device
806 int connman_device_set_scanning(struct connman_device *device,
807 connman_bool_t scanning)
809 DBG("device %p scanning %d", device, scanning);
811 if (!device->driver || !device->driver->scan)
814 if (device->scanning == scanning)
817 device->scanning = scanning;
819 if (scanning == TRUE) {
820 reset_scan_trigger(device);
822 g_hash_table_foreach(device->networks,
823 mark_network_unavailable, NULL);
828 __connman_device_cleanup_networks(device);
830 if (device->connections > 0)
833 __connman_service_auto_connect();
839 * connman_device_set_disconnected:
840 * @device: device structure
841 * @disconnected: disconnected state
843 * Change disconnected state of device (only for device with networks)
845 int connman_device_set_disconnected(struct connman_device *device,
846 connman_bool_t disconnected)
848 DBG("device %p disconnected %d", device, disconnected);
850 if (device->disconnected == disconnected)
853 device->disconnected = disconnected;
855 if (disconnected == TRUE)
856 force_scan_trigger(device);
862 * connman_device_get_disconnected:
863 * @device: device structure
865 * Get device disconnected state
867 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
869 return device->disconnected;
873 * connman_device_set_string:
874 * @device: device structure
875 * @key: unique identifier
876 * @value: string value
878 * Set string value for specific key
880 int connman_device_set_string(struct connman_device *device,
881 const char *key, const char *value)
883 DBG("device %p key %s value %s", device, key, value);
885 if (g_str_equal(key, "Address") == TRUE) {
886 g_free(device->address);
887 device->address = g_strdup(value);
888 } else if (g_str_equal(key, "Name") == TRUE) {
889 g_free(device->name);
890 device->name = g_strdup(value);
891 } else if (g_str_equal(key, "Node") == TRUE) {
892 g_free(device->node);
893 device->node = g_strdup(value);
894 } else if (g_str_equal(key, "Path") == TRUE) {
895 g_free(device->path);
896 device->path = g_strdup(value);
905 * connman_device_get_string:
906 * @device: device structure
907 * @key: unique identifier
909 * Get string value for specific key
911 const char *connman_device_get_string(struct connman_device *device,
914 DBG("device %p key %s", device, key);
916 if (g_str_equal(key, "Address") == TRUE)
917 return device->address;
918 else if (g_str_equal(key, "Name") == TRUE)
920 else if (g_str_equal(key, "Node") == TRUE)
922 else if (g_str_equal(key, "Interface") == TRUE)
923 return device->interface;
924 else if (g_str_equal(key, "Path") == TRUE)
930 void __connman_device_increase_connections(struct connman_device *device)
935 device->connections++;
938 void __connman_device_decrease_connections(struct connman_device *device)
943 device->connections--;
945 if (device->connections == 0)
946 device->backoff_interval = SCAN_INITIAL_DELAY;
950 * connman_device_add_network:
951 * @device: device structure
952 * @network: network structure
954 * Add new network to the device
956 int connman_device_add_network(struct connman_device *device,
957 struct connman_network *network)
959 const char *identifier = connman_network_get_identifier(network);
961 DBG("device %p network %p", device, network);
963 if (identifier == NULL)
966 connman_network_ref(network);
968 __connman_network_set_device(network, device);
970 g_hash_table_insert(device->networks, g_strdup(identifier),
977 * connman_device_get_network:
978 * @device: device structure
979 * @identifier: network identifier
981 * Get network for given identifier
983 struct connman_network *connman_device_get_network(struct connman_device *device,
984 const char *identifier)
986 DBG("device %p identifier %s", device, identifier);
988 return g_hash_table_lookup(device->networks, identifier);
992 * connman_device_remove_network:
993 * @device: device structure
994 * @identifier: network identifier
996 * Remove network for given identifier
998 int connman_device_remove_network(struct connman_device *device,
999 struct connman_network *network)
1001 const char *identifier;
1003 DBG("device %p network %p", device, network);
1005 if (network == NULL)
1008 identifier = connman_network_get_identifier(network);
1009 g_hash_table_remove(device->networks, identifier);
1014 void connman_device_remove_all_networks(struct connman_device *device)
1016 g_hash_table_remove_all(device->networks);
1019 void __connman_device_set_network(struct connman_device *device,
1020 struct connman_network *network)
1027 if (device->network == network)
1030 if (network != NULL) {
1031 name = connman_network_get_string(network, "Name");
1032 g_free(device->last_network);
1033 device->last_network = g_strdup(name);
1035 device->network = network;
1037 g_free(device->last_network);
1038 device->last_network = NULL;
1040 device->network = NULL;
1044 void __connman_device_set_reconnect(struct connman_device *device,
1045 connman_bool_t reconnect)
1047 device->reconnect = reconnect;
1050 connman_bool_t __connman_device_get_reconnect(
1051 struct connman_device *device)
1053 return device->reconnect;
1056 static gboolean match_driver(struct connman_device *device,
1057 struct connman_device_driver *driver)
1059 if (device->type == driver->type ||
1060 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1066 static int device_probe(struct connman_device *device)
1070 DBG("device %p name %s", device, device->name);
1072 if (device->driver != NULL)
1075 for (list = driver_list; list; list = list->next) {
1076 struct connman_device_driver *driver = list->data;
1078 if (match_driver(device, driver) == FALSE)
1081 DBG("driver %p name %s", driver, driver->name);
1083 if (driver->probe(device) == 0) {
1084 device->driver = driver;
1089 if (device->driver == NULL)
1092 return __connman_technology_add_device(device);
1095 static void device_remove(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_register:
1107 * @device: device structure
1109 * Register device with the system
1111 int connman_device_register(struct connman_device *device)
1113 return device_probe(device);
1117 * connman_device_unregister:
1118 * @device: device structure
1120 * Unregister device with the system
1122 void connman_device_unregister(struct connman_device *device)
1124 device_remove(device);
1128 * connman_device_get_data:
1129 * @device: device structure
1131 * Get private device data pointer
1133 void *connman_device_get_data(struct connman_device *device)
1135 return device->driver_data;
1139 * connman_device_set_data:
1140 * @device: device structure
1141 * @data: data pointer
1143 * Set private device data pointer
1145 void connman_device_set_data(struct connman_device *device, void *data)
1147 device->driver_data = data;
1150 struct connman_device *__connman_device_find_device(
1151 enum connman_service_type type)
1155 for (list = device_list; list != NULL; list = list->next) {
1156 struct connman_device *device = list->data;
1157 enum connman_service_type service_type =
1158 __connman_device_get_service_type(device);
1160 if (service_type != type)
1169 int __connman_device_request_scan(enum connman_service_type type)
1175 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1176 case CONNMAN_SERVICE_TYPE_SYSTEM:
1177 case CONNMAN_SERVICE_TYPE_ETHERNET:
1178 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1179 case CONNMAN_SERVICE_TYPE_CELLULAR:
1180 case CONNMAN_SERVICE_TYPE_GPS:
1181 case CONNMAN_SERVICE_TYPE_VPN:
1182 case CONNMAN_SERVICE_TYPE_GADGET:
1184 case CONNMAN_SERVICE_TYPE_WIFI:
1185 case CONNMAN_SERVICE_TYPE_WIMAX:
1189 for (list = device_list; list != NULL; list = list->next) {
1190 struct connman_device *device = list->data;
1191 enum connman_service_type service_type =
1192 __connman_device_get_service_type(device);
1194 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1195 service_type != type) {
1199 err = device_scan(device);
1200 if (err < 0 && err != -EINPROGRESS) {
1202 /* XXX maybe only a continue? */
1210 connman_bool_t __connman_device_isfiltered(const char *devname)
1214 if (device_filter == NULL)
1217 for (pattern = device_filter; *pattern; pattern++) {
1218 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1219 DBG("ignoring device %s (match)", devname);
1225 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1226 DBG("ignoring dummy networking devices");
1230 if (nodevice_filter == NULL)
1233 for (pattern = nodevice_filter; *pattern; pattern++) {
1234 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1235 DBG("ignoring device %s (no match)", devname);
1243 int __connman_device_init(const char *device, const char *nodevice)
1248 device_filter = g_strsplit(device, ",", -1);
1250 if (nodevice != NULL)
1251 nodevice_filter = g_strsplit(nodevice, ",", -1);
1256 void __connman_device_cleanup(void)
1260 g_strfreev(nodevice_filter);
1261 g_strfreev(device_filter);