1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-10-01 11:44:11 +03:00

[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
This commit is contained in:
jow 2012-07-06 09:30:50 +00:00
parent fe05aa2e02
commit 73bde4effd
2 changed files with 20 additions and 17 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo PKG_NAME:=libiwinfo
PKG_RELEASE:=34 PKG_RELEASE:=35
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CONFIG_DEPENDS := \ PKG_CONFIG_DEPENDS := \

View File

@ -351,15 +351,18 @@ static int nl80211_freq2channel(int freq)
return (freq / 5) - 1000; return (freq / 5) - 1000;
} }
static int nl80211_channel2freq(int channel) static int nl80211_channel2freq(int channel, const char *band)
{ {
if (channel == 14) if (channel == 14)
return 2484; return 2484;
if (channel < 14) if ((channel < 14) && (!band || band[0] != 'a'))
return (channel * 5) + 2407; 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) 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 **attr = nl80211_parse(msg);
struct nlattr *binfo[NL80211_BSS_MAX + 1]; 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] && if (attr[NL80211_ATTR_BSS] &&
!nla_parse_nested(binfo, NL80211_BSS_MAX, !nla_parse_nested(binfo, NL80211_BSS_MAX,
attr[NL80211_ATTR_BSS], bss_policy)) attr[NL80211_ATTR_BSS], bss_policy))
{ {
if (binfo[NL80211_BSS_FREQUENCY]) if (binfo[NL80211_BSS_FREQUENCY])
*channel = *freq = nla_get_u32(binfo[NL80211_BSS_FREQUENCY]);
nl80211_freq2channel(nla_get_u32(binfo[NL80211_BSS_FREQUENCY]));
} }
return NL_SKIP; 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; struct nl80211_msg_conveyor *req;
*buf = 0; *buf = 0;
if ((res = nl80211_hostapd_info(ifname)) && 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 else
{ {
@ -804,7 +807,7 @@ int nl80211_get_channel(const char *ifname, int *buf)
if (req) if (req)
{ {
nl80211_send(req, nl80211_get_channel_cb, buf); nl80211_send(req, nl80211_get_frequency_cb, buf);
nl80211_free(req); nl80211_free(req);
} }
} }
@ -812,11 +815,11 @@ int nl80211_get_channel(const char *ifname, int *buf)
return (*buf == 0) ? -1 : 0; 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; return 0;
} }