1
0
Fork 0

staging/rtl8192e: Convert to lib80211_crypt_data and lib80211_crypt_ops

Convert rtllib_crypt_data to lib80211_crypt_data and
rtllib_crypt_ops to lib80211_crypt_ops.

This is almost a 1:1 replacement, only extra_prefix_len and
extra_postfix_len changed.

Signed-off-by: Sean MacLennan <seanm@seanm.ca>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
wifi-calibration
Sean MacLennan 2011-12-19 23:20:41 -05:00 committed by Greg Kroah-Hartman
parent 184f1938b2
commit 32c44cb5b9
10 changed files with 65 additions and 112 deletions

View File

@ -21,7 +21,7 @@
struct rtllib_crypto_alg {
struct list_head list;
struct rtllib_crypto_ops *ops;
struct lib80211_crypto_ops *ops;
};
@ -36,11 +36,11 @@ void rtllib_crypt_deinit_entries(struct rtllib_device *ieee,
int force)
{
struct list_head *ptr, *n;
struct rtllib_crypt_data *entry;
struct lib80211_crypt_data *entry;
for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
entry = list_entry(ptr, struct rtllib_crypt_data, list);
entry = list_entry(ptr, struct lib80211_crypt_data, list);
if (atomic_read(&entry->refcnt) != 0 && !force)
continue;
@ -73,9 +73,9 @@ void rtllib_crypt_deinit_handler(unsigned long data)
EXPORT_SYMBOL(rtllib_crypt_deinit_handler);
void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
struct rtllib_crypt_data **crypt)
struct lib80211_crypt_data **crypt)
{
struct rtllib_crypt_data *tmp;
struct lib80211_crypt_data *tmp;
unsigned long flags;
if (*crypt == NULL)
@ -98,7 +98,7 @@ void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
}
EXPORT_SYMBOL(rtllib_crypt_delayed_deinit);
int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops)
int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops)
{
unsigned long flags;
struct rtllib_crypto_alg *alg;
@ -123,7 +123,7 @@ int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops)
}
EXPORT_SYMBOL(rtllib_register_crypto_ops);
int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops)
int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
{
unsigned long flags;
struct list_head *ptr;
@ -155,7 +155,7 @@ int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops)
EXPORT_SYMBOL(rtllib_unregister_crypto_ops);
struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name)
struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name)
{
unsigned long flags;
struct list_head *ptr;
@ -186,7 +186,7 @@ EXPORT_SYMBOL(rtllib_get_crypto_ops);
static void * rtllib_crypt_null_init(int keyidx) { return (void *) 1; }
static void rtllib_crypt_null_deinit(void *priv) {}
static struct rtllib_crypto_ops rtllib_crypt_null = {
static struct lib80211_crypto_ops rtllib_crypt_null = {
.name = "NULL",
.init = rtllib_crypt_null_init,
.deinit = rtllib_crypt_null_deinit,
@ -196,8 +196,10 @@ static struct rtllib_crypto_ops rtllib_crypt_null = {
.decrypt_msdu = NULL,
.set_key = NULL,
.get_key = NULL,
.extra_prefix_len = 0,
.extra_postfix_len = 0,
.extra_mpdu_prefix_len = 0,
.extra_mpdu_postfix_len = 0,
.extra_msdu_prefix_len = 0,
.extra_msdu_postfix_len = 0,
.owner = THIS_MODULE,
};

View File

@ -25,61 +25,11 @@
#include <linux/skbuff.h>
struct rtllib_crypto_ops {
const char *name;
/* init new crypto context (e.g., allocate private data space,
* select IV, etc.); returns NULL on failure or pointer to allocated
* private data on success */
void * (*init)(int keyidx);
/* deinitialize crypto context and free allocated private data */
void (*deinit)(void *priv);
/* encrypt/decrypt return < 0 on error or >= 0 on success. The return
* value from decrypt_mpdu is passed as the keyidx value for
* decrypt_msdu. skb must have enough head and tail room for the
* encryption; if not, error will be returned; these functions are
* called for all MPDUs (i.e., fragments).
*/
int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
/* These functions are called for full MSDUs, i.e. full frames.
* These can be NULL if full MSDU operations are not needed. */
int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
void *priv, struct rtllib_device* ieee);
int (*set_key)(void *key, int len, u8 *seq, void *priv);
int (*get_key)(void *key, int len, u8 *seq, void *priv);
/* procfs handler for printing out key information and possible
* statistics */
char * (*print_stats)(char *p, void *priv);
/* maximum number of bytes added by encryption; encrypt buf is
* allocated with extra_prefix_len bytes, copy of in_buf, and
* extra_postfix_len; encrypt need not use all this space, but
* the result must start at the beginning of the struct buffer and
* correct length must be returned */
int extra_prefix_len, extra_postfix_len;
struct module *owner;
};
struct rtllib_crypt_data {
struct list_head list; /* delayed deletion list */
struct rtllib_crypto_ops *ops;
void *priv;
atomic_t refcnt;
};
int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops);
int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops);
struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name);
int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops);
int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops);
struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name);
void rtllib_crypt_deinit_entries(struct rtllib_device *, int);
void rtllib_crypt_deinit_handler(unsigned long);
void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
struct rtllib_crypt_data **crypt);
struct lib80211_crypt_data **crypt);
#endif

