Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

PPM-338 Move UCI configuration to Agent DB #1590

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1ed9087
agent: Move front radio configuration to AgentDB
orenvor Aug 4, 2020
198dd29
agent: Move back radio configuration to AgentDB
orenvor Aug 4, 2020
b940541
agent: Move mem_only_psk configuration to AgentDB
orenvor Aug 5, 2020
fa19acb
agent: Move backhaul_max_vaps configuration to AgentDB
orenvor Aug 6, 2020
bd04912
agent: Move backhaul_network_enabled configuration to AgentDB
orenvor Aug 6, 2020
6d15f7e
agent: Move backhaul_preferred_radio_band configuration to AgentDB
orenvor Aug 6, 2020
6af1e0b
agent: Move operating_mode configuration to AgentDB
orenvor Aug 6, 2020
e59af3a
agent: Move management_mode configuration to AgentDB
orenvor Aug 6, 2020
84178c6
agent: Move certification_mode configuration to AgentDB
orenvor Aug 6, 2020
8d7e394
agent: Move stop_on_failure_attempts configuration to AgentDB
orenvor Aug 6, 2020
b13191f
agent: Move client_band_steering_enabled configuration to AgentDB
orenvor Aug 6, 2020
d6d17b4
agent: Move client_optimal_path_roaming_enabled configuration to AgentDB
orenvor Aug 6, 2020
f166c0a
agent: Move dfs_reentry_enabled configuration to AgentDB
orenvor Aug 6, 2020
ced7c3d
agent: Move client_optimal_path_prefer_signal_strength to AgentDB
orenvor Aug 6, 2020
1c890a3
agent: Move client_11k_roaming_enabled configuration to AgentDB
orenvor Aug 6, 2020
d672a81
agent: Move load_balancing_enabled configuration to AgentDB
orenvor Aug 6, 2020
9565fce
agent: Move service_fairness_enabled configuration to AgentDB
orenvor Aug 6, 2020
b9541a9
agent: Move rdkb_extensions_enabled configuration to AgentDB
orenvor Aug 6, 2020
5477bb5
agent: remove unused onboarding configuration
orenvor Aug 10, 2020
e3efdfb
tlvf: beerocks_message::sPlatformSettings remove unused settings
orenvor Aug 9, 2020
c666a11
agent: Remove "platform_settings" local variable from son_slave_thread
orenvor Aug 11, 2020
2831a7d
agent: Move wlan_settings configuration to AgentDB
orenvor Aug 11, 2020
cb51ce9
fixup! agent: Move wlan_settings configuration to AgentDB
orenvor Aug 12, 2020
9c450e9
tlvf: PLATFORM_SON_SLAVE_REGISTER_RESPONSE remove unused fields
orenvor Aug 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions agent/src/beerocks/slave/agent_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,41 @@ class AgentDB {
/* Agent Configuration */
struct sDeviceConf {
struct sFrontRadio {

char ssid[beerocks::message::WIFI_SSID_MAX_LENGTH];
char pass[beerocks::message::WIFI_PASS_MAX_LENGTH];
char security_type[beerocks::message::WIFI_SECURITY_TYPE_MAX_LENGTH];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doxygen documentation

} front_radio;

struct sBackRadio {

char ssid[beerocks::message::WIFI_SSID_MAX_LENGTH];
char pass[beerocks::message::WIFI_PASS_MAX_LENGTH];
char security_type[beerocks::message::WIFI_SECURITY_TYPE_MAX_LENGTH];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doxygen documentation

uint8_t mem_only_psk;
uint8_t backhaul_max_vaps;
uint8_t backhaul_network_enabled;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
uint8_t backhaul_preferred_radio_band;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
} back_radio;

bool local_gw;
bool local_controller;
uint8_t operating_mode;
uint8_t management_mode;
uint8_t certification_mode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it means certification_enabled, shouldn't it be renamed and defined as bool?

uint8_t stop_on_failure_attempts;
uint8_t client_band_steering_enabled;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
uint8_t client_optimal_path_roaming_enabled;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
uint8_t dfs_reentry_enabled;
uint8_t client_optimal_path_roaming_prefer_signal_strength_enabled;
uint8_t client_11k_roaming_enabled;
uint8_t load_balancing_enabled;
uint8_t service_fairness_enabled;
uint8_t rdkb_extensions_enabled;

struct sWlanSettings {
uint8_t band_enabled;
uint8_t channel;
} wlan_settings;

} device_conf;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,27 @@ static beerocks::eFreqType bpl_band_to_freq_type(int bpl_band)
}

