iptables: remove obsolete patch
[openwrt/staging/lynxis/omap.git] / package / mac80211 / patches / 018-mac80211-cfg80211-keys.patch
1 Subject: mac80211: support adding/removing keys via cfg80211
2
3 This adds the necessary hooks to mac80211 to allow userspace
4 to edit keys with cfg80211 (through nl80211.)
5
6 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
7
8 ---
9 net/mac80211/cfg.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
10 1 file changed, 91 insertions(+)
11
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
14 @@ -6,6 +6,7 @@
15 * This file is GPLv2 as found in COPYING.
16 */
17
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
23 return 0;
24 }
25
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)
29 +{
30 + struct ieee80211_sub_if_data *sdata;
31 + struct sta_info *sta = NULL;
32 + enum ieee80211_key_alg alg;
33 + int ret;
34 +
35 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
36 +
37 + switch (params->cipher) {
38 + case WLAN_CIPHER_SUITE_WEP40:
39 + case WLAN_CIPHER_SUITE_WEP104:
40 + alg = ALG_WEP;
41 + break;
42 + case WLAN_CIPHER_SUITE_TKIP:
43 + alg = ALG_TKIP;
44 + break;
45 + case WLAN_CIPHER_SUITE_CCMP:
46 + alg = ALG_CCMP;
47 + break;
48 + default:
49 + return -EINVAL;
50 + }
51 +
52 + if (mac_addr) {
53 + sta = sta_info_get(sdata->local, mac_addr);
54 + if (!sta)
55 + return -ENOENT;
56 + }
57 +
58 + ret = 0;
59 + if (!ieee80211_key_alloc(sdata, sta, alg, key_idx,
60 + params->key_len, params->key))
61 + ret = -ENOMEM;
62 +
63 + if (sta)
64 + sta_info_put(sta);
65 +
66 + return ret;
67 +}
68 +
69 +static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
70 + u8 key_idx, u8 *mac_addr)
71 +{
72 + struct ieee80211_sub_if_data *sdata;
73 + struct sta_info *sta;
74 + int ret;
75 +
76 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
77 +
78 + if (mac_addr) {
79 + sta = sta_info_get(sdata->local, mac_addr);
80 + if (!sta)
81 + return -ENOENT;
82 +
83 + ret = 0;
84 + if (sta->key)
85 + ieee80211_key_free(sta->key);
86 + else
87 + ret = -ENOENT;
88 +
89 + sta_info_put(sta);
90 + return ret;
91 + }
92 +
93 + if (!sdata->keys[key_idx])
94 + return -ENOENT;
95 +
96 + ieee80211_key_free(sdata->keys[key_idx]);
97 +
98 + return 0;
99 +}
100 +
101 +static int ieee80211_config_default_key(struct wiphy *wiphy,
102 + struct net_device *dev,
103 + u8 key_idx)
104 +{
105 + struct ieee80211_sub_if_data *sdata;
106 +
107 + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
108 + ieee80211_set_default_key(sdata, key_idx);
109 +
110 + return 0;
111 +}
112 +
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,
120 };