View File

@ -427,7 +427,7 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv)
return p;
}
static struct rtllib_crypto_ops rtllib_crypt_ccmp = {
static struct lib80211_crypto_ops rtllib_crypt_ccmp = {
.name = "CCMP",
.init = rtllib_ccmp_init,
.deinit = rtllib_ccmp_deinit,
@ -438,8 +438,8 @@ static struct rtllib_crypto_ops rtllib_crypt_ccmp = {
.set_key = rtllib_ccmp_set_key,
.get_key = rtllib_ccmp_get_key,
.print_stats = rtllib_ccmp_print_stats,
.extra_prefix_len = CCMP_HDR_LEN,
.extra_postfix_len = CCMP_MIC_LEN,
.extra_mpdu_prefix_len = CCMP_HDR_LEN,
.extra_mpdu_postfix_len = CCMP_MIC_LEN,
.owner = THIS_MODULE,
};

View File

@ -596,8 +596,7 @@ static void rtllib_michael_mic_failure(struct net_device *dev,
}
static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
int hdr_len, void *priv,
struct rtllib_device *ieee)
int hdr_len, void *priv)
{
struct rtllib_tkip_data *tkey = priv;
u8 mic[8];
@ -616,23 +615,20 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
return -1;
if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0) ||
(ieee->force_mic_error)) {
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
struct rtllib_hdr_4addr *hdr;
hdr = (struct rtllib_hdr_4addr *) skb->data;
printk(KERN_DEBUG "%s: Michael MIC verification failed for "
"MSDU from %pM keyidx=%d\n",
skb->dev ? skb->dev->name : "N/A", hdr->addr2,
keyidx);
printk(KERN_DEBUG "%d, force_mic_error = %d\n",
(memcmp(mic, skb->data + skb->len - 8, 8) != 0),\
ieee->force_mic_error);
printk(KERN_DEBUG "%d\n",
memcmp(mic, skb->data + skb->len - 8, 8) != 0);
if (skb->dev) {
printk(KERN_INFO "skb->dev != NULL\n");
rtllib_michael_mic_failure(skb->dev, hdr, keyidx);
}
tkey->dot11RSNAStatsTKIPLocalMICFailures++;
ieee->force_mic_error = false;
return -1;
}
@ -738,7 +734,7 @@ static char *rtllib_tkip_print_stats(char *p, void *priv)
return p;
}
static struct rtllib_crypto_ops rtllib_crypt_tkip = {
static struct lib80211_crypto_ops rtllib_crypt_tkip = {
.name = "TKIP",
.init = rtllib_tkip_init,
.deinit = rtllib_tkip_deinit,
@ -749,8 +745,9 @@ static struct rtllib_crypto_ops rtllib_crypt_tkip = {
.set_key = rtllib_tkip_set_key,
.get_key = rtllib_tkip_get_key,
.print_stats = rtllib_tkip_print_stats,
.extra_prefix_len = 4 + 4, /* IV + ExtIV */
.extra_postfix_len = 8 + 4, /* MIC + ICV */
.extra_mpdu_prefix_len = 4 + 4, /* IV + ExtIV */
.extra_mpdu_postfix_len = 4, /* ICV */
.extra_msdu_postfix_len = 8, /* MIC */
.owner = THIS_MODULE,
};

View File

@ -255,7 +255,7 @@ static char *prism2_wep_print_stats(char *p, void *priv)
return p;
}
static struct rtllib_crypto_ops rtllib_crypt_wep = {
static struct lib80211_crypto_ops rtllib_crypt_wep = {
.name = "WEP",
.init = prism2_wep_init,
.deinit = prism2_wep_deinit,
@ -266,8 +266,8 @@ static struct rtllib_crypto_ops rtllib_crypt_wep = {
.set_key = prism2_wep_set_key,
.get_key = prism2_wep_get_key,
.print_stats = prism2_wep_print_stats,
.extra_prefix_len = 4, /* IV */
.extra_postfix_len = 4, /* ICV */
.extra_mpdu_prefix_len = 4, /* IV */
.extra_mpdu_postfix_len = 4, /* ICV */
.owner = THIS_MODULE,
};

View File

@ -136,6 +136,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
ieee->host_decrypt = 1;
ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
/* SAM Init here */
INIT_LIST_HEAD(&ieee->crypt_deinit_list);
_setup_timer(&ieee->crypt_deinit_timer,
rtllib_crypt_deinit_handler,
@ -200,7 +201,7 @@ void free_rtllib(struct net_device *dev)
rtllib_crypt_deinit_entries(ieee, 1);
for (i = 0; i < NUM_WEP_KEYS; i++) {
struct rtllib_crypt_data *crypt = ieee->crypt[i];
struct lib80211_crypt_data *crypt = ieee->crypt[i];
if (crypt) {
if (crypt->ops)
crypt->ops->deinit(crypt->priv);

View File

@ -280,7 +280,7 @@ static int rtllib_is_eapol_frame(struct rtllib_device *ieee,
/* Called only as a tasklet (software IRQ), by rtllib_rx */
static inline int
rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
struct rtllib_crypt_data *crypt)
struct lib80211_crypt_data *crypt)
{
struct rtllib_hdr_4addr *hdr;
int res, hdrlen;
@ -321,7 +321,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
/* Called only as a tasklet (software IRQ), by rtllib_rx */
static inline int
rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
int keyidx, struct rtllib_crypt_data *crypt)
int keyidx, struct lib80211_crypt_data *crypt)
{
struct rtllib_hdr_4addr *hdr;
int res, hdrlen;
@ -340,7 +340,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
atomic_inc(&crypt->refcnt);
res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv, ieee);
res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
atomic_dec(&crypt->refcnt);
if (res < 0) {
printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
@ -1009,7 +1009,7 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
}
static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
struct rtllib_crypt_data **crypt, size_t hdrlen)
struct lib80211_crypt_data **crypt, size_t hdrlen)
{
struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
u16 fc = le16_to_cpu(hdr->frame_ctl);
@ -1044,7 +1044,7 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
struct rtllib_rx_stats *rx_stats,
struct rtllib_crypt_data *crypt, size_t hdrlen)
struct lib80211_crypt_data *crypt, size_t hdrlen)
{
struct rtllib_hdr_4addr *hdr;
int keyidx = 0;
@ -1252,7 +1252,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
{
struct net_device *dev = ieee->dev;
struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
struct rtllib_crypt_data *crypt = NULL;
struct lib80211_crypt_data *crypt = NULL;
struct rtllib_rxb *rxb = NULL;
struct rx_ts_record *pTS = NULL;
u16 fc, sc, SeqNum = 0;

View File

@ -836,7 +836,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
struct sk_buff *skb = NULL;
int encrypt;
int atim_len, erp_len;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
char *ssid = ieee->current_network.ssid;
int ssid_len = ieee->current_network.ssid_len;
@ -982,7 +982,7 @@ static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
struct sk_buff *skb;
u8 *tag;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
struct rtllib_assoc_response_frame *assoc;
short encrypt;
@ -1178,7 +1178,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
unsigned int ckip_ie_len = 0;
unsigned int ccxrm_ie_len = 0;
unsigned int cxvernum_ie_len = 0;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
int encrypt;
int PMKCacheIdx;
@ -3345,8 +3345,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
u8 is_mesh)
{
int ret = 0;
struct rtllib_crypto_ops *ops;
struct rtllib_crypt_data **crypt;
struct lib80211_crypto_ops *ops;
struct lib80211_crypt_data **crypt;
struct rtllib_security sec = {
.flags = 0,
@ -3408,17 +3408,17 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
goto done;
}
if (*crypt == NULL || (*crypt)->ops != ops) {
struct rtllib_crypt_data *new_crypt;
struct lib80211_crypt_data *new_crypt;
rtllib_crypt_delayed_deinit(ieee, crypt);
new_crypt = (struct rtllib_crypt_data *)
new_crypt = (struct lib80211_crypt_data *)
kmalloc(sizeof(*new_crypt), GFP_KERNEL);
if (new_crypt == NULL) {
ret = -ENOMEM;
goto done;
}
memset(new_crypt, 0, sizeof(struct rtllib_crypt_data));
memset(new_crypt, 0, sizeof(struct lib80211_crypt_data));
new_crypt->ops = ops;
if (new_crypt->ops)
new_crypt->priv =
@ -3562,7 +3562,7 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee)
static u8 ccmp_ie[4] = {0x00, 0x50, 0xf2, 0x04};
static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
int wpa_ie_len = ieee->wpa_ie_len;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
int encrypt;
crypt = ieee->crypt[ieee->tx_keyidx];

View File

@ -179,7 +179,7 @@ inline int rtllib_put_snap(u8 *data, u16 h_proto)
int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag,
int hdr_len)
{
struct rtllib_crypt_data *crypt = NULL;
struct lib80211_crypt_data *crypt = NULL;
int res;
crypt = ieee->crypt[ieee->tx_keyidx];
@ -568,7 +568,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
};
u8 dest[ETH_ALEN], src[ETH_ALEN];
int qos_actived = ieee->current_network.qos_data.active;
struct rtllib_crypt_data *crypt = NULL;
struct lib80211_crypt_data *crypt = NULL;
struct cb_desc *tcb_desc;
u8 bIsMulticast = false;
u8 IsAmsdu = false;
@ -741,8 +741,10 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
/* Each fragment may need to have room for encryptiong
* pre/postfix */
if (encrypt) {
bytes_per_frag -= crypt->ops->extra_prefix_len +
crypt->ops->extra_postfix_len;
bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len +
crypt->ops->extra_mpdu_postfix_len +
crypt->ops->extra_msdu_prefix_len +
crypt->ops->extra_msdu_postfix_len;
}
/* Number of fragments is the total bytes_per_frag /
* payload_per_fragment */
@ -790,7 +792,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
else
tcb_desc->bHwSec = 0;
skb_reserve(skb_frag,
crypt->ops->extra_prefix_len);
crypt->ops->extra_mpdu_prefix_len +
crypt->ops->extra_msdu_prefix_len);
} else {
tcb_desc->bHwSec = 0;
}

