summaryrefslogtreecommitdiffstats
path: root/meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch')
-rw-r--r--meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch535
1 files changed, 0 insertions, 535 deletions
diff --git a/meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch b/meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch
deleted file mode 100644
index 3c731c1256..0000000000
--- a/meta/packages/wpa-supplicant/wpa-supplicant-0.4.7/driver-zd1211.patch
+++ /dev/null
@@ -1,535 +0,0 @@
1diff -Nur wpa_supplicant-0.4.7/defconfig wpa_supplicant-0.4.7.new/defconfig
2--- wpa_supplicant-0.4.7/defconfig 2005-09-24 20:30:43.000000000 +0200
3+++ wpa_supplicant-0.4.7.new/defconfig 2005-12-26 19:18:14.000000000 +0100
4@@ -68,6 +68,9 @@
5 # Driver interface for Intel ipw2100/2200 driver
6 #CONFIG_DRIVER_IPW=y
7
8+# Driver interface for Zydas zd1211 driver
9+#CONFIG_DRIVER_ZD1211=y
10+
11 # Driver interface for generic Linux wireless extensions
12 CONFIG_DRIVER_WEXT=y
13
14diff -Nur wpa_supplicant-0.4.7/drivers.c wpa_supplicant-0.4.7.new/drivers.c
15--- wpa_supplicant-0.4.7/drivers.c 2005-02-20 01:15:54.000000000 +0100
16+++ wpa_supplicant-0.4.7.new/drivers.c 2005-12-26 19:19:16.000000000 +0100
17@@ -55,6 +55,9 @@
18 #ifdef CONFIG_DRIVER_TEST
19 extern struct wpa_driver_ops wpa_driver_test_ops; /* driver_test.c */
20 #endif /* CONFIG_DRIVER_TEST */
21+#ifdef CONFIG_DRIVER_ZD1211
22+extern struct wpa_driver_ops wpa_driver_zd1211_ops; /* driver_zd1211.c */
23+#endif /* CONFIG_DRIVER_ZD1211 */
24
25
26 struct wpa_driver_ops *wpa_supplicant_drivers[] =
27@@ -98,5 +101,8 @@
28 #ifdef CONFIG_DRIVER_TEST
29 &wpa_driver_test_ops,
30 #endif /* CONFIG_DRIVER_TEST */
31+#ifdef CONFIG_DRIVER_ZD1211
32+ &wpa_driver_zd1211_ops,
33+#endif /* CONFIG_DRIVER_ZD1211 */
34 NULL
35 };
36diff -Nur wpa_supplicant-0.4.7/driver_zd1211.c wpa_supplicant-0.4.7.new/driver_zd1211.c
37--- wpa_supplicant-0.4.7/driver_zd1211.c 1970-01-01 01:00:00.000000000 +0100
38+++ wpa_supplicant-0.4.7.new/driver_zd1211.c 2005-12-27 16:28:46.000000000 +0100
39@@ -0,0 +1,408 @@
40+#include <stdlib.h>
41+#include <stdio.h>
42+#include <unistd.h>
43+#include <string.h>
44+#include <sys/ioctl.h>
45+#include <errno.h>
46+
47+#include "common.h"
48+#include "driver.h"
49+#include "driver_wext.h"
50+#include "eloop.h"
51+#include "wireless_copy.h"
52+#include "wpa_supplicant.h"
53+
54+#include "zd1211_common.h"
55+
56+
57+struct wpa_driver_zd1211_data {
58+ void *ctx;
59+ void *wext; /* private data for driver_wext */
60+ char ifname[IFNAMSIZ + 1];
61+ int sock;
62+};
63+
64+
65+static int zd1211_ioctl(struct wpa_driver_zd1211_data *zd1211_drv, struct zd1211_wlan_param *param, int len, int show_err) {
66+ struct iwreq iwr;
67+
68+ memset(&iwr, 0, sizeof(iwr));
69+ strncpy(iwr.ifr_name, zd1211_drv->ifname, IFNAMSIZ);
70+ iwr.u.data.pointer = (caddr_t) param;
71+ iwr.u.data.length = len;
72+
73+ if (ioctl(zd1211_drv->sock, ZD_IOCTL_WPA, &iwr) < 0) {
74+ int ret;
75+
76+ ret = errno;
77+ if (show_err)
78+ perror("ioctl[ZD_IOCTL_WPA]");
79+ return ret;
80+ }
81+
82+ return 0;
83+}
84+
85+
86+static int zd1211_set_param(struct wpa_driver_zd1211_data *zd1211_drv, int op, int arg, int show_err) {
87+ struct iwreq iwr;
88+ int *i, ret = 0;
89+
90+ memset(&iwr, 0, sizeof(iwr));
91+ strncpy(iwr.ifr_name, zd1211_drv->ifname, IFNAMSIZ);
92+ i = (int *) iwr.u.name;
93+ *i++ = op;
94+ *i++ = arg;
95+
96+ if (ioctl(zd1211_drv->sock, ZD_IOCTL_PARAM, &iwr) < 0) {
97+ perror("ioctl[ZD_IOCTL_PARAM]");
98+ ret = -1;
99+ }
100+
101+ return ret;
102+}
103+
104+
105+static int wpa_driver_zd1211_get_scan_results(void *priv, struct wpa_scan_result *results, size_t max_size) {
106+ struct wpa_driver_zd1211_data *zd1211_drv;
107+
108+ zd1211_drv = priv;
109+ return wpa_driver_wext_get_scan_results(zd1211_drv->wext, results, max_size);
110+}
111+
112+
113+static int wpa_driver_zd1211_get_bssid(void *priv, u8 *bssid) {
114+ struct wpa_driver_zd1211_data *zd1211_drv;
115+
116+ zd1211_drv = priv;
117+ return wpa_driver_wext_get_bssid(zd1211_drv->wext, bssid);
118+}
119+
120+
121+static int wpa_driver_zd1211_get_ssid(void *priv, u8 *ssid) {
122+ struct wpa_driver_zd1211_data *zd1211_drv;
123+
124+ zd1211_drv = priv;
125+ return wpa_driver_wext_get_ssid(zd1211_drv->wext, ssid);
126+}
127+
128+
129+static int wpa_driver_zd1211_set_auth_alg(void *priv, int auth_alg) {
130+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
131+ int algs = 0;
132+
133+ if (auth_alg & AUTH_ALG_OPEN_SYSTEM)
134+ algs = 0;
135+ if (auth_alg & AUTH_ALG_SHARED_KEY)
136+ algs = 1;
137+
138+ return zd1211_set_param(zd1211_drv, ZD_PARAM_AUTH_ALGS, algs, 1);
139+}
140+
141+
142+static int wpa_driver_zd1211_set_countermeasures(void *priv, int enabled) {
143+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
144+
145+ /* Enable the countermeasure */
146+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
147+ return zd1211_set_param(zd1211_drv, ZD_PARAM_COUNTERMEASURES, enabled, 1);
148+}
149+
150+
151+static int wpa_driver_zd1211_set_drop_unencrypted(void *priv, int enabled) {
152+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
153+
154+ /* Enable the countermeasure */
155+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
156+ return zd1211_set_param(zd1211_drv, ZD_PARAM_DROPUNENCRYPTED, enabled, 1);
157+}
158+
159+
160+static int wpa_driver_zd1211_set_key(void *priv, wpa_alg alg,
161+ const u8 *addr, int key_idx,
162+ int set_tx, const u8 *seq, size_t seq_len,
163+ const u8 *key, size_t key_len) {
164+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
165+ struct zd1211_wlan_param *param;
166+ u8 *buf;
167+ size_t blen;
168+ int ret = 0;
169+ char *alg_name;
170+
171+ switch (alg) {
172+ case WPA_ALG_NONE:
173+ alg_name = "NONE";
174+ break;
175+ case WPA_ALG_WEP:
176+ alg_name = "WEP";
177+ break;
178+ case WPA_ALG_TKIP:
179+ alg_name = "TKIP";
180+ break;
181+ case WPA_ALG_CCMP:
182+ alg_name = "CCMP";
183+ break;
184+ default:
185+ return -1;
186+ }
187+
188+ wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%d "
189+ "key_len=%d", __FUNCTION__, alg_name, key_idx, set_tx,
190+ seq_len, key_len);
191+
192+ if (seq_len > 8)
193+ return -2;
194+
195+ blen = sizeof(*param) + key_len;
196+ buf = malloc(blen);
197+ if (buf == NULL)
198+ return -1;
199+ memset(buf, 0, blen);
200+
201+ param = (struct zd1211_wlan_param *) buf;
202+ param->cmd = ZD_CMD_SET_ENCRYPT_KEY;
203+ /* TODO: In theory, STA in client mode can use five keys; four default
204+ * keys for receiving (with keyidx 0..3) and one individual key for
205+ * both transmitting and receiving (keyidx 0) _unicast_ packets. Now,
206+ * keyidx 0 is reserved for this unicast use and default keys can only
207+ * use keyidx 1..3 (i.e., default key with keyidx 0 is not supported).
208+ * This should be fine for more or less all cases, but for completeness
209+ * sake, the driver could be enhanced to support the missing key. */
210+#if 0
211+ if (addr == NULL)
212+ memset(param->sta_addr, 0xff, ETH_ALEN);
213+ else
214+ memcpy(param->sta_addr, addr, ETH_ALEN);
215+#else
216+ memset(param->sta_addr, 0xff, ETH_ALEN);
217+#endif
218+ strncpy(param->u.crypt.alg, alg_name, ZD_CRYPT_ALG_NAME_LEN);
219+ param->u.crypt.flags = set_tx ? ZD_FLAG_SET_TX_KEY : 0;
220+ param->u.crypt.idx = key_idx;
221+ memcpy(param->u.crypt.seq, seq, seq_len);
222+ param->u.crypt.key_len = key_len;
223+ memcpy((u8 *) param->u.crypt.key, key, key_len);
224+
225+ /* Dump key context */
226+ if(alg == WPA_ALG_TKIP) {
227+ int ii;
228+
229+ wpa_printf(MSG_DEBUG, "Key Context:");
230+ for(ii = 0; ii < key_len; ) {
231+ printf("0x%02x ", key[ii]);
232+
233+ if((++ii % 16) == 0)
234+ printf("\n");
235+ }
236+
237+ printf("\n");
238+ }
239+
240+ if (zd1211_ioctl(zd1211_drv, param, blen, 1)) {
241+ wpa_printf(MSG_WARNING, "Failed to set encryption.");
242+ //show_set_key_error(param);
243+ ret = -1;
244+ }
245+ free(buf);
246+
247+ return ret;
248+}
249+
250+
251+static int wpa_driver_zd1211_set_wpa_ie(struct wpa_driver_zd1211_data *zd1211_drv, const u8 *wpa_ie, size_t wpa_ie_len) {
252+ int res;
253+ struct zd1211_wlan_param *param;
254+ size_t blen = ZD_GENERIC_ELEMENT_HDR_LEN + wpa_ie_len;
255+
256+ if (blen < sizeof(*param))
257+ blen = sizeof(*param);
258+
259+ param = (struct zd1211_wlan_param *) malloc(blen);
260+ if (param == NULL)
261+ return -1;
262+
263+ memset(param, 0, blen);
264+ param->cmd = ZD_CMD_SET_GENERIC_ELEMENT;
265+ param->u.generic_elem.len = wpa_ie_len;
266+ memcpy(param->u.generic_elem.data, wpa_ie, wpa_ie_len);
267+ res = zd1211_ioctl(zd1211_drv, param, blen, 1);
268+
269+ free(param);
270+
271+ return res;
272+}
273+
274+
275+static int wpa_driver_zd1211_set_wpa(void *priv, int enabled) {
276+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
277+ int ret = 0;
278+
279+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
280+
281+ if (!enabled && wpa_driver_zd1211_set_wpa_ie(zd1211_drv, NULL, 0) < 0)
282+ ret = -1;
283+ if (zd1211_set_param(zd1211_drv, ZD_PARAM_ROAMING, enabled, 1) < 0)
284+ ret = -1;
285+ if (zd1211_set_param(zd1211_drv, ZD_PARAM_PRIVACY, enabled, 1) < 0)
286+ ret = -1;
287+ if (zd1211_set_param(zd1211_drv, ZD_PARAM_WPA, enabled, 1) < 0)
288+ ret = -1;
289+
290+ return ret;
291+}
292+
293+
294+static int wpa_driver_zd1211_associate(void *priv, struct wpa_driver_associate_params *params) {
295+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
296+ int ret = 0;
297+
298+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
299+
300+ /* Because there might be the case, two or more APs with the same
301+ * SSID, in order to identify them, we need to set the BSSID. */
302+ if (wpa_driver_zd1211_set_wpa_ie(zd1211_drv, params->wpa_ie, params->wpa_ie_len) < 0)
303+ ret = -1;
304+ if (wpa_driver_wext_set_ssid(zd1211_drv->wext, params->ssid, params->ssid_len) < 0)
305+ ret = -1;
306+
307+ // Mark for test
308+ //if (wpa_driver_wext_set_bssid(ifname, bssid) < 0)
309+ // ret = -1;
310+
311+#if 0
312+ /* Allow unencrypted EAPOL messages even if pairwise keys are set when
313+ * not using WPA. IEEE 802.1X specifies that these frames are not
314+ * encrypted, but WPA encrypts them when pairwise keys are in use. */
315+ if (key_mgmt_suite == KEY_MGMT_802_1X ||
316+ key_mgmt_suite == KEY_MGMT_PSK)
317+ allow_unencrypted_eapol = 0;
318+ else
319+ allow_unencrypted_eapol = 1;
320+
321+ if (prism2param(ifname, PRISM2_PARAM_IEEE_802_1X,
322+ allow_unencrypted_eapol) < 0) {
323+ wpa_printf(MSG_DEBUG, "hostap: Failed to configure "
324+ "ieee_802_1x param");
325+ /* Ignore this error.. driver_hostap.c can also be used with
326+ * other drivers that do not support this prism2_param. */
327+ }
328+#endif
329+
330+ return ret;
331+}
332+
333+
334+static int wpa_driver_zd1211_deauthenticate(void *priv, const u8 *addr, int reason_code) {
335+ struct zd1211_wlan_param *param;
336+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
337+ int blen;
338+ int ret;
339+
340+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
341+
342+ blen = sizeof(*param);
343+ param = (struct zd1211_wlan_param *) malloc(blen);
344+ if (param == NULL)
345+ return -1;
346+
347+ memset(param, 0, blen);
348+ param->cmd = ZD_CMD_SET_MLME;
349+ param->u.mlme.cmd = MLME_STA_DEAUTH;
350+ param->u.mlme.reason_code = reason_code;
351+ memcpy(param->sta_addr, addr, ETH_ALEN);
352+ ret = zd1211_ioctl(zd1211_drv, param, blen, 1);
353+ usleep(100000);
354+ free(param);
355+ return ret;
356+}
357+
358+
359+static int wpa_driver_zd1211_disassociate(void *priv, const u8 *addr, int reason_code) {
360+ struct zd1211_wlan_param *param;
361+ struct wpa_driver_zd1211_data *zd1211_drv = priv;
362+ int blen;
363+ int ret;
364+
365+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
366+
367+ blen = sizeof(*param);
368+ param = (struct zd1211_wlan_param *) malloc(blen);
369+ if (param == NULL)
370+ return -1;
371+
372+ memset(param, 0, blen);
373+ param->cmd = ZD_CMD_SET_MLME;
374+ param->u.mlme.cmd = MLME_STA_DISASSOC;
375+ param->u.mlme.reason_code = reason_code;
376+ memcpy(param->sta_addr, addr, ETH_ALEN);
377+ ret = zd1211_ioctl(zd1211_drv, param, blen, 1);
378+ free(param);
379+ return ret;
380+}
381+
382+
383+static int wpa_driver_zd1211_scan(void *priv, const u8 *ssid, size_t ssid_len) {
384+ struct wpa_driver_zd1211_data *zd1211_drv;
385+
386+ zd1211_drv = priv;
387+ return wpa_driver_wext_scan(zd1211_drv->wext, ssid, ssid_len);
388+}
389+
390+
391+static void * wpa_driver_zd1211_init(void *ctx, const char *ifname) {
392+ struct wpa_driver_zd1211_data *zd1211_drv;
393+
394+ zd1211_drv = malloc(sizeof(*zd1211_drv));
395+ if (zd1211_drv == NULL)
396+ return NULL;
397+ memset(zd1211_drv, 0, sizeof(*zd1211_drv));
398+
399+ zd1211_drv->wext = wpa_driver_wext_init(ctx, ifname);
400+ if (zd1211_drv->wext == NULL)
401+ goto exit_no_wext;
402+
403+ zd1211_drv->ctx = ctx;
404+ strncpy(zd1211_drv->ifname, ifname, sizeof(zd1211_drv->ifname));
405+
406+ zd1211_drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
407+ if (zd1211_drv->sock < 0)
408+ goto exit_no_socket;
409+
410+ return zd1211_drv;
411+
412+exit_no_socket:
413+ wpa_driver_wext_deinit(zd1211_drv->wext);
414+exit_no_wext:
415+ free(zd1211_drv);
416+ return NULL;
417+}
418+
419+
420+static void wpa_driver_zd1211_deinit(void *ctx) {
421+ struct wpa_driver_zd1211_data *zd1211_drv = ctx;
422+
423+ wpa_driver_wext_deinit(zd1211_drv->wext);
424+ close(zd1211_drv->sock);
425+ free(zd1211_drv);
426+}
427+
428+
429+struct wpa_driver_ops wpa_driver_zd1211_ops = {
430+ .name = "zd1211",
431+ .desc = "Zydas zd1211 drivers",
432+ .init = wpa_driver_zd1211_init,
433+ .deinit = wpa_driver_zd1211_deinit,
434+ .associate = wpa_driver_zd1211_associate,
435+ .deauthenticate = wpa_driver_zd1211_deauthenticate,
436+ .disassociate = wpa_driver_zd1211_disassociate,
437+ .get_bssid = wpa_driver_zd1211_get_bssid,
438+ .get_scan_results = wpa_driver_zd1211_get_scan_results,
439+ .get_ssid = wpa_driver_zd1211_get_ssid,
440+// .get_capa = wpa_driver_zd1211_get_capa,
441+ .scan = wpa_driver_zd1211_scan,
442+ .set_auth_alg = wpa_driver_zd1211_set_auth_alg,
443+ .set_countermeasures = wpa_driver_zd1211_set_countermeasures,
444+ .set_drop_unencrypted = wpa_driver_zd1211_set_drop_unencrypted,
445+ .set_key = wpa_driver_zd1211_set_key,
446+ .set_wpa = wpa_driver_zd1211_set_wpa,
447+};
448diff -Nur wpa_supplicant-0.4.7/Makefile wpa_supplicant-0.4.7.new/Makefile
449--- wpa_supplicant-0.4.7/Makefile 2005-11-21 02:42:12.000000000 +0100
450+++ wpa_supplicant-0.4.7.new/Makefile 2005-12-26 19:17:14.000000000 +0100
451@@ -107,6 +107,12 @@
452 CONFIG_WIRELESS_EXTENSION=y
453 endif
454
455+ifdef CONFIG_DRIVER_ZD1211
456+CFLAGS += -DCONFIG_DRIVER_ZD1211
457+OBJS_d += driver_zd1211.o
458+CONFIG_WIRELESS_EXTENSION=y
459+endif
460+
461 ifdef CONFIG_DRIVER_BSD
462 CFLAGS += -DCONFIG_DRIVER_BSD
463 OBJS_d += driver_bsd.o
464diff -Nur wpa_supplicant-0.4.7/zd1211_common.h wpa_supplicant-0.4.7.new/zd1211_common.h
465--- wpa_supplicant-0.4.7/zd1211_common.h 1970-01-01 01:00:00.000000000 +0100
466+++ wpa_supplicant-0.4.7.new/zd1211_common.h 2005-12-27 16:00:36.000000000 +0100
467@@ -0,0 +1,68 @@
468+#ifndef ZD1211_COMMON_H
469+#define ZD1211_COMMON_H
470+
471+
472+#define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1)
473+#define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2)
474+
475+#define ZD_PARAM_ROAMING 0x0001
476+#define ZD_PARAM_PRIVACY 0x0002
477+#define ZD_PARAM_WPA 0x0003
478+#define ZD_PARAM_COUNTERMEASURES 0x0004
479+#define ZD_PARAM_DROPUNENCRYPTED 0x0005
480+#define ZD_PARAM_AUTH_ALGS 0x0006
481+
482+#define ZD_CMD_SET_ENCRYPT_KEY 0x0001
483+#define ZD_CMD_SET_MLME 0x0002
484+//#define ZD_CMD_SCAN_REQ 0x0003
485+#define ZD_CMD_SET_GENERIC_ELEMENT 0x0004
486+
487+#define ZD_FLAG_SET_TX_KEY 0x0001
488+
489+#define ZD_GENERIC_ELEMENT_HDR_LEN \
490+((int) (&((struct zd1211_wlan_param *) 0)->u.generic_elem.data))
491+
492+#define ZD_CRYPT_ALG_NAME_LEN 16
493+#define ZD_MAX_KEY_SIZE 32
494+#define ZD_MAX_GENERIC_SIZE 64
495+
496+/* structure definition */
497+
498+struct zd1211_wlan_param {
499+ u32 cmd;
500+ u8 sta_addr[ETH_ALEN];
501+ union {
502+ struct {
503+ u8 alg[ZD_CRYPT_ALG_NAME_LEN];
504+ u32 flags;
505+ u32 err;
506+ u8 idx;
507+ u8 seq[8]; /* sequence counter (set: RX, get: TX) */
508+ u16 key_len;
509+ u8 key[ZD_MAX_KEY_SIZE];
510+ } crypt;
511+/*
512+ struct {
513+ u32 flags_and;
514+ u32 flags_or;
515+ } set_flags_sta;
516+*/
517+ struct {
518+ u8 len;
519+ u8 data[ZD_MAX_GENERIC_SIZE];
520+ } generic_elem;
521+ struct {
522+#define MLME_STA_DEAUTH 0
523+#define MLME_STA_DISASSOC 1
524+ u16 cmd;
525+ u16 reason_code;
526+ } mlme;
527+ struct {
528+ u8 ssid_len;
529+ u8 ssid[32];
530+ } scan_req;
531+ } u;
532+};
533+
534+
535+#endif