iwinfo: expose txpower and frequency offset information

SVN-Revision: 29425
owl
Jo-Philipp Wich 2011-12-04 20:37:01 +00:00
parent 33750dc3e9
commit 3a9d303059
13 changed files with 281 additions and 108 deletions

View File

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

View File

@ -120,7 +120,9 @@ extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
struct iwinfo_ops { struct iwinfo_ops {
int (*channel)(const char *, int *); int (*channel)(const char *, int *);
int (*frequency)(const char *, int *); int (*frequency)(const char *, int *);
int (*frequency_offset)(const char *, int *);
int (*txpower)(const char *, int *); int (*txpower)(const char *, int *);
int (*txpower_offset)(const char *, int *);
int (*bitrate)(const char *, int *); int (*bitrate)(const char *, int *);
int (*signal)(const char *, int *); int (*signal)(const char *, int *);
int (*noise)(const char *, int *); int (*noise)(const char *, int *);

View File

@ -32,7 +32,9 @@ int madwifi_get_bssid(const char *ifname, char *buf);
int madwifi_get_country(const char *ifname, char *buf); int madwifi_get_country(const char *ifname, char *buf);
int madwifi_get_channel(const char *ifname, int *buf); int madwifi_get_channel(const char *ifname, int *buf);
int madwifi_get_frequency(const char *ifname, int *buf); int madwifi_get_frequency(const char *ifname, int *buf);
int madwifi_get_frequency_offset(const char *ifname, int *buf);
int madwifi_get_txpower(const char *ifname, int *buf); int madwifi_get_txpower(const char *ifname, int *buf);
int madwifi_get_txpower_offset(const char *ifname, int *buf);
int madwifi_get_bitrate(const char *ifname, int *buf); int madwifi_get_bitrate(const char *ifname, int *buf);
int madwifi_get_signal(const char *ifname, int *buf); int madwifi_get_signal(const char *ifname, int *buf);
int madwifi_get_noise(const char *ifname, int *buf); int madwifi_get_noise(const char *ifname, int *buf);
@ -51,29 +53,31 @@ int madwifi_get_hardware_name(const char *ifname, char *buf);
void madwifi_close(void); void madwifi_close(void);
static const struct iwinfo_ops madwifi_ops = { static const struct iwinfo_ops madwifi_ops = {
.channel = madwifi_get_channel, .channel = madwifi_get_channel,
.frequency = madwifi_get_frequency, .frequency = madwifi_get_frequency,
.txpower = madwifi_get_txpower, .frequency_offset = madwifi_get_frequency_offset,
.bitrate = madwifi_get_bitrate, .txpower = madwifi_get_txpower,
.signal = madwifi_get_signal, .txpower_offset = madwifi_get_txpower_offset,
.noise = madwifi_get_noise, .bitrate = madwifi_get_bitrate,
.quality = madwifi_get_quality, .signal = madwifi_get_signal,
.quality_max = madwifi_get_quality_max, .noise = madwifi_get_noise,
.mbssid_support = madwifi_get_mbssid_support, .quality = madwifi_get_quality,
.hwmodelist = madwifi_get_hwmodelist, .quality_max = madwifi_get_quality_max,
.mode = madwifi_get_mode, .mbssid_support = madwifi_get_mbssid_support,
.ssid = madwifi_get_ssid, .hwmodelist = madwifi_get_hwmodelist,
.bssid = madwifi_get_bssid, .mode = madwifi_get_mode,
.country = madwifi_get_country, .ssid = madwifi_get_ssid,
.hardware_id = madwifi_get_hardware_id, .bssid = madwifi_get_bssid,
.hardware_name = madwifi_get_hardware_name, .country = madwifi_get_country,
.encryption = madwifi_get_encryption, .hardware_id = madwifi_get_hardware_id,
.assoclist = madwifi_get_assoclist, .hardware_name = madwifi_get_hardware_name,
.txpwrlist = madwifi_get_txpwrlist, .encryption = madwifi_get_encryption,
.scanlist = madwifi_get_scanlist, .assoclist = madwifi_get_assoclist,
.freqlist = madwifi_get_freqlist, .txpwrlist = madwifi_get_txpwrlist,
.countrylist = madwifi_get_countrylist, .scanlist = madwifi_get_scanlist,
.close = madwifi_close .freqlist = madwifi_get_freqlist,
.countrylist = madwifi_get_countrylist,
.close = madwifi_close
}; };
#endif #endif

View File

@ -63,7 +63,9 @@ int nl80211_get_bssid(const char *ifname, char *buf);
int nl80211_get_country(const char *ifname, char *buf); int nl80211_get_country(const char *ifname, char *buf);
int nl80211_get_channel(const char *ifname, int *buf); int nl80211_get_channel(const char *ifname, int *buf);
int nl80211_get_frequency(const char *ifname, int *buf); int nl80211_get_frequency(const char *ifname, int *buf);
int nl80211_get_frequency_offset(const char *ifname, int *buf);
int nl80211_get_txpower(const char *ifname, int *buf); int nl80211_get_txpower(const char *ifname, int *buf);
int nl80211_get_txpower_offset(const char *ifname, int *buf);
int nl80211_get_bitrate(const char *ifname, int *buf); int nl80211_get_bitrate(const char *ifname, int *buf);
int nl80211_get_signal(const char *ifname, int *buf); int nl80211_get_signal(const char *ifname, int *buf);
int nl80211_get_noise(const char *ifname, int *buf); int nl80211_get_noise(const char *ifname, int *buf);
@ -82,29 +84,31 @@ int nl80211_get_hardware_name(const char *ifname, char *buf);
void nl80211_close(void); void nl80211_close(void);
static const struct iwinfo_ops nl80211_ops = { static const struct iwinfo_ops nl80211_ops = {
.channel = nl80211_get_channel, .channel = nl80211_get_channel,
.frequency = nl80211_get_frequency, .frequency = nl80211_get_frequency,
.txpower = nl80211_get_txpower, .frequency_offset = nl80211_get_frequency_offset,
.bitrate = nl80211_get_bitrate, .txpower = nl80211_get_txpower,
.signal = nl80211_get_signal, .txpower_offset = nl80211_get_txpower_offset,
.noise = nl80211_get_noise, .bitrate = nl80211_get_bitrate,
.quality = nl80211_get_quality, .signal = nl80211_get_signal,
.quality_max = nl80211_get_quality_max, .noise = nl80211_get_noise,
.mbssid_support = nl80211_get_mbssid_support, .quality = nl80211_get_quality,
.hwmodelist = nl80211_get_hwmodelist, .quality_max = nl80211_get_quality_max,
.mode = nl80211_get_mode, .mbssid_support = nl80211_get_mbssid_support,
.ssid = nl80211_get_ssid, .hwmodelist = nl80211_get_hwmodelist,
.bssid = nl80211_get_bssid, .mode = nl80211_get_mode,
.country = nl80211_get_country, .ssid = nl80211_get_ssid,
.hardware_id = nl80211_get_hardware_id, .bssid = nl80211_get_bssid,
.hardware_name = nl80211_get_hardware_name, .country = nl80211_get_country,
.encryption = nl80211_get_encryption, .hardware_id = nl80211_get_hardware_id,
.assoclist = nl80211_get_assoclist, .hardware_name = nl80211_get_hardware_name,
.txpwrlist = nl80211_get_txpwrlist, .encryption = nl80211_get_encryption,
.scanlist = nl80211_get_scanlist, .assoclist = nl80211_get_assoclist,
.freqlist = nl80211_get_freqlist, .txpwrlist = nl80211_get_txpwrlist,
.countrylist = nl80211_get_countrylist, .scanlist = nl80211_get_scanlist,
.close = nl80211_close .freqlist = nl80211_get_freqlist,
.countrylist = nl80211_get_countrylist,
.close = nl80211_close
}; };
#endif #endif

View File

@ -33,7 +33,9 @@ int wext_get_bssid(const char *ifname, char *buf);
int wext_get_country(const char *ifname, char *buf); int wext_get_country(const char *ifname, char *buf);
int wext_get_channel(const char *ifname, int *buf); int wext_get_channel(const char *ifname, int *buf);
int wext_get_frequency(const char *ifname, int *buf); int wext_get_frequency(const char *ifname, int *buf);
int wext_get_frequency_offset(const char *ifname, int *buf);
int wext_get_txpower(const char *ifname, int *buf); int wext_get_txpower(const char *ifname, int *buf);
int wext_get_txpower_offset(const char *ifname, int *buf);
int wext_get_bitrate(const char *ifname, int *buf); int wext_get_bitrate(const char *ifname, int *buf);
int wext_get_signal(const char *ifname, int *buf); int wext_get_signal(const char *ifname, int *buf);
int wext_get_noise(const char *ifname, int *buf); int wext_get_noise(const char *ifname, int *buf);
@ -52,29 +54,31 @@ int wext_get_hardware_name(const char *ifname, char *buf);
void wext_close(void); void wext_close(void);
static const struct iwinfo_ops wext_ops = { static const struct iwinfo_ops wext_ops = {
.channel = wext_get_channel, .channel = wext_get_channel,
.frequency = wext_get_frequency, .frequency = wext_get_frequency,
.txpower = wext_get_txpower, .frequency_offset = wext_get_frequency_offset,
.bitrate = wext_get_bitrate, .txpower = wext_get_txpower,
.signal = wext_get_signal, .txpower_offset = wext_get_txpower_offset,
.noise = wext_get_noise, .bitrate = wext_get_bitrate,
.quality = wext_get_quality, .signal = wext_get_signal,
.quality_max = wext_get_quality_max, .noise = wext_get_noise,
.mbssid_support = wext_get_mbssid_support, .quality = wext_get_quality,
.hwmodelist = wext_get_hwmodelist, .quality_max = wext_get_quality_max,
.mode = wext_get_mode, .mbssid_support = wext_get_mbssid_support,
.ssid = wext_get_ssid, .hwmodelist = wext_get_hwmodelist,
.bssid = wext_get_bssid, .mode = wext_get_mode,
.country = wext_get_country, .ssid = wext_get_ssid,
.hardware_id = wext_get_hardware_id, .bssid = wext_get_bssid,
.hardware_name = wext_get_hardware_name, .country = wext_get_country,
.encryption = wext_get_encryption, .hardware_id = wext_get_hardware_id,
.assoclist = wext_get_assoclist, .hardware_name = wext_get_hardware_name,
.txpwrlist = wext_get_txpwrlist, .encryption = wext_get_encryption,
.scanlist = wext_get_scanlist, .assoclist = wext_get_assoclist,
.freqlist = wext_get_freqlist, .txpwrlist = wext_get_txpwrlist,
.countrylist = wext_get_countrylist, .scanlist = wext_get_scanlist,
.close = wext_close .freqlist = wext_get_freqlist,
.countrylist = wext_get_countrylist,
.close = wext_close
}; };
#endif #endif

View File

@ -32,7 +32,9 @@ int wl_get_bssid(const char *ifname, char *buf);
int wl_get_country(const char *ifname, char *buf); int wl_get_country(const char *ifname, char *buf);
int wl_get_channel(const char *ifname, int *buf); int wl_get_channel(const char *ifname, int *buf);
int wl_get_frequency(const char *ifname, int *buf); int wl_get_frequency(const char *ifname, int *buf);
int wl_get_frequency_offset(const char *ifname, int *buf);
int wl_get_txpower(const char *ifname, int *buf); int wl_get_txpower(const char *ifname, int *buf);
int wl_get_txpower_offset(const char *ifname, int *buf);
int wl_get_bitrate(const char *ifname, int *buf); int wl_get_bitrate(const char *ifname, int *buf);
int wl_get_signal(const char *ifname, int *buf); int wl_get_signal(const char *ifname, int *buf);
int wl_get_noise(const char *ifname, int *buf); int wl_get_noise(const char *ifname, int *buf);
@ -52,29 +54,31 @@ int wl_get_hardware_name(const char *ifname, char *buf);
void wl_close(void); void wl_close(void);
static const struct iwinfo_ops wl_ops = { static const struct iwinfo_ops wl_ops = {
.channel = wl_get_channel, .channel = wl_get_channel,
.frequency = wl_get_frequency, .frequency = wl_get_frequency,
.txpower = wl_get_txpower, .frequency_offset = wl_get_frequency_offset,
.bitrate = wl_get_bitrate, .txpower = wl_get_txpower,
.signal = wl_get_signal, .txpower_offset = wl_get_txpower_offset,
.noise = wl_get_noise, .bitrate = wl_get_bitrate,
.quality = wl_get_quality, .signal = wl_get_signal,
.quality_max = wl_get_quality_max, .noise = wl_get_noise,
.mbssid_support = wl_get_mbssid_support, .quality = wl_get_quality,
.hwmodelist = wl_get_hwmodelist, .quality_max = wl_get_quality_max,
.mode = wl_get_mode, .mbssid_support = wl_get_mbssid_support,
.ssid = wl_get_ssid, .hwmodelist = wl_get_hwmodelist,
.bssid = wl_get_bssid, .mode = wl_get_mode,
.country = wl_get_country, .ssid = wl_get_ssid,
.hardware_id = wl_get_hardware_id, .bssid = wl_get_bssid,
.hardware_name = wl_get_hardware_name, .country = wl_get_country,
.encryption = wl_get_encryption, .hardware_id = wl_get_hardware_id,
.assoclist = wl_get_assoclist, .hardware_name = wl_get_hardware_name,
.txpwrlist = wl_get_txpwrlist, .encryption = wl_get_encryption,
.scanlist = wl_get_scanlist, .assoclist = wl_get_assoclist,
.freqlist = wl_get_freqlist, .txpwrlist = wl_get_txpwrlist,
.countrylist = wl_get_countrylist, .scanlist = wl_get_scanlist,
.close = wl_close .freqlist = wl_get_freqlist,
.countrylist = wl_get_countrylist,
.close = wl_close
}; };
#endif #endif

View File

@ -311,6 +311,36 @@ static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifnam
return buf; return buf;
} }
static char * print_txpower_offset(const struct iwinfo_ops *iw, const char *ifname)
{
int off;
static char buf[12];
if (iw->txpower_offset(ifname, &off))
snprintf(buf, sizeof(buf), "unknown");
else if (off != 0)
snprintf(buf, sizeof(buf), "%d dB", off);
else
snprintf(buf, sizeof(buf), "none");
return buf;
}
static char * print_frequency_offset(const struct iwinfo_ops *iw, const char *ifname)
{
int off;
static char buf[12];
if (iw->frequency_offset(ifname, &off))
snprintf(buf, sizeof(buf), "unknown");
else if (off != 0)
snprintf(buf, sizeof(buf), "%.3f GHz", ((float)off / 1000.0));
else
snprintf(buf, sizeof(buf), "none");
return buf;
}
static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname) static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
{ {
char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 }; char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
@ -473,6 +503,10 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
printf(" Hardware: %s [%s]\n", printf(" Hardware: %s [%s]\n",
print_hardware_id(iw, ifname), print_hardware_id(iw, ifname),
print_hardware_name(iw, ifname)); print_hardware_name(iw, ifname));
printf(" TX power offset: %s\n",
print_txpower_offset(iw, ifname));
printf(" Frequency offset: %s\n",
print_frequency_offset(iw, ifname));
printf(" Supports VAPs: %s\n", printf(" Supports VAPs: %s\n",
print_mbssid_supp(iw, ifname)); print_mbssid_supp(iw, ifname));
} }

