diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index 30df7cacd..4a624c58b 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -130,4 +130,9 @@ int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates); struct wpa_bss_anqp * wpa_bss_anqp_alloc(void); int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss); +static inline int bss_is_dmg(const struct wpa_bss *bss) +{ + return bss->freq > 45000; +} + #endif /* BSS_H */ diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 9bf03e340..88a4cd95f 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2204,17 +2204,43 @@ static int wpa_supplicant_ctrl_iface_scan_result( return -1; pos += ret; } - if (bss->caps & IEEE80211_CAP_IBSS) { - ret = os_snprintf(pos, end - pos, "[IBSS]"); + if (bss_is_dmg(bss)) { + const char *s; + ret = os_snprintf(pos, end - pos, "[DMG]"); if (ret < 0 || ret >= end - pos) return -1; pos += ret; - } - if (bss->caps & IEEE80211_CAP_ESS) { - ret = os_snprintf(pos, end - pos, "[ESS]"); + switch (bss->caps & IEEE80211_CAP_DMG_MASK) { + case IEEE80211_CAP_DMG_IBSS: + s = "[IBSS]"; + break; + case IEEE80211_CAP_DMG_AP: + s = "[ESS]"; + break; + case IEEE80211_CAP_DMG_PBSS: + s = "[PBSS]"; + break; + default: + s = ""; + break; + } + ret = os_snprintf(pos, end - pos, "%s", s); if (ret < 0 || ret >= end - pos) return -1; pos += ret; + } else { + if (bss->caps & IEEE80211_CAP_IBSS) { + ret = os_snprintf(pos, end - pos, "[IBSS]"); + if (ret < 0 || ret >= end - pos) + return -1; + pos += ret; + } + if (bss->caps & IEEE80211_CAP_ESS) { + ret = os_snprintf(pos, end - pos, "[ESS]"); + if (ret < 0 || ret >= end - pos) + return -1; + pos += ret; + } } if (p2p) { ret = os_snprintf(pos, end - pos, "[P2P]"); @@ -3544,17 +3570,43 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, return 0; pos += ret; } - if (bss->caps & IEEE80211_CAP_IBSS) { - ret = os_snprintf(pos, end - pos, "[IBSS]"); + if (bss_is_dmg(bss)) { + const char *s; + ret = os_snprintf(pos, end - pos, "[DMG]"); if (ret < 0 || ret >= end - pos) return 0; pos += ret; - } - if (bss->caps & IEEE80211_CAP_ESS) { - ret = os_snprintf(pos, end - pos, "[ESS]"); + switch (bss->caps & IEEE80211_CAP_DMG_MASK) { + case IEEE80211_CAP_DMG_IBSS: + s = "[IBSS]"; + break; + case IEEE80211_CAP_DMG_AP: + s = "[ESS]"; + break; + case IEEE80211_CAP_DMG_PBSS: + s = "[PBSS]"; + break; + default: + s = ""; + break; + } + ret = os_snprintf(pos, end - pos, "%s", s); if (ret < 0 || ret >= end - pos) return 0; pos += ret; + } else { + if (bss->caps & IEEE80211_CAP_IBSS) { + ret = os_snprintf(pos, end - pos, "[IBSS]"); + if (ret < 0 || ret >= end - pos) + return 0; + pos += ret; + } + if (bss->caps & IEEE80211_CAP_ESS) { + ret = os_snprintf(pos, end - pos, "[ESS]"); + if (ret < 0 || ret >= end - pos) + return 0; + pos += ret; + } } if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) || wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index bd38d65e0..6e1eedb12 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -3546,11 +3546,22 @@ dbus_bool_t wpas_dbus_getter_bss_mode(DBusMessageIter *iter, DBusError *error, res = get_bss_helper(args, error, __func__); if (!res) return FALSE; - - if (res->caps & IEEE80211_CAP_IBSS) - mode = "ad-hoc"; - else - mode = "infrastructure"; + if (bss_is_dmg(res)) { + switch (res->caps & IEEE80211_CAP_DMG_MASK) { + case IEEE80211_CAP_DMG_PBSS: + case IEEE80211_CAP_DMG_IBSS: + mode = "ad-hoc"; + break; + case IEEE80211_CAP_DMG_AP: + mode = "infrastructure"; + break; + } + } else { + if (res->caps & IEEE80211_CAP_IBSS) + mode = "ad-hoc"; + else + mode = "infrastructure"; + } return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &mode, error); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index eb27b57e7..1ecd6d611 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -713,12 +713,6 @@ static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) } -static int bss_is_dmg(struct wpa_bss *bss) -{ - return bss->freq > 45000; -} - - /* * Test whether BSS is in an ESS. * This is done differently in DMG (60 GHz) and non-DMG bands