memset(nif, 0, sizeof(nif));
- if ((d = opendir("/sys/class/net")) != NULL)
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/ieee80211/phy%d/device/net", phyidx);
+
+ if ((d = opendir(buffer)) != NULL)
{
while ((e = readdir(d)) != NULL)
{
snprintf(buffer, sizeof(buffer),
- "/sys/class/net/%s/phy80211/index", e->d_name);
+ "/sys/class/net/%s/ifindex", e->d_name);
- if (nl80211_readint(buffer) == phyidx)
+ if ((cifidx = nl80211_readint(buffer)) >= 0 &&
+ ((ifidx < 0) || (cifidx < ifidx)))
{
- snprintf(buffer, sizeof(buffer),
- "/sys/class/net/%s/ifindex", e->d_name);
-
- if ((cifidx = nl80211_readint(buffer)) >= 0 &&
- ((ifidx < 0) || (cifidx < ifidx)))
- {
- ifidx = cifidx;
- strncpy(nif, e->d_name, sizeof(nif) - 1);
- }
+ ifidx = cifidx;
+ strncpy(nif, e->d_name, sizeof(nif) - 1);
}
}