aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-08-12 09:38:38 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-24 16:27:56 -0400
commit2e161f78e5f63a7f9fd25a766bb7f816a01eb14a (patch)
treebefd44feeb1f47da1f41e6fc310a223ad67030ff /include
parentac4c977d16d843f12901595c91773dddb65768a9 (diff)
cfg80211/mac80211: extensible frame processing
Allow userspace to register for more than just action frames by giving the frame subtype, and make it possible to use this in various modes as well. With some tweaks and some added functionality this will, in the future, also be usable in AP mode and be able to replace the cooked monitor interface currently used in that case. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/nl80211.h93
-rw-r--r--include/net/cfg80211.h56
2 files changed, 108 insertions, 41 deletions
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 2c8701687336..8af1e66c3cf9 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -40,6 +40,43 @@
40 */ 40 */
41 41
42/** 42/**
43 * DOC: Frame transmission/registration support
44 *
45 * Frame transmission and registration support exists to allow userspace
46 * management entities such as wpa_supplicant react to management frames
47 * that are not being handled by the kernel. This includes, for example,
48 * certain classes of action frames that cannot be handled in the kernel
49 * for various reasons.
50 *
51 * Frame registration is done on a per-interface basis and registrations
52 * cannot be removed other than by closing the socket. It is possible to
53 * specify a registration filter to register, for example, only for a
54 * certain type of action frame. In particular with action frames, those
55 * that userspace registers for will not be returned as unhandled by the
56 * driver, so that the registered application has to take responsibility
57 * for doing that.
58 *
59 * The type of frame that can be registered for is also dependent on the
60 * driver and interface type. The frame types are advertised in wiphy
61 * attributes so applications know what to expect.
62 *
63 * NOTE: When an interface changes type while registrations are active,
64 * these registrations are ignored until the interface type is
65 * changed again. This means that changing the interface type can
66 * lead to a situation that couldn't otherwise be produced, but
67 * any such registrations will be dormant in the sense that they
68 * will not be serviced, i.e. they will not receive any frames.
69 *
70 * Frame transmission allows userspace to send for example the required
71 * responses to action frames. It is subject to some sanity checking,
72 * but many frames can be transmitted. When a frame was transmitted, its
73 * status is indicated to the sending socket.
74 *
75 * For more technical details, see the corresponding command descriptions
76 * below.
77 */
78
79/**
43 * enum nl80211_commands - supported nl80211 commands 80 * enum nl80211_commands - supported nl80211 commands
44 * 81 *
45 * @NL80211_CMD_UNSPEC: unspecified command to catch errors 82 * @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -301,16 +338,18 @@
301 * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface 338 * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
302 * and @NL80211_ATTR_TX_RATES the set of allowed rates. 339 * and @NL80211_ATTR_TX_RATES the set of allowed rates.
303 * 340 *
304 * @NL80211_CMD_REGISTER_ACTION: Register for receiving certain action frames 341 * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
305 * (via @NL80211_CMD_ACTION) for processing in userspace. This command 342 * (via @NL80211_CMD_FRAME) for processing in userspace. This command
306 * requires an interface index and a match attribute containing the first 343 * requires an interface index, a frame type attribute (optional for
307 * few bytes of the frame that should match, e.g. a single byte for only 344 * backward compatibility reasons, if not given assumes action frames)
308 * a category match or four bytes for vendor frames including the OUI. 345 * and a match attribute containing the first few bytes of the frame
309 * The registration cannot be dropped, but is removed automatically 346 * that should match, e.g. a single byte for only a category match or
310 * when the netlink socket is closed. Multiple registrations can be made. 347 * four bytes for vendor frames including the OUI. The registration
311 * @NL80211_CMD_ACTION: Action frame TX request and RX notification. This 348 * cannot be dropped, but is removed automatically when the netlink
312 * command is used both as a request to transmit an Action frame and as an 349 * socket is closed. Multiple registrations can be made.
313 * event indicating reception of an Action frame that was not processed in 350 * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
351 * command is used both as a request to transmit a management frame and
352 * as an event indicating reception of a frame that was not processed in
314 * kernel code, but is for us (i.e., which may need to be processed in a 353 * kernel code, but is for us (i.e., which may need to be processed in a
315 * user space application). %NL80211_ATTR_FRAME is used to specify the 354 * user space application). %NL80211_ATTR_FRAME is used to specify the
316 * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and 355 * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
@@ -320,8 +359,8 @@
320 * operational channel). When called, this operation returns a cookie 359 * operational channel). When called, this operation returns a cookie
321 * (%NL80211_ATTR_COOKIE) that will be included with the TX status event 360 * (%NL80211_ATTR_COOKIE) that will be included with the TX status event
322 * pertaining to the TX request. 361 * pertaining to the TX request.
323 * @NL80211_CMD_ACTION_TX_STATUS: Report TX status of an Action frame 362 * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
324 * transmitted with %NL80211_CMD_ACTION. %NL80211_ATTR_COOKIE identifies 363 * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
325 * the TX command and %NL80211_ATTR_FRAME includes the contents of the 364 * the TX command and %NL80211_ATTR_FRAME includes the contents of the
326 * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged 365 * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
327 * the frame. 366 * the frame.
@@ -429,9 +468,12 @@ enum nl80211_commands {
429 468
430 NL80211_CMD_SET_TX_BITRATE_MASK, 469 NL80211_CMD_SET_TX_BITRATE_MASK,
431 470
432 NL80211_CMD_REGISTER_ACTION, 471 NL80211_CMD_REGISTER_FRAME,
433 NL80211_CMD_ACTION, 472 NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
434 NL80211_CMD_ACTION_TX_STATUS, 473 NL80211_CMD_FRAME,
474 NL80211_CMD_ACTION = NL80211_CMD_FRAME,
475 NL80211_CMD_FRAME_TX_STATUS,
476 NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
435 477
436 NL80211_CMD_SET_POWER_SAVE, 478 NL80211_CMD_SET_POWER_SAVE,
437 NL80211_CMD_GET_POWER_SAVE, 479 NL80211_CMD_GET_POWER_SAVE,
@@ -708,7 +750,16 @@ enum nl80211_commands {
708 * is used with %NL80211_CMD_SET_TX_BITRATE_MASK. 750 * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
709 * 751 *
710 * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain 752 * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
711 * at least one byte, currently used with @NL80211_CMD_REGISTER_ACTION. 753 * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
754 * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
755 * @NL80211_CMD_REGISTER_FRAME command.
756 * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
757 * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
758 * information about which frame types can be transmitted with
759 * %NL80211_CMD_FRAME.
760 * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
761 * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
762 * information about which frame types can be registered for RX.
712 * 763 *
713 * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was 764 * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
714 * acknowledged by the recipient. 765 * acknowledged by the recipient.
@@ -891,6 +942,10 @@ enum nl80211_attrs {
891 NL80211_ATTR_WIPHY_TX_POWER_SETTING, 942 NL80211_ATTR_WIPHY_TX_POWER_SETTING,
892 NL80211_ATTR_WIPHY_TX_POWER_LEVEL, 943 NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
893 944
945 NL80211_ATTR_TX_FRAME_TYPES,
946 NL80211_ATTR_RX_FRAME_TYPES,
947 NL80211_ATTR_FRAME_TYPE,
948
894 /* add attributes here, update the policy in nl80211.c */ 949 /* add attributes here, update the policy in nl80211.c */
895 950
896 __NL80211_ATTR_AFTER_LAST, 951 __NL80211_ATTR_AFTER_LAST,
@@ -947,7 +1002,7 @@ enum nl80211_attrs {
947 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames 1002 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
948 * @NL80211_IFTYPE_MESH_POINT: mesh point 1003 * @NL80211_IFTYPE_MESH_POINT: mesh point
949 * @NL80211_IFTYPE_MAX: highest interface type number currently defined 1004 * @NL80211_IFTYPE_MAX: highest interface type number currently defined
950 * @__NL80211_IFTYPE_AFTER_LAST: internal use 1005 * @NUM_NL80211_IFTYPES: number of defined interface types
951 * 1006 *
952 * These values are used with the %NL80211_ATTR_IFTYPE 1007 * These values are used with the %NL80211_ATTR_IFTYPE
953 * to set the type of an interface. 1008 * to set the type of an interface.
@@ -964,8 +1019,8 @@ enum nl80211_iftype {
964 NL80211_IFTYPE_MESH_POINT, 1019 NL80211_IFTYPE_MESH_POINT,
965 1020
966 /* keep last */ 1021 /* keep last */
967 __NL80211_IFTYPE_AFTER_LAST, 1022 NUM_NL80211_IFTYPES,
968 NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1 1023 NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
969}; 1024};
970 1025
971/** 1026/**
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2b403c7ee32e..6a98b1b3bfde 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1020,7 +1020,7 @@ struct cfg80211_pmksa {
1020 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation. 1020 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
1021 * This allows the operation to be terminated prior to timeout based on 1021 * This allows the operation to be terminated prior to timeout based on
1022 * the duration value. 1022 * the duration value.
1023 * @action: Transmit an action frame 1023 * @mgmt_tx: Transmit a management frame
1024 * 1024 *
1025 * @testmode_cmd: run a test mode command 1025 * @testmode_cmd: run a test mode command
1026 * 1026 *
@@ -1172,7 +1172,7 @@ struct cfg80211_ops {
1172 struct net_device *dev, 1172 struct net_device *dev,
1173 u64 cookie); 1173 u64 cookie);
1174 1174
1175 int (*action)(struct wiphy *wiphy, struct net_device *dev, 1175 int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev,
1176 struct ieee80211_channel *chan, 1176 struct ieee80211_channel *chan,
1177 enum nl80211_channel_type channel_type, 1177 enum nl80211_channel_type channel_type,
1178 bool channel_type_valid, 1178 bool channel_type_valid,
@@ -1236,6 +1236,10 @@ struct mac_address {
1236 u8 addr[ETH_ALEN]; 1236 u8 addr[ETH_ALEN];
1237}; 1237};
1238 1238
1239struct ieee80211_txrx_stypes {
1240 u16 tx, rx;
1241};
1242
1239/** 1243/**
1240 * struct wiphy - wireless hardware description 1244 * struct wiphy - wireless hardware description
1241 * @reg_notifier: the driver's regulatory notification callback 1245 * @reg_notifier: the driver's regulatory notification callback
@@ -1286,6 +1290,10 @@ struct mac_address {
1286 * @privid: a pointer that drivers can use to identify if an arbitrary 1290 * @privid: a pointer that drivers can use to identify if an arbitrary
1287 * wiphy is theirs, e.g. in global notifiers 1291 * wiphy is theirs, e.g. in global notifiers
1288 * @bands: information about bands/channels supported by this device 1292 * @bands: information about bands/channels supported by this device
1293 *
1294 * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
1295 * transmitted through nl80211, points to an array indexed by interface
1296 * type
1289 */ 1297 */
1290struct wiphy { 1298struct wiphy {
1291 /* assign these fields before you register the wiphy */ 1299 /* assign these fields before you register the wiphy */
@@ -1294,9 +1302,12 @@ struct wiphy {
1294 u8 perm_addr[ETH_ALEN]; 1302 u8 perm_addr[ETH_ALEN];
1295 u8 addr_mask[ETH_ALEN]; 1303 u8 addr_mask[ETH_ALEN];
1296 1304
1297 u16 n_addresses;
1298 struct mac_address *addresses; 1305 struct mac_address *addresses;
1299 1306
1307 const struct ieee80211_txrx_stypes *mgmt_stypes;
1308
1309 u16 n_addresses;
1310
1300 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ 1311 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
1301 u16 interface_modes; 1312 u16 interface_modes;
1302 1313
@@ -1492,8 +1503,8 @@ struct cfg80211_cached_keys;
1492 * set by driver (if supported) on add_interface BEFORE registering the 1503 * set by driver (if supported) on add_interface BEFORE registering the
1493 * netdev and may otherwise be used by driver read-only, will be update 1504 * netdev and may otherwise be used by driver read-only, will be update
1494 * by cfg80211 on change_interface 1505 * by cfg80211 on change_interface
1495 * @action_registrations: list of registrations for action frames 1506 * @mgmt_registrations: list of registrations for management frames
1496 * @action_registrations_lock: lock for the list 1507 * @mgmt_registrations_lock: lock for the list
1497 * @mtx: mutex used to lock data in this struct 1508 * @mtx: mutex used to lock data in this struct
1498 * @cleanup_work: work struct used for cleanup that can't be done directly 1509 * @cleanup_work: work struct used for cleanup that can't be done directly
1499 */ 1510 */
@@ -1505,8 +1516,8 @@ struct wireless_dev {
1505 struct list_head list; 1516 struct list_head list;
1506 struct net_device *netdev; 1517 struct net_device *netdev;
1507 1518
1508 struct list_head action_registrations; 1519 struct list_head mgmt_registrations;
1509 spinlock_t action_registrations_lock; 1520 spinlock_t mgmt_registrations_lock;
1510 1521
1511 struct mutex mtx; 1522 struct mutex mtx;
1512 1523
@@ -2373,38 +2384,39 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
2373 struct station_info *sinfo, gfp_t gfp); 2384 struct station_info *sinfo, gfp_t gfp);
2374 2385
2375/** 2386/**
2376 * cfg80211_rx_action - notification of received, unprocessed Action frame 2387 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
2377 * @dev: network device 2388 * @dev: network device
2378 * @freq: Frequency on which the frame was received in MHz 2389 * @freq: Frequency on which the frame was received in MHz
2379 * @buf: Action frame (header + body) 2390 * @buf: Management frame (header + body)
2380 * @len: length of the frame data 2391 * @len: length of the frame data
2381 * @gfp: context flags 2392 * @gfp: context flags
2382 * Returns %true if a user space application is responsible for rejecting the 2393 *
2383 * unrecognized Action frame; %false if no such application is registered 2394 * Returns %true if a user space application has registered for this frame.
2384 * (i.e., the driver is responsible for rejecting the unrecognized Action 2395 * For action frames, that makes it responsible for rejecting unrecognized
2385 * frame) 2396 * action frames; %false otherwise, in which case for action frames the
2397 * driver is responsible for rejecting the frame.
2386 * 2398 *
2387 * This function is called whenever an Action frame is received for a station 2399 * This function is called whenever an Action frame is received for a station
2388 * mode interface, but is not processed in kernel. 2400 * mode interface, but is not processed in kernel.
2389 */ 2401 */
2390bool cfg80211_rx_action(struct net_device *dev, int freq, const u8 *buf, 2402bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
2391 size_t len, gfp_t gfp); 2403 size_t len, gfp_t gfp);
2392 2404
2393/** 2405/**
2394 * cfg80211_action_tx_status - notification of TX status for Action frame 2406 * cfg80211_mgmt_tx_status - notification of TX status for management frame
2395 * @dev: network device 2407 * @dev: network device
2396 * @cookie: Cookie returned by cfg80211_ops::action() 2408 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
2397 * @buf: Action frame (header + body) 2409 * @buf: Management frame (header + body)
2398 * @len: length of the frame data 2410 * @len: length of the frame data
2399 * @ack: Whether frame was acknowledged 2411 * @ack: Whether frame was acknowledged
2400 * @gfp: context flags 2412 * @gfp: context flags
2401 * 2413 *
2402 * This function is called whenever an Action frame was requested to be 2414 * This function is called whenever a management frame was requested to be
2403 * transmitted with cfg80211_ops::action() to report the TX status of the 2415 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
2404 * transmission attempt. 2416 * transmission attempt.
2405 */ 2417 */
2406void cfg80211_action_tx_status(struct net_device *dev, u64 cookie, 2418void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie,
2407 const u8 *buf, size_t len, bool ack, gfp_t gfp); 2419 const u8 *buf, size_t len, bool ack, gfp_t gfp);
2408 2420
2409 2421
2410/** 2422/**