[PATCH 2/6] driver_nl80211: use new frame registration API

Johannes Berg johannes
Thu Sep 16 06:03:12 PDT 2010


From: Johannes Berg <johannes.berg at intel.com>

This is backward compatible since older kernels
will ignore the extra attribute and only allow
registration for action frames.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/drivers/driver_nl80211.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index b884acc..75ccfab 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -802,10 +802,10 @@ static void mlme_event(struct wpa_driver_nl80211_data *drv,
 		mlme_event_deauth_disassoc(drv, EVENT_DISASSOC,
 					   nla_data(frame), nla_len(frame));
 		break;
-	case NL80211_CMD_ACTION:
+	case NL80211_CMD_FRAME:
 		mlme_event_action(drv, freq, nla_data(frame), nla_len(frame));
 		break;
-	case NL80211_CMD_ACTION_TX_STATUS:
+	case NL80211_CMD_FRAME_TX_STATUS:
 		mlme_event_action_tx_status(drv, cookie, nla_data(frame),
 					    nla_len(frame), ack);
 		break;
@@ -1103,8 +1103,8 @@ static int process_event(struct nl_msg *msg, void *arg)
 	case NL80211_CMD_ASSOCIATE:
 	case NL80211_CMD_DEAUTHENTICATE:
 	case NL80211_CMD_DISASSOCIATE:
-	case NL80211_CMD_ACTION:
-	case NL80211_CMD_ACTION_TX_STATUS:
+	case NL80211_CMD_FRAME:
+	case NL80211_CMD_FRAME_TX_STATUS:
 		mlme_event(drv, gnlh->cmd, tb[NL80211_ATTR_FRAME],
 			   tb[NL80211_ATTR_MAC], tb[NL80211_ATTR_TIMED_OUT],
 			   tb[NL80211_ATTR_WIPHY_FREQ], tb[NL80211_ATTR_ACK],
@@ -1549,8 +1549,8 @@ failed:
 }
 
 
-static int nl80211_register_action_frame(struct wpa_driver_nl80211_data *drv,
-					 const u8 *match, size_t match_len)
+static int nl80211_register_frame(struct wpa_driver_nl80211_data *drv,
+				  u16 type, const u8 *match, size_t match_len)
 {
 	struct nl_msg *msg;
 	int ret = -1;
@@ -1563,6 +1563,7 @@ static int nl80211_register_action_frame(struct wpa_driver_nl80211_data *drv,
 		    NL80211_CMD_REGISTER_ACTION, 0);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+	NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, type);
 	NLA_PUT(msg, NL80211_ATTR_FRAME_MATCH, match_len, match);
 
 	ret = send_and_recv(drv, drv->nl_handle_event, msg, NULL, NULL);
@@ -1580,6 +1581,12 @@ nla_put_failure:
 	return ret;
 }
 
+static int nl80211_register_action_frame(struct wpa_driver_nl80211_data *drv,
+					 const u8 *match, size_t match_len)
+{
+	u16 type = (WLAN_FC_TYPE_MGMT << 2) | (WLAN_FC_STYPE_ACTION << 4);
+	return nl80211_register_frame(drv, type, match, match_len);
+}
 
 static int nl80211_register_action_frames(struct wpa_driver_nl80211_data *drv)
 {
@@ -5184,7 +5191,7 @@ static int wpa_driver_nl80211_send_action(void *priv, unsigned int freq,
 	}
 
 	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
-		    NL80211_CMD_ACTION, 0);
+		    NL80211_CMD_FRAME, 0);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
 	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
-- 
1.7.1




More information about the Hostap mailing list