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>
37 #include "supplicant.h"
39 #define CLEANUP_TIMEOUT 8 /* in seconds */
40 #define INACTIVE_TIMEOUT 12 /* in seconds */
44 connman_bool_t connected;
47 static int network_probe(struct connman_network *network)
49 DBG("network %p", network);
54 static void network_remove(struct connman_network *network)
56 DBG("network %p", network);
59 static int network_connect(struct connman_network *network)
61 DBG("network %p", network);
63 return supplicant_connect(network);
66 static int network_disconnect(struct connman_network *network)
68 DBG("network %p", network);
70 //connman_element_unregister_children((struct connman_element *) network);
72 return supplicant_disconnect(network);
75 static struct connman_network_driver network_driver = {
77 .type = CONNMAN_NETWORK_TYPE_WIFI,
78 .probe = network_probe,
79 .remove = network_remove,
80 .connect = network_connect,
81 .disconnect = network_disconnect,
84 static int wifi_probe(struct connman_device *device)
86 struct wifi_data *data;
88 DBG("device %p", device);
90 data = g_try_new0(struct wifi_data, 1);
94 data->connected = FALSE;
96 connman_device_set_data(device, data);
101 static void wifi_remove(struct connman_device *device)
103 struct wifi_data *data = connman_device_get_data(device);
105 DBG("device %p", device);
107 connman_device_set_data(device, NULL);
109 g_free(data->identifier);
113 static int wifi_enable(struct connman_device *device)
115 DBG("device %p", device);
117 return supplicant_start(device);
120 static int wifi_disable(struct connman_device *device)
122 struct wifi_data *data = connman_device_get_data(device);
124 DBG("device %p", device);
126 //connman_element_unregister_children((struct connman_element *) device);
128 data->connected = FALSE;
130 return supplicant_stop(device);
133 static int wifi_scan(struct connman_device *device)
135 DBG("device %p", device);
137 return supplicant_scan(device);
140 static struct connman_device_driver wifi_driver = {
142 .type = CONNMAN_DEVICE_TYPE_WIFI,
144 .remove = wifi_remove,
145 .enable = wifi_enable,
146 .disable = wifi_disable,
150 static void wifi_register(void)
154 if (connman_device_driver_register(&wifi_driver) < 0)
155 connman_error("Failed to register WiFi driver");
158 static void wifi_unregister(void)
162 connman_device_driver_unregister(&wifi_driver);
165 static struct supplicant_driver supplicant = {
167 .probe = wifi_register,
168 .remove = wifi_unregister,
171 static int wifi_init(void)
175 err = connman_network_driver_register(&network_driver);
179 err = supplicant_register(&supplicant);
181 connman_network_driver_unregister(&network_driver);
188 static void wifi_exit(void)
190 supplicant_unregister(&supplicant);
192 connman_network_driver_unregister(&network_driver);
195 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
196 wifi_init, wifi_exit)