-
Notifications
You must be signed in to change notification settings - Fork 32
[PPM-275] Replace CLIENT_BEACON_11K_REQUEST/RESPONSE on the standard one #1585
base: master
Are you sure you want to change the base?
Changes from all commits
6ccbcea
a7422b0
22af675
b2b47bc
af1aef0
d7ba835
6cab1f8
f5f1dab
e0247a5
a95d340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |||||||||
| #include <beerocks/tlvf/beerocks_message.h> | ||||||||||
|
|
||||||||||
| #include <tlvf/wfa_map/tlvApMetricQuery.h> | ||||||||||
| #include <tlvf/wfa_map/tlvBeaconMetricsQuery.h> | ||||||||||
| #include <tlvf/wfa_map/tlvBeaconMetricsResponse.h> | ||||||||||
|
|
||||||||||
| #include <cmath> | ||||||||||
| #include <vector> | ||||||||||
|
|
@@ -659,6 +661,33 @@ bool monitor_thread::create_ap_metrics_response(uint16_t mid, | |||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool monitor_thread::create_beacon_metrics_response(uint16_t mid, | ||||||||||
| const bwl::SBeaconResponse11k &hal_data) | ||||||||||
| { | ||||||||||
| auto beacon_response = | ||||||||||
| cmdu_tx.create(mid, ieee1905_1::eMessageType::BEACON_METRICS_RESPONSE_MESSAGE); | ||||||||||
|
|
||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||||||||||
| if (!beacon_response) { | ||||||||||
| LOG(ERROR) << "Failed to create BEACON_METRICS_RESPONSE_MESSAGE"; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| auto beacon_metrics_response_tlv = cmdu_tx.addClass<wfa_map::tlvBeaconMetricsResponse>(); | ||||||||||
|
|
||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||||||||||
| if (!beacon_metrics_response_tlv) { | ||||||||||
| LOG(ERROR) << "Failed addClass<wfa_map::tlvBeaconMetricsResponse>"; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TODO: Add filling up the correct data according to the specification. | ||||||||||
|
|
||||||||||
| std::copy_n(hal_data.sta_mac.oct, sizeof(hal_data.sta_mac.oct), | ||||||||||
| beacon_metrics_response_tlv->associated_sta_mac().oct); | ||||||||||
| beacon_response->finalize(); | ||||||||||
|
|
||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool monitor_thread::update_sta_stats() | ||||||||||
| { | ||||||||||
| auto poll_cnt = mon_db.get_poll_cnt(); | ||||||||||
|
|
@@ -1381,6 +1410,8 @@ bool monitor_thread::handle_cmdu_ieee1905_1_message(Socket &sd, ieee1905_1::Cmdu | |||||||||
| return handle_ap_metrics_query(sd, cmdu_rx); | ||||||||||
| case ieee1905_1::eMessageType::MULTI_AP_POLICY_CONFIG_REQUEST_MESSAGE: | ||||||||||
| return handle_multi_ap_policy_config_request(sd, cmdu_rx); | ||||||||||
| case ieee1905_1::eMessageType::BEACON_METRICS_QUERY_MESSAGE: | ||||||||||
| return handle_beacon_metrics_query(sd, cmdu_rx); | ||||||||||
| default: | ||||||||||
| LOG(ERROR) << "Unknown CMDU message type: " << std::hex << int(cmdu_message_type); | ||||||||||
| } | ||||||||||
|
|
@@ -1480,6 +1511,88 @@ bool monitor_thread::handle_ap_metrics_query(Socket &sd, ieee1905_1::CmduMessage | |||||||||
| return message_com::send_cmdu(slave_socket, cmdu_tx); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool monitor_thread::handle_beacon_metrics_query(Socket &sd, ieee1905_1::CmduMessageRx &cmdu_rx) | ||||||||||
| { | ||||||||||
| const auto mid = cmdu_rx.getMessageId(); | ||||||||||
| int dialog_token; | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is used only to create the request at the end to the function, should be moved closer to point of use |
||||||||||
| auto beacon_metrics_query_tlv = cmdu_rx.getClass<wfa_map::tlvBeaconMetricsQuery>(); | ||||||||||
| if (!beacon_metrics_query_tlv) { | ||||||||||
| LOG(ERROR) << "Beacon Metrics Query CMDU mid=" << mid | ||||||||||
| << " does not have Beacon Metric Query TLV"; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bwl::SBeaconRequest11k bwl_request; | ||||||||||
|
|
||||||||||
| bwl_request.measurement_mode = beerocks::MEASURE_MODE_ACTIVE; | ||||||||||
| bwl_request.channel = beacon_metrics_query_tlv->channel_number(); | ||||||||||
| bwl_request.op_class = beacon_metrics_query_tlv->operating_class(); | ||||||||||
| bwl_request.repeats = 0; | ||||||||||
| bwl_request.rand_ival = beerocks::BEACON_MEASURE_DEFAULT_RANDOMIZATION_INTERVAL; | ||||||||||
|
|
||||||||||
| bwl_request.duration = beerocks::BEACON_MEASURE_DEFAULT_ACTIVE_DURATION; | ||||||||||
|
|
||||||||||
| std::copy_n(beacon_metrics_query_tlv->associated_sta_mac().oct, sizeof(bwl_request.sta_mac.oct), | ||||||||||
| bwl_request.sta_mac.oct); | ||||||||||
|
|
||||||||||
| std::copy_n(beacon_metrics_query_tlv->bssid().oct, sizeof(bwl_request.bssid.oct), | ||||||||||
| bwl_request.bssid.oct); | ||||||||||
|
|
||||||||||
| bwl_request.parallel = 0; | ||||||||||
| bwl_request.enable = 0; | ||||||||||
| bwl_request.request = 1; | ||||||||||
| bwl_request.report = beacon_metrics_query_tlv->reporting_detail_value(); | ||||||||||
| bwl_request.mandatory_duration = 0; | ||||||||||
| bwl_request.expected_reports_count = 1; | ||||||||||
| bwl_request.use_optional_ssid = 0; | ||||||||||
|
|
||||||||||
| auto ap_ch_report_length = beacon_metrics_query_tlv->ap_channel_reports_list_length(); | ||||||||||
|
|
||||||||||
| if (ap_ch_report_length != 0 && bwl_request.channel != 255) { | ||||||||||
| LOG(ERROR) << "inconsistency between channel report length and channel number. please take " | ||||||||||
| "look at the specification. v1 17.2.27"; | ||||||||||
|
Comment on lines
+1552
to
+1553
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (ap_ch_report_length > 1) { | ||||||||||
| // the reason we support only 1 channel list is that the hostapd does not support more | ||||||||||
| // there is no way to tell it for which operating class which channels to use | ||||||||||
|
Comment on lines
+1558
to
+1559
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| LOG(ERROR) | ||||||||||
| << "too many channles requested (the maximum is 237, current support is only for 1): " | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| << +ap_ch_report_length; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // we support only one | ||||||||||
| if (1 == ap_ch_report_length) { | ||||||||||
|
|
||||||||||
| // get the first (and currently only) structure from the list | ||||||||||
| auto channel = beacon_metrics_query_tlv->ap_channel_reports_list(0); | ||||||||||
| if (!std::get<0>(channel)) { | ||||||||||
| LOG(ERROR) << "there should be a structure at index 0, but it wasn't found"; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // the number of channels, excluding the first operating class | ||||||||||
| bwl_request.use_optional_ap_ch_report = | ||||||||||
| std::get<1>(channel).ap_channel_report_list_length() - 1; | ||||||||||
|
|
||||||||||
| // the first index in the tlv's channel-report-list is the operating class, | ||||||||||
| // we skip it. using pointer arithmethics and copying one element less from the source (we skip the operation class) | ||||||||||
| for (int idx = 0; idx < bwl_request.use_optional_ap_ch_report; ++idx) { | ||||||||||
| bwl_request.ap_ch_report[idx] = *std::get<1>(channel).ap_channel_report_list(idx + 1); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| auto request = mon_wlan_hal->sta_beacon_11k_request(bwl_request, dialog_token); | ||||||||||
|
|
||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||||||||||
| if (!request) { | ||||||||||
| LOG(ERROR) << "BWL method sta_beacon_11k_request failed."; | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event_ptr) | ||||||||||
| { | ||||||||||
| if (!event_ptr) { | ||||||||||
|
|
@@ -1568,62 +1681,19 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event | |||||||||
| case Event::RRM_Beacon_Response: { | ||||||||||
|
|
||||||||||
| auto hal_data = static_cast<bwl::SBeaconResponse11k *>(data); | ||||||||||
| int id = 0; | ||||||||||
| LOG(INFO) << "Received beacon measurement response on BSSID: " | ||||||||||
| << (sMacAddr &)hal_data->bssid | ||||||||||
| << ", dialog_token: " << int(hal_data->dialog_token); | ||||||||||
|
|
||||||||||
| // TODO: Can be changed to iterator loop? | ||||||||||
| auto event_map = pending_11k_events.equal_range("RRM_EVENT_BEACON_REP_RXED"); | ||||||||||
| for (auto it = event_map.first; it != event_map.second;) { | ||||||||||
| if ((it->second.dialog_token == hal_data->dialog_token) || | ||||||||||
| (hal_data->dialog_token == 0)) { | ||||||||||
|
|
||||||||||
| id = it->second.id; | ||||||||||
|
|
||||||||||
| auto response = message_com::create_vs_message< | ||||||||||
| beerocks_message::cACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE>(cmdu_tx, id); | ||||||||||
| if (response == nullptr) { | ||||||||||
| LOG(ERROR) | ||||||||||
| << "Failed building cACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE message!"; | ||||||||||
| break; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TODO: TEMPORARY CONVERSION! | ||||||||||
| response->params().channel = hal_data->channel; | ||||||||||
| response->params().op_class = hal_data->op_class; | ||||||||||
| response->params().dialog_token = hal_data->dialog_token; | ||||||||||
| response->params().measurement_token = hal_data->measurement_token; | ||||||||||
| response->params().rep_mode = hal_data->rep_mode; | ||||||||||
| response->params().phy_type = hal_data->phy_type; | ||||||||||
| response->params().frame_type = hal_data->frame_type; | ||||||||||
| response->params().rcpi = hal_data->rcpi; | ||||||||||
| response->params().rsni = hal_data->rsni; | ||||||||||
| response->params().ant_id = hal_data->ant_id; | ||||||||||
| response->params().duration = hal_data->duration; | ||||||||||
| response->params().parent_tsf = hal_data->parent_tsf; | ||||||||||
| response->params().start_time = hal_data->start_time; | ||||||||||
| response->params().new_ch_width = hal_data->new_ch_width; | ||||||||||
| response->params().new_ch_center_freq_seg_0 = hal_data->new_ch_center_freq_seg_0; | ||||||||||
| response->params().new_ch_center_freq_seg_1 = hal_data->new_ch_center_freq_seg_1; | ||||||||||
| response->params().use_optional_wide_band_ch_switch = | ||||||||||
| hal_data->use_optional_wide_band_ch_switch; | ||||||||||
| std::copy_n(hal_data->sta_mac.oct, sizeof(response->params().sta_mac.oct), | ||||||||||
| response->params().sta_mac.oct); | ||||||||||
| std::copy_n(hal_data->bssid.oct, sizeof(response->params().bssid.oct), | ||||||||||
| response->params().bssid.oct); | ||||||||||
|
|
||||||||||
| it = pending_11k_events.erase(it); | ||||||||||
| LOG(INFO) << "Sending beacon measurement reponse on BSSID: " | ||||||||||
| << response->params().bssid << " to task_id: " << id; | ||||||||||
|
|
||||||||||
| message_com::send_cmdu(slave_socket, cmdu_tx); | ||||||||||
| break; | ||||||||||
| } else { | ||||||||||
| ++it; | ||||||||||
| } | ||||||||||
| if (!create_beacon_metrics_response(0, *hal_data)) { | ||||||||||
| LOG(ERROR) << "Failed create_beacon_metrics_response."; | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| LOG(DEBUG) << "Sending BEACON_METRICS_RESPONSE to slave_socket."; | ||||||||||
|
|
||||||||||
| return message_com::send_cmdu(slave_socket, cmdu_tx); | ||||||||||
|
|
||||||||||
| } break; | ||||||||||
|
|
||||||||||
| case Event::AP_Enabled: { | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,6 +82,15 @@ class monitor_thread : public beerocks::socket_thread { | |||||
| */ | ||||||
| bool create_ap_metrics_response(uint16_t mid, const std::vector<sMacAddr> &bssid_list); | ||||||
|
|
||||||
| /** | ||||||
| * @brief Creates Beacon Metrics Response message | ||||||
| * | ||||||
| * @param mid Message ID. | ||||||
| * @param hal_data Data received from hostapd. | ||||||
| * @return True on success and false otherwise. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
no need to capitalized reserved keywords |
||||||
| */ | ||||||
| bool create_beacon_metrics_response(uint16_t mid, const bwl::SBeaconResponse11k &hal_data); | ||||||
|
|
||||||
| bool update_ap_stats(); | ||||||
| bool update_sta_stats(); | ||||||
|
|
||||||
|
|
@@ -146,6 +155,7 @@ class monitor_thread : public beerocks::socket_thread { | |||||
|
|
||||||
| bool handle_multi_ap_policy_config_request(Socket &sd, ieee1905_1::CmduMessageRx &cmdu_rx); | ||||||
| bool handle_ap_metrics_query(Socket &sd, ieee1905_1::CmduMessageRx &cmdu_rx); | ||||||
| bool handle_beacon_metrics_query(Socket &sd, ieee1905_1::CmduMessageRx &cmdu_rx); | ||||||
| }; | ||||||
| } // namespace son | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -376,6 +376,8 @@ bool slave_thread::handle_cmdu_monitor_ieee1905_1_message(Socket &sd, | |
| switch (cmdu_message_type) { | ||
| case ieee1905_1::eMessageType::AP_METRICS_RESPONSE_MESSAGE: | ||
| return handle_monitor_ap_metrics_response(sd, cmdu_rx); | ||
| case ieee1905_1::eMessageType::BEACON_METRICS_RESPONSE_MESSAGE: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in commit message: |
||
| return handle_monitor_beacon_metrics_response(sd, cmdu_rx); | ||
| default: | ||
| LOG(ERROR) << "Unknown CMDU message type: " << std::hex << int(cmdu_message_type); | ||
| return false; | ||
|
|
@@ -4320,25 +4322,15 @@ bool slave_thread::handle_client_steering_request(Socket *sd, ieee1905_1::CmduMe | |
|
|
||
| bool slave_thread::handle_beacon_metrics_query(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) | ||
| { | ||
| auto mid = cmdu_rx.getMessageId(); | ||
| LOG(DEBUG) << "Received BEACON_METRICS_QUERY_MESSAGE, mid=" << std::hex << int(mid); | ||
|
|
||
| // create vs message | ||
| auto request_out = | ||
| message_com::create_vs_message<beerocks_message::cACTION_MONITOR_CLIENT_BEACON_11K_REQUEST>( | ||
| cmdu_tx, mid); | ||
| if (request_out == nullptr) { | ||
| LOG(ERROR) << "Failed building ACTION_MONITOR_CLIENT_BEACON_11K_REQUEST message!"; | ||
| return false; | ||
| } | ||
|
|
||
| if (!gate::load(request_out, cmdu_rx)) { | ||
| LOG(ERROR) << "faild translating 1905 message to vs message"; | ||
| const auto mid = cmdu_rx.getMessageId(); | ||
| LOG(DEBUG) << "Forwarding BEACON_METRICS_QUERY_MESSAGE to monitor_socket, mid=" << std::hex | ||
| << int(mid); | ||
| uint16_t length = message_com::get_uds_header(cmdu_rx)->length; | ||
| cmdu_rx.swap(); // swap back before forwarding | ||
| if (!message_com::forward_cmdu_to_uds(monitor_socket, cmdu_rx, length)) { | ||
| LOG(ERROR) << "Failed forwarding BEACON_METRICS_QUERY_MESSAGE message to monitor_socket"; | ||
| return false; | ||
| } | ||
|
|
||
| message_com::send_cmdu(monitor_socket, cmdu_tx); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -4373,6 +4365,45 @@ bool slave_thread::handle_monitor_ap_metrics_response(Socket &sd, | |
| return true; | ||
| } | ||
|
|
||
| bool slave_thread::handle_monitor_beacon_metrics_response(Socket &sd, | ||
| ieee1905_1::CmduMessageRx &cmdu_rx) | ||
| { | ||
| const auto mid = cmdu_rx.getMessageId(); | ||
| LOG(DEBUG) << "Forwarding BEACON_METRICS_RESPONSE_MESSAGE to controller, mid=" << std::hex | ||
| << int(mid); | ||
|
|
||
| auto monitor_beacon_response = cmdu_rx.getClass<wfa_map::tlvBeaconMetricsResponse>(); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||
| if (!monitor_beacon_response) { | ||
| LOG(ERROR) << "Failed getClass<wfa_map::tlvBeaconMetricsResponse>"; | ||
| return false; | ||
| } | ||
|
|
||
| auto beacon_response = | ||
| cmdu_tx.create(mid, ieee1905_1::eMessageType::BEACON_METRICS_RESPONSE_MESSAGE); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||
| if (!beacon_response) { | ||
| LOG(ERROR) << "Failed to create BEACON_METRICS_RESPONSE_MESSAGE"; | ||
| return false; | ||
| } | ||
|
|
||
| auto beacon_metrics_response_tlv = cmdu_tx.addClass<wfa_map::tlvBeaconMetricsResponse>(); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line-space can be removed |
||
| if (!beacon_metrics_response_tlv) { | ||
| LOG(ERROR) << "Failed addClass<wfa_map::tlvBeaconMetricsResponse>"; | ||
| return false; | ||
| } | ||
|
|
||
| // TODO: Add filling up the correct data according to the specification. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems the monitor response and the forwarded message contain the exact same TLV: |
||
|
|
||
| beacon_metrics_response_tlv->associated_sta_mac() = | ||
| monitor_beacon_response->associated_sta_mac(); | ||
|
|
||
| beacon_response->finalize(); | ||
|
|
||
| return send_cmdu_to_controller(cmdu_tx); | ||
| } | ||
|
|
||
| bool slave_thread::handle_channel_preference_query(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) | ||
| { | ||
| const auto mid = cmdu_rx.getMessageId(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my similar comment regarding meaningful commit title:
agent: monitor_thread: add create beacon_metrics_query method