aboutsummaryrefslogtreecommitdiffstats
path: root/package/iwinfo/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-07-06 09:30:50 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-07-06 09:30:50 +0000
commitc18c485f382bd21403b84c3ad2dce2c9e6ab1fd9 (patch)
tree7ce0a9d3d15f0823ce46b40da52839622597bfad /package/iwinfo/src
parentb2ced753ee77f102535687b9340adaf93772bb34 (diff)
downloadupstream-c18c485f382bd21403b84c3ad2dce2c9e6ab1fd9.tar.gz
upstream-c18c485f382bd21403b84c3ad2dce2c9e6ab1fd9.tar.bz2
upstream-c18c485f382bd21403b84c3ad2dce2c9e6ab1fd9.zip
[package] iwinfo: properly deal with channels 7..12 on 5GHz
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32634 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/iwinfo/src')
-rw-r--r--package/iwinfo/src/iwinfo_nl80211.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/package/iwinfo/src/iwinfo_nl80211.c b/package/iwinfo/src/iwinfo_nl80211.c
index 7595ea838c..304a18b3ec 100644
--- a/package/iwinfo/src/iwinfo_nl80211.c
+++ b/package/iwinfo/src/iwinfo_nl80211.c
@@ -351,15 +351,18 @@ static int nl80211_freq2channel(int freq)
return (freq / 5) - 1000;
}
-static int nl80211_channel2freq(int channel)
+static int nl80211_channel2freq(int channel, const char *band)
{
if (channel == 14)
return 2484;
- if (channel < 14)
+ if ((channel < 14) && (!band || band[0] != 'a'))
return (channel * 5) + 2407;
- return (1000 + channel) * 5;
+ if (channel > 0)
+ return (1000 + channel) * 5;
+
+ return 0;
}
static char * nl80211_getval(const char *ifname, const char *buf, const char *key)
@@ -763,9 +766,9 @@ int nl80211_get_bssid(const char *ifname, char *buf)
}
-static int nl80211_get_channel_cb(struct nl_msg *msg, void *arg)
+static int nl80211_get_frequency_cb(struct nl_msg *msg, void *arg)
{
- int *channel = arg;
+ int *freq = arg;
struct nlattr **attr = nl80211_parse(msg);
struct nlattr *binfo[NL80211_BSS_MAX + 1];
@@ -775,27 +778,27 @@ static int nl80211_get_channel_cb(struct nl_msg *msg, void *arg)
if (attr[NL80211_ATTR_BSS] &&
!nla_parse_nested(binfo, NL80211_BSS_MAX,
- attr[NL80211_ATTR_BSS], bss_policy))
+ attr[NL80211_ATTR_BSS], bss_policy))
{
if (binfo[NL80211_BSS_FREQUENCY])
- *channel =
- nl80211_freq2channel(nla_get_u32(binfo[NL80211_BSS_FREQUENCY]));
+ *freq = nla_get_u32(binfo[NL80211_BSS_FREQUENCY]);
}
return NL_SKIP;
}
-int nl80211_get_channel(const char *ifname, int *buf)
+int nl80211_get_frequency(const char *ifname, int *buf)
{
- char *res;
+ char *res, *channel;
struct nl80211_msg_conveyor *req;
*buf = 0;
if ((res = nl80211_hostapd_info(ifname)) &&
- (res = nl80211_getval(NULL, res, "channel")))
+ (channel = nl80211_getval(NULL, res, "channel")))
{
- *buf = atoi(res);
+ *buf = nl80211_channel2freq(atoi(channel),
+ nl80211_getval(NULL, res, "hw_mode"));
}
else
{
@@ -804,7 +807,7 @@ int nl80211_get_channel(const char *ifname, int *buf)
if (req)
{
- nl80211_send(req, nl80211_get_channel_cb, buf);
+ nl80211_send(req, nl80211_get_frequency_cb, buf);
nl80211_free(req);
}
}
@@ -812,11 +815,11 @@ int nl80211_get_channel(const char *ifname, int *buf)
return (*buf == 0) ? -1 : 0;
}
-int nl80211_get_frequency(const char *ifname, int *buf)
+int nl80211_get_channel(const char *ifname, int *buf)
{
- if (!nl80211_get_channel(ifname, buf))
+ if (!nl80211_get_frequency(ifname, buf))
{
- *buf = nl80211_channel2freq(*buf);
+ *buf = nl80211_freq2channel(*buf);
return 0;
}