dbus: Emit more information over D-Bus

Allows informing the connection manager of additional information on CQM
events. Allows the connection manager to request the same information
on demand by using the existing "SignalPoll" method.

* Add new property "SignalChange"
        * Add storage for wpa_signal_info into wpa_supplicant context
          object
        * Copy memory from event to context object on CQM Event
* Write a common conversion method to be used by both "SignalPoll" and
  this property

Signed-off-by: David Ruth <druth@chromium.org>
This commit is contained in:
David Ruth 2022-11-30 23:33:10 +00:00 committed by Jouni Malinen
parent ad4fa5dd3c
commit 7a7ce95746
13 changed files with 235 additions and 27 deletions

View file

@ -647,6 +647,33 @@ fi.w1.wpa_supplicant1.CreateInterface.
<tr><td>avg-rssi</td><td>i</td><td>Average RSSI (dBm)</td><td>No</td>
<tr><td>center-frq1</td><td>i</td><td>VHT segment 1 frequency (MHz)</td><td>No</td>
<tr><td>center-frq2</td><td>i</td><td>VHT segment 2 frequency (MHz)</td><td>No</td>
<tr><td>rx-bytes</td><td>i</td><td>Bytes recieved</td><td>No</td>
<tr><td>tx-bytes</td><td>i</td><td>Bytes sent</td><td>No</td>
<tr><td>rx-packets</td><td>i</td><td>Packets recieved</td><td>No</td>
<tr><td>tx-packets</td><td>i</td><td>Packets sent</td><td>No</td>
<tr><td>beacons</td><td>i</td><td>Beacons received</td><td>No</td>
<tr><td>linkrxspeed</td><td>i</td><td>Link Speed (RX, kbps)</td><td>No</td>
<tr><td>linktxspeed</td><td>i</td><td>Link Speed (TX, kbps)</td><td>No</td>
<tr><td>retries-failed</td><td>i</td><td>Retries (failed)</td><td>No</td>
<tr><td>retries</td><td>i</td><td>Retries</td><td>No</td>
<tr><td>last-ack-rssi</td><td>i</td><td>RSSI of last ACK frame (dBm)</td><td>No</td>
<tr><td>fcs-errors</td><td>i</td><td>FCS errors</td><td>No</td>
<tr><td>beacon-losses</td><td>i</td><td>Beacons lost</td><td>No</td>
<tr><td>expected-throughput</td><td>i</td><td>Expected Throughput (kbps)</td><td>No</td>
<tr><td>rx-drop-misc</td><td>i</td><td>RX packets dropped for unspecified reasons</td><td>No</td>
<tr><td>rx-mpdus</td><td>i</td><td>Recieved packets</td><td>No</td>
<tr><td>rx-he-mcs</td><td>i</td><td>MCS index (rx, he)</td><td>No</td>
<tr><td>tx-he-mcs</td><td>i</td><td>MCS index (tx, he)</td><td>No</td>
<tr><td>rx-vht-mcs</td><td>i</td><td>MCS index (rx, vht)</td><td>No</td>
<tr><td>tx-vht-mcs</td><td>i</td><td>MCS index (tx, vht)</td><td>No</td>
<tr><td>rx-mcs</td><td>i</td><td>MCS index (rx)</td><td>No</td>
<tr><td>tx-mcs</td><td>i</td><td>MCS index (tx)</td><td>No</td>
<tr><td>rx-he-nss</td><td>i</td><td>Number of streams (rx, he)</td><td>No</td>
<tr><td>tx-he-nss</td><td>i</td><td>Number of streams (tx, he)</td><td>No</td>
<tr><td>rx-vht-nss</td><td>i</td><td>Number of streams (rx, vht)</td><td>No</td>
<tr><td>tx-vht-nss</td><td>i</td><td>Number of streams (tx, vht)</td><td>No</td>
<tr><td>avg-beacon-rssi</td><td>i</td><td>Average Beacon RSSI (dBm)</td><td>No</td>
<tr><td>avg-ack-rssi</td><td>i</td><td>Average ACK frame RSSI (dBm)</td><td>No</td>
</table>
</dd>
</dl>
@ -1244,7 +1271,7 @@ fi.w1.wpa_supplicant1.CreateInterface.
<h4>Arguments</h4>
<dl>
<dt>a{sv} : properties</dt>
<dd>A dictionary with pairs of properties names which have changed and theirs new values. Possible dictionary keys are: "ApScan", "Scanning", "State", "CurrentBSS", "CurrentNetwork"</dd>
<dd>A dictionary with pairs of properties names which have changed and their new values. Possible dictionary keys are: "ApScan", "Scanning", "State", "CurrentBSS", "CurrentNetwork", "SignalChange"</dd>
</dl>
</li>

