5 * Copyright (C) 2007-2008 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
31 #include <sys/ioctl.h>
32 #include <sys/socket.h>
33 #include <arpa/inet.h>
35 #include <net/ethernet.h>
36 #include <linux/wireless.h>
40 #include <connman/plugin.h>
41 #include <connman/iface.h>
42 #include <connman/log.h>
44 #include "supplicant.h"
47 char ifname[IFNAMSIZ];
50 static int wifi_probe(struct connman_iface *iface)
52 struct iface_data *data;
56 sk = socket(PF_INET, SOCK_DGRAM, 0);
60 memset(&ifr, 0, sizeof(ifr));
61 ifr.ifr_ifindex = iface->index;
63 err = ioctl(sk, SIOCGIFNAME, &ifr);
70 DBG("iface %p %s", iface, ifr.ifr_name);
72 data = malloc(sizeof(*data));
76 memset(data, 0, sizeof(*data));
78 memcpy(data->ifname, ifr.ifr_name, IFNAMSIZ);
80 iface->type = CONNMAN_IFACE_TYPE_80211;
82 iface->flags = CONNMAN_IFACE_FLAG_RTNL |
83 CONNMAN_IFACE_FLAG_IPV4 |
84 CONNMAN_IFACE_FLAG_SCANNING |
85 CONNMAN_IFACE_FLAG_NOCARRIER;
87 connman_iface_set_data(iface, data);
92 static void wifi_remove(struct connman_iface *iface)
94 struct iface_data *data = connman_iface_get_data(iface);
96 DBG("iface %p %s", iface, data->ifname);
98 __supplicant_stop(iface);
100 connman_iface_set_data(iface, NULL);
105 static int wifi_start(struct connman_iface *iface)
107 struct iface_data *data = connman_iface_get_data(iface);
109 DBG("iface %p %s", iface, data->ifname);
111 __supplicant_start(iface);
116 static int wifi_stop(struct connman_iface *iface)
118 struct iface_data *data = connman_iface_get_data(iface);
120 DBG("iface %p %s", iface, data->ifname);
122 __supplicant_stop(iface);
127 static int wifi_scan(struct connman_iface *iface)
129 struct iface_data *data = connman_iface_get_data(iface);
131 DBG("iface %p %s", iface, data->ifname);
133 __supplicant_scan(iface);
138 static int wifi_connect(struct connman_iface *iface,
139 struct connman_network *network)
141 struct iface_data *data = connman_iface_get_data(iface);
143 DBG("iface %p %s", iface, data->ifname);
145 __supplicant_connect(iface, network->identifier, network->passphrase);
150 static int wifi_disconnect(struct connman_iface *iface)
152 struct iface_data *data = connman_iface_get_data(iface);
154 DBG("iface %p %s", iface, data->ifname);
156 __supplicant_disconnect(iface);
161 static struct connman_iface_driver wifi_driver = {
163 .capability = "net.80211",
165 .remove = wifi_remove,
169 .connect = wifi_connect,
170 .disconnect = wifi_disconnect,
173 static int wifi_init(void)
175 return connman_iface_register(&wifi_driver);
178 static void wifi_exit(void)
180 connman_iface_unregister(&wifi_driver);
183 CONNMAN_PLUGIN_DEFINE("80211", "IEEE 802.11 interface plugin", VERSION,
184 wifi_init, wifi_exit)