Skip to content

Commit

Permalink
[wireless ieee80211,ipw2200] Lindent source code
Browse files Browse the repository at this point in the history
No code changes, just Lindent + manual fixups.

This prepares us for updating to the latest Intel driver code, plus
gives the source code a nice facelift.
  • Loading branch information
jgarzik committed Sep 7, 2005
1 parent bbeec90 commit 0edd5b4
Show file tree
Hide file tree
Showing 10 changed files with 1,648 additions and 1,749 deletions.
2,270 changes: 1,150 additions & 1,120 deletions drivers/net/wireless/ipw2200.c

Large diffs are not rendered by default.

406 changes: 171 additions & 235 deletions drivers/net/wireless/ipw2200.h

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions net/ieee80211/ieee80211_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ struct ieee80211_crypto_alg {
struct ieee80211_crypto_ops *ops;
};


struct ieee80211_crypto {
struct list_head algs;
spinlock_t lock;
};

static struct ieee80211_crypto *hcrypt;

void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
int force)
void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force)
{
struct list_head *ptr, *n;
struct ieee80211_crypt_data *entry;
Expand Down Expand Up @@ -140,7 +138,7 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
spin_lock_irqsave(&hcrypt->lock, flags);
for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
struct ieee80211_crypto_alg *alg =
(struct ieee80211_crypto_alg *) ptr;
(struct ieee80211_crypto_alg *)ptr;
if (alg->ops == ops) {
list_del(&alg->list);
del_alg = alg;
Expand All @@ -158,8 +156,7 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
return del_alg ? 0 : -1;
}


struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name)
{
unsigned long flags;
struct list_head *ptr;
Expand All @@ -171,7 +168,7 @@ struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
spin_lock_irqsave(&hcrypt->lock, flags);
for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
struct ieee80211_crypto_alg *alg =
(struct ieee80211_crypto_alg *) ptr;
(struct ieee80211_crypto_alg *)ptr;
if (strcmp(alg->ops->name, name) == 0) {
found_alg = alg;
break;
Expand All @@ -185,9 +182,13 @@ struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
return NULL;
}


static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
static void ieee80211_crypt_null_deinit(void *priv) {}
static void *ieee80211_crypt_null_init(int keyidx)
{
return (void *)1;
}
static void ieee80211_crypt_null_deinit(void *priv)
{
}

static struct ieee80211_crypto_ops ieee80211_crypt_null = {
.name = "NULL",
Expand All @@ -204,7 +205,6 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = {
.owner = THIS_MODULE,
};


static int __init ieee80211_crypto_init(void)
{
int ret = -ENOMEM;
Expand All @@ -222,11 +222,10 @@ static int __init ieee80211_crypto_init(void)
kfree(hcrypt);
hcrypt = NULL;
}
out:
out:
return ret;
}


static void __exit ieee80211_crypto_deinit(void)
{
struct list_head *ptr, *n;
Expand All @@ -237,7 +236,7 @@ static void __exit ieee80211_crypto_deinit(void)
for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs;
ptr = n, n = ptr->next) {
struct ieee80211_crypto_alg *alg =
(struct ieee80211_crypto_alg *) ptr;
(struct ieee80211_crypto_alg *)ptr;
list_del(ptr);
printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
"'%s' (deinit)\n", alg->ops->name);
Expand Down
47 changes: 16 additions & 31 deletions net/ieee80211/ieee80211_crypt_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <net/ieee80211.h>


#include <linux/crypto.h>
#include <asm/scatterlist.h>

Expand Down Expand Up @@ -55,7 +54,7 @@ struct ieee80211_ccmp_data {

/* scratch buffers for virt_to_page() (crypto API) */
u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
};

Expand All @@ -75,7 +74,7 @@ static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
}