View file

@ -298,6 +298,25 @@ dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
}
/**
* Add a 64-bit unsigned integer entry to the dict.
*
* @param iter_dict A valid DBusMessageIter returned from
* wpa_dbus_dict_open_write()
* @param key The key of the dict item
* @param value The 64-bit unsigned integer value
* @return TRUE on success, FALSE on failure
*
*/
dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
const char *key,
const dbus_uint64_t value)
{
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT64,
&value);
}
/**
* Add a DBus object path entry to the dict.
*

View file

@ -46,6 +46,10 @@ dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
const char *key,
const dbus_uint32_t value);
dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
const char *key,
const dbus_uint64_t value);
dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
const char *key,
const char *value);

View file

@ -2347,6 +2347,9 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
case WPAS_DBUS_PROP_MAC_ADDRESS:
prop = "MACAddress";
break;
case WPAS_DBUS_PROP_SIGNAL_CHANGE:
prop = "SignalChange";
break;
default:
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
__func__, property);
@ -4529,6 +4532,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
NULL,
NULL
},
{ "SignalChange", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
wpas_dbus_getter_signal_change,
NULL,
NULL
},
{ NULL, NULL, NULL, NULL, NULL, NULL }
};

View file

@ -39,6 +39,7 @@ enum wpas_dbus_prop {
WPAS_DBUS_PROP_SESSION_LENGTH,
WPAS_DBUS_PROP_BSS_TM_STATUS,
WPAS_DBUS_PROP_MAC_ADDRESS,
WPAS_DBUS_PROP_SIGNAL_CHANGE,
};
enum wpas_dbus_bss_prop {

View file

@ -1950,7 +1950,7 @@ DBusMessage * wpas_dbus_handler_signal_poll(DBusMessage *message,
{
struct wpa_signal_info si;
DBusMessage *reply = NULL;
DBusMessageIter iter, iter_dict, variant_iter;
DBusMessageIter iter;
int ret;
ret = wpa_drv_signal_poll(wpa_s, &si);
@ -1965,31 +1965,7 @@ DBusMessage * wpas_dbus_handler_signal_poll(DBusMessage *message,
dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
"a{sv}", &variant_iter) ||
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict) ||
!wpa_dbus_dict_append_int32(&iter_dict, "rssi",
si.data.signal) ||
!wpa_dbus_dict_append_int32(&iter_dict, "linkspeed",
si.data.current_tx_rate / 1000) ||
!wpa_dbus_dict_append_int32(&iter_dict, "noise",
si.current_noise) ||
!wpa_dbus_dict_append_uint32(&iter_dict, "frequency",
si.frequency) ||
(si.chanwidth != CHAN_WIDTH_UNKNOWN &&
!wpa_dbus_dict_append_string(
&iter_dict, "width",
channel_width_to_string(si.chanwidth))) ||
(si.center_frq1 > 0 && si.center_frq2 > 0 &&
(!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
si.center_frq1) ||
!wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
si.center_frq2))) ||
(si.data.avg_signal &&
!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
si.data.avg_signal)) ||
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
!dbus_message_iter_close_container(&iter, &variant_iter))
if (wpas_dbus_new_from_signal_information(&iter, &si) != 0)
goto nomem;
return reply;
@ -6120,3 +6096,28 @@ dbus_bool_t wpas_dbus_getter_mesh_group(
}
#endif /* CONFIG_MESH */
/**
* wpas_dbus_getter_signal_change - Get signal change
* @iter: Pointer to incoming dbus message iter
* @error: Location to store error on failure
* @user_data: Function specific data
* Returns: TRUE on success, FALSE on failure
*
* Getter for "SignalChange" property.
*/
dbus_bool_t wpas_dbus_getter_signal_change(
const struct wpa_dbus_property_desc *property_desc,
DBusMessageIter *iter, DBusError *error, void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
struct wpa_signal_info si = wpa_s->last_signal_info;
if (wpas_dbus_new_from_signal_information(iter, &si) != 0) {
dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: error constructing reply", __func__);
return FALSE;
}
return TRUE;
}

