summaryrefslogtreecommitdiff
path: root/iwinfo_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'iwinfo_utils.c')
-rw-r--r--iwinfo_utils.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/iwinfo_utils.c b/iwinfo_utils.c
index c15b305..63ae78c 100644
--- a/iwinfo_utils.c
+++ b/iwinfo_utils.c
@@ -77,6 +77,31 @@ int iwinfo_mw2dbm(int in)
return (int)res;
}
+size_t iwinfo_format_hwmodes(int modes, char *buf, size_t len)
+{
+ // bit numbers as per IWINFO_80211_*: ad ac ax a b g n
+ const int order[IWINFO_80211_COUNT] = { 5, 4, 6, 0, 1, 2, 3 };
+ size_t res = 0;
+ int i;
+
+ *buf = 0;
+
+ if (!(modes & ((1 << IWINFO_80211_COUNT) - 1)))
+ return 0;
+
+ for (i = 0; i < IWINFO_80211_COUNT; i++)
+ if (modes & 1 << order[i])
+ res += snprintf(buf + res, len - res, "%s/", IWINFO_80211_NAMES[order[i]]);
+
+ if (res > 0)
+ {
+ res--;
+ buf[res] = 0;
+ }
+
+ return res;
+}
+
int iwinfo_ifup(const char *ifname)
{
struct ifreq ifr;