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>
|
<p>Frequency of the BSS in MHz.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<h3>MaxRate - q - (read)</h3>
|
<h3>Rates - au - (read)</h3>
|
||||||
<p>Maximal data rate of the BSS in bits per second.</p>
|
<p>Descending ordered array of rates supported by the BSS in bits per second.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<h3>Signal - n - (read)</h3>
|
<h3>Signal - n - (read)</h3>
|
||||||
|
|
|
@ -434,3 +434,27 @@ int wpa_bss_get_max_rate(const struct wpa_bss *bss)
|
||||||
|
|
||||||
return rate;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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,
|
struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
|
||||||
u32 vendor_type);
|
u32 vendor_type);
|
||||||
int wpa_bss_get_max_rate(const struct wpa_bss *bss);
|
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 */
|
#endif /* BSS_H */
|
||||||
|
|
|
@ -1072,8 +1072,8 @@ static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
|
||||||
NULL,
|
NULL,
|
||||||
R
|
R
|
||||||
},
|
},
|
||||||
{ "MaxRate", WPAS_DBUS_NEW_IFACE_BSSID, "q",
|
{ "Rates", WPAS_DBUS_NEW_IFACE_BSSID, "au",
|
||||||
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_max_rate,
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_rates,
|
||||||
NULL,
|
NULL,
|
||||||
R
|
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
|
* @message: Pointer to incoming dbus message
|
||||||
* @bss: a pair of interface describing structure and bss's id
|
* @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)
|
struct bss_handler_args *bss)
|
||||||
{
|
{
|
||||||
|
DBusMessage *reply;
|
||||||
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
|
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) {
|
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);
|
"no bss with id %d found", bss->id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_rate = wpa_bss_get_max_rate(res);
|
rates_num = wpa_bss_get_bit_rates(res, &ie_rates);
|
||||||
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
|
if (rates_num < 0)
|
||||||
&max_rate);
|
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,
|
DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
|
||||||
struct bss_handler_args *bss);
|
struct bss_handler_args *bss);
|
||||||
|
|
||||||
DBusMessage * wpas_dbus_getter_bss_max_rate(DBusMessage *message,
|
DBusMessage * wpas_dbus_getter_bss_rates(DBusMessage *message,
|
||||||
struct bss_handler_args *bss);
|
struct bss_handler_args *bss);
|
||||||
|
|
||||||
DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
|
DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
|
||||||
struct bss_handler_args *bss);
|
struct bss_handler_args *bss);
|
||||||
|
|
|
@ -66,9 +66,12 @@ def showBss(bss):
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
signal = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Signal',
|
signal = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Signal',
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
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)
|
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)
|
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