Loading tools/rootcanal/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,7 @@ cc_test_host { srcs: [ "test/async_manager_unittest.cc", "test/h4_parser_unittest.cc", "test/pcap_filter_unittest.cc", "test/posix_socket_unittest.cc", ], header_libs: [ Loading tools/rootcanal/include/hci/pcap_filter.h +3 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ class PcapFilter final { std::vector<uint8_t> FilterHciCommand(std::vector<uint8_t> const& packet); std::vector<uint8_t> FilterHciEvent(std::vector<uint8_t> const& packet); private: // Specific filters for HCI commands. std::vector<uint8_t> FilterWriteLocalName( bluetooth::hci::CommandView& command); Loading Loading @@ -87,9 +86,8 @@ class PcapFilter final { // Specific filter for any Gap data array. // The Gap data entries are modified in place. void FilterGapData(std::vector<bluetooth::hci::GapData>& gap_data); void FilterLengthAndData( std::vector<bluetooth::hci::LengthAndData>& gap_data); void FilterGapData(uint8_t* gap_data, size_t gap_data_len); void FilterGapData(std::vector<uint8_t>& gap_data); // Helpers to replace local names. std::array<uint8_t, 248> ChangeDeviceName( Loading @@ -97,6 +95,7 @@ class PcapFilter final { std::vector<uint8_t> ChangeDeviceName( std::vector<uint8_t> const& device_name); private: // Map device names to anonymous replacements. std::vector<std::pair<std::vector<uint8_t>, std::vector<uint8_t>>> device_name_map{}; Loading tools/rootcanal/lib/hci/pcap_filter.cc +48 −37 Original line number Diff line number Diff line Loading @@ -168,41 +168,50 @@ static std::vector<uint8_t> FilterHciIso(std::vector<uint8_t> const& packet) { } // Replace device names in GAP entries. void PcapFilter::FilterGapData(std::vector<GapData>& gap_data) { for (GapData& entry : gap_data) { switch (entry.data_type_) { case GapDataType::COMPLETE_LOCAL_NAME: case GapDataType::SHORTENED_LOCAL_NAME: entry.data_ = ChangeDeviceName(entry.data_); break; default: // TODO: extended advertising reports can be chunked across multiple // events, and a single GAP data entry can be segmented in two. // The filter should account for that and keep a state for partial // GAP entries. void PcapFilter::FilterGapData(uint8_t* gap_data, size_t gap_data_len) { size_t offset = 0; while ((offset + 2) <= gap_data_len) { size_t length = gap_data[offset]; GapDataType data_type = static_cast<GapDataType>(gap_data[offset + 1]); // Truncated entry. if ((offset + length + 1) > gap_data_len) { break; } } } void PcapFilter::FilterLengthAndData( std::vector<bluetooth::hci::LengthAndData>& gap_data) { for (LengthAndData& entry : gap_data) { if (entry.data_.empty()) { // Empty entry. if (length == 0) { offset += 1; continue; } switch (GapDataType(entry.data_[0])) { // Apply the filter to entries that contain user data. switch (data_type) { case GapDataType::COMPLETE_LOCAL_NAME: case GapDataType::SHORTENED_LOCAL_NAME: { std::vector<uint8_t> device_name(entry.data_.begin() + 1, entry.data_.end()); device_name = ChangeDeviceName(device_name); entry.data_.insert(device_name.begin(), device_name.end(), entry.data_.begin() + 1); auto start_pos = gap_data + offset + 1; auto end_pos = gap_data + offset + length; std::vector<uint8_t> new_name = ChangeDeviceName(std::vector<uint8_t>{start_pos, end_pos}); std::copy(new_name.begin(), new_name.end(), start_pos); break; } default: break; } offset += length + 1; } } void PcapFilter::FilterGapData(std::vector<uint8_t>& gap_data) { FilterGapData(gap_data.data(), gap_data.size()); } // Replace the local device name. std::vector<uint8_t> PcapFilter::FilterWriteLocalName(CommandView& command) { auto parameters = WriteLocalNameView::Create(command); Loading @@ -219,9 +228,10 @@ std::vector<uint8_t> PcapFilter::FilterWriteExtendedInquiryResponse( auto parameters = WriteExtendedInquiryResponseView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); return WriteExtendedInquiryResponseBuilder::Create( parameters.GetFecRequired(), extended_inquiry_response) ->SerializeToBytes(); Loading @@ -233,7 +243,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetAdvertisingData( auto parameters = LeSetAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetAdvertisingDataBuilder::Create(advertising_data) ->SerializeToBytes(); Loading @@ -245,7 +255,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetScanResponseData( auto parameters = LeSetScanResponseDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetScanResponseDataBuilder::Create(advertising_data) ->SerializeToBytes(); Loading @@ -257,7 +267,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetExtendedAdvertisingData( auto parameters = LeSetExtendedAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetExtendedAdvertisingDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -272,7 +282,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetExtendedScanResponseData( auto parameters = LeSetExtendedScanResponseDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetScanResponseData(); std::vector<uint8_t> advertising_data = parameters.GetScanResponseData(); FilterGapData(advertising_data); return LeSetExtendedScanResponseDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -287,7 +297,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetPeriodicAdvertisingData( auto parameters = LeSetPeriodicAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetPeriodicAdvertisingDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -301,7 +311,7 @@ std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetData( auto parameters = LeMultiAdvtSetDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeMultiAdvtSetDataBuilder::Create(advertising_data, parameters.GetAdvertisingInstance()) Loading @@ -314,7 +324,7 @@ std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetScanResp( auto parameters = LeMultiAdvtSetScanRespView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeMultiAdvtSetScanRespBuilder::Create( advertising_data, parameters.GetAdvertisingInstance()) Loading Loading @@ -345,10 +355,11 @@ std::vector<uint8_t> PcapFilter::FilterReadExtendedInquiryResponseComplete( ReadExtendedInquiryResponseCompleteView::Create(command_complete); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); if (parameters.GetStatus() == ErrorCode::SUCCESS) { FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); } return ReadExtendedInquiryResponseCompleteBuilder::Create( Loading Loading @@ -379,10 +390,10 @@ std::vector<uint8_t> PcapFilter::FilterExtendedInquiryResult( auto parameters = ExtendedInquiryResultView::Create(event); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); return ExtendedInquiryResultBuilder::Create( parameters.GetAddress(), parameters.GetPageScanRepetitionMode(), parameters.GetClassOfDevice(), parameters.GetClockOffset(), Loading @@ -398,7 +409,7 @@ std::vector<uint8_t> PcapFilter::FilterLeAdvertisingReport( std::vector<LeAdvertisingResponse> responses = parameters.GetResponses(); for (auto& response : responses) { FilterLengthAndData(response.advertising_data_); FilterGapData(response.advertising_data_); } return LeAdvertisingReportBuilder::Create(responses)->SerializeToBytes(); Loading @@ -414,7 +425,7 @@ std::vector<uint8_t> PcapFilter::FilterLeExtendedAdvertisingReport( std::vector<LeExtendedAdvertisingResponse> responses = parameters.GetResponses(); for (auto& response : responses) { FilterLengthAndData(response.advertising_data_); FilterGapData(response.advertising_data_); } return LeExtendedAdvertisingReportBuilder::Create(responses) Loading tools/rootcanal/model/controller/dual_mode_controller.cc +5 −6 Original line number Diff line number Diff line Loading @@ -1592,8 +1592,7 @@ void DualModeController::LeReadAdvertisingPhysicalChannelTxPower( } void DualModeController::LeSetAdvertisingData(CommandView command) { auto command_view = bluetooth::hci::LeSetAdvertisingDataRawView::Create(command); auto command_view = bluetooth::hci::LeSetAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetAdvertisingData( command_view.GetAdvertisingData()); Loading @@ -1603,7 +1602,7 @@ void DualModeController::LeSetAdvertisingData(CommandView command) { void DualModeController::LeSetScanResponseData(CommandView command) { auto command_view = bluetooth::hci::LeSetScanResponseDataRawView::Create(command); bluetooth::hci::LeSetScanResponseDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetScanResponseData( command_view.GetAdvertisingData()); Loading Loading @@ -1945,7 +1944,7 @@ void DualModeController::LeSetPeriodicAdvertisingParameters( void DualModeController::LeSetPeriodicAdvertisingData(CommandView command) { auto command_view = bluetooth::hci::LeSetPeriodicAdvertisingDataRawView::Create(command); bluetooth::hci::LeSetPeriodicAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetPeriodicAdvertisingData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading Loading @@ -2558,7 +2557,7 @@ void DualModeController::LeSetExtendedAdvertisingData(CommandView command) { bluetooth::hci::LeSetExtendedAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); auto raw_command_view = bluetooth::hci::LeSetExtendedAdvertisingDataRawView::Create(command); bluetooth::hci::LeSetExtendedAdvertisingDataView::Create(command); ASSERT(raw_command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetExtendedAdvertisingData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading @@ -2574,7 +2573,7 @@ void DualModeController::LeSetExtendedScanResponseData(CommandView command) { bluetooth::hci::LeSetExtendedScanResponseDataView::Create(command); ASSERT(command_view.IsValid()); auto raw_command_view = bluetooth::hci::LeSetExtendedScanResponseDataRawView::Create(command); bluetooth::hci::LeSetExtendedScanResponseDataView::Create(command); ASSERT(raw_command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetExtendedScanResponseData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading tools/rootcanal/model/controller/link_layer_controller.cc +13 −16 Original line number Diff line number Diff line Loading @@ -2691,7 +2691,6 @@ void LinkLayerController::IncomingInquiryPacket( static_cast<uint8_t>(GetPageScanRepetitionMode()), class_of_device_, GetClockOffset(), rssi, extended_inquiry_response_)); } break; default: LOG_WARN("Unhandled Incoming Inquiry of type %d", Loading Loading @@ -2759,7 +2758,7 @@ void LinkLayerController::IncomingInquiryResponsePacket( basic_inquiry_response); ASSERT(inquiry_response.IsValid()); send_event_(bluetooth::hci::ExtendedInquiryResultRawBuilder::Create( send_event_(bluetooth::hci::ExtendedInquiryResultBuilder::Create( inquiry_response.GetSourceAddress(), static_cast<bluetooth::hci::PageScanRepetitionMode>( inquiry_response.GetPageScanRepetitionMode()), Loading Loading @@ -3181,7 +3180,7 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( if (LegacyAdvertising() && should_send_advertising_report && !should_send_directed_advertising_report && IsLeEventUnmasked(SubeventCode::ADVERTISING_REPORT)) { bluetooth::hci::LeAdvertisingResponseRaw response; bluetooth::hci::LeAdvertisingResponse response; response.address_type_ = resolved_advertising_address.GetAddressType(); response.address_ = resolved_advertising_address.GetAddress(); response.advertising_data_ = advertising_data; Loading @@ -3205,14 +3204,13 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( break; } send_event_( bluetooth::hci::LeAdvertisingReportRawBuilder::Create({response})); send_event_(bluetooth::hci::LeAdvertisingReportBuilder::Create({response})); } // Extended scanning. if (ExtendedAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.connectable_ = connectable_advertising; response.scannable_ = scannable_advertising; response.directed_ = directed_advertising; Loading Loading @@ -3241,8 +3239,8 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( } response.advertising_data_ = advertising_data; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( {response})); send_event_( bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create({response})); } // Did the user enable Active scanning ? Loading Loading @@ -3635,7 +3633,7 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu( if (should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.connectable_ = connectable_advertising; response.scannable_ = scannable_advertising; response.directed_ = directed_advertising; Loading Loading @@ -3680,7 +3678,7 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu( std::vector(advertising_data.begin() + offset, advertising_data.begin() + offset + fragment_size); offset += fragment_size; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( send_event_(bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create( {response})); } while (offset < advertising_data.size()); } Loading Loading @@ -5039,19 +5037,18 @@ void LinkLayerController::IncomingLeScanResponsePacket( if (LegacyAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::ADVERTISING_REPORT)) { bluetooth::hci::LeAdvertisingResponseRaw response; bluetooth::hci::LeAdvertisingResponse response; response.event_type_ = bluetooth::hci::AdvertisingEventType::SCAN_RESPONSE; response.address_ = resolved_advertising_address.GetAddress(); response.address_type_ = resolved_advertising_address.GetAddressType(); response.advertising_data_ = scan_response.GetScanResponseData(); response.rssi_ = rssi; send_event_( bluetooth::hci::LeAdvertisingReportRawBuilder::Create({response})); send_event_(bluetooth::hci::LeAdvertisingReportBuilder::Create({response})); } if (ExtendedAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.address_ = resolved_advertising_address.GetAddress(); response.address_type_ = static_cast<bluetooth::hci::DirectAdvertisingAddressType>( Loading @@ -5065,8 +5062,8 @@ void LinkLayerController::IncomingLeScanResponsePacket( response.tx_power_ = 0x7F; response.advertising_data_ = scan_response.GetScanResponseData(); response.rssi_ = rssi; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( {response})); send_event_( bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create({response})); } } Loading Loading
tools/rootcanal/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,7 @@ cc_test_host { srcs: [ "test/async_manager_unittest.cc", "test/h4_parser_unittest.cc", "test/pcap_filter_unittest.cc", "test/posix_socket_unittest.cc", ], header_libs: [ Loading
tools/rootcanal/include/hci/pcap_filter.h +3 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ class PcapFilter final { std::vector<uint8_t> FilterHciCommand(std::vector<uint8_t> const& packet); std::vector<uint8_t> FilterHciEvent(std::vector<uint8_t> const& packet); private: // Specific filters for HCI commands. std::vector<uint8_t> FilterWriteLocalName( bluetooth::hci::CommandView& command); Loading Loading @@ -87,9 +86,8 @@ class PcapFilter final { // Specific filter for any Gap data array. // The Gap data entries are modified in place. void FilterGapData(std::vector<bluetooth::hci::GapData>& gap_data); void FilterLengthAndData( std::vector<bluetooth::hci::LengthAndData>& gap_data); void FilterGapData(uint8_t* gap_data, size_t gap_data_len); void FilterGapData(std::vector<uint8_t>& gap_data); // Helpers to replace local names. std::array<uint8_t, 248> ChangeDeviceName( Loading @@ -97,6 +95,7 @@ class PcapFilter final { std::vector<uint8_t> ChangeDeviceName( std::vector<uint8_t> const& device_name); private: // Map device names to anonymous replacements. std::vector<std::pair<std::vector<uint8_t>, std::vector<uint8_t>>> device_name_map{}; Loading
tools/rootcanal/lib/hci/pcap_filter.cc +48 −37 Original line number Diff line number Diff line Loading @@ -168,41 +168,50 @@ static std::vector<uint8_t> FilterHciIso(std::vector<uint8_t> const& packet) { } // Replace device names in GAP entries. void PcapFilter::FilterGapData(std::vector<GapData>& gap_data) { for (GapData& entry : gap_data) { switch (entry.data_type_) { case GapDataType::COMPLETE_LOCAL_NAME: case GapDataType::SHORTENED_LOCAL_NAME: entry.data_ = ChangeDeviceName(entry.data_); break; default: // TODO: extended advertising reports can be chunked across multiple // events, and a single GAP data entry can be segmented in two. // The filter should account for that and keep a state for partial // GAP entries. void PcapFilter::FilterGapData(uint8_t* gap_data, size_t gap_data_len) { size_t offset = 0; while ((offset + 2) <= gap_data_len) { size_t length = gap_data[offset]; GapDataType data_type = static_cast<GapDataType>(gap_data[offset + 1]); // Truncated entry. if ((offset + length + 1) > gap_data_len) { break; } } } void PcapFilter::FilterLengthAndData( std::vector<bluetooth::hci::LengthAndData>& gap_data) { for (LengthAndData& entry : gap_data) { if (entry.data_.empty()) { // Empty entry. if (length == 0) { offset += 1; continue; } switch (GapDataType(entry.data_[0])) { // Apply the filter to entries that contain user data. switch (data_type) { case GapDataType::COMPLETE_LOCAL_NAME: case GapDataType::SHORTENED_LOCAL_NAME: { std::vector<uint8_t> device_name(entry.data_.begin() + 1, entry.data_.end()); device_name = ChangeDeviceName(device_name); entry.data_.insert(device_name.begin(), device_name.end(), entry.data_.begin() + 1); auto start_pos = gap_data + offset + 1; auto end_pos = gap_data + offset + length; std::vector<uint8_t> new_name = ChangeDeviceName(std::vector<uint8_t>{start_pos, end_pos}); std::copy(new_name.begin(), new_name.end(), start_pos); break; } default: break; } offset += length + 1; } } void PcapFilter::FilterGapData(std::vector<uint8_t>& gap_data) { FilterGapData(gap_data.data(), gap_data.size()); } // Replace the local device name. std::vector<uint8_t> PcapFilter::FilterWriteLocalName(CommandView& command) { auto parameters = WriteLocalNameView::Create(command); Loading @@ -219,9 +228,10 @@ std::vector<uint8_t> PcapFilter::FilterWriteExtendedInquiryResponse( auto parameters = WriteExtendedInquiryResponseView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); return WriteExtendedInquiryResponseBuilder::Create( parameters.GetFecRequired(), extended_inquiry_response) ->SerializeToBytes(); Loading @@ -233,7 +243,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetAdvertisingData( auto parameters = LeSetAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetAdvertisingDataBuilder::Create(advertising_data) ->SerializeToBytes(); Loading @@ -245,7 +255,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetScanResponseData( auto parameters = LeSetScanResponseDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetScanResponseDataBuilder::Create(advertising_data) ->SerializeToBytes(); Loading @@ -257,7 +267,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetExtendedAdvertisingData( auto parameters = LeSetExtendedAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetExtendedAdvertisingDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -272,7 +282,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetExtendedScanResponseData( auto parameters = LeSetExtendedScanResponseDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetScanResponseData(); std::vector<uint8_t> advertising_data = parameters.GetScanResponseData(); FilterGapData(advertising_data); return LeSetExtendedScanResponseDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -287,7 +297,7 @@ std::vector<uint8_t> PcapFilter::FilterLeSetPeriodicAdvertisingData( auto parameters = LeSetPeriodicAdvertisingDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeSetPeriodicAdvertisingDataBuilder::Create( parameters.GetAdvertisingHandle(), parameters.GetOperation(), Loading @@ -301,7 +311,7 @@ std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetData( auto parameters = LeMultiAdvtSetDataView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeMultiAdvtSetDataBuilder::Create(advertising_data, parameters.GetAdvertisingInstance()) Loading @@ -314,7 +324,7 @@ std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetScanResp( auto parameters = LeMultiAdvtSetScanRespView::Create(command); ASSERT(parameters.IsValid()); std::vector<GapData> advertising_data = parameters.GetAdvertisingData(); std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData(); FilterGapData(advertising_data); return LeMultiAdvtSetScanRespBuilder::Create( advertising_data, parameters.GetAdvertisingInstance()) Loading Loading @@ -345,10 +355,11 @@ std::vector<uint8_t> PcapFilter::FilterReadExtendedInquiryResponseComplete( ReadExtendedInquiryResponseCompleteView::Create(command_complete); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); if (parameters.GetStatus() == ErrorCode::SUCCESS) { FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); } return ReadExtendedInquiryResponseCompleteBuilder::Create( Loading Loading @@ -379,10 +390,10 @@ std::vector<uint8_t> PcapFilter::FilterExtendedInquiryResult( auto parameters = ExtendedInquiryResultView::Create(event); ASSERT(parameters.IsValid()); std::vector<GapData> extended_inquiry_response = std::array<uint8_t, 240> extended_inquiry_response = parameters.GetExtendedInquiryResponse(); FilterGapData(extended_inquiry_response); FilterGapData(extended_inquiry_response.data(), extended_inquiry_response.size()); return ExtendedInquiryResultBuilder::Create( parameters.GetAddress(), parameters.GetPageScanRepetitionMode(), parameters.GetClassOfDevice(), parameters.GetClockOffset(), Loading @@ -398,7 +409,7 @@ std::vector<uint8_t> PcapFilter::FilterLeAdvertisingReport( std::vector<LeAdvertisingResponse> responses = parameters.GetResponses(); for (auto& response : responses) { FilterLengthAndData(response.advertising_data_); FilterGapData(response.advertising_data_); } return LeAdvertisingReportBuilder::Create(responses)->SerializeToBytes(); Loading @@ -414,7 +425,7 @@ std::vector<uint8_t> PcapFilter::FilterLeExtendedAdvertisingReport( std::vector<LeExtendedAdvertisingResponse> responses = parameters.GetResponses(); for (auto& response : responses) { FilterLengthAndData(response.advertising_data_); FilterGapData(response.advertising_data_); } return LeExtendedAdvertisingReportBuilder::Create(responses) Loading
tools/rootcanal/model/controller/dual_mode_controller.cc +5 −6 Original line number Diff line number Diff line Loading @@ -1592,8 +1592,7 @@ void DualModeController::LeReadAdvertisingPhysicalChannelTxPower( } void DualModeController::LeSetAdvertisingData(CommandView command) { auto command_view = bluetooth::hci::LeSetAdvertisingDataRawView::Create(command); auto command_view = bluetooth::hci::LeSetAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetAdvertisingData( command_view.GetAdvertisingData()); Loading @@ -1603,7 +1602,7 @@ void DualModeController::LeSetAdvertisingData(CommandView command) { void DualModeController::LeSetScanResponseData(CommandView command) { auto command_view = bluetooth::hci::LeSetScanResponseDataRawView::Create(command); bluetooth::hci::LeSetScanResponseDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetScanResponseData( command_view.GetAdvertisingData()); Loading Loading @@ -1945,7 +1944,7 @@ void DualModeController::LeSetPeriodicAdvertisingParameters( void DualModeController::LeSetPeriodicAdvertisingData(CommandView command) { auto command_view = bluetooth::hci::LeSetPeriodicAdvertisingDataRawView::Create(command); bluetooth::hci::LeSetPeriodicAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetPeriodicAdvertisingData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading Loading @@ -2558,7 +2557,7 @@ void DualModeController::LeSetExtendedAdvertisingData(CommandView command) { bluetooth::hci::LeSetExtendedAdvertisingDataView::Create(command); ASSERT(command_view.IsValid()); auto raw_command_view = bluetooth::hci::LeSetExtendedAdvertisingDataRawView::Create(command); bluetooth::hci::LeSetExtendedAdvertisingDataView::Create(command); ASSERT(raw_command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetExtendedAdvertisingData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading @@ -2574,7 +2573,7 @@ void DualModeController::LeSetExtendedScanResponseData(CommandView command) { bluetooth::hci::LeSetExtendedScanResponseDataView::Create(command); ASSERT(command_view.IsValid()); auto raw_command_view = bluetooth::hci::LeSetExtendedScanResponseDataRawView::Create(command); bluetooth::hci::LeSetExtendedScanResponseDataView::Create(command); ASSERT(raw_command_view.IsValid()); ErrorCode status = link_layer_controller_.LeSetExtendedScanResponseData( command_view.GetAdvertisingHandle(), command_view.GetOperation(), Loading
tools/rootcanal/model/controller/link_layer_controller.cc +13 −16 Original line number Diff line number Diff line Loading @@ -2691,7 +2691,6 @@ void LinkLayerController::IncomingInquiryPacket( static_cast<uint8_t>(GetPageScanRepetitionMode()), class_of_device_, GetClockOffset(), rssi, extended_inquiry_response_)); } break; default: LOG_WARN("Unhandled Incoming Inquiry of type %d", Loading Loading @@ -2759,7 +2758,7 @@ void LinkLayerController::IncomingInquiryResponsePacket( basic_inquiry_response); ASSERT(inquiry_response.IsValid()); send_event_(bluetooth::hci::ExtendedInquiryResultRawBuilder::Create( send_event_(bluetooth::hci::ExtendedInquiryResultBuilder::Create( inquiry_response.GetSourceAddress(), static_cast<bluetooth::hci::PageScanRepetitionMode>( inquiry_response.GetPageScanRepetitionMode()), Loading Loading @@ -3181,7 +3180,7 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( if (LegacyAdvertising() && should_send_advertising_report && !should_send_directed_advertising_report && IsLeEventUnmasked(SubeventCode::ADVERTISING_REPORT)) { bluetooth::hci::LeAdvertisingResponseRaw response; bluetooth::hci::LeAdvertisingResponse response; response.address_type_ = resolved_advertising_address.GetAddressType(); response.address_ = resolved_advertising_address.GetAddress(); response.advertising_data_ = advertising_data; Loading @@ -3205,14 +3204,13 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( break; } send_event_( bluetooth::hci::LeAdvertisingReportRawBuilder::Create({response})); send_event_(bluetooth::hci::LeAdvertisingReportBuilder::Create({response})); } // Extended scanning. if (ExtendedAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.connectable_ = connectable_advertising; response.scannable_ = scannable_advertising; response.directed_ = directed_advertising; Loading Loading @@ -3241,8 +3239,8 @@ void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( } response.advertising_data_ = advertising_data; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( {response})); send_event_( bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create({response})); } // Did the user enable Active scanning ? Loading Loading @@ -3635,7 +3633,7 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu( if (should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.connectable_ = connectable_advertising; response.scannable_ = scannable_advertising; response.directed_ = directed_advertising; Loading Loading @@ -3680,7 +3678,7 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu( std::vector(advertising_data.begin() + offset, advertising_data.begin() + offset + fragment_size); offset += fragment_size; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( send_event_(bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create( {response})); } while (offset < advertising_data.size()); } Loading Loading @@ -5039,19 +5037,18 @@ void LinkLayerController::IncomingLeScanResponsePacket( if (LegacyAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::ADVERTISING_REPORT)) { bluetooth::hci::LeAdvertisingResponseRaw response; bluetooth::hci::LeAdvertisingResponse response; response.event_type_ = bluetooth::hci::AdvertisingEventType::SCAN_RESPONSE; response.address_ = resolved_advertising_address.GetAddress(); response.address_type_ = resolved_advertising_address.GetAddressType(); response.advertising_data_ = scan_response.GetScanResponseData(); response.rssi_ = rssi; send_event_( bluetooth::hci::LeAdvertisingReportRawBuilder::Create({response})); send_event_(bluetooth::hci::LeAdvertisingReportBuilder::Create({response})); } if (ExtendedAdvertising() && should_send_advertising_report && IsLeEventUnmasked(SubeventCode::EXTENDED_ADVERTISING_REPORT)) { bluetooth::hci::LeExtendedAdvertisingResponseRaw response; bluetooth::hci::LeExtendedAdvertisingResponse response; response.address_ = resolved_advertising_address.GetAddress(); response.address_type_ = static_cast<bluetooth::hci::DirectAdvertisingAddressType>( Loading @@ -5065,8 +5062,8 @@ void LinkLayerController::IncomingLeScanResponsePacket( response.tx_power_ = 0x7F; response.advertising_data_ = scan_response.GetScanResponseData(); response.rssi_ = rssi; send_event_(bluetooth::hci::LeExtendedAdvertisingReportRawBuilder::Create( {response})); send_event_( bluetooth::hci::LeExtendedAdvertisingReportBuilder::Create({response})); } } Loading