1 Subject: mac80211: support adding/removing keys via cfg80211
3 This adds the necessary hooks to mac80211 to allow userspace
4 to edit keys with cfg80211 (through nl80211.)
6 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
9 net/mac80211/cfg.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
10 1 file changed, 91 insertions(+)
12 --- everything.orig/net/mac80211/cfg.c 2007-11-07 13:19:29.441515732 +0100
13 +++ everything/net/mac80211/cfg.c 2007-11-07 13:19:39.531517685 +0100
15 * This file is GPLv2 as found in COPYING.
18 +#include <linux/ieee80211.h>
19 #include <linux/nl80211.h>
20 #include <linux/rtnetlink.h>
21 #include <net/net_namespace.h>
22 @@ -105,8 +106,98 @@ static int ieee80211_change_iface(struct
26 +static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
27 + u8 key_idx, u8 *mac_addr,
28 + struct key_params *params)
30 + struct ieee80211_sub_if_data *sdata;
31 + struct sta_info *sta = NULL;
32 + enum ieee80211_key_alg alg;
35 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
37 + switch (params->cipher) {
38 + case WLAN_CIPHER_SUITE_WEP40:
39 + case WLAN_CIPHER_SUITE_WEP104:
42 + case WLAN_CIPHER_SUITE_TKIP:
45 + case WLAN_CIPHER_SUITE_CCMP:
53 + sta = sta_info_get(sdata->local, mac_addr);
59 + if (!ieee80211_key_alloc(sdata, sta, alg, key_idx,
60 + params->key_len, params->key))
69 +static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
70 + u8 key_idx, u8 *mac_addr)
72 + struct ieee80211_sub_if_data *sdata;
73 + struct sta_info *sta;
76 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
79 + sta = sta_info_get(sdata->local, mac_addr);
85 + ieee80211_key_free(sta->key);
93 + if (!sdata->keys[key_idx])
96 + ieee80211_key_free(sdata->keys[key_idx]);
101 +static int ieee80211_config_default_key(struct wiphy *wiphy,
102 + struct net_device *dev,
105 + struct ieee80211_sub_if_data *sdata;
107 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
108 + ieee80211_set_default_key(sdata, key_idx);
113 struct cfg80211_ops mac80211_config_ops = {
114 .add_virtual_intf = ieee80211_add_iface,
115 .del_virtual_intf = ieee80211_del_iface,
116 .change_virtual_intf = ieee80211_change_iface,
117 + .add_key = ieee80211_add_key,
118 + .del_key = ieee80211_del_key,
119 + .set_default_key = ieee80211_config_default_key,