+ opt = uci_lookup_option_string(uci_ctx, s, "macaddr");
+ if (!opt)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/*", opt); /**/
+ if (glob(buf, 0, NULL, &gl))
+ return -1;
+
+ for (i = 0; i < gl.gl_pathc; i++)
+ {
+ snprintf(buf, sizeof(buf), "%s/macaddress", gl.gl_pathv[i]);
+ if (nl80211_readstr(buf, buf, sizeof(buf)) <= 0)
+ continue;
+
+ if (fnmatch(opt, buf, FNM_CASEFOLD))
+ continue;
+
+ snprintf(buf, sizeof(buf), "%s/index", gl.gl_pathv[i]);
+ if ((idx = nl80211_readint(buf)) > -1)
+ break;
+ }
+
+ globfree(&gl);
+
+ return idx;
+}
+
+static int nl80211_phy_idx_from_uci_phy(struct uci_section *s)
+{
+ const char *opt;
+ char buf[128];
+
+ opt = uci_lookup_option_string(uci_ctx, s, "phy");
+ if (!opt)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", opt);
+ return nl80211_readint(buf);
+}
+
+static int nl80211_phy_idx_from_uci(const char *name)
+{
+ struct uci_section *s;
+ int idx = -1;
+
+ s = iwinfo_uci_get_radio(name, "mac80211");
+ if (!s)