diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-10-05 10:26:05 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-10-05 10:26:05 +0000 |
commit | bfacdd543b92213a6f47ae0a58ac170286c4610a (patch) | |
tree | 4a16b45229df0058e948a825c157dfa41ef227a9 /package/network/utils/iwinfo/src/iwinfo_utils.c | |
parent | 0d160a4d3e056fb277d139119c7a0dab54883dd5 (diff) | |
download | upstream-bfacdd543b92213a6f47ae0a58ac170286c4610a.tar.gz upstream-bfacdd543b92213a6f47ae0a58ac170286c4610a.tar.bz2 upstream-bfacdd543b92213a6f47ae0a58ac170286c4610a.zip |
iwinfo: fix handling of accessing nl80211 interfaces via radio*
look up device path via uci instead of assuming a direct phy index
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@42759 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/utils/iwinfo/src/iwinfo_utils.c')
-rw-r--r-- | package/network/utils/iwinfo/src/iwinfo_utils.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/package/network/utils/iwinfo/src/iwinfo_utils.c b/package/network/utils/iwinfo/src/iwinfo_utils.c index 4a824337a9..b313ea2049 100644 --- a/package/network/utils/iwinfo/src/iwinfo_utils.c +++ b/package/network/utils/iwinfo/src/iwinfo_utils.c @@ -24,6 +24,7 @@ static int ioctl_socket = -1; +struct uci_context *uci_ctx = NULL; static int iwinfo_ioctl_socket(void) { @@ -365,3 +366,43 @@ void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len, data += 2 + (count * 4); len -= 2 + (count * 4); } + +struct uci_section *iwinfo_uci_get_radio(const char *name, const char *type) +{ + struct uci_ptr ptr = { + .package = "wireless", + .section = name, + }; + const char *opt; + + if (!uci_ctx) { + uci_ctx = uci_alloc_context(); + if (!uci_ctx) + return NULL; + } + + memset(&ptr, 0, sizeof(ptr)); + ptr.package = "wireless"; + ptr.section = name; + + if (uci_lookup_ptr(uci_ctx, &ptr, NULL, false)) + return NULL; + + if (!ptr.s || strcmp(ptr.s->type, "wifi-device") != 0) + return NULL; + + opt = uci_lookup_option_string(uci_ctx, ptr.s, "type"); + if (!opt || strcmp(opt, type) != 0) + return NULL; + + return ptr.s; +} + +void iwinfo_uci_free(void) +{ + if (!uci_ctx) + return; + + uci_free_context(uci_ctx); + uci_ctx = NULL; +} |