Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-wpa_supplicant_8: 提交

external/wpa_supplicant_8


Commit MetaInfo

修订版1c31348a7fa022f550a2228e788307963dfbb2d5 (tree)
时间2011-12-01 00:14:32
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

add private_lib for NL80211 driver.

Copied from hardware/broadcom/wlan/bcmdhd/wpa_supplicant_8_lib with
minor fixes for x86.

更改概述

差异

--- /dev/null
+++ b/private_lib/Android.mk
@@ -0,0 +1,67 @@
1+#
2+# Copyright (C) 2008 The Android Open Source Project
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+ifeq ($(TARGET_ARCH),x86)
17+ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_8_X)
18+
19+LOCAL_PATH := $(call my-dir)
20+
21+ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),)
22+ CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) := y
23+endif
24+
25+WPA_SUPPL_DIR = $(LOCAL_PATH)/..
26+WPA_SRC_FILE :=
27+
28+include $(WPA_SUPPL_DIR)/wpa_supplicant/.config
29+
30+WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)/src \
31+ $(WPA_SUPPL_DIR)/src/common \
32+ $(WPA_SUPPL_DIR)/src/drivers \
33+ $(WPA_SUPPL_DIR)/src/l2_packet \
34+ $(WPA_SUPPL_DIR)/src/utils \
35+ $(WPA_SUPPL_DIR)/src/wps \
36+ $(WPA_SUPPL_DIR)/wpa_supplicant
37+
38+ifdef CONFIG_DRIVER_NL80211
39+WPA_SUPPL_DIR_INCLUDE += external/libnl-headers
40+WPA_SRC_FILE += driver_cmd_nl80211.c
41+endif
42+
43+ifdef CONFIG_DRIVER_WEXT
44+WPA_SRC_FILE += driver_cmd_wext.c
45+endif
46+
47+# To force sizeof(enum) = 4
48+#L_CFLAGS += -mabi=aapcs-linux
49+
50+ifdef CONFIG_ANDROID_LOG
51+L_CFLAGS += -DCONFIG_ANDROID_LOG
52+endif
53+
54+########################
55+
56+include $(CLEAR_VARS)
57+LOCAL_MODULE := private_lib_driver_cmd
58+LOCAL_SHARED_LIBRARIES := libc libcutils
59+LOCAL_CFLAGS := $(L_CFLAGS)
60+LOCAL_SRC_FILES := $(WPA_SRC_FILE)
61+LOCAL_C_INCLUDES := $(WPA_SUPPL_DIR_INCLUDE)
62+include $(BUILD_STATIC_LIBRARY)
63+
64+########################
65+
66+endif
67+endif
--- /dev/null
+++ b/private_lib/NOTICE
@@ -0,0 +1,43 @@
1+
2+Copyright (c) 2005-2010, The Android Open Source Project
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions
7+are met:
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+ * Redistributions in binary form must reproduce the above copyright
11+ notice, this list of conditions and the following disclaimer in
12+ the documentation and/or other materials provided with the
13+ distribution.
14+ * Neither the name of The Android Open Source Project nor the names
15+ of its contributors may be used to endorse or promote products
16+ derived from this software without specific prior written
17+ permission.
18+
19+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+SUCH DAMAGE.
31+
32+ * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>
33+ * Copyright (c) 2003-2004, Instant802 Networks, Inc.
34+ * Copyright (c) 2005-2006, Devicescape Software, Inc.
35+ * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
36+ * Copyright (c) 2009-2010, Atheros Communications
37+ *
38+ * This program is free software; you can redistribute it and/or modify
39+ * it under the terms of the GNU General Public License version 2 as
40+ * published by the Free Software Foundation.
41+ *
42+ * Alternatively, this software may be distributed under the terms of BSD
43+ * license.
--- /dev/null
+++ b/private_lib/driver_cmd_common.h
@@ -0,0 +1,58 @@
1+/*
2+ * Driver interaction for private interface
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License version 2 as
6+ * published by the Free Software Foundation.
7+ *
8+ * Alternatively, this software may be distributed under the terms of BSD
9+ * license.
10+ *
11+ */
12+#ifndef DRIVER_CMD_COMMON_H
13+#define DRIVER_CMD_COMMON_H
14+
15+#include "config_ssid.h"
16+
17+#define MAX_DRV_CMD_SIZE 248
18+#define DRV_NUMBER_SEQUENTIAL_ERRORS 4
19+
20+#define RSSI_CMD "RSSI"
21+#define LINKSPEED_CMD "LINKSPEED"
22+
23+#define MAX_WPSP2PIE_CMD_SIZE 384
24+
25+#define WEXT_PNOSETUP_HEADER "PNOSETUP "
26+#define WEXT_PNOSETUP_HEADER_SIZE 9
27+#define WEXT_PNO_TLV_PREFIX 'S'
28+#define WEXT_PNO_TLV_VERSION '1'
29+#define WEXT_PNO_TLV_SUBVERSION '2'
30+#define WEXT_PNO_TLV_RESERVED '0'
31+#define WEXT_PNO_VERSION_SIZE 4
32+#define WEXT_PNO_AMOUNT 16
33+#define WEXT_PNO_SSID_SECTION 'S'
34+/* SSID header size is SSID section type above + SSID length */
35+#define WEXT_PNO_SSID_HEADER_SIZE 2
36+#define WEXT_PNO_SCAN_INTERVAL_SECTION 'T'
37+#define WEXT_PNO_SCAN_INTERVAL_LENGTH 2
38+#define WEXT_PNO_SCAN_INTERVAL 30
39+/* Scan interval size is scan interval section type + scan interval length above*/
40+#define WEXT_PNO_SCAN_INTERVAL_SIZE (1 + WEXT_PNO_SCAN_INTERVAL_LENGTH)
41+#define WEXT_PNO_REPEAT_SECTION 'R'
42+#define WEXT_PNO_REPEAT_LENGTH 1
43+#define WEXT_PNO_REPEAT 4
44+/* Repeat section size is Repeat section type + Repeat value length above*/
45+#define WEXT_PNO_REPEAT_SIZE (1 + WEXT_PNO_REPEAT_LENGTH)
46+#define WEXT_PNO_MAX_REPEAT_SECTION 'M'
47+#define WEXT_PNO_MAX_REPEAT_LENGTH 1
48+#define WEXT_PNO_MAX_REPEAT 3
49+/* Max Repeat section size is Max Repeat section type + Max Repeat value length above*/
50+#define WEXT_PNO_MAX_REPEAT_SIZE (1 + WEXT_PNO_MAX_REPEAT_LENGTH)
51+/* This corresponds to the size of all sections expect SSIDs */
52+#define WEXT_PNO_NONSSID_SECTIONS_SIZE (WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE)
53+/* PNO Max command size is total of header, version, ssid and other sections + Null termination */
54+#define WEXT_PNO_MAX_COMMAND_SIZE (WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \
55+ + WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + MAX_SSID_LEN) \
56+ + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1)
57+
58+#endif /* DRIVER_CMD_COMMON_H */
--- /dev/null
+++ b/private_lib/driver_cmd_nl80211.c
@@ -0,0 +1,366 @@
1+/*
2+ * Driver interaction with extended Linux CFG8021
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License version 2 as
6+ * published by the Free Software Foundation.
7+ *
8+ * Alternatively, this software may be distributed under the terms of BSD
9+ * license.
10+ *
11+ */
12+
13+#include "driver_nl80211.h"
14+#include "driver_cmd_common.h"
15+
16+#include "wpa_supplicant_i.h"
17+#include "config.h"
18+
19+#define WPA_EVENT_DRIVER_STATE "CTRL-EVENT-DRIVER-STATE "
20+
21+#define WPA_PS_ENABLED 0
22+#define WPA_PS_DISABLED 1
23+
24+typedef struct android_wifi_priv_cmd {
25+ char *buf;
26+ int used_len;
27+ int total_len;
28+} android_wifi_priv_cmd;
29+
30+int send_and_recv_msgs(struct wpa_driver_nl80211_data *drv, struct nl_msg *msg,
31+ int (*valid_handler)(struct nl_msg *, void *),
32+ void *valid_data);
33+
34+static int drv_errors = 0;
35+
36+static void wpa_driver_send_hang_msg(struct wpa_driver_nl80211_data *drv)
37+{
38+ drv_errors++;
39+ if (drv_errors > DRV_NUMBER_SEQUENTIAL_ERRORS) {
40+ drv_errors = 0;
41+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
42+ }
43+}
44+
45+static int wpa_driver_set_power_save(void *priv, int state)
46+{
47+ struct i802_bss *bss = priv;
48+ struct wpa_driver_nl80211_data *drv = bss->drv;
49+ struct nl_msg *msg;
50+ int ret = -1;
51+ enum nl80211_ps_state ps_state;
52+
53+ msg = nlmsg_alloc();
54+ if (!msg)
55+ return -1;
56+
57+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
58+ NL80211_CMD_SET_POWER_SAVE, 0);
59+
60+ if (state == WPA_PS_ENABLED)
61+ ps_state = NL80211_PS_ENABLED;
62+ else
63+ ps_state = NL80211_PS_DISABLED;
64+
65+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
66+ NLA_PUT_U32(msg, NL80211_ATTR_PS_STATE, ps_state);
67+
68+ ret = send_and_recv_msgs(drv, msg, NULL, NULL);
69+ msg = NULL;
70+ if (ret < 0)
71+ wpa_printf(MSG_ERROR, "nl80211: Set power mode fail: %d", ret);
72+nla_put_failure:
73+ nlmsg_free(msg);
74+ return ret;
75+}
76+
77+static int get_power_mode_handler(struct nl_msg *msg, void *arg)
78+{
79+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
80+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
81+ int *state = (int *)arg;
82+
83+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
84+ genlmsg_attrlen(gnlh, 0), NULL);
85+
86+ if (!tb[NL80211_ATTR_PS_STATE])
87+ return NL_SKIP;
88+
89+ if (state) {
90+ *state = (int)nla_get_u32(tb[NL80211_ATTR_PS_STATE]);
91+ wpa_printf(MSG_DEBUG, "nl80211: Get power mode = %d", *state);
92+ *state = (*state == NL80211_PS_ENABLED) ?
93+ WPA_PS_ENABLED : WPA_PS_DISABLED;
94+ }
95+
96+ return NL_SKIP;
97+}
98+
99+static int wpa_driver_get_power_save(void *priv, int *state)
100+{
101+ struct i802_bss *bss = priv;
102+ struct wpa_driver_nl80211_data *drv = bss->drv;
103+ struct nl_msg *msg;
104+ int ret = -1;
105+ enum nl80211_ps_state ps_state;
106+
107+ msg = nlmsg_alloc();
108+ if (!msg)
109+ return -1;
110+
111+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
112+ NL80211_CMD_GET_POWER_SAVE, 0);
113+
114+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
115+
116+ ret = send_and_recv_msgs(drv, msg, get_power_mode_handler, state);
117+ msg = NULL;
118+ if (ret < 0)
119+ wpa_printf(MSG_ERROR, "nl80211: Get power mode fail: %d", ret);
120+nla_put_failure:
121+ nlmsg_free(msg);
122+ return ret;
123+}
124+
125+static int wpa_driver_set_backgroundscan_params(void *priv)
126+{
127+ struct i802_bss *bss = priv;
128+ struct wpa_driver_nl80211_data *drv = bss->drv;
129+ struct wpa_supplicant *wpa_s;
130+ struct ifreq ifr;
131+ android_wifi_priv_cmd priv_cmd;
132+ int ret = 0, i = 0, bp;
133+ char buf[WEXT_PNO_MAX_COMMAND_SIZE];
134+ struct wpa_ssid *ssid_conf;
135+
136+ if (drv == NULL) {
137+ wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__);
138+ return -1;
139+ }
140+ if (drv->ctx == NULL) {
141+ wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__);
142+ return -1;
143+ }
144+ wpa_s = (struct wpa_supplicant *)(drv->ctx);
145+ if (wpa_s->conf == NULL) {
146+ wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__);
147+ return -1;
148+ }
149+ ssid_conf = wpa_s->conf->ssid;
150+
151+ bp = WEXT_PNOSETUP_HEADER_SIZE;
152+ os_memcpy(buf, WEXT_PNOSETUP_HEADER, bp);
153+ buf[bp++] = WEXT_PNO_TLV_PREFIX;
154+ buf[bp++] = WEXT_PNO_TLV_VERSION;
155+ buf[bp++] = WEXT_PNO_TLV_SUBVERSION;
156+ buf[bp++] = WEXT_PNO_TLV_RESERVED;
157+
158+ while ((i < WEXT_PNO_AMOUNT) && (ssid_conf != NULL)) {
159+ /* Check that there is enough space needed for 1 more SSID, the other sections and null termination */
160+ if ((bp + WEXT_PNO_SSID_HEADER_SIZE + MAX_SSID_LEN + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1) >= (int)sizeof(buf))
161+ break;
162+ if ((!ssid_conf->disabled) && (ssid_conf->ssid_len <= MAX_SSID_LEN)){
163+ wpa_printf(MSG_DEBUG, "For PNO Scan: %s", ssid_conf->ssid);
164+ buf[bp++] = WEXT_PNO_SSID_SECTION;
165+ buf[bp++] = ssid_conf->ssid_len;
166+ os_memcpy(&buf[bp], ssid_conf->ssid, ssid_conf->ssid_len);
167+ bp += ssid_conf->ssid_len;
168+ i++;
169+ }
170+ ssid_conf = ssid_conf->next;
171+ }
172+
173+ buf[bp++] = WEXT_PNO_SCAN_INTERVAL_SECTION;
174+ os_snprintf(&buf[bp], WEXT_PNO_SCAN_INTERVAL_LENGTH + 1, "%x", WEXT_PNO_SCAN_INTERVAL);
175+ bp += WEXT_PNO_SCAN_INTERVAL_LENGTH;
176+
177+ buf[bp++] = WEXT_PNO_REPEAT_SECTION;
178+ os_snprintf(&buf[bp], WEXT_PNO_REPEAT_LENGTH + 1, "%x", WEXT_PNO_REPEAT);
179+ bp += WEXT_PNO_REPEAT_LENGTH;
180+
181+ buf[bp++] = WEXT_PNO_MAX_REPEAT_SECTION;
182+ os_snprintf(&buf[bp], WEXT_PNO_MAX_REPEAT_LENGTH + 1, "%x", WEXT_PNO_MAX_REPEAT);
183+ bp += WEXT_PNO_MAX_REPEAT_LENGTH + 1;
184+
185+ memset(&ifr, 0, sizeof(ifr));
186+ memset(&priv_cmd, 0, sizeof(priv_cmd));
187+ os_strncpy(ifr.ifr_name, bss->ifname, IFNAMSIZ);
188+
189+ priv_cmd.buf = buf;
190+ priv_cmd.used_len = bp;
191+ priv_cmd.total_len = bp;
192+ ifr.ifr_data = &priv_cmd;
193+
194+ ret = ioctl(drv->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
195+
196+ if (ret < 0) {
197+ wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (pnosetup): %d", ret);
198+ wpa_driver_send_hang_msg(drv);
199+ } else {
200+ drv_errors = 0;
201+ }
202+ return ret;
203+}
204+
205+int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
206+ size_t buf_len )
207+{
208+ struct i802_bss *bss = priv;
209+ struct wpa_driver_nl80211_data *drv = bss->drv;
210+ struct ifreq ifr;
211+ android_wifi_priv_cmd priv_cmd;
212+ int ret = 0;
213+
214+ if (os_strcasecmp(cmd, "STOP") == 0) {
215+ linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0);
216+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
217+ } else if (os_strcasecmp(cmd, "START") == 0) {
218+ linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1);
219+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
220+ } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
221+ u8 macaddr[ETH_ALEN] = {};
222+
223+ ret = linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, macaddr);
224+ if (!ret)
225+ ret = os_snprintf(buf, buf_len,
226+ "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
227+ } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
228+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
229+ } else if (os_strncasecmp(cmd, "POWERMODE ", 10) == 0) {
230+ int state;
231+
232+ state = atoi(cmd + 10);
233+ ret = wpa_driver_set_power_save(priv, state);
234+ if (ret < 0)
235+ wpa_driver_send_hang_msg(drv);
236+ else
237+ drv_errors = 0;
238+ } else if (os_strncasecmp(cmd, "GETPOWER", 8) == 0) {
239+ int state = -1;
240+
241+ ret = wpa_driver_get_power_save(priv, &state);
242+ if (!ret && (state != -1)) {
243+ ret = os_snprintf(buf, buf_len, "POWERMODE = %d\n", state);
244+ drv_errors = 0;
245+ } else {
246+ wpa_driver_send_hang_msg(drv);
247+ }
248+ } else { /* Use private command */
249+ if (os_strcasecmp(cmd, "BGSCAN-START") == 0) {
250+ ret = wpa_driver_set_backgroundscan_params(priv);
251+ if (ret < 0) {
252+ return ret;
253+ }
254+ os_memcpy(buf, "PNOFORCE 1", 11);
255+ } else if (os_strcasecmp(cmd, "BGSCAN-STOP") == 0) {
256+ os_memcpy(buf, "PNOFORCE 0", 11);
257+ } else {
258+ os_memcpy(buf, cmd, strlen(cmd) + 1);
259+ }
260+ memset(&ifr, 0, sizeof(ifr));
261+ memset(&priv_cmd, 0, sizeof(priv_cmd));
262+ os_strncpy(ifr.ifr_name, bss->ifname, IFNAMSIZ);
263+
264+ priv_cmd.buf = buf;
265+ priv_cmd.used_len = buf_len;
266+ priv_cmd.total_len = buf_len;
267+ ifr.ifr_data = &priv_cmd;
268+
269+#ifndef __i386__ /* we don't support SIOCDEVPRIVATE */
270+ if ((ret = ioctl(drv->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr)) < 0) {
271+ wpa_printf(MSG_ERROR, "%s: failed to issue private commands\n", __func__);
272+ wpa_driver_send_hang_msg(drv);
273+ } else {
274+ drv_errors = 0;
275+ ret = 0;
276+ if ((os_strcasecmp(cmd, "LINKSPEED") == 0) ||
277+ (os_strcasecmp(cmd, "RSSI") == 0) ||
278+ (os_strcasecmp(cmd, "GETBAND") == 0) ||
279+ (os_strcasecmp(cmd, "P2P_GET_NOA") == 0))
280+ ret = strlen(buf);
281+
282+ wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
283+ }
284+#endif
285+ }
286+ return ret;
287+}
288+
289+int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration)
290+{
291+ char buf[MAX_DRV_CMD_SIZE];
292+
293+ memset(buf, 0, sizeof(buf));
294+ wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
295+ snprintf(buf, sizeof(buf), "P2P_SET_NOA %d %d %d", count, start, duration);
296+ return wpa_driver_nl80211_driver_cmd(priv, buf, buf, strlen(buf)+1);
297+}
298+
299+int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len)
300+{
301+ char rbuf[MAX_DRV_CMD_SIZE];
302+ char *cmd = "P2P_GET_NOA";
303+ int ret;
304+
305+ wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
306+ os_memset(buf, 0, len);
307+ ret = wpa_driver_nl80211_driver_cmd(priv, cmd, rbuf, sizeof(rbuf));
308+ if (ret <= 0)
309+ return 0;
310+ ret >>= 1;
311+ if (ret > (int)len)
312+ ret = (int)len;
313+ hexstr2bin(rbuf, buf, ret);
314+ return ret;
315+}
316+
317+int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow)
318+{
319+ char buf[MAX_DRV_CMD_SIZE];
320+
321+ memset(buf, 0, sizeof(buf));
322+ wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
323+ snprintf(buf, sizeof(buf), "P2P_SET_PS %d %d %d", legacy_ps, opp_ps, ctwindow);
324+ return wpa_driver_nl80211_driver_cmd(priv, buf, buf, strlen(buf) + 1);
325+}
326+
327+int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
328+ const struct wpabuf *proberesp,
329+ const struct wpabuf *assocresp)
330+{
331+ char buf[MAX_WPSP2PIE_CMD_SIZE];
332+ struct wpabuf *ap_wps_p2p_ie = NULL;
333+ char *_cmd = "SET_AP_WPS_P2P_IE";
334+ char *pbuf;
335+ int ret = 0;
336+ int i;
337+ struct cmd_desc {
338+ int cmd;
339+ const struct wpabuf *src;
340+ } cmd_arr[] = {
341+ {0x1, beacon},
342+ {0x2, proberesp},
343+ {0x4, assocresp},
344+ {-1, NULL}
345+ };
346+
347+ wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
348+ for (i = 0; cmd_arr[i].cmd != -1; i++) {
349+ os_memset(buf, 0, sizeof(buf));
350+ pbuf = buf;
351+ pbuf += sprintf(pbuf, "%s %d", _cmd, cmd_arr[i].cmd);
352+ *pbuf++ = '\0';
353+ ap_wps_p2p_ie = cmd_arr[i].src ?
354+ wpabuf_dup(cmd_arr[i].src) : NULL;
355+ if (ap_wps_p2p_ie) {
356+ os_memcpy(pbuf, wpabuf_head(ap_wps_p2p_ie), wpabuf_len(ap_wps_p2p_ie));
357+ ret = wpa_driver_nl80211_driver_cmd(priv, buf, buf,
358+ strlen(_cmd) + 3 + wpabuf_len(ap_wps_p2p_ie));
359+ wpabuf_free(ap_wps_p2p_ie);
360+ if (ret < 0)
361+ break;
362+ }
363+ }
364+
365+ return ret;
366+}
--- /dev/null
+++ b/private_lib/driver_cmd_wext.c
@@ -0,0 +1,392 @@
1+/*
2+ * Driver interaction with extended Linux Wireless Extensions
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License version 2 as
6+ * published by the Free Software Foundation.
7+ *
8+ * Alternatively, this software may be distributed under the terms of BSD
9+ * license.
10+ *
11+ */
12+
13+#include "includes.h"
14+#include <sys/ioctl.h>
15+#include <net/if_arp.h>
16+#include <net/if.h>
17+
18+#include "wireless_copy.h"
19+#include "common.h"
20+#include "driver.h"
21+#include "eloop.h"
22+#include "priv_netlink.h"
23+#include "driver_wext.h"
24+#include "ieee802_11_defs.h"
25+#include "wpa_common.h"
26+#include "wpa_ctrl.h"
27+#include "wpa_supplicant_i.h"
28+#include "config.h"
29+#include "linux_ioctl.h"
30+#include "scan.h"
31+
32+#include "driver_cmd_wext.h"
33+#include "driver_cmd_common.h"
34+
35+/**
36+ * wpa_driver_wext_set_scan_timeout - Set scan timeout to report scan completion
37+ * @priv: Pointer to private wext data from wpa_driver_wext_init()
38+ *
39+ * This function can be used to set registered timeout when starting a scan to
40+ * generate a scan completed event if the driver does not report this.
41+ */
42+static void wpa_driver_wext_set_scan_timeout(void *priv)
43+{
44+ struct wpa_driver_wext_data *drv = priv;
45+ int timeout = 10; /* In case scan A and B bands it can be long */
46+
47+ /* Not all drivers generate "scan completed" wireless event, so try to
48+ * read results after a timeout. */
49+ if (drv->scan_complete_events) {
50+ /*
51+ * The driver seems to deliver SIOCGIWSCAN events to notify
52+ * when scan is complete, so use longer timeout to avoid race
53+ * conditions with scanning and following association request.
54+ */
55+ timeout = 30;
56+ }
57+ wpa_printf(MSG_DEBUG, "Scan requested - scan timeout %d seconds",
58+ timeout);
59+ eloop_cancel_timeout(wpa_driver_wext_scan_timeout, drv, drv->ctx);
60+ eloop_register_timeout(timeout, 0, wpa_driver_wext_scan_timeout, drv,
61+ drv->ctx);
62+}
63+
64+/**
65+ * wpa_driver_wext_combo_scan - Request the driver to initiate combo scan
66+ * @priv: Pointer to private wext data from wpa_driver_wext_init()
67+ * @params: Scan parameters
68+ * Returns: 0 on success, -1 on failure
69+ */
70+int wpa_driver_wext_combo_scan(void *priv, struct wpa_driver_scan_params *params)
71+{
72+ char buf[WEXT_CSCAN_BUF_LEN];
73+ struct wpa_driver_wext_data *drv = priv;
74+ struct iwreq iwr;
75+ int ret, bp;
76+ unsigned i;
77+ struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)(drv->ctx);
78+
79+ if (!drv->driver_is_started) {
80+ wpa_printf(MSG_DEBUG, "%s: Driver stopped", __func__);
81+ return 0;
82+ }
83+
84+ wpa_printf(MSG_DEBUG, "%s: Start", __func__);
85+
86+ /* Set list of SSIDs */
87+ bp = WEXT_CSCAN_HEADER_SIZE;
88+ os_memcpy(buf, WEXT_CSCAN_HEADER, bp);
89+ for(i=0; i < params->num_ssids; i++) {
90+ if ((bp + IW_ESSID_MAX_SIZE + 10) >= (int)sizeof(buf))
91+ break;
92+ wpa_printf(MSG_DEBUG, "For Scan: %s", params->ssids[i].ssid);
93+ buf[bp++] = WEXT_CSCAN_SSID_SECTION;
94+ buf[bp++] = params->ssids[i].ssid_len;
95+ os_memcpy(&buf[bp], params->ssids[i].ssid, params->ssids[i].ssid_len);
96+ bp += params->ssids[i].ssid_len;
97+ }
98+
99+ /* Set list of channels */
100+ buf[bp++] = WEXT_CSCAN_CHANNEL_SECTION;
101+ buf[bp++] = 0;
102+
103+ /* Set passive dwell time (default is 250) */
104+ buf[bp++] = WEXT_CSCAN_PASV_DWELL_SECTION;
105+ buf[bp++] = (u8)WEXT_CSCAN_PASV_DWELL_TIME;
106+ buf[bp++] = (u8)(WEXT_CSCAN_PASV_DWELL_TIME >> 8);
107+
108+ /* Set home dwell time (default is 40) */
109+ buf[bp++] = WEXT_CSCAN_HOME_DWELL_SECTION;
110+ buf[bp++] = (u8)WEXT_CSCAN_HOME_DWELL_TIME;
111+ buf[bp++] = (u8)(WEXT_CSCAN_HOME_DWELL_TIME >> 8);
112+
113+ os_memset(&iwr, 0, sizeof(iwr));
114+ os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
115+ iwr.u.data.pointer = buf;
116+ iwr.u.data.length = bp;
117+
118+ if ((ret = ioctl(drv->ioctl_sock, SIOCSIWPRIV, &iwr)) < 0) {
119+ if (!drv->bgscan_enabled)
120+ wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (cscan): %d", ret);
121+ else
122+ ret = 0; /* Hide error in case of bg scan */
123+ }
124+ return ret;
125+}
126+
127+static int wpa_driver_wext_set_cscan_params(char *buf, size_t buf_len, char *cmd)
128+{
129+ char *pasv_ptr;
130+ int bp, i;
131+ u16 pasv_dwell = WEXT_CSCAN_PASV_DWELL_TIME_DEF;
132+ u8 channel;
133+
134+ wpa_printf(MSG_DEBUG, "%s: %s", __func__, cmd);
135+
136+ /* Get command parameters */
137+ pasv_ptr = os_strstr(cmd, ",TIME=");
138+ if (pasv_ptr) {
139+ *pasv_ptr = '\0';
140+ pasv_ptr += 6;
141+ pasv_dwell = (u16)atoi(pasv_ptr);
142+ if (pasv_dwell == 0)
143+ pasv_dwell = WEXT_CSCAN_PASV_DWELL_TIME_DEF;
144+ }
145+ channel = (u8)atoi(cmd + 5);
146+
147+ bp = WEXT_CSCAN_HEADER_SIZE;
148+ os_memcpy(buf, WEXT_CSCAN_HEADER, bp);
149+
150+ /* Set list of channels */
151+ buf[bp++] = WEXT_CSCAN_CHANNEL_SECTION;
152+ buf[bp++] = channel;
153+ if (channel != 0) {
154+ i = (pasv_dwell - 1) / WEXT_CSCAN_PASV_DWELL_TIME_DEF;
155+ for (; i > 0; i--) {
156+ if ((size_t)(bp + 12) >= buf_len)
157+ break;
158+ buf[bp++] = WEXT_CSCAN_CHANNEL_SECTION;
159+ buf[bp++] = channel;
160+ }
161+ } else {
162+ if (pasv_dwell > WEXT_CSCAN_PASV_DWELL_TIME_MAX)
163+ pasv_dwell = WEXT_CSCAN_PASV_DWELL_TIME_MAX;
164+ }
165+
166+ /* Set passive dwell time (default is 250) */
167+ buf[bp++] = WEXT_CSCAN_PASV_DWELL_SECTION;
168+ if (channel != 0) {
169+ buf[bp++] = (u8)WEXT_CSCAN_PASV_DWELL_TIME_DEF;
170+ buf[bp++] = (u8)(WEXT_CSCAN_PASV_DWELL_TIME_DEF >> 8);
171+ } else {
172+ buf[bp++] = (u8)pasv_dwell;
173+ buf[bp++] = (u8)(pasv_dwell >> 8);
174+ }
175+
176+ /* Set home dwell time (default is 40) */
177+ buf[bp++] = WEXT_CSCAN_HOME_DWELL_SECTION;
178+ buf[bp++] = (u8)WEXT_CSCAN_HOME_DWELL_TIME;
179+ buf[bp++] = (u8)(WEXT_CSCAN_HOME_DWELL_TIME >> 8);
180+
181+ /* Set cscan type */
182+ buf[bp++] = WEXT_CSCAN_TYPE_SECTION;
183+ buf[bp++] = WEXT_CSCAN_TYPE_PASSIVE;
184+ return bp;
185+}
186+
187+static char *wpa_driver_get_country_code(int channels)
188+{
189+ char *country = "US"; /* WEXT_NUMBER_SCAN_CHANNELS_FCC */
190+
191+ if (channels == WEXT_NUMBER_SCAN_CHANNELS_ETSI)
192+ country = "EU";
193+ else if( channels == WEXT_NUMBER_SCAN_CHANNELS_MKK1)
194+ country = "JP";
195+ return country;
196+}
197+
198+static int wpa_driver_set_backgroundscan_params(void *priv)
199+{
200+ struct wpa_driver_wext_data *drv = priv;
201+ struct wpa_supplicant *wpa_s;
202+ struct iwreq iwr;
203+ int ret = 0, i = 0, bp;
204+ char buf[WEXT_PNO_MAX_COMMAND_SIZE];
205+ struct wpa_ssid *ssid_conf;
206+
207+ if (drv == NULL) {
208+ wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__);
209+ return -1;
210+ }
211+ if (drv->ctx == NULL) {
212+ wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__);
213+ return -1;
214+ }
215+ wpa_s = (struct wpa_supplicant *)(drv->ctx);
216+ if (wpa_s->conf == NULL) {
217+ wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__);
218+ return -1;
219+ }
220+ ssid_conf = wpa_s->conf->ssid;
221+
222+ bp = WEXT_PNOSETUP_HEADER_SIZE;
223+ os_memcpy(buf, WEXT_PNOSETUP_HEADER, bp);
224+ buf[bp++] = WEXT_PNO_TLV_PREFIX;
225+ buf[bp++] = WEXT_PNO_TLV_VERSION;
226+ buf[bp++] = WEXT_PNO_TLV_SUBVERSION;
227+ buf[bp++] = WEXT_PNO_TLV_RESERVED;
228+
229+ while ((i < WEXT_PNO_AMOUNT) && (ssid_conf != NULL)) {
230+ /* Check that there is enough space needed for 1 more SSID, the other sections and null termination */
231+ if ((bp + WEXT_PNO_SSID_HEADER_SIZE + IW_ESSID_MAX_SIZE + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1) >= (int)sizeof(buf))
232+ break;
233+ if ((!ssid_conf->disabled) && (ssid_conf->ssid_len <= IW_ESSID_MAX_SIZE)){
234+ wpa_printf(MSG_DEBUG, "For PNO Scan: %s", ssid_conf->ssid);
235+ buf[bp++] = WEXT_PNO_SSID_SECTION;
236+ buf[bp++] = ssid_conf->ssid_len;
237+ os_memcpy(&buf[bp], ssid_conf->ssid, ssid_conf->ssid_len);
238+ bp += ssid_conf->ssid_len;
239+ i++;
240+ }
241+ ssid_conf = ssid_conf->next;
242+ }
243+
244+ buf[bp++] = WEXT_PNO_SCAN_INTERVAL_SECTION;
245+ os_snprintf(&buf[bp], WEXT_PNO_SCAN_INTERVAL_LENGTH + 1, "%x", WEXT_PNO_SCAN_INTERVAL);
246+ bp += WEXT_PNO_SCAN_INTERVAL_LENGTH;
247+
248+ buf[bp++] = WEXT_PNO_REPEAT_SECTION;
249+ os_snprintf(&buf[bp], WEXT_PNO_REPEAT_LENGTH + 1, "%x", WEXT_PNO_REPEAT);
250+ bp += WEXT_PNO_REPEAT_LENGTH;
251+
252+ buf[bp++] = WEXT_PNO_MAX_REPEAT_SECTION;
253+ os_snprintf(&buf[bp], WEXT_PNO_MAX_REPEAT_LENGTH + 1, "%x", WEXT_PNO_MAX_REPEAT);
254+ bp += WEXT_PNO_MAX_REPEAT_LENGTH + 1;
255+
256+ os_memset(&iwr, 0, sizeof(iwr));
257+ os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
258+ iwr.u.data.pointer = buf;
259+ iwr.u.data.length = bp;
260+
261+ ret = ioctl(drv->ioctl_sock, SIOCSIWPRIV, &iwr);
262+
263+ if (ret < 0) {
264+ wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (pnosetup): %d", ret);
265+ drv->errors++;
266+ if (drv->errors > DRV_NUMBER_SEQUENTIAL_ERRORS) {
267+ drv->errors = 0;
268+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
269+ }
270+ } else {
271+ drv->errors = 0;
272+ }
273+ return ret;
274+
275+}
276+
277+int wpa_driver_wext_driver_cmd( void *priv, char *cmd, char *buf, size_t buf_len )
278+{
279+ struct wpa_driver_wext_data *drv = priv;
280+ struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)(drv->ctx);
281+ struct iwreq iwr;
282+ int ret = 0, flags;
283+
284+ wpa_printf(MSG_DEBUG, "%s %s len = %d", __func__, cmd, buf_len);
285+
286+ if (!drv->driver_is_started && (os_strcasecmp(cmd, "START") != 0)) {
287+ wpa_printf(MSG_ERROR,"WEXT: Driver not initialized yet");
288+ return -1;
289+ }
290+
291+ if (os_strcasecmp(cmd, "RSSI-APPROX") == 0) {
292+ os_strncpy(cmd, RSSI_CMD, MAX_DRV_CMD_SIZE);
293+ } else if( os_strncasecmp(cmd, "SCAN-CHANNELS", 13) == 0 ) {
294+ int no_of_chan;
295+
296+ no_of_chan = atoi(cmd + 13);
297+ os_snprintf(cmd, MAX_DRV_CMD_SIZE, "COUNTRY %s",
298+ wpa_driver_get_country_code(no_of_chan));
299+ } else if (os_strcasecmp(cmd, "STOP") == 0) {
300+ linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
301+ } else if( os_strcasecmp(cmd, "RELOAD") == 0 ) {
302+ wpa_printf(MSG_DEBUG,"Reload command");
303+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
304+ return ret;
305+ } else if( os_strcasecmp(cmd, "BGSCAN-START") == 0 ) {
306+ ret = wpa_driver_set_backgroundscan_params(priv);
307+ if (ret < 0) {
308+ return ret;
309+ }
310+ os_strncpy(cmd, "PNOFORCE 1", MAX_DRV_CMD_SIZE);
311+ drv->bgscan_enabled = 1;
312+ } else if( os_strcasecmp(cmd, "BGSCAN-STOP") == 0 ) {
313+ os_strncpy(cmd, "PNOFORCE 0", MAX_DRV_CMD_SIZE);
314+ drv->bgscan_enabled = 0;
315+ }
316+
317+ os_memset(&iwr, 0, sizeof(iwr));
318+ os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
319+ os_memcpy(buf, cmd, strlen(cmd) + 1);
320+ iwr.u.data.pointer = buf;
321+ iwr.u.data.length = buf_len;
322+
323+ if( os_strncasecmp(cmd, "CSCAN", 5) == 0 ) {
324+ if (!wpa_s->scanning && ((wpa_s->wpa_state <= WPA_SCANNING) ||
325+ (wpa_s->wpa_state >= WPA_COMPLETED))) {
326+ iwr.u.data.length = wpa_driver_wext_set_cscan_params(buf, buf_len, cmd);
327+ } else {
328+ wpa_printf(MSG_ERROR, "Ongoing Scan action...");
329+ return ret;
330+ }
331+ }
332+
333+ ret = ioctl(drv->ioctl_sock, SIOCSIWPRIV, &iwr);
334+
335+ if (ret < 0) {
336+ wpa_printf(MSG_ERROR, "%s failed (%d): %s", __func__, ret, cmd);
337+ drv->errors++;
338+ if (drv->errors > DRV_NUMBER_SEQUENTIAL_ERRORS) {
339+ drv->errors = 0;
340+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
341+ }
342+ } else {
343+ drv->errors = 0;
344+ ret = 0;
345+ if ((os_strcasecmp(cmd, RSSI_CMD) == 0) ||
346+ (os_strcasecmp(cmd, LINKSPEED_CMD) == 0) ||
347+ (os_strcasecmp(cmd, "MACADDR") == 0) ||
348+ (os_strcasecmp(cmd, "GETPOWER") == 0) ||
349+ (os_strcasecmp(cmd, "GETBAND") == 0)) {
350+ ret = strlen(buf);
351+ } else if (os_strcasecmp(cmd, "START") == 0) {
352+ drv->driver_is_started = TRUE;
353+ linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1);
354+ /* os_sleep(0, WPA_DRIVER_WEXT_WAIT_US);
355+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED"); */
356+ } else if (os_strcasecmp(cmd, "STOP") == 0) {
357+ drv->driver_is_started = FALSE;
358+ /* wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED"); */
359+ } else if (os_strncasecmp(cmd, "CSCAN", 5) == 0) {
360+ wpa_driver_wext_set_scan_timeout(priv);
361+ wpa_supplicant_notify_scanning(wpa_s, 1);
362+ }
363+ wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
364+ }
365+ return ret;
366+}
367+
368+int wpa_driver_signal_poll(void *priv, struct wpa_signal_info *si)
369+{
370+ char buf[MAX_DRV_CMD_SIZE];
371+ struct wpa_driver_wext_data *drv = priv;
372+ char *prssi;
373+ int res;
374+
375+ os_memset(si, 0, sizeof(*si));
376+ res = wpa_driver_wext_driver_cmd(priv, RSSI_CMD, buf, sizeof(buf));
377+ /* Answer: SSID rssi -Val */
378+ if (res < 0)
379+ return res;
380+ prssi = strcasestr(buf, RSSI_CMD);
381+ if (!prssi)
382+ return -1;
383+ si->current_signal = atoi(prssi + strlen(RSSI_CMD) + 1);
384+
385+ res = wpa_driver_wext_driver_cmd(priv, LINKSPEED_CMD, buf, sizeof(buf));
386+ /* Answer: LinkSpeed Val */
387+ if (res < 0)
388+ return res;
389+ si->current_txrate = atoi(buf + strlen(LINKSPEED_CMD) + 1) * 1000;
390+
391+ return 0;
392+}
--- /dev/null
+++ b/private_lib/driver_cmd_wext.h
@@ -0,0 +1,38 @@
1+/*
2+ * Driver interaction with extended Linux Wireless Extensions
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License version 2 as
6+ * published by the Free Software Foundation.
7+ *
8+ * Alternatively, this software may be distributed under the terms of BSD
9+ * license.
10+ *
11+ */
12+#ifndef DRIVER_CMD_WEXT_H
13+#define DRIVER_CMD_WEXT_H
14+
15+#define WEXT_NUMBER_SCAN_CHANNELS_FCC 11
16+#define WEXT_NUMBER_SCAN_CHANNELS_ETSI 13
17+#define WEXT_NUMBER_SCAN_CHANNELS_MKK1 14
18+
19+#define WPA_DRIVER_WEXT_WAIT_US 400000
20+#define WEXT_CSCAN_AMOUNT 9
21+#define WEXT_CSCAN_BUF_LEN 360
22+#define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00"
23+#define WEXT_CSCAN_HEADER_SIZE 12
24+#define WEXT_CSCAN_SSID_SECTION 'S'
25+#define WEXT_CSCAN_CHANNEL_SECTION 'C'
26+#define WEXT_CSCAN_NPROBE_SECTION 'N'
27+#define WEXT_CSCAN_ACTV_DWELL_SECTION 'A'
28+#define WEXT_CSCAN_PASV_DWELL_SECTION 'P'
29+#define WEXT_CSCAN_HOME_DWELL_SECTION 'H'
30+#define WEXT_CSCAN_TYPE_SECTION 'T'
31+#define WEXT_CSCAN_TYPE_DEFAULT 0
32+#define WEXT_CSCAN_TYPE_PASSIVE 1
33+#define WEXT_CSCAN_PASV_DWELL_TIME 130
34+#define WEXT_CSCAN_PASV_DWELL_TIME_DEF 250
35+#define WEXT_CSCAN_PASV_DWELL_TIME_MAX 3000
36+#define WEXT_CSCAN_HOME_DWELL_TIME 130
37+
38+#endif /* DRIVER_CMD_WEXT_H */
--- /dev/null
+++ b/private_lib/driver_nl80211.h
@@ -0,0 +1,150 @@
1+/*
2+ * Driver interaction with Linux nl80211/cfg80211
3+ * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>
4+ * Copyright (c) 2003-2004, Instant802 Networks, Inc.
5+ * Copyright (c) 2005-2006, Devicescape Software, Inc.
6+ * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
7+ * Copyright (c) 2009-2010, Atheros Communications
8+ *
9+ * This program is free software; you can redistribute it and/or modify
10+ * it under the terms of the GNU General Public License version 2 as
11+ * published by the Free Software Foundation.
12+ *
13+ * Alternatively, this software may be distributed under the terms of BSD
14+ * license.
15+ *
16+ * See README and COPYING for more details.
17+ */
18+
19+#ifndef _DRIVER_NL80211_H_
20+#define _DRIVER_NL80211_H_
21+
22+#include "includes.h"
23+#include <sys/ioctl.h>
24+#include <sys/types.h>
25+#include <sys/stat.h>
26+#include <fcntl.h>
27+#include <net/if.h>
28+#include <netlink/genl/genl.h>
29+#include <netlink/genl/family.h>
30+#include <netlink/genl/ctrl.h>
31+#include <linux/rtnetlink.h>
32+#include <netpacket/packet.h>
33+#include <linux/filter.h>
34+#include "nl80211_copy.h"
35+
36+#include "common.h"
37+#include "eloop.h"
38+#include "utils/list.h"
39+#include "common/ieee802_11_defs.h"
40+#include "netlink.h"
41+#include "linux_ioctl.h"
42+#include "radiotap.h"
43+#include "radiotap_iter.h"
44+#include "rfkill.h"
45+#include "driver.h"
46+
47+#ifdef CONFIG_LIBNL20
48+/* libnl 2.0 compatibility code */
49+#define nl_handle nl_sock
50+#define nl80211_handle_alloc nl_socket_alloc_cb
51+#define nl80211_handle_destroy nl_socket_free
52+#endif /* CONFIG_LIBNL20 */
53+
54+#ifndef IFF_LOWER_UP
55+#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
56+#endif
57+#ifndef IFF_DORMANT
58+#define IFF_DORMANT 0x20000 /* driver signals dormant */
59+#endif
60+
61+#ifndef IF_OPER_DORMANT
62+#define IF_OPER_DORMANT 5
63+#endif
64+#ifndef IF_OPER_UP
65+#define IF_OPER_UP 6
66+#endif
67+
68+struct nl80211_global {
69+ struct dl_list interfaces;
70+};
71+
72+struct i802_bss {
73+ struct wpa_driver_nl80211_data *drv;
74+ struct i802_bss *next;
75+ int ifindex;
76+ char ifname[IFNAMSIZ + 1];
77+ char brname[IFNAMSIZ];
78+ unsigned int beacon_set:1;
79+ unsigned int added_if_into_bridge:1;
80+ unsigned int added_bridge:1;
81+};
82+
83+struct wpa_driver_nl80211_data {
84+ struct nl80211_global *global;
85+ struct dl_list list;
86+ u8 addr[ETH_ALEN];
87+ char phyname[32];
88+ void *ctx;
89+ struct netlink_data *netlink;
90+ int ioctl_sock; /* socket for ioctl() use */
91+ int ifindex;
92+ int if_removed;
93+ int if_disabled;
94+ struct rfkill_data *rfkill;
95+ struct wpa_driver_capa capa;
96+ int has_capability;
97+
98+ int operstate;
99+
100+ int scan_complete_events;
101+
102+ struct nl_handle *nl_handle;
103+ struct nl_handle *nl_handle_event;
104+ struct nl_handle *nl_handle_preq;
105+ struct nl_cache *nl_cache;
106+ struct nl_cache *nl_cache_event;
107+ struct nl_cache *nl_cache_preq;
108+ struct nl_cb *nl_cb;
109+ struct genl_family *nl80211;
110+
111+ u8 auth_bssid[ETH_ALEN];
112+ u8 bssid[ETH_ALEN];
113+ int associated;
114+ u8 ssid[32];
115+ size_t ssid_len;
116+ int nlmode;
117+ int ap_scan_as_station;
118+ unsigned int assoc_freq;
119+
120+ int monitor_sock;
121+ int monitor_ifidx;
122+ int no_monitor_iface_capab;
123+ int disable_11b_rates;
124+
125+ unsigned int pending_remain_on_chan:1;
126+
127+ u64 remain_on_chan_cookie;
128+ u64 send_action_cookie;
129+
130+ unsigned int last_mgmt_freq;
131+ unsigned int ap_oper_freq;
132+
133+ struct wpa_driver_scan_filter *filter_ssids;
134+ size_t num_filter_ssids;
135+
136+ struct i802_bss first_bss;
137+
138+#ifdef HOSTAPD
139+ int eapol_sock; /* socket for EAPOL frames */
140+
141+ int default_if_indices[16];
142+ int *if_indices;
143+ int num_if_indices;
144+
145+ int last_freq;
146+ int last_freq_ht;
147+#endif /* HOSTAPD */
148+};
149+
150+#endif
Show on old repository browser