fix typo
[openwrt.git] / package / mac80211 / patches / 020-nl80211-beacon-parameters.patch
1 Subject: cfg80211/nl80211: add beacon settings
2
3 This adds the necessary API to cfg80211/nl80211 to allow
4 changing beaconing settings.
5
6 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
7
8 ---
9 include/linux/nl80211.h | 24 ++++++++
10 include/net/cfg80211.h | 33 +++++++++++
11 net/wireless/nl80211.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++
12 3 files changed, 190 insertions(+)
13
14 --- everything.orig/include/net/cfg80211.h 2007-11-08 11:50:57.412840007 +0100
15 +++ everything/include/net/cfg80211.h 2007-11-08 16:50:38.421522842 +0100
16 @@ -69,6 +69,26 @@ struct key_params {
17 u32 cipher;
18 };
19
20 +/**
21 + * struct beacon_parameters - beacon parameters
22 + *
23 + * Used to configure the beacon for an interface.
24 + *
25 + * @head: head portion of beacon (before TIM IE)
26 + * or %NULL if not changed
27 + * @tail: tail portion of beacon (after TIM IE)
28 + * or %NULL if not changed
29 + * @interval: beacon interval or zero if not changed
30 + * @dtim_period: DTIM period or zero if not changed
31 + * @head_len: length of @head
32 + * @tail_len: length of @tail
33 + */
34 +struct beacon_parameters {
35 + u8 *head, *tail;
36 + int interval, dtim_period;
37 + int head_len, tail_len;
38 +};
39 +
40 /* from net/wireless.h */
41 struct wiphy;
42
43 @@ -103,6 +123,13 @@ struct wiphy;
44 * and @key_index
45 *
46 * @set_default_key: set the default key on an interface
47 + *
48 + * @add_beacon: Add a beacon with given parameters, @head, @interval
49 + * and @dtim_period will be valid, @tail is optional.
50 + * @set_beacon: Change the beacon parameters for an access point mode
51 + * interface. This should reject the call when no beacon has been
52 + * configured.
53 + * @del_beacon: Remove beacon configuration and stop sending the beacon.
54 */
55 struct cfg80211_ops {
56 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
57 @@ -122,6 +149,12 @@ struct cfg80211_ops {
58 int (*set_default_key)(struct wiphy *wiphy,
59 struct net_device *netdev,
60 u8 key_index);
61 +
62 + int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
63 + struct beacon_parameters *info);
64 + int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
65 + struct beacon_parameters *info);
66 + int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
67 };
68
69 #endif /* __NET_CFG80211_H */
70 --- everything.orig/include/linux/nl80211.h 2007-11-08 11:50:57.362839952 +0100
71 +++ everything/include/linux/nl80211.h 2007-11-08 16:56:32.431522732 +0100
72 @@ -47,6 +47,15 @@
73 * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
74 * or %NL80211_ATTR_MAC.
75 *
76 + * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a
77 + * %NL80222_CMD_NEW_BEACON message)
78 + * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
79 + * using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
80 + * %NL80211_BEACON_HEAD and %NL80211_BEACON_TAIL attributes.
81 + * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
82 + * parameters are like for %NL80211_CMD_SET_BEACON.
83 + * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
84 + *
85 * @NL80211_CMD_MAX: highest used command number
86 * @__NL80211_CMD_AFTER_LAST: internal use
87 */
88 @@ -69,6 +78,11 @@ enum nl80211_commands {
89 NL80211_CMD_NEW_KEY,
90 NL80211_CMD_DEL_KEY,
91
92 + NL80211_CMD_GET_BEACON,
93 + NL80211_CMD_SET_BEACON,
94 + NL80211_CMD_NEW_BEACON,
95 + NL80211_CMD_DEL_BEACON,
96 +
97 /* add commands here */
98
99 /* used to define NL80211_CMD_MAX below */
100 @@ -101,6 +115,11 @@ enum nl80211_commands {
101 * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
102 * CCMP keys, each six bytes in little endian
103 *
104 + * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
105 + * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
106 + * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
107 + * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
108 + *
109 * @NL80211_ATTR_MAX: highest attribute number currently defined
110 * @__NL80211_ATTR_AFTER_LAST: internal use
111 */
112 @@ -123,6 +142,11 @@ enum nl80211_attrs {
113 NL80211_ATTR_KEY_SEQ,
114 NL80211_ATTR_KEY_DEFAULT,
115
116 + NL80211_ATTR_BEACON_INTERVAL,
117 + NL80211_ATTR_DTIM_PERIOD,
118 + NL80211_ATTR_BEACON_HEAD,
119 + NL80211_ATTR_BEACON_TAIL,
120 +
121 /* add attributes here, update the policy in nl80211.c */
122
123 __NL80211_ATTR_AFTER_LAST,
124 --- everything.orig/net/wireless/nl80211.c 2007-11-08 11:50:57.382836589 +0100
125 +++ everything/net/wireless/nl80211.c 2007-11-08 16:58:36.711524524 +0100
126 @@ -69,6 +69,13 @@ static struct nla_policy nl80211_policy[
127 [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
128 [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
129 [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG },
130 +
131 + [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 },
132 + [NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
133 + [NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY,
134 + .len = IEEE80211_MAX_DATA_LEN },
135 + [NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
136 + .len = IEEE80211_MAX_DATA_LEN },
137 };
138
139 /* message building helper */
140 @@ -600,6 +607,114 @@ static int nl80211_del_key(struct sk_buf
141 return err;
142 }
143
144 +static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
145 +{
146 + int (*call)(struct wiphy *wiphy, struct net_device *dev,
147 + struct beacon_parameters *info);
148 + struct cfg80211_registered_device *drv;
149 + int err;
150 + struct net_device *dev;
151 + struct beacon_parameters params;
152 + int haveinfo = 0;
153 +
154 + err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
155 + if (err)
156 + return err;
157 +
158 + switch (info->genlhdr->cmd) {
159 + case NL80211_CMD_NEW_BEACON:
160 + /* these are required for NEW_BEACON */
161 + if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
162 + !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
163 + !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
164 + err = -EINVAL;
165 + goto out;
166 + }
167 +
168 + call = drv->ops->add_beacon;
169 + break;
170 + case NL80211_CMD_SET_BEACON:
171 + call = drv->ops->set_beacon;
172 + break;
173 + default:
174 + WARN_ON(1);
175 + err = -EOPNOTSUPP;
176 + goto out;
177 + }
178 +
179 + if (!call) {
180 + err = -EOPNOTSUPP;
181 + goto out;
182 + }
183 +
184 + memset(&params, 0, sizeof(params));
185 +
186 + if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
187 + params.interval =
188 + nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
189 + haveinfo = 1;
190 + }
191 +
192 + if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
193 + params.dtim_period =
194 + nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
195 + haveinfo = 1;
196 + }
197 +
198 + if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
199 + params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
200 + params.head_len =
201 + nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
202 + haveinfo = 1;
203 + }
204 +
205 + if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
206 + params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
207 + params.tail_len =
208 + nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
209 + haveinfo = 1;
210 + }
211 +
212 + if (!haveinfo) {
213 + err = -EINVAL;
214 + goto out;
215 + }
216 +
217 + rtnl_lock();
218 + err = call(&drv->wiphy, dev, &params);
219 + rtnl_unlock();
220 +
221 + out:
222 + cfg80211_put_dev(drv);
223 + dev_put(dev);
224 + return err;
225 +}
226 +
227 +static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
228 +{
229 + struct cfg80211_registered_device *drv;
230 + int err;
231 + struct net_device *dev;
232 +
233 + err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
234 + if (err)
235 + return err;
236 +
237 + if (!drv->ops->del_beacon) {
238 + err = -EOPNOTSUPP;
239 + goto out;
240 + }
241 +
242 + rtnl_lock();
243 + err = drv->ops->del_beacon(&drv->wiphy, dev);
244 + rtnl_unlock();
245 +
246 + out:
247 + cfg80211_put_dev(drv);
248 + dev_put(dev);
249 + return err;
250 +}
251 +
252 static struct genl_ops nl80211_ops[] = {
253 {
254 .cmd = NL80211_CMD_GET_WIPHY,
255 @@ -663,6 +778,24 @@ static struct genl_ops nl80211_ops[] = {
256 .policy = nl80211_policy,
257 .flags = GENL_ADMIN_PERM,
258 },
259 + {
260 + .cmd = NL80211_CMD_SET_BEACON,
261 + .policy = nl80211_policy,
262 + .flags = GENL_ADMIN_PERM,
263 + .doit = nl80211_addset_beacon,
264 + },
265 + {
266 + .cmd = NL80211_CMD_NEW_BEACON,
267 + .policy = nl80211_policy,
268 + .flags = GENL_ADMIN_PERM,
269 + .doit = nl80211_addset_beacon,
270 + },
271 + {
272 + .cmd = NL80211_CMD_DEL_BEACON,
273 + .policy = nl80211_policy,
274 + .flags = GENL_ADMIN_PERM,
275 + .doit = nl80211_del_beacon,
276 + },
277 };
278
279 /* multicast groups */
This page took 0.056395 seconds and 5 git commands to generate.