1 /******************************************************************************
2  *
3  *  Copyright 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #pragma once
20 
21 #include <base/strings/stringprintf.h>
22 #include <bluetooth/log.h>
23 
24 #include <cstdint>
25 #include <string>
26 
27 #include "internal_include/bt_target.h"
28 #include "macros.h"
29 #include "os/log.h"
30 #include "stack/include/bt_device_type.h"
31 #include "stack/include/bt_name.h"
32 #include "stack/include/bt_octets.h"
33 #include "stack/include/btm_sec_api_types.h"
34 #include "stack/include/hci_error_code.h"
35 #include "types/ble_address_with_type.h"
36 #include "types/raw_address.h"
37 #include "types/remote_version_type.h"
38 
39 typedef struct {
40   uint16_t min_conn_int;
41   uint16_t max_conn_int;
42   uint16_t peripheral_latency;
43   uint16_t supervision_tout;
44 
45 } tBTM_LE_CONN_PRAMS;
46 
47 /* The MSB of the clock offset field indicates whether the offset is valid. */
48 #define BTM_CLOCK_OFFSET_VALID 0x8000
49 
50 /*
51  * Define structure for Security Service Record.
52  * A record exists for each service registered with the Security Manager
53  */
54 #define BTM_SEC_OUT_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT)
55 #define BTM_SEC_IN_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT)
56 
57 #define BTM_SEC_OUT_LEVEL4_FLAGS                                       \
58   (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_MITM | \
59    BTM_SEC_MODE4_LEVEL4)
60 
61 #define BTM_SEC_IN_LEVEL4_FLAGS                                     \
62   (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_MITM | \
63    BTM_SEC_MODE4_LEVEL4)
64 typedef struct {
65   uint32_t mx_proto_id;     /* Service runs over this multiplexer protocol */
66   uint32_t orig_mx_chan_id; /* Channel on the multiplexer protocol    */
67   uint32_t term_mx_chan_id; /* Channel on the multiplexer protocol    */
68   uint16_t psm;             /* L2CAP PSM value */
69   uint16_t security_flags;  /* Bitmap of required security features */
70   uint8_t service_id;       /* Passed in authorization callback */
71   uint8_t orig_service_name[BT_MAX_SERVICE_NAME_LEN + 1];
72   uint8_t term_service_name[BT_MAX_SERVICE_NAME_LEN + 1];
73 } tBTM_SEC_SERV_REC;
74 
75 /* LE Security information of device in Peripheral Role */
76 typedef struct {
77   Octet16 irk;   /* peer diverified identity root */
78   Octet16 pltk;  /* peer long term key */
79   Octet16 pcsrk; /* peer SRK peer device used to secured sign local data  */
80 
81   Octet16 lltk;  /* local long term key */
82   Octet16 lcsrk; /* local SRK peer device used to secured sign local data  */
83 
84   BT_OCTET8 rand;        /* random vector for LTK generation */
85   uint16_t ediv;         /* LTK diversifier of this peripheral device */
86   uint16_t div;          /* local DIV  to generate local LTK=d1(ER,DIV,0) and
87                             CSRK=d1(ER,DIV,1)  */
88   uint8_t sec_level;     /* local pairing security level */
89   uint8_t key_size;      /* key size of the LTK delivered to peer device */
90   uint8_t srk_sec_level; /* security property of peer SRK for this device */
91   uint8_t local_csrk_sec_level; /* security property of local CSRK for this
92                                    device */
93 
94   uint32_t counter;       /* peer sign counter for verifying rcv signed cmd */
95   uint32_t local_counter; /* local sign counter for sending signed write cmd*/
96 
97   tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */
98 } tBTM_SEC_BLE_KEYS;
99 
100 // TODO: move it to btm_ble_addr.h
101 enum tBLE_RAND_ADDR_TYPE : uint8_t {
102   BTM_BLE_ADDR_PSEUDO = 0,
103   BTM_BLE_ADDR_RRA = 1,
104   BTM_BLE_ADDR_STATIC = 2,
105 };
106 
107 class tBTM_BLE_ADDR_INFO {
108  public:
109   RawAddress pseudo_addr; /* LE pseudo address of the device if different from
110                           device address  */
111  public:
AddressType()112   tBLE_ADDR_TYPE AddressType() const { return ble_addr_type_; }
SetAddressType(tBLE_ADDR_TYPE ble_addr_type)113   void SetAddressType(tBLE_ADDR_TYPE ble_addr_type) {
114     if (is_ble_addr_type_known(ble_addr_type)) {
115       ble_addr_type_ = ble_addr_type;
116     } else {
117       bluetooth::log::error("Unknown address type:0x{:x}", ble_addr_type);
118     }
119   }
120 
121   tBLE_BD_ADDR identity_address_with_type;
122 
123 #define BTM_RESOLVING_LIST_BIT 0x02
124   uint8_t in_controller_list; /* in controller resolving list or not */
125   uint8_t resolving_list_index;
126   RawAddress cur_rand_addr; /* current random address */
127 
128   tBLE_RAND_ADDR_TYPE active_addr_type;
129 
130  private:
131   tBLE_ADDR_TYPE ble_addr_type_; /* LE device type: public or random address */
132 };
133 
134 enum : uint16_t {
135   BTM_SEC_AUTHENTICATED = 0x0002,
136   BTM_SEC_ENCRYPTED = 0x0004,
137   BTM_SEC_NAME_KNOWN = 0x0008,
138   BTM_SEC_LINK_KEY_KNOWN = 0x0010,
139   BTM_SEC_LINK_KEY_AUTHED = 0x0020,
140   BTM_SEC_ROLE_SWITCHED = 0x0040,  // UNUSED - only cleared
141   BTM_SEC_IN_USE = 0x0080,         // UNUSED - only set
142   /* LE link security flag */
143   /* LE link is encrypted after pairing with MITM */
144   BTM_SEC_LE_AUTHENTICATED = 0x0200,
145   /* LE link is encrypted */
146   BTM_SEC_LE_ENCRYPTED = 0x0400,
147   /* not used */
148   BTM_SEC_LE_NAME_KNOWN = 0x0800,  // UNUSED
149   /* bonded with peer (peer LTK and/or SRK is saved) */
150   BTM_SEC_LE_LINK_KEY_KNOWN = 0x1000,
151   /* pairing is done with MITM */
152   BTM_SEC_LE_LINK_KEY_AUTHED = 0x2000,
153   /* pairing is done with 16 digit pin */
154   BTM_SEC_16_DIGIT_PIN_AUTHED = 0x4000,
155 };
156 
157 typedef enum : uint8_t {
158   BTM_SEC_STATE_IDLE = 0,
159   BTM_SEC_STATE_AUTHENTICATING = 1,
160   BTM_SEC_STATE_ENCRYPTING = 2,
161   BTM_SEC_STATE_GETTING_NAME = 3,
162   BTM_SEC_STATE_AUTHORIZING = 4,
163   BTM_SEC_STATE_SWITCHING_ROLE = 5,
164   /* disconnecting BR/EDR */
165   BTM_SEC_STATE_DISCONNECTING = 6,
166   /* delay to check for encryption to work around */
167   /* controller problems */
168   BTM_SEC_STATE_DELAY_FOR_ENC = 7,
169   BTM_SEC_STATE_DISCONNECTING_BLE = 8,
170   BTM_SEC_STATE_DISCONNECTING_BOTH = 9,
171   BTM_SEC_STATE_LE_ENCRYPTING = 10,
172 } tSECURITY_STATE;
173 
security_state_text(const tSECURITY_STATE & state)174 static inline std::string security_state_text(const tSECURITY_STATE& state) {
175   switch (state) {
176     CASE_RETURN_TEXT(BTM_SEC_STATE_IDLE);
177     CASE_RETURN_TEXT(BTM_SEC_STATE_AUTHENTICATING);
178     CASE_RETURN_TEXT(BTM_SEC_STATE_ENCRYPTING);
179     CASE_RETURN_TEXT(BTM_SEC_STATE_GETTING_NAME);
180     CASE_RETURN_TEXT(BTM_SEC_STATE_AUTHORIZING);
181     CASE_RETURN_TEXT(BTM_SEC_STATE_SWITCHING_ROLE);
182     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING);
183     CASE_RETURN_TEXT(BTM_SEC_STATE_DELAY_FOR_ENC);
184     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BLE);
185     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BOTH);
186     CASE_RETURN_TEXT(BTM_SEC_STATE_LE_ENCRYPTING);
187     default:
188       return base::StringPrintf("UNKNOWN[%hhu]", state);
189   }
190 }
191 
192 typedef enum : uint8_t {
193   BTM_SM4_UNKNOWN = 0x00,
194   BTM_SM4_KNOWN = 0x10,
195   BTM_SM4_TRUE = 0x11,
196   BTM_SM4_REQ_PEND = 0x08, /* set this bit when getting remote features */
197   BTM_SM4_UPGRADE = 0x04,  /* set this bit when upgrading link key */
198   BTM_SM4_RETRY = 0x02,    /* set this bit to retry on HCI_ERR_KEY_MISSING or \
199                               HCI_ERR_LMP_ERR_TRANS_COLLISION */
200   BTM_SM4_DD_ACP =
201       0x20, /* set this bit to indicate peer initiated dedicated bonding */
202   BTM_SM4_CONN_PEND = 0x40, /* set this bit to indicate accepting acl conn; to
203                              be cleared on \ btm_acl_created */
204 } tBTM_SM4_BIT;
205 
206 /*
207  * Define structure for Security Device Record.
208  * A record exists for each device authenticated with this device
209  */
210 struct tBTM_SEC_REC {
211   tSECURITY_STATE sec_state; /* Operating state                    */
212 
213   tHCI_STATUS sec_status; /* Status in encryption change event  */
214   uint16_t sec_flags;     /* Current device security state      */
215 
216   uint8_t pin_code_length; /* Length of the pin_code used for pairing */
217   uint32_t required_security_flags_for_pairing;
218   uint16_t security_required; /* Security required for connection   */
219   // security callback and its argument
220   tBTM_SEC_CALLBACK* p_callback;
221   void* p_ref_data;
222 
223   bool link_key_not_sent; /* link key notification has not been sent waiting for
224                              name */
225   tBTM_IO_CAP rmt_io_caps;    /* IO capability of the peer device */
226   tBTM_AUTH_REQ rmt_auth_req; /* the auth_req flag as in the IO caps rsp evt */
227   bool new_encryption_key_is_p256; /* Set to true when the newly generated LK
228                                    ** is generated from P-256.
229                                    ** Link encrypted with such LK can be used
230                                    ** for SM over BR/EDR. */
231 
232   // BREDR Link Key Info
233   LinkKey link_key;      /* Device link key                    */
234   uint8_t link_key_type; /* Type of key used in pairing        */
235   uint8_t enc_key_size;  /* current link encryption key size   */
236 
237   // LE Link Key Info
238   tBTM_SEC_BLE_KEYS ble_keys;
239 
240   tBTM_BOND_TYPE bond_type; /* bond type */
241 
242  public:
is_device_authenticatedtBTM_SEC_REC243   bool is_device_authenticated() const {
244     return sec_flags & BTM_SEC_AUTHENTICATED;
245   }
set_device_authenticatedtBTM_SEC_REC246   void set_device_authenticated() { sec_flags |= BTM_SEC_AUTHENTICATED; }
reset_device_authenticatedtBTM_SEC_REC247   void reset_device_authenticated() { sec_flags &= ~BTM_SEC_AUTHENTICATED; }
248 
is_device_encryptedtBTM_SEC_REC249   bool is_device_encrypted() const { return sec_flags & BTM_SEC_ENCRYPTED; }
set_device_encryptedtBTM_SEC_REC250   void set_device_encrypted() { sec_flags |= BTM_SEC_ENCRYPTED; }
reset_device_encryptedtBTM_SEC_REC251   void reset_device_encrypted() { sec_flags &= ~BTM_SEC_ENCRYPTED; }
252 
is_name_knowntBTM_SEC_REC253   bool is_name_known() const { return sec_flags & BTM_SEC_NAME_KNOWN; }
set_device_knowntBTM_SEC_REC254   void set_device_known() { sec_flags |= BTM_SEC_NAME_KNOWN; }
reset_device_knowntBTM_SEC_REC255   void reset_device_known() { sec_flags &= ~BTM_SEC_NAME_KNOWN; }
256 
is_link_key_knowntBTM_SEC_REC257   bool is_link_key_known() const { return sec_flags & BTM_SEC_LINK_KEY_KNOWN; }
set_link_key_knowntBTM_SEC_REC258   void set_link_key_known() { sec_flags |= BTM_SEC_LINK_KEY_KNOWN; }
reset_link_key_knowntBTM_SEC_REC259   void reset_link_key_known() { sec_flags &= ~BTM_SEC_LINK_KEY_KNOWN; }
260 
is_link_key_authenticatedtBTM_SEC_REC261   bool is_link_key_authenticated() const {
262     return sec_flags & BTM_SEC_LINK_KEY_AUTHED;
263   }
set_link_key_authenticatedtBTM_SEC_REC264   void set_link_key_authenticated() { sec_flags |= BTM_SEC_LINK_KEY_AUTHED; }
reset_link_key_authenticatedtBTM_SEC_REC265   void reset_link_key_authenticated() { sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED; }
266 
is_le_device_authenticatedtBTM_SEC_REC267   bool is_le_device_authenticated() const {
268     return sec_flags & BTM_SEC_LE_AUTHENTICATED;
269   }
set_le_device_authenticatedtBTM_SEC_REC270   void set_le_device_authenticated() { sec_flags |= BTM_SEC_LE_AUTHENTICATED; }
reset_le_device_authenticatedtBTM_SEC_REC271   void reset_le_device_authenticated() {
272     sec_flags &= ~BTM_SEC_LE_AUTHENTICATED;
273   }
274 
is_le_device_encryptedtBTM_SEC_REC275   bool is_le_device_encrypted() const {
276     return sec_flags & BTM_SEC_LE_ENCRYPTED;
277   }
set_le_device_encryptedtBTM_SEC_REC278   void set_le_device_encrypted() { sec_flags |= BTM_SEC_LE_ENCRYPTED; }
reset_le_device_encryptedtBTM_SEC_REC279   void reset_le_device_encrypted() { sec_flags &= ~BTM_SEC_LE_ENCRYPTED; }
280 
is_le_link_key_knowntBTM_SEC_REC281   bool is_le_link_key_known() const {
282     return sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN;
283   }
set_le_link_key_knowntBTM_SEC_REC284   void set_le_link_key_known() { sec_flags |= BTM_SEC_LE_LINK_KEY_KNOWN; }
reset_le_link_key_knowntBTM_SEC_REC285   void reset_le_link_key_known() { sec_flags &= ~BTM_SEC_LE_LINK_KEY_KNOWN; }
286 
is_le_link_key_authenticatedtBTM_SEC_REC287   bool is_le_link_key_authenticated() const {
288     return sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED;
289   }
set_le_link_key_authenticatedtBTM_SEC_REC290   void set_le_link_key_authenticated() {
291     sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
292   }
reset_le_link_key_authenticatedtBTM_SEC_REC293   void reset_le_link_key_authenticated() {
294     sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
295   }
296 
is_le_link_16_digit_key_authenticatedtBTM_SEC_REC297   bool is_le_link_16_digit_key_authenticated() const {
298     return sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED;
299   }
set_le_link_16_digit_key_authenticatedtBTM_SEC_REC300   void set_le_link_16_digit_key_authenticated() {
301     sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
302   }
reset_le_link_16_digit_key_authenticatedtBTM_SEC_REC303   void reset_le_link_16_digit_key_authenticated() {
304     sec_flags &= ~BTM_SEC_16_DIGIT_PIN_AUTHED;
305   }
306 
is_security_state_idletBTM_SEC_REC307   bool is_security_state_idle() const {
308     return sec_state == BTM_SEC_STATE_IDLE;
309   }
is_security_state_authenticatingtBTM_SEC_REC310   bool is_security_state_authenticating() const {
311     return sec_state == BTM_SEC_STATE_AUTHENTICATING;
312   }
is_security_state_bredr_encryptingtBTM_SEC_REC313   bool is_security_state_bredr_encrypting() const {
314     return sec_state == BTM_SEC_STATE_ENCRYPTING;
315   }
is_security_state_le_encryptingtBTM_SEC_REC316   bool is_security_state_le_encrypting() const {
317     return sec_state == BTM_SEC_STATE_LE_ENCRYPTING;
318   }
is_security_state_encryptingtBTM_SEC_REC319   bool is_security_state_encrypting() const {
320     return (is_security_state_bredr_encrypting() ||
321             is_security_state_le_encrypting());
322   }
is_security_state_getting_nametBTM_SEC_REC323   bool is_security_state_getting_name() const {
324     return sec_state == BTM_SEC_STATE_GETTING_NAME;
325   }
is_security_state_authorizingtBTM_SEC_REC326   bool is_security_state_authorizing() const {
327     return sec_state == BTM_SEC_STATE_AUTHORIZING;
328   }
is_security_state_switching_roletBTM_SEC_REC329   bool is_security_state_switching_role() const {
330     return sec_state == BTM_SEC_STATE_SWITCHING_ROLE;
331   }
is_security_state_disconnectingtBTM_SEC_REC332   bool is_security_state_disconnecting() const {
333     return sec_state == BTM_SEC_STATE_DISCONNECTING;
334   }
is_security_state_wait_for_encryptiontBTM_SEC_REC335   bool is_security_state_wait_for_encryption() const {
336     return sec_state == BTM_SEC_STATE_DELAY_FOR_ENC;
337   }
is_security_state_ble_disconnectingtBTM_SEC_REC338   bool is_security_state_ble_disconnecting() const {
339     return sec_state == BTM_SEC_STATE_DISCONNECTING_BLE;
340   }
is_security_state_br_edr_and_bletBTM_SEC_REC341   bool is_security_state_br_edr_and_ble() const {
342     return sec_state == BTM_SEC_STATE_DISCONNECTING_BOTH;
343   }
344 
is_bond_type_unknowntBTM_SEC_REC345   bool is_bond_type_unknown() const { return bond_type == BOND_TYPE_UNKNOWN; }
is_bond_type_persistenttBTM_SEC_REC346   bool is_bond_type_persistent() const {
347     return bond_type == BOND_TYPE_PERSISTENT;
348   }
is_bond_type_temporarytBTM_SEC_REC349   bool is_bond_type_temporary() const {
350     return bond_type == BOND_TYPE_TEMPORARY;
351   }
352 
get_encryption_key_sizetBTM_SEC_REC353   uint8_t get_encryption_key_size() const { return enc_key_size; }
354 
355   void increment_sign_counter(bool local);
356 
ToStringtBTM_SEC_REC357   std::string ToString() const {
358     return base::StringPrintf(
359         "bredr_linkkey_known:%c,le_linkkey_known:%c,"
360         "bond_type:%s,"
361         "bredr_linkkey_type:%s,"
362         "ble_enc_key_size:%d,"
363         "bredr_authenticated:%c,le_authenticated:%c,"
364         "16_digit_key_authenticated:%c,"
365         "bredr_encrypted:%c,le_encrypted:%c",
366         is_link_key_known() ? 'T' : 'F', is_le_link_key_known() ? 'T' : 'F',
367         bond_type_text(bond_type).c_str(),
368         linkkey_type_text(link_key_type).c_str(), enc_key_size,
369         is_device_authenticated() ? 'T' : 'F',
370         is_le_device_authenticated() ? 'T' : 'F',
371         is_le_link_16_digit_key_authenticated() ? 'T' : 'F',
372         is_device_encrypted() ? 'T' : 'F',
373         is_le_device_encrypted() ? 'T' : 'F');
374   }
375 };
376 
377 class tBTM_SEC_DEV_REC {
378  public:
RemoteAddress()379   RawAddress RemoteAddress() const { return bd_addr; }
380 
381   /* Data length extension */
set_suggested_tx_octect(uint16_t octets)382   void set_suggested_tx_octect(uint16_t octets) {
383     suggested_tx_octets = octets;
384   }
385 
get_suggested_tx_octets()386   uint16_t get_suggested_tx_octets() const { return suggested_tx_octets; }
IsLocallyInitiated()387   bool IsLocallyInitiated() const { return is_originator; }
388 
get_br_edr_hci_handle()389   uint16_t get_br_edr_hci_handle() const { return hci_handle; }
get_ble_hci_handle()390   uint16_t get_ble_hci_handle() const { return ble_hci_handle; }
391 
is_device_type_br_edr()392   bool is_device_type_br_edr() const {
393     return device_type == BT_DEVICE_TYPE_BREDR;
394   }
is_device_type_ble()395   bool is_device_type_ble() const { return device_type == BT_DEVICE_TYPE_BLE; }
is_device_type_dual_mode()396   bool is_device_type_dual_mode() const {
397     return device_type == BT_DEVICE_TYPE_DUMO;
398   }
399 
is_device_type_has_ble()400   bool is_device_type_has_ble() const {
401     return device_type & BT_DEVICE_TYPE_BLE;
402   }
403 
SupportsSecureConnections()404   bool SupportsSecureConnections() const {
405     return remote_supports_secure_connections;
406   }
407 
ToString()408   std::string ToString() const {
409     return base::StringPrintf(
410         "%s %6s cod:%s remote_info:%-14s sm4:0x%02x SecureConn:%c name:\"%s\""
411         "sec_prop:%s",
412         ADDRESS_TO_LOGGABLE_CSTR(bd_addr), DeviceTypeText(device_type).c_str(),
413         dev_class_text(dev_class).c_str(),
414         remote_version_info.ToString().c_str(), sm4,
415         (remote_supports_secure_connections) ? 'T' : 'F',
416         PRIVATE_NAME(sec_bd_name), sec_rec.ToString().c_str());
417   }
418 
419  public:
420   RawAddress bd_addr; /* BD_ADDR of the device */
421   tBTM_BLE_ADDR_INFO ble;
422   BD_NAME sec_bd_name;      /* User friendly name of the device. (may be
423                                     truncated to save space in dev_rec table) */
424   DEV_CLASS dev_class;      /* DEV_CLASS of the device            */
425   tBT_DEVICE_TYPE device_type;
426 
427   uint32_t timestamp;      /* Timestamp of the last connection   */
428   uint16_t hci_handle;     /* Handle to BR/EDR ACL connection when exists */
429   uint16_t ble_hci_handle; /* use in DUMO connection */
430 
431   uint16_t suggested_tx_octets; /* Recently suggested tx octects for data length
432                                    extension */
433   uint16_t clock_offset;        /* Latest known clock offset          */
434 
435   // whether the peer device can read GAP characteristics only visible in
436   // "discoverable" mode
437   bool can_read_discoverable{true};
438 
439   bool remote_features_needed; /* set to true if the local device is in */
440   /* "Secure Connections Only" mode and it receives */
441   /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */
442   /* it knows peer's support for Secure Connections */
443   uint8_t sm4; /* BTM_SM4_TRUE, if the peer supports SM4 */
444   bool remote_supports_hci_role_switch = false;
445   bool remote_supports_bredr;
446   bool remote_supports_ble;
447   bool remote_supports_secure_connections;
448   bool remote_feature_received = false;
449 
450   tREMOTE_VERSION_INFO remote_version_info;
451 
452   bool role_central;  /* true if current mode is central (BLE)    */
453   bool is_originator; /* true if device is originating ACL connection */
454 
455   // BLE connection parameters
456   tBTM_LE_CONN_PRAMS conn_params;
457   // security related properties
458   tBTM_SEC_REC sec_rec;
459 };
460 
461 namespace fmt {
462 template <>
463 struct formatter<tSECURITY_STATE>
464     : string_formatter<tSECURITY_STATE, &security_state_text> {};
465 template <>
466 struct formatter<tBLE_RAND_ADDR_TYPE> : enum_formatter<tBLE_RAND_ADDR_TYPE> {};
467 }  // namespace fmt
468