View File

@ -347,7 +347,7 @@ const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
{ VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 10, 0 }, { VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 10, 0 },
{ VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 10, 0 }, { VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 10, 0 },
#endif #endif
#ifdef NL80211 #ifdef USE_NL80211
{ VENDOR_UBNT, "NanoStation M2", 0x168c, 0x002a, 0x0777, 0xe012, 10, 0 }, /* ToDo: confirm offset */ { VENDOR_UBNT, "NanoStation M2", 0x168c, 0x002a, 0x0777, 0xe012, 10, 0 }, /* ToDo: confirm offset */
{ VENDOR_UBNT, "NanoStation M5", 0x168c, 0x002a, 0x0777, 0xe005, 5, 0 }, /* ToDo: confirm offset */ { VENDOR_UBNT, "NanoStation M5", 0x168c, 0x002a, 0x0777, 0xe005, 5, 0 }, /* ToDo: confirm offset */
{ VENDOR_UBNT, "Bullet M2", 0x168c, 0x002a, 0x0777, 0xe202, 12, 0 }, { VENDOR_UBNT, "Bullet M2", 0x168c, 0x002a, 0x0777, 0xe202, 12, 0 },

View File

@ -558,7 +558,9 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *,
/* Broadcom */ /* Broadcom */
LUA_WRAP_INT(wl,channel) LUA_WRAP_INT(wl,channel)
LUA_WRAP_INT(wl,frequency) LUA_WRAP_INT(wl,frequency)
LUA_WRAP_INT(wl,frequency_offset)
LUA_WRAP_INT(wl,txpower) LUA_WRAP_INT(wl,txpower)
LUA_WRAP_INT(wl,txpower_offset)
LUA_WRAP_INT(wl,bitrate) LUA_WRAP_INT(wl,bitrate)
LUA_WRAP_INT(wl,signal) LUA_WRAP_INT(wl,signal)
LUA_WRAP_INT(wl,noise) LUA_WRAP_INT(wl,noise)
@ -584,7 +586,9 @@ LUA_WRAP_STRUCT(wl,hardware_id)
/* Madwifi */ /* Madwifi */
LUA_WRAP_INT(madwifi,channel) LUA_WRAP_INT(madwifi,channel)
LUA_WRAP_INT(madwifi,frequency) LUA_WRAP_INT(madwifi,frequency)
LUA_WRAP_INT(madwifi,frequency_offset)
LUA_WRAP_INT(madwifi,txpower) LUA_WRAP_INT(madwifi,txpower)
LUA_WRAP_INT(madwifi,txpower_offset)
LUA_WRAP_INT(madwifi,bitrate) LUA_WRAP_INT(madwifi,bitrate)
LUA_WRAP_INT(madwifi,signal) LUA_WRAP_INT(madwifi,signal)
LUA_WRAP_INT(madwifi,noise) LUA_WRAP_INT(madwifi,noise)
@ -610,7 +614,9 @@ LUA_WRAP_STRUCT(madwifi,hardware_id)
/* NL80211 */ /* NL80211 */
LUA_WRAP_INT(nl80211,channel) LUA_WRAP_INT(nl80211,channel)
LUA_WRAP_INT(nl80211,frequency) LUA_WRAP_INT(nl80211,frequency)
LUA_WRAP_INT(nl80211,frequency_offset)
LUA_WRAP_INT(nl80211,txpower) LUA_WRAP_INT(nl80211,txpower)
LUA_WRAP_INT(nl80211,txpower_offset)
LUA_WRAP_INT(nl80211,bitrate) LUA_WRAP_INT(nl80211,bitrate)
LUA_WRAP_INT(nl80211,signal) LUA_WRAP_INT(nl80211,signal)
LUA_WRAP_INT(nl80211,noise) LUA_WRAP_INT(nl80211,noise)
@ -635,7 +641,9 @@ LUA_WRAP_STRUCT(nl80211,hardware_id)
/* Wext */ /* Wext */
LUA_WRAP_INT(wext,channel) LUA_WRAP_INT(wext,channel)
LUA_WRAP_INT(wext,frequency) LUA_WRAP_INT(wext,frequency)
LUA_WRAP_INT(wext,frequency_offset)
LUA_WRAP_INT(wext,txpower) LUA_WRAP_INT(wext,txpower)
LUA_WRAP_INT(wext,txpower_offset)
LUA_WRAP_INT(wext,bitrate) LUA_WRAP_INT(wext,bitrate)
LUA_WRAP_INT(wext,signal) LUA_WRAP_INT(wext,signal)
LUA_WRAP_INT(wext,noise) LUA_WRAP_INT(wext,noise)
@ -661,7 +669,9 @@ LUA_WRAP_STRUCT(wext,hardware_id)
static const luaL_reg R_wl[] = { static const luaL_reg R_wl[] = {
LUA_REG(wl,channel), LUA_REG(wl,channel),
LUA_REG(wl,frequency), LUA_REG(wl,frequency),
LUA_REG(wl,frequency_offset),
LUA_REG(wl,txpower), LUA_REG(wl,txpower),
LUA_REG(wl,txpower_offset),
LUA_REG(wl,bitrate), LUA_REG(wl,bitrate),
LUA_REG(wl,signal), LUA_REG(wl,signal),
LUA_REG(wl,noise), LUA_REG(wl,noise),
@ -690,7 +700,9 @@ static const luaL_reg R_wl[] = {
static const luaL_reg R_madwifi[] = { static const luaL_reg R_madwifi[] = {
LUA_REG(madwifi,channel), LUA_REG(madwifi,channel),
LUA_REG(madwifi,frequency), LUA_REG(madwifi,frequency),
LUA_REG(madwifi,frequency_offset),
LUA_REG(madwifi,txpower), LUA_REG(madwifi,txpower),
LUA_REG(madwifi,txpower_offset),
LUA_REG(madwifi,bitrate), LUA_REG(madwifi,bitrate),
LUA_REG(madwifi,signal), LUA_REG(madwifi,signal),
LUA_REG(madwifi,noise), LUA_REG(madwifi,noise),
@ -719,7 +731,9 @@ static const luaL_reg R_madwifi[] = {
static const luaL_reg R_nl80211[] = { static const luaL_reg R_nl80211[] = {
LUA_REG(nl80211,channel), LUA_REG(nl80211,channel),
LUA_REG(nl80211,frequency), LUA_REG(nl80211,frequency),
LUA_REG(nl80211,frequency_offset),
LUA_REG(nl80211,txpower), LUA_REG(nl80211,txpower),
LUA_REG(nl80211,txpower_offset),
LUA_REG(nl80211,bitrate), LUA_REG(nl80211,bitrate),
LUA_REG(nl80211,signal), LUA_REG(nl80211,signal),
LUA_REG(nl80211,noise), LUA_REG(nl80211,noise),
@ -747,7 +761,9 @@ static const luaL_reg R_nl80211[] = {
static const luaL_reg R_wext[] = { static const luaL_reg R_wext[] = {
LUA_REG(wext,channel), LUA_REG(wext,channel),
LUA_REG(wext,frequency), LUA_REG(wext,frequency),
LUA_REG(wext,frequency_offset),
LUA_REG(wext,txpower), LUA_REG(wext,txpower),
LUA_REG(wext,txpower_offset),
LUA_REG(wext,bitrate), LUA_REG(wext,bitrate),
LUA_REG(wext,signal), LUA_REG(wext,signal),
LUA_REG(wext,noise), LUA_REG(wext,noise),

View File

@ -1060,20 +1060,59 @@ int madwifi_get_hardware_id(const char *ifname, char *buf)
return 0; return 0;
} }
int madwifi_get_hardware_name(const char *ifname, char *buf) static const struct iwinfo_hardware_entry *
madwifi_get_hardware_entry(const char *ifname)
{ {
struct iwinfo_hardware_id id; struct iwinfo_hardware_id id;
struct iwinfo_hardware_entry *hw;
if (madwifi_get_hardware_id(ifname, (char *)&id)) if (madwifi_get_hardware_id(ifname, (char *)&id))
return -1; return NULL;
hw = iwinfo_hardware(&id); return iwinfo_hardware(&id);
}
if (hw) int madwifi_get_hardware_name(const char *ifname, char *buf)
sprintf(buf, "%s %s", hw->vendor_name, hw->device_name); {
char vendor[64];
char device[64];
const struct iwinfo_hardware_entry *hw;
if (!(hw = madwifi_get_hardware_entry(ifname)))
{
madwifi_proc_file(ifname, "dev_vendor", vendor, sizeof(vendor));
madwifi_proc_file(ifname, "dev_name", device, sizeof(device));
if (vendor[0] && device[0])
sprintf(buf, "%s %s", vendor, device);
else
sprintf(buf, "Generic Atheros");
}
else else
sprintf(buf, "Generic Atheros"); {
sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
}
return 0; return 0;
} }
int madwifi_get_txpower_offset(const char *ifname, int *buf)
{
const struct iwinfo_hardware_entry *hw;
if (!(hw = madwifi_get_hardware_entry(ifname)))
return -1;
*buf = hw->txpower_offset;
return 0;
}
int madwifi_get_frequency_offset(const char *ifname, int *buf)
{
const struct iwinfo_hardware_entry *hw;
if (!(hw = madwifi_get_hardware_entry(ifname)))
return -1;
*buf = hw->frequency_offset;
return 0;
}

View File

@ -1634,20 +1634,47 @@ int nl80211_get_hardware_id(const char *ifname, char *buf)
return wext_get_hardware_id(ifname, buf); return wext_get_hardware_id(ifname, buf);
} }
int nl80211_get_hardware_name(const char *ifname, char *buf) static const struct iwinfo_hardware_entry *
nl80211_get_hardware_entry(const char *ifname)
{ {
struct iwinfo_hardware_id id; struct iwinfo_hardware_id id;
struct iwinfo_hardware_entry *hw;
if (nl80211_get_hardware_id(ifname, (char *)&id)) if (nl80211_get_hardware_id(ifname, (char *)&id))
return -1; return NULL;
hw = iwinfo_hardware(&id); return iwinfo_hardware(&id);
}
if (hw) int nl80211_get_hardware_name(const char *ifname, char *buf)
sprintf(buf, "%s %s", hw->vendor_name, hw->device_name); {
else const struct iwinfo_hardware_entry *hw;
if (!(hw = nl80211_get_hardware_entry(ifname)))
sprintf(buf, "Generic MAC80211"); sprintf(buf, "Generic MAC80211");
else
sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
return 0; return 0;
} }
int nl80211_get_txpower_offset(const char *ifname, int *buf)
{
const struct iwinfo_hardware_entry *hw;
if (!(hw = nl80211_get_hardware_entry(ifname)))
return -1;
*buf = hw->txpower_offset;
return 0;
}
int nl80211_get_frequency_offset(const char *ifname, int *buf)
{
const struct iwinfo_hardware_entry *hw;
if (!(hw = nl80211_get_hardware_entry(ifname)))
return -1;
*buf = hw->frequency_offset;
return 0;
}

View File

@ -515,3 +515,17 @@ int wext_get_hardware_name(const char *ifname, char *buf)
sprintf(buf, "Generic WEXT"); sprintf(buf, "Generic WEXT");
return 0; return 0;
} }
int wext_get_txpower_offset(const char *ifname, int *buf)
{
/* Stub */
*buf = 0;
return -1;
}
int wext_get_frequency_offset(const char *ifname, int *buf)
{
/* Stub */
*buf = 0;
return -1;
}

View File

@ -585,3 +585,28 @@ int wl_get_hardware_name(const char *ifname, char *buf)
return 0; return 0;
} }
int wl_get_txpower_offset(const char *ifname, int *buf)
{
FILE *p;
char off[8];
*buf = 0;
if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
{
if (fread(off, 1, sizeof(off), p))
*buf = strtoul(off, NULL, 16);
pclose(p);
}
return 0;
}
int wl_get_frequency_offset(const char *ifname, int *buf)
{
/* Stub */
*buf = 0;
return -1;
}