mirror of
https://gitlab.com/prpl-foundation/prplmesh/prplMesh.git
synced 2025-12-20 01:21:22 +08:00
controller: use use_dataelements_vap_configs to choose configuration
- Reject configurations from `Device.WiFi.DataElements.AccessPoint` if use_dataelements_vap_configs is 0 - Reject configs from pWHM if use_dataelements_vap_configs is set to 1. - Set use_dataelements_vap_configs if USE_PRPLMESH_WHM is not defined - Add timer before applying ap changes. Closes: PPM-3503 Signed-off-by: Dmytro Kysil <d.kysil@inango-systems.com>
This commit is contained in:
committed by
Cihangir Odabas
parent
ddccca1122
commit
391ab8e64e
@@ -1,7 +1,12 @@
|
||||
set(BEEROCKS_CONTROLLER_DATAELEMENTS_VAP_CONFIGS 0)
|
||||
if (NOT USE_PRPLMESH_WHM)
|
||||
set(BEEROCKS_CONTROLLER_DATAELEMENTS_VAP_CONFIGS 1)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/beerocks_controller.conf.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/beerocks_controller.conf"
|
||||
)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/beerocks_controller.conf DESTINATION config)
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/beerocks_controller.conf DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/config")
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/beerocks_controller.conf DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/config")
|
||||
|
||||
@@ -53,7 +53,7 @@ credentials_change_timeout_sec=300
|
||||
fail_safe_5G_frequency=5180
|
||||
fail_safe_5G_bw=80
|
||||
fail_safe_5G_vht_frequency=5210
|
||||
use_dataelements_vap_configs=0
|
||||
use_dataelements_vap_configs=@BEEROCKS_CONTROLLER_DATAELEMENTS_VAP_CONFIGS@
|
||||
|
||||
[log]
|
||||
log_global_levels=error,info,warning,fatal,trace,debug
|
||||
|
||||
@@ -241,6 +241,17 @@ static uint64_t get_uint64_from_bss_color_bitmap(const std::string &decimal_str)
|
||||
amxd_status_t access_point_commit(amxd_object_t *object, amxd_function_t *func, amxc_var_t *args,
|
||||
amxc_var_t *ret)
|
||||
{
|
||||
if (!g_database) {
|
||||
LOG(ERROR) << "Can't read use_dataelements_vap_configs, g_database is nullptr";
|
||||
return amxd_status_ok;
|
||||
}
|
||||
|
||||
if (!g_database->config.use_dataelements_vap_configs) {
|
||||
LOG(WARNING) << "Device.WiFi.DataElements.Network.AccessPointCommit ignored when "
|
||||
"use_dataelements_vap_configs = false";
|
||||
return amxd_status_ok;
|
||||
}
|
||||
|
||||
amxc_var_clean(ret);
|
||||
amxd_object_t *access_point = amxd_object_get_child(object, "AccessPoint");
|
||||
|
||||
|
||||
@@ -773,13 +773,15 @@ int main(int argc, char *argv[])
|
||||
// be configured on the agents. Even though NBAPI exists to configure this, there is a lot of
|
||||
// existing software out there that doesn't use it. Therefore, prplMesh should also read the
|
||||
// configuration out of the legacy wireless settings.
|
||||
std::list<son::wireless_utils::sBssInfoConf> wireless_settings;
|
||||
if (beerocks::bpl::bpl_cfg_get_wireless_settings(wireless_settings)) {
|
||||
for (const auto &configuration : wireless_settings) {
|
||||
master_db.add_bss_info_configuration(configuration);
|
||||
if (!master_conf.use_dataelements_vap_configs) {
|
||||
std::list<son::wireless_utils::sBssInfoConf> wireless_settings;
|
||||
if (beerocks::bpl::bpl_cfg_get_wireless_settings(wireless_settings)) {
|
||||
for (const auto &configuration : wireless_settings) {
|
||||
master_db.add_bss_info_configuration(configuration);
|
||||
}
|
||||
} else {
|
||||
LOG(DEBUG) << "failed to read wireless settings";
|
||||
}
|
||||
} else {
|
||||
LOG(DEBUG) << "failed to read wireless settings";
|
||||
}
|
||||
|
||||
#ifdef USE_PRPLMESH_WHM
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "wifi_manager.h"
|
||||
|
||||
#include <bcl/beerocks_timer_factory_impl.h>
|
||||
#include <bcl/beerocks_timer_manager_impl.h>
|
||||
#include <beerocks/tlvf/beerocks_message_bml.h>
|
||||
#include <bpl/bpl_cfg.h>
|
||||
|
||||
@@ -25,6 +27,10 @@ namespace prplmesh {
|
||||
namespace controller {
|
||||
namespace whm {
|
||||
|
||||
namespace {
|
||||
constexpr std::chrono::milliseconds CONFIG_RENEW_TIMEOUT{3000};
|
||||
}
|
||||
|
||||
WifiManager::WifiManager(std::shared_ptr<beerocks::EventLoop> event_loop, son::db *ctx_wifi_db)
|
||||
{
|
||||
|
||||
@@ -38,11 +44,43 @@ WifiManager::WifiManager(std::shared_ptr<beerocks::EventLoop> event_loop, son::d
|
||||
|
||||
m_ambiorix_cl->init_event_loop(m_event_loop);
|
||||
m_ambiorix_cl->init_signal_loop(m_event_loop);
|
||||
|
||||
auto timer_factory = std::make_shared<beerocks::TimerFactoryImpl>();
|
||||
LOG_IF(!timer_factory, FATAL) << "Unable to create timer factory!";
|
||||
if (timer_factory) {
|
||||
m_timer_manager = std::make_shared<beerocks::TimerManagerImpl>(timer_factory, event_loop);
|
||||
LOG_IF(!m_timer_manager, FATAL) << "Unable to create timer manager!";
|
||||
}
|
||||
}
|
||||
|
||||
bool WifiManager::bss_info_config_change()
|
||||
{
|
||||
if (!m_timer_manager) {
|
||||
send_ap_config_renew_msg();
|
||||
}
|
||||
|
||||
if (m_timer != beerocks::net::FileDescriptor::invalid_descriptor) {
|
||||
m_timer_manager->remove_timer(m_timer);
|
||||
}
|
||||
m_timer =
|
||||
m_timer_manager->add_timer("ap_config_renew", CONFIG_RENEW_TIMEOUT, CONFIG_RENEW_TIMEOUT,
|
||||
[this](int /*fd*/, beerocks::EventLoop & /*loop*/) {
|
||||
m_timer_manager->remove_timer(m_timer);
|
||||
m_timer = beerocks::net::FileDescriptor::invalid_descriptor;
|
||||
send_ap_config_renew_msg();
|
||||
return true;
|
||||
});
|
||||
if (m_timer == beerocks::net::FileDescriptor::invalid_descriptor) {
|
||||
LOG(WARNING) << "Failed to create a timer for send_renew_msg(), calling it immediately.";
|
||||
send_ap_config_renew_msg();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WifiManager::send_ap_config_renew_msg()
|
||||
{
|
||||
m_ctx_wifi_db->clear_bss_info_configuration();
|
||||
|
||||
std::list<son::wireless_utils::sBssInfoConf> wireless_settings;
|
||||
@@ -62,7 +100,7 @@ bool WifiManager::bss_info_config_change()
|
||||
|
||||
if (!connected_agents.empty()) {
|
||||
if (!son_actions::send_ap_config_renew_msg(cmdu_tx, *m_ctx_wifi_db)) {
|
||||
LOG(ERROR) << "Failed son_actions::send_ap_config_renew_msg ! ";
|
||||
LOG(ERROR) << "Failed son_actions::send_ap_config_renew_msg!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,13 @@ public:
|
||||
|
||||
private:
|
||||
bool bss_info_config_change();
|
||||
bool send_ap_config_renew_msg();
|
||||
|
||||
std::shared_ptr<beerocks::wbapi::AmbiorixClient> m_ambiorix_cl = nullptr;
|
||||
son::db *m_ctx_wifi_db;
|
||||
std::shared_ptr<beerocks::EventLoop> m_event_loop;
|
||||
std::shared_ptr<beerocks::TimerManager> m_timer_manager;
|
||||
int m_timer = beerocks::net::FileDescriptor::invalid_descriptor;
|
||||
};
|
||||
|
||||
} // namespace whm
|
||||
|
||||
Reference in New Issue
Block a user