aboutsummaryrefslogtreecommitdiffstats
path: root/ws80211_utils.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-07-08 01:43:14 +0000
committerGuy Harris <guy@alum.mit.edu>2012-07-08 01:43:14 +0000
commit4d84671f9bc24de7e1cef3c897f26834e05c9637 (patch)
tree64e46360464782c04e7ff1e833950683df2fccaa /ws80211_utils.c
parent8f12c9d7d7b90c246e5d3000e17a5b83a2c0f340 (diff)
downloadwireshark-4d84671f9bc24de7e1cef3c897f26834e05c9637.tar.gz
wireshark-4d84671f9bc24de7e1cef3c897f26834e05c9637.tar.bz2
wireshark-4d84671f9bc24de7e1cef3c897f26834e05c9637.zip
Keep the NL80211_CHAN_ and WS80211_CHAN_ values distinct; only the
Linux version of the platform-dependent 802.11 stuff should use the NL80211_CHAN_ stuff. Map from the WS80211_CHAN_ values to the corresponding NL80211_CHAN_ values in ws80211_set_freq(), and have the channel_types bitset use bits indexed by WS80211_CHAN_ values rather than NL80211_CHAN_. This won't fix the problem of building this on Linuxes with old nl80211.h headers that lack NL80211_CHAN_, but it narrows the set of code that needs the NL80211_CHAN_ values, perhaps allowing the fix to be a bit cleaner, as well as making it easier to make this work on platforms other than Linux. svn path=/trunk/; revision=43606
Diffstat (limited to 'ws80211_utils.c')
-rw-r--r--ws80211_utils.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/ws80211_utils.c b/ws80211_utils.c
index 3c7ea73d66..d3c167f480 100644
--- a/ws80211_utils.c
+++ b/ws80211_utils.c
@@ -47,6 +47,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <netlink/msg.h>
#include <netlink/attr.h>
+#include <linux/nl80211.h>
+
/* libnl 1.x compatibility code */
#ifdef HAVE_LIBNL1
#define nl_sock nl_handle
@@ -202,7 +204,7 @@ static int get_phys_handler(struct nl_msg *msg, void *arg)
return NL_SKIP;
iface->frequencies = g_array_new(FALSE, FALSE, sizeof(int));
- iface->channel_types = 1 << NL80211_CHAN_NO_HT;
+ iface->channel_types = 1 << WS80211_CHAN_NO_HT;
if (tb_msg[NL80211_ATTR_WIPHY_NAME]) {
char *phyname;
@@ -218,11 +220,11 @@ static int get_phys_handler(struct nl_msg *msg, void *arg)
if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) {
gboolean ht40;
- iface->channel_types |= 1 << NL80211_CHAN_HT20;
+ iface->channel_types |= 1 << WS80211_CHAN_HT20;
ht40 = !!(nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]) & 0x02);
if (ht40) {
- iface->channel_types |= 1 << NL80211_CHAN_HT40MINUS;
- iface->channel_types |= 1 << NL80211_CHAN_HT40PLUS;
+ iface->channel_types |= 1 << WS80211_CHAN_HT40MINUS;
+ iface->channel_types |= 1 << WS80211_CHAN_HT40PLUS;
}
}
@@ -540,9 +542,27 @@ int ws80211_set_freq(const char *name, int freq, int chan_type)
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devidx);
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
- if (chan_type != -1)
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, chan_type);
+ switch (chan_type) {
+
+ case WS80211_CHAN_NO_HT:
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_NO_HT);
+ break;
+
+ case WS80211_CHAN_HT20:
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT20);
+ break;
+
+ case WS80211_CHAN_HT40MINUS:
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT40MINUS);
+ break;
+ case WS80211_CHAN_HT40PLUS:
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT40PLUS);
+ break;
+
+ case -1:
+ break;
+ }
err = nl80211_do_cmd(msg, cb);
return err;