chore: cleanup UCI dependency
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
215820132b
commit
aaa40cc77a
4 changed files with 1 additions and 80 deletions
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ IWINFO_SOVERSION = $(if $(SOVERSION),$(SOVERSION),0)
|
||||||
|
|
||||||
IWINFO_BACKENDS = $(BACKENDS)
|
IWINFO_BACKENDS = $(BACKENDS)
|
||||||
IWINFO_CFLAGS = $(CFLAGS) -Wall -std=gnu99 -fstrict-aliasing -Iinclude
|
IWINFO_CFLAGS = $(CFLAGS) -Wall -std=gnu99 -fstrict-aliasing -Iinclude
|
||||||
IWINFO_LDFLAGS = -luci -lubox -lubus
|
IWINFO_LDFLAGS = -lubox -lubus
|
||||||
|
|
||||||
IWINFO_LIB = libiwinfo.so
|
IWINFO_LIB = libiwinfo.so
|
||||||
IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname -Wl,$(IWINFO_LIB).$(IWINFO_SOVERSION)
|
IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname -Wl,$(IWINFO_LIB).$(IWINFO_SOVERSION)
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <uci.h>
|
|
||||||
#include <libubus.h>
|
#include <libubus.h>
|
||||||
|
|
||||||
#include "iwinfo.h"
|
#include "iwinfo.h"
|
||||||
|
@ -32,8 +31,6 @@
|
||||||
|
|
||||||
#define LOG10_MAGIC 1.25892541179
|
#define LOG10_MAGIC 1.25892541179
|
||||||
|
|
||||||
extern struct uci_context *uci_ctx;
|
|
||||||
|
|
||||||
int iwinfo_ioctl(int cmd, void *ifr);
|
int iwinfo_ioctl(int cmd, void *ifr);
|
||||||
|
|
||||||
int iwinfo_dbm2mw(int in);
|
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,
|
void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
|
||||||
uint16_t defcipher, uint8_t defauth);
|
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,
|
int iwinfo_ubus_query(const char *ifname, const char *field,
|
||||||
char *buf, size_t len);
|
char *buf, size_t len);
|
||||||
|
|
||||||
|
|
|
@ -401,34 +401,6 @@ static int nl80211_phy_idx_from_phy(const char *opt)
|
||||||
return nl80211_readint(buf);
|
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)
|
static bool nl80211_is_ifname(const char *name)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -458,8 +430,6 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phyidx = nl80211_phy_idx_from_phy(ifname);
|
phyidx = nl80211_phy_idx_from_phy(ifname);
|
||||||
if (phyidx < 0)
|
|
||||||
phyidx = nl80211_phy_idx_from_uci(ifname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Valid ifidx must be greater than 0 */
|
/* Valid ifidx must be greater than 0 */
|
||||||
|
@ -818,8 +788,6 @@ static char * nl80211_phy2ifname(const char *ifname)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
phyidx = nl80211_phy_idx_from_phy(ifname);
|
phyidx = nl80211_phy_idx_from_phy(ifname);
|
||||||
if (phyidx < 0)
|
|
||||||
phyidx = nl80211_phy_idx_from_uci(ifname);;
|
|
||||||
if (phyidx < 0)
|
if (phyidx < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -3590,8 +3558,6 @@ static int nl80211_lookup_phyname(const char *section, char *buf)
|
||||||
idx = nl80211_phy_idx_from_path(section + 5);
|
idx = nl80211_phy_idx_from_path(section + 5);
|
||||||
else if (!strncmp(section, "macaddr=", 8))
|
else if (!strncmp(section, "macaddr=", 8))
|
||||||
idx = nl80211_phy_idx_from_macaddr(section + 8);
|
idx = nl80211_phy_idx_from_macaddr(section + 8);
|
||||||
else
|
|
||||||
idx = nl80211_phy_idx_from_uci(section);
|
|
||||||
|
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
|
|
||||||
static int ioctl_socket = -1;
|
static int ioctl_socket = -1;
|
||||||
struct uci_context *uci_ctx = NULL;
|
|
||||||
|
|
||||||
static int iwinfo_ioctl_socket(void)
|
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);
|
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 {
|
struct iwinfo_ubus_query_state {
|
||||||
const char *ifname;
|
const char *ifname;
|
||||||
const char *field;
|
const char *field;
|
||||||
|
|
Loading…
Reference in a new issue