From aaa40cc77a42683df3c32d1f693e9ab95f910f2a Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 7 Sep 2024 18:39:59 +0200 Subject: [PATCH] chore: cleanup UCI dependency Signed-off-by: Raito Bezarius --- Makefile | 2 +- include/iwinfo/utils.h | 6 ------ iwinfo_nl80211.c | 34 ---------------------------------- iwinfo_utils.c | 39 --------------------------------------- 4 files changed, 1 insertion(+), 80 deletions(-) diff --git a/Makefile b/Makefile index adb9e73..4ee3468 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ IWINFO_SOVERSION = $(if $(SOVERSION),$(SOVERSION),0) IWINFO_BACKENDS = $(BACKENDS) IWINFO_CFLAGS = $(CFLAGS) -Wall -std=gnu99 -fstrict-aliasing -Iinclude -IWINFO_LDFLAGS = -luci -lubox -lubus +IWINFO_LDFLAGS = -lubox -lubus IWINFO_LIB = libiwinfo.so IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname -Wl,$(IWINFO_LIB).$(IWINFO_SOVERSION) diff --git a/include/iwinfo/utils.h b/include/iwinfo/utils.h index 7b8ceea..66e67bb 100644 --- a/include/iwinfo/utils.h +++ b/include/iwinfo/utils.h @@ -21,7 +21,6 @@ #include #include -#include #include #include "iwinfo.h" @@ -32,8 +31,6 @@ #define LOG10_MAGIC 1.25892541179 -extern struct uci_context *uci_ctx; - int iwinfo_ioctl(int cmd, void *ifr); int iwinfo_dbm2mw(int in); @@ -67,9 +64,6 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id); void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len, uint16_t defcipher, uint8_t defauth); -struct uci_section *iwinfo_uci_get_radio(const char *name, const char *type); -void iwinfo_uci_free(void); - int iwinfo_ubus_query(const char *ifname, const char *field, char *buf, size_t len); diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2200249..72d28cd 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -401,34 +401,6 @@ static int nl80211_phy_idx_from_phy(const char *opt) return nl80211_readint(buf); } -static int nl80211_phy_idx_from_uci(const char *name) -{ - struct uci_section *s; - const char *opt; - int idx = -1; - - s = iwinfo_uci_get_radio(name, "mac80211"); - if (!s) - goto out; - - opt = uci_lookup_option_string(uci_ctx, s, "path"); - idx = nl80211_phy_idx_from_path(opt); - if (idx >= 0) - goto out; - - opt = uci_lookup_option_string(uci_ctx, s, "macaddr"); - idx = nl80211_phy_idx_from_macaddr(opt); - if (idx >= 0) - goto out; - - opt = uci_lookup_option_string(uci_ctx, s, "phy"); - idx = nl80211_phy_idx_from_phy(opt); - -out: - iwinfo_uci_free(); - return idx; -} - static bool nl80211_is_ifname(const char *name) { struct stat st; @@ -458,8 +430,6 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname, else { phyidx = nl80211_phy_idx_from_phy(ifname); - if (phyidx < 0) - phyidx = nl80211_phy_idx_from_uci(ifname); } /* Valid ifidx must be greater than 0 */ @@ -818,8 +788,6 @@ static char * nl80211_phy2ifname(const char *ifname) return NULL; phyidx = nl80211_phy_idx_from_phy(ifname); - if (phyidx < 0) - phyidx = nl80211_phy_idx_from_uci(ifname);; if (phyidx < 0) return NULL; @@ -3590,8 +3558,6 @@ static int nl80211_lookup_phyname(const char *section, char *buf) idx = nl80211_phy_idx_from_path(section + 5); else if (!strncmp(section, "macaddr=", 8)) idx = nl80211_phy_idx_from_macaddr(section + 8); - else - idx = nl80211_phy_idx_from_uci(section); if (idx < 0) return -1; diff --git a/iwinfo_utils.c b/iwinfo_utils.c index d96cbb3..e8ac899 100644 --- a/iwinfo_utils.c +++ b/iwinfo_utils.c @@ -24,7 +24,6 @@ static int ioctl_socket = -1; -struct uci_context *uci_ctx = NULL; static int iwinfo_ioctl_socket(void) { @@ -599,44 +598,6 @@ void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len, 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, - .flags = (name && *name == '@') ? UCI_LOOKUP_EXTENDED : 0, - }; - const char *opt; - - if (!uci_ctx) { - uci_ctx = uci_alloc_context(); - if (!uci_ctx) - return NULL; - } - - if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true)) - 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; -} - - struct iwinfo_ubus_query_state { const char *ifname; const char *field;