• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 the SMP API function external definitions.
22  *
23  ******************************************************************************/
24 #ifndef SMP_API_H
25 #define SMP_API_H
26 
27 #include <cstdint>
28 
29 #include "bt_target.h"
30 #include "smp_api_types.h"
31 #include "types/bt_transport.h"
32 #include "types/raw_address.h"
33 
34 /*****************************************************************************
35  *  External Function Declarations
36  ****************************************************************************/
37 /* API of SMP */
38 
39 /*******************************************************************************
40  *
41  * Function         SMP_Init
42  *
43  * Description      This function initializes the SMP unit.
44  *
45  * Returns          void
46  *
47  ******************************************************************************/
48 void SMP_Init(void);
49 
50 /*******************************************************************************
51  *
52  * Function         SMP_SetTraceLevel
53  *
54  * Description      This function sets the trace level for SMP.  If called with
55  *                  a value of 0xFF, it simply returns the current trace level.
56  *
57  * Returns          The new or current trace level
58  *
59  ******************************************************************************/
60 uint8_t SMP_SetTraceLevel(uint8_t new_level);
61 
62 /*******************************************************************************
63  *
64  * Function         SMP_Register
65  *
66  * Description      This function register for the SMP service callback.
67  *
68  * Returns          void
69  *
70  ******************************************************************************/
71 bool SMP_Register(tSMP_CALLBACK* p_cback);
72 
73 /*******************************************************************************
74  *
75  * Function         SMP_Pair
76  *
77  * Description      This function is called to start a SMP pairing.
78  *
79  * Returns          SMP_STARTED if bond started, else otherwise exception.
80  *
81  ******************************************************************************/
82 tSMP_STATUS SMP_Pair(const RawAddress& bd_addr);
83 tSMP_STATUS SMP_Pair(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type);
84 
85 /*******************************************************************************
86  *
87  * Function         SMP_BR_PairWith
88  *
89  * Description      This function is called to start a SMP pairing over BR/EDR.
90  *
91  * Returns          SMP_STARTED if pairing started, otherwise the reason for the
92  *                  failure.
93  *
94  ******************************************************************************/
95 tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr);
96 
97 /*******************************************************************************
98  *
99  * Function         SMP_PairCancel
100  *
101  * Description      This function is called to cancel a SMP pairing.
102  *
103  * Returns          true - pairing cancelled
104  *
105  ******************************************************************************/
106 bool SMP_PairCancel(const RawAddress& bd_addr);
107 
108 /*******************************************************************************
109  *
110  * Function         SMP_SecurityGrant
111  *
112  * Description      This function is called to grant security process.
113  *
114  * Parameters       bd_addr - peer device bd address.
115  *                  res     - result of the operation SMP_SUCCESS if success.
116  *                            Otherwise, SMP_REPEATED_ATTEMPTS is too many
117  *                            attempts.
118  *
119  * Returns          None
120  *
121  ******************************************************************************/
122 void SMP_SecurityGrant(const RawAddress& bd_addr, tSMP_STATUS res);
123 
124 /*******************************************************************************
125  *
126  * Function         SMP_PasskeyReply
127  *
128  * Description      This function is called after Security Manager submitted
129  *                  Passkey request to the application.
130  *
131  * Parameters:      bd_addr  - Address of the device for which PIN was requested
132  *                  res      - result of the operation SMP_SUCCESS if success
133  *                  passkey  - numeric value in the range of
134  *                             BTM_MIN_PASSKEY_VAL(0) -
135  *                             BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
136  *
137  ******************************************************************************/
138 void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res, uint32_t passkey);
139 
140 /*******************************************************************************
141  *
142  * Function         SMP_ConfirmReply
143  *
144  * Description      This function is called after Security Manager submitted
145  *                  numeric comparison request to the application.
146  *
147  * Parameters:      bd_addr      - Address of the device with which numeric
148  *                                 comparison was requested
149  *                  res          - comparison result SMP_SUCCESS if success
150  *
151  ******************************************************************************/
152 void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res);
153 
154 /*******************************************************************************
155  *
156  * Function         SMP_OobDataReply
157  *
158  * Description      This function is called to provide the OOB data for
159  *                  SMP in response to SMP_OOB_REQ_EVT
160  *
161  * Parameters:      bd_addr     - Address of the peer device
162  *                  res         - result of the operation SMP_SUCCESS if success
163  *                  p_data      - SM Randomizer  C.
164  *
165  ******************************************************************************/
166 void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, uint8_t len,
167                       uint8_t* p_data);
168 
169 /*******************************************************************************
170  *
171  * Function         SMP_SecureConnectionOobDataReply
172  *
173  * Description      This function is called to provide the SC OOB data for
174  *                  SMP in response to SMP_SC_OOB_REQ_EVT
175  *
176  * Parameters:      p_data      - pointer to the data
177  *
178  ******************************************************************************/
179 void SMP_SecureConnectionOobDataReply(uint8_t* p_data);
180 
181 /*******************************************************************************
182  *
183  * Function         SMP_CrLocScOobData
184  *
185  * Description      This function is called to generate a public key to be
186  *                  passed to a remote device via an Out of Band transport
187  *
188  * Returns          true if the request is successfully sent and executed by the
189  *                  state machine, false otherwise
190  *
191  ******************************************************************************/
192 bool SMP_CrLocScOobData();
193 
194 /*******************************************************************************
195  *
196  * Function         SMP_ClearLocScOobData
197  *
198  * Description      This function is called to clear out the OOB stored locally.
199  *
200  ******************************************************************************/
201 void SMP_ClearLocScOobData();
202 
203 // Called when LTK request is received from controller.
204 bool smp_proc_ltk_request(const RawAddress& bda);
205 
206 // Called when link is encrypted and notified to peripheral device.
207 // Proceed to send LTK, DIV and ER to central if bonding the devices.
208 void smp_link_encrypted(const RawAddress& bda, uint8_t encr_enable);
209 
210 #endif /* SMP_API_H */
211