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

Commit f823bcaf authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Register security manager for L2CAP connection events"

parents bfaa9188 997c91db
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -232,6 +232,30 @@ void SecurityManagerImpl::OnPairingHandlerComplete(hci::Address address, Pairing
  }
}

void SecurityManagerImpl::OnL2capRegistrationCompleteLe(
    l2cap::le::FixedChannelManager::RegistrationResult result,
    std::unique_ptr<l2cap::le::FixedChannelService> le_smp_service) {
  ASSERT_LOG(result == bluetooth::l2cap::le::FixedChannelManager::RegistrationResult::SUCCESS,
             "Failed to register to LE SMP Fixed Channel Service");
}
void SecurityManagerImpl::OnConnectionOpenLe(std::unique_ptr<l2cap::le::FixedChannel> channel) {}
void SecurityManagerImpl::OnConnectionClosedLe(hci::AddressWithType address, hci::ErrorCode error_code) {}
void SecurityManagerImpl::OnConnectionFailureLe(bluetooth::l2cap::le::FixedChannelManager::ConnectionResult result) {}
void SecurityManagerImpl::OnHciLeEvent(hci::LeMetaEventView event) {}
SecurityManagerImpl::SecurityManagerImpl(os::Handler* security_handler, l2cap::le::L2capLeModule* l2cap_le_module,
                                         l2cap::classic::L2capClassicModule* l2cap_classic_module,
                                         channel::SecurityManagerChannel* security_manager_channel,
                                         hci::HciLayer* hci_layer)
    : security_handler_(security_handler), l2cap_le_module_(l2cap_le_module),
      l2cap_classic_module_(l2cap_classic_module), l2cap_manager_le_(l2cap_le_module_->GetFixedChannelManager()),
      hci_security_interface_le_(hci_layer->GetLeSecurityInterface(
          common::Bind(&SecurityManagerImpl::OnHciLeEvent, common::Unretained(this)), security_handler)),
      security_manager_channel_(security_manager_channel) {
  l2cap_manager_le_->RegisterService(
      bluetooth::l2cap::kSmpCid, {},
      common::BindOnce(&SecurityManagerImpl::OnL2capRegistrationCompleteLe, common::Unretained(this)),
      common::Bind(&SecurityManagerImpl::OnConnectionOpenLe, common::Unretained(this)), security_handler_);
}
}  // namespace internal
}  // namespace security
}  // namespace bluetooth
+9 −3
Original line number Diff line number Diff line
@@ -38,9 +38,7 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener {
 public:
  explicit SecurityManagerImpl(os::Handler* security_handler, l2cap::le::L2capLeModule* l2cap_le_module,
                               l2cap::classic::L2capClassicModule* l2cap_classic_module,
                               channel::SecurityManagerChannel* security_manager_channel)
      : security_handler_(security_handler), l2cap_le_module_(l2cap_le_module),
        l2cap_classic_module_(l2cap_classic_module), security_manager_channel_(security_manager_channel) {}
                               channel::SecurityManagerChannel* security_manager_channel, hci::HciLayer* hci_layer);
  virtual ~SecurityManagerImpl() = default;

  // All APIs must be invoked in SM layer handler
@@ -121,10 +119,18 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener {

  std::shared_ptr<record::SecurityRecord> CreateSecurityRecord(hci::Address address);
  void DispatchPairingHandler(std::shared_ptr<record::SecurityRecord> record, bool locally_initiated);
  void OnL2capRegistrationCompleteLe(l2cap::le::FixedChannelManager::RegistrationResult result,
                                     std::unique_ptr<l2cap::le::FixedChannelService> le_smp_service);
  void OnConnectionOpenLe(std::unique_ptr<l2cap::le::FixedChannel> channel);
  void OnConnectionClosedLe(hci::AddressWithType address, hci::ErrorCode error_code);
  void OnConnectionFailureLe(bluetooth::l2cap::le::FixedChannelManager::ConnectionResult result);
  void OnHciLeEvent(hci::LeMetaEventView event);

  os::Handler* security_handler_ __attribute__((unused));
  l2cap::le::L2capLeModule* l2cap_le_module_ __attribute__((unused));
  l2cap::classic::L2capClassicModule* l2cap_classic_module_ __attribute__((unused));
  std::unique_ptr<l2cap::le::FixedChannelManager> l2cap_manager_le_;
  hci::LeSecurityInterface* hci_security_interface_le_ __attribute__((unused));
  channel::SecurityManagerChannel* security_manager_channel_ __attribute__((unused));
  std::unordered_map<hci::Address, std::shared_ptr<record::SecurityRecord>> security_record_map_;
  std::unordered_map<hci::Address, std::shared_ptr<pairing::PairingHandler>> pairing_handler_map_;
+4 −2
Original line number Diff line number Diff line
@@ -37,14 +37,16 @@ struct SecurityModule::impl {
       l2cap::classic::L2capClassicModule* l2cap_classic_module, hci::HciLayer* hci_layer)
      : security_handler_(security_handler), l2cap_le_module_(l2cap_le_module),
        l2cap_classic_module_(l2cap_classic_module),
        security_manager_channel_(new channel::SecurityManagerChannel(security_handler_, hci_layer)) {}
        security_manager_channel_(new channel::SecurityManagerChannel(security_handler_, hci_layer)),
        hci_layer_(hci_layer) {}

  os::Handler* security_handler_;
  l2cap::le::L2capLeModule* l2cap_le_module_;
  l2cap::classic::L2capClassicModule* l2cap_classic_module_;
  channel::SecurityManagerChannel* security_manager_channel_;
  hci::HciLayer* hci_layer_;
  internal::SecurityManagerImpl security_manager_impl{security_handler_, l2cap_le_module_, l2cap_classic_module_,
                                                      security_manager_channel_};
                                                      security_manager_channel_, hci_layer_};
  ~impl() {
    delete security_manager_channel_;
  }