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

Commit e973beb1 authored by Chris Manton's avatar Chris Manton
Browse files

Store remote lmp version in security record

Toward loggable code

Bug: 163134718
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I928bcb52c65b5c9a3cbfd67d48a3465b7e14959f
parent 564c787a
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -231,12 +231,7 @@ struct tACL_CONN {
  tHCI_ROLE link_role;
  uint8_t switch_role_failed_attempts;

  struct {
    uint8_t lmp_version{0};
    uint16_t lmp_subversion{0};
    uint16_t manufacturer{0};
    bool valid{false};
  } remote_version_info;
  tREMOTE_VERSION_INFO remote_version_info;

#define BTM_SEC_RS_NOT_PENDING 0 /* Role Switch not in progress */
#define BTM_SEC_RS_PENDING 1     /* Role Switch in progress */
+6 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@
#include "types/hci_role.h"
#include "types/raw_address.h"

void BTM_update_version_info(const RawAddress& bd_addr,
                             const remote_version_info& remote_version_info);

void gatt_find_in_device_record(const RawAddress& bd_addr,
                                tBLE_BD_ADDR* address_with_type);
void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle,
@@ -781,6 +784,9 @@ void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
    p_acl_cb->remote_version_info.manufacturer = manufacturer;
    p_acl_cb->remote_version_info.lmp_subversion = lmp_subversion;
    p_acl_cb->remote_version_info.valid = true;
    BTM_update_version_info(p_acl_cb->RemoteAddress(),
                            p_acl_cb->remote_version_info);

    bluetooth::common::LogRemoteVersionInfo(handle, status, lmp_version,
                                            manufacturer, lmp_subversion);
  } else {
+8 −0
Original line number Diff line number Diff line
@@ -4860,3 +4860,11 @@ const uint8_t* btm_get_dev_class(const RawAddress& bda) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda);
  return p_dev_rec->dev_class;
}

void BTM_update_version_info(const RawAddress& bd_addr,
                             const remote_version_info& remote_version_info) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec == NULL) return;

  p_dev_rec->remote_version_info = remote_version_info;
}
+11 −3
Original line number Diff line number Diff line
@@ -188,6 +188,10 @@ typedef enum : uint8_t {
                             be cleared on \ btm_acl_created */
} tBTM_SM4_BIT;

inline std::string class_of_device_text(const DEV_CLASS& cod) {
  return base::StringPrintf("0x%01x%01x%01x", cod[2], cod[1], cod[0]);
}

/*
 * Define structure for Security Device Record.
 * A record exists for each device authenticated with this device
@@ -416,10 +420,14 @@ struct tBTM_SEC_DEV_REC {
  tBTM_SEC_BLE ble;
  tBTM_LE_CONN_PRAMS conn_params;

  tREMOTE_VERSION_INFO remote_version_info;

  std::string ToString() const {
    return base::StringPrintf(
        "%s %6s name:\"%s\" supports_SC:%s", PRIVATE_ADDRESS(bd_addr),
        DeviceTypeText(device_type).c_str(), sec_bd_name,
        logbool(remote_supports_secure_connections).c_str());
        "%s %6s name:\"%s\" supports_SC:%s cod:%s remote_info%s",
        PRIVATE_ADDRESS(bd_addr), DeviceTypeText(device_type).c_str(),
        sec_bd_name, logbool(remote_supports_secure_connections).c_str(),
        class_of_device_text(dev_class).c_str(),
        remote_version_info.ToString().c_str());
  }
};
+13 −0
Original line number Diff line number Diff line
@@ -970,4 +970,17 @@ typedef uint8_t tBTM_CONTRL_STATE;
// Bluetooth Quality Report - Report receiver
typedef void(tBTM_BT_QUALITY_REPORT_RECEIVER)(uint8_t len, uint8_t* p_stream);

struct tREMOTE_VERSION_INFO {
  uint8_t lmp_version{0};
  uint16_t lmp_subversion{0};
  uint16_t manufacturer{0};
  bool valid{false};
  std::string ToString() const {
    return (valid) ? base::StringPrintf("%02hhu-%05hu-%05hu", lmp_version,
                                        lmp_subversion, manufacturer)
                   : std::string("UNKNOWN");
  }
};
using remote_version_info = tREMOTE_VERSION_INFO;

#endif  // BTM_API_TYPES_H