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

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

L2cap: Remove SecurityPolicy in FixedChannel part

Fixed channel doesn't need security per GAP. Probably some fixed channel
like ATT needs service-level security in its own protocol, but L2CAP
cannot enforce it in L2CAP layer. Probably we can provide some other
security requirements outside L2CAP channel registration.

Test: cert/run --host
Bug: 156054037
Change-Id: I849be7f836378e9e473c31ca3bd3f870dd91ee3f
parent b53a3af0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ struct AttModule::impl {
    // TODO: move that into a ATT manager, or other proper place
    std::unique_ptr<bluetooth::l2cap::le::FixedChannelManager> l2cap_manager_le_(
        l2cap_le_module_->GetFixedChannelManager());
    l2cap_manager_le_->RegisterService(
        bluetooth::l2cap::kLeAttributeCid, l2cap::le::SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK,
        common::BindOnce(&OnAttRegistrationCompleteLe), common::Bind(&OnAttConnectionOpenLe), att_handler_);
    l2cap_manager_le_->RegisterService(bluetooth::l2cap::kLeAttributeCid,
                                       common::BindOnce(&OnAttRegistrationCompleteLe),
                                       common::Bind(&OnAttConnectionOpenLe), att_handler_);
  }

  os::Handler* att_handler_;
+1 −2
Original line number Diff line number Diff line
@@ -35,8 +35,7 @@ bool FixedChannelManager::ConnectServices(hci::Address device, OnConnectionFailu
  return true;
}

bool FixedChannelManager::RegisterService(Cid cid, const classic::SecurityPolicy& security_policy,
                                          OnRegistrationCompleteCallback on_registration_complete,
bool FixedChannelManager::RegisterService(Cid cid, OnRegistrationCompleteCallback on_registration_complete,
                                          OnConnectionOpenCallback on_connection_open, os::Handler* handler) {
  internal::FixedChannelServiceImpl::PendingRegistration pending_registration{
      .user_handler_ = handler,
+1 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
#include "l2cap/cid.h"
#include "l2cap/classic/fixed_channel.h"
#include "l2cap/classic/fixed_channel_service.h"
#include "l2cap/classic/security_policy.h"
#include "os/handler.h"

namespace bluetooth {
@@ -122,14 +121,12 @@ class FixedChannelManager {
   * - on_open_callback, will only be triggered after on_service_registered callback
   *
   * @param cid:  cid used to receive incoming connections
   * @param security_policy: The security policy used for the connection.
   * @param on_registration_complete: A callback to indicate the service setup has completed. If the return status is
   *        not SUCCESS, it means service is not registered due to reasons like CID already take
   * @param on_open_callback: A callback to indicate success of a connection initiated from a remote device.
   * @param handler: The handler context in which to execute the @callback parameter.
   */
  virtual bool RegisterService(Cid cid, const SecurityPolicy& security_policy,
                               OnRegistrationCompleteCallback on_registration_complete,
  virtual bool RegisterService(Cid cid, OnRegistrationCompleteCallback on_registration_complete,
                               OnConnectionOpenCallback on_connection_open, os::Handler* handler);

  virtual ~FixedChannelManager() = default;
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class MockFixedChannelManager : public FixedChannelManager {
  MOCK_METHOD(bool, ConnectServices,
              (hci::Address device, OnConnectionFailureCallback on_fail_callback, os::Handler* handler), (override));
  MOCK_METHOD(bool, RegisterService,
              (Cid cid, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete,
              (Cid cid, OnRegistrationCompleteCallback on_registration_complete,
               OnConnectionOpenCallback on_connection_open, os::Handler* handler),
              (override));
};
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include "l2cap/cid.h"
#include "l2cap/classic/internal/fixed_channel_impl.h"
#include "l2cap/classic/internal/link.h"
#include "l2cap/classic/security_policy.h"
#include "os/handler.h"
#include "os/log.h"

Loading