1 Subject: cfg80211/nl80211: add beacon settings
3 This adds the necessary API to cfg80211/nl80211 to allow
4 changing beaconing settings.
6 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
9 include/linux/nl80211.h | 24 ++++++++
10 include/net/cfg80211.h | 33 +++++++++++
11 net/wireless/nl80211.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++
12 3 files changed, 190 insertions(+)
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 {
21 + * struct beacon_parameters - beacon parameters
23 + * Used to configure the beacon for an interface.
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
34 +struct beacon_parameters {
36 + int interval, dtim_period;
37 + int head_len, tail_len;
40 /* from net/wireless.h */
43 @@ -103,6 +123,13 @@ struct wiphy;
46 * @set_default_key: set the default key on an interface
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
53 + * @del_beacon: Remove beacon configuration and stop sending the beacon.
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,
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);
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
73 * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
74 * or %NL80211_ATTR_MAC.
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
85 * @NL80211_CMD_MAX: highest used command number
86 * @__NL80211_CMD_AFTER_LAST: internal use
88 @@ -69,6 +78,11 @@ enum nl80211_commands {
92 + NL80211_CMD_GET_BEACON,
93 + NL80211_CMD_SET_BEACON,
94 + NL80211_CMD_NEW_BEACON,
95 + NL80211_CMD_DEL_BEACON,
97 /* add commands here */
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
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
109 * @NL80211_ATTR_MAX: highest attribute number currently defined
110 * @__NL80211_ATTR_AFTER_LAST: internal use
112 @@ -123,6 +142,11 @@ enum nl80211_attrs {
113 NL80211_ATTR_KEY_SEQ,
114 NL80211_ATTR_KEY_DEFAULT,
116 + NL80211_ATTR_BEACON_INTERVAL,
117 + NL80211_ATTR_DTIM_PERIOD,
118 + NL80211_ATTR_BEACON_HEAD,
119 + NL80211_ATTR_BEACON_TAIL,
121 /* add attributes here, update the policy in nl80211.c */
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 },
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 },
139 /* message building helper */
140 @@ -600,6 +607,114 @@ static int nl80211_del_key(struct sk_buf
144 +static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
146 + int (*call)(struct wiphy *wiphy, struct net_device *dev,
147 + struct beacon_parameters *info);
148 + struct cfg80211_registered_device *drv;
150 + struct net_device *dev;
151 + struct beacon_parameters params;
154 + err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
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]) {
168 + call = drv->ops->add_beacon;
170 + case NL80211_CMD_SET_BEACON:
171 + call = drv->ops->set_beacon;
184 + memset(¶ms, 0, sizeof(params));
186 + if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
188 + nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
192 + if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
193 + params.dtim_period =
194 + nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
198 + if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
199 + params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
201 + nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
205 + if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
206 + params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
208 + nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
218 + err = call(&drv->wiphy, dev, ¶ms);
222 + cfg80211_put_dev(drv);
227 +static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
229 + struct cfg80211_registered_device *drv;
231 + struct net_device *dev;
233 + err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
237 + if (!drv->ops->del_beacon) {
243 + err = drv->ops->del_beacon(&drv->wiphy, dev);
247 + cfg80211_put_dev(drv);
252 static struct genl_ops nl80211_ops[] = {
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,
260 + .cmd = NL80211_CMD_SET_BEACON,
261 + .policy = nl80211_policy,
262 + .flags = GENL_ADMIN_PERM,
263 + .doit = nl80211_addset_beacon,
266 + .cmd = NL80211_CMD_NEW_BEACON,
267 + .policy = nl80211_policy,
268 + .flags = GENL_ADMIN_PERM,
269 + .doit = nl80211_addset_beacon,
272 + .cmd = NL80211_CMD_DEL_BEACON,
273 + .policy = nl80211_policy,
274 + .flags = GENL_ADMIN_PERM,
275 + .doit = nl80211_del_beacon,
279 /* multicast groups */