static bool fill_platform_settings(
std::string iface_name,
std::shared_ptr<beerocks_message::cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE> msg,
main_thread::platform_common_conf_t &platform_common_conf,
std::string iface_name, main_thread::platform_common_conf_t &platform_common_conf,
orenvor marked this conversation as resolved.
Show resolved Hide resolved
std::unordered_map<std::string, std::shared_ptr<beerocks_message::sWlanSettings>>
&iface_wlan_params_map,
Socket *sd)
{
auto db = AgentDB::get();

if (bpl::cfg_get_beerocks_credentials(BPL_RADIO_FRONT, msg->platform_settings().front_ssid,
msg->platform_settings().front_pass,
msg->platform_settings().front_security_type) < 0) {
if (bpl::cfg_get_beerocks_credentials(BPL_RADIO_FRONT, db->device_conf.front_radio.ssid,
db->device_conf.front_radio.pass,
db->device_conf.front_radio.security_type) < 0) {
LOG(ERROR) << "Failed reading front Wi-Fi credentials!";
return false;
}

LOG(DEBUG) << "Front Credentials:"
<< " ssid=" << msg->platform_settings().front_ssid
<< " sec=" << msg->platform_settings().front_security_type << " pass=***";
<< " ssid=" << db->device_conf.front_radio.ssid
<< " sec=" << db->device_conf.front_radio.security_type << " pass=***";

if (bpl::cfg_get_beerocks_credentials(BPL_RADIO_BACK, msg->platform_settings().back_ssid,
msg->platform_settings().back_pass,
msg->platform_settings().back_security_type) < 0) {
if (bpl::cfg_get_beerocks_credentials(BPL_RADIO_BACK, db->device_conf.back_radio.ssid,
db->device_conf.back_radio.pass,
db->device_conf.back_radio.security_type) < 0) {
LOG(ERROR) << "Failed reading Wi-Fi back credentials!";
return false;
}
Expand All @@ -90,25 +88,26 @@ static bool fill_platform_settings(
return false;
}

msg->platform_settings().mem_only_psk = mem_only_psk;
db->device_conf.back_radio.mem_only_psk = mem_only_psk;

LOG(DEBUG) << "Back Credentials:"
<< " ssid=" << msg->platform_settings().back_ssid
<< " sec=" << msg->platform_settings().back_security_type
<< " mem_only_psk=" << int(msg->platform_settings().mem_only_psk) << " pass=***";
<< " ssid=" << db->device_conf.back_radio.ssid
<< " sec=" << db->device_conf.back_radio.security_type
<< " mem_only_psk=" << int(db->device_conf.back_radio.mem_only_psk) << " pass=***";
orenvor marked this conversation as resolved.
Show resolved Hide resolved

bpl::BPL_WLAN_PARAMS params;
if (bpl::cfg_get_wifi_params(iface_name.c_str(), &params) < 0) {
LOG(ERROR) << "Failed reading '" << iface_name << "' parameters!";
return false;
}
/* update message */
msg->wlan_settings().band_enabled = params.enabled;
msg->wlan_settings().channel = params.channel;
db->device_conf.wlan_settings.band_enabled = params.enabled;
db->device_conf.wlan_settings.channel = params.channel;

LOG(DEBUG) << "wlan settings:"
<< " band_enabled=" << string_utils::bool_str(msg->wlan_settings().band_enabled)
<< " channel=" << int(msg->wlan_settings().channel);
<< " band_enabled="
<< string_utils::bool_str(db->device_conf.wlan_settings.band_enabled)
orenvor marked this conversation as resolved.
Show resolved Hide resolved
<< " channel=" << int(db->device_conf.wlan_settings.channel);

// initialize wlan params cache
//erase interface cache from map if exists
Expand Down Expand Up @@ -191,48 +190,45 @@ static bool fill_platform_settings(
db->device_conf.local_gw = (platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY ||
platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY_WISP);

msg->platform_settings().onboarding = uint8_t(platform_common_conf.onboarding);
msg->platform_settings().dfs_reentry_enabled = uint8_t(platform_common_conf.dfs_reentry);
msg->platform_settings().rdkb_extensions_enabled =
uint8_t(platform_common_conf.rdkb_extensions);
msg->platform_settings().client_band_steering_enabled =
uint8_t(platform_common_conf.band_steering);
msg->platform_settings().client_optimal_path_roaming_enabled =
db->device_conf.dfs_reentry_enabled = uint8_t(platform_common_conf.dfs_reentry);
db->device_conf.rdkb_extensions_enabled = uint8_t(platform_common_conf.rdkb_extensions);
db->device_conf.client_band_steering_enabled = uint8_t(platform_common_conf.band_steering);
db->device_conf.client_optimal_path_roaming_enabled =
uint8_t(platform_common_conf.client_roaming);
msg->platform_settings().client_optimal_path_roaming_prefer_signal_strength_enabled =
db->device_conf.client_optimal_path_roaming_prefer_signal_strength_enabled =
0; // TODO add platform DB flag
msg->platform_settings().client_11k_roaming_enabled =
db->device_conf.client_11k_roaming_enabled =
uint8_t(platform_common_conf.client_roaming || platform_common_conf.band_steering);
msg->platform_settings().operating_mode = uint8_t(platform_common_conf.operating_mode);
msg->platform_settings().management_mode = uint8_t(platform_common_conf.management_mode);
msg->platform_settings().certification_mode = uint8_t(platform_common_conf.certification_mode);
msg->platform_settings().stop_on_failure_attempts =
db->device_conf.operating_mode = uint8_t(platform_common_conf.operating_mode);
db->device_conf.management_mode = uint8_t(platform_common_conf.management_mode);
db->device_conf.certification_mode = uint8_t(platform_common_conf.certification_mode);
db->device_conf.stop_on_failure_attempts =
uint8_t(platform_common_conf.stop_on_failure_attempts);
msg->platform_settings().backhaul_max_vaps = uint8_t(platform_common_conf.backhaul_max_vaps);
msg->platform_settings().backhaul_network_enabled =
db->device_conf.back_radio.backhaul_max_vaps = uint8_t(platform_common_conf.backhaul_max_vaps);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
db->device_conf.back_radio.backhaul_max_vaps = uint8_t(platform_common_conf.backhaul_max_vaps);
db->device_conf.back_radio.backhaul_max_vaps = static_cast<uint8_t>(platform_common_conf.backhaul_max_vaps);

This PR seems like a good opportunity to replace all these C style casts with the preferred C++ style casts

db->device_conf.back_radio.backhaul_network_enabled =
uint8_t(platform_common_conf.backhaul_network_enabled);
msg->platform_settings().backhaul_preferred_radio_band =
db->device_conf.back_radio.backhaul_preferred_radio_band =
uint8_t(bpl_band_to_freq_type(platform_common_conf.backhaul_preferred_radio_band));

msg->platform_settings().load_balancing_enabled = 0; // for v1.3 TODO read from CAL DB
msg->platform_settings().service_fairness_enabled = 0; // for v1.3 TODO read from CAL DB
db->device_conf.load_balancing_enabled = 0; // for v1.3 TODO read from CAL DB
db->device_conf.service_fairness_enabled = 0; // for v1.3 TODO read from CAL DB

LOG(DEBUG) << "iface " << iface_name << " settings:";
LOG(DEBUG) << "onboarding: " << (unsigned)msg->platform_settings().onboarding;
LOG(DEBUG) << "onboarding: " << (unsigned)0;
LOG(DEBUG) << "client_band_steering_enabled: "
<< (unsigned)msg->platform_settings().client_band_steering_enabled;
<< (unsigned)db->device_conf.client_band_steering_enabled;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
LOG(DEBUG) << "client_optimal_path_roaming_enabled: "
<< (unsigned)msg->platform_settings().client_optimal_path_roaming_enabled;
<< (unsigned)db->device_conf.client_optimal_path_roaming_enabled;
LOG(DEBUG) << "client_optimal_path_roaming_prefer_signal_strength_enabled: "
<< (unsigned)msg->platform_settings()
.client_optimal_path_roaming_prefer_signal_strength_enabled;
LOG(DEBUG) << "band_enabled: " << (unsigned)msg->wlan_settings().band_enabled;
<< (unsigned)
db->device_conf.client_optimal_path_roaming_prefer_signal_strength_enabled;
LOG(DEBUG) << "band_enabled: " << (unsigned)db->device_conf.wlan_settings.band_enabled;
LOG(DEBUG) << "local_gw: " << db->device_conf.local_gw;
LOG(DEBUG) << "local_controller: " << db->device_conf.local_controller;
LOG(DEBUG) << "dfs_reentry_enabled: " << (unsigned)msg->platform_settings().dfs_reentry_enabled;
LOG(DEBUG) << "dfs_reentry_enabled: " << (unsigned)db->device_conf.dfs_reentry_enabled;
LOG(DEBUG) << "backhaul_preferred_radio_band: "
<< (unsigned)msg->platform_settings().backhaul_preferred_radio_band;
LOG(DEBUG) << "rdkb_extensions: " << (unsigned)msg->platform_settings().rdkb_extensions_enabled;
<< (unsigned)db->device_conf.back_radio.backhaul_preferred_radio_band;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
LOG(DEBUG) << "rdkb_extensions: " << (unsigned)db->device_conf.rdkb_extensions_enabled;

return true;
}
Expand Down Expand Up @@ -652,7 +648,7 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx)
do {
LOG(TRACE) << "Trying to read settings of iface:" << strIfaceName
<< ", attempt=" << int(retry_cnt);
if (fill_platform_settings(strIfaceName, register_response, platform_common_conf,
if (fill_platform_settings(strIfaceName, platform_common_conf,
bpl_iface_wlan_params_map, sd)) {
register_response->valid() = 1;
} else {
Expand Down
61 changes: 37 additions & 24 deletions agent/src/beerocks/slave/son_slave_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd,
if (request_in->params().use_optional_ssid &&
std::string((char *)request_in->params().ssid).empty()) {
//LOG(DEBUG) << "ssid field is empty! using slave ssid -> " << config.ssid;
string_utils::copy_string(request_in->params().ssid, platform_settings.front_ssid,
string_utils::copy_string(request_in->params().ssid, db->device_conf.front_radio.ssid,
message::WIFI_SSID_MAX_LENGTH);
}

Expand Down Expand Up @@ -1320,10 +1320,9 @@ bool slave_thread::handle_cmdu_platform_manager_message(
return true;
}

platform_settings = response->platform_settings();
wlan_settings = response->wlan_settings();

auto db = AgentDB::get();
auto db = AgentDB::get();
wlan_settings.band_enabled = db->device_conf.wlan_settings.band_enabled;
wlan_settings.channel = db->device_conf.wlan_settings.channel;

/**
* On GW platform the ethernet interface which is used for backhaul connection must be
Expand All @@ -1336,9 +1335,8 @@ bool slave_thread::handle_cmdu_platform_manager_message(
db->ethernet.mac = network_utils::ZERO_MAC;
}

configuration_stop_on_failure_attempts =
response->platform_settings().stop_on_failure_attempts;
stop_on_failure_attempts = configuration_stop_on_failure_attempts;
configuration_stop_on_failure_attempts = db->device_conf.stop_on_failure_attempts;
stop_on_failure_attempts = configuration_stop_on_failure_attempts;

LOG(TRACE) << "goto STATE_CONNECT_TO_BACKHAUL_MANAGER";
slave_state = STATE_CONNECT_TO_BACKHAUL_MANAGER;
Expand Down Expand Up @@ -2978,8 +2976,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH);

request->sta_iface_filter_low() = config.backhaul_wireless_iface_filter_low;
request->onboarding() = platform_settings.onboarding;
request->certification_mode() = platform_settings.certification_mode;
request->onboarding() = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you remove this field from the message?

request->certification_mode() = db->device_conf.certification_mode;

LOG(INFO) << "ACTION_BACKHAUL_REGISTER_REQUEST "
<< " hostap_iface=" << request->hostap_iface(message::IFACE_NAME_LENGTH)
Expand Down Expand Up @@ -3007,12 +3005,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
case STATE_JOIN_INIT: {

auto db = AgentDB::get();
LOG(DEBUG) << "onboarding: " << int(platform_settings.onboarding);
if (platform_settings.onboarding) {
LOG(TRACE) << "goto STATE_ONBOARDING";
slave_state = STATE_ONBOARDING;
orenvor marked this conversation as resolved.
Show resolved Hide resolved
break;
} else if (!wlan_settings.band_enabled) {
LOG(DEBUG) << "onboarding: " << int(0);
if (!wlan_settings.band_enabled) {
LOG(DEBUG) << "wlan_settings.band_enabled=false";
LOG(TRACE) << "goto STATE_BACKHAUL_ENABLE";
slave_state = STATE_BACKHAUL_ENABLE;
Expand Down Expand Up @@ -3105,14 +3099,16 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
// to the backhaul manager will no longer be necessary, and therefore should be be
// removed completely from beerocks including the BPL.
string_utils::copy_string(bh_enable->ssid(message::WIFI_SSID_MAX_LENGTH),
platform_settings.back_ssid, message::WIFI_SSID_MAX_LENGTH);
db->device_conf.back_radio.ssid,
message::WIFI_SSID_MAX_LENGTH);
string_utils::copy_string(bh_enable->pass(message::WIFI_PASS_MAX_LENGTH),
platform_settings.back_pass, message::WIFI_PASS_MAX_LENGTH);
db->device_conf.back_radio.pass,
message::WIFI_PASS_MAX_LENGTH);
bh_enable->security_type() = static_cast<uint32_t>(
platform_to_bwl_security(platform_settings.back_security_type));
bh_enable->mem_only_psk() = platform_settings.mem_only_psk;
platform_to_bwl_security(db->device_conf.back_radio.security_type));
bh_enable->mem_only_psk() = db->device_conf.back_radio.mem_only_psk;
bh_enable->backhaul_preferred_radio_band() =
platform_settings.backhaul_preferred_radio_band;
db->device_conf.back_radio.backhaul_preferred_radio_band;

string_utils::copy_string(bh_enable->wire_iface(message::IFACE_NAME_LENGTH),
db->ethernet.iface_name.c_str(), message::IFACE_NAME_LENGTH);
Expand Down Expand Up @@ -3367,7 +3363,24 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
}

//Platform Settings
notification->platform_settings() = platform_settings;
notification->platform_settings().client_band_steering_enabled =
db->device_conf.client_band_steering_enabled;
notification->platform_settings().client_optimal_path_roaming_enabled =
db->device_conf.client_optimal_path_roaming_enabled;
notification->platform_settings().dfs_reentry_enabled =
db->device_conf.dfs_reentry_enabled;
notification->platform_settings()
.client_optimal_path_roaming_prefer_signal_strength_enabled =
db->device_conf.client_optimal_path_roaming_prefer_signal_strength_enabled;
notification->platform_settings().client_11k_roaming_enabled =
db->device_conf.client_11k_roaming_enabled;
notification->platform_settings().load_balancing_enabled =
db->device_conf.load_balancing_enabled;
notification->platform_settings().service_fairness_enabled =
db->device_conf.service_fairness_enabled;
notification->platform_settings().rdkb_extensions_enabled =
db->device_conf.rdkb_extensions_enabled;

notification->platform_settings().local_master = db->device_conf.local_controller;

//Wlan Settings
Expand Down Expand Up @@ -3948,7 +3961,7 @@ bool slave_thread::handle_autoconfiguration_wsc(Socket *sd, ieee1905_1::CmduMess
// All EasyMesh VAPs will be stored in the platform DB.
// All other VAPs are manual, AKA should not be modified by prplMesh
////////////////////////////////////////////////////////////////////
if (platform_settings.management_mode != BPL_MGMT_MODE_NOT_MULTIAP) {
if (db->device_conf.management_mode != BPL_MGMT_MODE_NOT_MULTIAP) {
message_com::send_cmdu(ap_manager_socket, cmdu_tx);
} else {
LOG(WARNING) << "non-EasyMesh mode - skip updating VAP credentials";
Expand Down Expand Up @@ -4711,7 +4724,7 @@ bool slave_thread::handle_channel_selection_request(Socket *sd, ieee1905_1::Cmdu
// and in this case don't switch channel
//
////////////////////////////////////////////////////////////////////
if (platform_settings.management_mode != BPL_MGMT_MODE_NOT_MULTIAP) {
if (db->device_conf.management_mode != BPL_MGMT_MODE_NOT_MULTIAP) {
message_com::send_cmdu(ap_manager_socket, cmdu_tx);
} else {
LOG(WARNING) << "non-EasyMesh mode - skip channel switch";
Expand Down
3 changes: 1 addition & 2 deletions agent/src/beerocks/slave/son_slave_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class slave_thread : public beerocks::socket_thread {
std::string backhaul_manager_uds;
std::string platform_manager_uds;
sSlaveConfig config;
beerocks_message::sPlatformSettings platform_settings; // from platform manager //
beerocks_message::sWlanSettings wlan_settings; // from platform manager //
beerocks_message::sWlanSettings wlan_settings; // from platform manager //
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add proper doxygen documentation

beerocks_message::sSonConfig son_config;
beerocks::logging &logger;
std::string master_version;
Expand Down
Loading