-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MAC80211]: split out some key functions from ieee80211.c
into a new file key.c which doesn't have much code right now but it makes ieee80211.c easier to read. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Jiri Benc <jbenc@suse.cz> Signed-off-by: John W. Linville <linville@tuxdriver.com>
- Loading branch information
Johannes Berg
authored and
David S. Miller
committed
Oct 10, 2007
1 parent
75c35aa
commit 1f5a7e4
Showing
4 changed files
with
78 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ mac80211-objs := \ | |
ieee80211_cfg.o \ | ||
rx.o \ | ||
tx.o \ | ||
key.o \ | ||
$(mac80211-objs-y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2002-2005, Instant802 Networks, Inc. | ||
* Copyright 2005-2006, Devicescape Software, Inc. | ||
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <net/mac80211.h> | ||
#include "ieee80211_i.h" | ||
#include "debugfs_key.h" | ||
#include "aes_ccm.h" | ||
|
||
struct ieee80211_key_conf * | ||
ieee80211_key_data2conf(struct ieee80211_local *local, | ||
const struct ieee80211_key *data) | ||
{ | ||
struct ieee80211_key_conf *conf; | ||
|
||
conf = kmalloc(sizeof(*conf) + data->keylen, GFP_ATOMIC); | ||
if (!conf) | ||
return NULL; | ||
|
||
conf->hw_key_idx = data->hw_key_idx; | ||
conf->alg = data->alg; | ||
conf->keylen = data->keylen; | ||
conf->flags = 0; | ||
if (data->force_sw_encrypt) | ||
conf->flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT; | ||
conf->keyidx = data->keyidx; | ||
if (data->default_tx_key) | ||
conf->flags |= IEEE80211_KEY_DEFAULT_TX_KEY; | ||
if (local->default_wep_only) | ||
conf->flags |= IEEE80211_KEY_DEFAULT_WEP_ONLY; | ||
memcpy(conf->key, data->key, data->keylen); | ||
|
||
return conf; | ||
} | ||
|
||
struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | ||
int idx, size_t key_len, gfp_t flags) | ||
{ | ||
struct ieee80211_key *key; | ||
|
||
key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags); | ||
if (!key) | ||
return NULL; | ||
kref_init(&key->kref); | ||
return key; | ||
} | ||
|
||
static void ieee80211_key_release(struct kref *kref) | ||
{ | ||
struct ieee80211_key *key; | ||
|
||
key = container_of(kref, struct ieee80211_key, kref); | ||
if (key->alg == ALG_CCMP) | ||
ieee80211_aes_key_free(key->u.ccmp.tfm); | ||
ieee80211_debugfs_key_remove(key); | ||
kfree(key); | ||
} | ||
|
||
void ieee80211_key_free(struct ieee80211_key *key) | ||
{ | ||
if (key) | ||
kref_put(&key->kref, ieee80211_key_release); | ||
} |