mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 23:28:55 +00:00
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>
This commit is contained in:
parent
2fb6b9b8e5
commit
191dd46905
1 changed files with 55 additions and 23 deletions
|
@ -312,31 +312,21 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
|
static int
|
||||||
const u8 *peer, u8 action_code, u8 dialog_token,
|
ieee80211_tdls_mgmt_setup(struct wiphy *wiphy, struct net_device *dev,
|
||||||
u16 status_code, u32 peer_capability,
|
const u8 *peer, u8 action_code, u8 dialog_token,
|
||||||
bool initiator, const u8 *extra_ies,
|
u16 status_code, u32 peer_capability, bool initiator,
|
||||||
size_t extra_ies_len)
|
const u8 *extra_ies, size_t extra_ies_len)
|
||||||
{
|
{
|
||||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||||
struct ieee80211_local *local = sdata->local;
|
struct ieee80211_local *local = sdata->local;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
|
|
||||||
return -ENOTSUPP;
|
|
||||||
|
|
||||||
/* make sure we are in managed mode, and associated */
|
|
||||||
if (sdata->vif.type != NL80211_IFTYPE_STATION ||
|
|
||||||
!sdata->u.mgd.associated)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
mutex_lock(&local->mtx);
|
mutex_lock(&local->mtx);
|
||||||
|
|
||||||
/* we don't support concurrent TDLS peer setups */
|
/* we don't support concurrent TDLS peer setups */
|
||||||
if (!is_zero_ether_addr(sdata->tdls_peer) &&
|
if (!is_zero_ether_addr(sdata->tdls_peer) &&
|
||||||
!ether_addr_equal(sdata->tdls_peer, peer) &&
|
!ether_addr_equal(sdata->tdls_peer, peer)) {
|
||||||
(action_code == WLAN_TDLS_SETUP_REQUEST ||
|
|
||||||
action_code == WLAN_TDLS_SETUP_RESPONSE)) {
|
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -348,16 +338,58 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
if (action_code == WLAN_TDLS_SETUP_REQUEST ||
|
memcpy(sdata->tdls_peer, peer, ETH_ALEN);
|
||||||
action_code == WLAN_TDLS_SETUP_RESPONSE) {
|
ieee80211_queue_delayed_work(&sdata->local->hw,
|
||||||
memcpy(sdata->tdls_peer, peer, ETH_ALEN);
|
&sdata->tdls_peer_del_work,
|
||||||
ieee80211_queue_delayed_work(&sdata->local->hw,
|
TDLS_PEER_SETUP_TIMEOUT);
|
||||||
&sdata->tdls_peer_del_work,
|
|
||||||
TDLS_PEER_SETUP_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mutex_unlock(&local->mtx);
|
mutex_unlock(&local->mtx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
|
||||||
|
const u8 *peer, u8 action_code, u8 dialog_token,
|
||||||
|
u16 status_code, u32 peer_capability,
|
||||||
|
bool initiator, const u8 *extra_ies,
|
||||||
|
size_t extra_ies_len)
|
||||||
|
{
|
||||||
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
|
/* make sure we are in managed mode, and associated */
|
||||||
|
if (sdata->vif.type != NL80211_IFTYPE_STATION ||
|
||||||
|
!sdata->u.mgd.associated)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
switch (action_code) {
|
||||||
|
case WLAN_TDLS_SETUP_REQUEST:
|
||||||
|
case WLAN_TDLS_SETUP_RESPONSE:
|
||||||
|
ret = ieee80211_tdls_mgmt_setup(wiphy, dev, peer, action_code,
|
||||||
|
dialog_token, status_code,
|
||||||
|
peer_capability, initiator,
|
||||||
|
extra_ies, extra_ies_len);
|
||||||
|
break;
|
||||||
|
case WLAN_TDLS_TEARDOWN:
|
||||||
|
case WLAN_TDLS_SETUP_CONFIRM:
|
||||||
|
case WLAN_TDLS_DISCOVERY_REQUEST:
|
||||||
|
case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
|
||||||
|
/* no special handling */
|
||||||
|
ret = ieee80211_tdls_prep_mgmt_packet(wiphy, dev, peer,
|
||||||
|
action_code,
|
||||||
|
dialog_token,
|
||||||
|
status_code,
|
||||||
|
peer_capability,
|
||||||
|
initiator, extra_ies,
|
||||||
|
extra_ies_len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = -EOPNOTSUPP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tdls_dbg(sdata, "TDLS mgmt action %d peer %pM status %d\n",
|
tdls_dbg(sdata, "TDLS mgmt action %d peer %pM status %d\n",
|
||||||
action_code, peer, ret);
|
action_code, peer, ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue