Loading system/gd/l2cap/Android.bp +3 −1 Original line number Diff line number Diff line Loading @@ -17,8 +17,9 @@ filegroup { "classic/internal/link_manager.cc", "classic/internal/signalling_manager.cc", "classic/l2cap_classic_module.cc", "internal/scheduler_fifo.cc", "internal/reassembler.cc", "internal/scheduler_fifo.cc", "internal/segmenter.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link_manager.cc", Loading @@ -42,6 +43,7 @@ filegroup { "internal/fixed_channel_allocator_test.cc", "internal/reassembler_test.cc", "internal/scheduler_fifo_test.cc", "internal/segmenter_test.cc", "l2cap_packet_test.cc", "le/internal/fixed_channel_impl_test.cc", "le/internal/fixed_channel_service_manager_test.cc", Loading system/gd/l2cap/classic/internal/dynamic_channel_impl.cc +32 −0 Original line number Diff line number Diff line Loading @@ -81,14 +81,46 @@ std::string DynamicChannelImpl::ToString() { return ss.str(); } DynamicChannelImpl::ConfigurationStatus DynamicChannelImpl::GetOutgoingConfigurationStatus() const { return outgoing_configuration_status_; } void DynamicChannelImpl::SetOutgoingConfigurationStatus(ConfigurationStatus status) { outgoing_configuration_status_ = status; } DynamicChannelImpl::ConfigurationStatus DynamicChannelImpl::GetIncomingConfigurationStatus() const { return incoming_configuration_status_; } void DynamicChannelImpl::SetIncomingConfigurationStatus(ConfigurationStatus status) { incoming_configuration_status_ = status; } Mtu DynamicChannelImpl::GetIncomingMtu() const { return incoming_mtu_; } void DynamicChannelImpl::SetIncomingMtu(Mtu mtu) { incoming_mtu_ = mtu; } RetransmissionAndFlowControlModeOption DynamicChannelImpl::GetMode() const { return mode_; } void DynamicChannelImpl::SetMode(RetransmissionAndFlowControlModeOption mode) { mode_ = mode; } FcsType DynamicChannelImpl::GetFcsType() const { return fcs_type_; } void DynamicChannelImpl::SetFcsType(FcsType fcs_type) { fcs_type_ = fcs_type; } } // namespace internal } // namespace classic } // namespace l2cap Loading system/gd/l2cap/classic/internal/dynamic_channel_impl.h +17 −6 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include "hci/address.h" #include "l2cap/cid.h" #include "l2cap/classic/dynamic_channel.h" #include "l2cap/l2cap_packets.h" #include "l2cap/mtu.h" #include "l2cap/psm.h" #include "os/handler.h" #include "os/log.h" Loading Loading @@ -67,16 +69,20 @@ class DynamicChannelImpl { enum class ConfigurationStatus { NOT_CONFIGURED, CONFIGURED }; virtual ConfigurationStatus GetOutgoingConfigurationStatus() const; virtual void SetOutgoingConfigurationStatus(ConfigurationStatus status); virtual ConfigurationStatus GetIncomingConfigurationStatus() const; virtual void SetIncomingConfigurationStatus(ConfigurationStatus status); virtual ConfigurationStatus GetOutgoingConfigurationStatus() const { return outgoing_configuration_status_; } virtual Mtu GetIncomingMtu() const; virtual void SetIncomingMtu(Mtu mtu); virtual ConfigurationStatus GetIncomingConfigurationStatus() const { return incoming_configuration_status_; } virtual RetransmissionAndFlowControlModeOption GetMode() const; virtual void SetMode(RetransmissionAndFlowControlModeOption mode); virtual FcsType GetFcsType() const; virtual void SetFcsType(FcsType fcs_type); // TODO(cmanton) Do something a little bit better than this bool local_initiated_{false}; Loading @@ -102,6 +108,11 @@ class DynamicChannelImpl { ConfigurationStatus outgoing_configuration_status_ = ConfigurationStatus::NOT_CONFIGURED; ConfigurationStatus incoming_configuration_status_ = ConfigurationStatus::NOT_CONFIGURED; Mtu incoming_mtu_ = kDefaultClassicMtu; RetransmissionAndFlowControlModeOption mode_ = RetransmissionAndFlowControlModeOption::L2CAP_BASIC; // TODO: Add all RetransmissionAndFlowControlConfigurationOptions FcsType fcs_type_ = FcsType::DEFAULT; DISALLOW_COPY_AND_ASSIGN(DynamicChannelImpl); }; Loading system/gd/l2cap/classic/internal/link.cc +3 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ void Link::Disconnect() { std::shared_ptr<FixedChannelImpl> Link::AllocateFixedChannel(Cid cid, SecurityPolicy security_policy) { auto channel = fixed_channel_allocator_.AllocateChannel(cid, security_policy); scheduler_->AttachChannel(cid, channel->GetQueueDownEnd(), cid); reassembler_.AttachChannel(cid, channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(cid, channel->GetQueueDownEnd(), nullptr); return channel; } Loading Loading @@ -96,7 +96,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateDynamicChannel(Psm psm, Cid re auto channel = dynamic_channel_allocator_.AllocateChannel(psm, remote_cid, security_policy); if (channel != nullptr) { scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid()); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel); } channel->local_initiated_ = false; return channel; Loading @@ -107,7 +107,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateReservedDynamicChannel(Cid res auto channel = dynamic_channel_allocator_.AllocateReservedChannel(reserved_cid, psm, remote_cid, security_policy); if (channel != nullptr) { scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid()); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel); } channel->local_initiated_ = true; return channel; Loading system/gd/l2cap/classic/internal/signalling_manager.cc +31 −1 Original line number Diff line number Diff line Loading @@ -183,12 +183,42 @@ void ClassicSignallingManager::OnConnectionResponse(SignalId signal_id, Cid remo } void ClassicSignallingManager::OnConfigurationRequest(SignalId signal_id, Cid cid, Continuation is_continuation, std::vector<std::unique_ptr<ConfigurationOption>> option) { std::vector<std::unique_ptr<ConfigurationOption>> options) { auto channel = channel_allocator_->FindChannelByCid(cid); if (channel == nullptr) { LOG_WARN("Configuration request for an unknown channel"); return; } for (auto& option : options) { switch (option->type_) { case ConfigurationOptionType::MTU: { channel->SetIncomingMtu(MtuConfigurationOption::Specialize(option.get())->mtu_); break; } case ConfigurationOptionType::FLUSH_TIMEOUT: { // TODO: Handle this configuration option break; } case ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL: { auto config = RetransmissionAndFlowControlConfigurationOption::Specialize(option.get()); channel->SetMode(config->mode_); break; } case ConfigurationOptionType::FRAME_CHECK_SEQUENCE: { channel->SetFcsType(FrameCheckSequenceOption::Specialize(option.get())->fcs_type_); break; } default: LOG_WARN("Received some unsupported configuration option: %d", static_cast<int>(option->type_)); auto response = ConfigurationResponseBuilder::Create(signal_id.Value(), channel->GetRemoteCid(), is_continuation, ConfigurationResponseResult::UNKNOWN_OPTIONS, {}); enqueue_buffer_->Enqueue(std::move(response), handler_); return; } } auto response = ConfigurationResponseBuilder::Create(signal_id.Value(), channel->GetRemoteCid(), is_continuation, ConfigurationResponseResult::SUCCESS, {}); enqueue_buffer_->Enqueue(std::move(response), handler_); Loading Loading
system/gd/l2cap/Android.bp +3 −1 Original line number Diff line number Diff line Loading @@ -17,8 +17,9 @@ filegroup { "classic/internal/link_manager.cc", "classic/internal/signalling_manager.cc", "classic/l2cap_classic_module.cc", "internal/scheduler_fifo.cc", "internal/reassembler.cc", "internal/scheduler_fifo.cc", "internal/segmenter.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link_manager.cc", Loading @@ -42,6 +43,7 @@ filegroup { "internal/fixed_channel_allocator_test.cc", "internal/reassembler_test.cc", "internal/scheduler_fifo_test.cc", "internal/segmenter_test.cc", "l2cap_packet_test.cc", "le/internal/fixed_channel_impl_test.cc", "le/internal/fixed_channel_service_manager_test.cc", Loading
system/gd/l2cap/classic/internal/dynamic_channel_impl.cc +32 −0 Original line number Diff line number Diff line Loading @@ -81,14 +81,46 @@ std::string DynamicChannelImpl::ToString() { return ss.str(); } DynamicChannelImpl::ConfigurationStatus DynamicChannelImpl::GetOutgoingConfigurationStatus() const { return outgoing_configuration_status_; } void DynamicChannelImpl::SetOutgoingConfigurationStatus(ConfigurationStatus status) { outgoing_configuration_status_ = status; } DynamicChannelImpl::ConfigurationStatus DynamicChannelImpl::GetIncomingConfigurationStatus() const { return incoming_configuration_status_; } void DynamicChannelImpl::SetIncomingConfigurationStatus(ConfigurationStatus status) { incoming_configuration_status_ = status; } Mtu DynamicChannelImpl::GetIncomingMtu() const { return incoming_mtu_; } void DynamicChannelImpl::SetIncomingMtu(Mtu mtu) { incoming_mtu_ = mtu; } RetransmissionAndFlowControlModeOption DynamicChannelImpl::GetMode() const { return mode_; } void DynamicChannelImpl::SetMode(RetransmissionAndFlowControlModeOption mode) { mode_ = mode; } FcsType DynamicChannelImpl::GetFcsType() const { return fcs_type_; } void DynamicChannelImpl::SetFcsType(FcsType fcs_type) { fcs_type_ = fcs_type; } } // namespace internal } // namespace classic } // namespace l2cap Loading
system/gd/l2cap/classic/internal/dynamic_channel_impl.h +17 −6 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include "hci/address.h" #include "l2cap/cid.h" #include "l2cap/classic/dynamic_channel.h" #include "l2cap/l2cap_packets.h" #include "l2cap/mtu.h" #include "l2cap/psm.h" #include "os/handler.h" #include "os/log.h" Loading Loading @@ -67,16 +69,20 @@ class DynamicChannelImpl { enum class ConfigurationStatus { NOT_CONFIGURED, CONFIGURED }; virtual ConfigurationStatus GetOutgoingConfigurationStatus() const; virtual void SetOutgoingConfigurationStatus(ConfigurationStatus status); virtual ConfigurationStatus GetIncomingConfigurationStatus() const; virtual void SetIncomingConfigurationStatus(ConfigurationStatus status); virtual ConfigurationStatus GetOutgoingConfigurationStatus() const { return outgoing_configuration_status_; } virtual Mtu GetIncomingMtu() const; virtual void SetIncomingMtu(Mtu mtu); virtual ConfigurationStatus GetIncomingConfigurationStatus() const { return incoming_configuration_status_; } virtual RetransmissionAndFlowControlModeOption GetMode() const; virtual void SetMode(RetransmissionAndFlowControlModeOption mode); virtual FcsType GetFcsType() const; virtual void SetFcsType(FcsType fcs_type); // TODO(cmanton) Do something a little bit better than this bool local_initiated_{false}; Loading @@ -102,6 +108,11 @@ class DynamicChannelImpl { ConfigurationStatus outgoing_configuration_status_ = ConfigurationStatus::NOT_CONFIGURED; ConfigurationStatus incoming_configuration_status_ = ConfigurationStatus::NOT_CONFIGURED; Mtu incoming_mtu_ = kDefaultClassicMtu; RetransmissionAndFlowControlModeOption mode_ = RetransmissionAndFlowControlModeOption::L2CAP_BASIC; // TODO: Add all RetransmissionAndFlowControlConfigurationOptions FcsType fcs_type_ = FcsType::DEFAULT; DISALLOW_COPY_AND_ASSIGN(DynamicChannelImpl); }; Loading
system/gd/l2cap/classic/internal/link.cc +3 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ void Link::Disconnect() { std::shared_ptr<FixedChannelImpl> Link::AllocateFixedChannel(Cid cid, SecurityPolicy security_policy) { auto channel = fixed_channel_allocator_.AllocateChannel(cid, security_policy); scheduler_->AttachChannel(cid, channel->GetQueueDownEnd(), cid); reassembler_.AttachChannel(cid, channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(cid, channel->GetQueueDownEnd(), nullptr); return channel; } Loading Loading @@ -96,7 +96,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateDynamicChannel(Psm psm, Cid re auto channel = dynamic_channel_allocator_.AllocateChannel(psm, remote_cid, security_policy); if (channel != nullptr) { scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid()); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel); } channel->local_initiated_ = false; return channel; Loading @@ -107,7 +107,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateReservedDynamicChannel(Cid res auto channel = dynamic_channel_allocator_.AllocateReservedChannel(reserved_cid, psm, remote_cid, security_policy); if (channel != nullptr) { scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid()); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), {}); reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel); } channel->local_initiated_ = true; return channel; Loading
system/gd/l2cap/classic/internal/signalling_manager.cc +31 −1 Original line number Diff line number Diff line Loading @@ -183,12 +183,42 @@ void ClassicSignallingManager::OnConnectionResponse(SignalId signal_id, Cid remo } void ClassicSignallingManager::OnConfigurationRequest(SignalId signal_id, Cid cid, Continuation is_continuation, std::vector<std::unique_ptr<ConfigurationOption>> option) { std::vector<std::unique_ptr<ConfigurationOption>> options) { auto channel = channel_allocator_->FindChannelByCid(cid); if (channel == nullptr) { LOG_WARN("Configuration request for an unknown channel"); return; } for (auto& option : options) { switch (option->type_) { case ConfigurationOptionType::MTU: { channel->SetIncomingMtu(MtuConfigurationOption::Specialize(option.get())->mtu_); break; } case ConfigurationOptionType::FLUSH_TIMEOUT: { // TODO: Handle this configuration option break; } case ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL: { auto config = RetransmissionAndFlowControlConfigurationOption::Specialize(option.get()); channel->SetMode(config->mode_); break; } case ConfigurationOptionType::FRAME_CHECK_SEQUENCE: { channel->SetFcsType(FrameCheckSequenceOption::Specialize(option.get())->fcs_type_); break; } default: LOG_WARN("Received some unsupported configuration option: %d", static_cast<int>(option->type_)); auto response = ConfigurationResponseBuilder::Create(signal_id.Value(), channel->GetRemoteCid(), is_continuation, ConfigurationResponseResult::UNKNOWN_OPTIONS, {}); enqueue_buffer_->Enqueue(std::move(response), handler_); return; } } auto response = ConfigurationResponseBuilder::Create(signal_id.Value(), channel->GetRemoteCid(), is_continuation, ConfigurationResponseResult::SUCCESS, {}); enqueue_buffer_->Enqueue(std::move(response), handler_); Loading