Add "Channel" property to the DBus interface that allows to get the channel of a BSS. Signed-off-by: Stefan Ursella <stefan.ursella@xxxxxxxxxxxxxx> --- wpa_supplicant/dbus/dbus_new.c | 5 +++ wpa_supplicant/dbus/dbus_new_handlers.c | 52 +++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 1 + 3 files changed, 58 insertions(+) diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index ff7e003cb..fd7958a62 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -3096,6 +3096,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = { NULL, NULL }, + { "Channel", WPAS_DBUS_NEW_IFACE_BSS, "y", + wpas_dbus_getter_bss_channel, + NULL, + NULL + }, { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au", wpas_dbus_getter_bss_rates, NULL, diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 2fad8dd59..6072e97a9 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -12,6 +12,7 @@ #include "common.h" #include "common/ieee802_11_defs.h" +#include "common/ieee802_11_common.h" #include "common/nan_de.h" #include "eap_peer/eap_methods.h" #include "eapol_supp/eapol_supp_sm.h" @@ -5385,6 +5386,57 @@ dbus_bool_t wpas_dbus_getter_bss_frequency( &freq, error); } +/** + * wpas_dbus_getter_bss_channel - Return the channel of a BSS + * @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 "Channel" property. + */ +dbus_bool_t wpas_dbus_getter_bss_channel( + const struct wpa_dbus_property_desc *property_desc, + DBusMessageIter *iter, DBusError *error, void *user_data) +{ + struct bss_handler_args *args = user_data; + const u8 *ie; + struct wpa_bss *res; + u16 channel = 0, op_class = 0; + int sec_chan = 0, vht = 0; + + res = get_bss_helper(args, error, __func__); + if (!res) + return FALSE; + + ie = wpa_bss_get_ie(res, WLAN_EID_HT_OPERATION); + if (ie && ie[2] >= 2) { + struct ieee80211_ht_operation *ht_oper = (struct ieee80211_ht_operation *) (ie + 2); + + if (ht_oper->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE) + sec_chan = 1; + else if (ht_oper->ht_param & + HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW) + sec_chan = -1; + } + + ie = wpa_bss_get_ie(res, WLAN_EID_VHT_OPERATION); + if (ie && ie[1] >= 1) { + struct ieee80211_vht_operation *vht_oper = (struct ieee80211_vht_operation *) (ie + 2); + + if (vht_oper->vht_op_info_chwidth == CHANWIDTH_80MHZ || + vht_oper->vht_op_info_chwidth == CHANWIDTH_160MHZ || + vht_oper->vht_op_info_chwidth == CHANWIDTH_80P80MHZ) + vht = vht_oper->vht_op_info_chwidth; + } + + if (ieee80211_freq_to_channel_ext(res->freq, sec_chan, vht, (u8 *)&op_class, + (u8 *)&channel) == NUM_HOSTAPD_MODES) + return FALSE; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16, + &channel, error); +} static int cmp_u8s_desc(const void *a, const void *b) { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index a5260907a..3391e51f7 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -214,6 +214,7 @@ DECLARE_ACCESSOR(wpas_dbus_getter_bss_privacy); DECLARE_ACCESSOR(wpas_dbus_getter_bss_mode); DECLARE_ACCESSOR(wpas_dbus_getter_bss_signal); DECLARE_ACCESSOR(wpas_dbus_getter_bss_frequency); +DECLARE_ACCESSOR(wpas_dbus_getter_bss_channel); DECLARE_ACCESSOR(wpas_dbus_getter_bss_rates); DECLARE_ACCESSOR(wpas_dbus_getter_bss_wpa); DECLARE_ACCESSOR(wpas_dbus_getter_bss_rsn); -- 2.34.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap