Compare commits
10 commits
d1f07cfdf3
...
aaa40cc77a
Author | SHA1 | Date | |
---|---|---|---|
|
aaa40cc77a | ||
|
215820132b | ||
|
79a9615064 | ||
|
3aa2b6b2c6 | ||
|
8ffb8bfd11 | ||
|
163a640fef | ||
|
a34977c076 | ||
|
3eb34df3ee | ||
|
ca79f64154 | ||
|
65ea345a5b |
6 changed files with 37 additions and 98 deletions
2
Makefile
2
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)
|
||||
|
|
10
devices.txt
10
devices.txt
|
@ -154,6 +154,7 @@
|
|||
0x168c 0x0030 0x168c 0x3114 0 0 "Atheros" "AR9390"
|
||||
0x168c 0x0033 0x168c 0xa120 0 0 "Atheros" "AR9580"
|
||||
0x168c 0x0033 0x168c 0xa136 0 0 "Atheros" "AR9580"
|
||||
0x168c 0x0033 0x168c 0x3123 0 0 "Atheros" "AR9590"
|
||||
0x168c 0x0033 0x19b6 0xd014 0 0 "MikroTik" "R11e-5HnD"
|
||||
0x168c 0x0033 0x19b6 0xd057 0 0 "MikroTik" "R11e-5HnDr2"
|
||||
0x168c 0x0033 0x19b6 0xd016 0 0 "MikroTik" "R11e-2HPnD"
|
||||
|
@ -163,6 +164,7 @@
|
|||
0x168c 0x003c 0x1a56 0x1420 0 0 "Qualcomm Atheros" "QCA9862"
|
||||
0x168c 0x003c 0x19b6 0xd03c 0 0 "Mikrotik" "R11e-5HacT"
|
||||
0x168c 0x003c 0x19b6 0xd075 0 0 "Mikrotik" "R11e-5HacD"
|
||||
0x168c 0x003e 0x168c 0x3361 0 0 "Qualcomm Atheros" "QCA6174"
|
||||
0x168c 0x0040 0x168c 0x0002 0 0 "Qualcomm Atheros" "QCA9990"
|
||||
0x168c 0x0046 0x168c 0xcafe 0 0 "Qualcomm Atheros" "QCA9984"
|
||||
0x168c 0x0050 0x0000 0x0000 0 0 "Qualcomm Atheros" "QCA9887"
|
||||
|
@ -186,12 +188,16 @@
|
|||
0x14c3 0x7650 0x14c3 0x7650 0 0 "MediaTek" "MT7610E"
|
||||
0x14c3 0x7662 0x14c3 0x7662 0 0 "MediaTek" "MT76x2E"
|
||||
0x14c3 0x7915 0x14c3 0x7915 0 0 "MediaTek" "MT7915E"
|
||||
0x14c3 0x7906 0x14c3 0x7906 0 0 "MediaTek" "MT7916AN"
|
||||
0x14e4 0xaa52 0x14e4 0xaa52 0 0 "Broadcom" "BCM43602"
|
||||
0x02d0 0xa9a6 0x0000 0x0000 0 0 "Cypress" "CYW43455"
|
||||
0x02d0 0x4345 0x0000 0x0000 0 0 "Cypress" "CYW43455"
|
||||
0x1ae9 0x0310 0x1ae9 0x0000 0 0 "Wilocity" "Wil6210"
|
||||
|
||||
# USB devices
|
||||
# 0x0000 | 0x0000 | vendor id | product id | ...
|
||||
# mt7601u/usb.c
|
||||
0x0000 0x0000 0x148f 0x7601 0 0 "MediaTek" "MT7601U"
|
||||
# mt7921/usb.c
|
||||
0x0000 0x0000 0x0e8d 0x7961 0 0 "MediaTek" "MT7921AU"
|
||||
# mt76x2/usb.c
|
||||
|
@ -233,6 +239,9 @@
|
|||
# mt7615/usb.c
|
||||
0x0000 0x0000 0x0e8d 0x7663 0 0 "MediaTek" "MT7663U"
|
||||
0x0000 0x0000 0x043e 0x310c 0 0 "LG" "LGSBWAC02"
|
||||
# rtl8xxxu/rtl8xxxu_core.c
|
||||
0x0000 0x0000 0x0bda 0x8176 0 0 "Realtek" "RTL8188CU"
|
||||
0x0000 0x0000 0x0bda 0xf179 0 0 "Realtek" "RTL8188FTV"
|
||||
|
||||
# FDT compatible strings
|
||||
# "compatible" | txpower offset | frequency offset | ...
|
||||
|
@ -243,6 +252,7 @@
|
|||
"qca,qca9550-wmac" 0 0 "Qualcomm Atheros" "QCA9550"
|
||||
"qca,qca9560-wmac" 0 0 "Qualcomm Atheros" "QCA9560"
|
||||
"qcom,ipq4019-wifi" 0 0 "Qualcomm Atheros" "IPQ4019"
|
||||
"qcom,ipq6018-wifi" 0 0 "Qualcomm Atheros" "IPQ6018"
|
||||
"qcom,ipq8074-wifi" 0 0 "Qualcomm Atheros" "IPQ8074"
|
||||
"mediatek,mt7622-wmac" 0 0 "MediaTek" "MT7622"
|
||||
"mediatek,mt7628-wmac" 0 0 "MediaTek" "MT7628"
|
||||
|
|
|
@ -240,8 +240,8 @@ struct iwinfo_assoclist_entry {
|
|||
uint64_t rx_drop_misc;
|
||||
struct iwinfo_rate_entry rx_rate;
|
||||
struct iwinfo_rate_entry tx_rate;
|
||||
uint32_t rx_bytes;
|
||||
uint32_t tx_bytes;
|
||||
uint64_t rx_bytes;
|
||||
uint64_t tx_bytes;
|
||||
uint32_t tx_retries;
|
||||
uint32_t tx_failed;
|
||||
uint64_t t_offset;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <uci.h>
|
||||
#include <libubus.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -1249,7 +1217,7 @@ static int nl80211_get_ssid_bssid_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr **tb = nl80211_parse(msg);
|
||||
struct nlattr *bss[NL80211_BSS_MAX + 1];
|
||||
|
||||
static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
static const struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
[NL80211_BSS_INFORMATION_ELEMENTS] = { 0 },
|
||||
[NL80211_BSS_STATUS] = { .type = NLA_U32 },
|
||||
};
|
||||
|
@ -1373,7 +1341,7 @@ static int nl80211_get_frequency_scan_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr **attr = nl80211_parse(msg);
|
||||
struct nlattr *binfo[NL80211_BSS_MAX + 1];
|
||||
|
||||
static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
static const struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
[NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
|
||||
[NL80211_BSS_STATUS] = { .type = NLA_U32 },
|
||||
};
|
||||
|
@ -1550,10 +1518,12 @@ static int nl80211_fill_signal_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
|
||||
struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
|
||||
|
||||
static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
|
||||
static const struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
|
||||
[NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 },
|
||||
[NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 },
|
||||
[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
|
||||
|
@ -1563,7 +1533,7 @@ static int nl80211_fill_signal_cb(struct nl_msg *msg, void *arg)
|
|||
[NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
|
||||
};
|
||||
|
||||
static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
|
||||
static const struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
|
||||
[NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
|
||||
[NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
|
||||
[NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
|
||||
|
@ -1662,7 +1632,7 @@ static int nl80211_get_noise_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr **tb = nl80211_parse(msg);
|
||||
struct nlattr *si[NL80211_SURVEY_INFO_MAX + 1];
|
||||
|
||||
static struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = {
|
||||
static const struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = {
|
||||
[NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
|
||||
[NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
|
||||
};
|
||||
|
@ -1760,7 +1730,7 @@ static int nl80211_check_wepkey(const char *key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct {
|
||||
static const struct {
|
||||
const char *match;
|
||||
int version;
|
||||
int suite;
|
||||
|
@ -1817,7 +1787,7 @@ static void parse_wpa_suites(const char *str, int defversion,
|
|||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
static const struct {
|
||||
const char *match;
|
||||
int cipher;
|
||||
} wpa_cipher_strings[] = {
|
||||
|
@ -2099,7 +2069,7 @@ static int nl80211_get_survey_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr *sinfo[NL80211_SURVEY_INFO_MAX + 1];
|
||||
int rc;
|
||||
|
||||
static struct nla_policy survey_policy[NL80211_SURVEY_INFO_MAX + 1] = {
|
||||
static const struct nla_policy survey_policy[NL80211_SURVEY_INFO_MAX + 1] = {
|
||||
[NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
|
||||
[NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
|
||||
[NL80211_SURVEY_INFO_TIME] = { .type = NLA_U64 },
|
||||
|
@ -2204,7 +2174,7 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
|
||||
struct nl80211_sta_flag_update *sta_flags;
|
||||
|
||||
static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
|
||||
static const struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
|
||||
[NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
|
||||
|
@ -2214,6 +2184,8 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
|
|||
[NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 },
|
||||
[NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 },
|
||||
[NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 },
|
||||
[NL80211_STA_INFO_TX_RETRIES] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
|
||||
[NL80211_STA_INFO_CONNECTED_TIME]= { .type = NLA_U32 },
|
||||
|
@ -2231,7 +2203,7 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
|
|||
[NL80211_STA_INFO_NONPEER_PM] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
|
||||
static const struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
|
||||
[NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
|
||||
[NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
|
||||
[NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
|
||||
|
@ -2277,10 +2249,14 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
|
|||
sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy))
|
||||
nl80211_parse_rateinfo(rinfo, &e->tx_rate);
|
||||
|
||||
if (sinfo[NL80211_STA_INFO_RX_BYTES])
|
||||
if (sinfo[NL80211_STA_INFO_RX_BYTES64])
|
||||
e->rx_bytes = nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]);
|
||||
else if (sinfo[NL80211_STA_INFO_RX_BYTES])
|
||||
e->rx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]);
|
||||
|
||||
if (sinfo[NL80211_STA_INFO_TX_BYTES])
|
||||
if (sinfo[NL80211_STA_INFO_TX_BYTES64])
|
||||
e->tx_bytes = nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]);
|
||||
else if (sinfo[NL80211_STA_INFO_TX_BYTES])
|
||||
e->tx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]);
|
||||
|
||||
if (sinfo[NL80211_STA_INFO_TX_RETRIES])
|
||||
|
@ -2413,7 +2389,7 @@ static int nl80211_get_txpwrlist_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
|
||||
struct nlattr *band, *freq;
|
||||
|
||||
static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
|
||||
static const struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
|
||||
[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
|
||||
[NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
|
||||
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
|
||||
|
@ -2596,7 +2572,7 @@ static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
|
|||
struct nlattr **tb = nl80211_parse(msg);
|
||||
struct nlattr *bss[NL80211_BSS_MAX + 1];
|
||||
|
||||
static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
static const struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
|
||||
[NL80211_BSS_TSF] = { .type = NLA_U64 },
|
||||
[NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
|
||||
[NL80211_BSS_BSSID] = { 0 },
|
||||
|
@ -3421,12 +3397,12 @@ static int nl80211_get_ifcomb_cb(struct nl_msg *msg, void *arg)
|
|||
|
||||
nla_for_each_nested(comb, attr[NL80211_ATTR_INTERFACE_COMBINATIONS], comb_rem)
|
||||
{
|
||||
static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
|
||||
static const struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
|
||||
[NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
|
||||
[NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
|
||||
};
|
||||
struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB+1];
|
||||
static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
|
||||
static const struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
|
||||
[NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
|
||||
[NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
|
||||
};
|
||||
|
@ -3582,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue