5 * Copyright (C) 2007-2009 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
26 #include <dbus/dbus.h>
28 #define CONNMAN_API_SUBJECT_TO_CHANGE
29 #include <connman/plugin.h>
30 #include <connman/device.h>
31 #include <connman/log.h>
34 #include "supplicant.h"
36 #define CLEANUP_TIMEOUT 8 /* in seconds */
37 #define INACTIVE_TIMEOUT 12 /* in seconds */
41 connman_bool_t connected;
44 static int network_probe(struct connman_network *network)
46 DBG("network %p", network);
51 static void network_remove(struct connman_network *network)
53 DBG("network %p", network);
56 static struct connman_network_driver network_driver = {
58 .type = CONNMAN_NETWORK_TYPE_WIFI,
59 .probe = network_probe,
60 .remove = network_remove,
63 static int wifi_probe(struct connman_device *device)
65 struct wifi_data *data;
67 DBG("device %p", device);
69 data = g_try_new0(struct wifi_data, 1);
73 data->connected = FALSE;
75 connman_device_set_data(device, data);
80 static void wifi_remove(struct connman_device *device)
82 struct wifi_data *data = connman_device_get_data(device);
84 DBG("device %p", device);
86 connman_device_set_data(device, NULL);
88 g_free(data->identifier);
92 static int wifi_enable(struct connman_device *device)
94 DBG("device %p", device);
96 return supplicant_start(device);
99 static int wifi_disable(struct connman_device *device)
101 struct wifi_data *data = connman_device_get_data(device);
103 DBG("device %p", device);
105 connman_element_unregister_children((struct connman_element *) device);
107 data->connected = FALSE;
109 return supplicant_stop(device);
112 static int wifi_scan(struct connman_device *device)
114 DBG("device %p", device);
116 return supplicant_scan(device);
119 static struct connman_device_driver wifi_driver = {
121 .type = CONNMAN_DEVICE_TYPE_WIFI,
123 .remove = wifi_remove,
124 .enable = wifi_enable,
125 .disable = wifi_disable,
129 static void wifi_register(void)
133 if (connman_device_driver_register(&wifi_driver) < 0)
134 connman_error("Failed to register WiFi driver");
137 static void wifi_unregister(void)
141 connman_device_driver_unregister(&wifi_driver);
144 static struct supplicant_driver supplicant = {
146 .probe = wifi_register,
147 .remove = wifi_unregister,
150 static int wifi_init(void)
154 err = connman_network_driver_register(&network_driver);
158 err = supplicant_register(&supplicant);
160 connman_network_driver_unregister(&network_driver);
167 static void wifi_exit(void)
169 supplicant_unregister(&supplicant);
171 connman_network_driver_unregister(&network_driver);
174 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
175 wifi_init, wifi_exit)