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

Commit 22459989 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2CAP Segmenter: Keep a reference to DynamicChannelImpl

Since we store configuration in ChannelImpl now, we can store a
reference in Segmenter to read the configuration, and in the future,
observe I-frame and S-frame changes from remote via ChannelImpl.

Bug: 141557006
Test: bluetooth_test_gd and run_cert.sh
Change-Id: Iba0c6ee1dd915e7ef7951f4208abb8467cb9755d
parent 7c5aa34e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -60,7 +60,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);
  scheduler_->AttachChannel(cid, channel->GetQueueDownEnd(), cid, nullptr);
  reassembler_.AttachChannel(cid, channel->GetQueueDownEnd(), nullptr);
  return channel;
}
@@ -95,7 +95,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateDynamicChannel(Psm psm, Cid re
                                                                 SecurityPolicy security_policy) {
  auto channel = dynamic_channel_allocator_.AllocateChannel(psm, remote_cid, security_policy);
  if (channel != nullptr) {
    scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid());
    scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid(), channel);
    reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel);
  }
  channel->local_initiated_ = false;
@@ -106,7 +106,7 @@ std::shared_ptr<DynamicChannelImpl> Link::AllocateReservedDynamicChannel(Cid res
                                                                         SecurityPolicy security_policy) {
  auto channel = dynamic_channel_allocator_.AllocateReservedChannel(reserved_cid, psm, remote_cid, security_policy);
  if (channel != nullptr) {
    scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid());
    scheduler_->AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel->GetRemoteCid(), channel);
    reassembler_.AttachChannel(channel->GetCid(), channel->GetQueueDownEnd(), channel);
  }
  channel->local_initiated_ = true;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ namespace l2cap {
namespace classic {
namespace internal {
class DynamicChannelImpl;
}
}  // namespace internal
}  // namespace classic

namespace internal {
+11 −1
Original line number Diff line number Diff line
@@ -24,6 +24,13 @@

namespace bluetooth {
namespace l2cap {

namespace classic {
namespace internal {
class DynamicChannelImpl;
}  // namespace internal
}  // namespace classic

namespace internal {

/**
@@ -49,8 +56,11 @@ class Scheduler {
   * @param cid The channel to attach to the scheduler.
   * @param channel_down_end The ChannelQueueDownEnd associated with the channel to attach to the scheduler.
   * @param remote_cid The destination endpoint of the packet.
   * @param channel The reference to a DynamicChannelImpl object. Use nullptr for fixed channel.
   * TODO (b/144503952): Rethink about channel abstraction. Currently channel contains duplicated info as remote_cid
   */
  virtual void AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid) {}
  virtual void AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid,
                             std::shared_ptr<classic::internal::DynamicChannelImpl> channel) {}

  /**
   * Detach the channel from the scheduler.
+5 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */

#include "l2cap/internal/scheduler_fifo.h"

#include "l2cap/classic/internal/dynamic_channel_impl.h"
#include "l2cap/l2cap_packets.h"
#include "os/log.h"

@@ -34,10 +36,11 @@ Fifo::~Fifo() {
  }
}

void Fifo::AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid) {
void Fifo::AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid,
                         std::shared_ptr<classic::internal::DynamicChannelImpl> channel) {
  ASSERT(segmenter_map_.find(cid) == segmenter_map_.end());
  segmenter_map_.emplace(std::piecewise_construct, std::forward_as_tuple(cid),
                         std::forward_as_tuple(handler_, channel_down_end, this, cid, remote_cid));
                         std::forward_as_tuple(handler_, channel_down_end, this, cid, remote_cid, channel));
}

void Fifo::DetachChannel(Cid cid) {
+9 −1
Original line number Diff line number Diff line
@@ -29,13 +29,21 @@

namespace bluetooth {
namespace l2cap {

namespace classic {
namespace internal {
class DynamicChannelImpl;
}  // namespace internal
}  // namespace classic

namespace internal {

class Fifo : public Scheduler {
 public:
  Fifo(LowerQueueUpEnd* link_queue_up_end, os::Handler* handler);
  ~Fifo() override;
  void AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid) override;
  void AttachChannel(Cid cid, UpperQueueDownEnd* channel_down_end, Cid remote_cid,
                     std::shared_ptr<classic::internal::DynamicChannelImpl> channel) override;
  void DetachChannel(Cid cid) override;
  void NotifyPacketsReady(Cid cid, int number_packets) override;

Loading