Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b19957b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I353f27c3,I4ce56909,Ia4a1707d,I50e6d383

* changes:
  L2CAP Reassembler: Keep a reference to DynamicChannelImpl
  L2CAP: Store channel configuration on request
  L2CAP: Decouple scheduler and segmenter
  L2CAP: Minor clean up for scheduler and mtu
parents e2a5d369 b42d6d7a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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",
@@ -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",
+32 −0
Original line number Diff line number Diff line
@@ -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
+17 −6
Original line number Diff line number Diff line
@@ -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"
@@ -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};
@@ -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);
};

+3 −3
Original line number Diff line number Diff line
@@ -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;
}

@@ -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;
@@ -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;
+31 −1
Original line number Diff line number Diff line
@@ -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