diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/Makefile | 1 | ||||
-rw-r--r-- | net/mac80211/ieee80211.c | 56 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 14 | ||||
-rw-r--r-- | net/mac80211/key.c | 69 |
4 files changed, 78 insertions, 62 deletions
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index 848260296a0c..d95de3f8a4b1 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -20,4 +20,5 @@ mac80211-objs := \ | |||
20 | ieee80211_cfg.o \ | 20 | ieee80211_cfg.o \ |
21 | rx.o \ | 21 | rx.o \ |
22 | tx.o \ | 22 | tx.o \ |
23 | key.o \ | ||
23 | $(mac80211-objs-y) | 24 | $(mac80211-objs-y) |
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 02fb00ec2ed3..f20e647552ec 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include "ieee80211_cfg.h" | 33 | #include "ieee80211_cfg.h" |
34 | #include "debugfs.h" | 34 | #include "debugfs.h" |
35 | #include "debugfs_netdev.h" | 35 | #include "debugfs_netdev.h" |
36 | #include "debugfs_key.h" | ||
37 | 36 | ||
38 | /* privid for wiphys to determine whether they belong to us or not */ | 37 | /* privid for wiphys to determine whether they belong to us or not */ |
39 | void *mac80211_wiphy_privid = &mac80211_wiphy_privid; | 38 | void *mac80211_wiphy_privid = &mac80211_wiphy_privid; |
@@ -63,61 +62,6 @@ struct ieee80211_tx_status_rtap_hdr { | |||
63 | } __attribute__ ((packed)); | 62 | } __attribute__ ((packed)); |
64 | 63 | ||
65 | 64 | ||
66 | struct ieee80211_key_conf * | ||
67 | ieee80211_key_data2conf(struct ieee80211_local *local, | ||
68 | const struct ieee80211_key *data) | ||
69 | { | ||
70 | struct ieee80211_key_conf *conf; | ||
71 | |||
72 | conf = kmalloc(sizeof(*conf) + data->keylen, GFP_ATOMIC); | ||
73 | if (!conf) | ||
74 | return NULL; | ||
75 | |||
76 | conf->hw_key_idx = data->hw_key_idx; | ||
77 | conf->alg = data->alg; | ||
78 | conf->keylen = data->keylen; | ||
79 | conf->flags = 0; | ||
80 | if (data->force_sw_encrypt) | ||
81 | conf->flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT; | ||
82 | conf->keyidx = data->keyidx; | ||
83 | if (data->default_tx_key) | ||
84 | conf->flags |= IEEE80211_KEY_DEFAULT_TX_KEY; | ||
85 | if (local->default_wep_only) | ||
86 | conf->flags |= IEEE80211_KEY_DEFAULT_WEP_ONLY; | ||
87 | memcpy(conf->key, data->key, data->keylen); | ||
88 | |||
89 | return conf; | ||
90 | } | ||
91 | |||
92 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | ||
93 | int idx, size_t key_len, gfp_t flags) | ||
94 | { | ||
95 | struct ieee80211_key *key; | ||
96 | |||
97 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags); | ||
98 | if (!key) | ||
99 | return NULL; | ||
100 | kref_init(&key->kref); | ||
101 | return key; | ||
102 | } | ||
103 | |||
104 | static void ieee80211_key_release(struct kref *kref) | ||
105 | { | ||
106 | struct ieee80211_key *key; | ||
107 | |||
108 | key = container_of(kref, struct ieee80211_key, kref); | ||
109 | if (key->alg == ALG_CCMP) | ||
110 | ieee80211_aes_key_free(key->u.ccmp.tfm); | ||
111 | ieee80211_debugfs_key_remove(key); | ||
112 | kfree(key); | ||
113 | } | ||
114 | |||
115 | void ieee80211_key_free(struct ieee80211_key *key) | ||
116 | { | ||
117 | if (key) | ||
118 | kref_put(&key->kref, ieee80211_key_release); | ||
119 | } | ||
120 | |||
121 | static int rate_list_match(const int *rate_list, int rate) | 65 | static int rate_list_match(const int *rate_list, int rate) |
122 | { | 66 | { |
123 | int i; | 67 | int i; |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 9d3401d12917..af8b9848e021 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -719,12 +719,6 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) | |||
719 | int ieee80211_hw_config(struct ieee80211_local *local); | 719 | int ieee80211_hw_config(struct ieee80211_local *local); |
720 | int ieee80211_if_config(struct net_device *dev); | 720 | int ieee80211_if_config(struct net_device *dev); |
721 | int ieee80211_if_config_beacon(struct net_device *dev); | 721 | int ieee80211_if_config_beacon(struct net_device *dev); |
722 | struct ieee80211_key_conf * | ||
723 | ieee80211_key_data2conf(struct ieee80211_local *local, | ||
724 | const struct ieee80211_key *data); | ||
725 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | ||
726 | int idx, size_t key_len, gfp_t flags); | ||
727 | void ieee80211_key_free(struct ieee80211_key *key); | ||
728 | void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb, | 722 | void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb, |
729 | struct ieee80211_rx_status *status, u32 msg_type); | 723 | struct ieee80211_rx_status *status, u32 msg_type); |
730 | void ieee80211_prepare_rates(struct ieee80211_local *local, | 724 | void ieee80211_prepare_rates(struct ieee80211_local *local, |
@@ -833,6 +827,14 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); | |||
833 | int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); | 827 | int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); |
834 | int ieee80211_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev); | 828 | int ieee80211_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev); |
835 | 829 | ||
830 | /* key handling */ | ||
831 | struct ieee80211_key_conf * | ||
832 | ieee80211_key_data2conf(struct ieee80211_local *local, | ||
833 | const struct ieee80211_key *data); | ||
834 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | ||
835 | int idx, size_t key_len, gfp_t flags); | ||
836 | void ieee80211_key_free(struct ieee80211_key *key); | ||
837 | |||
836 | /* for wiphy privid */ | 838 | /* for wiphy privid */ |
837 | extern void *mac80211_wiphy_privid; | 839 | extern void *mac80211_wiphy_privid; |
838 | 840 | ||
diff --git a/net/mac80211/key.c b/net/mac80211/key.c new file mode 100644 index 000000000000..b67558c24639 --- /dev/null +++ b/net/mac80211/key.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | ||
3 | * Copyright 2005-2006, Devicescape Software, Inc. | ||
4 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <net/mac80211.h> | ||
12 | #include "ieee80211_i.h" | ||
13 | #include "debugfs_key.h" | ||
14 | #include "aes_ccm.h" | ||
15 | |||
16 | struct ieee80211_key_conf * | ||
17 | ieee80211_key_data2conf(struct ieee80211_local *local, | ||
18 | const struct ieee80211_key *data) | ||
19 | { | ||
20 | struct ieee80211_key_conf *conf; | ||
21 | |||
22 | conf = kmalloc(sizeof(*conf) + data->keylen, GFP_ATOMIC); | ||
23 | if (!conf) | ||
24 | return NULL; | ||
25 | |||
26 | conf->hw_key_idx = data->hw_key_idx; | ||
27 | conf->alg = data->alg; | ||
28 | conf->keylen = data->keylen; | ||
29 | conf->flags = 0; | ||
30 | if (data->force_sw_encrypt) | ||
31 | conf->flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT; | ||
32 | conf->keyidx = data->keyidx; | ||
33 | if (data->default_tx_key) | ||
34 | conf->flags |= IEEE80211_KEY_DEFAULT_TX_KEY; | ||
35 | if (local->default_wep_only) | ||
36 | conf->flags |= IEEE80211_KEY_DEFAULT_WEP_ONLY; | ||
37 | memcpy(conf->key, data->key, data->keylen); | ||
38 | |||
39 | return conf; | ||
40 | } | ||
41 | |||
42 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | ||
43 | int idx, size_t key_len, gfp_t flags) | ||
44 | { | ||
45 | struct ieee80211_key *key; | ||
46 | |||
47 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags); | ||
48 | if (!key) | ||
49 | return NULL; | ||
50 | kref_init(&key->kref); | ||
51 | return key; | ||
52 | } | ||
53 | |||
54 | static void ieee80211_key_release(struct kref *kref) | ||
55 | { | ||
56 | struct ieee80211_key *key; | ||
57 | |||
58 | key = container_of(kref, struct ieee80211_key, kref); | ||
59 | if (key->alg == ALG_CCMP) | ||
60 | ieee80211_aes_key_free(key->u.ccmp.tfm); | ||
61 | ieee80211_debugfs_key_remove(key); | ||
62 | kfree(key); | ||
63 | } | ||
64 | |||
65 | void ieee80211_key_free(struct ieee80211_key *key) | ||
66 | { | ||
67 | if (key) | ||
68 | kref_put(&key->kref, ieee80211_key_release); | ||
69 | } | ||