1 /******************************************************************************
2 *
3 * Copyright (C) 2008-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 implementation of the SMP interface used by
22 * applications that can run over an SMP.
23 *
24 ******************************************************************************/
25 #include <string.h>
26
27 #include "common/bt_target.h"
28 //#include "bt_utils.h"
29 #if SMP_INCLUDED == TRUE
30 #include "smp_int.h"
31 #include "stack/smp_api.h"
32 #include "stack/l2cdefs.h"
33 #include "l2c_int.h"
34 #include "btm_int.h"
35 #include "stack/hcimsgs.h"
36
37 #include "stack/btu.h"
38 #include "p_256_ecc_pp.h"
39 #include "osi/allocator.h"
40
41 /*******************************************************************************
42 **
43 ** Function SMP_Init
44 **
45 ** Description This function initializes the SMP unit.
46 **
47 ** Returns void
48 **
49 *******************************************************************************/
SMP_Init(void)50 void SMP_Init(void)
51 {
52 #if SMP_DYNAMIC_MEMORY
53 smp_cb_ptr = (tSMP_CB *)osi_malloc(sizeof(tSMP_CB));
54 curve_ptr = (elliptic_curve_t *)osi_malloc(sizeof(elliptic_curve_t));
55 curve_p256_ptr = (elliptic_curve_t *)osi_malloc(sizeof(elliptic_curve_t));
56 #endif
57 memset(&smp_cb, 0, sizeof(tSMP_CB));
58 memset(&curve, 0, sizeof(elliptic_curve_t));
59 memset(&curve_p256, 0, sizeof(elliptic_curve_t));
60
61 #if defined(SMP_INITIAL_TRACE_LEVEL)
62 smp_cb.trace_level = SMP_INITIAL_TRACE_LEVEL;
63 #else
64 smp_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
65 #endif
66 SMP_TRACE_EVENT ("%s", __FUNCTION__);
67
68 smp_l2cap_if_init();
69 /* initialization of P-256 parameters */
70 p_256_init_curve(KEY_LENGTH_DWORDS_P256);
71 }
72
SMP_Free(void)73 void SMP_Free(void)
74 {
75 memset(&smp_cb, 0, sizeof(tSMP_CB));
76 #if SMP_DYNAMIC_MEMORY
77 FREE_AND_RESET(smp_cb_ptr);
78 FREE_AND_RESET(curve_ptr);
79 FREE_AND_RESET(curve_p256_ptr);
80 #endif /* #if SMP_DYNAMIC_MEMORY */
81 }
82
83
84 /*******************************************************************************
85 **
86 ** Function SMP_SetTraceLevel
87 **
88 ** Description This function sets the trace level for SMP. If called with
89 ** a value of 0xFF, it simply returns the current trace level.
90 **
91 ** Input Parameters:
92 ** level: The level to set the GATT tracing to:
93 ** 0xff-returns the current setting.
94 ** 0-turns off tracing.
95 ** >= 1-Errors.
96 ** >= 2-Warnings.
97 ** >= 3-APIs.
98 ** >= 4-Events.
99 ** >= 5-Debug.
100 **
101 ** Returns The new or current trace level
102 **
103 *******************************************************************************/
SMP_SetTraceLevel(UINT8 new_level)104 extern UINT8 SMP_SetTraceLevel (UINT8 new_level)
105 {
106 if (new_level != 0xFF) {
107 smp_cb.trace_level = new_level;
108 }
109
110 return (smp_cb.trace_level);
111 }
112
113
114 /*******************************************************************************
115 **
116 ** Function SMP_Register
117 **
118 ** Description This function register for the SMP services callback.
119 **
120 ** Returns void
121 **
122 *******************************************************************************/
SMP_Register(tSMP_CALLBACK * p_cback)123 BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback)
124 {
125 SMP_TRACE_EVENT ("SMP_Register state=%d", smp_cb.state);
126
127 if (smp_cb.p_callback != NULL) {
128 SMP_TRACE_ERROR ("SMP_Register: duplicate registration, overwrite it");
129 }
130 smp_cb.p_callback = p_cback;
131
132 return (TRUE);
133
134 }
135
136 /*******************************************************************************
137 **
138 ** Function SMP_Pair
139 **
140 ** Description This function call to perform a SMP pairing with peer device.
141 ** Device support one SMP pairing at one time.
142 **
143 ** Parameters bd_addr - peer device bd address.
144 **
145 ** Returns None
146 **
147 *******************************************************************************/
SMP_Pair(BD_ADDR bd_addr)148 tSMP_STATUS SMP_Pair (BD_ADDR bd_addr)
149 {
150 tSMP_CB *p_cb = &smp_cb;
151 UINT8 status = SMP_PAIR_INTERNAL_ERR;
152
153 SMP_TRACE_EVENT ("%s state=%d br_state=%d flag=0x%x \n",
154 __FUNCTION__, p_cb->state, p_cb->br_state, p_cb->flags);
155 if (p_cb->state != SMP_STATE_IDLE || p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD ||
156 p_cb->smp_over_br) {
157 /* pending security on going, reject this one */
158 return SMP_BUSY;
159 } else {
160 p_cb->flags = SMP_PAIR_FLAGS_WE_STARTED_DD;
161
162 memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
163
164 if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) {
165 SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__);
166 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
167 return status;
168 }
169
170 return SMP_STARTED;
171 }
172 }
173
174 /*******************************************************************************
175 **
176 ** Function SMP_BR_PairWith
177 **
178 ** Description This function is called to start a SMP pairing over BR/EDR.
179 ** Device support one SMP pairing at one time.
180 **
181 ** Parameters bd_addr - peer device bd address.
182 **
183 ** Returns SMP_STARTED if pairing started, otherwise reason for failure.
184 **
185 *******************************************************************************/
186 #if (CLASSIC_BT_INCLUDED == TRUE)
SMP_BR_PairWith(BD_ADDR bd_addr)187 tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr)
188 {
189 tSMP_CB *p_cb = &smp_cb;
190 UINT8 status = SMP_PAIR_INTERNAL_ERR;
191
192 SMP_TRACE_EVENT ("%s state=%d br_state=%d flag=0x%x ",
193 __func__, p_cb->state, p_cb->br_state, p_cb->flags);
194
195 if (p_cb->state != SMP_STATE_IDLE ||
196 p_cb->smp_over_br ||
197 p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD) {
198 /* pending security on going, reject this one */
199 return SMP_BUSY;
200 }
201
202 p_cb->role = HCI_ROLE_MASTER;
203 p_cb->flags = SMP_PAIR_FLAGS_WE_STARTED_DD;
204 p_cb->smp_over_br = TRUE;
205
206 memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
207
208 if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) {
209 SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__);
210 smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status);
211 return status;
212 }
213
214 return SMP_STARTED;
215 }
216 #endif ///CLASSIC_BT_INCLUDED == TRUE
217
218 /*******************************************************************************
219 **
220 ** Function SMP_PairCancel
221 **
222 ** Description This function call to cancel a SMP pairing with peer device.
223 **
224 ** Parameters bd_addr - peer device bd address.
225 **
226 ** Returns TRUE - Pairining is cancelled
227 **
228 *******************************************************************************/
SMP_PairCancel(BD_ADDR bd_addr)229 BOOLEAN SMP_PairCancel (BD_ADDR bd_addr)
230 {
231 tSMP_CB *p_cb = &smp_cb;
232 UINT8 err_code = SMP_PAIR_FAIL_UNKNOWN;
233 BOOLEAN status = FALSE;
234
235 BTM_TRACE_EVENT ("SMP_CancelPair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
236 if ( (p_cb->state != SMP_STATE_IDLE) &&
237 (!memcmp (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN)) ) {
238 p_cb->is_pair_cancel = TRUE;
239 SMP_TRACE_DEBUG("Cancel Pairing: set fail reason Unknown");
240 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &err_code);
241 status = TRUE;
242 }
243
244 return status;
245 }
246 /*******************************************************************************
247 **
248 ** Function SMP_SecurityGrant
249 **
250 ** Description This function is called to grant security process.
251 **
252 ** Parameters bd_addr - peer device bd address.
253 ** res - result of the operation SMP_SUCCESS if success.
254 ** Otherwise, SMP_REPEATED_ATTEMPTS is too many attempts.
255 **
256 ** Returns None
257 **
258 *******************************************************************************/
SMP_SecurityGrant(BD_ADDR bd_addr,UINT8 res)259 void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res)
260 {
261 SMP_TRACE_EVENT ("SMP_SecurityGrant ");
262
263 #if (CLASSIC_BT_INCLUDED == TRUE)
264 if (smp_cb.smp_over_br) {
265 if (smp_cb.br_state != SMP_BR_STATE_WAIT_APP_RSP ||
266 smp_cb.cb_evt != SMP_SEC_REQUEST_EVT ||
267 memcmp (smp_cb.pairing_bda, bd_addr, BD_ADDR_LEN)) {
268 return;
269 }
270
271 /* clear the SMP_SEC_REQUEST_EVT event after get grant */
272 /* avoid generating duplicate pair request */
273 smp_cb.cb_evt = 0;
274 smp_br_state_machine_event(&smp_cb, SMP_BR_API_SEC_GRANT_EVT, &res);
275 return;
276 }
277 #endif ///CLASSIC_BT_INCLUDED == TRUE
278
279 if (smp_cb.state != SMP_STATE_WAIT_APP_RSP ||
280 smp_cb.cb_evt != SMP_SEC_REQUEST_EVT ||
281 memcmp (smp_cb.pairing_bda, bd_addr, BD_ADDR_LEN)) {
282 return;
283 }
284 /* clear the SMP_SEC_REQUEST_EVT event after get grant */
285 /* avoid generate duplicate pair request */
286 smp_cb.cb_evt = 0;
287 smp_sm_event(&smp_cb, SMP_API_SEC_GRANT_EVT, &res);
288 }
289
290 /*******************************************************************************
291 **
292 ** Function SMP_PasskeyReply
293 **
294 ** Description This function is called after Security Manager submitted
295 ** passkey request to the application.
296 **
297 ** Parameters: bd_addr - Address of the device for which passkey was requested
298 ** res - result of the operation SMP_SUCCESS if success
299 ** passkey - numeric value in the range of
300 ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
301 **
302 *******************************************************************************/
SMP_PasskeyReply(BD_ADDR bd_addr,UINT8 res,UINT32 passkey)303 void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey)
304 {
305 tSMP_CB *p_cb = & smp_cb;
306 UINT8 failure = SMP_PASSKEY_ENTRY_FAIL;
307
308 SMP_TRACE_EVENT ("SMP_PasskeyReply: Key: %d Result:%d",
309 passkey, res);
310
311 /* If timeout already expired or has been canceled, ignore the reply */
312 if (p_cb->cb_evt != SMP_PASSKEY_REQ_EVT) {
313 SMP_TRACE_WARNING ("SMP_PasskeyReply() - Wrong State: %d", p_cb->state);
314 return;
315 }
316
317 if (memcmp (bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) != 0) {
318 SMP_TRACE_ERROR ("SMP_PasskeyReply() - Wrong BD Addr");
319 return;
320 }
321
322 if (btm_find_dev (bd_addr) == NULL) {
323 SMP_TRACE_ERROR ("SMP_PasskeyReply() - no dev CB");
324 return;
325 }
326
327 if (passkey > BTM_MAX_PASSKEY_VAL || res != SMP_SUCCESS) {
328 SMP_TRACE_WARNING ("SMP_PasskeyReply() - Wrong key len: %d or passkey entry fail", passkey);
329 /* send pairing failure */
330 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
331
332 } else if (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_PASSKEY_ENT) {
333 smp_sm_event(&smp_cb, SMP_SC_KEY_READY_EVT, &passkey);
334 } else {
335 smp_convert_string_to_tk(p_cb->tk, passkey);
336 }
337
338 return;
339 }
340
341 /*******************************************************************************
342 **
343 ** Function SMP_SetStaticPasskey
344 **
345 ** Description This function is called to set static passkey
346 **
347 **
348 ** Parameters: add - set static passkey when add is TRUE
349 ** clear static passkey when add is FALSE
350 ** passkey - static passkey
351 **
352 **
353 *******************************************************************************/
SMP_SetStaticPasskey(BOOLEAN add,UINT32 passkey)354 void SMP_SetStaticPasskey (BOOLEAN add, UINT32 passkey)
355 {
356 SMP_TRACE_DEBUG("static passkey %6d", passkey);
357 tSMP_CB *p_cb = & smp_cb;
358 if(add) {
359 p_cb->static_passkey = passkey;
360 p_cb->use_static_passkey = true;
361 } else {
362 p_cb->static_passkey = 0;
363 p_cb->use_static_passkey = false;
364 }
365 }
366
367 /*******************************************************************************
368 **
369 ** Function SMP_ConfirmReply
370 **
371 ** Description This function is called after Security Manager submitted
372 ** numeric comparison request to the application.
373 **
374 ** Parameters: bd_addr - Address of the device with which numeric
375 ** comparison was requested
376 ** res - comparison result SMP_SUCCESS if success
377 **
378 *******************************************************************************/
SMP_ConfirmReply(BD_ADDR bd_addr,UINT8 res)379 void SMP_ConfirmReply (BD_ADDR bd_addr, UINT8 res)
380 {
381 tSMP_CB *p_cb = & smp_cb;
382 UINT8 failure = SMP_NUMERIC_COMPAR_FAIL;
383
384 SMP_TRACE_EVENT ("%s: Result:%d", __FUNCTION__, res);
385
386 /* If timeout already expired or has been canceled, ignore the reply */
387 if (p_cb->cb_evt != SMP_NC_REQ_EVT) {
388 SMP_TRACE_WARNING ("%s() - Wrong State: %d", __FUNCTION__, p_cb->state);
389 return;
390 }
391
392 if (memcmp (bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) != 0) {
393 SMP_TRACE_ERROR ("%s() - Wrong BD Addr", __FUNCTION__);
394 return;
395 }
396
397 if (btm_find_dev (bd_addr) == NULL) {
398 SMP_TRACE_ERROR ("%s() - no dev CB", __FUNCTION__);
399 return;
400 }
401
402 if (res != SMP_SUCCESS) {
403 SMP_TRACE_WARNING ("%s() - Numeric Comparison fails", __FUNCTION__);
404 /* send pairing failure */
405 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
406 } else {
407 smp_sm_event(p_cb, SMP_SC_NC_OK_EVT, NULL);
408 }
409 }
410
411 /*******************************************************************************
412 **
413 ** Function SMP_OobDataReply
414 **
415 ** Description This function is called to provide the OOB data for
416 ** SMP in response to SMP_OOB_REQ_EVT
417 **
418 ** Parameters: bd_addr - Address of the peer device
419 ** res - result of the operation SMP_SUCCESS if success
420 ** p_data - simple pairing Randomizer C.
421 **
422 *******************************************************************************/
SMP_OobDataReply(BD_ADDR bd_addr,tSMP_STATUS res,UINT8 len,UINT8 * p_data)423 void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len, UINT8 *p_data)
424 {
425 tSMP_CB *p_cb = & smp_cb;
426 UINT8 failure = SMP_OOB_FAIL;
427 tSMP_KEY key;
428
429 SMP_TRACE_EVENT ("%s State: %d res:%d", __FUNCTION__, smp_cb.state, res);
430
431 /* If timeout already expired or has been canceled, ignore the reply */
432 if (p_cb->state != SMP_STATE_WAIT_APP_RSP || p_cb->cb_evt != SMP_OOB_REQ_EVT) {
433 return;
434 }
435
436 if (res != SMP_SUCCESS || len == 0 || !p_data) {
437 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
438 } else {
439 if (len > BT_OCTET16_LEN) {
440 len = BT_OCTET16_LEN;
441 }
442
443 memcpy(p_cb->tk, p_data, len);
444
445 key.key_type = SMP_KEY_TYPE_TK;
446 key.p_data = p_cb->tk;
447
448 smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &key);
449 }
450 }
451
452 /*******************************************************************************
453 **
454 ** Function SMP_SecureConnectionOobDataReply
455 **
456 ** Description This function is called to provide the SC OOB data for
457 ** SMP in response to SMP_SC_OOB_REQ_EVT
458 **
459 ** Parameters: p_data - pointer to the data
460 **
461 *******************************************************************************/
SMP_SecureConnectionOobDataReply(UINT8 * p_data)462 void SMP_SecureConnectionOobDataReply(UINT8 *p_data)
463 {
464 tSMP_CB *p_cb = &smp_cb;
465
466 UINT8 failure = SMP_OOB_FAIL;
467 tSMP_SC_OOB_DATA *p_oob = (tSMP_SC_OOB_DATA *) p_data;
468 if (!p_oob) {
469 SMP_TRACE_ERROR("%s received no data", __FUNCTION__);
470 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
471 return;
472 }
473
474 SMP_TRACE_EVENT ("%s req_oob_type: %d, loc_oob_data.present: %d, "
475 "peer_oob_data.present: %d",
476 __FUNCTION__, p_cb->req_oob_type, p_oob->loc_oob_data.present,
477 p_oob->peer_oob_data.present);
478
479 if (p_cb->state != SMP_STATE_WAIT_APP_RSP || p_cb->cb_evt != SMP_SC_OOB_REQ_EVT) {
480 return;
481 }
482
483 BOOLEAN data_missing = FALSE;
484 switch (p_cb->req_oob_type) {
485 case SMP_OOB_PEER:
486 if (!p_oob->peer_oob_data.present) {
487 data_missing = TRUE;
488 }
489 break;
490 case SMP_OOB_LOCAL:
491 if (!p_oob->loc_oob_data.present) {
492 data_missing = TRUE;
493 }
494 break;
495 case SMP_OOB_BOTH:
496 if (!p_oob->loc_oob_data.present || !p_oob->peer_oob_data.present) {
497 data_missing = TRUE;
498 }
499 break;
500 default:
501 SMP_TRACE_EVENT ("Unexpected OOB data type requested. Fail OOB");
502 data_missing = TRUE;
503 break;
504 }
505
506 if (data_missing) {
507 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
508 return;
509 }
510
511 p_cb->sc_oob_data = *p_oob;
512
513 smp_sm_event(&smp_cb, SMP_SC_OOB_DATA_EVT, p_data);
514 }
515
516 /*******************************************************************************
517 **
518 ** Function SMP_Encrypt
519 **
520 ** Description This function is called to encrypt the data with the specified
521 ** key
522 **
523 ** Parameters: key - Pointer to key key[0] conatins the MSB
524 ** key_len - key length
525 ** plain_text - Pointer to data to be encrypted
526 ** plain_text[0] conatins the MSB
527 ** pt_len - plain text length
528 ** p_out - output of the encrypted texts
529 **
530 ** Returns Boolean - request is successful
531 *******************************************************************************/
SMP_Encrypt(UINT8 * key,UINT8 key_len,UINT8 * plain_text,UINT8 pt_len,tSMP_ENC * p_out)532 BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
533 UINT8 *plain_text, UINT8 pt_len,
534 tSMP_ENC *p_out)
535
536 {
537 BOOLEAN status = FALSE;
538 status = smp_encrypt_data(key, key_len, plain_text, pt_len, p_out);
539 return status;
540 }
541
542 /*******************************************************************************
543 **
544 ** Function SMP_KeypressNotification
545 **
546 ** Description This function is called to notify Security Manager about Keypress Notification.
547 **
548 ** Parameters: bd_addr Address of the device to send keypress notification to
549 ** value Keypress notification parameter value
550 **
551 *******************************************************************************/
SMP_KeypressNotification(BD_ADDR bd_addr,UINT8 value)552 void SMP_KeypressNotification (BD_ADDR bd_addr, UINT8 value)
553 {
554 tSMP_CB *p_cb = &smp_cb;
555
556 SMP_TRACE_EVENT ("%s: Value: %d", __FUNCTION__, value);
557
558 if (memcmp (bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) != 0) {
559 SMP_TRACE_ERROR ("%s() - Wrong BD Addr", __FUNCTION__);
560 return;
561 }
562
563 if (btm_find_dev (bd_addr) == NULL) {
564 SMP_TRACE_ERROR ("%s() - no dev CB", __FUNCTION__);
565 return;
566 }
567
568 /* Keypress Notification is used by a device with KeyboardOnly IO capabilities */
569 /* during the passkey entry protocol */
570 if (p_cb->local_io_capability != SMP_IO_CAP_IN) {
571 SMP_TRACE_ERROR ("%s() - wrong local IO capabilities %d",
572 __FUNCTION__, p_cb->local_io_capability);
573 return;
574 }
575
576 if (p_cb->selected_association_model != SMP_MODEL_SEC_CONN_PASSKEY_ENT) {
577 SMP_TRACE_ERROR ("%s() - wrong protocol %d", __FUNCTION__,
578 p_cb->selected_association_model);
579 return;
580 }
581
582 smp_sm_event(p_cb, SMP_KEYPRESS_NOTIFICATION_EVENT, &value);
583 }
584
585 /*******************************************************************************
586 **
587 ** Function SMP_CreateLocalSecureConnectionsOobData
588 **
589 ** Description This function is called to start creation of local SC OOB
590 ** data set (tSMP_LOC_OOB_DATA).
591 **
592 ** Parameters: bd_addr - Address of the device to send OOB data block to
593 **
594 ** Returns Boolean - TRUE: creation of local SC OOB data set started.
595 *******************************************************************************/
SMP_CreateLocalSecureConnectionsOobData(tBLE_BD_ADDR * addr_to_send_to)596 BOOLEAN SMP_CreateLocalSecureConnectionsOobData (tBLE_BD_ADDR *addr_to_send_to)
597 {
598 tSMP_CB *p_cb = &smp_cb;
599 #if (!CONFIG_BT_STACK_NO_LOG)
600 UINT8 *bd_addr;
601 #endif
602
603 if (addr_to_send_to == NULL) {
604 SMP_TRACE_ERROR ("%s addr_to_send_to is not provided", __FUNCTION__);
605 return FALSE;
606 }
607
608 #if (!CONFIG_BT_STACK_NO_LOG)
609 bd_addr = addr_to_send_to->bda;
610 #endif
611
612 SMP_TRACE_EVENT ("%s addr type: %u, BDA: %08x%04x, state: %u, br_state: %u",
613 __FUNCTION__, addr_to_send_to->type,
614 (bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
615 (bd_addr[4] << 8) + bd_addr[5],
616 p_cb->state,
617 p_cb->br_state);
618
619 if ((p_cb->state != SMP_STATE_IDLE) || (p_cb->smp_over_br)) {
620 SMP_TRACE_WARNING ("%s creation of local OOB data set "\
621 "starts only in IDLE state", __FUNCTION__);
622 return FALSE;
623 }
624
625 p_cb->sc_oob_data.loc_oob_data.addr_sent_to = *addr_to_send_to;
626 smp_sm_event(p_cb, SMP_CR_LOC_SC_OOB_DATA_EVT, NULL);
627
628 return TRUE;
629 }
630
631 #endif /* SMP_INCLUDED */
632