• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2009-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 #ifndef BTIF_DM_H
20 #define BTIF_DM_H
21 
22 #include "bta/include/bta_api.h"
23 #include "bte_appl.h"
24 #include "btif_uid.h"
25 #include "types/raw_address.h"
26 
27 /*******************************************************************************
28  *  Functions
29  ******************************************************************************/
30 void btif_dm_init(uid_set_t* set);
31 void btif_dm_cleanup(void);
32 
33 /**
34  * BTIF callback to switch context from bte to btif
35  */
36 void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data);
37 
38 /**
39  * Notify BT disable being initiated. DM may chose to abort
40  * pending commands, like pairing
41  */
42 void btif_dm_on_disable(void);
43 
44 /**
45  * Callout for handling io_capabilities request
46  */
47 void btif_dm_proc_io_req(tBTM_AUTH_REQ* p_auth_req, bool is_orig);
48 /**
49  * Callout for handling io_capabilities response
50  */
51 void btif_dm_proc_io_rsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap,
52                          tBTM_OOB_DATA oob_data, tBTM_AUTH_REQ auth_req);
53 
54 /**
55  * Device Configuration Queries
56  */
57 void btif_dm_get_local_class_of_device(DEV_CLASS device_class);
58 
59 /**
60  * Out-of-band functions
61  */
62 void btif_dm_set_oob_for_io_req(tBTM_OOB_DATA* p_oob_data);
63 void btif_dm_set_oob_for_le_io_req(const RawAddress& bd_addr,
64                                    tBTM_OOB_DATA* p_oob_data,
65                                    tBTM_LE_AUTH_REQ* p_auth_req);
66 #ifdef BTIF_DM_OOB_TEST
67 void btif_dm_load_local_oob(void);
68 void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid,
69                           const Octet16& c, const Octet16& r);
70 bool btif_dm_proc_rmt_oob(const RawAddress& bd_addr, Octet16* p_c,
71                           Octet16* p_r);
72 void btif_dm_generate_local_oob_data(tBT_TRANSPORT transport);
73 #endif /* BTIF_DM_OOB_TEST */
74 
75 void btif_dm_clear_event_filter();
76 
77 void btif_dm_metadata_changed(const RawAddress& remote_bd_addr, int key,
78                               std::vector<uint8_t> value);
79 
80 /*callout for reading SMP properties from Text file*/
81 bool btif_dm_get_smp_config(tBTE_APPL_CFG* p_cfg);
82 
83 typedef struct {
84   bool is_penc_key_rcvd;
85   tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
86   bool is_pcsrk_key_rcvd;
87   tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
88   bool is_pid_key_rcvd;
89   tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
90   bool is_lenc_key_rcvd;
91   tBTM_LE_LENC_KEYS
92       lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
93   bool is_lcsrk_key_rcvd;
94   tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
95   bool is_lidk_key_rcvd;        /* local identity key received */
96 } btif_dm_ble_cb_t;
97 
98 #define BTIF_DM_LE_LOCAL_KEY_IR (1 << 0)
99 #define BTIF_DM_LE_LOCAL_KEY_IRK (1 << 1)
100 #define BTIF_DM_LE_LOCAL_KEY_DHK (1 << 2)
101 #define BTIF_DM_LE_LOCAL_KEY_ER (1 << 3)
102 
103 void btif_dm_load_ble_local_keys(void);
104 void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask,
105                                 Octet16* p_er,
106                                 tBTA_BLE_LOCAL_ID_KEYS* p_id_keys);
107 void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr,
108                                           BD_NAME bd_name,
109                                           tBT_DEVICE_TYPE dev_type);
110 
111 bool check_cod_hid(const RawAddress& bd_addr);
112 #endif
113