View File

@ -306,7 +306,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
.flags = 0
};
int i, key, key_provided, len;
struct rtllib_crypt_data **crypt;
struct lib80211_crypt_data **crypt;
RTLLIB_DEBUG_WX("SET_ENCODE\n");
@ -365,10 +365,10 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
}
if (*crypt == NULL) {
struct rtllib_crypt_data *new_crypt;
struct lib80211_crypt_data *new_crypt;
/* take WEP into use */
new_crypt = kzalloc(sizeof(struct rtllib_crypt_data),
new_crypt = kzalloc(sizeof(struct lib80211_crypt_data),
GFP_KERNEL);
if (new_crypt == NULL)
return -ENOMEM;
@ -477,7 +477,7 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
{
struct iw_point *erq = &(wrqu->encoding);
int len, key;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
RTLLIB_DEBUG_WX("GET_ENCODE\n");
@ -526,8 +526,8 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
int i, idx;
int group_key = 0;
const char *alg, *module;
struct rtllib_crypto_ops *ops;
struct rtllib_crypt_data **crypt;
struct lib80211_crypto_ops *ops;
struct lib80211_crypt_data **crypt;
struct rtllib_security sec = {
.flags = 0,
@ -593,7 +593,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
}
printk(KERN_INFO "alg name:%s\n", alg);
ops = rtllib_get_crypto_ops(alg);
ops = rtllib_get_crypto_ops(alg);
if (ops == NULL) {
char tempbuf[100];
@ -611,7 +611,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
}
if (*crypt == NULL || (*crypt)->ops != ops) {
struct rtllib_crypt_data *new_crypt;
struct lib80211_crypt_data *new_crypt;
rtllib_crypt_delayed_deinit(ieee, crypt);
@ -683,7 +683,7 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
{
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
struct rtllib_crypt_data *crypt;
struct lib80211_crypt_data *crypt;
int idx, max_key_len;
max_key_len = encoding->length - sizeof(*ext);