From fdcfc008be76273c36f2393673f38bc30504dfc1 Mon Sep 17 00:00:00 2001 From: Legrand Benjamin Date: Sun, 17 Feb 2013 23:05:05 +0100 Subject: [PATCH] Fix authenticaiton behavior for AP and STA mode --- drivers/ar6000/os/linux/ar6000_drv.c | 18 ++++--- drivers/ar6000/os/linux/include/ar6000_drv.h | 12 ++++- drivers/ar6000/os/linux/ioctl.c | 50 ++++++++++++++------ 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/drivers/ar6000/os/linux/ar6000_drv.c b/drivers/ar6000/os/linux/ar6000_drv.c index cf46d167..facde2d1 100644 --- a/drivers/ar6000/os/linux/ar6000_drv.c +++ b/drivers/ar6000/os/linux/ar6000_drv.c @@ -2,7 +2,7 @@ // // Copyright (c) 2004-2009 Atheros Corporation. All rights reserved. // Copyright (C) 2010 Sony Ericsson Mobile Communications AB -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation; @@ -1600,7 +1600,7 @@ static void ar6000_enable_mmchost_detect_change(int enable) char buf[3]; int length; length = snprintf(buf, sizeof(buf), "%d\n", enable ? 1 : 0); - if (ar6000_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/detect_change", + if (ar6000_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/detect_change", NULL, buf, length) < 0) { /* fall back to polling */ ar6000_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/polling", NULL, buf, length); @@ -2503,6 +2503,7 @@ void ar6000_init_profile_info(AR_SOFTC_T *ar) ar->arDot11AuthMode = OPEN_AUTH; ar->arAuthMode = NONE_AUTH; ar->arPairwiseCrypto = NONE_CRYPT; + //ar->arPairwiseApCrypto = NONE_CRYPT; ar->arPairwiseCryptoLen = 0; ar->arGroupCrypto = NONE_CRYPT; ar->arGroupCryptoLen = 0; @@ -4315,7 +4316,7 @@ ar6000_disconnect_event(AR_SOFTC_T *ar, A_UINT8 reason, A_UINT8 *bssid, if (NO_NETWORK_AVAIL != reason) { - union iwreq_data wrqu; + union iwreq_data wrqu; A_MEMZERO(&wrqu, sizeof(wrqu)); A_MEMCPY(wrqu.addr.sa_data, "\x00\x00\x00\x00\x00\x00", IEEE80211_ADDR_LEN); wrqu.addr.sa_family = ARPHRD_ETHER; @@ -5409,6 +5410,9 @@ ar6000_ap_mode_profile_commit(struct ar6_softc *ar) return -ECHRNG; } + //Force change to use arPairwiseApCrypto. + //ar->arPairwiseCrypto = ar->arPairwiseApCrypto; + if(ar->arPairwiseCrypto != ar->arGroupCrypto) { A_PRINTF("Mixed cipher not supported in AP mode\n"); return -EOPNOTSUPP; @@ -5502,7 +5506,7 @@ ar6000_connect_to_ap(struct ar6_softc *ar) */ if((ar->arWmiReady == TRUE) && (ar->arSsidLen > 0) && ar->arNetworkType!=AP_NETWORK) { - A_STATUS status; + A_STATUS status; if((ADHOC_NETWORK != ar->arNetworkType) && (NONE_AUTH==ar->arAuthMode) && (WEP_CRYPT==ar->arPairwiseCrypto)) { @@ -5532,7 +5536,7 @@ ar6000_connect_to_ap(struct ar6_softc *ar) if ((ar->arNetworkType == INFRA_NETWORK)) { wmi_listeninterval_cmd(ar->arWmi, 1000, 0); } - + ar->arConnectPending = TRUE; ar->wmm_vi_throttle_flag = 0; @@ -5552,8 +5556,8 @@ ar6000_connect_to_ap(struct ar6_softc *ar) } ar->arPrevCrypto = ar->arPairwiseCrypto; - - return status; + + return status; } return A_ERROR; } diff --git a/drivers/ar6000/os/linux/include/ar6000_drv.h b/drivers/ar6000/os/linux/include/ar6000_drv.h index a80fc9ce..ca25d605 100755 --- a/drivers/ar6000/os/linux/include/ar6000_drv.h +++ b/drivers/ar6000/os/linux/include/ar6000_drv.h @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) 2004-2009 Atheros Corporation. All rights reserved. -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation; @@ -259,6 +259,16 @@ typedef struct ar6_softc { A_UINT8 arPrevCrypto; A_UINT8 arPairwiseCrypto; A_UINT8 arPairwiseCryptoLen; +#if 0 + //Add field for the AP mode, we need to store some specific information + //But we don't know yet if we are in AP or STA mode at this time + A_UINT8 arPairwiseApCrypto; + //Add some padding in order to keep structure alignment + A_UINT8 padding1; + A_UINT8 padding2; + A_UINT8 padding4; + //Finished AP mode specific padding +#endif A_UINT8 arGroupCrypto; A_UINT8 arGroupCryptoLen; A_UINT8 arDefTxKeyIndex; diff --git a/drivers/ar6000/os/linux/ioctl.c b/drivers/ar6000/os/linux/ioctl.c index a8f8662a..921898f8 100755 --- a/drivers/ar6000/os/linux/ioctl.c +++ b/drivers/ar6000/os/linux/ioctl.c @@ -2,7 +2,7 @@ // // Copyright (c) 2004-2009 Atheros Corporation. All rights reserved. // Copyright (C) 2010 Sony Ericsson Mobile Communications AB -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation; @@ -1194,23 +1194,45 @@ ar6000_ioctl_setparam(AR_SOFTC_T *ar, int param, int value) } break; case IEEE80211_PARAM_UCASTCIPHER: - switch (value) { - case IEEE80211_CIPHER_AES_CCM: + /* + * SCRITCH FIX for HOSTAPD + * Ok so now we need to convert the way hostapd works into expected behavior + */ + + if (ar->arNextMode == AP_NETWORK) + { + pr_info("Setting Pairwise Crypto for AP mode"); + if (value & (1 << IEEE80211_CIPHER_AES_CCM) ) + { ar->arPairwiseCrypto = AES_CRYPT; - profChanged = TRUE; - break; - case IEEE80211_CIPHER_TKIP: + } else if( value & (1 << IEEE80211_CIPHER_TKIP)){ ar->arPairwiseCrypto = TKIP_CRYPT; - profChanged = TRUE; - break; - case IEEE80211_CIPHER_WEP: + } else if (value & (1 << IEEE80211_CIPHER_WEP)) + { ar->arPairwiseCrypto = WEP_CRYPT; - profChanged = TRUE; - break; - case IEEE80211_CIPHER_NONE: + }else{ ar->arPairwiseCrypto = NONE_CRYPT; - profChanged = TRUE; - break; + } + }else{ + pr_info("Setting Pairwise Crypto for STA mode"); + switch (value) { + case IEEE80211_CIPHER_AES_CCM: + ar->arPairwiseCrypto = AES_CRYPT; + profChanged = TRUE; + break; + case IEEE80211_CIPHER_TKIP: + ar->arPairwiseCrypto = TKIP_CRYPT; + profChanged = TRUE; + break; + case IEEE80211_CIPHER_WEP: + ar->arPairwiseCrypto = WEP_CRYPT; + profChanged = TRUE; + break; + case IEEE80211_CIPHER_NONE: + ar->arPairwiseCrypto = NONE_CRYPT; + profChanged = TRUE; + break; + } } break; case IEEE80211_PARAM_UCASTKEYLEN: