aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/chan.c
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2012-06-29 06:47:00 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-06-29 07:39:16 -0400
commit26ab9a0c589db9ba2710f042c4959da25fd3297b (patch)
tree4c8c1df8f9dd67b1556f0f4271f948126b0b8eaa /net/wireless/chan.c
parentc30a3d38689bc601e03d5f2ad3c37d8ea13e46ca (diff)
cfg80211: introduce cfg80211_get_chan_state
Helper function for finding out which channel is used by a given interface. An exclusive channel can be used only by a single interface. This is mainly for non-fixed channel IBSS handling. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/chan.c')
-rw-r--r--net/wireless/chan.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index c1999e45a07c..167e7cb60089 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -92,3 +92,54 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
92 92
93 return rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype); 93 return rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype);
94} 94}
95
96void
97cfg80211_get_chan_state(struct cfg80211_registered_device *rdev,
98 struct wireless_dev *wdev,
99 struct ieee80211_channel **chan,
100 enum cfg80211_chan_mode *chanmode)
101{
102 *chan = NULL;
103 *chanmode = CHAN_MODE_UNDEFINED;
104
105 ASSERT_RDEV_LOCK(rdev);
106 ASSERT_WDEV_LOCK(wdev);
107
108 if (!netif_running(wdev->netdev))
109 return;
110
111 switch (wdev->iftype) {
112 case NL80211_IFTYPE_ADHOC:
113 if (wdev->current_bss) {
114 *chan = wdev->current_bss->pub.channel;
115 *chanmode = wdev->ibss_fixed
116 ? CHAN_MODE_SHARED
117 : CHAN_MODE_EXCLUSIVE;
118 return;
119 }
120 case NL80211_IFTYPE_STATION:
121 case NL80211_IFTYPE_P2P_CLIENT:
122 if (wdev->current_bss) {
123 *chan = wdev->current_bss->pub.channel;
124 *chanmode = CHAN_MODE_SHARED;
125 return;
126 }
127 break;
128 case NL80211_IFTYPE_AP:
129 case NL80211_IFTYPE_P2P_GO:
130 case NL80211_IFTYPE_MESH_POINT:
131 *chan = wdev->channel;
132 *chanmode = CHAN_MODE_SHARED;
133 return;
134 case NL80211_IFTYPE_MONITOR:
135 case NL80211_IFTYPE_AP_VLAN:
136 case NL80211_IFTYPE_WDS:
137 /* these interface types don't really have a channel */
138 return;
139 case NL80211_IFTYPE_UNSPECIFIED:
140 case NUM_NL80211_IFTYPES:
141 WARN_ON(1);
142 }
143
144 return;
145}