aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArik Nemtsov <arik@wizery.com>2014-06-11 10:18:23 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-06-23 08:24:55 -0400
commit191dd46905ce9a25174dd9eea4ff3029802ac37c (patch)
treefb65cdbe536e8f17f21b3c4ad545494229c9ba5f /net
parent2fb6b9b8e5f08df31bc4081b4d9f38701c59cfd3 (diff)
mac80211: split tdls_mgmt function
There are setup/teardown specific actions to be done that accompany the sending of a TDLS management packet. Split the main function to simplify future additions. Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/tdls.c78
1 files changed, 55 insertions, 23 deletions
diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
index c4a9af3b75e5..92d203a3be07 100644
--- a/net/mac80211/tdls.c
+++ b/net/mac80211/tdls.c
@@ -312,31 +312,21 @@ fail:
312 return ret; 312 return ret;
313} 313}
314 314
315int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 315static int
316 const u8 *peer, u8 action_code, u8 dialog_token, 316ieee80211_tdls_mgmt_setup(struct wiphy *wiphy, struct net_device *dev,
317 u16 status_code, u32 peer_capability, 317 const u8 *peer, u8 action_code, u8 dialog_token,
318 bool initiator, const u8 *extra_ies, 318 u16 status_code, u32 peer_capability, bool initiator,
319 size_t extra_ies_len) 319 const u8 *extra_ies, size_t extra_ies_len)
320{ 320{
321 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 321 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
322 struct ieee80211_local *local = sdata->local; 322 struct ieee80211_local *local = sdata->local;
323 int ret; 323 int ret;
324 324
325 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
326 return -ENOTSUPP;
327
328 /* make sure we are in managed mode, and associated */
329 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
330 !sdata->u.mgd.associated)
331 return -EINVAL;
332
333 mutex_lock(&local->mtx); 325 mutex_lock(&local->mtx);
334 326
335 /* we don't support concurrent TDLS peer setups */ 327 /* we don't support concurrent TDLS peer setups */
336 if (!is_zero_ether_addr(sdata->tdls_peer) && 328 if (!is_zero_ether_addr(sdata->tdls_peer) &&
337 !ether_addr_equal(sdata->tdls_peer, peer) && 329 !ether_addr_equal(sdata->tdls_peer, peer)) {
338 (action_code == WLAN_TDLS_SETUP_REQUEST ||
339 action_code == WLAN_TDLS_SETUP_RESPONSE)) {
340 ret = -EBUSY; 330 ret = -EBUSY;
341 goto exit; 331 goto exit;
342 } 332 }
@@ -348,16 +338,58 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
348 if (ret < 0) 338 if (ret < 0)
349 goto exit; 339 goto exit;
350 340
351 if (action_code == WLAN_TDLS_SETUP_REQUEST || 341 memcpy(sdata->tdls_peer, peer, ETH_ALEN);
352 action_code == WLAN_TDLS_SETUP_RESPONSE) { 342 ieee80211_queue_delayed_work(&sdata->local->hw,
353 memcpy(sdata->tdls_peer, peer, ETH_ALEN); 343 &sdata->tdls_peer_del_work,
354 ieee80211_queue_delayed_work(&sdata->local->hw, 344 TDLS_PEER_SETUP_TIMEOUT);
355 &sdata->tdls_peer_del_work,
356 TDLS_PEER_SETUP_TIMEOUT);
357 }
358 345
359exit: 346exit:
360 mutex_unlock(&local->mtx); 347 mutex_unlock(&local->mtx);
348 return ret;
349}
350
351int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
352 const u8 *peer, u8 action_code, u8 dialog_token,
353 u16 status_code, u32 peer_capability,
354 bool initiator, const u8 *extra_ies,
355 size_t extra_ies_len)
356{
357 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
358 int ret;
359
360 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
361 return -ENOTSUPP;
362
363 /* make sure we are in managed mode, and associated */
364 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
365 !sdata->u.mgd.associated)
366 return -EINVAL;
367
368 switch (action_code) {
369 case WLAN_TDLS_SETUP_REQUEST:
370 case WLAN_TDLS_SETUP_RESPONSE:
371 ret = ieee80211_tdls_mgmt_setup(wiphy, dev, peer, action_code,
372 dialog_token, status_code,
373 peer_capability, initiator,
374 extra_ies, extra_ies_len);
375 break;
376 case WLAN_TDLS_TEARDOWN:
377 case WLAN_TDLS_SETUP_CONFIRM:
378 case WLAN_TDLS_DISCOVERY_REQUEST:
379 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
380 /* no special handling */
381 ret = ieee80211_tdls_prep_mgmt_packet(wiphy, dev, peer,
382 action_code,
383 dialog_token,
384 status_code,
385 peer_capability,
386 initiator, extra_ies,
387 extra_ies_len);
388 break;
389 default:
390 ret = -EOPNOTSUPP;
391 break;
392 }
361 393
362 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM status %d\n", 394 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM status %d\n",
363 action_code, peer, ret); 395 action_code, peer, ret);