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

Commit e1330ff2 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: LE advertisement fixes

- Reject LE connection requests if advertising events
  are non-connectable (Core Specification v5.3,
  6.B § 4.4.2 Advertising state).

- Disable LE advertiser after LE connection request is received.

Test: cert/run
Change-Id: Id122ec8edd9a0fa15c0648862fe5d7055c73dcef
parent 78a2f3ce
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ bool LeAdvertiser::IsEnabled() const { return enabled_; }

bool LeAdvertiser::IsExtended() const { return extended_; }

bool LeAdvertiser::IsConnectable() const {
  return type_ != model::packets::AdvertisementType::ADV_NONCONN_IND &&
         type_ != model::packets::AdvertisementType::ADV_SCAN_IND;
}

uint8_t LeAdvertiser::GetNumAdvertisingEvents() const { return num_events_; }

std::unique_ptr<model::packets::LeAdvertisementBuilder>
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ class LeAdvertiser {

  bool IsExtended() const;

  bool IsConnectable() const;

  uint8_t GetNumAdvertisingEvents() const;

  bluetooth::hci::AddressWithType GetAddress() const;
+9 −1
Original line number Diff line number Diff line
@@ -1432,6 +1432,13 @@ void LinkLayerController::IncomingLeConnectPacket(
    return;
  }

  if (!advertisers_[set].IsConnectable()) {
    LOG_INFO(
        "Rejecting connection request from %s to non-connectable advertiser",
        incoming.GetSourceAddress().ToString().c_str());
    return;
  }

  uint16_t handle = HandleLeConnection(
      AddressWithType(
          incoming.GetSourceAddress(),
@@ -1447,9 +1454,10 @@ void LinkLayerController::IncomingLeConnectPacket(
      static_cast<uint8_t>(my_address.GetAddressType()));
  SendLeLinkLayerPacket(std::move(to_send));

  advertisers_[set].Disable();

  if (advertisers_[set].IsExtended()) {
    uint8_t num_advertisements = advertisers_[set].GetNumAdvertisingEvents();
    advertisers_[set].Disable();
    if (properties_.GetLeEventSupported(
            bluetooth::hci::SubeventCode::ADVERTISING_SET_TERMINATED)) {
      send_event_(bluetooth::hci::LeAdvertisingSetTerminatedBuilder::Create(