Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * mac80211 - channel management |
| 3 | */ |
| 4 | |
| 5 | #include "ieee80211_i.h" |
| 6 | |
| 7 | enum ieee80211_chan_mode |
| 8 | __ieee80211_get_channel_mode(struct ieee80211_local *local, |
| 9 | struct ieee80211_sub_if_data *ignore) |
| 10 | { |
| 11 | struct ieee80211_sub_if_data *sdata; |
| 12 | |
| 13 | WARN_ON(!mutex_is_locked(&local->iflist_mtx)); |
| 14 | |
| 15 | list_for_each_entry(sdata, &local->interfaces, list) { |
| 16 | if (sdata == ignore) |
| 17 | continue; |
| 18 | |
| 19 | if (!ieee80211_sdata_running(sdata)) |
| 20 | continue; |
| 21 | |
| 22 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR) |
| 23 | continue; |
| 24 | |
| 25 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
| 26 | !sdata->u.mgd.associated) |
| 27 | continue; |
| 28 | |
| 29 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
| 30 | if (!sdata->u.ibss.ssid_len) |
| 31 | continue; |
| 32 | if (!sdata->u.ibss.fixed_channel) |
| 33 | return CHAN_MODE_HOPPING; |
| 34 | } |
| 35 | |
| 36 | if (sdata->vif.type == NL80211_IFTYPE_AP && |
| 37 | !sdata->u.ap.beacon) |
| 38 | continue; |
| 39 | |
| 40 | return CHAN_MODE_FIXED; |
| 41 | } |
| 42 | |
| 43 | return CHAN_MODE_UNDEFINED; |
| 44 | } |
| 45 | |
| 46 | enum ieee80211_chan_mode |
| 47 | ieee80211_get_channel_mode(struct ieee80211_local *local, |
| 48 | struct ieee80211_sub_if_data *ignore) |
| 49 | { |
| 50 | enum ieee80211_chan_mode mode; |
| 51 | |
| 52 | mutex_lock(&local->iflist_mtx); |
| 53 | mode = __ieee80211_get_channel_mode(local, ignore); |
| 54 | mutex_unlock(&local->iflist_mtx); |
| 55 | |
| 56 | return mode; |
| 57 | } |