aboutsummaryrefslogtreecommitdiffstats
path: root/package/network
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-09-14 14:46:51 +0000
committerFelix Fietkau <nbd@openwrt.org>2013-09-14 14:46:51 +0000
commit28eceb0343cc90a0bd787bf75c2e203b344df878 (patch)
tree570e47ab5a207ec8c73cde7d0f8beb35bd0bc726 /package/network
parent6eeb0261e615e16f05444dd8678c3ab433e7d979 (diff)
downloadupstream-28eceb0343cc90a0bd787bf75c2e203b344df878.tar.gz
upstream-28eceb0343cc90a0bd787bf75c2e203b344df878.tar.bz2
upstream-28eceb0343cc90a0bd787bf75c2e203b344df878.zip
iwinfo: when using nl80211, parse interface combinations instead of creating/deleting interfaces
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 37983
Diffstat (limited to 'package/network')
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_nl80211.c66
1 files changed, 57 insertions, 9 deletions
diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
index 9486ffc3f9..a258d2f2b2 100644
--- a/package/network/utils/iwinfo/src/iwinfo_nl80211.c
+++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
@@ -2212,22 +2212,70 @@ int nl80211_get_hwmodelist(const char *ifname, int *buf)
return *buf ? 0 : -1;
}
-int nl80211_get_mbssid_support(const char *ifname, int *buf)
+static int nl80211_get_ifcomb_cb(struct nl_msg *msg, void *arg)
{
- /* Test whether we can create another interface */
- char *nif = nl80211_ifadd(ifname);
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *comb;
+ int *ret = arg;
+ int comb_rem, limit_rem, mode_rem;
+
+ *ret = 0;
+ if (!attr[NL80211_ATTR_INTERFACE_COMBINATIONS])
+ return NL_SKIP;
- if (nif)
+ nla_for_each_nested(comb, attr[NL80211_ATTR_INTERFACE_COMBINATIONS], comb_rem)
{
- *buf = (iwinfo_ifmac(nif) && iwinfo_ifup(nif));
+ static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
+ [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
+ [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
+ static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
+ [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
+ [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
+ struct nlattr *limit;
- iwinfo_ifdown(nif);
- nl80211_ifdel(nif);
+ nla_parse_nested(tb_comb, NL80211_BAND_ATTR_MAX, comb, iface_combination_policy);
- return 0;
+ if (!tb_comb[NL80211_IFACE_COMB_LIMITS])
+ continue;
+
+ nla_for_each_nested(limit, tb_comb[NL80211_IFACE_COMB_LIMITS], limit_rem)
+ {
+ struct nlattr *mode;
+
+ nla_parse_nested(tb_limit, NUM_NL80211_IFACE_LIMIT, limit, iface_limit_policy);
+
+ if (!tb_limit[NL80211_IFACE_LIMIT_TYPES] ||
+ !tb_limit[NL80211_IFACE_LIMIT_MAX])
+ continue;
+
+ if (nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]) < 2)
+ continue;
+
+ nla_for_each_nested(mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], mode_rem) {
+ if (nla_type(mode) == NL80211_IFTYPE_AP)
+ *ret = 1;
+ }
+ }
}
- return -1;
+ return NL_SKIP;
+}
+
+int nl80211_get_mbssid_support(const char *ifname, int *buf)
+{
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (!req)
+ return -1;
+
+ nl80211_send(req, nl80211_get_ifcomb_cb, buf);
+ nl80211_free(req);
+ return 0;
}
int nl80211_get_hardware_id(const char *ifname, char *buf)