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 /* Reset pending request */
667 g_source_remove(device->pending_timeout);
668 device->pending_timeout = 0;
669 device->powered_pending = PENDING_NONE;
671 device->powered = powered;
673 type = __connman_device_get_service_type(device);
675 if (device->powered == TRUE)
676 __connman_technology_enabled(type);
678 __connman_technology_disabled(type);
680 if (powered == FALSE) {
681 device->connections = 0;
685 connman_device_set_disconnected(device, FALSE);
686 device->scanning = FALSE;
688 reset_scan_trigger(device);
690 if (device->driver && device->driver->scan)
691 device->driver->scan(device);
696 static int device_scan(struct connman_device *device)
698 if (!device->driver || !device->driver->scan)
701 if (device->powered == FALSE)
704 reset_scan_trigger(device);
706 return device->driver->scan(device);
709 int __connman_device_disconnect(struct connman_device *device)
714 DBG("device %p", device);
716 connman_device_set_disconnected(device, TRUE);
718 g_hash_table_iter_init(&iter, device->networks);
720 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
721 struct connman_network *network = value;
723 if (connman_network_get_connecting(network) == TRUE) {
725 * Skip network in the process of connecting.
726 * This is a workaround for WiFi networks serviced
727 * by the supplicant plugin that hold a reference
728 * to the network. If we disconnect the network
729 * here then the referenced object will not be
730 * registered and usage (like launching DHCP client)
731 * will fail. There is nothing to be gained by
732 * removing the network here anyway.
734 connman_warn("Skipping disconnect of %s, network is connecting.",
735 connman_network_get_identifier(network));
739 __connman_network_disconnect(network);
745 static void mark_network_available(gpointer key, gpointer value,
748 struct connman_network *network = value;
750 connman_network_set_available(network, TRUE);
753 static void mark_network_unavailable(gpointer key, gpointer value,
756 struct connman_network *network = value;
758 if (connman_network_get_connected(network) == TRUE)
761 connman_network_set_available(network, FALSE);
764 static gboolean remove_unavailable_network(gpointer key, gpointer value,
767 struct connman_network *network = value;
769 if (connman_network_get_connected(network) == TRUE)
772 if (connman_network_get_available(network) == TRUE)
778 void __connman_device_cleanup_networks(struct connman_device *device)
780 g_hash_table_foreach_remove(device->networks,
781 remove_unavailable_network, NULL);
784 connman_bool_t __connman_device_scanning(struct connman_device *device)
786 return device->scanning;
789 void connman_device_reset_scanning(struct connman_device *device)
791 device->scanning = FALSE;
793 g_hash_table_foreach(device->networks,
794 mark_network_available, NULL);
799 * connman_device_set_scanning:
800 * @device: device structure
801 * @scanning: scanning state
803 * Change scanning state of device
805 int connman_device_set_scanning(struct connman_device *device,
806 connman_bool_t scanning)
808 DBG("device %p scanning %d", device, scanning);
810 if (!device->driver || !device->driver->scan)
813 if (device->scanning == scanning)
816 device->scanning = scanning;
818 if (scanning == TRUE) {
819 reset_scan_trigger(device);
821 g_hash_table_foreach(device->networks,
822 mark_network_unavailable, NULL);
827 __connman_device_cleanup_networks(device);
829 if (device->connections > 0)
832 __connman_service_auto_connect();
838 * connman_device_set_disconnected:
839 * @device: device structure
840 * @disconnected: disconnected state
842 * Change disconnected state of device (only for device with networks)
844 int connman_device_set_disconnected(struct connman_device *device,
845 connman_bool_t disconnected)
847 DBG("device %p disconnected %d", device, disconnected);
849 if (device->disconnected == disconnected)
852 device->disconnected = disconnected;
854 if (disconnected == TRUE)
855 force_scan_trigger(device);
861 * connman_device_get_disconnected:
862 * @device: device structure
864 * Get device disconnected state
866 connman_bool_t connman_device_get_disconnected(struct connman_device *device)
868 return device->disconnected;
872 * connman_device_set_string:
873 * @device: device structure
874 * @key: unique identifier
875 * @value: string value
877 * Set string value for specific key
879 int connman_device_set_string(struct connman_device *device,
880 const char *key, const char *value)
882 DBG("device %p key %s value %s", device, key, value);
884 if (g_str_equal(key, "Address") == TRUE) {
885 g_free(device->address);
886 device->address = g_strdup(value);
887 } else if (g_str_equal(key, "Name") == TRUE) {
888 g_free(device->name);
889 device->name = g_strdup(value);
890 } else if (g_str_equal(key, "Node") == TRUE) {
891 g_free(device->node);
892 device->node = g_strdup(value);
893 } else if (g_str_equal(key, "Path") == TRUE) {
894 g_free(device->path);
895 device->path = g_strdup(value);
904 * connman_device_get_string:
905 * @device: device structure
906 * @key: unique identifier
908 * Get string value for specific key
910 const char *connman_device_get_string(struct connman_device *device,
913 DBG("device %p key %s", device, key);
915 if (g_str_equal(key, "Address") == TRUE)
916 return device->address;
917 else if (g_str_equal(key, "Name") == TRUE)
919 else if (g_str_equal(key, "Node") == TRUE)
921 else if (g_str_equal(key, "Interface") == TRUE)
922 return device->interface;
923 else if (g_str_equal(key, "Path") == TRUE)
929 void __connman_device_increase_connections(struct connman_device *device)
934 device->connections++;
937 void __connman_device_decrease_connections(struct connman_device *device)
942 device->connections--;
944 if (device->connections == 0)
945 device->backoff_interval = SCAN_INITIAL_DELAY;
949 * connman_device_add_network:
950 * @device: device structure
951 * @network: network structure
953 * Add new network to the device
955 int connman_device_add_network(struct connman_device *device,
956 struct connman_network *network)
958 const char *identifier = connman_network_get_identifier(network);
960 DBG("device %p network %p", device, network);
962 if (identifier == NULL)
965 connman_network_ref(network);
967 __connman_network_set_device(network, device);
969 g_hash_table_insert(device->networks, g_strdup(identifier),
976 * connman_device_get_network:
977 * @device: device structure
978 * @identifier: network identifier
980 * Get network for given identifier
982 struct connman_network *connman_device_get_network(struct connman_device *device,
983 const char *identifier)
985 DBG("device %p identifier %s", device, identifier);
987 return g_hash_table_lookup(device->networks, identifier);
991 * connman_device_remove_network:
992 * @device: device structure
993 * @identifier: network identifier
995 * Remove network for given identifier
997 int connman_device_remove_network(struct connman_device *device,
998 struct connman_network *network)
1000 const char *identifier;
1002 DBG("device %p network %p", device, network);
1004 if (network == NULL)
1007 identifier = connman_network_get_identifier(network);
1008 g_hash_table_remove(device->networks, identifier);
1013 void connman_device_remove_all_networks(struct connman_device *device)
1015 g_hash_table_remove_all(device->networks);
1018 void __connman_device_set_network(struct connman_device *device,
1019 struct connman_network *network)
1026 if (device->network == network)
1029 if (network != NULL) {
1030 name = connman_network_get_string(network, "Name");
1031 g_free(device->last_network);
1032 device->last_network = g_strdup(name);
1034 device->network = network;
1036 g_free(device->last_network);
1037 device->last_network = NULL;
1039 device->network = NULL;
1043 void __connman_device_set_reconnect(struct connman_device *device,
1044 connman_bool_t reconnect)
1046 device->reconnect = reconnect;
1049 connman_bool_t __connman_device_get_reconnect(
1050 struct connman_device *device)
1052 return device->reconnect;
1055 static gboolean match_driver(struct connman_device *device,
1056 struct connman_device_driver *driver)
1058 if (device->type == driver->type ||
1059 driver->type == CONNMAN_DEVICE_TYPE_UNKNOWN)
1065 static int device_probe(struct connman_device *device)
1069 DBG("device %p name %s", device, device->name);
1071 if (device->driver != NULL)
1074 for (list = driver_list; list; list = list->next) {
1075 struct connman_device_driver *driver = list->data;
1077 if (match_driver(device, driver) == FALSE)
1080 DBG("driver %p name %s", driver, driver->name);
1082 if (driver->probe(device) == 0) {
1083 device->driver = driver;
1088 if (device->driver == NULL)
1091 return __connman_technology_add_device(device);
1094 static void device_remove(struct connman_device *device)
1096 DBG("device %p name %s", device, device->name);
1098 if (device->driver == NULL)
1101 remove_device(device);
1105 * connman_device_register:
1106 * @device: device structure
1108 * Register device with the system
1110 int connman_device_register(struct connman_device *device)
1112 return device_probe(device);
1116 * connman_device_unregister:
1117 * @device: device structure
1119 * Unregister device with the system
1121 void connman_device_unregister(struct connman_device *device)
1123 device_remove(device);
1127 * connman_device_get_data:
1128 * @device: device structure
1130 * Get private device data pointer
1132 void *connman_device_get_data(struct connman_device *device)
1134 return device->driver_data;
1138 * connman_device_set_data:
1139 * @device: device structure
1140 * @data: data pointer
1142 * Set private device data pointer
1144 void connman_device_set_data(struct connman_device *device, void *data)
1146 device->driver_data = data;
1149 struct connman_device *__connman_device_find_device(
1150 enum connman_service_type type)
1154 for (list = device_list; list != NULL; list = list->next) {
1155 struct connman_device *device = list->data;
1156 enum connman_service_type service_type =
1157 __connman_device_get_service_type(device);
1159 if (service_type != type)
1168 int __connman_device_request_scan(enum connman_service_type type)
1174 case CONNMAN_SERVICE_TYPE_UNKNOWN:
1175 case CONNMAN_SERVICE_TYPE_SYSTEM:
1176 case CONNMAN_SERVICE_TYPE_ETHERNET:
1177 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
1178 case CONNMAN_SERVICE_TYPE_CELLULAR:
1179 case CONNMAN_SERVICE_TYPE_GPS:
1180 case CONNMAN_SERVICE_TYPE_VPN:
1181 case CONNMAN_SERVICE_TYPE_GADGET:
1183 case CONNMAN_SERVICE_TYPE_WIFI:
1184 case CONNMAN_SERVICE_TYPE_WIMAX:
1188 for (list = device_list; list != NULL; list = list->next) {
1189 struct connman_device *device = list->data;
1190 enum connman_service_type service_type =
1191 __connman_device_get_service_type(device);
1193 if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
1194 service_type != type) {
1198 err = device_scan(device);
1199 if (err < 0 && err != -EINPROGRESS) {
1201 /* XXX maybe only a continue? */
1209 connman_bool_t __connman_device_isfiltered(const char *devname)
1213 if (device_filter == NULL)
1216 for (pattern = device_filter; *pattern; pattern++) {
1217 if (g_pattern_match_simple(*pattern, devname) == FALSE) {
1218 DBG("ignoring device %s (match)", devname);
1224 if (g_pattern_match_simple("dummy*", devname) == TRUE) {
1225 DBG("ignoring dummy networking devices");
1229 if (nodevice_filter == NULL)
1232 for (pattern = nodevice_filter; *pattern; pattern++) {
1233 if (g_pattern_match_simple(*pattern, devname) == TRUE) {
1234 DBG("ignoring device %s (no match)", devname);
1242 int __connman_device_init(const char *device, const char *nodevice)
1247 device_filter = g_strsplit(device, ",", -1);
1249 if (nodevice != NULL)
1250 nodevice_filter = g_strsplit(nodevice, ",", -1);
1255 void __connman_device_cleanup(void)
1259 g_strfreev(nodevice_filter);
1260 g_strfreev(device_filter);