static void * ieee80211_ccmp_init(int key_idx)
static void *ieee80211_ccmp_init(int key_idx)
{
struct ieee80211_ccmp_data *priv;

Expand All @@ -94,7 +93,7 @@ static void * ieee80211_ccmp_init(int key_idx)

return priv;

fail:
fail:
if (priv) {
if (priv->tfm)
crypto_free_tfm(priv->tfm);
Expand All @@ -104,7 +103,6 @@ static void * ieee80211_ccmp_init(int key_idx)
return NULL;
}


static void ieee80211_ccmp_deinit(void *priv)
{
struct ieee80211_ccmp_data *_priv = priv;
Expand All @@ -113,19 +111,16 @@ static void ieee80211_ccmp_deinit(void *priv)
kfree(priv);
}


static inline void xor_block(u8 *b, u8 *a, size_t len)
static inline void xor_block(u8 * b, u8 * a, size_t len)
{
int i;
for (i = 0; i < len; i++)
b[i] ^= a[i];
}


static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr *hdr,
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
u8 *s0)
u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0)
{
u8 *pos, qc = 0;
size_t aad_len;
Expand All @@ -142,7 +137,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
if (a4_included)
aad_len += 6;
if (qc_included) {
pos = (u8 *) &hdr->addr4;
pos = (u8 *) & hdr->addr4;
if (a4_included)
pos += 6;
qc = *pos & 0x0f;
Expand All @@ -169,14 +164,14 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
* QC (if present)
*/
pos = (u8 *) hdr;
aad[0] = 0; /* aad_len >> 8 */
aad[0] = 0; /* aad_len >> 8 */
aad[1] = aad_len & 0xff;
aad[2] = pos[0] & 0x8f;
aad[3] = pos[1] & 0xc7;
memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
pos = (u8 *) &hdr->seq_ctl;
pos = (u8 *) & hdr->seq_ctl;
aad[22] = pos[0] & 0x0f;
aad[23] = 0; /* all bits masked */
aad[23] = 0; /* all bits masked */
memset(aad + 24, 0, 8);
if (a4_included)
memcpy(aad + 24, hdr->addr4, ETH_ALEN);
Expand All @@ -196,7 +191,6 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
}


static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_ccmp_data *key = priv;
Expand All @@ -209,8 +203,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 *s0 = key->tx_s0;

if (skb_headroom(skb) < CCMP_HDR_LEN ||
skb_tailroom(skb) < CCMP_MIC_LEN ||
skb->len < hdr_len)
skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len)
return -1;

data_len = skb->len - hdr_len;
Expand All @@ -230,13 +223,13 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[5];
*pos++ = key->tx_pn[4];
*pos++ = 0;
*pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
*pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */ ;
*pos++ = key->tx_pn[3];
*pos++ = key->tx_pn[2];
*pos++ = key->tx_pn[1];
*pos++ = key->tx_pn[0];

hdr = (struct ieee80211_hdr *) skb->data;
hdr = (struct ieee80211_hdr *)skb->data;
ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);

blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
Expand All @@ -261,7 +254,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
return 0;
}


static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_ccmp_data *key = priv;
Expand All @@ -280,7 +272,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -1;
}

hdr = (struct ieee80211_hdr *) skb->data;
hdr = (struct ieee80211_hdr *)skb->data;
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
Expand Down Expand Up @@ -364,8 +356,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return keyidx;
}


static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
static int ieee80211_ccmp_set_key(void *key, int len, u8 * seq, void *priv)
{
struct ieee80211_ccmp_data *data = priv;
int keyidx;
Expand Down Expand Up @@ -395,8 +386,7 @@ static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
return 0;
}


static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
static int ieee80211_ccmp_get_key(void *key, int len, u8 * seq, void *priv)
{
struct ieee80211_ccmp_data *data = priv;

Expand All @@ -419,8 +409,7 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
return CCMP_TK_LEN;
}


static char * ieee80211_ccmp_print_stats(char *p, void *priv)
static char *ieee80211_ccmp_print_stats(char *p, void *priv)
{
struct ieee80211_ccmp_data *ccmp = priv;
p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
Expand All @@ -436,7 +425,6 @@ static char * ieee80211_ccmp_print_stats(char *p, void *priv)
return p;
}


static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
.name = "CCMP",
.init = ieee80211_ccmp_init,
Expand All @@ -453,18 +441,15 @@ static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
.owner = THIS_MODULE,
};


static int __init ieee80211_crypto_ccmp_init(void)
{
return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
}


static void __exit ieee80211_crypto_ccmp_exit(void)
{
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
}


module_init(ieee80211_crypto_ccmp_init);
module_exit(ieee80211_crypto_ccmp_exit);
Loading

0 comments on commit 0edd5b4

Please sign in to comment.