iwinfo: detect AC PHY for broadcom-wl
[openwrt/openwrt.git] / package / network / utils / iwinfo / src / iwinfo_wl.c
index 95240add70f070552eb56a9bdc2bf43b1ff70c2f..7cbda9679e566456988466d9c73d74d3e75b125d 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "iwinfo.h"
-#include "iwinfo/api/broadcom.h"
+#include "api/broadcom.h"
 
 static int wl_ioctl(const char *name, int cmd, void *buf, int len)
 {
@@ -565,7 +565,7 @@ static int wl_get_countrylist(const char *ifname, char *buf, int *len)
        {
                for (i = 0, count = 0; i < cl->count; i++, c++)
                {
-                       sprintf(c->ccode, &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
+                       snprintf(c->ccode, sizeof(c->ccode), "%s", &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
                        c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
 
                        /* IL0 -> World */
@@ -592,6 +592,7 @@ static int wl_get_hwmodelist(const char *ifname, int *buf)
        if (!wl_ioctl(ifname, WLC_GET_PHYTYPE, &phytype, sizeof(phytype)) &&
                !wl_ioctl(ifname, WLC_GET_BANDLIST, band, sizeof(band)))
        {
+               *buf = 0;
                switch (phytype)
                {
                        case WLC_PHY_TYPE_A:
@@ -600,15 +601,18 @@ static int wl_get_hwmodelist(const char *ifname, int *buf)
                        case WLC_PHY_TYPE_B:
                                *buf = IWINFO_80211_B;
                                break;
+                       case WLC_PHY_TYPE_AC:
+                               *buf |= IWINFO_80211_AC;
+                       case WLC_PHY_TYPE_HT:
+                       case WLC_PHY_TYPE_N:
+                               *buf |= IWINFO_80211_N;
                        case WLC_PHY_TYPE_LP:
                        case WLC_PHY_TYPE_G:
-                       case WLC_PHY_TYPE_N:
                                bands = 0;
                                for (i = 1; i <= band[0]; i++)
                                {
                                        bands |= band[i];
                                }
-                               *buf = 0;
                                if (bands & WLC_BAND_5G)
                                        *buf |= IWINFO_80211_A;
                                if (bands & WLC_BAND_2G)
@@ -616,8 +620,6 @@ static int wl_get_hwmodelist(const char *ifname, int *buf)
                                        *buf |= IWINFO_80211_B;
                                        *buf |= IWINFO_80211_G;
                                }
-                               if (phytype == WLC_PHY_TYPE_N)
-                                       *buf |= IWINFO_80211_N;
                                break;
                        default:
                                return -1;