1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-27 22:21:51 +02:00

[package] iwinfo: add initial hardware detection capabilities

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29421 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2011-12-04 03:42:17 +00:00
parent ec376e8870
commit c02a9bd7aa
16 changed files with 361 additions and 39 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo
PKG_RELEASE:=18
PKG_RELEASE:=19
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View File

@ -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 *);

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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));
}

View File

@ -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)
{

View File

@ -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 }
};

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}