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@xxxxxxxxxxxx> --- doc/dbus.doxygen | 29 +++++- wpa_supplicant/dbus/dbus_dict_helpers.c | 19 ++++ wpa_supplicant/dbus/dbus_dict_helpers.h | 4 + wpa_supplicant/dbus/dbus_new.c | 8 ++ wpa_supplicant/dbus/dbus_new.h | 2 + wpa_supplicant/dbus/dbus_new_handlers.c | 52 +++++----- wpa_supplicant/dbus/dbus_new_handlers.h | 2 + wpa_supplicant/dbus/dbus_new_helpers.c | 126 ++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_helpers.h | 4 + wpa_supplicant/events.c | 2 + wpa_supplicant/notify.c | 4 + wpa_supplicant/notify.h | 1 + wpa_supplicant/wpa_supplicant_i.h | 2 + 13 files changed, 228 insertions(+), 27 deletions(-) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 504db7540..b00fdf6b6 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -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> @@ -1240,7 +1267,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> diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.c b/wpa_supplicant/dbus/dbus_dict_helpers.c index e4e9b8da9..0e4753450 100644 --- a/wpa_supplicant/dbus/dbus_dict_helpers.c +++ b/wpa_supplicant/dbus/dbus_dict_helpers.c @@ -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. * diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.h b/wpa_supplicant/dbus/dbus_dict_helpers.h index 94a0efdbe..44685ea4a 100644 --- a/wpa_supplicant/dbus/dbus_dict_helpers.h +++ b/wpa_supplicant/dbus/dbus_dict_helpers.h @@ -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); diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 9279ae4d5..2127554f2 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2344,6 +2344,9 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, case WPAS_DBUS_PROP_BSS_TM_STATUS: prop = "BSSTMStatus"; break; + case WPAS_DBUS_PROP_SIGNAL_CHANGE: + prop = "SignalChange"; + break; default: wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d", __func__, property); @@ -3939,6 +3942,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = { wpas_dbus_setter_mac_address_randomization_mask, NULL }, + { "SignalChange", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}", + wpas_dbus_getter_signal_change, + NULL, + NULL + }, { NULL, NULL, NULL, NULL, NULL, NULL } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 26bdcb548..cb6a55be5 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -11,6 +11,7 @@ #define CTRL_IFACE_DBUS_NEW_H #include "common/defs.h" +#include "drivers/driver.h" #include "p2p/p2p.h" struct wpa_global; @@ -38,6 +39,7 @@ enum wpas_dbus_prop { WPAS_DBUS_PROP_ROAM_COMPLETE, WPAS_DBUS_PROP_SESSION_LENGTH, WPAS_DBUS_PROP_BSS_TM_STATUS, + WPAS_DBUS_PROP_SIGNAL_CHANGE, }; enum wpas_dbus_bss_prop { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 69fdf6036..145c7a2ff 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -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; @@ -6099,3 +6075,27 @@ 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; +} diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index a421083f7..2fc8434cb 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -246,6 +246,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, diff --git a/wpa_supplicant/dbus/dbus_new_helpers.c b/wpa_supplicant/dbus/dbus_new_helpers.c index d9009ba85..b8d3e0131 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.c +++ b/wpa_supplicant/dbus/dbus_new_helpers.c @@ -1023,3 +1023,129 @@ 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; +} diff --git a/wpa_supplicant/dbus/dbus_new_helpers.h b/wpa_supplicant/dbus/dbus_new_helpers.h index 7b63b28d7..4eb0e286c 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.h +++ b/wpa_supplicant/dbus/dbus_new_helpers.h @@ -11,6 +11,7 @@ #define WPA_DBUS_CTRL_H #include <dbus/dbus.h> +#include "drivers/driver.h" typedef DBusMessage * (*WPADBusMethodHandler)(DBusMessage *message, void *user_data); @@ -151,4 +152,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 */ diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index ee2271d67..bc89b2087 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -5781,6 +5781,8 @@ 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); diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 427405da9..466f26804 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -976,6 +976,10 @@ void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s) wpas_dbus_signal_interworking_select_done(wpa_s); } +void wpas_notify_signal_change(struct wpa_supplicant *wpa_s) +{ + wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE); +} #endif /* CONFIG_INTERWORKING */ diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index f26f4286d..41b4258c2 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -166,5 +166,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 */ diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0cc8633ee..f5c44115c 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -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; }; -- 2.38.1.584.g0f3c55d4c2-goog _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap