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
30 static GSList *device_list = NULL;
32 static struct connman_device *find_device(int index)
36 for (list = device_list; list; list = list->next) {
37 struct connman_device *device = list->data;
39 if (connman_device_get_index(device) == index)
46 static void detect_newlink(unsigned short type, int index,
47 unsigned flags, unsigned change)
49 struct connman_device *device;
50 enum connman_device_type devtype;
52 DBG("type %d index %d", type, index);
54 devtype = __connman_inet_get_device_type(index);
57 case CONNMAN_DEVICE_TYPE_UNKNOWN:
58 case CONNMAN_DEVICE_TYPE_VENDOR:
59 case CONNMAN_DEVICE_TYPE_WIMAX:
60 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
61 case CONNMAN_DEVICE_TYPE_CELLULAR:
62 case CONNMAN_DEVICE_TYPE_GPS:
64 case CONNMAN_DEVICE_TYPE_ETHERNET:
65 case CONNMAN_DEVICE_TYPE_WIFI:
66 case CONNMAN_DEVICE_TYPE_MBM:
67 case CONNMAN_DEVICE_TYPE_HSO:
71 device = find_device(index);
75 device = connman_inet_create_device(index);
79 if (connman_device_register(device) < 0) {
80 connman_device_unref(device);
84 device_list = g_slist_append(device_list, device);
87 static void detect_dellink(unsigned short type, int index,
88 unsigned flags, unsigned change)
90 struct connman_device *device;
92 DBG("type %d index %d", type, index);
94 device = find_device(index);
98 device_list = g_slist_remove(device_list, device);
100 connman_device_unregister(device);
101 connman_device_unref(device);
104 static struct connman_rtnl detect_rtnl = {
106 .priority = CONNMAN_RTNL_PRIORITY_LOW,
107 .newlink = detect_newlink,
108 .dellink = detect_dellink,
111 void __connman_udev_enable_rfkill_processing(void)
115 char *__connman_udev_get_devtype(const char *ifname)
120 char *__connman_udev_get_mbm_devnode(const char *ifname)
125 void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked)
127 DBG("sysname %s blocked %d", sysname, blocked);
130 int __connman_udev_init(void)
134 return connman_rtnl_register(&detect_rtnl);
137 void __connman_udev_start(void)
142 void __connman_udev_cleanup(void)
148 connman_rtnl_unregister(&detect_rtnl);
150 for (list = device_list; list; list = list->next) {
151 struct connman_device *device = list->data;
153 connman_device_unregister(device);
154 connman_device_unref(device);
157 g_slist_free(device_list);