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 struct connman_device_driver wifi_driver = {
137 .type = CONNMAN_DEVICE_TYPE_WIFI,
139 .remove = wifi_remove,
140 .enable = wifi_enable,
141 .disable = wifi_disable,
145 static void wifi_register(void)
149 if (connman_device_driver_register(&wifi_driver) < 0)
150 connman_error("Failed to register WiFi driver");
153 static void wifi_unregister(void)
157 connman_device_driver_unregister(&wifi_driver);
160 static struct supplicant_driver supplicant = {
162 .probe = wifi_register,
163 .remove = wifi_unregister,
166 static int wifi_init(void)
170 err = connman_network_driver_register(&network_driver);
174 err = supplicant_register(&supplicant);
176 connman_network_driver_unregister(&network_driver);
183 static void wifi_exit(void)
185 supplicant_unregister(&supplicant);
187 connman_network_driver_unregister(&network_driver);
190 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
191 CONNMAN_PLUGIN_PRIORITY_DEFAULT, wifi_init, wifi_exit)