From 5a96a516a888876e23069fdc0e4c017aa478dc88 Mon Sep 17 00:00:00 2001 From: David Ruth Date: Wed, 19 Jul 2023 17:29:15 +0000 Subject: [PATCH] dbus: Report guard interval and dual carrier modulation Propagate guard interval as a double value and dual carrier modulation as a boolean over D-Bus. Signed-off-by: David Ruth --- wpa_supplicant/dbus/dbus_dict_helpers.c | 21 +++++++++++++++++ wpa_supplicant/dbus/dbus_dict_helpers.h | 4 ++++ wpa_supplicant/dbus/dbus_new_helpers.c | 31 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.c b/wpa_supplicant/dbus/dbus_dict_helpers.c index 0e4753450..fdf7b1258 100644 --- a/wpa_supplicant/dbus/dbus_dict_helpers.c +++ b/wpa_supplicant/dbus/dbus_dict_helpers.c @@ -361,6 +361,27 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict, } +/** + * Add a double 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 double value + * @return TRUE on success, FALSE on failure + * + */ +dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict, + const char *key, + const double value) +{ + if (!key) + return FALSE; + return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_DOUBLE, + &value); +} + + /** * Begin an array entry in the dict * diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.h b/wpa_supplicant/dbus/dbus_dict_helpers.h index 44685ea4a..cc9e26fa9 100644 --- a/wpa_supplicant/dbus/dbus_dict_helpers.h +++ b/wpa_supplicant/dbus/dbus_dict_helpers.h @@ -59,6 +59,10 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict, const char *value, const dbus_uint32_t value_len); +dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict, + const char *key, + const double value); + /* Manual construction and addition of array elements */ dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict, const char *key, const char *type, diff --git a/wpa_supplicant/dbus/dbus_new_helpers.c b/wpa_supplicant/dbus/dbus_new_helpers.c index 06f74ad3d..7fb066991 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.c +++ b/wpa_supplicant/dbus/dbus_new_helpers.c @@ -1026,6 +1026,23 @@ DBusMessage * wpas_dbus_reply_new_from_error(DBusMessage *message, } +static double guard_interval_to_double(enum guard_interval value) +{ + switch (value) { + case GUARD_INTERVAL_0_4: + return 0.4; + case GUARD_INTERVAL_0_8: + return 0.8; + case GUARD_INTERVAL_1_6: + return 1.6; + case GUARD_INTERVAL_3_2: + return 3.2; + default: + return 0; + } +} + + /** * wpas_dbus_new_from_signal_information - Adds a wpa_signal_info * to a DBusMessage. @@ -1149,6 +1166,20 @@ int wpas_dbus_new_from_signal_information(DBusMessageIter *iter, (si->data.avg_ack_signal && !wpa_dbus_dict_append_int32(&iter_dict, "avg-ack-rssi", si->data.avg_ack_signal)) || + (si->data.rx_guard_interval && + !wpa_dbus_dict_append_double( + &iter_dict, "rx-guard-interval", + guard_interval_to_double(si->data.rx_guard_interval))) || + (si->data.tx_guard_interval && + !wpa_dbus_dict_append_double( + &iter_dict, "tx-guard-interval", + guard_interval_to_double(si->data.tx_guard_interval))) || + ((si->data.flags & STA_DRV_DATA_RX_HE_DCM) && + !wpa_dbus_dict_append_bool(&iter_dict, "rx-dcm", + si->data.rx_dcm)) || + ((si->data.flags & STA_DRV_DATA_TX_HE_DCM) && + !wpa_dbus_dict_append_bool(&iter_dict, "tx-dcm", + si->data.tx_dcm)) || !wpa_dbus_dict_close_write(&variant_iter, &iter_dict) || !dbus_message_iter_close_container(iter, &variant_iter)) return -ENOMEM;