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

Commit 491579dc authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Implement quirk to set a default LE random address

The specification states that the Random Address is invalid until
explicitly set by the command LE Set Random Address. Some HCI
commands have explicit checks for this condition.
Some controller implementations however do not enforce this.

The quirk is currently disabled.

Bug: 279443791
Test: m root-canal
Change-Id: Ib985c14827cf63c53567deac93041a70cff0c18a
parent 1f3cdb14
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,18 @@ namespace rootcanal {
using bluetooth::hci::HciVersion;
using bluetooth::hci::LmpVersion;

// Local controller quirks.
struct ControllerQuirks {
  // The specification states that the Random Address is invalid until
  // explicitly set by the command LE Set Random Address. Certain HCI commands
  // check for this condition.
  //
  // This quirk configures a default value for the LE random address in order
  // to bypass this validation. The default random address will
  // be ba:db:ad:ba:db:ad.
  bool has_default_random_address{false};
};

// Local controller information.
//
// Provide the Informational Parameters returned by HCI commands
@@ -54,6 +66,9 @@ struct ControllerProperties {
  // specification.
  bool CheckSupportedCommands() const;

  // Enabled quirks.
  ControllerQuirks quirks{};

  // Local Version Information (Vol 4, Part E § 7.4.1).
  HciVersion hci_version{HciVersion::V_5_3};
  LmpVersion lmp_version{LmpVersion::V_5_3};
+6 −0
Original line number Diff line number Diff line
@@ -1803,6 +1803,12 @@ LinkLayerController::LinkLayerController(const Address& address,
    : address_(address),
      properties_(properties),
      lm_(nullptr, link_manager_destroy) {

  if (properties_.quirks.has_default_random_address) {
    LOG_WARN("Configuring a default random address for this controller");
    random_address_ = Address { 0xba, 0xdb, 0xad, 0xba, 0xdb, 0xad };
  }

  ops_ = {
      .user_pointer = this,
      .get_handle =