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
28 #include <dbus/dbus.h>
31 #define CONNMAN_API_SUBJECT_TO_CHANGE
32 #include <connman/plugin.h>
33 #include <connman/device.h>
34 #include <connman/log.h>
36 #include "supplicant.h"
38 #define CLEANUP_TIMEOUT 8 /* in seconds */
39 #define INACTIVE_TIMEOUT 12 /* in seconds */
43 connman_bool_t connected;
46 static int network_probe(struct connman_network *network)
48 DBG("network %p", network);
53 static void network_remove(struct connman_network *network)
55 DBG("network %p", network);
58 static int network_connect(struct connman_network *network)
60 DBG("network %p", network);
62 return supplicant_connect(network);
65 static int network_disconnect(struct connman_network *network)
67 DBG("network %p", network);
69 return supplicant_disconnect(network);
72 static struct connman_network_driver network_driver = {
74 .type = CONNMAN_NETWORK_TYPE_WIFI,
75 .probe = network_probe,
76 .remove = network_remove,
77 .connect = network_connect,
78 .disconnect = network_disconnect,
81 static int wifi_probe(struct connman_device *device)
83 struct wifi_data *data;
85 DBG("device %p", device);
87 data = g_try_new0(struct wifi_data, 1);
91 data->connected = FALSE;
93 connman_device_set_data(device, data);
98 static void wifi_remove(struct connman_device *device)
100 struct wifi_data *data = connman_device_get_data(device);
102 DBG("device %p", device);
104 connman_device_set_data(device, NULL);
106 g_free(data->identifier);
110 static int wifi_enable(struct connman_device *device)
112 DBG("device %p", device);
114 return supplicant_start(device);
117 static int wifi_disable(struct connman_device *device)
119 struct wifi_data *data = connman_device_get_data(device);
121 DBG("device %p", device);
123 data->connected = FALSE;
125 return supplicant_stop(device);
128 static int wifi_scan(struct connman_device *device)
130 DBG("device %p", device);
132 return supplicant_scan(device);
135 static int wifi_join(struct connman_device *device,
136 struct connman_network *network)
140 DBG("device %p", device);
142 err = supplicant_connect(network);
146 connman_network_ref(network);
148 connman_device_add_network(device, network);
150 connman_network_set_available(network, TRUE);
155 static struct connman_device_driver wifi_driver = {
157 .type = CONNMAN_DEVICE_TYPE_WIFI,
159 .remove = wifi_remove,
160 .enable = wifi_enable,
161 .disable = wifi_disable,
166 static void wifi_register(void)
170 if (connman_device_driver_register(&wifi_driver) < 0)
171 connman_error("Failed to register WiFi driver");
174 static void wifi_unregister(void)
178 connman_device_driver_unregister(&wifi_driver);
181 static struct supplicant_driver supplicant = {
183 .probe = wifi_register,
184 .remove = wifi_unregister,
187 static int wifi_init(void)
191 err = connman_network_driver_register(&network_driver);
195 err = supplicant_register(&supplicant);
197 connman_network_driver_unregister(&network_driver);
204 static void wifi_exit(void)
206 supplicant_unregister(&supplicant);
208 connman_network_driver_unregister(&network_driver);
211 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
212 CONNMAN_PLUGIN_PRIORITY_DEFAULT, wifi_init, wifi_exit)