diff --git a/agent/src/beerocks/slave/ap_manager_thread.cpp b/agent/src/beerocks/slave/ap_manager_thread.cpp index 4673fbd00e..122f0e921f 100644 --- a/agent/src/beerocks/slave/ap_manager_thread.cpp +++ b/agent/src/beerocks/slave/ap_manager_thread.cpp @@ -1555,6 +1555,9 @@ void ap_manager_thread::handle_hostapd_attached() notification->cs_params().bandwidth = uint8_t( beerocks::utils::convert_bandwidth_to_enum(ap_wlan_hal->get_radio_info().bandwidth)); + notification->params().frequency_band = ap_wlan_hal->get_radio_info().frequency_band; + notification->params().max_bandwidth = ap_wlan_hal->get_radio_info().max_bandwidth; + // Copy the channels supported by the AP copy_radio_supported_channels(ap_wlan_hal, notification->params().supported_channels); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 246d81cd6e..9699b3712c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -25,7 +25,6 @@ * move all these includes into a separate header because * over time this list is going to get very long */ -#include #include #include #include @@ -83,71 +82,45 @@ namespace beerocks { const char *backhaul_manager::s_arrStates[] = {FOREACH_STATE(GENERATE_STRING)}; /** - * @brief Gets media type group for given interface. + * IEEE Std 1905.1, Table 6-12—Media type (intfType) * - * @param[in] interface_name Name of the local interface. - * @param[in, out] media_type_group The media type group of the connecting interface. - * - * @return True on success and false otherwise. + * Value and Description Frequency MaxBandwith Comments + * 0 IEEE 802.11b (2.4 GHz) 2.4 GHz 22 MHz Not supported + * 1 IEEE 802.11g (2.4 GHz) 2.4 GHz 20 MHz + * 2 IEEE 802.11a (5 GHz) 5 GHz 20 MHz + * 3 IEEE 802.11n (2.4 GHz) 2.4 GHz 40 MHz + * 4 IEEE 802.11n (5 GHz) 5 GHz 40 MHz + * 5 IEEE 802.11ac (5 GHz) 5 GHz 80 MHz + * 6 IEEE 802.11ad (60 GHz) 60 GHz 160 MHz Not supported + * 7 IEEE 802.11af (whitespace) Not supported + * 8 IEEE 802.11ax (2.4 GHz) 2.4 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 + * 8 IEEE 802.11ax (5 GHz) 5 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 */ -static bool get_media_type_group(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup &media_type_group) -{ - // TODO: Currently, only Ethernet is supported - // When dealing with WiFi interfaces in task #792, use NL80211_CMD_GET_INTERFACE command to - // find out if media type group is WiFi - media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_3; +static const std::vector> + table_6_12_media_type // + { + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_20, // + ieee1905_1::eMediaType::IEEE_802_11G_2_4_GHZ}, - return true; -} + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_20, // + ieee1905_1::eMediaType::IEEE_802_11A_5_GHZ}, -/** - * @brief Gets media type for given interface. - * - * The mechanism to use to obtain media type depends on the media type group: - * Ethernet, WiFi, MoCA, etc. - * - * @param[in] interface_name Name of the local interface. - * @param[in] media_type_group The media type group of the connecting interface. - * @param[in, out] media_type The underlying network technology of the connecting interface. - * - * @return True on success and false otherwise. - */ -static bool get_media_type(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup media_type_group, - ieee1905_1::eMediaType &media_type) -{ - bool result = false; + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_40, // + ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ}, - if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { - uint32_t speed; - if (network_utils::linux_iface_get_speed(interface_name, speed)) { - if (SPEED_100 == speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; - } else if (SPEED_1000 <= speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; - } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - } + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_40, // + ieee1905_1::eMediaType::IEEE_802_11N_5_GHZ}, - result = true; - } - } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "IEEE_802_11 media is not supported yet"; - } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "IEEE_1901 media is not supported yet"; - } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "MoCA media is not supported yet"; - } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - result = true; - } + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_80, // + ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ}, - return result; -} + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_160, // + ieee1905_1::eMediaType::IEEE_802_11AX}, + + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_160, // + ieee1905_1::eMediaType::IEEE_802_11AX}, + + }; /** * @brief Adds link metrics to response message. @@ -1781,6 +1754,12 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptriface_mac()]; + + radio_info.interface_name = request->ap_iface(); + radio_info.frequency_band = request->frequency_band(); + radio_info.max_bandwidth = request->max_bandwidth(); + std::string mac = network_utils::mac_to_string(request->iface_mac()); auto tuple_supported_channels = request->supported_channels_list(0); @@ -1792,7 +1771,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr(tuple_supported_channels); std::copy_n(channels, beerocks::message::SUPPORTED_CHANNELS_LENGTH, - m_radio_info_map[request->iface_mac()].supported_channels.begin()); + radio_info.supported_channels.begin()); soc->radio_mac = mac; soc->freq_type = (request->iface_is_5ghz() ? beerocks::eFreqType::FREQ_5G @@ -2274,14 +2253,12 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); } - // TODO: Add a LocalInterfaceInfo field for each wireless interface. - // This is something that cannot be done at this moment because the MediaType field - // must be computed with information obtained through NL80211_CMD_GET_WIPHY command of DWPAL, - // which is currently not supported. See "Send standard NL80211 commands using DWPAL #782" - // For now, fill from radio data with dummy values based on information we have. + /** + * Add a LocalInterfaceInfo field for each wireless interface. + */ for (const auto &soc : slaves_sockets) { // Iterate on front radio iface and then switch to back radio iface - auto fill_radio_iface_info = [&](bool front_iface) { + auto fill_radio_iface_info = [&](ieee1905_1::eMediaType media_type, bool front_iface) { LOG(DEBUG) << "filling interface information on radio=" << (front_iface ? soc->radio_mac : soc->radio_mac + " backhaul"); @@ -2301,16 +2278,6 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd LOG(DEBUG) << "Added radio interface to tlvDeviceInformation: " << localInterfaceInfo->mac(); - ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - if (soc->freq_type == beerocks::eFreqType::FREQ_24G) { - media_type = ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ; - } else if (soc->freq_type == beerocks::eFreqType::FREQ_5G) { - media_type = ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ; - } else { - LOG(ERROR) << "Unsupported freq_type=" << int(soc->freq_type) - << ", iface=" << soc->hostap_iface; - return false; - } localInterfaceInfo->media_type() = media_type; ieee1905_1::s802_11SpecificInformation media_info = {}; @@ -2352,13 +2319,22 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd return true; }; - if (!fill_radio_iface_info(true)) { + std::string local_interface_name = soc->hostap_iface; + + ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; + ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + if (!get_media_type(local_interface_name, media_type_group, media_type)) { + LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; + return false; + } + + if (!fill_radio_iface_info(media_type, true)) { LOG(DEBUG) << "filling interface information on radio=" << soc->radio_mac << " has failed!"; return true; } - if (!fill_radio_iface_info(false)) { + if (!fill_radio_iface_info(media_type, false)) { LOG(DEBUG) << "filling interface information on radio=" << soc->radio_mac << " backhaul has failed!"; return true; @@ -3421,6 +3397,69 @@ std::shared_ptr backhaul_manager::get_wireless_hal(std::strin return slave_sk->second->sta_wlan_hal; } +bool backhaul_manager::get_media_type_group(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup &media_type_group) +{ + // TODO: Currently, only Ethernet is supported + // When dealing with WiFi interfaces in task #792, use NL80211_CMD_GET_INTERFACE command to + // find out if media type group is WiFi + media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_3; + + return true; +} + +bool backhaul_manager::get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type) +{ + bool result = false; + + if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { + uint32_t speed; + if (network_utils::linux_iface_get_speed(interface_name, speed)) { + if (SPEED_100 == speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; + } else if (SPEED_1000 <= speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; + } else { + media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + } + + result = true; + } + } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { + + for (const auto &radio_info_entry : m_radio_info_map) { + auto radio_info = radio_info_entry.second; + + if (interface_name == radio_info.interface_name) { + + for (const auto &tuple : table_6_12_media_type) { + if ((std::get<0>(tuple) == radio_info.frequency_band) && + (std::get<1>(tuple) == radio_info.max_bandwidth)) { + media_type = std::get<2>(tuple); + + break; + } + } + + break; + } + } + } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "IEEE_1901 media is not supported yet"; + } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "MoCA media is not supported yet"; + } else { + media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + result = true; + } + + return result; +} + bool backhaul_manager::get_neighbor_links( const sMacAddr &neighbor_mac_filter, std::map> &neighbor_links_map) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 15e3f714a2..420e7e2953 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -21,6 +21,8 @@ #include +#include + #include "../agent_ucc_listener.h" #include @@ -263,7 +265,12 @@ class backhaul_manager : public btl::transport_socket_thread { * the TLVs to include in notification messages or responses to CDMU query messages. */ struct sRadioInfo { - beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */ + std::string interface_name; /**< Name of the radio interface */ + beerocks::eFreqType frequency_band = + beerocks::eFreqType::FREQ_UNKNOWN; /**< Frequency band */ + beerocks::eWiFiBandwidth max_bandwidth = + beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; /**< Maximum supported bandwidth */ + beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */ std::array supported_channels; /**< Array of supported channels in radio. */ std::unordered_map @@ -275,6 +282,33 @@ class backhaul_manager : public btl::transport_socket_thread { */ std::unordered_map m_radio_info_map; + /** + * @brief Gets media type group for given interface. + * + * @param[in] interface_name Name of the local interface. + * @param[in, out] media_type_group The media type group of the connecting interface. + * + * @return True on success and false otherwise. + */ + bool get_media_type_group(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup &media_type_group); + + /** + * @brief Gets media type for given interface. + * + * The mechanism to use to obtain media type depends on the media type group: + * Ethernet, WiFi, MoCA, etc. + * + * @param[in] interface_name Name of the local interface. + * @param[in] media_type_group The media type group of the connecting interface. + * @param[in, out] media_type The underlying network technology of the connecting interface. + * + * @return True on success and false otherwise. + */ + bool get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type); + /** * @brief Gets the list of neighbor links from topology database. * diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index fb3c5874a2..a0e7c3a179 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -3250,6 +3250,9 @@ bool slave_thread::slave_fsm(bool &call_slave_select) config.backhaul_wireless_iface.c_str(), message::IFACE_NAME_LENGTH); + bh_enable->frequency_band() = hostap_params.frequency_band; + bh_enable->max_bandwidth() = hostap_params.max_bandwidth; + auto tuple_supported_channels = bh_enable->supported_channels_list(0); if (!std::get<0>(tuple_supported_channels)) { LOG(ERROR) << "getting supported channels has failed!"; diff --git a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp index 0ab8dfeb4c..1c5d410f6e 100644 --- a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp @@ -292,9 +292,15 @@ bool base_wlan_hal_dummy::process_nl_events() bool base_wlan_hal_dummy::refresh_radio_info() { + m_radio_info.max_bandwidth = beerocks::eWiFiBandwidth::BANDWIDTH_40; + if (get_iface_name() == "wlan2") { - m_radio_info.is_5ghz = true; + m_radio_info.is_5ghz = true; + m_radio_info.frequency_band = beerocks::eFreqType::FREQ_5G; + } else { + m_radio_info.frequency_band = beerocks::eFreqType::FREQ_24G; } + std::string radio_mac; beerocks::net::network_utils::linux_iface_get_mac(m_radio_info.iface_name, radio_mac); for (int vap_id = 0; vap_id < predefined_vaps_num; vap_id++) { diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp index e960151b09..e2b3586087 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp @@ -710,6 +710,23 @@ bool base_wlan_hal_dwpal::refresh_radio_info() { char *reply = nullptr; + /** + * Obtain frequency band and maximum supported bandwidth using NL80211. + * As this information does not change, this is required the first time this method is called + * only. + */ + if (beerocks::eFreqType::FREQ_UNKNOWN == m_radio_info.frequency_band) { + nl80211_client::radio_info radio_info; + if (m_nl80211_client->get_radio_info(get_iface_name(), radio_info)) { + if (!radio_info.bands.empty()) { + nl80211_client::band_info band_info = radio_info.bands.at(0); + + m_radio_info.frequency_band = band_info.get_frequency_band(); + m_radio_info.max_bandwidth = band_info.get_max_bandwidth(); + } + } + } + // TODO: Add radio_info get for station // Station HAL diff --git a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h index 5347071382..23aa36cdd3 100644 --- a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h @@ -77,18 +77,21 @@ enum class WiFiSec { Invalid = 0, None, WEP_64, WEP_128, WPA_PSK, WPA2_PSK, WPA_ struct RadioInfo { std::string iface_name; - IfaceType iface_type = IfaceType::Unsupported; - bool radio_enabled = false; - int wifi_ctrl_enabled = 0; // Hostapd / wpa_supplicant - bool tx_enabled = false; - bool is_5ghz = false; - int channel = 0; - int bandwidth = 0; - int channel_ext_above = 0; - int vht_center_freq = 0; - bool is_dfs_channel = false; - int ant_num = 0; - int tx_power = 0; + IfaceType iface_type = IfaceType::Unsupported; + bool radio_enabled = false; + int wifi_ctrl_enabled = 0; // Hostapd / wpa_supplicant + bool tx_enabled = false; + bool is_5ghz = false; + int channel = 0; + int bandwidth = 0; + int channel_ext_above = 0; + int vht_center_freq = 0; + bool is_dfs_channel = false; + int ant_num = 0; + int tx_power = 0; + beerocks::eFreqType frequency_band = beerocks::eFreqType::FREQ_UNKNOWN; /**< Frequency band */ + beerocks::eWiFiBandwidth max_bandwidth = + beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; /**< Maximum supported bandwidth */ ChanSwReason last_csa_sw_reason = ChanSwReason::Unknown; std::vector supported_channels; std::unordered_map available_vaps; // key = vap_id diff --git a/common/beerocks/bwl/include/bwl/nl80211_client.h b/common/beerocks/bwl/include/bwl/nl80211_client.h index ed2464d3d5..7d1fb67bda 100644 --- a/common/beerocks/bwl/include/bwl/nl80211_client.h +++ b/common/beerocks/bwl/include/bwl/nl80211_client.h @@ -171,6 +171,23 @@ class nl80211_client { * @return True if this band is the 5GHz band and false otherwise. */ bool is_5ghz_band() const { return beerocks::eFreqType::FREQ_5G == get_frequency_band(); } + + /** + * @brief Gets the maximum supported bandwidth by all the channels in the band. + * + * @return Maximum supported bandwidth + */ + beerocks::eWiFiBandwidth get_max_bandwidth() const + { + beerocks::eWiFiBandwidth max_bandwith = beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; + + for (const auto &it : supported_channels) { + channel_info channel = it.second; + max_bandwith = std::max(max_bandwith, channel.get_max_bandwidth()); + } + + return max_bandwith; + } }; /** diff --git a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp index 5484b920a6..5a4f91cf5a 100644 --- a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp @@ -633,6 +633,23 @@ bool base_wlan_hal_nl80211::refresh_radio_info() { parsed_obj_map_t reply; + /** + * Obtain frequency band and maximum supported bandwidth using NL80211. + * As this information does not change, this is required the first time this method is called + * only. + */ + if (beerocks::eFreqType::FREQ_UNKNOWN == m_radio_info.frequency_band) { + nl80211_client::radio_info radio_info; + if (m_nl80211_client->get_radio_info(get_iface_name(), radio_info)) { + if (!radio_info.bands.empty()) { + nl80211_client::band_info band_info = radio_info.bands.at(0); + + m_radio_info.frequency_band = band_info.get_frequency_band(); + m_radio_info.max_bandwidth = band_info.get_max_bandwidth(); + } + } + } + if (!wpa_ctrl_send_msg("STATUS", reply)) { LOG(ERROR) << __func__ << " failed"; return false; diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h index 7101aa2ea8..5f630b7345 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h @@ -149,6 +149,8 @@ class cACTION_BACKHAUL_ENABLE : public BaseClass uint8_t& wireless_iface_type(); uint8_t& mem_only_psk(); uint8_t& backhaul_preferred_radio_band(); + beerocks::eFreqType& frequency_band(); + beerocks::eWiFiBandwidth& max_bandwidth(); std::tuple supported_channels_list(size_t idx); void class_swap() override; bool finalize() override; @@ -176,6 +178,8 @@ class cACTION_BACKHAUL_ENABLE : public BaseClass uint8_t* m_wireless_iface_type = nullptr; uint8_t* m_mem_only_psk = nullptr; uint8_t* m_backhaul_preferred_radio_band = nullptr; + beerocks::eFreqType* m_frequency_band = nullptr; + beerocks::eWiFiBandwidth* m_max_bandwidth = nullptr; beerocks::message::sWifiChannel* m_supported_channels_list = nullptr; size_t m_supported_channels_list_idx__ = 0; }; diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h index 775de4ae4c..48bb313b48 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h @@ -369,10 +369,14 @@ typedef struct sNodeHostap { uint8_t ant_num; uint8_t ant_gain; uint8_t tx_power; + beerocks::eFreqType frequency_band; + beerocks::eWiFiBandwidth max_bandwidth; char driver_version[beerocks::message::WIFI_DRIVER_VER_LENGTH]; beerocks::message::sWifiChannel supported_channels[beerocks::message::SUPPORTED_CHANNELS_LENGTH]; void struct_swap(){ iface_mac.struct_swap(); + tlvf_swap(8*sizeof(beerocks::eFreqType), reinterpret_cast(&frequency_band)); + tlvf_swap(8*sizeof(beerocks::eWiFiBandwidth), reinterpret_cast(&max_bandwidth)); for (size_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++){ (supported_channels[i]).struct_swap(); } diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp index 56f21fa3bd..2cd0ce1bf8 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp @@ -506,6 +506,14 @@ uint8_t& cACTION_BACKHAUL_ENABLE::backhaul_preferred_radio_band() { return (uint8_t&)(*m_backhaul_preferred_radio_band); } +beerocks::eFreqType& cACTION_BACKHAUL_ENABLE::frequency_band() { + return (beerocks::eFreqType&)(*m_frequency_band); +} + +beerocks::eWiFiBandwidth& cACTION_BACKHAUL_ENABLE::max_bandwidth() { + return (beerocks::eWiFiBandwidth&)(*m_max_bandwidth); +} + std::tuple cACTION_BACKHAUL_ENABLE::supported_channels_list(size_t idx) { bool ret_success = ( (m_supported_channels_list_idx__ > 0) && (m_supported_channels_list_idx__ > idx) ); size_t ret_idx = ret_success ? idx : 0; @@ -521,6 +529,8 @@ void cACTION_BACKHAUL_ENABLE::class_swap() m_iface_mac->struct_swap(); tlvf_swap(32, reinterpret_cast(m_security_type)); m_preferred_bssid->struct_swap(); + tlvf_swap(8*sizeof(beerocks::eFreqType), reinterpret_cast(m_frequency_band)); + tlvf_swap(8*sizeof(beerocks::eWiFiBandwidth), reinterpret_cast(m_max_bandwidth)); for (size_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++){ m_supported_channels_list[i].struct_swap(); } @@ -569,6 +579,8 @@ size_t cACTION_BACKHAUL_ENABLE::get_initial_size() class_size += sizeof(uint8_t); // wireless_iface_type class_size += sizeof(uint8_t); // mem_only_psk class_size += sizeof(uint8_t); // backhaul_preferred_radio_band + class_size += sizeof(beerocks::eFreqType); // frequency_band + class_size += sizeof(beerocks::eWiFiBandwidth); // max_bandwidth class_size += beerocks::message::SUPPORTED_CHANNELS_LENGTH * sizeof(beerocks::message::sWifiChannel); // supported_channels_list return class_size; } @@ -651,6 +663,16 @@ bool cACTION_BACKHAUL_ENABLE::init() LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; return false; } + m_frequency_band = (beerocks::eFreqType*)m_buff_ptr__; + if (!buffPtrIncrementSafe(sizeof(beerocks::eFreqType))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::eFreqType) << ") Failed!"; + return false; + } + m_max_bandwidth = (beerocks::eWiFiBandwidth*)m_buff_ptr__; + if (!buffPtrIncrementSafe(sizeof(beerocks::eWiFiBandwidth))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::eWiFiBandwidth) << ") Failed!"; + return false; + } m_supported_channels_list = (beerocks::message::sWifiChannel*)m_buff_ptr__; if (!buffPtrIncrementSafe(sizeof(beerocks::message::sWifiChannel) * (beerocks::message::SUPPORTED_CHANNELS_LENGTH))) { LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::message::sWifiChannel) * (beerocks::message::SUPPORTED_CHANNELS_LENGTH) << ") Failed!"; diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml index 6e2c84771b..543b59a9cf 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml @@ -59,6 +59,8 @@ cACTION_BACKHAUL_ENABLE: wireless_iface_type: uint8_t mem_only_psk: uint8_t backhaul_preferred_radio_band: uint8_t + frequency_band: beerocks::eFreqType + max_bandwidth: beerocks::eWiFiBandwidth supported_channels_list: _type: beerocks::message::sWifiChannel _length: [ "beerocks::message::SUPPORTED_CHANNELS_LENGTH" ] diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml index f3321d55f2..21501a8a8d 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml @@ -265,6 +265,8 @@ sNodeHostap: ant_num: uint8_t ant_gain: uint8_t tx_power: uint8_t + frequency_band: beerocks::eFreqType + max_bandwidth: beerocks::eWiFiBandwidth driver_version: _type: char _length: [ "beerocks::message::WIFI_DRIVER_VER_LENGTH" ] diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 5d2488475b..456409ff2d 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -1640,14 +1640,14 @@ bool master_thread::handle_cmdu_1905_topology_response(const std::string &src_ma const auto &iface_mac = iface_info.mac(); auto iface_mac_str = network_utils::mac_to_string(iface_mac); - const auto media_type = iface_info.media_type(); + const auto media_type = iface_info.media_type(); + const auto media_type_group = media_type >> 8; // For wireless interface it is defined on IEEE 1905.1 that the size of the media info // is n=10 octets, which the size of s802_11SpecificInformation struct. // For wired interface n=0. - if (media_type >= ieee1905_1::eMediaType::IEEE_802_11B_2_4_GHZ && - media_type <= ieee1905_1::eMediaType::IEEE_802_11AF && - iface_info.media_info_length() == 10) { + if ((ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) && + (iface_info.media_info_length() == 10)) { const auto media_info = reinterpret_cast( iface_info.media_info(0)); diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h index f26fd9273f..63df0998fd 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h @@ -30,6 +30,7 @@ enum eMediaType: uint16_t { IEEE_802_11AC_5_GHZ = 0x105, IEEE_802_11AD_60_GHZ = 0x106, IEEE_802_11AF = 0x107, + IEEE_802_11AX = 0x108, IEEE_1901_WAVELET = 0x200, IEEE_1901_FFT = 0x201, MOCA_V1_1 = 0x300, diff --git a/framework/tlvf/tlvf.py b/framework/tlvf/tlvf.py index e0da4d852f..15ad120524 100755 --- a/framework/tlvf/tlvf.py +++ b/framework/tlvf/tlvf.py @@ -136,7 +136,9 @@ def __init__(self, type_str): elif len(self.type_str) > 2 and (str(self.type_str[1]).isupper() or str(self.type_str[1]).isdigit()): if self.type_str[0] == "e": self.set_type(TypeInfo.ENUM) - self.swap_prefix = "tlvf_swap(8*sizeof(" + self.type_str + "), reinterpret_cast(" + self.swap_prefix = "tlvf_swap(8*sizeof(" + self.swap_prefix += type_str + self.swap_prefix += "), reinterpret_cast(" self.swap_suffix = "))" self.swap_needed = True elif self.type_str[0] == "s": diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml index 0de5ffa8f2..3aeb679382 100755 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml @@ -15,6 +15,7 @@ eMediaType: IEEE_802_11AC_5_GHZ: 0x0105 IEEE_802_11AD_60_GHZ: 0x0106 IEEE_802_11AF: 0x0107 + IEEE_802_11AX: 0x0108 IEEE_1901_WAVELET: 0x0200 IEEE_1901_FFT: 0x0201 MOCA_V1_1: 0x0300