aboutsummaryrefslogtreecommitdiffstats
path: root/package/iwinfo
diff options
context:
space:
mode:
Diffstat (limited to 'package/iwinfo')
-rw-r--r--package/iwinfo/Makefile2
-rw-r--r--package/iwinfo/src/include/iwinfo.h21
-rw-r--r--package/iwinfo/src/include/iwinfo/lua.h3
-rw-r--r--package/iwinfo/src/include/iwinfo/madwifi.h4
-rw-r--r--package/iwinfo/src/include/iwinfo/nl80211.h4
-rw-r--r--package/iwinfo/src/include/iwinfo/utils.h2
-rw-r--r--package/iwinfo/src/include/iwinfo/wext.h4
-rw-r--r--package/iwinfo/src/include/iwinfo/wl.h4
-rw-r--r--package/iwinfo/src/iwinfo_cli.c38
-rw-r--r--package/iwinfo/src/iwinfo_lib.c52
-rw-r--r--package/iwinfo/src/iwinfo_lua.c112
-rw-r--r--package/iwinfo/src/iwinfo_madwifi.c23
-rw-r--r--package/iwinfo/src/iwinfo_nl80211.c23
-rw-r--r--package/iwinfo/src/iwinfo_utils.c26
-rw-r--r--package/iwinfo/src/iwinfo_wext.c53
-rw-r--r--package/iwinfo/src/iwinfo_wl.c29
16 files changed, 361 insertions, 39 deletions
diff --git a/package/iwinfo/Makefile b/package/iwinfo/Makefile
index a661139794..db11844cfb 100644
--- a/package/iwinfo/Makefile
+++ b/package/iwinfo/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo
-PKG_RELEASE:=18
+PKG_RELEASE:=19
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
diff --git a/package/iwinfo/src/include/iwinfo.h b/package/iwinfo/src/include/iwinfo.h
index 824b945365..86bf8b1b6d 100644
--- a/package/iwinfo/src/include/iwinfo.h
+++ b/package/iwinfo/src/include/iwinfo.h
@@ -95,7 +95,26 @@ struct iwinfo_iso3166_label {
uint8_t name[28];
};
+struct iwinfo_hardware_id {
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+};
+
+struct iwinfo_hardware_entry {
+ const char *vendor_name;
+ const char *device_name;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+ int16_t txpower_offset;
+ int16_t frequency_offset;
+};
+
extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
+extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
struct iwinfo_ops {
@@ -113,6 +132,8 @@ struct iwinfo_ops {
int (*ssid)(const char *, char *);
int (*bssid)(const char *, char *);
int (*country)(const char *, char *);
+ int (*hardware_id)(const char *, char *);
+ int (*hardware_name)(const char *, char *);
int (*encryption)(const char *, char *);
int (*assoclist)(const char *, char *, int *);
int (*txpwrlist)(const char *, char *, int *);
diff --git a/package/iwinfo/src/include/iwinfo/lua.h b/package/iwinfo/src/include/iwinfo/lua.h
index 65a3a5cb91..d976c0cf46 100644
--- a/package/iwinfo/src/include/iwinfo/lua.h
+++ b/package/iwinfo/src/include/iwinfo/lua.h
@@ -71,11 +71,10 @@
return 1; \
}
-#define LUA_WRAP_LIST(type,op) \
+#define LUA_WRAP_STRUCT(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
return iwinfo_L_##op(L, type##_get_##op); \
}
#endif
-
diff --git a/package/iwinfo/src/include/iwinfo/madwifi.h b/package/iwinfo/src/include/iwinfo/madwifi.h
index 4de48557d4..ecbe749c8a 100644
--- a/package/iwinfo/src/include/iwinfo/madwifi.h
+++ b/package/iwinfo/src/include/iwinfo/madwifi.h
@@ -46,6 +46,8 @@ int madwifi_get_freqlist(const char *ifname, char *buf, int *len);
int madwifi_get_countrylist(const char *ifname, char *buf, int *len);
int madwifi_get_hwmodelist(const char *ifname, int *buf);
int madwifi_get_mbssid_support(const char *ifname, int *buf);
+int madwifi_get_hardware_id(const char *ifname, char *buf);
+int madwifi_get_hardware_name(const char *ifname, char *buf);
void madwifi_close(void);
static const struct iwinfo_ops madwifi_ops = {
@@ -63,6 +65,8 @@ static const struct iwinfo_ops madwifi_ops = {
.ssid = madwifi_get_ssid,
.bssid = madwifi_get_bssid,
.country = madwifi_get_country,
+ .hardware_id = madwifi_get_hardware_id,
+ .hardware_name = madwifi_get_hardware_name,
.encryption = madwifi_get_encryption,
.assoclist = madwifi_get_assoclist,
.txpwrlist = madwifi_get_txpwrlist,
diff --git a/package/iwinfo/src/include/iwinfo/nl80211.h b/package/iwinfo/src/include/iwinfo/nl80211.h
index dce508cf0a..3df25d34b4 100644
--- a/package/iwinfo/src/include/iwinfo/nl80211.h
+++ b/package/iwinfo/src/include/iwinfo/nl80211.h
@@ -77,6 +77,8 @@ int nl80211_get_freqlist(const char *ifname, char *buf, int *len);
int nl80211_get_countrylist(const char *ifname, char *buf, int *len);
int nl80211_get_hwmodelist(const char *ifname, int *buf);
int nl80211_get_mbssid_support(const char *ifname, int *buf);
+int nl80211_get_hardware_id(const char *ifname, char *buf);
+int nl80211_get_hardware_name(const char *ifname, char *buf);
void nl80211_close(void);
static const struct iwinfo_ops nl80211_ops = {
@@ -94,6 +96,8 @@ static const struct iwinfo_ops nl80211_ops = {
.ssid = nl80211_get_ssid,
.bssid = nl80211_get_bssid,
.country = nl80211_get_country,
+ .hardware_id = nl80211_get_hardware_id,
+ .hardware_name = nl80211_get_hardware_name,
.encryption = nl80211_get_encryption,
.assoclist = nl80211_get_assoclist,
.txpwrlist = nl80211_get_txpwrlist,
diff --git a/package/iwinfo/src/include/iwinfo/utils.h b/package/iwinfo/src/include/iwinfo/utils.h
index 57958b1b54..e897b2718a 100644
--- a/package/iwinfo/src/include/iwinfo/utils.h
+++ b/package/iwinfo/src/include/iwinfo/utils.h
@@ -37,4 +37,6 @@ int iwinfo_ifmac(const char *ifname);
void iwinfo_close(void);
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id);
+
#endif
diff --git a/package/iwinfo/src/include/iwinfo/wext.h b/package/iwinfo/src/include/iwinfo/wext.h
index 69b7a8e3d0..4d2f4aa0a2 100644
--- a/package/iwinfo/src/include/iwinfo/wext.h
+++ b/package/iwinfo/src/include/iwinfo/wext.h
@@ -47,6 +47,8 @@ int wext_get_freqlist(const char *ifname, char *buf, int *len);
int wext_get_countrylist(const char *ifname, char *buf, int *len);
int wext_get_hwmodelist(const char *ifname, int *buf);
int wext_get_mbssid_support(const char *ifname, int *buf);
+int wext_get_hardware_id(const char *ifname, char *buf);
+int wext_get_hardware_name(const char *ifname, char *buf);
void wext_close(void);
static const struct iwinfo_ops wext_ops = {
@@ -64,6 +66,8 @@ static const struct iwinfo_ops wext_ops = {
.ssid = wext_get_ssid,
.bssid = wext_get_bssid,
.country = wext_get_country,
+ .hardware_id = wext_get_hardware_id,
+ .hardware_name = wext_get_hardware_name,
.encryption = wext_get_encryption,
.assoclist = wext_get_assoclist,
.txpwrlist = wext_get_txpwrlist,
diff --git a/package/iwinfo/src/include/iwinfo/wl.h b/package/iwinfo/src/include/iwinfo/wl.h
index e931f7c6e3..10be96aeb9 100644
--- a/package/iwinfo/src/include/iwinfo/wl.h
+++ b/package/iwinfo/src/include/iwinfo/wl.h
@@ -47,6 +47,8 @@ int wl_get_freqlist(const char *ifname, char *buf, int *len);
int wl_get_countrylist(const char *ifname, char *buf, int *len);
int wl_get_hwmodelist(const char *ifname, int *buf);
int wl_get_mbssid_support(const char *ifname, int *buf);
+int wl_get_hardware_id(const char *ifname, char *buf);
+int wl_get_hardware_name(const char *ifname, char *buf);
void wl_close(void);
static const struct iwinfo_ops wl_ops = {
@@ -64,6 +66,8 @@ static const struct iwinfo_ops wl_ops = {
.ssid = wl_get_ssid,
.bssid = wl_get_bssid,
.country = wl_get_country,
+ .hardware_id = wl_get_hardware_id,
+ .hardware_name = wl_get_hardware_name,
.encryption = wl_get_encryption,
.assoclist = wl_get_assoclist,
.txpwrlist = wl_get_txpwrlist,
diff --git a/package/iwinfo/src/iwinfo_cli.c b/package/iwinfo/src/iwinfo_cli.c
index 4229b19f56..bfa1d88ef9 100644
--- a/package/iwinfo/src/iwinfo_cli.c
+++ b/package/iwinfo/src/iwinfo_cli.c
@@ -282,6 +282,35 @@ static const char * print_type(const struct iwinfo_ops *iw, const char *ifname)
return type ? type : "unknown";
}
+static char * print_hardware_id(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[20];
+ struct iwinfo_hardware_id ids;
+
+ if (!iw->hardware_id(ifname, (char *)&ids))
+ {
+ snprintf(buf, sizeof(buf), "%04X:%04X %04X:%04X",
+ ids.vendor_id, ids.device_id,
+ ids.subsystem_vendor_id, ids.subsystem_device_id);
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+
+ return buf;
+}
+
+static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[128];
+
+ if (iw->hardware_name(ifname, buf))
+ snprintf(buf, sizeof(buf), "unknown");
+
+ return buf;
+}
+
static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
{
char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
@@ -423,9 +452,6 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
print_ssid(iw, ifname));
printf(" Access Point: %s\n",
print_bssid(iw, ifname));
- printf(" Type: %s HW Mode(s): %s\n",
- print_type(iw, ifname),
- print_hwmodes(iw, ifname));
printf(" Mode: %s Channel: %s (%s)\n",
print_mode(iw, ifname),
print_channel(iw, ifname),
@@ -441,6 +467,12 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
print_rate(iw, ifname));
printf(" Encryption: %s\n",
print_encryption(iw, ifname));
+ printf(" Type: %s HW Mode(s): %s\n",
+ print_type(iw, ifname),
+ print_hwmodes(iw, ifname));
+ printf(" Hardware: %s [%s]\n",
+ print_hardware_id(iw, ifname),
+ print_hardware_name(iw, ifname));
printf(" Supports VAPs: %s\n",
print_mbssid_supp(iw, ifname));
}
diff --git a/package/iwinfo/src/iwinfo_lib.c b/package/iwinfo/src/iwinfo_lib.c
index a7160417d2..ca2dc3b2e9 100644
--- a/package/iwinfo/src/iwinfo_lib.c
+++ b/package/iwinfo/src/iwinfo_lib.c
@@ -300,6 +300,58 @@ const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
{ 0, "" }
};
+/*
+ * hardware database
+ */
+
+const char VENDOR_UBNT[] = "Ubiquiti";
+const char VENDOR_ATH[] = "Atheros";
+
+const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
+/* { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
+#if defined(USE_MADWIFI) || defined(USE_NL80211)
+ { VENDOR_UBNT, "PowerStation2 (18V)", 0xffff, 0xffff, 0xffff, 0xb102, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (16D)", 0xffff, 0xffff, 0xffff, 0xb202, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (EXT)", 0xffff, 0xffff, 0xffff, 0xb302, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (22V)", 0xffff, 0xffff, 0xffff, 0xb105, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (EXT)", 0xffff, 0xffff, 0xffff, 0xb305, 0, 0 },
+ { VENDOR_UBNT, "WispStation5", 0xffff, 0xffff, 0xffff, 0xa105, 0, 0 },
+ { VENDOR_UBNT, "LiteStation2", 0xffff, 0xffff, 0xffff, 0xa002, 0, 0 },
+ { VENDOR_UBNT, "LiteStation5", 0xffff, 0xffff, 0xffff, 0xa005, 0, 0 },
+ { VENDOR_UBNT, "NanoStation2", 0xffff, 0xffff, 0xffff, 0xc002, 0, 0 },
+ { VENDOR_UBNT, "NanoStation5", 0xffff, 0xffff, 0xffff, 0xc005, 0, 0 },
+ { VENDOR_UBNT, "NanoStation Loco2", 0xffff, 0xffff, 0xffff, 0xc102, 0, 0 },
+ { VENDOR_UBNT, "NanoStation Loco5", 0xffff, 0xffff, 0xffff, 0xc105, 0, 0 },
+ { VENDOR_UBNT, "Bullet2", 0xffff, 0xffff, 0xffff, 0xc202, 0, 0 },
+ { VENDOR_UBNT, "Bullet5", 0xffff, 0xffff, 0xffff, 0xc205, 0, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x0777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x7777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2.3", 0x168c, 0x001b, 0x0777, 0x3b02, 10, 0 },
+ { VENDOR_UBNT, "XR2.6", 0x168c, 0x001b, 0x0777, 0x3c02, 10, 0 },
+ { VENDOR_UBNT, "XR3-2.8", 0x168c, 0x001b, 0x0777, 0x3b03, 10, 0 },
+ { VENDOR_UBNT, "XR3-3.6", 0x168c, 0x001b, 0x0777, 0x3c03, 10, 0 },
+ { VENDOR_UBNT, "XR3", 0x168c, 0x001b, 0x0777, 0x3003, 10, 0 },
+ { VENDOR_UBNT, "XR4", 0x168c, 0x001b, 0x0777, 0x3004, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x0777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x7777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR7", 0x168c, 0x001b, 0x0777, 0x3007, 10, 0 },
+ { VENDOR_UBNT, "XR9", 0x168c, 0x001b, 0x0777, 0x3009, 10, -1520 },
+ { VENDOR_UBNT, "SRC", 0x168c, 0x0013, 0x168c, 0x1042, 1, 0 },
+ { VENDOR_UBNT, "SR2", 0x168c, 0x0013, 0x0777, 0x2041, 10, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x0777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x7777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x0777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x7777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR5", 0x168c, 0x0013, 0x168c, 0x2042, 7, 0 },
+ { VENDOR_UBNT, "SR9", 0x168c, 0x0013, 0x7777, 0x2009, 12, -1500 },
+ { VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 10, 0 },
+ { VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 10, 0 },
+ { VENDOR_ATH, "AR9220", 0x168c, 0x0029, 0x168c, 0xa094, 0, 0 },
+ { VENDOR_ATH, "AR9223", 0x168c, 0x0029, 0x168c, 0xa095, 0, 0 },
+#endif
+ { NULL }
+};
+
const char * iwinfo_type(const char *ifname)
{
diff --git a/package/iwinfo/src/iwinfo_lua.c b/package/iwinfo/src/iwinfo_lua.c
index 997cc8a566..08eec18bd9 100644
--- a/package/iwinfo/src/iwinfo_lua.c
+++ b/package/iwinfo/src/iwinfo_lua.c
@@ -451,7 +451,7 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
return 1;
}
-/* Wrapper for mbbsid_support */
+/* Wrapper for mbssid_support */
static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
{
const char *ifname = luaL_checkstring(L, 1);
@@ -467,6 +467,36 @@ static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *
return 1;
}
+/* Wrapper for hardware_id */
+static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_hardware_id ids;
+
+ if (!(*func)(ifname, (char *)&ids))
+ {
+ lua_newtable(L);
+
+ lua_pushnumber(L, ids.vendor_id);
+ lua_setfield(L, -2, "vendor_id");
+
+ lua_pushnumber(L, ids.device_id);
+ lua_setfield(L, -2, "device_id");
+
+ lua_pushnumber(L, ids.subsystem_vendor_id);
+ lua_setfield(L, -2, "subsystem_vendor_id");
+
+ lua_pushnumber(L, ids.subsystem_device_id);
+ lua_setfield(L, -2, "subsystem_device_id");
+ }
+ else
+ {
+ lua_pushnil(L);
+ }
+
+ return 1;
+}
+
/* Wrapper for country list */
static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
{
@@ -538,14 +568,16 @@ LUA_WRAP_STRING(wl,mode)
LUA_WRAP_STRING(wl,ssid)
LUA_WRAP_STRING(wl,bssid)
LUA_WRAP_STRING(wl,country)
-LUA_WRAP_LIST(wl,assoclist)
-LUA_WRAP_LIST(wl,txpwrlist)
-LUA_WRAP_LIST(wl,scanlist)
-LUA_WRAP_LIST(wl,freqlist)
-LUA_WRAP_LIST(wl,countrylist)
-LUA_WRAP_LIST(wl,hwmodelist)
-LUA_WRAP_LIST(wl,encryption)
-LUA_WRAP_LIST(wl,mbssid_support)
+LUA_WRAP_STRING(wl,hardware_name)
+LUA_WRAP_STRUCT(wl,assoclist)
+LUA_WRAP_STRUCT(wl,txpwrlist)
+LUA_WRAP_STRUCT(wl,scanlist)
+LUA_WRAP_STRUCT(wl,freqlist)
+LUA_WRAP_STRUCT(wl,countrylist)
+LUA_WRAP_STRUCT(wl,hwmodelist)
+LUA_WRAP_STRUCT(wl,encryption)
+LUA_WRAP_STRUCT(wl,mbssid_support)
+LUA_WRAP_STRUCT(wl,hardware_id)
#endif
#ifdef USE_MADWIFI
@@ -562,14 +594,16 @@ LUA_WRAP_STRING(madwifi,mode)
LUA_WRAP_STRING(madwifi,ssid)
LUA_WRAP_STRING(madwifi,bssid)
LUA_WRAP_STRING(madwifi,country)
-LUA_WRAP_LIST(madwifi,assoclist)
-LUA_WRAP_LIST(madwifi,txpwrlist)
-LUA_WRAP_LIST(madwifi,scanlist)
-LUA_WRAP_LIST(madwifi,freqlist)
-LUA_WRAP_LIST(madwifi,countrylist)
-LUA_WRAP_LIST(madwifi,hwmodelist)
-LUA_WRAP_LIST(madwifi,encryption)
-LUA_WRAP_LIST(madwifi,mbssid_support)
+LUA_WRAP_STRING(madwifi,hardware_name)
+LUA_WRAP_STRUCT(madwifi,assoclist)
+LUA_WRAP_STRUCT(madwifi,txpwrlist)
+LUA_WRAP_STRUCT(madwifi,scanlist)
+LUA_WRAP_STRUCT(madwifi,freqlist)
+LUA_WRAP_STRUCT(madwifi,countrylist)
+LUA_WRAP_STRUCT(madwifi,hwmodelist)
+LUA_WRAP_STRUCT(madwifi,encryption)
+LUA_WRAP_STRUCT(madwifi,mbssid_support)
+LUA_WRAP_STRUCT(madwifi,hardware_id)
#endif
#ifdef USE_NL80211
@@ -586,14 +620,16 @@ LUA_WRAP_STRING(nl80211,mode)
LUA_WRAP_STRING(nl80211,ssid)
LUA_WRAP_STRING(nl80211,bssid)
LUA_WRAP_STRING(nl80211,country)
-LUA_WRAP_LIST(nl80211,assoclist)
-LUA_WRAP_LIST(nl80211,txpwrlist)
-LUA_WRAP_LIST(nl80211,scanlist)
-LUA_WRAP_LIST(nl80211,freqlist)
-LUA_WRAP_LIST(nl80211,countrylist)
-LUA_WRAP_LIST(nl80211,hwmodelist)
-LUA_WRAP_LIST(nl80211,encryption)
-LUA_WRAP_LIST(nl80211,mbssid_support)
+LUA_WRAP_STRING(nl80211,hardware_name)
+LUA_WRAP_STRUCT(nl80211,assoclist)
+LUA_WRAP_STRUCT(nl80211,txpwrlist)
+LUA_WRAP_STRUCT(nl80211,scanlist)
+LUA_WRAP_STRUCT(nl80211,freqlist)
+LUA_WRAP_STRUCT(nl80211,countrylist)
+LUA_WRAP_STRUCT(nl80211,hwmodelist)
+LUA_WRAP_STRUCT(nl80211,encryption)
+LUA_WRAP_STRUCT(nl80211,mbssid_support)
+LUA_WRAP_STRUCT(nl80211,hardware_id)
#endif
/* Wext */
@@ -609,14 +645,16 @@ LUA_WRAP_STRING(wext,mode)
LUA_WRAP_STRING(wext,ssid)
LUA_WRAP_STRING(wext,bssid)
LUA_WRAP_STRING(wext,country)
-LUA_WRAP_LIST(wext,assoclist)
-LUA_WRAP_LIST(wext,txpwrlist)
-LUA_WRAP_LIST(wext,scanlist)
-LUA_WRAP_LIST(wext,freqlist)
-LUA_WRAP_LIST(wext,countrylist)
-LUA_WRAP_LIST(wext,hwmodelist)
-LUA_WRAP_LIST(wext,encryption)
-LUA_WRAP_LIST(wext,mbssid_support)
+LUA_WRAP_STRING(wext,hardware_name)
+LUA_WRAP_STRUCT(wext,assoclist)
+LUA_WRAP_STRUCT(wext,txpwrlist)
+LUA_WRAP_STRUCT(wext,scanlist)
+LUA_WRAP_STRUCT(wext,freqlist)
+LUA_WRAP_STRUCT(wext,countrylist)
+LUA_WRAP_STRUCT(wext,hwmodelist)
+LUA_WRAP_STRUCT(wext,encryption)
+LUA_WRAP_STRUCT(wext,mbssid_support)
+LUA_WRAP_STRUCT(wext,hardware_id)
#ifdef USE_WL
/* Broadcom table */
@@ -641,6 +679,8 @@ static const luaL_reg R_wl[] = {
LUA_REG(wl,hwmodelist),
LUA_REG(wl,encryption),
LUA_REG(wl,mbssid_support),
+ LUA_REG(wl,hardware_id),
+ LUA_REG(wl,hardware_name),
{ NULL, NULL }
};
#endif
@@ -668,6 +708,8 @@ static const luaL_reg R_madwifi[] = {
LUA_REG(madwifi,hwmodelist),
LUA_REG(madwifi,encryption),
LUA_REG(madwifi,mbssid_support),
+ LUA_REG(madwifi,hardware_id),
+ LUA_REG(madwifi,hardware_name),
{ NULL, NULL }
};
#endif
@@ -695,6 +737,8 @@ static const luaL_reg R_nl80211[] = {
LUA_REG(nl80211,hwmodelist),
LUA_REG(nl80211,encryption),
LUA_REG(nl80211,mbssid_support),
+ LUA_REG(nl80211,hardware_id),
+ LUA_REG(nl80211,hardware_name),
{ NULL, NULL }
};
#endif
@@ -721,6 +765,8 @@ static const luaL_reg R_wext[] = {
LUA_REG(wext,hwmodelist),
LUA_REG(wext,encryption),
LUA_REG(wext,mbssid_support),
+ LUA_REG(wext,hardware_id),
+ LUA_REG(wext,hardware_name),
{ NULL, NULL }
};
diff --git a/package/iwinfo/src/iwinfo_madwifi.c b/package/iwinfo/src/iwinfo_madwifi.c
index 54082c7371..feb98e25a2 100644
--- a/package/iwinfo/src/iwinfo_madwifi.c
+++ b/package/iwinfo/src/iwinfo_madwifi.c
@@ -987,3 +987,26 @@ int madwifi_get_mbssid_support(const char *ifname, int *buf)
return -1;
}
+
+int madwifi_get_hardware_id(const char *ifname, char *buf)
+{
+ return wext_get_hardware_id(ifname, buf);
+}
+
+int madwifi_get_hardware_name(const char *ifname, char *buf)
+{
+ struct iwinfo_hardware_id id;
+ struct iwinfo_hardware_entry *hw;
+
+ if (madwifi_get_hardware_id(ifname, (char *)&id))
+ return -1;
+
+ hw = iwinfo_hardware(&id);
+
+ if (hw)
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+ else
+ sprintf(buf, "Generic Atheros");
+
+ return 0;
+}
diff --git a/package/iwinfo/src/iwinfo_nl80211.c b/package/iwinfo/src/iwinfo_nl80211.c
index b3da8384e7..d3726821fc 100644
--- a/package/iwinfo/src/iwinfo_nl80211.c
+++ b/package/iwinfo/src/iwinfo_nl80211.c
@@ -1628,3 +1628,26 @@ int nl80211_get_mbssid_support(const char *ifname, int *buf)
return -1;
}
+
+int nl80211_get_hardware_id(const char *ifname, char *buf)
+{
+ return wext_get_hardware_id(ifname, buf);
+}
+
+int nl80211_get_hardware_name(const char *ifname, char *buf)
+{
+ struct iwinfo_hardware_id id;
+ struct iwinfo_hardware_entry *hw;
+
+ if (nl80211_get_hardware_id(ifname, (char *)&id))
+ return -1;
+
+ hw = iwinfo_hardware(&id);
+
+ if (hw)
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+ else
+ sprintf(buf, "Generic MAC80211");
+
+ return 0;
+}
diff --git a/package/iwinfo/src/iwinfo_utils.c b/package/iwinfo/src/iwinfo_utils.c
index 081464aafa..b49447b072 100644
--- a/package/iwinfo/src/iwinfo_utils.c
+++ b/package/iwinfo/src/iwinfo_utils.c
@@ -124,3 +124,29 @@ void iwinfo_close(void)
if( ioctl_socket > -1 )
close(ioctl_socket);
}
+
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
+{
+ const struct iwinfo_hardware_entry *e;
+
+ for (e = IWINFO_HARDWARE_ENTRIES; e->vendor_name; e++)
+ {
+ if ((e->vendor_id != 0xffff) && (e->vendor_id != id->vendor_id))
+ continue;
+
+ if ((e->device_id != 0xffff) && (e->device_id != id->device_id))
+ continue;
+
+ if ((e->subsystem_vendor_id != 0xffff) &&
+ (e->subsystem_vendor_id != id->subsystem_vendor_id))
+ continue;
+
+ if ((e->subsystem_device_id != 0xffff) &&
+ (e->subsystem_device_id != id->subsystem_device_id))
+ continue;
+
+ return e;
+ }
+
+ return NULL;
+}
diff --git a/package/iwinfo/src/iwinfo_wext.c b/package/iwinfo/src/iwinfo_wext.c
index 283f77e9f8..3923c9e760 100644
--- a/package/iwinfo/src/iwinfo_wext.c
+++ b/package/iwinfo/src/iwinfo_wext.c
@@ -462,3 +462,56 @@ int wext_get_mbssid_support(const char *ifname, int *buf)
/* No multi bssid support atm */
return -1;
}
+
+static char * wext_sysfs_ifname_file(const char *ifname, const char *path)
+{
+ FILE *f;
+ static char buf[128];
+ char *rv = NULL;
+
+ snprintf(buf, sizeof(buf), "/sys/class/net/%s/%s", ifname, path);
+
+ if ((f = fopen(buf, "r")) != NULL)
+ {
+ memset(buf, 0, sizeof(buf));
+
+ if (fread(buf, 1, sizeof(buf), f))
+ rv = buf;
+
+ fclose(f);
+ }
+
+ return rv;
+}
+
+int wext_get_hardware_id(const char *ifname, char *buf)
+{
+ char *data;
+ struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf;
+
+ memset(id, 0, sizeof(struct iwinfo_hardware_id));
+
+ data = wext_sysfs_ifname_file(ifname, "device/vendor");
+ if (data)
+ id->vendor_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/device");
+ if (data)
+ id->device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_device");
+ if (data)
+ id->subsystem_device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_vendor");
+ if (data)
+ id->subsystem_vendor_id = strtoul(data, NULL, 16);
+
+ return (id->vendor_id > 0 && id->device_id > 0) ? 0 : -1;
+}
+
+int wext_get_hardware_name(const char *ifname, char *buf)
+{
+ sprintf(buf, "Generic WEXT");
+ return 0;
+}
diff --git a/package/iwinfo/src/iwinfo_wl.c b/package/iwinfo/src/iwinfo_wl.c
index b3227918d4..76984de336 100644
--- a/package/iwinfo/src/iwinfo_wl.c
+++ b/package/iwinfo/src/iwinfo_wl.c
@@ -135,6 +135,7 @@ int wl_get_frequency(const char *ifname, int *buf)
int wl_get_txpower(const char *ifname, int *buf)
{
+ /* WLC_GET_VAR "qtxpower" */
return wext_get_txpower(ifname, buf);
}
@@ -556,3 +557,31 @@ int wl_get_mbssid_support(const char *ifname, int *buf)
return -1;
}
+
+int wl_get_hardware_id(const char *ifname, char *buf)
+{
+ wlc_rev_info_t revinfo;
+ struct iwinfo_hardware_id *ids = (struct iwinfo_hardware_id *)buf;
+
+ if (wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
+ return -1;
+
+ ids->vendor_id = revinfo.vendorid;
+ ids->device_id = revinfo.deviceid;
+ ids->subsystem_vendor_id = revinfo.boardvendor;
+ ids->subsystem_device_id = revinfo.boardid;
+
+ return 0;
+}
+
+int wl_get_hardware_name(const char *ifname, char *buf)
+{
+ struct iwinfo_hardware_id ids;
+
+ if (wl_get_hardware_id(ifname, (char *)&ids))
+ return -1;
+
+ sprintf(buf, "Broadcom BCM%04X", ids.device_id);
+
+ return 0;
+}