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 /****************************************************************************** 20 * 21 * This file contains functions for the Bluetooth Security Manager 22 * 23 ******************************************************************************/ 24 25 #pragma once 26 #include <cstdint> 27 #include <string> 28 29 #include "stack/btm/security_device_record.h" 30 #include "stack/include/bt_device_type.h" 31 #include "stack/include/bt_octets.h" 32 #include "stack/include/btm_sec_api_types.h" 33 #include "stack/include/btm_status.h" 34 #include "stack/include/hci_error_code.h" 35 #include "stack/include/security_client_callbacks.h" 36 #include "stack/include/smp_api_types.h" 37 #include "types/ble_address_with_type.h" 38 #include "types/bt_transport.h" 39 #include "types/hci_role.h" 40 #include "types/raw_address.h" 41 42 #define BTM_SEC_MAX_COLLISION_DELAY (5000) 43 44 /******************************************************************************* 45 * 46 * Function BTM_SecRegister 47 * 48 * Description Application manager calls this function to register for 49 * security services. There can be one and only one 50 * application saving link keys. BTM allows only first 51 * registration. 52 * 53 * Returns true if registered OK, else false 54 * 55 ******************************************************************************/ 56 bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info); 57 58 bool BTM_IsEncrypted(const RawAddress& bd_addr, tBT_TRANSPORT transport); 59 bool BTM_IsLinkKeyAuthed(const RawAddress& bd_addr, tBT_TRANSPORT transport); 60 bool BTM_IsBonded(const RawAddress& bd_addr, tBT_TRANSPORT transport = BT_TRANSPORT_AUTO); 61 bool BTM_IsAuthenticated(const RawAddress& bd_addr, tBT_TRANSPORT transport); 62 bool BTM_CanReadDiscoverableCharacteristics(const RawAddress& bd_addr); 63 void BTM_update_version_info(const RawAddress& bd_addr, 64 const remote_version_info& remote_version_info); 65 66 /******************************************************************************* 67 * 68 * Function BTM_SetPinType 69 * 70 * Description Set PIN type for the device. 71 * 72 * Returns void 73 * 74 ******************************************************************************/ 75 void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len); 76 77 /******************************************************************************* 78 * 79 * Function BTM_SetSecurityLevel 80 * 81 * Description Register service security level with Security Manager 82 * 83 * Parameters: is_originator - true if originating the connection 84 * p_name - Name of the service relevant only if 85 * authorization will show this name to user. 86 * Ignored if BT_MAX_SERVICE_NAME_LEN is 0. 87 * service_id - service ID for the service passed to 88 * authorization callback 89 * sec_level - bit mask of the security features 90 * psm - L2CAP PSM 91 * mx_proto_id - protocol ID of multiplexing proto below 92 * mx_chan_id - channel ID of multiplexing proto below 93 * 94 * Returns true if registered OK, else false 95 * 96 ******************************************************************************/ 97 bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, uint8_t service_id, 98 uint16_t sec_level, uint16_t psm, uint32_t mx_proto_id, 99 uint32_t mx_chan_id); 100 101 /******************************************************************************* 102 * 103 * Function BTM_SecClrService 104 * 105 * Description Removes specified service record(s) from the security 106 * database. All service records with the specified name are 107 * removed. Typically used only by devices with limited RAM so 108 * that it can reuse an old security service record. 109 * 110 * Note: Unpredictable results may occur if a service is 111 * cleared that is still in use by an application/profile. 112 * 113 * Parameters Service ID - Id of the service to remove. '0' removes all 114 * service records (except SDP). 115 * 116 * Returns Number of records that were freed. 117 * 118 ******************************************************************************/ 119 uint8_t BTM_SecClrService(uint8_t service_id); 120 121 /******************************************************************************* 122 * 123 * Function BTM_SecClrServiceByPsm 124 * 125 * Description Removes specified service record from the security database. 126 * All service records with the specified psm are removed. 127 * Typically used by L2CAP to free up the service record used 128 * by dynamic PSM clients when the channel is closed. 129 * The given psm must be a virtual psm. 130 * 131 * Parameters Service ID - Id of the service to remove. '0' removes all 132 * service records (except SDP). 133 * 134 * Returns Number of records that were freed. 135 * 136 ******************************************************************************/ 137 uint8_t BTM_SecClrServiceByPsm(uint16_t psm); 138 139 /******************************************************************************* 140 * 141 * Function BTM_PINCodeReply 142 * 143 * Description This function is called after Security Manager submitted 144 * PIN code request to the UI. 145 * 146 * Parameters: bd_addr - Address of the device for which PIN was 147 * requested 148 * res - result of the operation tBTM_STATUS::BTM_SUCCESS 149 * if success 150 * pin_len - length in bytes of the PIN Code 151 * p_pin - pointer to array with the PIN Code 152 * 153 ******************************************************************************/ 154 void BTM_PINCodeReply(const RawAddress& bd_addr, tBTM_STATUS res, uint8_t pin_len, uint8_t* p_pin); 155 156 /******************************************************************************* 157 * 158 * Function btm_sec_bond_by_transport 159 * 160 * Description this is the bond function that will start either SSP or SMP. 161 * 162 * Parameters: bd_addr - Address of the device to bond 163 * pin_len - length in bytes of the PIN Code 164 * p_pin - pointer to array with the PIN Code 165 * 166 * Note: After 2.1 parameters are not used and preserved here not to change API 167 ******************************************************************************/ 168 tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, 169 tBT_TRANSPORT transport); 170 171 /******************************************************************************* 172 * 173 * Function BTM_SecBond 174 * 175 * Description This function is called to perform bonding with peer device. 176 * If the connection is already up, but not secure, pairing 177 * is attempted. If already paired tBTM_STATUS::BTM_SUCCESS is returned. 178 * 179 * Parameters: bd_addr - Address of the device to bond 180 * transport - doing SSP over BR/EDR or SMP over LE 181 * 182 * Note: After 2.1 parameters are not used and preserved here not to change API 183 ******************************************************************************/ 184 tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, 185 tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type); 186 187 /******************************************************************************* 188 * 189 * Function BTM_SecBondCancel 190 * 191 * Description This function is called to cancel ongoing bonding process 192 * with peer device. 193 * 194 * Parameters: bd_addr - Address of the peer device 195 * transport - false for BR/EDR link; true for LE link 196 * 197 ******************************************************************************/ 198 tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr); 199 200 /******************************************************************************* 201 * 202 * Function BTM_SecGetDeviceLinkKeyType 203 * 204 * Description This function is called to obtain link key type for the 205 * device. 206 * it returns tBTM_STATUS::BTM_SUCCESS if link key is available, or 207 * tBTM_STATUS::BTM_UNKNOWN_ADDR if Security Manager does not know about 208 * the device or device record does not contain link key info 209 * 210 * Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type 211 * otherwise. 212 * 213 ******************************************************************************/ 214 tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(const RawAddress& bd_addr); 215 216 /******************************************************************************* 217 * 218 * Function BTM_SetEncryption 219 * 220 * Description This function is called to ensure that connection is 221 * encrypted. Should be called only on an open connection. 222 * Typically only needed for connections that first want to 223 * bring up unencrypted links, then later encrypt them. 224 * 225 * Parameters: bd_addr - Address of the peer device 226 * transport - Link transport 227 * p_callback - Pointer to callback function called if 228 * this function returns PENDING after required 229 * procedures are completed. Can be set to 230 * NULL if status is not desired. 231 * p_ref_data - pointer to any data the caller wishes to 232 * receive in the callback function upon 233 * completion. can be set to NULL if not used. 234 * sec_act - LE security action, unused for BR/EDR 235 * 236 * Returns tBTM_STATUS::BTM_SUCCESS - already encrypted 237 * BTM_PENDING - command will be returned in the callback 238 * tBTM_STATUS::BTM_WRONG_MODE- connection not up. 239 * tBTM_STATUS::BTM_BUSY - security procedures are currently active 240 * tBTM_STATUS::BTM_ERR_KEY_MISSING - link key is missing. 241 * tBTM_STATUS::BTM_MODE_UNSUPPORTED - if security manager not linked in. 242 * 243 ******************************************************************************/ 244 tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr, tBT_TRANSPORT transport, 245 tBTM_SEC_CALLBACK* p_callback, void* p_ref_data, 246 tBTM_BLE_SEC_ACT sec_act); 247 248 bool BTM_SecIsLeSecurityPending(const RawAddress& bd_addr); 249 250 /******************************************************************************* 251 * 252 * Function BTM_ConfirmReqReply 253 * 254 * Description This function is called to confirm the numeric value for 255 * Simple Pairing in response to BTM_SP_CFM_REQ_EVT 256 * 257 * Parameters: res - result of the operation tBTM_STATUS::BTM_SUCCESS if 258 * success 259 * bd_addr - Address of the peer device 260 * 261 ******************************************************************************/ 262 void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr); 263 264 /******************************************************************************* 265 * 266 * Function BTM_PasskeyReqReply 267 * 268 * Description This function is called to provide the passkey for 269 * Simple Pairing in response to BTM_SP_KEY_REQ_EVT 270 * 271 * Parameters: res - result of the operation tBTM_STATUS::BTM_SUCCESS if success 272 * bd_addr - Address of the peer device 273 * passkey - numeric value in the range of 274 * BTM_MIN_PASSKEY_VAL(0) - 275 * BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 276 * 277 ******************************************************************************/ 278 void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr, uint32_t passkey); 279 280 /******************************************************************************* 281 * 282 * Function BTM_ReadLocalOobData 283 * 284 * Description This function is called to read the local OOB data from 285 * LM 286 * 287 ******************************************************************************/ 288 void BTM_ReadLocalOobData(void); 289 290 /******************************************************************************* 291 * 292 * Function BTM_RemoteOobDataReply 293 * 294 * Description This function is called to provide the remote OOB data for 295 * Simple Pairing in response to BTM_SP_RMT_OOB_EVT 296 * 297 * Parameters: bd_addr - Address of the peer device 298 * c - simple pairing Hash C. 299 * r - simple pairing Randomizer C. 300 * 301 ******************************************************************************/ 302 void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr, const Octet16& c, 303 const Octet16& r); 304 305 /******************************************************************************* 306 * 307 * Function BTM_PeerSupportsSecureConnections 308 * 309 * Description This function is called to check if the peer supports 310 * BR/EDR Secure Connections. 311 * 312 * Parameters: bd_addr - address of the peer 313 * 314 * Returns true if BR/EDR Secure Connections are supported by the peer, 315 * else false. 316 * 317 ******************************************************************************/ 318 bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr); 319 320 /******************************************************************************* 321 * 322 * Function BTM_GetInitialSecurityMode 323 * 324 * Description This function is called to retrieve the configured 325 * security mode. 326 * 327 ******************************************************************************/ 328 uint8_t BTM_GetSecurityMode(); 329 330 /******************************************************************************* 331 * 332 * Function btm_sec_l2cap_access_req 333 * 334 * Description This function is called by the L2CAP to grant permission to 335 * establish L2CAP connection to or from the peer device. 336 * 337 * Parameters: bd_addr - Address of the peer device 338 * psm - L2CAP PSM 339 * is_originator - true if protocol above L2CAP originates 340 * connection 341 * p_callback - Pointer to callback function called if 342 * this function returns PENDING after required 343 * procedures are complete. MUST NOT BE NULL. 344 * 345 * Returns tBTM_STATUS 346 * 347 ******************************************************************************/ 348 tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, uint16_t psm, bool is_originator, 349 tBTM_SEC_CALLBACK* p_callback, void* p_ref_data); 350 351 // Allow enforcing security by specific requirement (from shim layer). 352 tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(const RawAddress& bd_addr, 353 uint16_t security_required, bool is_originator, 354 tBTM_SEC_CALLBACK* p_callback, 355 void* p_ref_data); 356 357 /******************************************************************************* 358 * 359 * Function btm_sec_mx_access_request 360 * 361 * Description This function is called by all Multiplexing Protocols 362 *during establishing connection to or from peer device to grant permission 363 *to establish application connection. 364 * 365 * Parameters: bd_addr - Address of the peer device 366 * psm - L2CAP PSM 367 * is_originator - true if protocol above L2CAP originates 368 * connection 369 * mx_proto_id - protocol ID of the multiplexer 370 * mx_chan_id - multiplexer channel to reach application 371 * p_callback - Pointer to callback function called if 372 * this function returns PENDING after 373 *required procedures are completed p_ref_data - Pointer to any reference 374 *data needed by the the callback function. 375 * 376 * Returns tBTM_STATUS::BTM_CMD_STARTED 377 * 378 ******************************************************************************/ 379 tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr, bool is_originator, 380 uint16_t security_requirement, tBTM_SEC_CALLBACK* p_callback, 381 void* p_ref_data); 382 383 /******************************************************************************* 384 * 385 * Function btm_sec_conn_req 386 * 387 * Description This function is when the peer device is requesting 388 * connection 389 * 390 * Returns void 391 * 392 ******************************************************************************/ 393 void btm_sec_conn_req(const RawAddress& bda, const DEV_CLASS dc); 394 395 /******************************************************************************* 396 * 397 * Function btm_create_conn_cancel_complete 398 * 399 * Description This function is called when the command complete message 400 * is received from the HCI for the create connection cancel 401 * command. 402 * 403 * Returns void 404 * 405 ******************************************************************************/ 406 void btm_create_conn_cancel_complete(uint8_t status, const RawAddress bd_addr); 407 408 /******************************************************************************* 409 * 410 * Function btm_sec_dev_reset 411 * 412 * Description This function should be called after device reset 413 * 414 * Returns void 415 * 416 ******************************************************************************/ 417 void btm_sec_dev_reset(void); 418 419 /******************************************************************************* 420 * 421 * Function btm_sec_abort_access_req 422 * 423 * Description This function is called by the L2CAP or RFCOMM to abort 424 * the pending operation. 425 * 426 * Parameters: bd_addr - Address of the peer device 427 * 428 * Returns void 429 * 430 ******************************************************************************/ 431 void btm_sec_abort_access_req(const RawAddress& bd_addr); 432 433 /******************************************************************************* 434 * 435 * Function btm_sec_rmt_name_request_complete 436 * 437 * Description This function is called when remote name was obtained from 438 * the peer device 439 * 440 * Returns void 441 * 442 ******************************************************************************/ 443 void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_t* p_bd_name, 444 tHCI_STATUS status); 445 446 /******************************************************************************* 447 * 448 * Function btm_sec_rmt_host_support_feat_evt 449 * 450 * Description This function is called when the 451 * HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT is received 452 * 453 * Returns void 454 * 455 ******************************************************************************/ 456 void btm_sec_rmt_host_support_feat_evt(const RawAddress bd_addr, uint8_t features_0); 457 458 /******************************************************************************* 459 * 460 * Function btm_io_capabilities_req 461 * 462 * Description This function is called when LM request for the IO 463 * capability of the local device and 464 * if the OOB data is present for the device in the event 465 * 466 * Returns void 467 * 468 ******************************************************************************/ 469 void btm_io_capabilities_req(RawAddress p); 470 471 /******************************************************************************* 472 * 473 * Function btm_io_capabilities_rsp 474 * 475 * Description This function is called when the IO capability of the 476 * specified device is received 477 * 478 * Returns void 479 * 480 ******************************************************************************/ 481 void btm_io_capabilities_rsp(const tBTM_SP_IO_RSP evt_data); 482 483 /******************************************************************************* 484 * 485 * Function btm_proc_sp_req_evt 486 * 487 * Description This function is called to process/report 488 * HCI_USER_CONFIRMATION_REQUEST_EVT 489 * or HCI_USER_PASSKEY_REQUEST_EVT 490 * or HCI_USER_PASSKEY_NOTIFY_EVT 491 * 492 * Returns void 493 * 494 ******************************************************************************/ 495 void btm_proc_sp_req_evt(tBTM_SP_EVT event, const RawAddress bda, uint32_t value); 496 497 /******************************************************************************* 498 * 499 * Function btm_simple_pair_complete 500 * 501 * Description This function is called when simple pairing process is 502 * complete 503 * 504 * Returns void 505 * 506 ******************************************************************************/ 507 void btm_simple_pair_complete(const RawAddress bd_addr, uint8_t status); 508 509 /******************************************************************************* 510 * 511 * Function btm_rem_oob_req 512 * 513 * Description This function is called to process/report 514 * HCI_REMOTE_OOB_DATA_REQUEST_EVT 515 * 516 * Returns void 517 * 518 ******************************************************************************/ 519 void btm_rem_oob_req(const RawAddress bd_addr); 520 521 /******************************************************************************* 522 * 523 * Function btm_read_local_oob_complete 524 * 525 * Description This function is called when read local oob data is 526 * completed by the LM 527 * 528 * Returns void 529 * 530 ******************************************************************************/ 531 void btm_read_local_oob_complete(const tBTM_SP_LOC_OOB evt_data); 532 533 /******************************************************************************* 534 * 535 * Function btm_sec_auth_complete 536 * 537 * Description This function is when authentication of the connection is 538 * completed by the LM 539 * 540 * Returns void 541 * 542 ******************************************************************************/ 543 void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status); 544 545 /******************************************************************************* 546 * 547 * Function btm_sec_encryption_change_evt 548 * 549 * Description This function is called to process an encryption change. 550 * 551 * Returns void 552 * 553 ******************************************************************************/ 554 void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable, 555 uint8_t key_size); 556 557 /******************************************************************************* 558 * 559 * Function btm_sec_encrypt_change 560 * 561 * Description This function is when encryption of the connection is 562 * completed by the LM 563 * 564 * Returns void 565 * 566 ******************************************************************************/ 567 void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable, 568 uint8_t key_size, bool from_key_refresh); 569 570 /******************************************************************************* 571 * 572 * Function btm_sec_connected 573 * 574 * Description This function is when a connection to the peer device is 575 * established 576 * 577 * Returns void 578 * 579 ******************************************************************************/ 580 void btm_sec_connected(const RawAddress& bda, uint16_t handle, tHCI_STATUS status, uint8_t enc_mode, 581 tHCI_ROLE assigned_role = HCI_ROLE_PERIPHERAL); 582 583 /******************************************************************************* 584 * 585 * Function btm_sec_disconnect 586 * 587 * Description This function is called to disconnect HCI link 588 * 589 * Returns btm status 590 * 591 ******************************************************************************/ 592 tBTM_STATUS btm_sec_disconnect(uint16_t handle, tHCI_STATUS reason, std::string); 593 594 /******************************************************************************* 595 * 596 * Function btm_sec_disconnected 597 * 598 * Description This function is when a connection to the peer device is 599 * dropped 600 * 601 * Returns void 602 * 603 ******************************************************************************/ 604 void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason, std::string comment); 605 606 /******************************************************************************* 607 * 608 * Function btm_sec_role_changed 609 * 610 * Description This function is called when receiving an HCI role change 611 * event 612 * 613 * Returns void 614 * 615 ******************************************************************************/ 616 void btm_sec_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr, tHCI_ROLE new_role); 617 618 /** This function is called when a new connection link key is generated */ 619 void btm_sec_link_key_notification(const RawAddress& p_bda, const Octet16& link_key, 620 uint8_t key_type); 621 622 /** This function is called for each encryption key refresh complete event */ 623 void btm_sec_encryption_key_refresh_complete(uint16_t handle, tHCI_STATUS status); 624 625 /******************************************************************************* 626 * 627 * Function btm_sec_link_key_request 628 * 629 * Description This function is called when controller requests link key 630 * 631 * Returns Pointer to the record or NULL 632 * 633 ******************************************************************************/ 634 void btm_sec_link_key_request(const RawAddress bda); 635 636 /******************************************************************************* 637 * 638 * Function btm_sec_pin_code_request 639 * 640 * Description This function is called when controller requests PIN code 641 * 642 * Returns Pointer to the record or NULL 643 * 644 ******************************************************************************/ 645 void btm_sec_pin_code_request(const RawAddress bda); 646 647 /******************************************************************************* 648 * 649 * Function btm_sec_update_clock_offset 650 * 651 * Description This function is called to update clock offset 652 * 653 * Returns void 654 * 655 ******************************************************************************/ 656 void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset); 657 658 /******************************************************************************* 659 * 660 * Function btm_sec_dev_rec_cback_event 661 * 662 * Description This function calls the callback function with the given 663 * result and clear the callback function. 664 * 665 * Parameters: void 666 * 667 ******************************************************************************/ 668 void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, tBTM_STATUS res, 669 bool is_le_transport); 670 671 /******************************************************************************* 672 * 673 * Function btm_sec_clear_ble_keys 674 * 675 * Description This function is called to clear out the BLE keys. 676 * Typically when devices are removed in BTM_SecDeleteDevice, 677 * or when a new BT Link key is generated. 678 * 679 * Returns void 680 * 681 ******************************************************************************/ 682 void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec); 683 684 /******************************************************************************* 685 * 686 * Function btm_sec_is_a_bonded_dev 687 * 688 * Description Is the specified device is a bonded device 689 * 690 * Returns true - dev is bonded 691 * 692 ******************************************************************************/ 693 bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 694 695 /******************************************************************************* 696 * 697 * Function btm_sec_set_peer_sec_caps 698 * 699 * Description This function is called to set sm4 and rmt_sec_caps fields 700 * based on the available peer device features. 701 * 702 * Returns void 703 * 704 ******************************************************************************/ 705 void btm_sec_set_peer_sec_caps(uint16_t hci_handle, bool ssp_supported, bool sc_supported, 706 bool hci_role_switch_supported, bool br_edr_supported, 707 bool le_supported); 708 709 /******************************************************************************* 710 * 711 * Function btm_sec_cr_loc_oob_data_cback_event 712 * 713 * Description This function is called to pass the local oob up to caller 714 * 715 * Returns void 716 * 717 ******************************************************************************/ 718 void btm_sec_cr_loc_oob_data_cback_event(const RawAddress& address, tSMP_LOC_OOB_DATA loc_oob_data); 719 720 // Return DEV_CLASS of bda. If record doesn't exist, create one. 721 DEV_CLASS btm_get_dev_class(const RawAddress& bda); 722