diff options
Diffstat (limited to 'packages/wpa-supplicant/wpa-supplicant-0.4.9/driver-zd1211.patch')
-rw-r--r-- | packages/wpa-supplicant/wpa-supplicant-0.4.9/driver-zd1211.patch | 535 |
1 files changed, 535 insertions, 0 deletions
diff --git a/packages/wpa-supplicant/wpa-supplicant-0.4.9/driver-zd1211.patch b/packages/wpa-supplicant/wpa-supplicant-0.4.9/driver-zd1211.patch new file mode 100644 index 0000000000..3c731c1256 --- /dev/null +++ b/packages/wpa-supplicant/wpa-supplicant-0.4.9/driver-zd1211.patch @@ -0,0 +1,535 @@ +diff -Nur wpa_supplicant-0.4.7/defconfig wpa_supplicant-0.4.7.new/defconfig +--- wpa_supplicant-0.4.7/defconfig 2005-09-24 20:30:43.000000000 +0200 ++++ wpa_supplicant-0.4.7.new/defconfig 2005-12-26 19:18:14.000000000 +0100 +@@ -68,6 +68,9 @@ + # Driver interface for Intel ipw2100/2200 driver + #CONFIG_DRIVER_IPW=y + ++# Driver interface for Zydas zd1211 driver ++#CONFIG_DRIVER_ZD1211=y ++ + # Driver interface for generic Linux wireless extensions + CONFIG_DRIVER_WEXT=y + +diff -Nur wpa_supplicant-0.4.7/drivers.c wpa_supplicant-0.4.7.new/drivers.c +--- wpa_supplicant-0.4.7/drivers.c 2005-02-20 01:15:54.000000000 +0100 ++++ wpa_supplicant-0.4.7.new/drivers.c 2005-12-26 19:19:16.000000000 +0100 +@@ -55,6 +55,9 @@ + #ifdef CONFIG_DRIVER_TEST + extern struct wpa_driver_ops wpa_driver_test_ops; /* driver_test.c */ + #endif /* CONFIG_DRIVER_TEST */ ++#ifdef CONFIG_DRIVER_ZD1211 ++extern struct wpa_driver_ops wpa_driver_zd1211_ops; /* driver_zd1211.c */ ++#endif /* CONFIG_DRIVER_ZD1211 */ + + + struct wpa_driver_ops *wpa_supplicant_drivers[] = +@@ -98,5 +101,8 @@ + #ifdef CONFIG_DRIVER_TEST + &wpa_driver_test_ops, + #endif /* CONFIG_DRIVER_TEST */ ++#ifdef CONFIG_DRIVER_ZD1211 ++ &wpa_driver_zd1211_ops, ++#endif /* CONFIG_DRIVER_ZD1211 */ + NULL + }; +diff -Nur wpa_supplicant-0.4.7/driver_zd1211.c wpa_supplicant-0.4.7.new/driver_zd1211.c +--- wpa_supplicant-0.4.7/driver_zd1211.c 1970-01-01 01:00:00.000000000 +0100 ++++ wpa_supplicant-0.4.7.new/driver_zd1211.c 2005-12-27 16:28:46.000000000 +0100 +@@ -0,0 +1,408 @@ ++#include <stdlib.h> ++#include <stdio.h> ++#include <unistd.h> ++#include <string.h> ++#include <sys/ioctl.h> ++#include <errno.h> ++ ++#include "common.h" ++#include "driver.h" ++#include "driver_wext.h" ++#include "eloop.h" ++#include "wireless_copy.h" ++#include "wpa_supplicant.h" ++ ++#include "zd1211_common.h" ++ ++ ++struct wpa_driver_zd1211_data { ++ void *ctx; ++ void *wext; /* private data for driver_wext */ ++ char ifname[IFNAMSIZ + 1]; ++ int sock; ++}; ++ ++ ++static int zd1211_ioctl(struct wpa_driver_zd1211_data *zd1211_drv, struct zd1211_wlan_param *param, int len, int show_err) { ++ struct iwreq iwr; ++ ++ memset(&iwr, 0, sizeof(iwr)); ++ strncpy(iwr.ifr_name, zd1211_drv->ifname, IFNAMSIZ); ++ iwr.u.data.pointer = (caddr_t) param; ++ iwr.u.data.length = len; ++ ++ if (ioctl(zd1211_drv->sock, ZD_IOCTL_WPA, &iwr) < 0) { ++ int ret; ++ ++ ret = errno; ++ if (show_err) ++ perror("ioctl[ZD_IOCTL_WPA]"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++ ++static int zd1211_set_param(struct wpa_driver_zd1211_data *zd1211_drv, int op, int arg, int show_err) { ++ struct iwreq iwr; ++ int *i, ret = 0; ++ ++ memset(&iwr, 0, sizeof(iwr)); ++ strncpy(iwr.ifr_name, zd1211_drv->ifname, IFNAMSIZ); ++ i = (int *) iwr.u.name; ++ *i++ = op; ++ *i++ = arg; ++ ++ if (ioctl(zd1211_drv->sock, ZD_IOCTL_PARAM, &iwr) < 0) { ++ perror("ioctl[ZD_IOCTL_PARAM]"); ++ ret = -1; ++ } ++ ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_get_scan_results(void *priv, struct wpa_scan_result *results, size_t max_size) { ++ struct wpa_driver_zd1211_data *zd1211_drv; ++ ++ zd1211_drv = priv; ++ return wpa_driver_wext_get_scan_results(zd1211_drv->wext, results, max_size); ++} ++ ++ ++static int wpa_driver_zd1211_get_bssid(void *priv, u8 *bssid) { ++ struct wpa_driver_zd1211_data *zd1211_drv; ++ ++ zd1211_drv = priv; ++ return wpa_driver_wext_get_bssid(zd1211_drv->wext, bssid); ++} ++ ++ ++static int wpa_driver_zd1211_get_ssid(void *priv, u8 *ssid) { ++ struct wpa_driver_zd1211_data *zd1211_drv; ++ ++ zd1211_drv = priv; ++ return wpa_driver_wext_get_ssid(zd1211_drv->wext, ssid); ++} ++ ++ ++static int wpa_driver_zd1211_set_auth_alg(void *priv, int auth_alg) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ int algs = 0; ++ ++ if (auth_alg & AUTH_ALG_OPEN_SYSTEM) ++ algs = 0; ++ if (auth_alg & AUTH_ALG_SHARED_KEY) ++ algs = 1; ++ ++ return zd1211_set_param(zd1211_drv, ZD_PARAM_AUTH_ALGS, algs, 1); ++} ++ ++ ++static int wpa_driver_zd1211_set_countermeasures(void *priv, int enabled) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ ++ /* Enable the countermeasure */ ++ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); ++ return zd1211_set_param(zd1211_drv, ZD_PARAM_COUNTERMEASURES, enabled, 1); ++} ++ ++ ++static int wpa_driver_zd1211_set_drop_unencrypted(void *priv, int enabled) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ ++ /* Enable the countermeasure */ ++ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); ++ return zd1211_set_param(zd1211_drv, ZD_PARAM_DROPUNENCRYPTED, enabled, 1); ++} ++ ++ ++static int wpa_driver_zd1211_set_key(void *priv, wpa_alg alg, ++ const u8 *addr, int key_idx, ++ int set_tx, const u8 *seq, size_t seq_len, ++ const u8 *key, size_t key_len) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ struct zd1211_wlan_param *param; ++ u8 *buf; ++ size_t blen; ++ int ret = 0; ++ char *alg_name; ++ ++ switch (alg) { ++ case WPA_ALG_NONE: ++ alg_name = "NONE"; ++ break; ++ case WPA_ALG_WEP: ++ alg_name = "WEP"; ++ break; ++ case WPA_ALG_TKIP: ++ alg_name = "TKIP"; ++ break; ++ case WPA_ALG_CCMP: ++ alg_name = "CCMP"; ++ break; ++ default: ++ return -1; ++ } ++ ++ wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%d " ++ "key_len=%d", __FUNCTION__, alg_name, key_idx, set_tx, ++ seq_len, key_len); ++ ++ if (seq_len > 8) ++ return -2; ++ ++ blen = sizeof(*param) + key_len; ++ buf = malloc(blen); ++ if (buf == NULL) ++ return -1; ++ memset(buf, 0, blen); ++ ++ param = (struct zd1211_wlan_param *) buf; ++ param->cmd = ZD_CMD_SET_ENCRYPT_KEY; ++ /* TODO: In theory, STA in client mode can use five keys; four default ++ * keys for receiving (with keyidx 0..3) and one individual key for ++ * both transmitting and receiving (keyidx 0) _unicast_ packets. Now, ++ * keyidx 0 is reserved for this unicast use and default keys can only ++ * use keyidx 1..3 (i.e., default key with keyidx 0 is not supported). ++ * This should be fine for more or less all cases, but for completeness ++ * sake, the driver could be enhanced to support the missing key. */ ++#if 0 ++ if (addr == NULL) ++ memset(param->sta_addr, 0xff, ETH_ALEN); ++ else ++ memcpy(param->sta_addr, addr, ETH_ALEN); ++#else ++ memset(param->sta_addr, 0xff, ETH_ALEN); ++#endif ++ strncpy(param->u.crypt.alg, alg_name, ZD_CRYPT_ALG_NAME_LEN); ++ param->u.crypt.flags = set_tx ? ZD_FLAG_SET_TX_KEY : 0; ++ param->u.crypt.idx = key_idx; ++ memcpy(param->u.crypt.seq, seq, seq_len); ++ param->u.crypt.key_len = key_len; ++ memcpy((u8 *) param->u.crypt.key, key, key_len); ++ ++ /* Dump key context */ ++ if(alg == WPA_ALG_TKIP) { ++ int ii; ++ ++ wpa_printf(MSG_DEBUG, "Key Context:"); ++ for(ii = 0; ii < key_len; ) { ++ printf("0x%02x ", key[ii]); ++ ++ if((++ii % 16) == 0) ++ printf("\n"); ++ } ++ ++ printf("\n"); ++ } ++ ++ if (zd1211_ioctl(zd1211_drv, param, blen, 1)) { ++ wpa_printf(MSG_WARNING, "Failed to set encryption."); ++ //show_set_key_error(param); ++ ret = -1; ++ } ++ free(buf); ++ ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_set_wpa_ie(struct wpa_driver_zd1211_data *zd1211_drv, const u8 *wpa_ie, size_t wpa_ie_len) { ++ int res; ++ struct zd1211_wlan_param *param; ++ size_t blen = ZD_GENERIC_ELEMENT_HDR_LEN + wpa_ie_len; ++ ++ if (blen < sizeof(*param)) ++ blen = sizeof(*param); ++ ++ param = (struct zd1211_wlan_param *) malloc(blen); ++ if (param == NULL) ++ return -1; ++ ++ memset(param, 0, blen); ++ param->cmd = ZD_CMD_SET_GENERIC_ELEMENT; ++ param->u.generic_elem.len = wpa_ie_len; ++ memcpy(param->u.generic_elem.data, wpa_ie, wpa_ie_len); ++ res = zd1211_ioctl(zd1211_drv, param, blen, 1); ++ ++ free(param); ++ ++ return res; ++} ++ ++ ++static int wpa_driver_zd1211_set_wpa(void *priv, int enabled) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ int ret = 0; ++ ++ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); ++ ++ if (!enabled && wpa_driver_zd1211_set_wpa_ie(zd1211_drv, NULL, 0) < 0) ++ ret = -1; ++ if (zd1211_set_param(zd1211_drv, ZD_PARAM_ROAMING, enabled, 1) < 0) ++ ret = -1; ++ if (zd1211_set_param(zd1211_drv, ZD_PARAM_PRIVACY, enabled, 1) < 0) ++ ret = -1; ++ if (zd1211_set_param(zd1211_drv, ZD_PARAM_WPA, enabled, 1) < 0) ++ ret = -1; ++ ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_associate(void *priv, struct wpa_driver_associate_params *params) { ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ int ret = 0; ++ ++ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); ++ ++ /* Because there might be the case, two or more APs with the same ++ * SSID, in order to identify them, we need to set the BSSID. */ ++ if (wpa_driver_zd1211_set_wpa_ie(zd1211_drv, params->wpa_ie, params->wpa_ie_len) < 0) ++ ret = -1; ++ if (wpa_driver_wext_set_ssid(zd1211_drv->wext, params->ssid, params->ssid_len) < 0) ++ ret = -1; ++ ++ // Mark for test ++ //if (wpa_driver_wext_set_bssid(ifname, bssid) < 0) ++ // ret = -1; ++ ++#if 0 ++ /* Allow unencrypted EAPOL messages even if pairwise keys are set when ++ * not using WPA. IEEE 802.1X specifies that these frames are not ++ * encrypted, but WPA encrypts them when pairwise keys are in use. */ ++ if (key_mgmt_suite == KEY_MGMT_802_1X || ++ key_mgmt_suite == KEY_MGMT_PSK) ++ allow_unencrypted_eapol = 0; ++ else ++ allow_unencrypted_eapol = 1; ++ ++ if (prism2param(ifname, PRISM2_PARAM_IEEE_802_1X, ++ allow_unencrypted_eapol) < 0) { ++ wpa_printf(MSG_DEBUG, "hostap: Failed to configure " ++ "ieee_802_1x param"); ++ /* Ignore this error.. driver_hostap.c can also be used with ++ * other drivers that do not support this prism2_param. */ ++ } ++#endif ++ ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_deauthenticate(void *priv, const u8 *addr, int reason_code) { ++ struct zd1211_wlan_param *param; ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ int blen; ++ int ret; ++ ++ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); ++ ++ blen = sizeof(*param); ++ param = (struct zd1211_wlan_param *) malloc(blen); ++ if (param == NULL) ++ return -1; ++ ++ memset(param, 0, blen); ++ param->cmd = ZD_CMD_SET_MLME; ++ param->u.mlme.cmd = MLME_STA_DEAUTH; ++ param->u.mlme.reason_code = reason_code; ++ memcpy(param->sta_addr, addr, ETH_ALEN); ++ ret = zd1211_ioctl(zd1211_drv, param, blen, 1); ++ usleep(100000); ++ free(param); ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_disassociate(void *priv, const u8 *addr, int reason_code) { ++ struct zd1211_wlan_param *param; ++ struct wpa_driver_zd1211_data *zd1211_drv = priv; ++ int blen; ++ int ret; ++ ++ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); ++ ++ blen = sizeof(*param); ++ param = (struct zd1211_wlan_param *) malloc(blen); ++ if (param == NULL) ++ return -1; ++ ++ memset(param, 0, blen); ++ param->cmd = ZD_CMD_SET_MLME; ++ param->u.mlme.cmd = MLME_STA_DISASSOC; ++ param->u.mlme.reason_code = reason_code; ++ memcpy(param->sta_addr, addr, ETH_ALEN); ++ ret = zd1211_ioctl(zd1211_drv, param, blen, 1); ++ free(param); ++ return ret; ++} ++ ++ ++static int wpa_driver_zd1211_scan(void *priv, const u8 *ssid, size_t ssid_len) { ++ struct wpa_driver_zd1211_data *zd1211_drv; ++ ++ zd1211_drv = priv; ++ return wpa_driver_wext_scan(zd1211_drv->wext, ssid, ssid_len); ++} ++ ++ ++static void * wpa_driver_zd1211_init(void *ctx, const char *ifname) { ++ struct wpa_driver_zd1211_data *zd1211_drv; ++ ++ zd1211_drv = malloc(sizeof(*zd1211_drv)); ++ if (zd1211_drv == NULL) ++ return NULL; ++ memset(zd1211_drv, 0, sizeof(*zd1211_drv)); ++ ++ zd1211_drv->wext = wpa_driver_wext_init(ctx, ifname); ++ if (zd1211_drv->wext == NULL) ++ goto exit_no_wext; ++ ++ zd1211_drv->ctx = ctx; ++ strncpy(zd1211_drv->ifname, ifname, sizeof(zd1211_drv->ifname)); ++ ++ zd1211_drv->sock = socket(PF_INET, SOCK_DGRAM, 0); ++ if (zd1211_drv->sock < 0) ++ goto exit_no_socket; ++ ++ return zd1211_drv; ++ ++exit_no_socket: ++ wpa_driver_wext_deinit(zd1211_drv->wext); ++exit_no_wext: ++ free(zd1211_drv); ++ return NULL; ++} ++ ++ ++static void wpa_driver_zd1211_deinit(void *ctx) { ++ struct wpa_driver_zd1211_data *zd1211_drv = ctx; ++ ++ wpa_driver_wext_deinit(zd1211_drv->wext); ++ close(zd1211_drv->sock); ++ free(zd1211_drv); ++} ++ ++ ++struct wpa_driver_ops wpa_driver_zd1211_ops = { ++ .name = "zd1211", ++ .desc = "Zydas zd1211 drivers", ++ .init = wpa_driver_zd1211_init, ++ .deinit = wpa_driver_zd1211_deinit, ++ .associate = wpa_driver_zd1211_associate, ++ .deauthenticate = wpa_driver_zd1211_deauthenticate, ++ .disassociate = wpa_driver_zd1211_disassociate, ++ .get_bssid = wpa_driver_zd1211_get_bssid, ++ .get_scan_results = wpa_driver_zd1211_get_scan_results, ++ .get_ssid = wpa_driver_zd1211_get_ssid, ++// .get_capa = wpa_driver_zd1211_get_capa, ++ .scan = wpa_driver_zd1211_scan, ++ .set_auth_alg = wpa_driver_zd1211_set_auth_alg, ++ .set_countermeasures = wpa_driver_zd1211_set_countermeasures, ++ .set_drop_unencrypted = wpa_driver_zd1211_set_drop_unencrypted, ++ .set_key = wpa_driver_zd1211_set_key, ++ .set_wpa = wpa_driver_zd1211_set_wpa, ++}; +diff -Nur wpa_supplicant-0.4.7/Makefile wpa_supplicant-0.4.7.new/Makefile +--- wpa_supplicant-0.4.7/Makefile 2005-11-21 02:42:12.000000000 +0100 ++++ wpa_supplicant-0.4.7.new/Makefile 2005-12-26 19:17:14.000000000 +0100 +@@ -107,6 +107,12 @@ + CONFIG_WIRELESS_EXTENSION=y + endif + ++ifdef CONFIG_DRIVER_ZD1211 ++CFLAGS += -DCONFIG_DRIVER_ZD1211 ++OBJS_d += driver_zd1211.o ++CONFIG_WIRELESS_EXTENSION=y ++endif ++ + ifdef CONFIG_DRIVER_BSD + CFLAGS += -DCONFIG_DRIVER_BSD + OBJS_d += driver_bsd.o +diff -Nur wpa_supplicant-0.4.7/zd1211_common.h wpa_supplicant-0.4.7.new/zd1211_common.h +--- wpa_supplicant-0.4.7/zd1211_common.h 1970-01-01 01:00:00.000000000 +0100 ++++ wpa_supplicant-0.4.7.new/zd1211_common.h 2005-12-27 16:00:36.000000000 +0100 +@@ -0,0 +1,68 @@ ++#ifndef ZD1211_COMMON_H ++#define ZD1211_COMMON_H ++ ++ ++#define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1) ++#define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2) ++ ++#define ZD_PARAM_ROAMING 0x0001 ++#define ZD_PARAM_PRIVACY 0x0002 ++#define ZD_PARAM_WPA 0x0003 ++#define ZD_PARAM_COUNTERMEASURES 0x0004 ++#define ZD_PARAM_DROPUNENCRYPTED 0x0005 ++#define ZD_PARAM_AUTH_ALGS 0x0006 ++ ++#define ZD_CMD_SET_ENCRYPT_KEY 0x0001 ++#define ZD_CMD_SET_MLME 0x0002 ++//#define ZD_CMD_SCAN_REQ 0x0003 ++#define ZD_CMD_SET_GENERIC_ELEMENT 0x0004 ++ ++#define ZD_FLAG_SET_TX_KEY 0x0001 ++ ++#define ZD_GENERIC_ELEMENT_HDR_LEN \ ++((int) (&((struct zd1211_wlan_param *) 0)->u.generic_elem.data)) ++ ++#define ZD_CRYPT_ALG_NAME_LEN 16 ++#define ZD_MAX_KEY_SIZE 32 ++#define ZD_MAX_GENERIC_SIZE 64 ++ ++/* structure definition */ ++ ++struct zd1211_wlan_param { ++ u32 cmd; ++ u8 sta_addr[ETH_ALEN]; ++ union { ++ struct { ++ u8 alg[ZD_CRYPT_ALG_NAME_LEN]; ++ u32 flags; ++ u32 err; ++ u8 idx; ++ u8 seq[8]; /* sequence counter (set: RX, get: TX) */ ++ u16 key_len; ++ u8 key[ZD_MAX_KEY_SIZE]; ++ } crypt; ++/* ++ struct { ++ u32 flags_and; ++ u32 flags_or; ++ } set_flags_sta; ++*/ ++ struct { ++ u8 len; ++ u8 data[ZD_MAX_GENERIC_SIZE]; ++ } generic_elem; ++ struct { ++#define MLME_STA_DEAUTH 0 ++#define MLME_STA_DISASSOC 1 ++ u16 cmd; ++ u16 reason_code; ++ } mlme; ++ struct { ++ u8 ssid_len; ++ u8 ssid[32]; ++ } scan_req; ++ } u; ++}; ++ ++ ++#endif |