return 0;
}
+static uint8_t nl80211_freq2band(int freq)
+{
+ if (freq >= 2412 && freq <= 2484)
+ return IWINFO_BAND_24;
+ else if (freq >= 5160 && freq <= 5885)
+ return IWINFO_BAND_5;
+ else if (freq >= 5925 && freq <= 7125)
+ return IWINFO_BAND_6;
+ else if (freq >= 58320 && freq <= 69120)
+ return IWINFO_BAND_60;
+
+ return 0;
+}
+
static int nl80211_phyname_cb(struct nl_msg *msg, void *arg)
{
char *buf = arg;
sl->e->crypto.enabled = 1;
if (bss[NL80211_BSS_FREQUENCY])
- sl->e->channel = nl80211_freq2channel(nla_get_u32(
- bss[NL80211_BSS_FREQUENCY]));
+ {
+ sl->e->mhz = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
+ sl->e->band = nl80211_freq2band(sl->e->mhz);
+ sl->e->channel = nl80211_freq2channel(sl->e->mhz);
+ }
if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
nl80211_get_scanlist_ie(bss, sl->e);
e->mode = IWINFO_OPMODE_MASTER;
/* Channel */
- e->channel = nl80211_freq2channel(atoi(freq));
+ e->mhz = atoi(freq);
+ e->band = nl80211_freq2band(e->mhz);
+ e->channel = nl80211_freq2channel(e->mhz);
/* Signal */
rssi = atoi(signal);
freqs[NL80211_FREQUENCY_ATTR_DISABLED])
continue;
+ e->band = nl80211_get_band(band->nla_type);
e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
e->channel = nl80211_freq2channel(e->mhz);
- e->restricted = (
- freqs[NL80211_FREQUENCY_ATTR_NO_IR] &&
- !freqs[NL80211_FREQUENCY_ATTR_RADAR]
- ) ? 1 : 0;
-
if (freqs[NL80211_FREQUENCY_ATTR_NO_HT40_MINUS])
e->flags |= IWINFO_FREQ_NO_HT40MINUS;
if (freqs[NL80211_FREQUENCY_ATTR_NO_HT40_PLUS])
e->flags |= IWINFO_FREQ_NO_20MHZ;
if (freqs[NL80211_FREQUENCY_ATTR_NO_10MHZ])
e->flags |= IWINFO_FREQ_NO_10MHZ;
+ if (freqs[NL80211_FREQUENCY_ATTR_NO_HE])
+ e->flags |= IWINFO_FREQ_NO_HE;
+ if (freqs[NL80211_FREQUENCY_ATTR_NO_IR] &&
+ !freqs[NL80211_FREQUENCY_ATTR_RADAR])
+ e->flags |= IWINFO_FREQ_NO_IR;
+ if (freqs[NL80211_FREQUENCY_ATTR_INDOOR_ONLY])
+ e->flags |= IWINFO_FREQ_INDOOR_ONLY;
+
+ /* keep backwards compatibility */
+ e->restricted = (e->flags & IWINFO_FREQ_NO_IR) ? 1 : 0;
e++;
arr->count++;
static int nl80211_get_htmode(const char *ifname, int *buf)
{
- struct chan_info chn = { .width = 0, .mode = 0 };
- char *res;
+ struct chan_info chn = { 0 };
+ char *res, b[2] = { 0 };
int err;
+ bool he = false;
res = nl80211_phy2ifname(ifname);
*buf = 0;
if (err)
return -1;
+ if (nl80211_hostapd_query(res ? res : ifname, "ieee80211ax", b, sizeof(b)))
+ he = b[0] == '1';
+ else if (nl80211_wpactl_query(res ? res : ifname, "wifi_generation", b, sizeof(b)))
+ he = b[0] == '6';
+
switch (chn.width) {
case NL80211_CHAN_WIDTH_20:
- if (chn.mode == -1)
+ if (he)
+ *buf = IWINFO_HTMODE_HE20;
+ else if (chn.mode == -1)
*buf = IWINFO_HTMODE_VHT20;
else
*buf = IWINFO_HTMODE_HT20;
break;
case NL80211_CHAN_WIDTH_40:
- if (chn.mode == -1)
+ if (he)
+ *buf = IWINFO_HTMODE_HE40;
+ else if (chn.mode == -1)
*buf = IWINFO_HTMODE_VHT40;
else
*buf = IWINFO_HTMODE_HT40;
break;
case NL80211_CHAN_WIDTH_80:
- *buf = IWINFO_HTMODE_VHT80;
+ if (he)
+ *buf = IWINFO_HTMODE_HE80;
+ else
+ *buf = IWINFO_HTMODE_VHT80;
break;
case NL80211_CHAN_WIDTH_80P80:
- *buf = IWINFO_HTMODE_VHT80_80;
+ if (he)
+ *buf = IWINFO_HTMODE_HE80_80;
+ else
+ *buf = IWINFO_HTMODE_VHT80_80;
break;
case NL80211_CHAN_WIDTH_160:
- *buf = IWINFO_HTMODE_VHT160;
+ if (he)
+ *buf = IWINFO_HTMODE_HE160;
+ else
+ *buf = IWINFO_HTMODE_VHT160;
break;
case NL80211_CHAN_WIDTH_5:
case NL80211_CHAN_WIDTH_10:
static int nl80211_hardware_id_from_fdt(struct iwinfo_hardware_id *id, const char *ifname)
{
- char *phy, compat[64], path[PATH_MAX];
+ char *phy, path[PATH_MAX];
/* Try to determine the phy name from the given interface */
phy = nl80211_ifname2phy(ifname);
snprintf(path, sizeof(path), "/sys/class/%s/%s/device/of_node/compatible",
phy ? "ieee80211" : "net", phy ? phy : ifname);
- if (nl80211_readstr(path, compat, sizeof(compat)) <= 0)
+ if (nl80211_readstr(path, id->compatible, sizeof(id->compatible)) <= 0)
return -1;
- if (!strcmp(compat, "qca,ar9130-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0029;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9130;
- } else if (!strcmp(compat, "qca,ar9330-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0030;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9330;
- } else if (!strcmp(compat, "qca,ar9340-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0030;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9340;
- } else if (!strcmp(compat, "qca,qca9530-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0033;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9530;
- } else if (!strcmp(compat, "qca,qca9550-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0033;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9550;
- } else if (!strcmp(compat, "qca,qca9560-wmac")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x0033;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x9560;
- } else if (!strcmp(compat, "qcom,ipq4019-wifi")) {
- id->vendor_id = 0x168c;
- id->device_id = 0x003c;
- id->subsystem_vendor_id = 0x168c;
- id->subsystem_device_id = 0x4019;
- } else if (!strcmp(compat, "mediatek,mt7622-wmac")) {
- id->vendor_id = 0x14c3;
- id->device_id = 0x7622;
- id->subsystem_vendor_id = 0x14c3;
- id->subsystem_device_id = 0x7622;
- } else if (!strcmp(compat, "mediatek,mt7986-wmac")) {
- id->vendor_id = 0x14c3;
- id->device_id = 0x7986;
- id->subsystem_vendor_id = 0x14c3;
- id->subsystem_device_id = 0x7986;
- }
-
- return (id->vendor_id && id->device_id) ? 0 : -1;
+ return 0;
}
*lookup[i].dest = strtoul(num, NULL, 16);
}
- /* Failed to obtain hardware IDs, try FDT */
- if (id->vendor_id == 0 && id->device_id == 0 &&
- id->subsystem_vendor_id == 0 && id->subsystem_device_id == 0)
- if (!nl80211_hardware_id_from_fdt(id, ifname))
- return 0;
-
- /* Failed to obtain hardware IDs, search board config */
+ /* Failed to obtain hardware PCI/USB IDs... */
if (id->vendor_id == 0 && id->device_id == 0 &&
id->subsystem_vendor_id == 0 && id->subsystem_device_id == 0)
- return iwinfo_hardware_id_from_mtd(id);
+ /* ... first fallback to FDT ... */
+ if (nl80211_hardware_id_from_fdt(id, ifname) == -1)
+ /* ... then board config */
+ return iwinfo_hardware_id_from_mtd(id);
return 0;
}