1398 lines
42 KiB
Diff
1398 lines
42 KiB
Diff
From 88f9b566e64c2eb84a6340052501c22fe973833e Mon Sep 17 00:00:00 2001
|
|
From: Mauro Carvalho Chehab <mchehab@infradead.org>
|
|
Date: Tue, 3 Nov 2009 07:17:24 -0200
|
|
Subject: [PATCH] Staging: rtl8192u: make it compile
|
|
|
|
commit f61fb9356d20977258bb59a8d9f1857d2c58ac98 upstream.
|
|
|
|
Add it to staging Kbuild and fixes some API differences that prevents
|
|
compilation.
|
|
|
|
It seems that the ieee80211 stack is very close to rtl8192su one.
|
|
|
|
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
[bwh: Adjust context for 2.6.32]
|
|
---
|
|
drivers/staging/Kconfig | 2 +
|
|
drivers/staging/Makefile | 1 +
|
|
drivers/staging/rtl8192u/Makefile | 1 +
|
|
drivers/staging/rtl8192u/ieee80211.h | 6 +-
|
|
.../staging/rtl8192u/ieee80211/ieee80211_crypt.c | 35 +---
|
|
.../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 62 +----
|
|
.../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 272 +-------------------
|
|
.../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 114 +--------
|
|
.../staging/rtl8192u/ieee80211/ieee80211_module.c | 82 +------
|
|
drivers/staging/rtl8192u/r8192U_core.c | 110 +++++---
|
|
10 files changed, 109 insertions(+), 576 deletions(-)
|
|
|
|
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
|
|
index b2901d8..805858e 100644
|
|
--- a/drivers/staging/Kconfig
|
|
+++ b/drivers/staging/Kconfig
|
|
@@ -79,6 +79,8 @@ source "drivers/staging/rtl8187se/Kconfig"
|
|
|
|
source "drivers/staging/rtl8192su/Kconfig"
|
|
|
|
+source "drivers/staging/rtl8192u/Kconfig"
|
|
+
|
|
source "drivers/staging/rtl8192e/Kconfig"
|
|
|
|
source "drivers/staging/frontier/Kconfig"
|
|
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
|
|
index b50162a..49bc2ff 100644
|
|
--- a/drivers/staging/Makefile
|
|
+++ b/drivers/staging/Makefile
|
|
@@ -22,6 +22,7 @@ obj-$(CONFIG_PANEL) += panel/
|
|
obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma/
|
|
obj-$(CONFIG_RTL8187SE) += rtl8187se/
|
|
obj-$(CONFIG_RTL8192SU) += rtl8192su/
|
|
+obj-$(CONFIG_RTL8192U) += rtl8192u/
|
|
obj-$(CONFIG_RTL8192E) += rtl8192e/
|
|
obj-$(CONFIG_TRANZPORT) += frontier/
|
|
obj-$(CONFIG_ANDROID) += android/
|
|
diff --git a/drivers/staging/rtl8192u/Makefile b/drivers/staging/rtl8192u/Makefile
|
|
index 9923690..2d59c4e 100644
|
|
--- a/drivers/staging/rtl8192u/Makefile
|
|
+++ b/drivers/staging/rtl8192u/Makefile
|
|
@@ -10,6 +10,7 @@ EXTRA_CFLAGS += -DTHOMAS_BEACON -DTHOMAS_TASKLET -DTHOMAS_SKB -DTHOMAS_TURBO
|
|
#EXTRA_CFLAGS += -DUSB_RX_AGGREGATION_SUPPORT
|
|
EXTRA_CFLAGS += -DUSE_ONE_PIPE
|
|
EXTRA_CFLAGS += -DENABLE_DOT11D
|
|
+EXTRA_CFLAGS += -Idrivers/staging/rtl8192u/ieee80211
|
|
|
|
r8192u_usb-objs := r8192U_core.o r8180_93cx6.o r8192U_wx.o \
|
|
r8190_rtl8256.o r819xU_phy.o r819xU_firmware.o \
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211.h b/drivers/staging/rtl8192u/ieee80211.h
|
|
index c182e91..690d41c 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211.h
|
|
+++ b/drivers/staging/rtl8192u/ieee80211.h
|
|
@@ -39,9 +39,9 @@
|
|
#include <linux/delay.h>
|
|
#include <linux/wireless.h>
|
|
|
|
-#include "../../ieee80211/rtl819x_HT.h"
|
|
-#include "../../ieee80211/rtl819x_BA.h"
|
|
-#include "../../ieee80211/rtl819x_TS.h"
|
|
+#include "ieee80211/rtl819x_HT.h"
|
|
+#include "ieee80211/rtl819x_BA.h"
|
|
+#include "ieee80211/rtl819x_TS.h"
|
|
|
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
|
|
#ifndef bool
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
|
|
index 199ee16..521e7b9 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
|
|
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
|
|
@@ -53,14 +53,8 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
|
|
|
|
list_del(ptr);
|
|
|
|
- if (entry->ops) {
|
|
+ if (entry->ops)
|
|
entry->ops->deinit(entry->priv);
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
|
|
- module_put(entry->ops->owner);
|
|
-#else
|
|
- __MOD_DEC_USE_COUNT(entry->ops->owner);
|
|
-#endif
|
|
- }
|
|
kfree(entry);
|
|
}
|
|
}
|
|
@@ -208,8 +202,7 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = {
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
-
|
|
-static int __init ieee80211_crypto_init(void)
|
|
+int __init ieee80211_crypto_init(void)
|
|
{
|
|
int ret = -ENOMEM;
|
|
|
|
@@ -230,8 +223,7 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-
|
|
-static void __exit ieee80211_crypto_deinit(void)
|
|
+void __exit ieee80211_crypto_deinit(void)
|
|
{
|
|
struct list_head *ptr, *n;
|
|
|
|
@@ -250,24 +242,3 @@ static void __exit ieee80211_crypto_deinit(void)
|
|
|
|
kfree(hcrypt);
|
|
}
|
|
-
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
-EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
|
|
-EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
|
|
-EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
|
|
-
|
|
-EXPORT_SYMBOL(ieee80211_register_crypto_ops);
|
|
-EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
|
|
-EXPORT_SYMBOL(ieee80211_get_crypto_ops);
|
|
-#else
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_entries);
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_handler);
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_crypt_delayed_deinit);
|
|
-
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_register_crypto_ops);
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_unregister_crypto_ops);
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_get_crypto_ops);
|
|
-#endif
|
|
-
|
|
-module_init(ieee80211_crypto_init);
|
|
-module_exit(ieee80211_crypto_deinit);
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
|
|
index a86c26e..181edc4 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
|
|
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
|
|
@@ -24,27 +24,13 @@
|
|
|
|
#include "ieee80211.h"
|
|
|
|
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
|
|
-#include "rtl_crypto.h"
|
|
-#else
|
|
#include <linux/crypto.h>
|
|
-#endif
|
|
-
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
|
|
- #include <asm/scatterlist.h>
|
|
-#else
|
|
#include <linux/scatterlist.h>
|
|
-#endif
|
|
-//#include <asm/scatterlist.h>
|
|
|
|
MODULE_AUTHOR("Jouni Malinen");
|
|
MODULE_DESCRIPTION("Host AP crypt: CCMP");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
-#ifndef OPENSUSE_SLED
|
|
-#define OPENSUSE_SLED 0
|
|
-#endif
|
|
-
|
|
#define AES_BLOCK_LEN 16
|
|
#define CCMP_HDR_LEN 8
|
|
#define CCMP_MIC_LEN 8
|
|
@@ -75,21 +61,7 @@ struct ieee80211_ccmp_data {
|
|
void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
|
|
const u8 pt[16], u8 ct[16])
|
|
{
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- struct scatterlist src, dst;
|
|
-
|
|
- src.page = virt_to_page(pt);
|
|
- src.offset = offset_in_page(pt);
|
|
- src.length = AES_BLOCK_LEN;
|
|
-
|
|
- dst.page = virt_to_page(ct);
|
|
- dst.offset = offset_in_page(ct);
|
|
- dst.length = AES_BLOCK_LEN;
|
|
-
|
|
- crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
|
|
-#else
|
|
crypto_cipher_encrypt_one((void*)tfm, ct, pt);
|
|
-#endif
|
|
}
|
|
|
|
static void * ieee80211_ccmp_init(int key_idx)
|
|
@@ -102,14 +74,6 @@ static void * ieee80211_ccmp_init(int key_idx)
|
|
memset(priv, 0, sizeof(*priv));
|
|
priv->key_idx = key_idx;
|
|
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- priv->tfm = crypto_alloc_tfm("aes", 0);
|
|
- if (priv->tfm == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
|
|
- "crypto API aes\n");
|
|
- goto fail;
|
|
- }
|
|
- #else
|
|
priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
|
|
if (IS_ERR(priv->tfm)) {
|
|
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
|
|
@@ -117,17 +81,13 @@ static void * ieee80211_ccmp_init(int key_idx)
|
|
priv->tfm = NULL;
|
|
goto fail;
|
|
}
|
|
- #endif
|
|
+
|
|
return priv;
|
|
|
|
fail:
|
|
if (priv) {
|
|
if (priv->tfm)
|
|
- #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
|
|
- crypto_free_tfm(priv->tfm);
|
|
- #else
|
|
crypto_free_cipher((void*)priv->tfm);
|
|
- #endif
|
|
kfree(priv);
|
|
}
|
|
|
|
@@ -138,12 +98,9 @@ fail:
|
|
static void ieee80211_ccmp_deinit(void *priv)
|
|
{
|
|
struct ieee80211_ccmp_data *_priv = priv;
|
|
+
|
|
if (_priv && _priv->tfm)
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
|
|
- crypto_free_tfm(_priv->tfm);
|
|
-#else
|
|
crypto_free_cipher((void*)_priv->tfm);
|
|
-#endif
|
|
kfree(priv);
|
|
}
|
|
|
|
@@ -512,23 +469,12 @@ static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
-
|
|
-static int __init ieee80211_crypto_ccmp_init(void)
|
|
+int __init ieee80211_crypto_ccmp_init(void)
|
|
{
|
|
return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
|
|
}
|
|
|
|
-
|
|
-static void __exit ieee80211_crypto_ccmp_exit(void)
|
|
+void __exit ieee80211_crypto_ccmp_exit(void)
|
|
{
|
|
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
|
|
}
|
|
-
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
-EXPORT_SYMBOL(ieee80211_ccmp_null);
|
|
-#else
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_ccmp_null);
|
|
-#endif
|
|
-
|
|
-module_init(ieee80211_crypto_ccmp_init);
|
|
-module_exit(ieee80211_crypto_ccmp_exit);
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
|
|
index b031b64..58af7c8 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
|
|
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
|
|
@@ -22,33 +22,15 @@
|
|
#include <asm/string.h>
|
|
|
|
#include "ieee80211.h"
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
|
|
-//#include "crypto_compat.h"
|
|
-#endif
|
|
-
|
|
|
|
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
|
|
-#include "rtl_crypto.h"
|
|
-#else
|
|
#include <linux/crypto.h>
|
|
-#endif
|
|
-//#include <asm/scatterlist.h>
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
|
|
- #include <asm/scatterlist.h>
|
|
-#else
|
|
#include <linux/scatterlist.h>
|
|
-#endif
|
|
-
|
|
#include <linux/crc32.h>
|
|
|
|
MODULE_AUTHOR("Jouni Malinen");
|
|
MODULE_DESCRIPTION("Host AP crypt: TKIP");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
-#ifndef OPENSUSE_SLED
|
|
-#define OPENSUSE_SLED 0
|
|
-#endif
|
|
-
|
|
struct ieee80211_tkip_data {
|
|
#define TKIP_KEY_LEN 32
|
|
u8 key[TKIP_KEY_LEN];
|
|
@@ -71,17 +53,12 @@ struct ieee80211_tkip_data {
|
|
u32 dot11RSNAStatsTKIPLocalMICFailures;
|
|
|
|
int key_idx;
|
|
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
|
|
+
|
|
struct crypto_blkcipher *rx_tfm_arc4;
|
|
struct crypto_hash *rx_tfm_michael;
|
|
struct crypto_blkcipher *tx_tfm_arc4;
|
|
struct crypto_hash *tx_tfm_michael;
|
|
-#else
|
|
- struct crypto_tfm *tx_tfm_arc4;
|
|
- struct crypto_tfm *tx_tfm_michael;
|
|
- struct crypto_tfm *rx_tfm_arc4;
|
|
- struct crypto_tfm *rx_tfm_michael;
|
|
-#endif
|
|
+
|
|
/* scratch buffers for virt_to_page() (crypto API) */
|
|
u8 rx_hdr[16], tx_hdr[16];
|
|
};
|
|
@@ -95,35 +72,7 @@ static void * ieee80211_tkip_init(int key_idx)
|
|
goto fail;
|
|
memset(priv, 0, sizeof(*priv));
|
|
priv->key_idx = key_idx;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
|
|
- if (priv->tx_tfm_arc4 == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
|
- "crypto API arc4\n");
|
|
- goto fail;
|
|
- }
|
|
-
|
|
- priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
|
|
- if (priv->tx_tfm_michael == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
|
- "crypto API michael_mic\n");
|
|
- goto fail;
|
|
- }
|
|
-
|
|
- priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
|
|
- if (priv->rx_tfm_arc4 == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
|
- "crypto API arc4\n");
|
|
- goto fail;
|
|
- }
|
|
|
|
- priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
|
|
- if (priv->rx_tfm_michael == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
|
- "crypto API michael_mic\n");
|
|
- goto fail;
|
|
- }
|
|
-#else
|
|
priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
|
|
CRYPTO_ALG_ASYNC);
|
|
if (IS_ERR(priv->tx_tfm_arc4)) {
|
|
@@ -159,22 +108,11 @@ static void * ieee80211_tkip_init(int key_idx)
|
|
priv->rx_tfm_michael = NULL;
|
|
goto fail;
|
|
}
|
|
-#endif
|
|
+
|
|
return priv;
|
|
|
|
fail:
|
|
if (priv) {
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (priv->tx_tfm_michael)
|
|
- crypto_free_tfm(priv->tx_tfm_michael);
|
|
- if (priv->tx_tfm_arc4)
|
|
- crypto_free_tfm(priv->tx_tfm_arc4);
|
|
- if (priv->rx_tfm_michael)
|
|
- crypto_free_tfm(priv->rx_tfm_michael);
|
|
- if (priv->rx_tfm_arc4)
|
|
- crypto_free_tfm(priv->rx_tfm_arc4);
|
|
-
|
|
-#else
|
|
if (priv->tx_tfm_michael)
|
|
crypto_free_hash(priv->tx_tfm_michael);
|
|
if (priv->tx_tfm_arc4)
|
|
@@ -183,7 +121,6 @@ fail:
|
|
crypto_free_hash(priv->rx_tfm_michael);
|
|
if (priv->rx_tfm_arc4)
|
|
crypto_free_blkcipher(priv->rx_tfm_arc4);
|
|
-#endif
|
|
kfree(priv);
|
|
}
|
|
|
|
@@ -194,16 +131,7 @@ fail:
|
|
static void ieee80211_tkip_deinit(void *priv)
|
|
{
|
|
struct ieee80211_tkip_data *_priv = priv;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (_priv->tx_tfm_michael)
|
|
- crypto_free_tfm(_priv->tx_tfm_michael);
|
|
- if (_priv->tx_tfm_arc4)
|
|
- crypto_free_tfm(_priv->tx_tfm_arc4);
|
|
- if (_priv->rx_tfm_michael)
|
|
- crypto_free_tfm(_priv->rx_tfm_michael);
|
|
- if (_priv->rx_tfm_arc4)
|
|
- crypto_free_tfm(_priv->rx_tfm_arc4);
|
|
-#else
|
|
+
|
|
if (_priv) {
|
|
if (_priv->tx_tfm_michael)
|
|
crypto_free_hash(_priv->tx_tfm_michael);
|
|
@@ -214,7 +142,6 @@ static void ieee80211_tkip_deinit(void *priv)
|
|
if (_priv->rx_tfm_arc4)
|
|
crypto_free_blkcipher(_priv->rx_tfm_arc4);
|
|
}
|
|
-#endif
|
|
kfree(priv);
|
|
}
|
|
|
|
@@ -384,11 +311,8 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
u8 *pos;
|
|
struct ieee80211_hdr_4addr *hdr;
|
|
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
|
|
-
|
|
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
|
|
struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4};
|
|
int ret = 0;
|
|
- #endif
|
|
u8 rc4key[16], *icv;
|
|
u32 crc;
|
|
struct scatterlist sg;
|
|
@@ -399,18 +323,6 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
|
|
hdr = (struct ieee80211_hdr_4addr *) skb->data;
|
|
|
|
-#if 0
|
|
-printk("@@ tkey\n");
|
|
-printk("%x|", ((u32*)tkey->key)[0]);
|
|
-printk("%x|", ((u32*)tkey->key)[1]);
|
|
-printk("%x|", ((u32*)tkey->key)[2]);
|
|
-printk("%x|", ((u32*)tkey->key)[3]);
|
|
-printk("%x|", ((u32*)tkey->key)[4]);
|
|
-printk("%x|", ((u32*)tkey->key)[5]);
|
|
-printk("%x|", ((u32*)tkey->key)[6]);
|
|
-printk("%x\n", ((u32*)tkey->key)[7]);
|
|
-#endif
|
|
-
|
|
if (!tcb_desc->bHwSec)
|
|
{
|
|
if (!tkey->tx_phase1_done) {
|
|
@@ -451,33 +363,14 @@ printk("%x\n", ((u32*)tkey->key)[7]);
|
|
if (!tcb_desc->bHwSec)
|
|
{
|
|
icv = skb_put(skb, 4);
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
crc = ~crc32_le(~0, pos, len);
|
|
-#else
|
|
- crc = ~ether_crc_le(len, pos);
|
|
-#endif
|
|
icv[0] = crc;
|
|
icv[1] = crc >> 8;
|
|
icv[2] = crc >> 16;
|
|
icv[3] = crc >> 24;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = len + 4;
|
|
- crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4);
|
|
-#else
|
|
crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = len + 4;
|
|
-#else
|
|
sg_init_one(&sg, pos, len+4);
|
|
-#endif
|
|
ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
|
|
-#endif
|
|
-
|
|
}
|
|
|
|
tkey->tx_iv16++;
|
|
@@ -487,11 +380,7 @@ printk("%x\n", ((u32*)tkey->key)[7]);
|
|
}
|
|
|
|
if (!tcb_desc->bHwSec)
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- return 0;
|
|
- #else
|
|
return ret;
|
|
- #endif
|
|
else
|
|
return 0;
|
|
|
|
@@ -506,9 +395,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
u16 iv16;
|
|
struct ieee80211_hdr_4addr *hdr;
|
|
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
|
|
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
|
|
struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4};
|
|
- #endif
|
|
u8 rc4key[16];
|
|
u8 icv[4];
|
|
u32 crc;
|
|
@@ -567,21 +454,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
|
|
plen = skb->len - hdr_len - 12;
|
|
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = plen + 4;
|
|
- crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4);
|
|
-#else
|
|
crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = plen + 4;
|
|
-#else
|
|
sg_init_one(&sg, pos, plen+4);
|
|
-#endif
|
|
+
|
|
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
|
|
if (net_ratelimit()) {
|
|
printk(KERN_DEBUG ": TKIP: failed to decrypt "
|
|
@@ -590,13 +465,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
}
|
|
return -7;
|
|
}
|
|
-#endif
|
|
|
|
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
crc = ~crc32_le(~0, pos, plen);
|
|
- #else
|
|
- crc = ~ether_crc_le(plen, pos);
|
|
- #endif
|
|
icv[0] = crc;
|
|
icv[1] = crc >> 8;
|
|
icv[2] = crc >> 16;
|
|
@@ -628,63 +498,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
skb_pull(skb, 8);
|
|
skb_trim(skb, skb->len - 4);
|
|
|
|
-//john's test
|
|
-#ifdef JOHN_DUMP
|
|
-if( ((u16*)skb->data)[0] & 0x4000){
|
|
- printk("@@ rx decrypted skb->data");
|
|
- int i;
|
|
- for(i=0;i<skb->len;i++){
|
|
- if( (i%24)==0 ) printk("\n");
|
|
- printk("%2x ", ((u8*)skb->data)[i]);
|
|
- }
|
|
- printk("\n");
|
|
-}
|
|
-#endif /*JOHN_DUMP*/
|
|
return keyidx;
|
|
}
|
|
|
|
-
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
-static int michael_mic(struct crypto_tfm * tfm_michael, u8 *key, u8 *hdr,
|
|
- u8 *data, size_t data_len, u8 *mic)
|
|
-{
|
|
- struct scatterlist sg[2];
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
|
|
- struct hash_desc desc;
|
|
- int ret = 0;
|
|
-#endif
|
|
-
|
|
- if (tfm_michael == NULL){
|
|
- printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
|
|
- return -1;
|
|
- }
|
|
- sg[0].page = virt_to_page(hdr);
|
|
- sg[0].offset = offset_in_page(hdr);
|
|
- sg[0].length = 16;
|
|
-
|
|
- sg[1].page = virt_to_page(data);
|
|
- sg[1].offset = offset_in_page(data);
|
|
- sg[1].length = data_len;
|
|
-
|
|
-
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
|
|
- crypto_digest_init(tfm_michael);
|
|
- crypto_digest_setkey(tfm_michael, key, 8);
|
|
- crypto_digest_update(tfm_michael, sg, 2);
|
|
- crypto_digest_final(tfm_michael, mic);
|
|
- return 0;
|
|
-#else
|
|
-if (crypto_hash_setkey(tkey->tfm_michael, key, 8))
|
|
- return -1;
|
|
-
|
|
-// return 0;
|
|
- desc.tfm = tkey->tfm_michael;
|
|
- desc.flags = 0;
|
|
- ret = crypto_hash_digest(&desc, sg, data_len + 16, mic);
|
|
- return ret;
|
|
-#endif
|
|
-}
|
|
-#else
|
|
static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
|
|
u8 * data, size_t data_len, u8 * mic)
|
|
{
|
|
@@ -695,19 +511,10 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
|
|
printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
|
|
return -1;
|
|
}
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
|
|
- sg[0].page = virt_to_page(hdr);
|
|
- sg[0].offset = offset_in_page(hdr);
|
|
- sg[0].length = 16;
|
|
-
|
|
- sg[1].page = virt_to_page(data);
|
|
- sg[1].offset = offset_in_page(data);
|
|
- sg[1].length = data_len;
|
|
-#else
|
|
+
|
|
sg_init_table(sg, 2);
|
|
sg_set_buf(&sg[0], hdr, 16);
|
|
sg_set_buf(&sg[1], data, data_len);
|
|
-#endif
|
|
|
|
if (crypto_hash_setkey(tfm_michael, key, 8))
|
|
return -1;
|
|
@@ -716,9 +523,6 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
|
|
desc.flags = 0;
|
|
return crypto_hash_digest(&desc, sg, data_len + 16, mic);
|
|
}
|
|
-#endif
|
|
-
|
|
-
|
|
|
|
static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
|
|
{
|
|
@@ -775,20 +579,14 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri
|
|
}
|
|
// }
|
|
pos = skb_put(skb, 8);
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
|
|
- skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
|
|
-#else
|
|
+
|
|
if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
|
|
skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
|
|
-#endif
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
-
|
|
-#if WIRELESS_EXT >= 18
|
|
static void ieee80211_michael_mic_failure(struct net_device *dev,
|
|
struct ieee80211_hdr_4addr *hdr,
|
|
int keyidx)
|
|
@@ -809,29 +607,6 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
|
|
wrqu.data.length = sizeof(ev);
|
|
wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
|
|
}
|
|
-#elif WIRELESS_EXT >= 15
|
|
-static void ieee80211_michael_mic_failure(struct net_device *dev,
|
|
- struct ieee80211_hdr_4addr *hdr,
|
|
- int keyidx)
|
|
-{
|
|
- union iwreq_data wrqu;
|
|
- char buf[128];
|
|
-
|
|
- /* TODO: needed parameters: count, keyid, key type, TSC */
|
|
- sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
|
|
- MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
|
|
- MAC_ARG(hdr->addr2));
|
|
- memset(&wrqu, 0, sizeof(wrqu));
|
|
- wrqu.data.length = strlen(buf);
|
|
- wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
|
|
-}
|
|
-#else /* WIRELESS_EXT >= 15 */
|
|
-static inline void ieee80211_michael_mic_failure(struct net_device *dev,
|
|
- struct ieee80211_hdr_4addr *hdr,
|
|
- int keyidx)
|
|
-{
|
|
-}
|
|
-#endif /* WIRELESS_EXT >= 15 */
|
|
|
|
static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
|
|
int hdr_len, void *priv)
|
|
@@ -853,13 +628,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
|
|
}
|
|
// }
|
|
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
|
|
- skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
|
|
-#else
|
|
if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
|
|
skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
|
|
-#endif
|
|
return -1;
|
|
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
|
|
struct ieee80211_hdr_4addr *hdr;
|
|
@@ -889,32 +659,18 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
|
|
{
|
|
struct ieee80211_tkip_data *tkey = priv;
|
|
int keyidx;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- struct crypto_tfm *tfm = tkey->tx_tfm_michael;
|
|
- struct crypto_tfm *tfm2 = tkey->tx_tfm_arc4;
|
|
- struct crypto_tfm *tfm3 = tkey->rx_tfm_michael;
|
|
- struct crypto_tfm *tfm4 = tkey->rx_tfm_arc4;
|
|
-#else
|
|
struct crypto_hash *tfm = tkey->tx_tfm_michael;
|
|
struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
|
|
struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
|
|
struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
|
|
-#endif
|
|
|
|
keyidx = tkey->key_idx;
|
|
memset(tkey, 0, sizeof(*tkey));
|
|
tkey->key_idx = keyidx;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- tkey->tx_tfm_michael = tfm;
|
|
- tkey->tx_tfm_arc4 = tfm2;
|
|
- tkey->rx_tfm_michael = tfm3;
|
|
- tkey->rx_tfm_arc4 = tfm4;
|
|
-#else
|
|
tkey->tx_tfm_michael = tfm;
|
|
tkey->tx_tfm_arc4 = tfm2;
|
|
tkey->rx_tfm_michael = tfm3;
|
|
tkey->rx_tfm_arc4 = tfm4;
|
|
-#endif
|
|
|
|
if (len == TKIP_KEY_LEN) {
|
|
memcpy(tkey->key, key, TKIP_KEY_LEN);
|
|
@@ -1007,14 +763,12 @@ static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
-
|
|
-static int __init ieee80211_crypto_tkip_init(void)
|
|
+int __init ieee80211_crypto_tkip_init(void)
|
|
{
|
|
return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
|
|
}
|
|
|
|
-
|
|
-static void __exit ieee80211_crypto_tkip_exit(void)
|
|
+void __exit ieee80211_crypto_tkip_exit(void)
|
|
{
|
|
ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
|
|
}
|
|
@@ -1024,11 +778,3 @@ void ieee80211_tkip_null(void)
|
|
// printk("============>%s()\n", __FUNCTION__);
|
|
return;
|
|
}
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
-EXPORT_SYMBOL(ieee80211_tkip_null);
|
|
-#else
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_tkip_null);
|
|
-#endif
|
|
-
|
|
-module_init(ieee80211_crypto_tkip_init);
|
|
-module_exit(ieee80211_crypto_tkip_exit);
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
|
|
index 7e39432..39c74d1 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
|
|
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
|
|
@@ -20,41 +20,13 @@
|
|
|
|
#include "ieee80211.h"
|
|
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
|
|
-//#include "crypto_compat.h"
|
|
-#endif
|
|
-
|
|
-
|
|
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
|
|
-#include "rtl_crypto.h"
|
|
-#else
|
|
#include <linux/crypto.h>
|
|
-#endif
|
|
-
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
|
|
- #include <asm/scatterlist.h>
|
|
-#else
|
|
#include <linux/scatterlist.h>
|
|
-#endif
|
|
-//#include <asm/scatterlist.h>
|
|
#include <linux/crc32.h>
|
|
-//
|
|
-/*
|
|
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
|
|
-#include "rtl_crypto.h"
|
|
-#else
|
|
-#include <linux/crypto.h>
|
|
-#endif
|
|
|
|
-#include <asm/scatterlist.h>
|
|
-#include <linux/crc32.h>
|
|
-*/
|
|
MODULE_AUTHOR("Jouni Malinen");
|
|
MODULE_DESCRIPTION("Host AP crypt: WEP");
|
|
MODULE_LICENSE("GPL");
|
|
-#ifndef OPENSUSE_SLED
|
|
-#define OPENSUSE_SLED 0
|
|
-#endif
|
|
|
|
struct prism2_wep_data {
|
|
u32 iv;
|
|
@@ -62,12 +34,8 @@ struct prism2_wep_data {
|
|
u8 key[WEP_KEY_LEN + 1];
|
|
u8 key_len;
|
|
u8 key_idx;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- struct crypto_tfm *tfm;
|
|
- #else
|
|
struct crypto_blkcipher *tx_tfm;
|
|
struct crypto_blkcipher *rx_tfm;
|
|
- #endif
|
|
};
|
|
|
|
|
|
@@ -81,14 +49,6 @@ static void * prism2_wep_init(int keyidx)
|
|
memset(priv, 0, sizeof(*priv));
|
|
priv->key_idx = keyidx;
|
|
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- priv->tfm = crypto_alloc_tfm("arc4", 0);
|
|
- if (priv->tfm == NULL) {
|
|
- printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
|
|
- "crypto API arc4\n");
|
|
- goto fail;
|
|
- }
|
|
- #else
|
|
priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
|
|
if (IS_ERR(priv->tx_tfm)) {
|
|
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
|
|
@@ -103,7 +63,6 @@ static void * prism2_wep_init(int keyidx)
|
|
priv->rx_tfm = NULL;
|
|
goto fail;
|
|
}
|
|
- #endif
|
|
|
|
/* start WEP IV from a random value */
|
|
get_random_bytes(&priv->iv, 4);
|
|
@@ -111,13 +70,6 @@ static void * prism2_wep_init(int keyidx)
|
|
return priv;
|
|
|
|
fail:
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (priv) {
|
|
- if (priv->tfm)
|
|
- crypto_free_tfm(priv->tfm);
|
|
- kfree(priv);
|
|
- }
|
|
- #else
|
|
if (priv) {
|
|
if (priv->tx_tfm)
|
|
crypto_free_blkcipher(priv->tx_tfm);
|
|
@@ -125,7 +77,7 @@ fail:
|
|
crypto_free_blkcipher(priv->rx_tfm);
|
|
kfree(priv);
|
|
}
|
|
- #endif
|
|
+
|
|
return NULL;
|
|
}
|
|
|
|
@@ -133,17 +85,13 @@ fail:
|
|
static void prism2_wep_deinit(void *priv)
|
|
{
|
|
struct prism2_wep_data *_priv = priv;
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- if (_priv && _priv->tfm)
|
|
- crypto_free_tfm(_priv->tfm);
|
|
- #else
|
|
+
|
|
if (_priv) {
|
|
if (_priv->tx_tfm)
|
|
crypto_free_blkcipher(_priv->tx_tfm);
|
|
if (_priv->rx_tfm)
|
|
crypto_free_blkcipher(_priv->rx_tfm);
|
|
}
|
|
- #endif
|
|
kfree(priv);
|
|
}
|
|
|
|
@@ -160,9 +108,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
u8 key[WEP_KEY_LEN + 3];
|
|
u8 *pos;
|
|
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
|
|
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
|
|
struct blkcipher_desc desc = {.tfm = wep->tx_tfm};
|
|
- #endif
|
|
u32 crc;
|
|
u8 *icv;
|
|
struct scatterlist sg;
|
|
@@ -201,35 +147,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
{
|
|
|
|
/* Append little-endian CRC32 and encrypt it to produce ICV */
|
|
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
crc = ~crc32_le(~0, pos, len);
|
|
- #else
|
|
- crc = ~ether_crc_le(len, pos);
|
|
- #endif
|
|
icv = skb_put(skb, 4);
|
|
icv[0] = crc;
|
|
icv[1] = crc >> 8;
|
|
icv[2] = crc >> 16;
|
|
icv[3] = crc >> 24;
|
|
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- crypto_cipher_setkey(wep->tfm, key, klen);
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = len + 4;
|
|
- crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
|
|
- return 0;
|
|
- #else
|
|
crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
|
|
- #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = len + 4;
|
|
- #else
|
|
sg_init_one(&sg, pos, len+4);
|
|
- #endif
|
|
+
|
|
return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
|
|
- #endif
|
|
}
|
|
|
|
return 0;
|
|
@@ -250,9 +178,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
u8 key[WEP_KEY_LEN + 3];
|
|
u8 keyidx, *pos;
|
|
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
|
|
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
|
|
struct blkcipher_desc desc = {.tfm = wep->rx_tfm};
|
|
- #endif
|
|
u32 crc;
|
|
u8 icv[4];
|
|
struct scatterlist sg;
|
|
@@ -277,29 +203,13 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
|
|
|
if (!tcb_desc->bHwSec)
|
|
{
|
|
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
|
|
- crypto_cipher_setkey(wep->tfm, key, klen);
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = plen + 4;
|
|
- crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
|
|
- #else
|
|
crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
|
|
- #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- sg.page = virt_to_page(pos);
|
|
- sg.offset = offset_in_page(pos);
|
|
- sg.length = plen + 4;
|
|
- #else
|
|
sg_init_one(&sg, pos, plen+4);
|
|
- #endif
|
|
+
|
|
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
|
|
return -7;
|
|
- #endif
|
|
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
+
|
|
crc = ~crc32_le(~0, pos, plen);
|
|
- #else
|
|
- crc = ~ether_crc_le(plen, pos);
|
|
- #endif
|
|
icv[0] = crc;
|
|
icv[1] = crc >> 8;
|
|
icv[2] = crc >> 16;
|
|
@@ -370,14 +280,12 @@ static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
-
|
|
-static int __init ieee80211_crypto_wep_init(void)
|
|
+int __init ieee80211_crypto_wep_init(void)
|
|
{
|
|
return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
|
|
}
|
|
|
|
-
|
|
-static void __exit ieee80211_crypto_wep_exit(void)
|
|
+void __exit ieee80211_crypto_wep_exit(void)
|
|
{
|
|
ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
|
|
}
|
|
@@ -387,11 +295,3 @@ void ieee80211_wep_null(void)
|
|
// printk("============>%s()\n", __FUNCTION__);
|
|
return;
|
|
}
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
-EXPORT_SYMBOL(ieee80211_wep_null);
|
|
-#else
|
|
-EXPORT_SYMBOL_NOVERS(ieee80211_wep_null);
|
|
-#endif
|
|
-
|
|
-module_init(ieee80211_crypto_wep_init);
|
|
-module_exit(ieee80211_crypto_wep_exit);
|
|
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
|
|
index f408b45..c3383bb 100644
|
|
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
|
|
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
|
|
@@ -113,13 +113,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
|
|
goto failed;
|
|
}
|
|
|
|
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
|
|
ieee = netdev_priv(dev);
|
|
-#else
|
|
- ieee = (struct ieee80211_device *)dev->priv;
|
|
-#endif
|
|
- dev->hard_start_xmit = ieee80211_xmit;
|
|
-
|
|
memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
|
|
ieee->dev = dev;
|
|
|
|
@@ -167,12 +161,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
|
|
|
|
ieee80211_softmac_init(ieee);
|
|
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
|
|
ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
|
|
-#else
|
|
- ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kmalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
|
|
- memset(ieee->pHTInfo,0,sizeof(RT_HIGH_THROUGHPUT));
|
|
-#endif
|
|
if (ieee->pHTInfo == NULL)
|
|
{
|
|
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n");
|
|
@@ -181,13 +170,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
|
|
HTUpdateDefaultSetting(ieee);
|
|
HTInitializeHTInfo(ieee); //may move to other place.
|
|
TSInitialize(ieee);
|
|
-#if 0
|
|
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
|
|
- INIT_WORK(&ieee->ht_onAssRsp, (void(*)(void*)) HTOnAssocRsp_wq);
|
|
-#else
|
|
- INIT_WORK(&ieee->ht_onAssRsp, (void(*)(void*)) HTOnAssocRsp_wq, ieee);
|
|
-#endif
|
|
-#endif
|
|
+
|
|
for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
|
|
INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
|
|
|
|
@@ -206,22 +189,15 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
|
|
|
|
failed:
|
|
if (dev)
|
|
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
|
|
free_netdev(dev);
|
|
-#else
|
|
- kfree(dev);
|
|
-#endif
|
|
+
|
|
return NULL;
|
|
}
|
|
|
|
|
|
void free_ieee80211(struct net_device *dev)
|
|
{
|
|
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
|
|
struct ieee80211_device *ieee = netdev_priv(dev);
|
|
-#else
|
|
- struct ieee80211_device *ieee = (struct ieee80211_device *)dev->priv;
|
|
-#endif
|
|
int i;
|
|
//struct list_head *p, *q;
|
|
// del_timer_sync(&ieee->SwBwTimer);
|
|
@@ -240,34 +216,15 @@ void free_ieee80211(struct net_device *dev)
|
|
for (i = 0; i < WEP_KEYS; i++) {
|
|
struct ieee80211_crypt_data *crypt = ieee->crypt[i];
|
|
if (crypt) {
|
|
- if (crypt->ops) {
|
|
+ if (crypt->ops)
|
|
crypt->ops->deinit(crypt->priv);
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
|
|
- module_put(crypt->ops->owner);
|
|
-#else
|
|
- __MOD_DEC_USE_COUNT(crypt->ops->owner);
|
|
-#endif
|
|
- }
|
|
kfree(crypt);
|
|
ieee->crypt[i] = NULL;
|
|
}
|
|
}
|
|
|
|
ieee80211_networks_free(ieee);
|
|
-#if 0
|
|
- for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
|
|
- list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
|
|
- kfree(list_entry(p, struct ieee_ibss_seq, list));
|
|
- list_del(p);
|
|
- }
|
|
- }
|
|
-
|
|
-#endif
|
|
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
|
|
free_netdev(dev);
|
|
-#else
|
|
- kfree(dev);
|
|
-#endif
|
|
}
|
|
|
|
#ifdef CONFIG_IEEE80211_DEBUG
|
|
@@ -305,7 +262,7 @@ static int store_debug_level(struct file *file, const char *buffer,
|
|
unsigned long count, void *data)
|
|
{
|
|
char buf[] = "0x00000000";
|
|
- unsigned long len = min(sizeof(buf) - 1, (u32)count);
|
|
+ unsigned long len = min(sizeof(buf) - 1, count);
|
|
char *p = (char *)buf;
|
|
unsigned long val;
|
|
|
|
@@ -328,16 +285,13 @@ static int store_debug_level(struct file *file, const char *buffer,
|
|
return strnlen(buf, count);
|
|
}
|
|
|
|
-static int __init ieee80211_init(void)
|
|
+int __init ieee80211_debug_init(void)
|
|
{
|
|
struct proc_dir_entry *e;
|
|
|
|
ieee80211_debug_level = debug;
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
|
|
-#else
|
|
+
|
|
ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
|
|
-#endif
|
|
if (ieee80211_proc == NULL) {
|
|
IEEE80211_ERROR("Unable to create " DRV_NAME
|
|
" proc directory\n");
|
|
@@ -346,11 +300,7 @@ static int __init ieee80211_init(void)
|
|
e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
|
|
ieee80211_proc);
|
|
if (!e) {
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- remove_proc_entry(DRV_NAME, proc_net);
|
|
-#else
|
|
remove_proc_entry(DRV_NAME, init_net.proc_net);
|
|
-#endif
|
|
ieee80211_proc = NULL;
|
|
return -EIO;
|
|
}
|
|
@@ -361,34 +311,16 @@ static int __init ieee80211_init(void)
|
|
return 0;
|
|
}
|
|
|
|
-static void __exit ieee80211_exit(void)
|
|
+void __exit ieee80211_debug_exit(void)
|
|
{
|
|
if (ieee80211_proc) {
|
|
remove_proc_entry("debug_level", ieee80211_proc);
|
|
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
|
- remove_proc_entry(DRV_NAME, proc_net);
|
|
-#else
|
|
remove_proc_entry(DRV_NAME, init_net.proc_net);
|
|
-#endif
|
|
ieee80211_proc = NULL;
|
|
}
|
|
}
|
|
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
#include <linux/moduleparam.h>
|
|
module_param(debug, int, 0444);
|
|
MODULE_PARM_DESC(debug, "debug output mask");
|
|
-
|
|
-
|
|
-module_exit(ieee80211_exit);
|
|
-module_init(ieee80211_init);
|
|
-#endif
|
|
-#endif
|
|
-
|
|
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
|
-EXPORT_SYMBOL(alloc_ieee80211);
|
|
-EXPORT_SYMBOL(free_ieee80211);
|
|
-#else
|
|
-EXPORT_SYMBOL_NOVERS(alloc_ieee80211);
|
|
-EXPORT_SYMBOL_NOVERS(free_ieee80211);
|
|
#endif
|
|
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
|
|
index 6997e97..15999e8 100644
|
|
--- a/drivers/staging/rtl8192u/r8192U_core.c
|
|
+++ b/drivers/staging/rtl8192u/r8192U_core.c
|
|
@@ -1175,18 +1175,14 @@ static int rtl8192_rx_initiate(struct net_device*dev)
|
|
}
|
|
// printk("nomal packet IN request!\n");
|
|
usb_fill_bulk_urb(entry, priv->udev,
|
|
- usb_rcvbulkpipe(priv->udev, 3), skb->tail,
|
|
+ usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb),
|
|
RX_URB_SIZE, rtl8192_rx_isr, skb);
|
|
info = (struct rtl8192_rx_info *) skb->cb;
|
|
info->urb = entry;
|
|
info->dev = dev;
|
|
info->out_pipe = 3; //denote rx normal packet queue
|
|
skb_queue_tail(&priv->rx_queue, skb);
|
|
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
|
|
usb_submit_urb(entry, GFP_KERNEL);
|
|
-#else
|
|
- usb_submit_urb(entry);
|
|
-#endif
|
|
}
|
|
|
|
/* command packet rx procedure */
|
|
@@ -1205,18 +1201,14 @@ static int rtl8192_rx_initiate(struct net_device*dev)
|
|
break;
|
|
}
|
|
usb_fill_bulk_urb(entry, priv->udev,
|
|
- usb_rcvbulkpipe(priv->udev, 9), skb->tail,
|
|
+ usb_rcvbulkpipe(priv->udev, 9), skb_tail_pointer(skb),
|
|
RX_URB_SIZE, rtl8192_rx_isr, skb);
|
|
info = (struct rtl8192_rx_info *) skb->cb;
|
|
info->urb = entry;
|
|
info->dev = dev;
|
|
info->out_pipe = 9; //denote rx cmd packet queue
|
|
skb_queue_tail(&priv->rx_queue, skb);
|
|
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
|
|
usb_submit_urb(entry, GFP_KERNEL);
|
|
-#else
|
|
- usb_submit_urb(entry);
|
|
-#endif
|
|
}
|
|
|
|
return 0;
|
|
@@ -1586,7 +1578,7 @@ static void rtl8192_rx_isr(struct urb *urb)
|
|
}
|
|
|
|
usb_fill_bulk_urb(urb, priv->udev,
|
|
- usb_rcvbulkpipe(priv->udev, out_pipe), skb->tail,
|
|
+ usb_rcvbulkpipe(priv->udev, out_pipe), skb_tail_pointer(skb),
|
|
RX_URB_SIZE, rtl8192_rx_isr, skb);
|
|
|
|
info = (struct rtl8192_rx_info *) skb->cb;
|
|
@@ -1594,14 +1586,10 @@ static void rtl8192_rx_isr(struct urb *urb)
|
|
info->dev = dev;
|
|
info->out_pipe = out_pipe;
|
|
|
|
- urb->transfer_buffer = skb->tail;
|
|
+ urb->transfer_buffer = skb_tail_pointer(skb);
|
|
urb->context = skb;
|
|
skb_queue_tail(&priv->rx_queue, skb);
|
|
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
-#else
|
|
- err = usb_submit_urb(urb);
|
|
-#endif
|
|
if(err && err != EPERM)
|
|
printk("can not submit rxurb, err is %x,URB status is %x\n",err,urb->status);
|
|
}
|
|
@@ -2953,25 +2941,21 @@ short rtl8192_usb_initendpoints(struct net_device *dev)
|
|
|
|
#ifdef THOMAS_BEACON
|
|
{
|
|
- int align = 0;
|
|
- u32 oldaddr,newaddr;
|
|
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
|
|
+ long align = 0;
|
|
+ void *oldaddr, *newaddr;
|
|
+
|
|
priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
|
|
-#else
|
|
- priv->rx_urb[16] = usb_alloc_urb(0);
|
|
-#endif
|
|
priv->oldaddr = kmalloc(16, GFP_KERNEL);
|
|
- oldaddr = (u32)priv->oldaddr;
|
|
- align = oldaddr&3;
|
|
- if(align != 0 ){
|
|
+ oldaddr = priv->oldaddr;
|
|
+ align = ((long)oldaddr) & 3;
|
|
+ if (align) {
|
|
newaddr = oldaddr + 4 - align;
|
|
- priv->rx_urb[16]->transfer_buffer_length = 16-4+align;
|
|
- }
|
|
- else{
|
|
+ priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
|
|
+ } else {
|
|
newaddr = oldaddr;
|
|
priv->rx_urb[16]->transfer_buffer_length = 16;
|
|
}
|
|
- priv->rx_urb[16]->transfer_buffer = (u32*)newaddr;
|
|
+ priv->rx_urb[16]->transfer_buffer = newaddr;
|
|
}
|
|
#endif
|
|
|
|
@@ -6831,6 +6815,18 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
|
|
}
|
|
}
|
|
|
|
+static const struct net_device_ops rtl8192_netdev_ops = {
|
|
+ .ndo_open = rtl8192_open,
|
|
+ .ndo_stop = rtl8192_close,
|
|
+ .ndo_get_stats = rtl8192_stats,
|
|
+ .ndo_tx_timeout = tx_timeout,
|
|
+ .ndo_do_ioctl = rtl8192_ioctl,
|
|
+ .ndo_set_multicast_list = r8192_set_multicast,
|
|
+ .ndo_set_mac_address = r8192_set_mac_adr,
|
|
+ .ndo_validate_addr = eth_validate_addr,
|
|
+ .ndo_change_mtu = eth_change_mtu,
|
|
+ .ndo_start_xmit = ieee80211_xmit,
|
|
+};
|
|
|
|
|
|
/****************************************************************************
|
|
@@ -6872,15 +6868,7 @@ static void * __devinit rtl8192_usb_probe(struct usb_device *udev,
|
|
#endif
|
|
priv->udev=udev;
|
|
|
|
- dev->open = rtl8192_open;
|
|
- dev->stop = rtl8192_close;
|
|
- //dev->hard_start_xmit = rtl8192_8023_hard_start_xmit;
|
|
- dev->tx_timeout = tx_timeout;
|
|
- //dev->wireless_handlers = &r8192_wx_handlers_def;
|
|
- dev->do_ioctl = rtl8192_ioctl;
|
|
- dev->set_multicast_list = r8192_set_multicast;
|
|
- dev->set_mac_address = r8192_set_mac_adr;
|
|
- dev->get_stats = rtl8192_stats;
|
|
+ dev->netdev_ops = &rtl8192_netdev_ops;
|
|
|
|
//DMESG("Oops: i'm coming\n");
|
|
#if WIRELESS_EXT >= 12
|
|
@@ -7000,9 +6988,55 @@ static void __devexit rtl8192_usb_disconnect(struct usb_device *udev, void *ptr)
|
|
RT_TRACE(COMP_DOWN, "wlan driver removed\n");
|
|
}
|
|
|
|
+/* fun with the built-in ieee80211 stack... */
|
|
+extern int ieee80211_debug_init(void);
|
|
+extern void ieee80211_debug_exit(void);
|
|
+extern int ieee80211_crypto_init(void);
|
|
+extern void ieee80211_crypto_deinit(void);
|
|
+extern int ieee80211_crypto_tkip_init(void);
|
|
+extern void ieee80211_crypto_tkip_exit(void);
|
|
+extern int ieee80211_crypto_ccmp_init(void);
|
|
+extern void ieee80211_crypto_ccmp_exit(void);
|
|
+extern int ieee80211_crypto_wep_init(void);
|
|
+extern void ieee80211_crypto_wep_exit(void);
|
|
|
|
static int __init rtl8192_usb_module_init(void)
|
|
{
|
|
+ int ret;
|
|
+
|
|
+#ifdef CONFIG_IEEE80211_DEBUG
|
|
+ ret = ieee80211_debug_init();
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "ieee80211_debug_init() failed %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+#endif
|
|
+ ret = ieee80211_crypto_init();
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "ieee80211_crypto_init() failed %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ret = ieee80211_crypto_tkip_init();
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "ieee80211_crypto_tkip_init() failed %d\n",
|
|
+ ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ret = ieee80211_crypto_ccmp_init();
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "ieee80211_crypto_ccmp_init() failed %d\n",
|
|
+ ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ret = ieee80211_crypto_wep_init();
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "ieee80211_crypto_wep_init() failed %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n");
|
|
printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n");
|
|
RT_TRACE(COMP_INIT, "Initializing module");
|
|
--
|
|
1.7.1
|
|
|