View file

@ -247,6 +247,8 @@ DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_device_type);
DECLARE_ACCESSOR(wpas_dbus_getter_mesh_peers);
DECLARE_ACCESSOR(wpas_dbus_getter_mesh_group);
DECLARE_ACCESSOR(wpas_dbus_getter_signal_change);
DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_tdls_setup(DBusMessage *message,

View file

@ -11,6 +11,7 @@
#include "utils/common.h"
#include "utils/eloop.h"
#include "drivers/driver.h"
#include "dbus_common.h"
#include "dbus_common_i.h"
#include "dbus_new.h"
@ -1023,3 +1024,131 @@ DBusMessage * wpas_dbus_reply_new_from_error(DBusMessage *message,
}
return NULL;
}
/**
* wpas_dbus_new_from_signal_information - Adds a wpa_signal_info
* to a DBusMessage.
* @msg: Pointer to message to append fields to
* @si: Pointer to wpa_signal_info to add to the message
* Returns: 0 on success, otherwise, an errorcode
*
* Adds all the pertinent fields from a wpa_signal_info to a DBusMessage.
* The same logic is useful in both responding to signal_poll calls, and
* sending signal_change signals.
*/
int wpas_dbus_new_from_signal_information(DBusMessageIter *iter,
struct wpa_signal_info *si)
{
DBusMessageIter iter_dict, variant_iter;
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
"a{sv}", &variant_iter) ||
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict) ||
!wpa_dbus_dict_append_int32(&iter_dict, "rssi",
si->data.signal) ||
!wpa_dbus_dict_append_uint32(&iter_dict, "linkspeed",
si->data.current_tx_rate / 1000) ||
!wpa_dbus_dict_append_int32(&iter_dict, "noise",
si->current_noise) ||
!wpa_dbus_dict_append_uint32(&iter_dict, "frequency",
si->frequency) ||
(si->chanwidth != CHAN_WIDTH_UNKNOWN &&
!wpa_dbus_dict_append_string(
&iter_dict, "width",
channel_width_to_string(si->chanwidth))) ||
(si->center_frq1 > 0 && si->center_frq2 > 0 &&
(!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
si->center_frq1) ||
!wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
si->center_frq2))) ||
(si->data.avg_signal &&
!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
si->data.avg_signal)) ||
(si->data.rx_bytes &&
!wpa_dbus_dict_append_uint64(&iter_dict, "rx-bytes",
si->data.rx_bytes)) ||
(si->data.tx_bytes &&
!wpa_dbus_dict_append_uint64(&iter_dict, "tx-bytes",
si->data.tx_bytes)) ||
(si->data.rx_packets &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-packets",
si->data.rx_packets)) ||
(si->data.tx_packets &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-packets",
si->data.tx_packets)) ||
(si->data.beacons_count &&
!wpa_dbus_dict_append_uint64(&iter_dict, "beacons",
si->data.beacons_count)) ||
(si->data.current_rx_rate &&
!wpa_dbus_dict_append_uint32(&iter_dict, "linkrxspeed",
si->data.current_rx_rate)) ||
(si->data.current_rx_rate &&
!wpa_dbus_dict_append_uint32(&iter_dict, "linktxspeed",
si->data.current_tx_rate)) ||
(si->data.tx_retry_failed &&
!wpa_dbus_dict_append_uint32(&iter_dict, "retries-failed",
si->data.tx_retry_failed)) ||
(si->data.tx_retry_count &&
!wpa_dbus_dict_append_uint32(&iter_dict, "retries",
si->data.tx_retry_count)) ||
(si->data.last_ack_rssi &&
!wpa_dbus_dict_append_int32(&iter_dict, "last-ack-rssi",
si->data.last_ack_rssi)) ||
(si->data.fcs_error_count &&
!wpa_dbus_dict_append_uint32(&iter_dict, "fcs-errors",
si->data.fcs_error_count)) ||
(si->data.beacon_loss_count &&
!wpa_dbus_dict_append_uint32(&iter_dict, "beacon-losses",
si->data.beacon_loss_count)) ||
(si->data.expected_throughput &&
!wpa_dbus_dict_append_uint32(&iter_dict, "expected-throughput",
si->data.expected_throughput)) ||
(si->data.rx_drop_misc &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-drop-misc",
si->data.rx_drop_misc)) ||
(si->data.rx_mpdus &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-mpdus",
si->data.rx_mpdus)) ||
(si->data.rx_hemcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-he-mcs",
si->data.rx_hemcs)) ||
(si->data.tx_hemcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-he-mcs",
si->data.tx_hemcs)) ||
(si->data.rx_vhtmcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-vht-mcs",
si->data.rx_vhtmcs)) ||
(si->data.tx_vhtmcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-vht-mcs",
si->data.tx_vhtmcs)) ||
(si->data.rx_mcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-mcs",
si->data.rx_mcs)) ||
(si->data.tx_mcs &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-mcs",
si->data.tx_mcs)) ||
(si->data.rx_he_nss &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-he-nss",
si->data.rx_he_nss)) ||
(si->data.tx_he_nss &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-he-nss",
si->data.tx_he_nss)) ||
(si->data.rx_vht_nss &&
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-vht-nss",
si->data.rx_vht_nss)) ||
(si->data.tx_vht_nss &&
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-vht-nss",
si->data.tx_vht_nss)) ||
(si->data.avg_beacon_signal &&
!wpa_dbus_dict_append_int32(&iter_dict, "avg-beacon-rssi",
si->data.avg_beacon_signal)) ||
(si->data.avg_ack_signal &&
!wpa_dbus_dict_append_int32(&iter_dict, "avg-ack-rssi",
si->data.avg_ack_signal)) ||
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
!dbus_message_iter_close_container(iter, &variant_iter))
return -ENOMEM;
return 0;
}

