dbus: Change BSS property MaxRate to Rates
Instead of exposing maximum BSS bit rate, expose sorted array of all supported rates.
This commit is contained in:
parent
58e1452474
commit
75d328af50
7 changed files with 75 additions and 18 deletions
|
@ -644,8 +644,8 @@ scan results.
|
|||
<p>Frequency of the BSS in MHz.</p>
|
||||
</li>
|
||||
<li>
|
||||
<h3>MaxRate - q - (read)</h3>
|
||||
<p>Maximal data rate of the BSS in bits per second.</p>
|
||||
<h3>Rates - au - (read)</h3>
|
||||
<p>Descending ordered array of rates supported by the BSS in bits per second.</p>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Signal - n - (read)</h3>
|
||||
|
|
|
@ -434,3 +434,27 @@ int wpa_bss_get_max_rate(const struct wpa_bss *bss)
|
|||
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates)
|
||||
{
|
||||
const u8 *ie, *ie2;
|
||||
int i, j, len;
|
||||
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
|
||||
ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
|
||||
|
||||
len = (ie ? ie[1] : 0) + (ie2 ? ie2[1] : 0);
|
||||
|
||||
*rates = os_malloc(len);
|
||||
if (!rates)
|
||||
return -1;
|
||||
|
||||
for (i = 0; ie && i < ie[1]; i++)
|
||||
(*rates)[i] = ie[i + 2] & 0x7f;
|
||||
|
||||
for (j = 0; ie2 && j < ie2[1]; j++)
|
||||
(*rates)[i + j] = ie2[j + 2] & 0x7f;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ struct wpa_scan_res;
|
|||
* @noise: noise level
|
||||
* @level: signal level
|
||||
* @tsf: Timestamp of last Beacon/Probe Response frame
|
||||
* @last_update: Time of the last update (i.e., Beacon or Probe Response RX)
|
||||
* @last_update: Time of the last update (i.e., Beacon or Probe Response RX)
|
||||
* @ie_len: length of the following IE field in octets
|
||||
*
|
||||
* This structure is used to store information about neighboring BSSes in
|
||||
|
@ -85,5 +85,6 @@ const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
|
|||
struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
|
||||
u32 vendor_type);
|
||||
int wpa_bss_get_max_rate(const struct wpa_bss *bss);
|
||||
int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates);
|
||||
|
||||
#endif /* BSS_H */
|
||||
|
|
|
@ -1072,8 +1072,8 @@ static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
|
|||
NULL,
|
||||
R
|
||||
},
|
||||
{ "MaxRate", WPAS_DBUS_NEW_IFACE_BSSID, "q",
|
||||
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_max_rate,
|
||||
{ "Rates", WPAS_DBUS_NEW_IFACE_BSSID, "au",
|
||||
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_rates,
|
||||
NULL,
|
||||
R
|
||||
},
|
||||
|
|
|
@ -2505,29 +2505,58 @@ DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
|
|||
}
|
||||
|
||||
|
||||
static int cmp_u8s_desc(const void *a, const void *b)
|
||||
{
|
||||
return (*(u8 *) b - *(u8 *) a);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpas_dbus_getter_bss_max_rate - Return the maximal rate of a BSS
|
||||
* wpas_dbus_getter_bss_rates - Return available bit rates of a BSS
|
||||
* @message: Pointer to incoming dbus message
|
||||
* @bss: a pair of interface describing structure and bss's id
|
||||
* Returns: a dbus message containing the maximal data rate of requested bss
|
||||
* Returns: a dbus message containing sorted array of bit rates
|
||||
*
|
||||
* Getter for "MaxRate" property.
|
||||
* Getter for "Rates" property.
|
||||
*/
|
||||
DBusMessage * wpas_dbus_getter_bss_max_rate(DBusMessage *message,
|
||||
DBusMessage * wpas_dbus_getter_bss_rates(DBusMessage *message,
|
||||
struct bss_handler_args *bss)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
|
||||
int max_rate;
|
||||
u8 *ie_rates = NULL;
|
||||
u32 *real_rates;
|
||||
int rates_num, i;
|
||||
|
||||
if (!res) {
|
||||
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_max_rate[dbus]: "
|
||||
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rates[dbus]: "
|
||||
"no bss with id %d found", bss->id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
max_rate = wpa_bss_get_max_rate(res);
|
||||
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
|
||||
&max_rate);
|
||||
rates_num = wpa_bss_get_bit_rates(res, &ie_rates);
|
||||
if (rates_num < 0)
|
||||
return NULL;
|
||||
|
||||
qsort(ie_rates, rates_num, 1, cmp_u8s_desc);
|
||||
|
||||
real_rates = os_malloc(sizeof(u32) * rates_num);
|
||||
if (!real_rates) {
|
||||
os_free(ie_rates);
|
||||
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < rates_num; i++)
|
||||
real_rates[i] = ie_rates[i] * 500000;
|
||||
|
||||
reply = wpas_dbus_simple_array_property_getter(message,
|
||||
DBUS_TYPE_UINT32,
|
||||
real_rates, rates_num);
|
||||
|
||||
os_free(ie_rates);
|
||||
os_free(real_rates);
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ DBusMessage * wpas_dbus_getter_bss_signal(DBusMessage *message,
|
|||
DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
|
||||
struct bss_handler_args *bss);
|
||||
|
||||
DBusMessage * wpas_dbus_getter_bss_max_rate(DBusMessage *message,
|
||||
struct bss_handler_args *bss);
|
||||
DBusMessage * wpas_dbus_getter_bss_rates(DBusMessage *message,
|
||||
struct bss_handler_args *bss);
|
||||
|
||||
DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
|
||||
struct bss_handler_args *bss);
|
||||
|
|
|
@ -66,9 +66,12 @@ def showBss(bss):
|
|||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
signal = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Signal',
|
||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
val = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'MaxRate',
|
||||
val = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Rates',
|
||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
maxrate = val / 1000000
|
||||
if len(val) > 0:
|
||||
maxrate = val[0] / 1000000
|
||||
else:
|
||||
maxrate = 0
|
||||
|
||||
print " %s :: ssid='%s' wpa=%s wpa2=%s signal=%d rate=%d freq=%d" % (bssid, ssid, wpa, wpa2, signal, maxrate, freq)
|
||||
|
||||
|
|
Loading…
Reference in a new issue