int buf_len, offset;
struct dirent *e;
char buf[128], *link;
- int phy_id;
+ int phy_idx;
int seq = 0;
DIR *d;
- if (strncmp(phyname, "phy", 3) != 0)
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", phyname);
+ phy_idx = nl80211_readint(buf);
+ if (phy_idx < 0)
return NULL;
- phy_id = atoi(phyname + 3);
buf_len = snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/device", phyname);
link = realpath(buf, path);
if (!link)
return link;
while ((e = readdir(d)) != NULL) {
- int cur_id;
+ int cur_idx;
- if (strncmp(e->d_name, "phy", 3) != 0)
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", e->d_name);
+ cur_idx = nl80211_readint(buf);
+ if (cur_idx < 0)
continue;
- cur_id = atoi(e->d_name + 3);
- if (cur_id >= phy_id)
+ if (cur_idx >= phy_idx)
continue;
seq++;
static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
int cmd, int flags)
{
- int ifidx = -1, phyidx = -1;
+ unsigned int ifidx = 0;
+ int phyidx = -1;
struct nl80211_msg_conveyor *cv;
if (ifname == NULL)
if (nl80211_init() < 0)
return NULL;
- if (!strncmp(ifname, "phy", 3))
- phyidx = atoi(&ifname[3]);
- else if (!strncmp(ifname, "radio", 5))
- phyidx = nl80211_phy_idx_from_uci(ifname);
-
if (!strncmp(ifname, "mon.", 4))
ifidx = if_nametoindex(&ifname[4]);
else
ifidx = if_nametoindex(ifname);
+ if (!ifidx) {
+ phyidx = nl80211_phy_idx_from_phy(ifname);
+ if (phyidx < 0)
+ phyidx = nl80211_phy_idx_from_uci(ifname);
+ }
+
/* Valid ifidx must be greater than 0 */
if ((ifidx <= 0) && (phyidx < 0))
return NULL;
return 0;
}
-static int nl80211_ifname2phy_cb(struct nl_msg *msg, void *arg)
+static int nl80211_phyname_cb(struct nl_msg *msg, void *arg)
{
char *buf = arg;
struct nlattr **attr = nl80211_parse(msg);
memset(phy, 0, sizeof(phy));
nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0,
- nl80211_ifname2phy_cb, phy);
+ nl80211_phyname_cb, phy);
+
+ return phy[0] ? phy : NULL;
+}
+
+static char * nl80211_phyidx2name(unsigned int idx)
+{
+ struct nl80211_msg_conveyor *cv;
+ static char phy[32] = { 0 };
+
+ if (nl80211_init() < 0)
+ return NULL;
+
+ cv = nl80211_new(nls->nl80211, NL80211_CMD_GET_WIPHY, 0);
+ if (!cv)
+ return NULL;
+
+ NLA_PUT_U32(cv->msg, NL80211_ATTR_WIPHY, idx);
+
+ memset(phy, 0, sizeof(phy));
+ nl80211_send(cv, nl80211_phyname_cb, phy);
return phy[0] ? phy : NULL;
+
+nla_put_failure:
+ return NULL;
}
static char * nl80211_phy2ifname(const char *ifname)
/* Only accept phy name of the form phy%d or radio%d */
if (!ifname)
return NULL;
- else if (!strncmp(ifname, "phy", 3))
- phyidx = atoi(&ifname[3]);
- else if (!strncmp(ifname, "radio", 5))
- phyidx = nl80211_phy_idx_from_uci(ifname);
- else
+
+ phyidx = nl80211_phy_idx_from_phy(ifname);
+ if (phyidx < 0)
+ phyidx = nl80211_phy_idx_from_uci(ifname);;
+ if (phyidx < 0)
return NULL;
memset(nif, 0, sizeof(nif));
{ "IEEE 802.1X/EAP", 0, IWINFO_KMGMT_8021x },
{ "EAP-SUITE-B-192", 4, IWINFO_KMGMT_8021x },
{ "EAP-SUITE-B", 4, IWINFO_KMGMT_8021x },
+ { "EAP-SHA384", 4, IWINFO_KMGMT_8021x },
{ "EAP-SHA256", 0, IWINFO_KMGMT_8021x },
{ "PSK-SHA256", 0, IWINFO_KMGMT_PSK },
{ "NONE", 0, IWINFO_KMGMT_NONE },
if (!strncmp(p, "WPA-", 4))
p += 4;
+ if (!strncmp(p, "FT-", 3))
+ p += 3;
+
parse_wpa_suites(p, atoi(wpa), &c->wpa_version, &c->auth_suites);
}
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;
}
static int nl80211_lookup_phyname(const char *section, char *buf)
{
+ const char *name;
int idx;
if (!strncmp(section, "path=", 5))
if (idx < 0)
return -1;
- sprintf(buf, "phy%d", idx);
+ name = nl80211_phyidx2name(idx);
+ if (!name)
+ return -1;
+
+ strcpy(buf, name);
return 0;
}
static int nl80211_phy_path(const char *phyname, const char **path)
{
- if (strncmp(phyname, "phy", 3) != 0)
- return -1;
-
if (strchr(phyname, '/'))
return -1;