View file

@ -12,6 +12,8 @@
#include <dbus/dbus.h>
struct wpa_signal_info;
typedef DBusMessage * (*WPADBusMethodHandler)(DBusMessage *message,
void *user_data);
typedef void (*WPADBusArgumentFreeFunction)(void *handler_arg);
@ -151,4 +153,7 @@ DBusMessage *wpas_dbus_reply_new_from_error(DBusMessage *message,
const char *fallback_name,
const char *fallback_string);
int wpas_dbus_new_from_signal_information(DBusMessageIter *iter,
struct wpa_signal_info *si);
#endif /* WPA_DBUS_CTRL_H */

View file

@ -5781,6 +5781,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
data->signal_change.data.signal,
data->signal_change.current_noise,
data->signal_change.data.current_tx_rate);
os_memcpy(&wpa_s->last_signal_info, data,
sizeof(struct wpa_signal_info));
wpas_notify_signal_change(wpa_s);
break;
case EVENT_INTERFACE_MAC_CHANGED:
wpa_supplicant_update_mac_addr(wpa_s);

View file

@ -993,3 +993,9 @@ void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
{
/* TODO: Notify external entities of the added PMKSA cache entry */
}
void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
{
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
}

View file

@ -167,5 +167,6 @@ void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s);
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *entry);
void wpas_notify_signal_change(struct wpa_supplicant *wpa_s);
#endif /* NOTIFY_H */

View file

@ -1523,6 +1523,8 @@ struct wpa_supplicant {
unsigned int enable_dscp_policy_capa:1;
unsigned int connection_dscp:1;
unsigned int wait_for_dscp_req:1;
struct wpa_signal_info last_signal_info;
};